diff options
author | Martin Braenne <mboehme@google.com> | 2023-04-03 14:45:13 +0000 |
---|---|---|
committer | Martin Braenne <mboehme@google.com> | 2023-04-04 07:13:44 +0000 |
commit | 745a957f9dc562477cbe587fb3fa8305713b51b3 (patch) | |
tree | 0ff99bf94ed0b233f9b32dec0b745bfcd6321646 /clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp | |
parent | 3ce5ac51700f11a62ee5b25393082d44028906ed (diff) | |
download | llvm-745a957f9dc562477cbe587fb3fa8305713b51b3.zip llvm-745a957f9dc562477cbe587fb3fa8305713b51b3.tar.gz llvm-745a957f9dc562477cbe587fb3fa8305713b51b3.tar.bz2 |
[clang][dataflow] Add `create<T>()` methods to `Environment` and `DataflowAnalysisContext`.
These methods provide a less verbose way of allocating `StorageLocation`s and
`Value`s than the existing `takeOwnership(make_unique(...))` pattern.
In addition, because allocation of `StorageLocation`s and `Value`s now happens
within the `DataflowAnalysisContext`, the `create<T>()` open up the possibility
of using `BumpPtrAllocator` to allocate these objects if it turns out this
helps performance.
Reviewed By: ymandel, xazax.hun, gribozavr2
Differential Revision: https://reviews.llvm.org/D147302
Diffstat (limited to 'clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp')
-rw-r--r-- | clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp b/clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp index 57169ba..5a49ef1 100644 --- a/clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp +++ b/clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp @@ -59,10 +59,9 @@ StorageLocation &DataflowAnalysisContext::createStorageLocation(QualType Type) { : getReferencedFields(Type); for (const FieldDecl *Field : Fields) FieldLocs.insert({Field, &createStorageLocation(Field->getType())}); - return takeOwnership( - std::make_unique<AggregateStorageLocation>(Type, std::move(FieldLocs))); + return create<AggregateStorageLocation>(Type, std::move(FieldLocs)); } - return takeOwnership(std::make_unique<ScalarStorageLocation>(Type)); + return create<ScalarStorageLocation>(Type); } StorageLocation & @@ -90,8 +89,7 @@ DataflowAnalysisContext::getOrCreateNullPointerValue(QualType PointeeType) { auto Res = NullPointerVals.try_emplace(CanonicalPointeeType, nullptr); if (Res.second) { auto &PointeeLoc = createStorageLocation(CanonicalPointeeType); - Res.first->second = - &takeOwnership(std::make_unique<PointerValue>(PointeeLoc)); + Res.first->second = &create<PointerValue>(PointeeLoc); } return *Res.first->second; } @@ -112,8 +110,7 @@ BoolValue &DataflowAnalysisContext::getOrCreateConjunction(BoolValue &LHS, auto Res = ConjunctionVals.try_emplace(makeCanonicalBoolValuePair(LHS, RHS), nullptr); if (Res.second) - Res.first->second = - &takeOwnership(std::make_unique<ConjunctionValue>(LHS, RHS)); + Res.first->second = &create<ConjunctionValue>(LHS, RHS); return *Res.first->second; } @@ -125,15 +122,14 @@ BoolValue &DataflowAnalysisContext::getOrCreateDisjunction(BoolValue &LHS, auto Res = DisjunctionVals.try_emplace(makeCanonicalBoolValuePair(LHS, RHS), nullptr); if (Res.second) - Res.first->second = - &takeOwnership(std::make_unique<DisjunctionValue>(LHS, RHS)); + Res.first->second = &create<DisjunctionValue>(LHS, RHS); return *Res.first->second; } BoolValue &DataflowAnalysisContext::getOrCreateNegation(BoolValue &Val) { auto Res = NegationVals.try_emplace(&Val, nullptr); if (Res.second) - Res.first->second = &takeOwnership(std::make_unique<NegationValue>(Val)); + Res.first->second = &create<NegationValue>(Val); return *Res.first->second; } @@ -144,8 +140,7 @@ BoolValue &DataflowAnalysisContext::getOrCreateImplication(BoolValue &LHS, auto Res = ImplicationVals.try_emplace(std::make_pair(&LHS, &RHS), nullptr); if (Res.second) - Res.first->second = - &takeOwnership(std::make_unique<ImplicationValue>(LHS, RHS)); + Res.first->second = &create<ImplicationValue>(LHS, RHS); return *Res.first->second; } @@ -157,8 +152,7 @@ BoolValue &DataflowAnalysisContext::getOrCreateIff(BoolValue &LHS, auto Res = BiconditionalVals.try_emplace(makeCanonicalBoolValuePair(LHS, RHS), nullptr); if (Res.second) - Res.first->second = - &takeOwnership(std::make_unique<BiconditionalValue>(LHS, RHS)); + Res.first->second = &create<BiconditionalValue>(LHS, RHS); return *Res.first->second; } |