forked from OSchip/llvm-project
fix PR2357 (#ifs didnt invalidate the multiple-inclusion optimization state)
llvm-svn: 51843
This commit is contained in:
parent
1086ab478d
commit
363212b3fa
|
@ -1059,17 +1059,18 @@ void Preprocessor::HandleIfDirective(Token &IfToken,
|
||||||
IdentifierInfo *IfNDefMacro = 0;
|
IdentifierInfo *IfNDefMacro = 0;
|
||||||
bool ConditionalTrue = EvaluateDirectiveExpression(IfNDefMacro);
|
bool ConditionalTrue = EvaluateDirectiveExpression(IfNDefMacro);
|
||||||
|
|
||||||
|
|
||||||
|
// If this condition is equivalent to #ifndef X, and if this is the first
|
||||||
|
// directive seen, handle it for the multiple-include optimization.
|
||||||
|
if (CurLexer->getConditionalStackDepth() == 0) {
|
||||||
|
if (!ReadAnyTokensBeforeDirective && IfNDefMacro)
|
||||||
|
CurLexer->MIOpt.EnterTopLevelIFNDEF(IfNDefMacro);
|
||||||
|
else
|
||||||
|
CurLexer->MIOpt.EnterTopLevelConditional();
|
||||||
|
}
|
||||||
|
|
||||||
// Should we include the stuff contained by this directive?
|
// Should we include the stuff contained by this directive?
|
||||||
if (ConditionalTrue) {
|
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 (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.
|
// Yes, remember that we are inside a conditional, then lex the next token.
|
||||||
CurLexer->pushConditionalLevel(IfToken.getLocation(), /*wasskip*/false,
|
CurLexer->pushConditionalLevel(IfToken.getLocation(), /*wasskip*/false,
|
||||||
/*foundnonskip*/true, /*foundelse*/false);
|
/*foundnonskip*/true, /*foundelse*/false);
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
// RUN: clang %s -fsyntax-only
|
||||||
|
|
||||||
|
#ifndef XVID_AUTO_INCLUDE
|
||||||
|
|
||||||
|
#define XVID_AUTO_INCLUDE
|
||||||
|
#define FUNC_H H_Pass_16_C
|
||||||
|
#include "multiple-include.c"
|
||||||
|
|
||||||
|
#define FUNC_H H_Pass_8_C
|
||||||
|
|
||||||
|
#include "multiple-include.c"
|
||||||
|
#undef XVID_AUTO_INCLUDE
|
||||||
|
|
||||||
|
typedef void ff();
|
||||||
|
typedef struct { ff *a;} S;
|
||||||
|
|
||||||
|
S s = { H_Pass_8_C };
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(XVID_AUTO_INCLUDE) && defined(REFERENCE_CODE)
|
||||||
|
#elif defined(XVID_AUTO_INCLUDE) && !defined(REFERENCE_CODE)
|
||||||
|
|
||||||
|
static void FUNC_H(){};
|
||||||
|
#undef FUNC_H
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in New Issue