diff options
author | Daniel Jasper <djasper@google.com> | 2015-05-19 11:18:39 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2015-05-19 11:18:39 +0000 |
commit | f5e5ee6d69d974b4f643a9f5291354b3a8850229 (patch) | |
tree | 949d3fd4d82bccaf225b0625b1585bef8bdcbc38 | |
parent | d90d6fb53a38ca33b75adaedd5f93480336cb55a (diff) | |
download | bcm5719-llvm-f5e5ee6d69d974b4f643a9f5291354b3a8850229.tar.gz bcm5719-llvm-f5e5ee6d69d974b4f643a9f5291354b3a8850229.zip |
clang-format: Correctly detect casts to qualified types.
Before:
ns::E f() { return (ns::E) - 1; }
After:
ns::E f() { return (ns::E)-1; }
This fixes llvm.org/PR23503.
llvm-svn: 237684
-rw-r--r-- | clang/lib/Format/TokenAnnotator.cpp | 3 | ||||
-rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 1 |
2 files changed, 3 insertions, 1 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index d3122615c83..772fa1d2390 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -1082,7 +1082,8 @@ private: } for (; Prev != Tok.MatchingParen; Prev = Prev->Previous) { - if (!Prev || !Prev->isOneOf(tok::kw_const, tok::identifier)) { + if (!Prev || + !Prev->isOneOf(tok::kw_const, tok::identifier, tok::coloncolon)) { IsCast = false; break; } diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 3903ac31e83..9c3448ad83b 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -5765,6 +5765,7 @@ TEST_F(FormatTest, FormatsCasts) { verifyFormat("my_int a = (const my_int)-1;"); verifyFormat("my_int a = (const my_int *)-1;"); verifyFormat("my_int a = (my_int)(my_int)-1;"); + verifyFormat("my_int a = (ns::my_int)-2;"); // FIXME: single value wrapped with paren will be treated as cast. verifyFormat("void f(int i = (kValue)*kMask) {}"); |