diff options
author | Daniel Jasper <djasper@google.com> | 2013-08-01 17:58:23 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2013-08-01 17:58:23 +0000 |
commit | 8b1c63543b427c7b6e149a99fc2516db5f5b3e0e (patch) | |
tree | 4efea3b06f1cc764b63aaa7906fbd86267b1b9e0 /clang/lib | |
parent | 3a39a98669df6c9ab0d47246f70781ab0b9d27ae (diff) | |
download | bcm5719-llvm-8b1c63543b427c7b6e149a99fc2516db5f5b3e0e.tar.gz bcm5719-llvm-8b1c63543b427c7b6e149a99fc2516db5f5b3e0e.zip |
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
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Format/Format.cpp | 2 | ||||
-rw-r--r-- | clang/lib/Format/TokenAnnotator.cpp | 3 |
2 files changed, 4 insertions, 1 deletions
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp index 290f0597f57..f59fb37996e 100644 --- a/clang/lib/Format/Format.cpp +++ b/clang/lib/Format/Format.cpp @@ -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); } diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index e0e24e27488..39ebe95a43b 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -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; |