llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Shafik Yaghmour (shafik)

<details>
<summary>Changes</summary>

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.

---
Full diff: https://github.com/llvm/llvm-project/pull/140137.diff


1 Files Affected:

- (modified) clang/lib/Lex/Preprocessor.cpp (+2) 


``````````diff
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);
 }
 

``````````

</details>


https://github.com/llvm/llvm-project/pull/140137
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to