[PATCH] D147603: [clang][dataflow] Use `isRecordType()` where appropriate.
Martin Böhme via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 5 05:32:29 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.
This is less verbose than checking for class, struct, and union individually,
and I believe it's also more efficient (not that that should be the overriding
concern).
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D147603
Files:
clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
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
@@ -608,7 +608,7 @@
auto &AggregateLoc = *cast<AggregateStorageLocation>(&Loc);
const QualType Type = AggregateLoc.getType();
- assert(Type->isStructureOrClassType() || Type->isUnionType());
+ assert(Type->isRecordType());
for (const FieldDecl *Field : DACtx->getReferencedFields(Type)) {
assert(Field != nullptr);
@@ -722,7 +722,7 @@
return &create<PointerValue>(PointeeLoc);
}
- if (Type->isStructureOrClassType() || Type->isUnionType()) {
+ if (Type->isRecordType()) {
CreatedValuesCount++;
llvm::DenseMap<const ValueDecl *, Value *> FieldValues;
for (const FieldDecl *Field : DACtx->getReferencedFields(Type)) {
Index: clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
===================================================================
--- clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
+++ clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
@@ -45,8 +45,7 @@
}
StorageLocation &DataflowAnalysisContext::createStorageLocation(QualType Type) {
- if (!Type.isNull() &&
- (Type->isStructureOrClassType() || Type->isUnionType())) {
+ if (!Type.isNull() && Type->isRecordType()) {
llvm::DenseMap<const ValueDecl *, StorageLocation *> FieldLocs;
// During context-sensitive analysis, a struct may be allocated in one
// function, but its field accessed in a function lower in the stack than
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D147603.511062.patch
Type: text/x-patch
Size: 1664 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230405/bb208552/attachment.bin>
More information about the cfe-commits
mailing list