[clang] effdfa7 - [clang][dataflow] Use `isRecordType()` where appropriate.
Martin Braenne via cfe-commits
cfe-commits at lists.llvm.org
Thu Apr 6 00:26:34 PDT 2023
Author: Martin Braenne
Date: 2023-04-06T07:26:24Z
New Revision: effdfa7d5f49b00b4c0d36f7c6835b519b0f46bb
URL: https://github.com/llvm/llvm-project/commit/effdfa7d5f49b00b4c0d36f7c6835b519b0f46bb
DIFF: https://github.com/llvm/llvm-project/commit/effdfa7d5f49b00b4c0d36f7c6835b519b0f46bb.diff
LOG: [clang][dataflow] Use `isRecordType()` where appropriate.
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).
Reviewed By: sammccall, xazax.hun
Differential Revision: https://reviews.llvm.org/D147603
Added:
Modified:
clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
Removed:
################################################################################
diff --git a/clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp b/clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
index 4d8a42c1390c2..1fbc3759747e8 100644
--- a/clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
+++ b/clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
@@ -45,8 +45,7 @@ DataflowAnalysisContext::getReferencedFields(QualType Type) {
}
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
diff --git a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
index ee8f6c5b8f574..6a6343b5f169b 100644
--- a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
+++ b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
@@ -608,7 +608,7 @@ void Environment::setValue(const StorageLocation &Loc, Value &Val) {
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);
@@ -708,7 +708,7 @@ Value *Environment::createValueUnlessSelfReferential(
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)) {
More information about the cfe-commits
mailing list