aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
diff options
context:
space:
mode:
authorMartin Braenne <mboehme@google.com>2023-04-03 14:45:13 +0000
committerMartin Braenne <mboehme@google.com>2023-04-04 07:13:44 +0000
commit745a957f9dc562477cbe587fb3fa8305713b51b3 (patch)
tree0ff99bf94ed0b233f9b32dec0b745bfcd6321646 /clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
parent3ce5ac51700f11a62ee5b25393082d44028906ed (diff)
downloadllvm-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/DataflowEnvironment.cpp')
-rw-r--r--clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
index fbb8d8a..faeabdc 100644
--- a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
+++ b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
@@ -359,7 +359,7 @@ void Environment::pushCallInternal(const FunctionDecl *FuncDecl,
QualType ParamType = Param->getType();
if (ParamType->isReferenceType()) {
- auto &Val = takeOwnership(std::make_unique<ReferenceValue>(*ArgLoc));
+ auto &Val = create<ReferenceValue>(*ArgLoc);
setValue(Loc, Val);
} else if (auto *ArgVal = getValue(*ArgLoc)) {
setValue(Loc, *ArgVal);
@@ -685,7 +685,7 @@ Value *Environment::createValueUnlessSelfReferential(
// with integers, and so distinguishing them serves no purpose, but could
// prevent convergence.
CreatedValuesCount++;
- return &takeOwnership(std::make_unique<IntegerValue>());
+ return &create<IntegerValue>();
}
if (Type->isReferenceType()) {
@@ -702,7 +702,7 @@ Value *Environment::createValueUnlessSelfReferential(
setValue(PointeeLoc, *PointeeVal);
}
- return &takeOwnership(std::make_unique<ReferenceValue>(PointeeLoc));
+ return &create<ReferenceValue>(PointeeLoc);
}
if (Type->isPointerType()) {
@@ -719,7 +719,7 @@ Value *Environment::createValueUnlessSelfReferential(
setValue(PointeeLoc, *PointeeVal);
}
- return &takeOwnership(std::make_unique<PointerValue>(PointeeLoc));
+ return &create<PointerValue>(PointeeLoc);
}
if (Type->isStructureOrClassType() || Type->isUnionType()) {
@@ -739,8 +739,7 @@ Value *Environment::createValueUnlessSelfReferential(
Visited.erase(FieldType.getCanonicalType());
}
- return &takeOwnership(
- std::make_unique<StructValue>(std::move(FieldValues)));
+ return &create<StructValue>(std::move(FieldValues));
}
return nullptr;