[PATCH] D154952: [clang][dataflow] Various refactorings in TypeErasedDataflowAnalysisTest.cpp
Martin Böhme via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 11 21:53:12 PDT 2023
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1e9b4fc1dcf2: [clang][dataflow] Various refactorings in TypeErasedDataflowAnalysisTest.cpp (authored by mboehme).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D154952/new/
https://reviews.llvm.org/D154952
Files:
clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
Index: clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
===================================================================
--- clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
@@ -370,6 +370,13 @@
// FIXME: Called functions at point `p` should contain only "foo".
}
+StructValue &createNewStructValue(AggregateStorageLocation &Loc,
+ Environment &Env) {
+ auto &Val = *cast<StructValue>(Env.createValue(Loc.getType()));
+ Env.setValue(Loc, Val);
+ return Val;
+}
+
// Models an analysis that uses flow conditions.
class SpecialBoolAnalysis final
: public DataflowAnalysis<SpecialBoolAnalysis, NoopLattice> {
@@ -390,23 +397,18 @@
if (const auto *E = selectFirst<CXXConstructExpr>(
"call", match(cxxConstructExpr(HasSpecialBoolType).bind("call"), *S,
getASTContext()))) {
- auto &ConstructorVal = *Env.createValue(E->getType());
- ConstructorVal.setProperty("is_set", Env.getBoolLiteralValue(false));
- Env.setValue(*Env.getStorageLocation(*E, SkipPast::None), ConstructorVal);
+ cast<StructValue>(Env.getValueStrict(*E))
+ ->setProperty("is_set", Env.getBoolLiteralValue(false));
} else if (const auto *E = selectFirst<CXXMemberCallExpr>(
"call", match(cxxMemberCallExpr(callee(cxxMethodDecl(ofClass(
SpecialBoolRecordDecl))))
.bind("call"),
*S, getASTContext()))) {
- auto *Object = E->getImplicitObjectArgument();
- assert(Object != nullptr);
-
- auto *ObjectLoc = getImplicitObjectLocation(*E, Env);
- assert(ObjectLoc != nullptr);
+ auto &ObjectLoc =
+ *cast<AggregateStorageLocation>(getImplicitObjectLocation(*E, Env));
- auto &ConstructorVal = *Env.createValue(Object->getType());
- ConstructorVal.setProperty("is_set", Env.getBoolLiteralValue(true));
- Env.setValue(*ObjectLoc, ConstructorVal);
+ createNewStructValue(ObjectLoc, Env)
+ .setProperty("is_set", Env.getBoolLiteralValue(true));
}
}
@@ -551,21 +553,19 @@
*S, getASTContext());
if (const auto *E = selectFirst<CXXConstructExpr>(
"construct", Matches)) {
- auto &ConstructorVal = *Env.createValue(E->getType());
- ConstructorVal.setProperty("has_value", Env.getBoolLiteralValue(false));
- Env.setValue(*Env.getStorageLocation(*E, SkipPast::None), ConstructorVal);
+ cast<StructValue>(Env.getValueStrict(*E))
+ ->setProperty("has_value", Env.getBoolLiteralValue(false));
} else if (const auto *E =
selectFirst<CXXOperatorCallExpr>("operator", Matches)) {
assert(E->getNumArgs() > 0);
auto *Object = E->getArg(0);
assert(Object != nullptr);
- auto *ObjectLoc = Env.getStorageLocation(*Object, SkipPast::Reference);
- assert(ObjectLoc != nullptr);
+ auto &ObjectLoc = *cast<AggregateStorageLocation>(
+ Env.getStorageLocation(*Object, SkipPast::Reference));
- auto &ConstructorVal = *Env.createValue(Object->getType());
- ConstructorVal.setProperty("has_value", Env.getBoolLiteralValue(true));
- Env.setValue(*ObjectLoc, ConstructorVal);
+ createNewStructValue(ObjectLoc, Env)
+ .setProperty("has_value", Env.getBoolLiteralValue(true));
}
}
@@ -1227,9 +1227,7 @@
match(callExpr(callee(functionDecl(hasName("makeTop")))).bind("top"),
*S, getASTContext());
if (const auto *E = selectFirst<CallExpr>("top", Matches)) {
- auto &Loc = Env.createStorageLocation(*E);
- Env.setValue(Loc, Env.makeTopBoolValue());
- Env.setStorageLocation(*E, Loc);
+ Env.setValueStrict(*E, Env.makeTopBoolValue());
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D154952.539370.patch
Type: text/x-patch
Size: 3968 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230712/67abb7d3/attachment-0001.bin>
More information about the cfe-commits
mailing list