https://github.com/shafik created https://github.com/llvm/llvm-project/pull/140137
Static analysis flagged the unconditional access of getExternalSource(). We don't initialize ExternalSource during construction but via setExternalSource(). If this is not set it will violate the invariant covered by the assert. >From b7f6f5408405edc564c5d37dac1510e137c2c922 Mon Sep 17 00:00:00 2001 From: Shafik Yaghmour <shafik.yaghm...@intel.com> Date: Thu, 15 May 2025 13:49:15 -0700 Subject: [PATCH] [Clang][Lex][NFC] Assert getExternalSource() in updateOutOfDateIdentifier Static analysis flagged the unconditional access of getExternalSource(). We don't initialize ExternalSource during construction but via setExternalSource(). If this is not set it will violate the invariant covered by the assert. --- clang/lib/Lex/Preprocessor.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/clang/lib/Lex/Preprocessor.cpp b/clang/lib/Lex/Preprocessor.cpp index 9ea7b95622c76..4c2dbbe881b48 100644 --- a/clang/lib/Lex/Preprocessor.cpp +++ b/clang/lib/Lex/Preprocessor.cpp @@ -759,6 +759,8 @@ void Preprocessor::HandlePoisonedIdentifier(Token & Identifier) { void Preprocessor::updateOutOfDateIdentifier(const IdentifierInfo &II) const { assert(II.isOutOfDate() && "not out of date"); + assert(getExternalSource() && + "getExternalSource() should not return nullptr"); getExternalSource()->updateOutOfDateIdentifier(II); } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits