forked from OSchip/llvm-project
Teach clang-format to understand static_asserts better.
Before: template <bool B, bool C> class A { static_assert(B &&C, "Something is wrong"); }; After: template <bool B, bool C> class A { static_assert(B && C, "Something is wrong"); }; (Note the spacing around '&&'). Also change the identifier table to always understand all C++11 keywords (which seems like the right thing to do). llvm-svn: 187589
This commit is contained in:
parent
3a39a98669
commit
8b1c63543b
|
@ -1330,7 +1330,7 @@ public:
|
|||
FormatTokenLexer(Lexer &Lex, SourceManager &SourceMgr,
|
||||
encoding::Encoding Encoding)
|
||||
: FormatTok(NULL), GreaterStashed(false), TrailingWhitespace(0), Lex(Lex),
|
||||
SourceMgr(SourceMgr), IdentTable(Lex.getLangOpts()),
|
||||
SourceMgr(SourceMgr), IdentTable(getFormattingLangOpts()),
|
||||
Encoding(Encoding) {
|
||||
Lex.SetKeepWhitespaceMode(true);
|
||||
}
|
||||
|
|
|
@ -93,6 +93,9 @@ private:
|
|||
}
|
||||
}
|
||||
|
||||
if (Left->Previous && Left->Previous->is(tok::kw_static_assert))
|
||||
Contexts.back().IsExpression = true;
|
||||
|
||||
if (StartsObjCMethodExpr) {
|
||||
Contexts.back().ColonIsObjCMethodExpr = true;
|
||||
Left->Type = TT_ObjCMethodExpr;
|
||||
|
|
|
@ -3687,6 +3687,11 @@ TEST_F(FormatTest, UnderstandsRvalueReferences) {
|
|||
verifyIndependentOfContext("A<int &&, int &&> a;");
|
||||
verifyGoogleFormat("A<int&&> a;");
|
||||
verifyGoogleFormat("A<int&&, int&&> a;");
|
||||
|
||||
// Not rvalue references:
|
||||
verifyFormat("template <bool B, bool C> class A {\n"
|
||||
" static_assert(B && C, \"Something is wrong\");\n"
|
||||
"};");
|
||||
}
|
||||
|
||||
TEST_F(FormatTest, FormatsBinaryOperatorsPrecedingEquals) {
|
||||
|
|
Loading…
Reference in New Issue