Skip to content

[clang][dataflow] Expand debug dumping of Values. #71527

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 8, 2023

Conversation

martinboehme
Copy link
Contributor

No description provided.

@llvmbot llvmbot added clang Clang issues not falling into any other category clang:dataflow Clang Dataflow Analysis framework - https://clang.llvm.org/docs/DataFlowAnalysisIntro.html clang:analysis labels Nov 7, 2023
@martinboehme martinboehme requested a review from ymand November 7, 2023 12:04
@llvmbot
Copy link
Member

llvmbot commented Nov 7, 2023

@llvm/pr-subscribers-clang-analysis

Author: None (martinboehme)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/71527.diff

1 Files Affected:

  • (modified) clang/lib/Analysis/FlowSensitive/Value.cpp (+12-7)
diff --git a/clang/lib/Analysis/FlowSensitive/Value.cpp b/clang/lib/Analysis/FlowSensitive/Value.cpp
index b069c1cd3da1171..80dde7c8d582358 100644
--- a/clang/lib/Analysis/FlowSensitive/Value.cpp
+++ b/clang/lib/Analysis/FlowSensitive/Value.cpp
@@ -34,13 +34,18 @@ bool areEquivalentValues(const Value &Val1, const Value &Val2) {
 
 raw_ostream &operator<<(raw_ostream &OS, const Value &Val) {
   switch (Val.getKind()) {
-  case Value::Kind::Pointer: {
-    const auto *PV = dyn_cast<PointerValue>(&Val);
-    return OS << "Pointer(" << &PV->getPointeeLoc() << ")";
-  }
-  // FIXME: support remaining cases.
-  default:
-    return OS << debugString(Val.getKind());
+  case Value::Kind::Integer:
+    return OS << "Integer(@" << &Val << ")";
+  case Value::Kind::Pointer:
+    return OS << "Pointer(" << &cast<PointerValue>(Val).getPointeeLoc() << ")";
+  case Value::Kind::Record:
+    return OS << "Record(" << &cast<RecordValue>(Val).getLoc() << ")";
+  case Value::Kind::TopBool:
+    return OS << "TopBool(" << cast<TopBoolValue>(Val).getAtom() << ")";
+  case Value::Kind::AtomicBool:
+    return OS << "AtomicBool(" << cast<AtomicBoolValue>(Val).getAtom() << ")";
+  case Value::Kind::FormulaBool:
+    return OS << "FormulaBool(" << cast<FormulaBoolValue>(Val).formula() << ")";
   }
 }
 

@llvmbot
Copy link
Member

llvmbot commented Nov 7, 2023

@llvm/pr-subscribers-clang

Author: None (martinboehme)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/71527.diff

1 Files Affected:

  • (modified) clang/lib/Analysis/FlowSensitive/Value.cpp (+12-7)
diff --git a/clang/lib/Analysis/FlowSensitive/Value.cpp b/clang/lib/Analysis/FlowSensitive/Value.cpp
index b069c1cd3da1171..80dde7c8d582358 100644
--- a/clang/lib/Analysis/FlowSensitive/Value.cpp
+++ b/clang/lib/Analysis/FlowSensitive/Value.cpp
@@ -34,13 +34,18 @@ bool areEquivalentValues(const Value &Val1, const Value &Val2) {
 
 raw_ostream &operator<<(raw_ostream &OS, const Value &Val) {
   switch (Val.getKind()) {
-  case Value::Kind::Pointer: {
-    const auto *PV = dyn_cast<PointerValue>(&Val);
-    return OS << "Pointer(" << &PV->getPointeeLoc() << ")";
-  }
-  // FIXME: support remaining cases.
-  default:
-    return OS << debugString(Val.getKind());
+  case Value::Kind::Integer:
+    return OS << "Integer(@" << &Val << ")";
+  case Value::Kind::Pointer:
+    return OS << "Pointer(" << &cast<PointerValue>(Val).getPointeeLoc() << ")";
+  case Value::Kind::Record:
+    return OS << "Record(" << &cast<RecordValue>(Val).getLoc() << ")";
+  case Value::Kind::TopBool:
+    return OS << "TopBool(" << cast<TopBoolValue>(Val).getAtom() << ")";
+  case Value::Kind::AtomicBool:
+    return OS << "AtomicBool(" << cast<AtomicBoolValue>(Val).getAtom() << ")";
+  case Value::Kind::FormulaBool:
+    return OS << "FormulaBool(" << cast<FormulaBoolValue>(Val).formula() << ")";
   }
 }
 

@martinboehme martinboehme merged commit 64ed4ed into llvm:main Nov 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:analysis clang:dataflow Clang Dataflow Analysis framework - https://clang.llvm.org/docs/DataFlowAnalysisIntro.html clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants