diff options
author | Nico Weber <nicolasweber@gmx.de> | 2013-02-11 15:32:15 +0000 |
---|---|---|
committer | Nico Weber <nicolasweber@gmx.de> | 2013-02-11 15:32:15 +0000 |
commit | 29f9dea1ab821e9b0c7cada17802e6b3fd5a7c93 (patch) | |
tree | ef5a4854d7648961b19ddc531febb22253a8e307 /clang/lib/Format/TokenAnnotator.h | |
parent | 154faa6deda4d6b14f074f43b74519152d922784 (diff) | |
download | bcm5719-llvm-29f9dea1ab821e9b0c7cada17802e6b3fd5a7c93.tar.gz bcm5719-llvm-29f9dea1ab821e9b0c7cada17802e6b3fd5a7c93.zip |
Formatter: Detect ObjC message expressions after 'in' in loop
Before:
for (id foo in[self getStuffFor : bla]) {
}
Now:
for (id foo in [self getStuffFor:bla]) {
}
"in" is treated as loop keyword if the line starts with "for", and as a
regular identifier else. To check for "in", its IdentifierInfo is handed
through a few layers.
llvm-svn: 174889
Diffstat (limited to 'clang/lib/Format/TokenAnnotator.h')
-rw-r--r-- | clang/lib/Format/TokenAnnotator.h | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/clang/lib/Format/TokenAnnotator.h b/clang/lib/Format/TokenAnnotator.h index c19b486c1c2..506f271dc5d 100644 --- a/clang/lib/Format/TokenAnnotator.h +++ b/clang/lib/Format/TokenAnnotator.h @@ -38,6 +38,7 @@ enum TokenType { TT_ObjCArrayLiteral, TT_ObjCBlockLParen, TT_ObjCDecl, + TT_ObjCForIn, TT_ObjCMethodExpr, TT_ObjCMethodSpecifier, TT_ObjCProperty, @@ -178,8 +179,9 @@ inline prec::Level getPrecedence(const AnnotatedToken &Tok) { /// \c UnwrappedLine. class TokenAnnotator { public: - TokenAnnotator(const FormatStyle &Style, SourceManager &SourceMgr, Lexer &Lex) - : Style(Style), SourceMgr(SourceMgr), Lex(Lex) { + TokenAnnotator(const FormatStyle &Style, SourceManager &SourceMgr, Lexer &Lex, + IdentifierInfo &Ident_in) + : Style(Style), SourceMgr(SourceMgr), Lex(Lex), Ident_in(Ident_in) { } void annotate(AnnotatedLine &Line); @@ -201,6 +203,9 @@ private: const FormatStyle &Style; SourceManager &SourceMgr; Lexer &Lex; + + // Contextual keywords: + IdentifierInfo &Ident_in; }; } // end namespace format |