================
@@ -751,12 +751,27 @@ 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
+  if (R) {
+    // MemRegion can be pretty printed.
+    if (R->canPrintPrettyAsExpr()) {
+      R->printPrettyAsExpr(os);
+      if (UseQuotes)
+        return (llvm::Twine("'") + os.str() + ArrayIndices + "'").str();
       return (llvm::Twine(os.str()) + ArrayIndices).str();
+    }
+
+    // FieldRegion may have ElementRegion as SuperRegion.
+    if (const clang::ento::FieldRegion *FR =
+            R->getAs<clang::ento::FieldRegion>()) {
+      std::string Super = FR->getSuperRegion()->getDescriptiveName(false);
----------------
T-Gruber wrote:

The current issue is that MemRegions that are not ElementRegions are 
pretty-printed if possible using printPrettyAsExpr. With FieldRegions, this 
only works if the SuperRegion is not an ElementRegion. So my strategy is to 
obtain the SuperRegion in case of an ElementRegion or FieldRegion and only for 
the MemRegions that do not have a SuperRegion (e.g. ParamVarRegion) I use the 
prettyprintExpr function.

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

Reply via email to