// Check to see if this is the last token on the #if[n]def line.
CheckEndOfDirective(isIfndef ? "#ifndef" : "#ifdef");
-
- // If the start of a top-level #ifdef, inform MIOpt.
- if (!ReadAnyTokensBeforeDirective &&
- CurLexer->getConditionalStackDepth() == 0) {
- assert(isIfndef && "#ifdef shouldn't reach here");
- CurLexer->MIOpt.EnterTopLevelIFNDEF(MacroNameTok.getIdentifierInfo());
+
+ if (CurLexer->getConditionalStackDepth() == 0) {
+ // If the start of a top-level #ifdef, inform MIOpt.
+ if (!ReadAnyTokensBeforeDirective) {
+ assert(isIfndef && "#ifdef shouldn't reach here");
+ CurLexer->MIOpt.EnterTopLevelIFNDEF(MacroNameTok.getIdentifierInfo());
+ } else
+ CurLexer->MIOpt.EnterTopLevelConditional();
}
-
+
IdentifierInfo *MII = MacroNameTok.getIdentifierInfo();
MacroInfo *MI = getMacroInfo(MII);
if (ConditionalTrue) {
// If this condition is equivalent to #ifndef X, and if this is the first
// directive seen, handle it for the multiple-include optimization.
- if (!ReadAnyTokensBeforeDirective &&
- CurLexer->getConditionalStackDepth() == 0 && IfNDefMacro)
- CurLexer->MIOpt.EnterTopLevelIFNDEF(IfNDefMacro);
+ if (CurLexer->getConditionalStackDepth() == 0) {
+ if (!ReadAnyTokensBeforeDirective && IfNDefMacro)
+ CurLexer->MIOpt.EnterTopLevelIFNDEF(IfNDefMacro);
+ else
+ CurLexer->MIOpt.EnterTopLevelConditional();
+ }
// Yes, remember that we are inside a conditional, then lex the next token.
CurLexer->pushConditionalLevel(IfToken.getLocation(), /*wasskip*/false,
// If this the end of a top-level #endif, inform MIOpt.
if (CurLexer->getConditionalStackDepth() == 0)
- CurLexer->MIOpt.ExitTopLevelConditional();
+ CurLexer->MIOpt.EnterTopLevelConditional();
assert(!CondInfo.WasSkipping && !CurLexer->LexingRawMode &&
"This code should only be reachable in the non-skipping case!");
// If this is a top-level #else, inform the MIOpt.
if (CurLexer->getConditionalStackDepth() == 0)
- CurLexer->MIOpt.FoundTopLevelElse();
+ CurLexer->MIOpt.EnterTopLevelConditional();
// If this is a #else with a #else before it, report the error.
if (CI.FoundElse) Diag(Result, diag::pp_err_else_after_else);
// If this is a top-level #elif, inform the MIOpt.
if (CurLexer->getConditionalStackDepth() == 0)
- CurLexer->MIOpt.FoundTopLevelElse();
+ CurLexer->MIOpt.EnterTopLevelConditional();
// If this is a #elif with a #else before it, report the error.
if (CI.FoundElse) Diag(ElifToken, diag::pp_err_elif_after_else);
TheMacro = M;
}
- /// FoundTopLevelElse - This is invoked when an #else/#elif directive is found
- /// in the top level conditional in the file.
- void FoundTopLevelElse() {
- /// If a #else directive is found at the top level, there is a chunk of the
- /// file not guarded by the controlling macro.
+ /// EnterTopLevelConditional - This is invoked when a top level conditional
+ /// (except #ifndef) is found.
+ void EnterTopLevelConditional() {
+ /// If a conditional directive (except #ifndef) is found at the top level,
+ /// there is a chunk of the file not guarded by the controlling macro.
Invalidate();
}