[clang] 817dd5e - [clang][dataflow] Rename member to make it clear that it isn't stable
Stanislav Gatev via cfe-commits
cfe-commits at lists.llvm.org
Tue Aug 2 23:25:26 PDT 2022
Author: Stanislav Gatev
Date: 2022-08-03T06:25:02Z
New Revision: 817dd5e3fd6bdad584728843c72892f0fae058cd
URL: https://github.com/llvm/llvm-project/commit/817dd5e3fd6bdad584728843c72892f0fae058cd
DIFF: https://github.com/llvm/llvm-project/commit/817dd5e3fd6bdad584728843c72892f0fae058cd.diff
LOG: [clang][dataflow] Rename member to make it clear that it isn't stable
Rename `DataflowAnalysisContext::getStableStorageLocation(QualType)`
to `createStorageLocation`, to make it clear that it doesn't return
a stable storage location.
Differential Revision: https://reviews.llvm.org/D131021
Reviewed-by: ymandel, xazax.hun, gribozavr2
Added:
Modified:
clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h
clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
Removed:
################################################################################
diff --git a/clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h b/clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h
index b3e725ad3f6a5..6a9a35ac0baf1 100644
--- a/clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h
+++ b/clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h
@@ -90,12 +90,12 @@ class DataflowAnalysisContext {
return *cast<T>(Vals.back().get());
}
- /// Returns a stable storage location appropriate for `Type`.
+ /// Returns a new storage location appropriate for `Type`.
///
/// Requirements:
///
/// `Type` must not be null.
- StorageLocation &getStableStorageLocation(QualType Type);
+ StorageLocation &createStorageLocation(QualType Type);
/// Returns a stable storage location for `D`.
StorageLocation &getStableStorageLocation(const VarDecl &D);
diff --git a/clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp b/clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
index 216f41bdee1cf..fa70e5fd9f9a5 100644
--- a/clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
+++ b/clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
@@ -24,15 +24,14 @@
namespace clang {
namespace dataflow {
-StorageLocation &
-DataflowAnalysisContext::getStableStorageLocation(QualType Type) {
+StorageLocation &DataflowAnalysisContext::createStorageLocation(QualType Type) {
if (!Type.isNull() &&
(Type->isStructureOrClassType() || Type->isUnionType())) {
// FIXME: Explore options to avoid eager initialization of fields as some of
// them might not be needed for a particular analysis.
llvm::DenseMap<const ValueDecl *, StorageLocation *> FieldLocs;
for (const FieldDecl *Field : getObjectFields(Type))
- FieldLocs.insert({Field, &getStableStorageLocation(Field->getType())});
+ FieldLocs.insert({Field, &createStorageLocation(Field->getType())});
return takeOwnership(
std::make_unique<AggregateStorageLocation>(Type, std::move(FieldLocs)));
}
@@ -43,7 +42,7 @@ StorageLocation &
DataflowAnalysisContext::getStableStorageLocation(const VarDecl &D) {
if (auto *Loc = getStorageLocation(D))
return *Loc;
- auto &Loc = getStableStorageLocation(D.getType());
+ auto &Loc = createStorageLocation(D.getType());
setStorageLocation(D, Loc);
return Loc;
}
@@ -52,7 +51,7 @@ StorageLocation &
DataflowAnalysisContext::getStableStorageLocation(const Expr &E) {
if (auto *Loc = getStorageLocation(E))
return *Loc;
- auto &Loc = getStableStorageLocation(E.getType());
+ auto &Loc = createStorageLocation(E.getType());
setStorageLocation(E, Loc);
return Loc;
}
@@ -63,7 +62,7 @@ DataflowAnalysisContext::getOrCreateNullPointerValue(QualType PointeeType) {
PointeeType.isNull() ? PointeeType : PointeeType.getCanonicalType();
auto Res = NullPointerVals.try_emplace(CanonicalPointeeType, nullptr);
if (Res.second) {
- auto &PointeeLoc = getStableStorageLocation(CanonicalPointeeType);
+ auto &PointeeLoc = createStorageLocation(CanonicalPointeeType);
Res.first->second =
&takeOwnership(std::make_unique<PointerValue>(PointeeLoc));
}
diff --git a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
index 1bb4e192ef341..4e5b2adee5c99 100644
--- a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
+++ b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
@@ -337,7 +337,7 @@ LatticeJoinEffect Environment::join(const Environment &Other,
}
StorageLocation &Environment::createStorageLocation(QualType Type) {
- return DACtx->getStableStorageLocation(Type);
+ return DACtx->createStorageLocation(Type);
}
StorageLocation &Environment::createStorageLocation(const VarDecl &D) {
More information about the cfe-commits
mailing list