li.zhe.hua created this revision.
li.zhe.hua added a reviewer: ymandel.
Herald added subscribers: martong, xazax.hun.
Herald added a reviewer: NoQ.
Herald added a project: All.
li.zhe.hua requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
Though we request users implementing `join` to return a meaningful
`LatticeJoinEffect`, we never use the returned value. Requiring users
(and the framework) to continue calculating an unused value adds
unnecessary complexity.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D131688
Files:
clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h
clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
clang/include/clang/Analysis/FlowSensitive/DataflowLattice.h
clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h
clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
Index: clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
===================================================================
--- clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
+++ 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) {
Index: clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h
===================================================================
--- clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h
+++ 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,
Index: clang/include/clang/Analysis/FlowSensitive/DataflowLattice.h
===================================================================
--- clang/include/clang/Analysis/FlowSensitive/DataflowLattice.h
+++ 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,
Index: clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
===================================================================
--- clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
+++ 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.
Index: clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h
===================================================================
--- clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h
+++ 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<Derived *>(this)->initialElement()};
}
- LatticeJoinEffect joinTypeErased(TypeErasedLattice &E1,
- const TypeErasedLattice &E2) final {
+ void joinTypeErased(TypeErasedLattice &E1,
+ const TypeErasedLattice &E2) final {
Lattice &L1 = llvm::any_cast<Lattice &>(E1.Value);
const Lattice &L2 = llvm::any_cast<const Lattice &>(E2.Value);
- return L1.join(L2);
+ L1.join(L2);
}
void widenTypeErased(TypeErasedLattice &E1,
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits