Closed mydeveloperday closed 4 years ago
M=0 C=0 T=Unknown S=1 B=0 BK=0 P=0 Name=class L=5 PPK=2 FakeLParens= FakeRParens=0 II=0xed3390 Text='class' M=0 C=1 T=Unknown S=1 B=0 BK=0 P=5020 Name=identifier L=7 PPK=2 FakeLParens= FakeRParens=0 II=0xe8e290 Text='S' M=0 C=0 T=Unknown S=1 B=0 BK=1 P=23 Name=l_brace L=9 PPK=2 FakeLParens= FakeRParens=0 II=0x0 Text='{'
Adding [[nodiscard]] makes { a FunctionLBrace
M=0 C=0 T=Unknown S=1 B=0 BK=0 P=0 Name=class L=5 PPK=2 FakeLParens= FakeRParens=0 II=0xed3390 Text='class' M=0 C=1 T=AttributeSquare S=1 B=0 BK=0 P=5020 Name=l_square L=7 PPK=2 FakeLParens= FakeRParens=0 II=0x0 Text='[' M=0 C=0 T=AttributeSquare S=0 B=0 BK=0 P=59 Name=l_square L=8 PPK=2 FakeLParens= FakeRParens=0 II=0x0 Text='[' M=0 C=0 T=Unknown S=0 B=0 BK=0 P=79 Name=identifier L=17 PPK=2 FakeLParens= FakeRParens=0 II=0xe8e2c8 Text='nodiscard' M=0 C=0 T=AttributeSquare S=0 B=0 BK=0 P=63 Name=r_square L=18 PPK=2 FakeLParens= FakeRParens=0 II=0x0 Text=']' M=0 C=0 T=AttributeSquare S=0 B=0 BK=0 P=43 Name=r_square L=19 PPK=2 FakeLParens= FakeRParens=0 II=0x0 Text=']' M=0 C=0 T=Unknown S=1 B=0 BK=0 P=23 Name=identifier L=21 PPK=2 FakeLParens= FakeRParens=0 II=0xe8e290 Text='S' M=0 C=0 T=FunctionLBrace S=1 B=0 BK=1 P=23 Name=l_brace L=23 PPK=2 FakeLParens= FakeRParens=0 II=0x0 Text='{'
assigned to @mydeveloperday
Extended Description
Using
Language: Cpp BasedOnStyle: Chromium
The following code will case
Will format the move constructor (and other areas) incorrectly just because of the addition of [[nodiscard]] to the class.
e.g. S(S&&) = default; vs S(S &&) = default;
namespace n1 { struct S { S(const S&) = default; S(S&) = default; S(S&&) = default; S(int&&) {}
void x() const&; void x() &; void x() &&; void y() && noexcept; }; } // namespace n1
namespace n2 { struct [[nodiscard]] S { // OK S(const S&) = default; S(S&) = default;
// Inconsistent space before && S(S &&) = default; S(int&&) {}
// OK void x() const&;
// Lack of space betwen () and && void x()&; void x()&&; void y()&& noexcept; }; } // namespace n2
This is caused by && being interpreted as a BinaryOperator in the second case
AnnotatedTokens(L=1): M=0 C=0 T=Unknown S=1 B=0 BK=0 P=0 Name=identifier L=1 PPK=2 FakeLParens=2/ FakeRParens=0 II=0xfc5800 Text='S' M=0 C=0 T=Unknown S=0 B=0 BK=0 P=23 Name=l_paren L=2 PPK=2 FakeLParens= FakeRParens=0 II=0x0 Text='(' M=0 C=1 T=Unknown S=0 B=0 BK=0 P=140 Name=identifier L=3 PPK=2 FakeLParens= FakeRParens=0 II=0xfc5800 Text='S' M=0 C=0 T=PointerOrReference S=0 B=0 BK=0 P=230 Name=ampamp L=5 PPK=2 FakeLParens= FakeRParens=0 II=0x0 Text='&&' M=0 C=0 T=Unknown S=0 B=0 BK=0 P=45 Name=r_paren L=6 PPK=2 FakeLParens= FakeRParens=0 II=0x0 Text=')' M=0 C=0 T=BinaryOperator S=1 B=0 BK=0 P=22 Name=equal L=8 PPK=2 FakeLParens= FakeRParens=0 II=0x0 Text='=' M=0 C=1 T=Unknown S=1 B=0 BK=0 P=130 Name=default L=16 PPK=2 FakeLParens= FakeRParens=1 II=0xfc4530 Text='default' M=0 C=0 T=Unknown S=0 B=0 BK=0 P=23 Name=semi L=17 PPK=2 FakeLParens= FakeRParens=0 II=0x0 Text=';'
vs
AnnotatedTokens(L=1): M=0 C=0 T=Unknown S=1 B=0 BK=0 P=0 Name=identifier L=1 PPK=2 FakeLParens=2/ FakeRParens=0 II=0xfc5800 Text='S' M=0 C=0 T=Unknown S=0 B=0 BK=0 P=23 Name=l_paren L=2 PPK=2 FakeLParens= FakeRParens=0 II=0x0 Text='(' M=0 C=1 T=Unknown S=0 B=0 BK=0 P=59 Name=identifier L=3 PPK=2 FakeLParens=5/ FakeRParens=0 II=0xfc5800 Text='S' M=0 C=0 T=BinaryOperator S=1 B=0 BK=0 P=45 Name=ampamp L=6 PPK=2 FakeLParens= FakeRParens=1 II=0x0 Text='&&' M=0 C=0 T=Unknown S=0 B=0 BK=0 P=45 Name=r_paren L=7 PPK=2 FakeLParens= FakeRParens=0 II=0x0 Text=')' M=0 C=0 T=BinaryOperator S=1 B=0 BK=0 P=22 Name=equal L=9 PPK=2 FakeLParens= FakeRParens=0 II=0x0 Text='=' M=0 C=1 T=Unknown S=1 B=0 BK=0 P=22 Name=default L=17 PPK=2 FakeLParens= FakeRParens=1 II=0xfc4530 Text='default' M=0 C=0 T=Unknown S=0 B=0 BK=0 P=23 Name=semi L=18 PPK=2 FakeLParens= FakeRParens=0 II=0x0 Text=';'