r205517 - clang-format: Understand that "auto" is a type.
Daniel Jasper
djasper at google.com
Thu Apr 3 02:00:49 PDT 2014
Author: djasper
Date: Thu Apr 3 04:00:49 2014
New Revision: 205517
URL: http://llvm.org/viewvc/llvm-project?rev=205517&view=rev
Log:
clang-format: Understand that "auto" is a type.
Before:
MACRO(auto * a);
After:
MACRO(auto *a);
Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTest.cpp
Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=205517&r1=205516&r2=205517&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Thu Apr 3 04:00:49 2014
@@ -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())
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=205517&r1=205516&r2=205517&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Thu Apr 3 04:00:49 2014
@@ -4554,6 +4554,12 @@ TEST_F(FormatTest, UnderstandsUsesOfStar
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;");
More information about the cfe-commits
mailing list