[clang] dbb95c2 - [clang][dataflow] Debug string for value kinds.
Wei Yi Tee via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 19 08:01:29 PDT 2022
Author: Wei Yi Tee
Date: 2022-08-19T15:00:01Z
New Revision: dbb95c2a851c64e50ca9801a331cb871da88be49
URL: https://github.com/llvm/llvm-project/commit/dbb95c2a851c64e50ca9801a331cb871da88be49
DIFF: https://github.com/llvm/llvm-project/commit/dbb95c2a851c64e50ca9801a331cb871da88be49.diff
LOG: [clang][dataflow] Debug string for value kinds.
Differential Revision: https://reviews.llvm.org/D131891
Added:
Modified:
clang/include/clang/Analysis/FlowSensitive/DebugSupport.h
clang/lib/Analysis/FlowSensitive/DebugSupport.cpp
Removed:
################################################################################
diff --git a/clang/include/clang/Analysis/FlowSensitive/DebugSupport.h b/clang/include/clang/Analysis/FlowSensitive/DebugSupport.h
index b8efdeb61d280..ca50ffc5f5c8a 100644
--- a/clang/include/clang/Analysis/FlowSensitive/DebugSupport.h
+++ b/clang/include/clang/Analysis/FlowSensitive/DebugSupport.h
@@ -20,15 +20,19 @@
#include "clang/Analysis/FlowSensitive/Solver.h"
#include "clang/Analysis/FlowSensitive/Value.h"
#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/StringRef.h"
namespace clang {
namespace dataflow {
+/// Returns a string representation of a value kind.
+llvm::StringRef debugString(Value::Kind Kind);
+
/// Returns a string representation of a boolean assignment to true or false.
-std::string debugString(Solver::Result::Assignment Assignment);
+llvm::StringRef debugString(Solver::Result::Assignment Assignment);
/// Returns a string representation of the result status of a SAT check.
-std::string debugString(Solver::Result::Status Status);
+llvm::StringRef debugString(Solver::Result::Status Status);
/// Returns a string representation for the boolean value `B`.
///
diff --git a/clang/lib/Analysis/FlowSensitive/DebugSupport.cpp b/clang/lib/Analysis/FlowSensitive/DebugSupport.cpp
index 714ad08643edb..220617ab9e30d 100644
--- a/clang/lib/Analysis/FlowSensitive/DebugSupport.cpp
+++ b/clang/lib/Analysis/FlowSensitive/DebugSupport.cpp
@@ -18,6 +18,7 @@
#include "clang/Analysis/FlowSensitive/Value.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/StringSet.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/FormatAdapters.h"
@@ -31,7 +32,33 @@ using llvm::AlignStyle;
using llvm::fmt_pad;
using llvm::formatv;
-std::string debugString(Solver::Result::Assignment Assignment) {
+llvm::StringRef debugString(Value::Kind Kind) {
+ switch (Kind) {
+ case Value::Kind::Integer:
+ return "Integer";
+ case Value::Kind::Reference:
+ return "Reference";
+ case Value::Kind::Pointer:
+ return "Pointer";
+ case Value::Kind::Struct:
+ return "Struct";
+ case Value::Kind::AtomicBool:
+ return "AtomicBool";
+ case Value::Kind::Conjunction:
+ return "Conjunction";
+ case Value::Kind::Disjunction:
+ return "Disjunction";
+ case Value::Kind::Negation:
+ return "Negation";
+ case Value::Kind::Implication:
+ return "Implication";
+ case Value::Kind::Biconditional:
+ return "Biconditional";
+ }
+ llvm_unreachable("Unhandled value kind");
+}
+
+llvm::StringRef debugString(Solver::Result::Assignment Assignment) {
switch (Assignment) {
case Solver::Result::Assignment::AssignedFalse:
return "False";
@@ -41,7 +68,7 @@ std::string debugString(Solver::Result::Assignment Assignment) {
llvm_unreachable("Booleans can only be assigned true/false");
}
-std::string debugString(Solver::Result::Status Status) {
+llvm::StringRef debugString(Solver::Result::Status Status) {
switch (Status) {
case Solver::Result::Status::Satisfiable:
return "Satisfiable";
More information about the cfe-commits
mailing list