[llvm-bugs] [Bug 47995] New: Wrong alignment in #elif/#else branch for #define blocks
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Oct 28 03:52:04 PDT 2020
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: unassignedclangbugs at nondot.org
Reporter: simon.nuebler at gmail.com
CC: djasper at google.com, klimek at google.com,
llvm-bugs at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20201028/11ce72be/attachment-0001.html>
More information about the llvm-bugs
mailing list