[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
This commit is contained in:
Stanislav Gatev 2022-08-02 21:05:48 +00:00
parent 9ef11616b2
commit 817dd5e3fd
3 changed files with 8 additions and 9 deletions

View File

@ -90,12 +90,12 @@ public:
return *cast<T>(Vals.back().get()); return *cast<T>(Vals.back().get());
} }
/// Returns a stable storage location appropriate for `Type`. /// Returns a new storage location appropriate for `Type`.
/// ///
/// Requirements: /// Requirements:
/// ///
/// `Type` must not be null. /// `Type` must not be null.
StorageLocation &getStableStorageLocation(QualType Type); StorageLocation &createStorageLocation(QualType Type);
/// Returns a stable storage location for `D`. /// Returns a stable storage location for `D`.
StorageLocation &getStableStorageLocation(const VarDecl &D); StorageLocation &getStableStorageLocation(const VarDecl &D);

View File

@ -24,15 +24,14 @@
namespace clang { namespace clang {
namespace dataflow { namespace dataflow {
StorageLocation & StorageLocation &DataflowAnalysisContext::createStorageLocation(QualType Type) {
DataflowAnalysisContext::getStableStorageLocation(QualType Type) {
if (!Type.isNull() && if (!Type.isNull() &&
(Type->isStructureOrClassType() || Type->isUnionType())) { (Type->isStructureOrClassType() || Type->isUnionType())) {
// FIXME: Explore options to avoid eager initialization of fields as some of // FIXME: Explore options to avoid eager initialization of fields as some of
// them might not be needed for a particular analysis. // them might not be needed for a particular analysis.
llvm::DenseMap<const ValueDecl *, StorageLocation *> FieldLocs; llvm::DenseMap<const ValueDecl *, StorageLocation *> FieldLocs;
for (const FieldDecl *Field : getObjectFields(Type)) for (const FieldDecl *Field : getObjectFields(Type))
FieldLocs.insert({Field, &getStableStorageLocation(Field->getType())}); FieldLocs.insert({Field, &createStorageLocation(Field->getType())});
return takeOwnership( return takeOwnership(
std::make_unique<AggregateStorageLocation>(Type, std::move(FieldLocs))); std::make_unique<AggregateStorageLocation>(Type, std::move(FieldLocs)));
} }
@ -43,7 +42,7 @@ StorageLocation &
DataflowAnalysisContext::getStableStorageLocation(const VarDecl &D) { DataflowAnalysisContext::getStableStorageLocation(const VarDecl &D) {
if (auto *Loc = getStorageLocation(D)) if (auto *Loc = getStorageLocation(D))
return *Loc; return *Loc;
auto &Loc = getStableStorageLocation(D.getType()); auto &Loc = createStorageLocation(D.getType());
setStorageLocation(D, Loc); setStorageLocation(D, Loc);
return Loc; return Loc;
} }
@ -52,7 +51,7 @@ StorageLocation &
DataflowAnalysisContext::getStableStorageLocation(const Expr &E) { DataflowAnalysisContext::getStableStorageLocation(const Expr &E) {
if (auto *Loc = getStorageLocation(E)) if (auto *Loc = getStorageLocation(E))
return *Loc; return *Loc;
auto &Loc = getStableStorageLocation(E.getType()); auto &Loc = createStorageLocation(E.getType());
setStorageLocation(E, Loc); setStorageLocation(E, Loc);
return Loc; return Loc;
} }
@ -63,7 +62,7 @@ DataflowAnalysisContext::getOrCreateNullPointerValue(QualType PointeeType) {
PointeeType.isNull() ? PointeeType : PointeeType.getCanonicalType(); PointeeType.isNull() ? PointeeType : PointeeType.getCanonicalType();
auto Res = NullPointerVals.try_emplace(CanonicalPointeeType, nullptr); auto Res = NullPointerVals.try_emplace(CanonicalPointeeType, nullptr);
if (Res.second) { if (Res.second) {
auto &PointeeLoc = getStableStorageLocation(CanonicalPointeeType); auto &PointeeLoc = createStorageLocation(CanonicalPointeeType);
Res.first->second = Res.first->second =
&takeOwnership(std::make_unique<PointerValue>(PointeeLoc)); &takeOwnership(std::make_unique<PointerValue>(PointeeLoc));
} }

View File

@ -337,7 +337,7 @@ LatticeJoinEffect Environment::join(const Environment &Other,
} }
StorageLocation &Environment::createStorageLocation(QualType Type) { StorageLocation &Environment::createStorageLocation(QualType Type) {
return DACtx->getStableStorageLocation(Type); return DACtx->createStorageLocation(Type);
} }
StorageLocation &Environment::createStorageLocation(const VarDecl &D) { StorageLocation &Environment::createStorageLocation(const VarDecl &D) {