diff options
author | Daniel Jasper <djasper@google.com> | 2013-03-22 10:44:43 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2013-03-22 10:44:43 +0000 |
commit | b5985420d5910e068b0c8b84b8af2223e6bdf130 (patch) | |
tree | 57ff03478251942986bd43444d1d5f1b54ac71a8 /lib/Format | |
parent | b2cc52159023b2008cf028dc6bf153c264fc686f (diff) |
More precisely recognize ObjC method declarations.
Otherwise, +/- and the beginning of constants can be recognized
incorrectly.
Before: #define A - 1
After: #define A -1
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177725 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Format')
-rw-r--r-- | lib/Format/TokenAnnotator.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp index 3578162c3f..7e3ef75d3d 100644 --- a/lib/Format/TokenAnnotator.cpp +++ b/lib/Format/TokenAnnotator.cpp @@ -313,9 +313,11 @@ private: switch (Tok->FormatTok.Tok.getKind()) { case tok::plus: case tok::minus: - // At the start of the line, +/- specific ObjectiveC method - // declarations. - if (Tok->Parent == NULL) + // 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))) Tok->Type = TT_ObjCMethodSpecifier; break; case tok::colon: |