[clang] d6d29dc - Revert commit 01adf96ebc86 because it caused "Unhandled DeclRefExpr" errors.
Liming Liu via cfe-commits
cfe-commits at lists.llvm.org
Sat Jan 28 22:37:43 PST 2023
Author: Liming Liu
Date: 2023-01-29T14:37:13+08:00
New Revision: d6d29dc4fa9cbb6d4d5622f9fea4697669edf214
URL: https://github.com/llvm/llvm-project/commit/d6d29dc4fa9cbb6d4d5622f9fea4697669edf214
DIFF: https://github.com/llvm/llvm-project/commit/d6d29dc4fa9cbb6d4d5622f9fea4697669edf214.diff
LOG: Revert commit 01adf96ebc86 because it caused "Unhandled DeclRefExpr" errors.
Added:
Modified:
clang/docs/ReleaseNotes.rst
clang/include/clang/AST/DeclCXX.h
clang/lib/AST/CXXInheritance.cpp
clang/lib/Sema/SemaExpr.cpp
clang/test/SemaCXX/decltype.cpp
Removed:
################################################################################
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index a73a750cbe305..4c72ec64f6e19 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -57,9 +57,6 @@ Bug Fixes
- Fix crash on invalid code when looking up a destructor in a templated class
inside a namespace. This fixes
`Issue 59446 <https://github.com/llvm/llvm-project/issues/59446>`_.
-- Fix an issue about ``decltype`` in the members of class templates derived from
- templates with related parameters. This fixes
- `Issue 58674 <https://github.com/llvm/llvm-project/issues/58674>`_.
Improvements to Clang's diagnostics
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/clang/include/clang/AST/DeclCXX.h b/clang/include/clang/AST/DeclCXX.h
index 30200a1785a3f..11276c77490ce 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -1547,8 +1547,7 @@ class CXXRecordDecl : public RecordDecl {
/// \param Base the base class we are searching for.
///
/// \returns true if this class is derived from Base, false otherwise.
- bool isDerivedFrom(const CXXRecordDecl *Base,
- bool LookupIndependent = false) const;
+ bool isDerivedFrom(const CXXRecordDecl *Base) const;
/// Determine whether this class is derived from the type \p Base.
///
@@ -1566,8 +1565,7 @@ class CXXRecordDecl : public RecordDecl {
///
/// \todo add a separate parameter to configure IsDerivedFrom, rather than
/// tangling input and output in \p Paths
- bool isDerivedFrom(const CXXRecordDecl *Base, CXXBasePaths &Paths,
- bool LookupIndependent = false) const;
+ bool isDerivedFrom(const CXXRecordDecl *Base, CXXBasePaths &Paths) const;
/// Determine whether this class is virtually derived from
/// the class \p Base.
diff --git a/clang/lib/AST/CXXInheritance.cpp b/clang/lib/AST/CXXInheritance.cpp
index 175e461787fdf..25de2a20a7f3b 100644
--- a/clang/lib/AST/CXXInheritance.cpp
+++ b/clang/lib/AST/CXXInheritance.cpp
@@ -64,16 +64,14 @@ void CXXBasePaths::swap(CXXBasePaths &Other) {
std::swap(DetectedVirtual, Other.DetectedVirtual);
}
-bool CXXRecordDecl::isDerivedFrom(const CXXRecordDecl *Base,
- bool LookupIndependent) const {
+bool CXXRecordDecl::isDerivedFrom(const CXXRecordDecl *Base) const {
CXXBasePaths Paths(/*FindAmbiguities=*/false, /*RecordPaths=*/false,
/*DetectVirtual=*/false);
- return isDerivedFrom(Base, Paths, LookupIndependent);
+ return isDerivedFrom(Base, Paths);
}
bool CXXRecordDecl::isDerivedFrom(const CXXRecordDecl *Base,
- CXXBasePaths &Paths,
- bool LookupIndependent) const {
+ CXXBasePaths &Paths) const {
if (getCanonicalDecl() == Base->getCanonicalDecl())
return false;
@@ -85,7 +83,7 @@ bool CXXRecordDecl::isDerivedFrom(const CXXRecordDecl *Base,
return Specifier->getType()->getAsRecordDecl() &&
FindBaseClass(Specifier, Path, BaseDecl);
},
- Paths, LookupIndependent);
+ Paths);
}
bool CXXRecordDecl::isVirtuallyDerivedFrom(const CXXRecordDecl *Base) const {
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index b7c62f5375e42..2842add2cc4af 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -2693,36 +2693,20 @@ Sema::ActOnIdExpression(Scope *S, CXXScopeSpec &SS,
// to get this right here so that we don't end up making a
// spuriously dependent expression if we're inside a dependent
// instance method.
- //
- // We also don't need to do this if R resolved to a member in another
- // class, which can happen in an unevaluated operand:
- //
- // C++ [expr.prim.id]p3.3:
- // If that id-expression denotes a non-static data member and it
- // appears in an unevaluated operand.
if (!R.empty() && (*R.begin())->isCXXClassMember()) {
- bool MightBeImplicitMember = true, CheckField = true;
- if (IsAddressOfOperand) {
- MightBeImplicitMember = SS.isEmpty() && !R.isOverloadedResult();
- CheckField = !R.isUnresolvableResult();
- }
- if (MightBeImplicitMember && CheckField) {
- if (R.isSingleResult() &&
- isa<FieldDecl, IndirectFieldDecl, MSPropertyDecl>(R.getFoundDecl())) {
- auto Class = cast<CXXRecordDecl>((*R.begin())->getDeclContext());
- for (auto Curr = S->getLookupEntity(); Curr && !Curr->isFileContext();
- Curr = Curr->getParent()) {
- if (auto ThisClass = dyn_cast_if_present<CXXRecordDecl>(Curr)) {
- if ((MightBeImplicitMember =
- ThisClass->Equals(Class) ||
- ThisClass->isDerivedFrom(Class,
- /*LookupIndependent=*/true)))
- break;
- }
- }
- } else if (IsAddressOfOperand)
- MightBeImplicitMember = false;
- }
+ bool MightBeImplicitMember;
+ if (!IsAddressOfOperand)
+ MightBeImplicitMember = true;
+ else if (!SS.isEmpty())
+ MightBeImplicitMember = false;
+ else if (R.isOverloadedResult())
+ MightBeImplicitMember = false;
+ else if (R.isUnresolvableResult())
+ MightBeImplicitMember = true;
+ else
+ MightBeImplicitMember = isa<FieldDecl>(R.getFoundDecl()) ||
+ isa<IndirectFieldDecl>(R.getFoundDecl()) ||
+ isa<MSPropertyDecl>(R.getFoundDecl());
if (MightBeImplicitMember)
return BuildPossibleImplicitMemberExpr(SS, TemplateKWLoc,
diff --git a/clang/test/SemaCXX/decltype.cpp b/clang/test/SemaCXX/decltype.cpp
index 96abb60836e40..32c61bbccc842 100644
--- a/clang/test/SemaCXX/decltype.cpp
+++ b/clang/test/SemaCXX/decltype.cpp
@@ -101,44 +101,6 @@ namespace D5789 {
template<class T> void foo(decltype(T(LP1{ .p1 = g1, .p1.x[1] = 'x' }))) {}
}
-namespace GH58674 {
- struct Foo {
- float value_;
- struct nested {
- float value_;
- };
- };
-
- template <typename T>
- struct TemplateFoo {
- float value_;
- };
-
- float bar;
-
- template <typename T>
- struct Animal{};
-
- template <typename T>
- class Cat : Animal<T> {
- using okay = decltype(Foo::value_);
- using also_okay = decltype(bar);
- using okay2 = decltype(Foo::nested::value_);
- using okay3 = decltype(TemplateFoo<T>::value_);
- public:
- void meow() {
- using okay = decltype(Foo::value_);
- using also_okay = decltype(bar);
- using okay2 = decltype(Foo::nested::value_);
- using okay3 = decltype(TemplateFoo<T>::value_);
- }
- };
-
- void baz() {
- Cat<void>{}.meow();
- }
-}
-
template<typename>
class conditional {
};
More information about the cfe-commits
mailing list