r220801 - clang-format: Improve function declaration detection.
Daniel Jasper
djasper at google.com
Tue Oct 28 10:06:04 PDT 2014
Author: djasper
Date: Tue Oct 28 12:06:04 2014
New Revision: 220801
URL: http://llvm.org/viewvc/llvm-project?rev=220801&view=rev
Log:
clang-format: Improve function declaration detection.
Before:
ReturnType MACRO
FunctionName() {}
After:
ReturnType MACRO
FunctionName() {}
This fixes llvm.org/PR21404.
I wonder what the motivation for that if-condition was. But as no test
breaks, ...
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=220801&r1=220800&r2=220801&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Tue Oct 28 12:06:04 2014
@@ -1263,8 +1263,7 @@ void TokenAnnotator::annotate(AnnotatedL
// function declaration.
static bool isFunctionDeclarationName(const FormatToken &Current) {
if (Current.Type != TT_StartOfName ||
- Current.NestingLevel != 0 ||
- Current.Previous->Type == TT_StartOfName)
+ Current.NestingLevel != 0)
return false;
const FormatToken *Next = Current.Next;
for (; Next; Next = Next->Next) {
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=220801&r1=220800&r2=220801&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Tue Oct 28 12:06:04 2014
@@ -5269,6 +5269,8 @@ TEST_F(FormatTest, BreaksLongDeclaration
"LoooooooooooooooooooooooooooooooongFunctionDeclaration();");
verifyFormat("LoooooooooooooooooooooooooooooooooooooooongReturnType\n"
"LooooooooooooooooooooooooooooooooooongFunctionDefinition() {}");
+ verifyFormat("LoooooooooooooooooooooooooooooooooooooooongReturnType MACRO\n"
+ "LooooooooooooooooooooooooooooooooooongFunctionDefinition() {}");
verifyFormat("LoooooooooooooooooooooooooooooooooooooooongReturnType const\n"
"LooooooooooooooooooooooooooooooooooongFunctionDefinition() {}");
verifyFormat("decltype(LoooooooooooooooooooooooooooooooooooooooongName)\n"
More information about the cfe-commits
mailing list