diff --git a/clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h b/clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h --- a/clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h +++ b/clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h @@ -49,10 +49,8 @@ /// /// `LatticeT` is a bounded join-semilattice that is used by `Derived` and must /// provide the following public members: -/// * `LatticeJoinEffect join(const LatticeT &)` - joins the object and the -/// argument by computing their least upper bound, modifies the object if -/// necessary, and returns an effect indicating whether any changes were -/// made to it; +/// * `void join(const LatticeT &)` - joins the object and the argument by +/// computing their least upper bound and modifies the object if necessary; /// * `bool operator==(const LatticeT &) const` - returns true if and only if /// the object is equal to the argument. /// @@ -84,11 +82,11 @@ return {static_cast(this)->initialElement()}; } - LatticeJoinEffect joinTypeErased(TypeErasedLattice &E1, - const TypeErasedLattice &E2) final { + void joinTypeErased(TypeErasedLattice &E1, + const TypeErasedLattice &E2) final { Lattice &L1 = llvm::any_cast(E1.Value); const Lattice &L2 = llvm::any_cast(E2.Value); - return L1.join(L2); + L1.join(L2); } void widenTypeErased(TypeErasedLattice &E1, diff --git a/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h b/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h --- a/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h +++ b/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h @@ -21,7 +21,6 @@ #include "clang/AST/Type.h" #include "clang/Analysis/FlowSensitive/ControlFlowContext.h" #include "clang/Analysis/FlowSensitive/DataflowAnalysisContext.h" -#include "clang/Analysis/FlowSensitive/DataflowLattice.h" #include "clang/Analysis/FlowSensitive/StorageLocation.h" #include "clang/Analysis/FlowSensitive/Value.h" #include "llvm/ADT/DenseMap.h" @@ -169,8 +168,7 @@ /// Requirements: /// /// `Other` and `this` must use the same `DataflowAnalysisContext`. - LatticeJoinEffect join(const Environment &Other, - Environment::ValueModel &Model); + void join(const Environment &Other, Environment::ValueModel &Model); // FIXME: Rename `createOrGetStorageLocation` to `getOrCreateStorageLocation`, // `getStableStorageLocation`, or something more appropriate. diff --git a/clang/include/clang/Analysis/FlowSensitive/DataflowLattice.h b/clang/include/clang/Analysis/FlowSensitive/DataflowLattice.h --- a/clang/include/clang/Analysis/FlowSensitive/DataflowLattice.h +++ b/clang/include/clang/Analysis/FlowSensitive/DataflowLattice.h @@ -17,7 +17,11 @@ namespace clang { namespace dataflow { +/// DEPRECATED: Not meaningfully used. +/// /// Effect indicating whether a lattice join operation resulted in a new value. +/// +/// FIXME: Delete this file once all references are removed. enum class LatticeJoinEffect { Unchanged, Changed, diff --git a/clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h b/clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h --- a/clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h +++ b/clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h @@ -22,7 +22,6 @@ #include "clang/Analysis/CFG.h" #include "clang/Analysis/FlowSensitive/ControlFlowContext.h" #include "clang/Analysis/FlowSensitive/DataflowEnvironment.h" -#include "clang/Analysis/FlowSensitive/DataflowLattice.h" #include "clang/Analysis/FlowSensitive/Transfer.h" #include "llvm/ADT/Any.h" #include "llvm/ADT/Optional.h" @@ -74,8 +73,8 @@ /// Joins two type-erased lattice elements by computing their least upper /// bound. Places the join result in the left element and returns an effect /// indicating whether any changes were made to it. - virtual LatticeJoinEffect joinTypeErased(TypeErasedLattice &, - const TypeErasedLattice &) = 0; + virtual void joinTypeErased(TypeErasedLattice &, + const TypeErasedLattice &) = 0; /// Relaxes the constraints in `A` to subsume the state in `B`. virtual void widenTypeErased(TypeErasedLattice &A, diff --git a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp --- a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp +++ b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp @@ -16,7 +16,6 @@ #include "clang/AST/Decl.h" #include "clang/AST/DeclCXX.h" #include "clang/AST/Type.h" -#include "clang/Analysis/FlowSensitive/DataflowLattice.h" #include "clang/Analysis/FlowSensitive/Value.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/DenseSet.h" @@ -299,33 +298,21 @@ return true; } -LatticeJoinEffect Environment::join(const Environment &Other, - Environment::ValueModel &Model) { +void Environment::join(const Environment &Other, + Environment::ValueModel &Model) { assert(DACtx == Other.DACtx); assert(ReturnLoc == Other.ReturnLoc); assert(ThisPointeeLoc == Other.ThisPointeeLoc); - auto Effect = LatticeJoinEffect::Unchanged; - Environment JoinedEnv(*DACtx); JoinedEnv.ReturnLoc = ReturnLoc; JoinedEnv.ThisPointeeLoc = ThisPointeeLoc; JoinedEnv.DeclToLoc = intersectDenseMaps(DeclToLoc, Other.DeclToLoc); - if (DeclToLoc.size() != JoinedEnv.DeclToLoc.size()) - Effect = LatticeJoinEffect::Changed; - JoinedEnv.ExprToLoc = intersectDenseMaps(ExprToLoc, Other.ExprToLoc); - if (ExprToLoc.size() != JoinedEnv.ExprToLoc.size()) - Effect = LatticeJoinEffect::Changed; - JoinedEnv.MemberLocToStruct = intersectDenseMaps(MemberLocToStruct, Other.MemberLocToStruct); - if (MemberLocToStruct.size() != JoinedEnv.MemberLocToStruct.size()) - Effect = LatticeJoinEffect::Changed; - - // FIXME: set `Effect` as needed. JoinedEnv.FlowConditionToken = &DACtx->joinFlowConditions( *FlowConditionToken, *Other.FlowConditionToken); @@ -350,12 +337,8 @@ Loc->getType(), Val, *this, It->second, Other, JoinedEnv, Model)) JoinedEnv.LocToVal.insert({Loc, MergedVal}); } - if (LocToVal.size() != JoinedEnv.LocToVal.size()) - Effect = LatticeJoinEffect::Changed; *this = std::move(JoinedEnv); - - return Effect; } StorageLocation &Environment::createStorageLocation(QualType Type) {