aboutsummaryrefslogtreecommitdiff
path: root/lib/Format/Format.cpp
diff options
context:
space:
mode:
authorNico Weber <nicolasweber@gmx.de>2013-02-11 15:32:15 +0000
committerNico Weber <nicolasweber@gmx.de>2013-02-11 15:32:15 +0000
commitc2e6d2a4a7fe9dfa7d52a38c6048b7b18e6b591a (patch)
tree079b1d7737ae0fed7eb6751a3c26b61076d18e9c /lib/Format/Format.cpp
parent3f4535e44965f46cf603146141d2d27a1cef1f7f (diff)
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174889 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Format/Format.cpp')
-rw-r--r--lib/Format/Format.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/Format/Format.cpp b/lib/Format/Format.cpp
index 6dc84a10c6..347e31470d 100644
--- a/lib/Format/Format.cpp
+++ b/lib/Format/Format.cpp
@@ -842,6 +842,8 @@ public:
return FormatTok;
}
+ IdentifierTable &getIdentTable() { return IdentTable; }
+
private:
FormatToken FormatTok;
bool GreaterStashed;
@@ -909,7 +911,8 @@ public:
UnwrappedLineParser Parser(Diag, Style, Tokens, *this);
StructuralError = Parser.parse();
unsigned PreviousEndOfLineColumn = 0;
- TokenAnnotator Annotator(Style, SourceMgr, Lex);
+ TokenAnnotator Annotator(Style, SourceMgr, Lex,
+ Tokens.getIdentTable().get("in"));
for (unsigned i = 0, e = AnnotatedLines.size(); i != e; ++i) {
Annotator.annotate(AnnotatedLines[i]);
}