diff options
Diffstat (limited to 'clang/lib/Lex/DependencyDirectivesSourceMinimizer.cpp')
-rw-r--r-- | clang/lib/Lex/DependencyDirectivesSourceMinimizer.cpp | 13 |
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; |