[clang] [analyzer] Match dangling subobjects by their base region in DanglingPtrDeref (PR #211552)

via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 24 05:53:55 PDT 2026


================
@@ -66,13 +66,21 @@ void DanglingPtrDeref::checkPostCall(const CallEvent &Call,
   }
 }
 
+static std::string getRegionName(const MemRegion *Reg) {
+  // FIXME: Once the checker supports heap allocation, more region kinds
+  // should be handled to produce the correct descriptive name.
+  if (const std::string RegName = Reg->getDescriptiveName(); !RegName.empty())
----------------
isuckatcs wrote:

Nit:
```suggestion
  if (std::string RegName = Reg->getDescriptiveName(); !RegName.empty())
```
or
```suggestion
  if (const std::string &RegName = Reg->getDescriptiveName(); !RegName.empty())
```

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


More information about the cfe-commits mailing list