diff --git a/clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h b/clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h index e5c325b876bd7..685bbe486b54e 100644 --- a/clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h +++ b/clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h @@ -103,39 +103,6 @@ class DataflowAnalysisContext { /// Returns a stable storage location for `E`. StorageLocation &getStableStorageLocation(const Expr &E); - /// Assigns `Loc` as the storage location of `D`. - /// - /// Requirements: - /// - /// `D` must not be assigned a storage location. - void setStorageLocation(const ValueDecl &D, StorageLocation &Loc) { - assert(!DeclToLoc.contains(&D)); - DeclToLoc[&D] = &Loc; - } - - /// Returns the storage location assigned to `D` or null if `D` has no - /// assigned storage location. - StorageLocation *getStorageLocation(const ValueDecl &D) const { - return DeclToLoc.lookup(&D); - } - - /// Assigns `Loc` as the storage location of `E`. - /// - /// Requirements: - /// - /// `E` must not be assigned a storage location. - void setStorageLocation(const Expr &E, StorageLocation &Loc) { - const Expr &CanonE = ignoreCFGOmittedNodes(E); - assert(!ExprToLoc.contains(&CanonE)); - ExprToLoc[&CanonE] = &Loc; - } - - /// Returns the storage location assigned to `E` or null if `E` has no - /// assigned storage location. - StorageLocation *getStorageLocation(const Expr &E) const { - return ExprToLoc.lookup(&ignoreCFGOmittedNodes(E)); - } - /// Returns a pointer value that represents a null pointer. Calls with /// `PointeeType` that are canonically equivalent will return the same result. /// A null `PointeeType` can be used for the pointee of `std::nullptr_t`. diff --git a/clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp b/clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp index 0a6d779220825..47a994f4bbdb6 100644 --- a/clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp +++ b/clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp @@ -74,19 +74,21 @@ StorageLocation &DataflowAnalysisContext::createStorageLocation(QualType Type) { StorageLocation & DataflowAnalysisContext::getStableStorageLocation(const VarDecl &D) { - if (auto *Loc = getStorageLocation(D)) + if (auto *Loc = DeclToLoc.lookup(&D)) return *Loc; auto &Loc = createStorageLocation(D.getType().getNonReferenceType()); - setStorageLocation(D, Loc); + DeclToLoc[&D] = &Loc; return Loc; } StorageLocation & DataflowAnalysisContext::getStableStorageLocation(const Expr &E) { - if (auto *Loc = getStorageLocation(E)) + const Expr &CanonE = ignoreCFGOmittedNodes(E); + + if (auto *Loc = ExprToLoc.lookup(&CanonE)) return *Loc; - auto &Loc = createStorageLocation(E.getType()); - setStorageLocation(E, Loc); + auto &Loc = createStorageLocation(CanonE.getType()); + ExprToLoc[&CanonE] = &Loc; return Loc; }