[clang] Fieldregion descript name (PR #112313)

Balazs Benics via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 23 01:39:16 PDT 2024


================
@@ -751,12 +758,20 @@ std::string MemRegion::getDescriptiveName(bool UseQuotes) const {
   }
 
   // Get variable name.
-  if (R && R->canPrintPrettyAsExpr()) {
-    R->printPrettyAsExpr(os);
-    if (UseQuotes)
-      return (llvm::Twine("'") + os.str() + ArrayIndices + "'").str();
-    else
-      return (llvm::Twine(os.str()) + ArrayIndices).str();
+  if (R) {
+    // MemRegion can be pretty printed.
+    if (R->canPrintPrettyAsExpr()) {
+      R->printPrettyAsExpr(os);
+      return QuoteIfNeeded(llvm::Twine(os.str()) + ArrayIndices);
+    }
+
+    // FieldRegion may have ElementRegion as SuperRegion.
+    if (const auto *FR = R->getAs<clang::ento::FieldRegion>()) {
----------------
steakhal wrote:

```suggestion
    if (const auto *FR = R->getAs<FieldRegion>()) {
```

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


More information about the cfe-commits mailing list