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, ...

llvm-svn: 220801
This commit is contained in:
Daniel Jasper 2014-10-28 17:06:04 +00:00
parent 241ae2cecf
commit 2ad0aba610
2 changed files with 3 additions and 2 deletions

View File

@ -1263,8 +1263,7 @@ void TokenAnnotator::annotate(AnnotatedLine &Line) {
// 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) {

View File

@ -5269,6 +5269,8 @@ TEST_F(FormatTest, BreaksLongDeclarations) {
"LoooooooooooooooooooooooooooooooongFunctionDeclaration();");
verifyFormat("LoooooooooooooooooooooooooooooooooooooooongReturnType\n"
"LooooooooooooooooooooooooooooooooooongFunctionDefinition() {}");
verifyFormat("LoooooooooooooooooooooooooooooooooooooooongReturnType MACRO\n"
"LooooooooooooooooooooooooooooooooooongFunctionDefinition() {}");
verifyFormat("LoooooooooooooooooooooooooooooooooooooooongReturnType const\n"
"LooooooooooooooooooooooooooooooooooongFunctionDefinition() {}");
verifyFormat("decltype(LoooooooooooooooooooooooooooooooooooooooongName)\n"