aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/AST/CXXInheritance.cpp
diff options
context:
space:
mode:
authorKazu Hirata <kazu@google.com>2024-10-07 06:55:56 -0700
committerGitHub <noreply@github.com>2024-10-07 06:55:56 -0700
commit4c9c2d6082740b4ddda1ecfdc33702e4cbd3444d (patch)
treec1ca9bb6aebc7fe94bdb30ed79c15b0e84d0756f /clang/lib/AST/CXXInheritance.cpp
parent1666d13078e4799df2d8eaa101ccf02acd031427 (diff)
downloadllvm-4c9c2d6082740b4ddda1ecfdc33702e4cbd3444d.zip
llvm-4c9c2d6082740b4ddda1ecfdc33702e4cbd3444d.tar.gz
llvm-4c9c2d6082740b4ddda1ecfdc33702e4cbd3444d.tar.bz2
[AST] Avoid repeated hash lookups (NFC) (#111327)
Here I'm splitting up the existing "if" statement into two. Mixing hasDefinition() and insert() in one "if" condition would be extremely confusing as hasDefinition() doesn't change anything while insert() does.
Diffstat (limited to 'clang/lib/AST/CXXInheritance.cpp')
-rw-r--r--clang/lib/AST/CXXInheritance.cpp8
1 files changed, 3 insertions, 5 deletions
diff --git a/clang/lib/AST/CXXInheritance.cpp b/clang/lib/AST/CXXInheritance.cpp
index 25de2a2..eb265a8 100644
--- a/clang/lib/AST/CXXInheritance.cpp
+++ b/clang/lib/AST/CXXInheritance.cpp
@@ -259,12 +259,10 @@ bool CXXBasePaths::lookupInBases(ASTContext &Context,
BaseRecord = TD->getTemplatedDecl();
}
if (BaseRecord) {
- if (!BaseRecord->hasDefinition() ||
- VisitedDependentRecords.count(BaseRecord)) {
+ if (!BaseRecord->hasDefinition())
+ BaseRecord = nullptr;
+ else if (!VisitedDependentRecords.insert(BaseRecord).second)
BaseRecord = nullptr;
- } else {
- VisitedDependentRecords.insert(BaseRecord);
- }
}
} else {
BaseRecord = cast<CXXRecordDecl>(