diff options
| author | Daniel Jasper <djasper@google.com> | 2013-03-22 16:55:40 +0000 | 
|---|---|---|
| committer | Daniel Jasper <djasper@google.com> | 2013-03-22 16:55:40 +0000 | 
| commit | dd9276e464e4f15a0f46b46d3df182e9cf58e6d1 (patch) | |
| tree | cc4b6eccf6512b35e981953228464677b4774660 /clang | |
| parent | bc0fa39d69abeb306cab1c2b333e5da17c0a1277 (diff) | |
| download | bcm5719-llvm-dd9276e464e4f15a0f46b46d3df182e9cf58e6d1.tar.gz bcm5719-llvm-dd9276e464e4f15a0f46b46d3df182e9cf58e6d1.zip  | |
Better fix for r177725.
It turns out that
-foo;
can be an objective C method declaration. So instead of the previous
solution, recognize objective C methods only if we are in a declaration
scope.
llvm-svn: 177740
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/lib/Format/TokenAnnotator.cpp | 6 | ||||
| -rw-r--r-- | clang/lib/Format/UnwrappedLineParser.cpp | 5 | ||||
| -rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 1 | 
3 files changed, 5 insertions, 7 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 7e3ef75d3dc..25670d4f688 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -313,11 +313,7 @@ private:      switch (Tok->FormatTok.Tok.getKind()) {      case tok::plus:      case tok::minus: -      // At the start of the line, +/- specify ObjectiveC method declarations. -      if (Tok->Children.empty() || Tok->Children[0].Children.empty()) -        break; // Can't be an ObjectiveC method declaration. -      if (Tok->Parent == NULL && (Tok->Children[0].is(tok::l_paren) || -                                  Tok->Children[0].Children[0].is(tok::colon))) +      if (Tok->Parent == NULL && Line.MustBeDeclaration)          Tok->Type = TT_ObjCMethodSpecifier;        break;      case tok::colon: diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index a01344c03e6..8408ce3a0d8 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -144,8 +144,9 @@ bool UnwrappedLineParser::parse() {  }  bool UnwrappedLineParser::parseFile() { -  ScopedDeclarationState DeclarationState(*Line, DeclarationScopeStack, -                                          /*MustBeDeclaration=*/ true); +  ScopedDeclarationState DeclarationState( +      *Line, DeclarationScopeStack, +      /*MustBeDeclaration=*/ !Line->InPPDirective);    bool Error = parseLevel(/*HasOpeningBrace=*/ false);    // Make sure to format the remaining tokens.    flushComments(true); diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 08403027542..5988a905965 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -2815,6 +2815,7 @@ TEST_F(FormatTest, FormatForObjectiveCMethodDecls) {    // If there's no return type (very rare in practice!), LLVM and Google style    // agree. +  verifyFormat("- foo;");    verifyFormat("- foo:(int)f;");    verifyGoogleFormat("- foo:(int)foo;");  }  | 

