diff options
author | Martin Braenne <mboehme@google.com> | 2023-08-28 12:55:35 +0000 |
---|---|---|
committer | Martin Braenne <mboehme@google.com> | 2023-08-29 06:53:48 +0000 |
commit | aef05a12329cf83c0a6fe46b464ab6ac08ee3439 (patch) | |
tree | 78ab5fa3b43f74cd48e327498ae4accf3198cef3 /clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp | |
parent | 20e6515d5c5ff155a54e10f64caef1c76d8d5976 (diff) | |
download | llvm-aef05a12329cf83c0a6fe46b464ab6ac08ee3439.zip llvm-aef05a12329cf83c0a6fe46b464ab6ac08ee3439.tar.gz llvm-aef05a12329cf83c0a6fe46b464ab6ac08ee3439.tar.bz2 |
[clang][dataflow][NFC] Eliminate `getStorageLocation()` / `setStorageLocation()` in `DataflowAnalysisContext`.
Instead, inline them into the `getStableStorageLocation()` overloads, which is the only place they were called from (and should be called from).
`getStorageLocation()` / `setStorageLocation()` were confusing because neither their name nor their documentation made reference to the fact that the storage location is stable.
It didn't make sense to keep these as private member functions either. The code for the two `getStableStorageLocation()` overloads has become only marginally more complex by inlining these functions, and the `Expr` version is actually more efficient because we only call `ignoreCFGOmittedNodes()` once instead of twice.
Reviewed By: ymandel, xazax.hun
Differential Revision: https://reviews.llvm.org/D158981
Diffstat (limited to 'clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp')
-rw-r--r-- | clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp b/clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp index 0a6d779..47a994f 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; } |