diff options
-rw-r--r-- | clang/lib/Format/TokenAnnotator.cpp | 6 | ||||
-rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 1 |
2 files changed, 4 insertions, 3 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 5b148eab6b1..ea5503ade68 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -543,12 +543,12 @@ private: parseTemplateDeclaration(); break; case tok::comma: - if (Contexts.back().FirstStartOfName && Contexts.size() == 1) { + if (Contexts.back().InCtorInitializer) + Tok->Type = TT_CtorInitializerComma; + else if (Contexts.back().FirstStartOfName && Contexts.size() == 1) { Contexts.back().FirstStartOfName->PartOfMultiVariableDeclStmt = true; Line.IsMultiVariableDeclStmt = true; } - if (Contexts.back().InCtorInitializer) - Tok->Type = TT_CtorInitializerComma; if (Contexts.back().IsForEachMacro) Contexts.back().IsExpression = true; break; diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 9791e2a5fb9..bec7a9cfb50 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -5336,6 +5336,7 @@ TEST_F(FormatTest, UnderstandsUsesOfStarAndAmp) { verifyIndependentOfContext("int x = ~*p;"); verifyFormat("Constructor() : a(a), area(width * height) {}"); verifyFormat("Constructor() : a(a), area(a, width * height) {}"); + verifyGoogleFormat("MACRO Constructor(const int& i) : a(a), b(b) {}"); verifyFormat("void f() { f(a, c * d); }"); verifyIndependentOfContext("InvalidRegions[*R] = 0;"); |