Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unusual indentation #20

Open
saloniig opened this issue Mar 30, 2021 · 6 comments
Open

Unusual indentation #20

saloniig opened this issue Mar 30, 2021 · 6 comments

Comments

@saloniig
Copy link

According to haiku guidelines every call to .AddGroup results in an extra indentation level for all things that go inside the group, until the next call to .End() but haiku-format removes indentation which is incorrect as shown below in code:
code

@owenca
Copy link
Owner

owenca commented Jun 12, 2021

See #19.

@owenca owenca closed this as completed Jun 12, 2021
@pulkomandy
Copy link

A work in progress version of the code for this is available here: https://github.com/saloniig/llvm-project/tree/wip_haiku_api

We have also found that clang-format has a somewhat similar feature: MacroBlockBegin and MacroBlockEnd are used to identify some specific macros and change the indentation of following lines as a result. Unfortunately, it is not usable directly in our case, because the methods we want to detect are part of a more complex statement. But I think it shows that such things are possible in clang-format, even if the parser does not have a deep understanding of the sourcecode.

I would suggest to reopen this issue because this seems quite important to using haiku-format on Haiku sourcecode. If we don't do this, a lot of code (everything related to building user interfaces) would need to be in "clang-format off" blocks, and this would reduce the usefulness of the tool a lot.

@owenca owenca reopened this Aug 10, 2021
@owenca
Copy link
Owner

owenca commented Aug 10, 2021

Also reopened #19.

@saloniig
Copy link
Author

Here is the link of the code for this issue :
saloniig/llvm-project@c63b4b2

@owenca
Copy link
Owner

owenca commented Aug 17, 2021

Can you create a PR at https://github.com/owenca/llvm-project/tree/haiku-format? Please also include the test case(s) you used. Thanks!

@owenca
Copy link
Owner

owenca commented Feb 25, 2024

Here is the link of the code for this issue : saloniig/llvm-project@c63b4b2

This breaks a lot of unit tests and causes segmentation faults:

[  FAILED  ] FormatTest.ShortCaseLabels (3 ms)
[  FAILED  ] FormatTest.MultiLineControlStatements (3 ms)
[  FAILED  ] FormatTest.FormatsEnumsWithErrors (1 ms)
[  FAILED  ] FormatTest.FormatsNamespaces (5 ms)
[  FAILED  ] FormatTest.NamespaceMacros (5 ms)
[  FAILED  ] FormatTest.FormatTryCatch (1 ms)
[  FAILED  ] FormatTest.FormatSEHTryCatch (1 ms)
[  FAILED  ] FormatTest.IncompleteTryCatchBlocks (1 ms)
[  FAILED  ] FormatTest.FormatTryCatchBraceStyles (3 ms)
[  FAILED  ] FormatTest.MacroCallsWithoutTrailingSemicolon (4 ms)
[  FAILED  ] FormatTest.FormatsJoinedLinesOnSubsequentRuns (0 ms)
[  FAILED  ] FormatTest.FormatBeginBlockEndMacros (1 ms)
[  FAILED  ] FormatTest.BreaksFunctionDeclarationsWithTrailingTokens (9 ms)
[  FAILED  ] FormatTest.FunctionAnnotations (3 ms)
[  FAILED  ] FormatTest.ReturnTypeBreakingStyle (11 ms)
[  FAILED  ] FormatTest.UnderstandsSquareAttributes (5 ms)
[  FAILED  ] FormatTest.AttributesAfterMacro (1 ms)
[  FAILED  ] FormatTest.BreaksLongVariableDeclarations (3 ms)
[  FAILED  ] FormatTest.IncorrectCodeMissingSemicolon (0 ms)
[  FAILED  ] FormatTest.KeepShortFunctionAfterPPElse (1 ms)
[  FAILED  ] FormatTest.DontSplitStringLiteralsWithEscapedNewlines (0 ms)
[  FAILED  ] FormatTest.AlignConsecutiveDeclarations (14 ms)
[  FAILED  ] FormatTest.StroustrupBraceBreaking (3 ms)
[  FAILED  ] FormatTest.AllmanBraceBreaking (8 ms)
[  FAILED  ] FormatTest.WhitesmithsBraceBreaking (9 ms)
[  FAILED  ] FormatTest.GNUBraceBreaking (3 ms)
[  FAILED  ] FormatTest.FormatsLambdas (52 ms)
[  FAILED  ] FormatTest.FormatsBlocksWithZeroColumnWidth (2 ms)

[ RUN      ] FormatTest.MergeLessLessAtEnd
0  FormatTests              0x00000001028fec70 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 52
1  FormatTests              0x00000001028fe2ec llvm::sys::RunSignalHandlers() + 64
2  FormatTests              0x00000001028ff438 SignalHandler(int) + 312
3  libsystem_platform.dylib 0x0000000183429a24 _sigtramp + 56
4  FormatTests              0x0000000102980644 clang::format::(anonymous namespace)::NoLineBreakFormatter::formatLineForBLayout(clang::format::AnnotatedLine const&, unsigned int, clang::SourceManager const&, unsigned int, unsigned int, bool, bool) + 208
5  FormatTests              0x0000000102980644 clang::format::(anonymous namespace)::NoLineBreakFormatter::formatLineForBLayout(clang::format::AnnotatedLine const&, unsigned int, clang::SourceManager const&, unsigned int, unsigned int, bool, bool) + 208
6  FormatTests              0x000000010297f480 clang::format::UnwrappedLineFormatter::formatHaiku(llvm::SmallVectorImpl<clang::format::AnnotatedLine*> const&, clang::SourceManager const&, bool, int, bool, unsigned int, unsigned int, unsigned int) + 156
7  FormatTests              0x0000000102963054 clang::format::(anonymous namespace)::MergeOrBreak::analyze(clang::format::TokenAnnotator&, llvm::SmallVectorImpl<clang::format::AnnotatedLine*>&, clang::format::FormatTokenLexer&) + 1264
8  FormatTests              0x000000010297113c clang::format::TokenAnalyzer::process() + 780
9  FormatTests              0x0000000102962a30 std::__1::__function::__func<clang::format::internal::reformat(clang::format::FormatStyle const&, llvm::StringRef, llvm::ArrayRef<clang::tooling::Range>, unsigned int, unsigned int, unsigned int, llvm::StringRef, clang::format::FormattingAttemptStatus*)::$_10, std::__1::allocator<clang::format::internal::reformat(clang::format::FormatStyle const&, llvm::StringRef, llvm::ArrayRef<clang::tooling::Range>, unsigned int, unsigned int, unsigned int, llvm::StringRef, clang::format::FormattingAttemptStatus*)::$_10>, std::__1::pair<clang::tooling::Replacements, unsigned int> (clang::format::Environment const&)>::operator()(clang::format::Environment const&) + 88
10 FormatTests              0x0000000102951208 clang::format::internal::reformat(clang::format::FormatStyle const&, llvm::StringRef, llvm::ArrayRef<clang::tooling::Range>, unsigned int, unsigned int, unsigned int, llvm::StringRef, clang::format::FormattingAttemptStatus*) + 968
11 FormatTests              0x000000010295163c clang::format::reformat(clang::format::FormatStyle const&, llvm::StringRef, llvm::ArrayRef<clang::tooling::Range>, llvm::StringRef, clang::format::FormattingAttemptStatus*) + 52
12 FormatTests              0x0000000102750bb4 clang::format::(anonymous namespace)::FormatTest::format(llvm::StringRef, clang::format::FormatStyle const&, clang::format::(anonymous namespace)::FormatTest::StatusCheck) + 144
13 FormatTests              0x0000000102751fbc clang::format::(anonymous namespace)::FormatTest::verifyFormat(llvm::StringRef, llvm::StringRef, clang::format::FormatStyle const&) + 188
14 FormatTests              0x0000000102820428 clang::format::(anonymous namespace)::FormatTest_MergeLessLessAtEnd_Test::TestBody() + 524
15 FormatTests              0x00000001029066b0 testing::Test::Run() + 524
16 FormatTests              0x0000000102907300 testing::TestInfo::Run() + 472
17 FormatTests              0x0000000102907af0 testing::TestCase::Run() + 264
18 FormatTests              0x000000010290e6b0 testing::internal::UnitTestImpl::RunAllTests() + 1060
19 FormatTests              0x000000010290e218 testing::UnitTest::Run() + 192
20 FormatTests              0x00000001028ff81c main + 132
21 dyld                     0x00000001830790e0 start + 2360
Segmentation fault: 11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants