https://github.com/kinu created https://github.com/llvm/llvm-project/pull/65645:

We can dump the same information from RecordStorageLocation.

Tested the behavior before and after patch, that generates the field values in 
the HTML
in both cases (and also made sure that removing the relevant code makes the 
field values
in the HTML go away)

>From 74c4f7999db0cda33aade39a916a122cea2f11b6 Mon Sep 17 00:00:00 2001
From: Kinuko Yasuda <kin...@chromium.org>
Date: Thu, 7 Sep 2023 17:22:17 +0000
Subject: [PATCH] [clang][dataflow] Remove RecordValue.getLog() usage in
 HTMLLogger

We can dump the same information from RecordStorageLocation.

Tested the behavior before and after patch, that generates the
field values in the HTML in both cases
(And also made sure if we remove the code it goes away)
---
 .../lib/Analysis/FlowSensitive/HTMLLogger.cpp  | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp 
b/clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
index b1bfe10db202435..a5f64021eb6ba4b 100644
--- a/clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
+++ b/clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
@@ -95,6 +95,7 @@ class ModelDumper {
 
     switch (V.getKind()) {
     case Value::Kind::Integer:
+    case Value::Kind::Record:
     case Value::Kind::TopBool:
     case Value::Kind::AtomicBool:
     case Value::Kind::FormulaBool:
@@ -103,14 +104,6 @@ class ModelDumper {
       JOS.attributeObject(
           "pointee", [&] { dump(cast<PointerValue>(V).getPointeeLoc()); });
       break;
-    case Value::Kind::Record:
-      for (const auto &Child : cast<RecordValue>(V).getLoc().children())
-        JOS.attributeObject("f:" + Child.first->getNameAsString(), [&] {
-          if (Child.second)
-            if (Value *Val = Env.getValue(*Child.second))
-              dump(*Val);
-        });
-      break;
     }
 
     for (const auto& Prop : V.properties())
@@ -136,6 +129,15 @@ class ModelDumper {
     JOS.attribute("type", L.getType().getAsString());
     if (auto *V = Env.getValue(L))
       dump(*V);
+
+    if (auto *RLoc = dyn_cast<RecordStorageLocation>(&L)) {
+      for (const auto &Child : RLoc->children())
+        JOS.attributeObject("f:" + Child.first->getNameAsString(), [&] {
+          if (Child.second)
+            if (Value *Val = Env.getValue(*Child.second))
+              dump(*Val);
+        });
+    }
   }
 
   llvm::DenseSet<const void*> Visited;

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to