clang-format: Understand that "auto" is a type.

Before:
  MACRO(auto * a);

After:
  MACRO(auto *a);

llvm-svn: 205517
This commit is contained in:
Daniel Jasper 2014-04-03 09:00:49 +00:00
parent 92e0fc0484
commit cc7bf7fda1
2 changed files with 7 additions and 1 deletions

View File

@ -196,7 +196,7 @@ private:
!CurrentToken->Next->HasUnescapedNewline &&
!CurrentToken->Next->isTrailingComment())
HasMultipleParametersOnALine = true;
if (CurrentToken->is(tok::kw_const) ||
if (CurrentToken->isOneOf(tok::kw_const, tok::kw_auto) ||
CurrentToken->isSimpleTypeSpecifier())
Contexts.back().IsExpression = false;
if (!consumeToken())

View File

@ -4554,6 +4554,12 @@ TEST_F(FormatTest, UnderstandsUsesOfStarAndAmp) {
verifyFormat("foo<b && false>();");
verifyFormat("foo<b & 1>();");
verifyIndependentOfContext("MACRO(int *i);");
verifyIndependentOfContext("MACRO(auto *a);");
verifyIndependentOfContext("MACRO(const A *a);");
// FIXME: Is there a way to make this work?
// verifyIndependentOfContext("MACRO(A *a);");
// FIXME: We cannot handle this case yet; we might be able to figure out that
// foo<x> d > v; doesn't make sense.
verifyFormat("foo<a < b && c> d > v;");