[llvm-bugs] [Bug 45614] New: clang-format incorrectly indents [[nodiscard]] attribute funtions after a macro without semicolon
via llvm-bugs
llvm-bugs at lists.llvm.org
Sun Apr 19 22:44:50 PDT 2020
https://bugs.llvm.org/show_bug.cgi?id=45614
Bug ID: 45614
Summary: clang-format incorrectly indents [[nodiscard]]
attribute funtions after a macro without semicolon
Product: clang
Version: 9.0
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P
Component: Formatter
Assignee: unassignedclangbugs at nondot.org
Reporter: cpeterson at mozilla.com
CC: djasper at google.com, klimek at google.com,
llvm-bugs at lists.llvm.org
clang-format incorrectly indents [[nodiscard]] functions (or any functions with
a [[attribute]]) that follow a macro without a trailing semicolon. This problem
does not affect __attribute__((warn_unused_result)) functions.
```
#define MACRO
MACRO;
__attribute__((warn_unused_result)) int f1(); // ok
MACRO;
[[nodiscard]] int f2(); // ok
MACRO
__attribute__((warn_unused_result)) int f3(); // ok
MACRO
[[nodiscard]] int f4(); // bad: unexpectedly indented!
MACRO
[[bogus_attribute_name]] int f5(); // bad: unexpectedly indented!
```
produces this output:
```
#define MACRO
MACRO;
__attribute__((warn_unused_result)) int f1(); // ok
MACRO;
[[nodiscard]] int f2(); // ok
MACRO
__attribute__((warn_unused_result)) int f3(); // ok
MACRO
[[nodiscard]] int
f4(); // bad: unexpectedly indented!
MACRO
[[bogus_attribute_name]] int
f5(); // bad: unexpectedly indented!
```
I found this bug when trying to replace __attribute__((warn_unused_result))
with [[nodiscard]] in Firefox source code:
https://bugzilla.mozilla.org/show_bug.cgi?id=1629756. I am testing clang-format
version 9.0.1.
--
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/20200420/ae7b9078/attachment.html>
More information about the llvm-bugs
mailing list