================
@@ -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);
----------------
steakhal wrote:

```suggestion
    if (const auto *FR = R->getAs<FieldRegion>()) {
      std::string Super = 
FR->getSuperRegion()->getDescriptiveName(/*UseQuotes=*/false);
```

We prefer not spelling out the type if the line already spells it. We don't 
need to use fully qualified names, as we are already within the `ento` 
namespace. We usually use named arguments for bool parameters, to make it more 
descriptive.

Why are `FieldRegions` so special? Couldn't we do something more generic? I 
wonder if we could use something like a visitor to bring some structure to this 
function. This starts to look really messy to me, without evidence that we 
couldn't do something better. WDYT?

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