summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/TokenAnnotator.cpp
diff options
context:
space:
mode:
authorNico Weber <nicolasweber@gmx.de>2017-02-10 19:36:52 +0000
committerNico Weber <nicolasweber@gmx.de>2017-02-10 19:36:52 +0000
commit210888066095283a88ebd0c45ebf448b75f7e714 (patch)
treeaf73c22c1d21cbff75e8e13f12dd2898d89a9a79 /clang/lib/Format/TokenAnnotator.cpp
parentdc412ccc4111ad1c5f55ecf90b2faf6c7e2ae19f (diff)
downloadbcm5719-llvm-210888066095283a88ebd0c45ebf448b75f7e714.tar.gz
bcm5719-llvm-210888066095283a88ebd0c45ebf448b75f7e714.zip
clang-format: don't break code using __has_include, PR31908
llvm-svn: 294772
Diffstat (limited to 'clang/lib/Format/TokenAnnotator.cpp')
-rw-r--r--clang/lib/Format/TokenAnnotator.cpp22
1 files changed, 21 insertions, 1 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index 726383eda9b..ac3c9df5fa6 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -684,6 +684,12 @@ private:
if (Contexts.back().IsForEachMacro)
Contexts.back().IsExpression = true;
break;
+ case tok::identifier:
+ if (Tok->isOneOf(Keywords.kw___has_include,
+ Keywords.kw___has_include_next)) {
+ parseHasInclude();
+ }
+ break;
default:
break;
}
@@ -727,6 +733,14 @@ private:
}
}
+ void parseHasInclude() {
+ if (!CurrentToken || !CurrentToken->is(tok::l_paren))
+ return;
+ next(); // '('
+ parseIncludeDirective();
+ next(); // ')'
+ }
+
LineType parsePreprocessorDirective() {
bool IsFirstToken = CurrentToken->IsFirst;
LineType Type = LT_PreprocessorDirective;
@@ -777,8 +791,14 @@ private:
default:
break;
}
- while (CurrentToken)
+ while (CurrentToken) {
+ FormatToken *Tok = CurrentToken;
next();
+ if (Tok->isOneOf(Keywords.kw___has_include,
+ Keywords.kw___has_include_next)) {
+ parseHasInclude();
+ }
+ }
return Type;
}
OpenPOWER on IntegriCloud