From 399d1ee5a01c2d0e7584105a23c25c0ff899a022 Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Fri, 22 Mar 2013 10:44:43 +0000 Subject: More precisely recognize ObjC method declarations. Otherwise, +/- and the beginning of constants can be recognized incorrectly. Before: #define A - 1 After: #define A -1 llvm-svn: 177725 --- clang/lib/Format/TokenAnnotator.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'clang/lib/Format/TokenAnnotator.cpp') diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 3578162c3f6..7e3ef75d3dc 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/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: -- cgit v1.2.3