diff options
| author | Daniel Jasper <djasper@google.com> | 2014-08-13 08:29:18 +0000 |
|---|---|---|
| committer | Daniel Jasper <djasper@google.com> | 2014-08-13 08:29:18 +0000 |
| commit | 343643b9798c8a6f0e236453bf61985dc5eb4438 (patch) | |
| tree | 8e67b7a6f7ff5276149f90f26ab691981a7070d9 /clang/lib/Format/TokenAnnotator.cpp | |
| parent | 51bbd011c32e9bbb5af12effc526358efece498c (diff) | |
| download | bcm5719-llvm-343643b9798c8a6f0e236453bf61985dc5eb4438.tar.gz bcm5719-llvm-343643b9798c8a6f0e236453bf61985dc5eb4438.zip | |
clang-format: Understand #defines defining system includes.
Before:
#define MY_IMPORT < a / b >
After:
#define MY_IMPORT <a/b>
llvm-svn: 215527
Diffstat (limited to 'clang/lib/Format/TokenAnnotator.cpp')
| -rw-r--r-- | clang/lib/Format/TokenAnnotator.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index b24573fffcd..a3662348736 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -497,7 +497,6 @@ private: } void parseIncludeDirective() { - next(); if (CurrentToken && CurrentToken->is(tok::less)) { next(); while (CurrentToken) { @@ -554,6 +553,7 @@ private: switch (CurrentToken->Tok.getIdentifierInfo()->getPPKeywordID()) { case tok::pp_include: case tok::pp_import: + next(); parseIncludeDirective(); break; case tok::pp_error: @@ -587,8 +587,18 @@ public: // should not break the line). IdentifierInfo *Info = CurrentToken->Tok.getIdentifierInfo(); if (Info && Info->getPPKeywordID() == tok::pp_import && - CurrentToken->Next && CurrentToken->Next->is(tok::string_literal)) + CurrentToken->Next && CurrentToken->Next->is(tok::string_literal)) { + next(); parseIncludeDirective(); + return LT_Other; + } + + // If this line starts and ends in '<' and '>', respectively, it is likely + // part of "#define <a/b.h>". + if (CurrentToken->is(tok::less) && Line.Last->is(tok::greater)) { + parseIncludeDirective(); + return LT_Other; + } while (CurrentToken) { if (CurrentToken->is(tok::kw_virtual)) |

