summaryrefslogtreecommitdiff
path: root/clang/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2020-01-17 20:45:01 +0000
committerDimitry Andric <dim@FreeBSD.org>2020-01-17 20:45:01 +0000
commit706b4fc47bbc608932d3b491ae19a3b9cde9497b (patch)
tree4adf86a776049cbf7f69a1929c4babcbbef925eb /clang/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
parent7cc9cf2bf09f069cb2dd947ead05d0b54301fb71 (diff)
Notes
Diffstat (limited to 'clang/lib/Lex/DependencyDirectivesSourceMinimizer.cpp')
-rw-r--r--clang/lib/Lex/DependencyDirectivesSourceMinimizer.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/clang/lib/Lex/DependencyDirectivesSourceMinimizer.cpp b/clang/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
index f063ed711c44..029bfe1cd600 100644
--- a/clang/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
+++ b/clang/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
@@ -763,12 +763,13 @@ bool Minimizer::lexEndif(const char *&First, const char *const End) {
if (top() == pp_else)
popToken();
- // Strip out "#elif" if they're empty.
- while (top() == pp_elif)
- popToken();
-
- // If "#if" is empty, strip it and skip the "#endif".
- if (top() == pp_if || top() == pp_ifdef || top() == pp_ifndef) {
+ // If "#ifdef" is empty, strip it and skip the "#endif".
+ //
+ // FIXME: Once/if Clang starts disallowing __has_include in macro expansions,
+ // we can skip empty `#if` and `#elif` blocks as well after scanning for a
+ // literal __has_include in the condition. Even without that rule we could
+ // drop the tokens if we scan for identifiers in the condition and find none.
+ if (top() == pp_ifdef || top() == pp_ifndef) {
popToken();
skipLine(First, End);
return false;