aboutsummaryrefslogtreecommitdiff
path: root/lib/Format
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2013-03-22 16:55:40 +0000
committerDaniel Jasper <djasper@google.com>2013-03-22 16:55:40 +0000
commit627707b9360597b65a9a0953d0ead2a08c3a0d5d (patch)
treea274b38e07d52c0e3b5fbeb7a58f8283e05ee2bb /lib/Format
parentc363dbb204b6c77b67dfed030436643947b37cbd (diff)
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177740 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Format')
-rw-r--r--lib/Format/TokenAnnotator.cpp6
-rw-r--r--lib/Format/UnwrappedLineParser.cpp5
2 files changed, 4 insertions, 7 deletions
diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp
index 7e3ef75d3d..25670d4f68 100644
--- a/lib/Format/TokenAnnotator.cpp
+++ b/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/lib/Format/UnwrappedLineParser.cpp b/lib/Format/UnwrappedLineParser.cpp
index a01344c03e..8408ce3a0d 100644
--- a/lib/Format/UnwrappedLineParser.cpp
+++ b/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);