[clang] [clang][analyzer] Fix a nullptr dereference when `-ftime-trace` is used (PR #139820)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Wed May 14 06:24:01 PDT 2025


================
@@ -103,6 +103,8 @@ class SymbolConjured : public SymbolData {
   const Stmt *getStmt() const {
     switch (Elem->getKind()) {
     case CFGElement::Initializer:
+      if (Elem->castAs<CFGInitializer>().getInitializer() == nullptr)
----------------
AaronBallman wrote:

How about
```
if (const auto *Init = Elem->castAs<CFGInitializer>().getInitializer())
  return Init->getInit();
return nullptr;
```
instead?

https://github.com/llvm/llvm-project/pull/139820


More information about the cfe-commits mailing list