[PATCH] D147601: [clang][dataflow] Eliminate code duplication in Environment::createValueUnlessSelfReferential().
Martin Böhme via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 5 04:20:45 PDT 2023
mboehme created this revision.
Herald added subscribers: martong, xazax.hun.
Herald added a reviewer: NoQ.
Herald added a project: All.
mboehme requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D147601
Files:
clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
Index: clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
===================================================================
--- clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
+++ clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
@@ -688,9 +688,9 @@
return &create<IntegerValue>();
}
- if (Type->isReferenceType()) {
+ if (Type->isReferenceType() || Type->isPointerType()) {
CreatedValuesCount++;
- QualType PointeeType = Type->castAs<ReferenceType>()->getPointeeType();
+ QualType PointeeType = Type->getPointeeType();
auto &PointeeLoc = createStorageLocation(PointeeType);
if (Visited.insert(PointeeType.getCanonicalType()).second) {
@@ -702,24 +702,10 @@
setValue(PointeeLoc, *PointeeVal);
}
- return &create<ReferenceValue>(PointeeLoc);
- }
-
- if (Type->isPointerType()) {
- CreatedValuesCount++;
- QualType PointeeType = Type->castAs<PointerType>()->getPointeeType();
- auto &PointeeLoc = createStorageLocation(PointeeType);
-
- if (Visited.insert(PointeeType.getCanonicalType()).second) {
- Value *PointeeVal = createValueUnlessSelfReferential(
- PointeeType, Visited, Depth, CreatedValuesCount);
- Visited.erase(PointeeType.getCanonicalType());
-
- if (PointeeVal != nullptr)
- setValue(PointeeLoc, *PointeeVal);
- }
-
- return &create<PointerValue>(PointeeLoc);
+ if (Type->isReferenceType())
+ return &create<ReferenceValue>(PointeeLoc);
+ else
+ return &create<PointerValue>(PointeeLoc);
}
if (Type->isStructureOrClassType() || Type->isUnionType()) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D147601.511042.patch
Type: text/x-patch
Size: 1615 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230405/9757ffa0/attachment.bin>
More information about the cfe-commits
mailing list