Skip to content

Commit 33b02d7

Browse files
committed
[NFC][Clang] Fix static code analyzer concern about null value dereference
CurLexer is dereferenced and should not be null in clang::Preprocessor::SkipExcludedConditionalBlock(clang::SourceLocation, clang::SourceLocation, bool, bool, clang::SourceLocation) This patch adds an assert for NULL value check of pointer CurLexer and splits up all predicates so that, when/if a failure occurs, we'll be able to tell which predicate failed. Reviewed By: tahonermann Differential Revision: https://reviews.llvm.org/D158293
1 parent c4a769b commit 33b02d7

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

clang/lib/Lex/PPDirectives.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,9 @@ void Preprocessor::SkipExcludedConditionalBlock(SourceLocation HashTokenLoc,
491491
llvm::SaveAndRestore SARSkipping(SkippingExcludedConditionalBlock, true);
492492

493493
++NumSkipped;
494-
assert(!CurTokenLexer && CurPPLexer && "Lexing a macro, not a file?");
494+
assert(!CurTokenLexer && "Conditional PP block cannot appear in a macro!");
495+
assert(CurPPLexer && "Conditional PP block must be in a file!");
496+
assert(CurLexer && "Conditional PP block but no current lexer set!");
495497

496498
if (PreambleConditionalStack.reachedEOFWhileSkipping())
497499
PreambleConditionalStack.clearSkipInfo();

0 commit comments

Comments
 (0)