diff options
| -rw-r--r-- | clang/lib/Lex/PPDirectives.cpp | 12 | ||||
| -rw-r--r-- | clang/test/Index/single-file-parse.m | 10 |
2 files changed, 16 insertions, 6 deletions
diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp index 422bfc89687..8c79e50176e 100644 --- a/clang/lib/Lex/PPDirectives.cpp +++ b/clang/lib/Lex/PPDirectives.cpp @@ -2658,7 +2658,7 @@ void Preprocessor::HandleIfdefDirective(Token &Result, bool isIfndef, // In 'single-file-parse mode' undefined identifiers trigger parsing of all // the directive blocks. CurPPLexer->pushConditionalLevel(DirectiveTok.getLocation(), - /*wasskip*/true, /*foundnonskip*/false, + /*wasskip*/false, /*foundnonskip*/false, /*foundelse*/false); } else if (!MI == isIfndef) { // Yes, remember that we are inside a conditional, then lex the next token. @@ -2705,7 +2705,7 @@ void Preprocessor::HandleIfDirective(Token &IfToken, if (PPOpts->SingleFileParseMode && DER.IncludedUndefinedIds) { // In 'single-file-parse mode' undefined identifiers trigger parsing of all // the directive blocks. - CurPPLexer->pushConditionalLevel(IfToken.getLocation(), /*wasskip*/true, + CurPPLexer->pushConditionalLevel(IfToken.getLocation(), /*wasskip*/false, /*foundnonskip*/false, /*foundelse*/false); } else if (ConditionalTrue) { // Yes, remember that we are inside a conditional, then lex the next token. @@ -2768,11 +2768,11 @@ void Preprocessor::HandleElseDirective(Token &Result) { if (Callbacks) Callbacks->Else(Result.getLocation(), CI.IfLoc); - if (PPOpts->SingleFileParseMode && CI.WasSkipping) { + if (PPOpts->SingleFileParseMode && !CI.FoundNonSkip) { // In 'single-file-parse mode' undefined identifiers trigger parsing of all // the directive blocks. CurPPLexer->pushConditionalLevel(CI.IfLoc, /*wasskip*/false, - /*foundnonskip*/true, /*foundelse*/true); + /*foundnonskip*/false, /*foundelse*/true); return; } @@ -2811,10 +2811,10 @@ void Preprocessor::HandleElifDirective(Token &ElifToken) { SourceRange(ConditionalBegin, ConditionalEnd), PPCallbacks::CVK_NotEvaluated, CI.IfLoc); - if (PPOpts->SingleFileParseMode && CI.WasSkipping) { + if (PPOpts->SingleFileParseMode && !CI.FoundNonSkip) { // In 'single-file-parse mode' undefined identifiers trigger parsing of all // the directive blocks. - CurPPLexer->pushConditionalLevel(ElifToken.getLocation(), /*wasskip*/true, + CurPPLexer->pushConditionalLevel(ElifToken.getLocation(), /*wasskip*/false, /*foundnonskip*/false, /*foundelse*/false); return; } diff --git a/clang/test/Index/single-file-parse.m b/clang/test/Index/single-file-parse.m index 6e2189c43dd..f75b9bd0ee5 100644 --- a/clang/test/Index/single-file-parse.m +++ b/clang/test/Index/single-file-parse.m @@ -109,3 +109,13 @@ // CHECK: [[@LINE+1]]:12: ObjCInterfaceDecl=Test28 @interface Test28 @end #endif + +#if SOMETHING_NOT_DEFINED +// CHECK: [[@LINE+1]]:12: ObjCInterfaceDecl=Test29 +@interface Test29 @end +#endif + +#ifdef SOMETHING_NOT_DEFINED +// CHECK: [[@LINE+1]]:12: ObjCInterfaceDecl=Test30 +@interface Test30 @end +#endif |

