From b5414b566a5aedd90e41f01dd2b7b632afc5d5b7 Mon Sep 17 00:00:00 2001 From: Dmitri Gribenko Date: Sat, 23 Jul 2022 01:23:17 +0200 Subject: [clang][dataflow] Add DataflowEnvironment::dump() Start by dumping the flow condition. Reviewed By: ymandel Differential Revision: https://reviews.llvm.org/D130398 --- .../clang/Analysis/FlowSensitive/DataflowAnalysisContext.h | 3 +++ .../clang/Analysis/FlowSensitive/DataflowEnvironment.h | 3 ++- clang/include/clang/Analysis/FlowSensitive/DebugSupport.h | 14 ++++++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) (limited to 'clang/include') diff --git a/clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h b/clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h index 358ace0..abc3183 100644 --- a/clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h +++ b/clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h @@ -23,6 +23,7 @@ #include "clang/Analysis/FlowSensitive/Value.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/DenseSet.h" +#include "llvm/Support/Compiler.h" #include #include #include @@ -251,6 +252,8 @@ public: /// `Val2` imposed by the flow condition. bool equivalentBoolValues(BoolValue &Val1, BoolValue &Val2); + LLVM_DUMP_METHOD void dumpFlowCondition(AtomicBoolValue &Token); + private: struct NullableQualTypeDenseMapInfo : private llvm::DenseMapInfo { static QualType getEmptyKey() { diff --git a/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h b/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h index ce195f0..f17df36 100644 --- a/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h +++ b/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h @@ -19,7 +19,6 @@ #include "clang/AST/DeclBase.h" #include "clang/AST/Expr.h" #include "clang/AST/Type.h" -#include "clang/AST/TypeOrdering.h" #include "clang/Analysis/FlowSensitive/DataflowAnalysisContext.h" #include "clang/Analysis/FlowSensitive/DataflowLattice.h" #include "clang/Analysis/FlowSensitive/StorageLocation.h" @@ -325,6 +324,8 @@ public: /// imply that `Val` is true. bool flowConditionImplies(BoolValue &Val) const; + LLVM_DUMP_METHOD void dump() const; + private: /// Creates a value appropriate for `Type`, if `Type` is supported, otherwise /// return null. diff --git a/clang/include/clang/Analysis/FlowSensitive/DebugSupport.h b/clang/include/clang/Analysis/FlowSensitive/DebugSupport.h index 74367d2..b8efdeb 100644 --- a/clang/include/clang/Analysis/FlowSensitive/DebugSupport.h +++ b/clang/include/clang/Analysis/FlowSensitive/DebugSupport.h @@ -43,6 +43,20 @@ std::string debugString( llvm::DenseMap AtomNames = {{}}); /// Returns a string representation for `Constraints` - a collection of boolean +/// formulas. +/// +/// Atomic booleans appearing in the boolean value `Constraints` are assigned to +/// labels either specified in `AtomNames` or created by default rules as B0, +/// B1, ... +/// +/// Requirements: +/// +/// Names assigned to atoms should not be repeated in `AtomNames`. +std::string debugString( + const llvm::DenseSet &Constraints, + llvm::DenseMap AtomNames = {{}}); + +/// Returns a string representation for `Constraints` - a collection of boolean /// formulas and the `Result` of satisfiability checking. /// /// Atomic booleans appearing in `Constraints` and `Result` are assigned to -- cgit v1.1