aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/AST/CXXInheritance.cpp
diff options
context:
space:
mode:
authorLiming Liu <gangliugangliu.ml@outlook.com>2023-01-10 20:28:52 +0800
committerLiming Liu <gangliugangliu.ml@outlook.com>2023-01-29 13:44:19 +0800
commit01adf96ebc8608bcdda0cacc303035b2e60ccb46 (patch)
tree1753ee200cf7b61cfd2f1285a04e127d3220d074 /clang/lib/AST/CXXInheritance.cpp
parent2667be0eb85b65f95d5cf303162219d067de11ae (diff)
downloadllvm-01adf96ebc8608bcdda0cacc303035b2e60ccb46.zip
llvm-01adf96ebc8608bcdda0cacc303035b2e60ccb46.tar.gz
llvm-01adf96ebc8608bcdda0cacc303035b2e60ccb46.tar.bz2
[clang] Add the check of membership in decltype for the issue #58674
D137531 had once fixed the issue. However, it caused a crash during compiling llvm/unittests/IR/PatternMatch.cpp in stage-2. The reason is the predicator isDerivedFrom does not consider independent types if the derived type is dependent. This patch improves D137531 by adding an option to make isDerivedFrom consider independent types. Differential Revision: https://reviews.llvm.org/D142437
Diffstat (limited to 'clang/lib/AST/CXXInheritance.cpp')
-rw-r--r--clang/lib/AST/CXXInheritance.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/clang/lib/AST/CXXInheritance.cpp b/clang/lib/AST/CXXInheritance.cpp
index 1abbe81..175e461 100644
--- a/clang/lib/AST/CXXInheritance.cpp
+++ b/clang/lib/AST/CXXInheritance.cpp
@@ -64,14 +64,16 @@ void CXXBasePaths::swap(CXXBasePaths &Other) {
std::swap(DetectedVirtual, Other.DetectedVirtual);
}
-bool CXXRecordDecl::isDerivedFrom(const CXXRecordDecl *Base) const {
+bool CXXRecordDecl::isDerivedFrom(const CXXRecordDecl *Base,
+ bool LookupIndependent) const {
CXXBasePaths Paths(/*FindAmbiguities=*/false, /*RecordPaths=*/false,
/*DetectVirtual=*/false);
- return isDerivedFrom(Base, Paths);
+ return isDerivedFrom(Base, Paths, LookupIndependent);
}
bool CXXRecordDecl::isDerivedFrom(const CXXRecordDecl *Base,
- CXXBasePaths &Paths) const {
+ CXXBasePaths &Paths,
+ bool LookupIndependent) const {
if (getCanonicalDecl() == Base->getCanonicalDecl())
return false;
@@ -80,9 +82,10 @@ bool CXXRecordDecl::isDerivedFrom(const CXXRecordDecl *Base,
const CXXRecordDecl *BaseDecl = Base->getCanonicalDecl();
return lookupInBases(
[BaseDecl](const CXXBaseSpecifier *Specifier, CXXBasePath &Path) {
- return FindBaseClass(Specifier, Path, BaseDecl);
+ return Specifier->getType()->getAsRecordDecl() &&
+ FindBaseClass(Specifier, Path, BaseDecl);
},
- Paths);
+ Paths, LookupIndependent);
}
bool CXXRecordDecl::isVirtuallyDerivedFrom(const CXXRecordDecl *Base) const {