clang-format: Fix incorrect multi-var declstmt detection.

This is now obvious as the pointer alignment behavior was changed.

Before (even with pointer alignment "Left"):
  MACRO Constructor(const int &i) : a(a), b(b) {}

After:
  MACRO Constructor(const int& i) : a(a), b(b) {}

llvm-svn: 235301
This commit is contained in:
Daniel Jasper 2015-04-20 12:54:29 +00:00
parent 29c8270916
commit e4ab49e8d3
2 changed files with 4 additions and 3 deletions

View File

@ -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;

View File

@ -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;");