diff options
author | Daniel Jasper <djasper@google.com> | 2015-01-08 08:48:21 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2015-01-08 08:48:21 +0000 |
commit | b13135bc08df6b3ccf82ce8f0240508625a86d88 (patch) | |
tree | d6b5672a8ceaae19fcf0dc37668e17f880d88c9a | |
parent | 0c4d51b7790682bc45f8e9d4691da421e7d542ef (diff) | |
download | bcm5719-llvm-b13135bc08df6b3ccf82ce8f0240508625a86d88.tar.gz bcm5719-llvm-b13135bc08df6b3ccf82ce8f0240508625a86d88.zip |
clang-format: Improve template parameter detection.
Before:
struct A < std::enable_if<sizeof(T2) <sizeof(int32)>::type>;
After:
struct A<std::enable_if<sizeof(T2) < sizeof(int32)>::type>;
llvm-svn: 225435
-rw-r--r-- | clang/lib/Format/TokenAnnotator.cpp | 7 | ||||
-rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 1 |
2 files changed, 6 insertions, 2 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 8966ab2484b..23c1fcd2129 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -470,9 +470,12 @@ private: return false; break; case tok::less: - if ((!Tok->Previous || !Tok->Previous->Tok.isLiteral()) && parseAngle()) + if ((!Tok->Previous || + (!Tok->Previous->Tok.isLiteral() && + !(Tok->Previous->is(tok::r_paren) && Contexts.size() > 1))) && + parseAngle()) { Tok->Type = TT_TemplateOpener; - else { + } else { Tok->Type = TT_BinaryOperator; CurrentToken = Tok; next(); diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index fc49bde7140..1ecaf090e2e 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -4939,6 +4939,7 @@ TEST_F(FormatTest, UnderstandsTemplateParameters) { verifyFormat("f<int>();"); verifyFormat("template <typename T> void f() {}"); + verifyFormat("struct A<std::enable_if<sizeof(T2) < sizeof(int32)>::type>;"); // Not template parameters. verifyFormat("return a < b && c > d;"); |