https://bugs.llvm.org/show_bug.cgi?id=47995
Bug ID: 47995
Summary: Wrong alignment in #elif/#else branch for #define
blocks
Product: clang
Version: 11.0
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: Formatter
Assignee: unassignedclangb...@nondot.org
Reporter: simon.nueb...@gmail.com
CC: djas...@google.com, kli...@google.com,
llvm-bugs@lists.llvm.org
Hello,
I have encountered a bug in clang-format-11.0.0 (valid at least for v10 too)
Default configuration with
"AlignConsecutiveMacros = true"
"IndentPPDirectives = BeforeHash"
When there are #define blocks in an #elif/#else branch and there is a comment
in between #define blocks, all #defines, their values and comments are aligned
based on the last block, which is incorrect. If the comments in between the
blocks are removed or the blocks are in an #if branch, this error does not
occur.
Example how it looks:
#if defined(SOMETHING)
#elif defined(SOMETHING_ELSE)
// A comment.
#define a 1 // A comment.
#define b 2 // A comment.
#define c 3 // A comment.
// A comment.
#define aa 1111 // A comment.
#define bb 2222 // A comment.
#define cc 3333 // A comment.
// A comment.
#define aaaaa 111111 // A comment.
#define bbbbb 222222 // A comment.
#define ccbbc 333333 // A comment.
#endif
This is how it should look:
#if defined(SOMETHING)
#elif defined(SOMETHING_ELSE)
// A comment.
#define a 1 // A comment.
#define b 2 // A comment.
#define c 3 // A comment.
// A comment.
#define aa 1111 // A comment.
#define bb 2222 // A comment.
#define cc 3333 // A comment.
// A comment.
#define aaaaa 111111 // A comment.
#define bbbbb 222222 // A comment.
#define ccbbc 333333 // A comment.
#endif
Best regards
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs