Skip to content

Reapply "[clang] Fix name lookup for dependent bases" #118003

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 3, 2024

Conversation

vbe-sc
Copy link
Contributor

@vbe-sc vbe-sc commented Nov 28, 2024

Unlike the previous version (#114978), this patch also removes an unnecessary assert that causes Clang to crash when compiling such tests. (clang/lib/AST/DeclCXX.cpp)

https://lab.llvm.org/buildbot/#/builders/52/builds/4021

template <class T> 
class X {
public:
  X() = default;
  virtual ~X() = default;

  virtual int foo(int x, int y, T &entry) = 0;

  void bar() {
    struct Y : public X<T> {
      Y() : X() {}

      int foo(int, int, T &) override {
        return 42;
      }
    };
  }
};

the assertions:

llvm-project/clang/lib/AST/DeclCXX.cpp:2508: void clang::CXXMethodDecl::addOverriddenMethod(const CXXMethodDecl *): Assertion `!MD->getParent()->isDependentContext() && "Can't add an overridden method to a class template!"' failed.

I believe that this assert is unnecessary and contradicts the logic of this patch. After its removal, Clang was successfully built using itself, and all tests passed.

@vbe-sc vbe-sc requested a review from Endilll as a code owner November 28, 2024 13:42
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Nov 28, 2024
@llvmbot
Copy link
Member

llvmbot commented Nov 28, 2024

@llvm/pr-subscribers-clang

Author: Vladislav Belov (vbe-sc)

Changes

Unlike the previous version, this patch also removes an unnecessary assert that causes Clang to crash when compiling such tests. (clang/lib/AST/DeclCXX.cpp)

https://lab.llvm.org/buildbot/#/builders/52/builds/4021

template &lt;class T&gt; 
class X {
public:
  X() = default;
  virtual ~X() = default;

  virtual int foo(int x, int y, T &amp;entry) = 0;

  void bar() {
    struct Y : public X&lt;T&gt; {
      Y() : X() {}

      int foo(int, int, T &amp;) override {
        return 42;
      }
    };
  }
};

the assertions:

llvm-project/clang/lib/AST/DeclCXX.cpp:2508: void clang::CXXMethodDecl::addOverriddenMethod(const CXXMethodDecl *): Assertion `!MD-&gt;getParent()-&gt;isDependentContext() &amp;&amp; "Can't add an overridden method to a class template!"' failed.

I believe that this assert is unnecessary and contradicts the logic of this patch. After its removal, Clang was successfully built using itself, and all tests passed.


Full diff: https://github.com/llvm/llvm-project/pull/118003.diff

5 Files Affected:

  • (modified) clang/docs/ReleaseNotes.rst (+3)
  • (modified) clang/lib/AST/CXXInheritance.cpp (+12-6)
  • (modified) clang/lib/AST/DeclCXX.cpp (-2)
  • (modified) clang/test/CXX/drs/cwg5xx.cpp (+46-2)
  • (modified) clang/www/cxx_dr_status.html (+1-1)
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 2ecd19bdc39448..c3bb3ea69b03ea 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -308,6 +308,9 @@ Resolutions to C++ Defect Reports
   by default.
   (`CWG2521: User-defined literals and reserved identifiers <https://cplusplus.github.io/CWG/issues/2521.html>`_).
 
+- Fix name lookup for a dependent base class that is the current instantiation.  
+  (`CWG591: When a dependent base class is the current instantiation <https://cplusplus.github.io/CWG/issues/591.html>`_).
+
 C Language Changes
 ------------------
 
diff --git a/clang/lib/AST/CXXInheritance.cpp b/clang/lib/AST/CXXInheritance.cpp
index aefc06e9197cfb..10b8d524ff8978 100644
--- a/clang/lib/AST/CXXInheritance.cpp
+++ b/clang/lib/AST/CXXInheritance.cpp
@@ -134,7 +134,7 @@ bool CXXRecordDecl::forallBases(ForallBasesCallback BaseMatches) const {
         return false;
 
       CXXRecordDecl *Base =
-            cast_or_null<CXXRecordDecl>(Ty->getDecl()->getDefinition());
+          cast_if_present<CXXRecordDecl>(Ty->getDecl()->getDefinition());
       if (!Base ||
           (Base->isDependentContext() &&
            !Base->isCurrentInstantiation(Record))) {
@@ -169,13 +169,21 @@ bool CXXBasePaths::lookupInBases(ASTContext &Context,
     QualType BaseType =
         Context.getCanonicalType(BaseSpec.getType()).getUnqualifiedType();
 
+    bool isCurrentInstantiation = isa<InjectedClassNameType>(BaseType);
+    if (!isCurrentInstantiation) {
+      if (auto *BaseRecord = cast_if_present<CXXRecordDecl>(
+              BaseSpec.getType()->getAsRecordDecl()))
+        isCurrentInstantiation = BaseRecord->isDependentContext() &&
+                                 BaseRecord->isCurrentInstantiation(Record);
+    }
     // C++ [temp.dep]p3:
     //   In the definition of a class template or a member of a class template,
     //   if a base class of the class template depends on a template-parameter,
     //   the base class scope is not examined during unqualified name lookup
     //   either at the point of definition of the class template or member or
     //   during an instantiation of the class tem- plate or member.
-    if (!LookupInDependent && BaseType->isDependentType())
+    if (!LookupInDependent &&
+        (BaseType->isDependentType() && !isCurrentInstantiation))
       continue;
 
     // Determine whether we need to visit this base class at all,
@@ -243,9 +251,8 @@ bool CXXBasePaths::lookupInBases(ASTContext &Context,
         return FoundPath;
       }
     } else if (VisitBase) {
-      CXXRecordDecl *BaseRecord;
+      CXXRecordDecl *BaseRecord = nullptr;
       if (LookupInDependent) {
-        BaseRecord = nullptr;
         const TemplateSpecializationType *TST =
             BaseSpec.getType()->getAs<TemplateSpecializationType>();
         if (!TST) {
@@ -264,8 +271,7 @@ bool CXXBasePaths::lookupInBases(ASTContext &Context,
             BaseRecord = nullptr;
         }
       } else {
-        BaseRecord = cast<CXXRecordDecl>(
-            BaseSpec.getType()->castAs<RecordType>()->getDecl());
+        BaseRecord = cast<CXXRecordDecl>(BaseSpec.getType()->getAsRecordDecl());
       }
       if (BaseRecord &&
           lookupInBases(Context, BaseRecord, BaseMatches, LookupInDependent)) {
diff --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp
index f2f2835641245e..af73c658d6a0c5 100644
--- a/clang/lib/AST/DeclCXX.cpp
+++ b/clang/lib/AST/DeclCXX.cpp
@@ -2602,8 +2602,6 @@ bool CXXMethodDecl::isMoveAssignmentOperator() const {
 
 void CXXMethodDecl::addOverriddenMethod(const CXXMethodDecl *MD) {
   assert(MD->isCanonicalDecl() && "Method is not canonical!");
-  assert(!MD->getParent()->isDependentContext() &&
-         "Can't add an overridden method to a class template!");
   assert(MD->isVirtual() && "Method is not virtual!");
 
   getASTContext().addOverriddenMethod(this, MD);
diff --git a/clang/test/CXX/drs/cwg5xx.cpp b/clang/test/CXX/drs/cwg5xx.cpp
index ed0c7159dfc889..0d53a9d07d76de 100644
--- a/clang/test/CXX/drs/cwg5xx.cpp
+++ b/clang/test/CXX/drs/cwg5xx.cpp
@@ -1178,17 +1178,61 @@ namespace cwg590 { // cwg590: yes
   template<typename T> typename A<T>::B::C A<T>::B::C::f(A<T>::B::C) {}
 }
 
-namespace cwg591 { // cwg591: no
+namespace cwg591 { // cwg591: yes
   template<typename T> struct A {
     typedef int M;
     struct B {
       typedef void M;
       struct C;
+      struct D;
+    };
+  };
+
+  template<typename T> struct G {
+    struct B {
+      typedef int M;
+      struct C {
+        typedef void M;
+        struct D;
+      };
+    };
+  };
+
+  template<typename T> struct H {
+    template<typename U> struct B {
+      typedef int M;
+      template<typename F> struct C {
+        typedef void M;
+        struct D;
+        struct P;
+      };
     };
   };
 
   template<typename T> struct A<T>::B::C : A<T> {
-    // FIXME: Should find member of non-dependent base class A<T>.
+    M m;
+  };
+
+  template<typename T> struct G<T>::B::C::D : B {
+    M m;
+  };
+
+  template<typename T>
+  template<typename U>
+  template<typename F>
+  struct H<T>::B<U>::C<F>::D : B<U> {
+    M m;
+  };
+
+  template<typename T> struct A<T>::B::D : A<T*> {
+    M m;
+    // expected-error@-1 {{field has incomplete type 'M' (aka 'void'}}
+  };
+
+  template<typename T>
+  template<typename U>
+  template<typename F>
+  struct H<T>::B<U>::C<F>::P : B<F> {
     M m;
     // expected-error@-1 {{field has incomplete type 'M' (aka 'void'}}
   };
diff --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html
index 186f7cc0ace546..c773c58fac4d0f 100755
--- a/clang/www/cxx_dr_status.html
+++ b/clang/www/cxx_dr_status.html
@@ -3599,7 +3599,7 @@ <h2 id="cxxdr">C++ defect report implementation status</h2>
     <td><a href="https://cplusplus.github.io/CWG/issues/591.html">591</a></td>
     <td>CD4</td>
     <td>When a dependent base class is the current instantiation</td>
-    <td class="none" align="center">No</td>
+    <td class="none" align="center">Yes</td>
   </tr>
   <tr id="592">
     <td><a href="https://cplusplus.github.io/CWG/issues/592.html">592</a></td>

@vbe-sc
Copy link
Contributor Author

vbe-sc commented Nov 28, 2024

@erichkeane, @nikic This is the second version of this patch. I’m not entirely sure if my suggestion regarding the redundant assertion is correct, but I’d like to share some thoughts on the clang build time regression:

According to the actual implementation of CXXRecordDecl::lookupInBases:

  // FIXME: This is an O(N^2) algorithm, but DPG doesn't see an easy
  // way to make it any faster.

My patch enforces additional lookups through the bases (as required by the C++ standard), so worse performance is expected regardless. It might be possible to limit this algorithm or improve its efficiency, but at the moment, I don’t see a viable way to achieve this.

Do you have any thoughts on the assertion I removed?

Do you have any suggestions or concern? Thanks

@@ -1178,17 +1178,61 @@ namespace cwg590 { // cwg590: yes
template<typename T> typename A<T>::B::C A<T>::B::C::f(A<T>::B::C) {}
}

namespace cwg591 { // cwg591: no
namespace cwg591 { // cwg591: yes
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
namespace cwg591 { // cwg591: yes
namespace cwg591 { // cwg591: 20

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -3599,7 +3599,7 @@ <h2 id="cxxdr">C++ defect report implementation status</h2>
<td><a href="https://cplusplus.github.io/CWG/issues/591.html">591</a></td>
<td>CD4</td>
<td>When a dependent base class is the current instantiation</td>
<td class="none" align="center">No</td>
<td class="none" align="center">Yes</td>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<td class="none" align="center">Yes</td>
<td class="unreleased" align="center">Clang 20</td>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@vbe-sc vbe-sc force-pushed the vb-sc/reapply-clang-dependent-lookup-fix branch from 63f64a3 to 98583ff Compare November 28, 2024 18:58
@vbe-sc vbe-sc requested a review from zwuis November 28, 2024 19:10
@vbe-sc
Copy link
Contributor Author

vbe-sc commented Nov 29, 2024

@cor3ntin, FYI: we reverted the patch you merged before. This is the second attempt

Copy link
Collaborator

@erichkeane erichkeane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please give @cor3ntin 48 hrs from now to have a chance to review this before committing.

Copy link
Contributor

@cor3ntin cor3ntin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@asi-sc asi-sc merged commit e1cb316 into llvm:main Dec 3, 2024
9 checks passed
@glandium
Copy link
Contributor

glandium commented Dec 6, 2024

I'm hitting an assertion on some Firefox code after this landed:

clang++: /tmp/llvm/llvm/include/llvm/Support/Casting.h:566: decltype(auto) llvm::cast(const From &) [To = cl
ang::RecordType, From = clang::QualType]: Assertion `isa<To>(Val) && "cast<Ty>() argument of incompatible ty
pe!"' failed.
(...)
1.      /tmp/g/obj-x86_64-pc-linux-gnu/dist/include/mozilla/MozPromise.h:1348:5 <Spelling=/tmp/g/obj-x86_64-
pc-linux-gnu/dist/include/mozilla/MozPromise.h:1348:38>: current parser token '&&'
2.      /tmp/g/obj-x86_64-pc-linux-gnu/dist/include/mozilla/MozPromise.h:48:1: parsing namespace 'mozilla'
3.      /tmp/g/obj-x86_64-pc-linux-gnu/dist/include/mozilla/MozPromise.h:1339:1: parsing struct/union/class body 'mozilla::MozPromise::Private'
4.      /tmp/g/obj-x86_64-pc-linux-gnu/dist/include/mozilla/MozPromise.h:1347:75: parsing function body 'mozilla::MozPromise::Private::Resolve'
5.      /tmp/g/obj-x86_64-pc-linux-gnu/dist/include/mozilla/MozPromise.h:1347:75: in compound statement ('{}')
6.      /tmp/g/obj-x86_64-pc-linux-gnu/dist/include/mozilla/MozPromise.h:1348:5 <Spelling=/tmp/g/obj-x86_64-pc-linux-gnu/dist/include/mozilla/Assertions.h:468:6>: in compound statement ('{}')
  #0 0x00007f5c64d183f9 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /tmp/llvm/llvm/lib/Support/Unix/Signals.inc:723:11
  #1 0x00007f5c64d188ab PrintStackTraceSignalHandler(void*) /tmp/llvm/llvm/lib/Support/Unix/Signals.inc:798:1 
  #2 0x00007f5c64d16b6f llvm::sys::RunSignalHandlers() /tmp/llvm/llvm/lib/Support/Signals.cpp:105:5
  #3 0x00007f5c64d17d69 llvm::sys::CleanupOnSignal(unsigned long) /tmp/llvm/llvm/lib/Support/Unix/Signals.inc:368:1
  #4 0x00007f5c64bca842 (anonymous namespace)::CrashRecoveryContextImpl::HandleCrash(int, unsigned long) /tmp/llvm/llvm/lib/Support/CrashRecoveryContext.cpp:0:7
  #5 0x00007f5c64bcaba6 CrashRecoverySignalHandler(int) /tmp/llvm/llvm/lib/Support/CrashRecoveryContext.cpp:391:1
  #6 0x00007f5c62e5b050 (/lib/x86_64-linux-gnu/libc.so.6+0x3c050)
  #7 0x00007f5c62ea9ebc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
  #8 0x00007f5c62e5afb2 raise ./signal/../sysdeps/posix/raise.c:27:6
  #9 0x00007f5c62e45472 abort ./stdlib/abort.c:81:7
 #10 0x00007f5c62e45395 _nl_load_domain ./intl/loadmsgcat.c:1177:9
 #11 0x00007f5c62e53eb2 (/lib/x86_64-linux-gnu/libc.so.6+0x34eb2)
 #12 0x00007f5c72cbf024 decltype(auto) llvm::cast<clang::RecordType, clang::QualType>(clang::QualType const&) /tmp/llvm/llvm/include/llvm/Support/Casting.h:567:43
 #13 0x00007f5c72cbaaa9 clang::RecordType const* clang::Type::castAs<clang::RecordType>() const /tmp/llvm/obj/tools/clang/include/clang/AST/TypeNodes.inc:96:1
 #14 0x00007f5c730e72ca clang::CXXRecordDecl::FindBaseClass(clang::CXXBaseSpecifier const*, clang::CXXBasePath&, clang::CXXRecordDecl const*) /tmp/llvm/clang/lib/AST/CXXInheritance.cpp:371:32
 #15 0x00007f5c730e868c clang::CXXRecordDecl::isDerivedFrom(clang::CXXRecordDecl const*, clang::CXXBasePaths&) const::$_0::operator()(clang::CXXBaseSpecifier const*, clang::CXXBasePath&) const /tmp/llvm/clang/lib/AST/CXXInheritance.cpp:83:16
 #16 0x00007f5c730e8625 bool llvm::function_ref<bool (clang::CXXBaseSpecifier const*, clang::CXXBasePath&)>::callback_fn<clang::CXXRecordDecl::isDerivedFrom(clang::CXXRecordDecl const*, clang::CXXBasePaths&) const::$_0>(long, clang::CXXBaseSpecifier const*, clang::CXXBasePath&) /tmp/llvm/llvm/include/llvm/ADT/STLFunctionalExtras.h:46:5
 #17 0x00007f5c730e9cd9 llvm::function_ref<bool (clang::CXXBaseSpecifier const*, clang::CXXBasePath&)>::operator()(clang::CXXBaseSpecifier const*, clang::CXXBasePath&) const /tmp/llvm/llvm/include/llvm/ADT/STLFunctionalExtras.h:69:5
 #18 0x00007f5c730e6e5e clang::CXXBasePaths::lookupInBases(clang::ASTContext&, clang::CXXRecordDecl const*, llvm::function_ref<bool (clang::CXXBaseSpecifier const*, clang::CXXBasePath&)>, bool) /tmp/llvm/clang/lib/AST/CXXInheritance.cpp:242:9
 #19 0x00007f5c730e6586 clang::CXXRecordDecl::lookupInBases(llvm::function_ref<bool (clang::CXXBaseSpecifier const*, clang::CXXBasePath&)>, clang::CXXBasePaths&, bool) const /tmp/llvm/clang/lib/AST/CXXInheritance.cpp:314:7
 #20 0x00007f5c730e650e clang::CXXRecordDecl::isDerivedFrom(clang::CXXRecordDecl const*, clang::CXXBasePaths&) const /tmp/llvm/clang/lib/AST/CXXInheritance.cpp:80:3
 #21 0x00007f5c73dd0869 FindBestPath(clang::Sema&, (anonymous namespace)::EffectiveContext const&, (anonymous namespace)::AccessTarget&, clang::AccessSpecifier, clang::CXXBasePaths&) /tmp/llvm/clang/lib/Sema/SemaAccess.cpp:956:8
 #22 0x00007f5c73dcf305 IsAccessible(clang::Sema&, (anonymous namespace)::EffectiveContext const&, (anonymous namespace)::AccessTarget&) /tmp/llvm/clang/lib/Sema/SemaAccess.cpp:1402:16
 #23 0x00007f5c73dccdee CheckEffectiveAccess(clang::Sema&, (anonymous namespace)::EffectiveContext const&, clang::SourceLocation, (anonymous namespace)::AccessTarget&) /tmp/llvm/clang/lib/Sema/SemaAccess.cpp:1437:3
 #24 0x00007f5c73dcd379 CheckAccess(clang::Sema&, clang::SourceLocation, (anonymous namespace)::AccessTarget&) /tmp/llvm/clang/lib/Sema/SemaAccess.cpp:1501:3
 #25 0x00007f5c73dcedde clang::Sema::CheckLookupAccess(clang::LookupResult const&) /tmp/llvm/clang/lib/Sema/SemaAccess.cpp:1922:5
 #26 0x00007f5c72ba1a83 clang::LookupResult::diagnoseAccess() /tmp/llvm/clang/include/clang/Sema/Lookup.h:765:3

@vbe-sc
Copy link
Contributor Author

vbe-sc commented Dec 6, 2024

I'm hitting an assertion on some Firefox code after this landed:

clang++: /tmp/llvm/llvm/include/llvm/Support/Casting.h:566: decltype(auto) llvm::cast(const From &) [To = cl
ang::RecordType, From = clang::QualType]: Assertion `isa<To>(Val) && "cast<Ty>() argument of incompatible ty
pe!"' failed.
(...)
1.      /tmp/g/obj-x86_64-pc-linux-gnu/dist/include/mozilla/MozPromise.h:1348:5 <Spelling=/tmp/g/obj-x86_64-
pc-linux-gnu/dist/include/mozilla/MozPromise.h:1348:38>: current parser token '&&'
2.      /tmp/g/obj-x86_64-pc-linux-gnu/dist/include/mozilla/MozPromise.h:48:1: parsing namespace 'mozilla'
3.      /tmp/g/obj-x86_64-pc-linux-gnu/dist/include/mozilla/MozPromise.h:1339:1: parsing struct/union/class body 'mozilla::MozPromise::Private'
4.      /tmp/g/obj-x86_64-pc-linux-gnu/dist/include/mozilla/MozPromise.h:1347:75: parsing function body 'mozilla::MozPromise::Private::Resolve'
5.      /tmp/g/obj-x86_64-pc-linux-gnu/dist/include/mozilla/MozPromise.h:1347:75: in compound statement ('{}')
6.      /tmp/g/obj-x86_64-pc-linux-gnu/dist/include/mozilla/MozPromise.h:1348:5 <Spelling=/tmp/g/obj-x86_64-pc-linux-gnu/dist/include/mozilla/Assertions.h:468:6>: in compound statement ('{}')
  #0 0x00007f5c64d183f9 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /tmp/llvm/llvm/lib/Support/Unix/Signals.inc:723:11
  #1 0x00007f5c64d188ab PrintStackTraceSignalHandler(void*) /tmp/llvm/llvm/lib/Support/Unix/Signals.inc:798:1 
  #2 0x00007f5c64d16b6f llvm::sys::RunSignalHandlers() /tmp/llvm/llvm/lib/Support/Signals.cpp:105:5
  #3 0x00007f5c64d17d69 llvm::sys::CleanupOnSignal(unsigned long) /tmp/llvm/llvm/lib/Support/Unix/Signals.inc:368:1
  #4 0x00007f5c64bca842 (anonymous namespace)::CrashRecoveryContextImpl::HandleCrash(int, unsigned long) /tmp/llvm/llvm/lib/Support/CrashRecoveryContext.cpp:0:7
  #5 0x00007f5c64bcaba6 CrashRecoverySignalHandler(int) /tmp/llvm/llvm/lib/Support/CrashRecoveryContext.cpp:391:1
  #6 0x00007f5c62e5b050 (/lib/x86_64-linux-gnu/libc.so.6+0x3c050)
  #7 0x00007f5c62ea9ebc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
  #8 0x00007f5c62e5afb2 raise ./signal/../sysdeps/posix/raise.c:27:6
  #9 0x00007f5c62e45472 abort ./stdlib/abort.c:81:7
 #10 0x00007f5c62e45395 _nl_load_domain ./intl/loadmsgcat.c:1177:9
 #11 0x00007f5c62e53eb2 (/lib/x86_64-linux-gnu/libc.so.6+0x34eb2)
 #12 0x00007f5c72cbf024 decltype(auto) llvm::cast<clang::RecordType, clang::QualType>(clang::QualType const&) /tmp/llvm/llvm/include/llvm/Support/Casting.h:567:43
 #13 0x00007f5c72cbaaa9 clang::RecordType const* clang::Type::castAs<clang::RecordType>() const /tmp/llvm/obj/tools/clang/include/clang/AST/TypeNodes.inc:96:1
 #14 0x00007f5c730e72ca clang::CXXRecordDecl::FindBaseClass(clang::CXXBaseSpecifier const*, clang::CXXBasePath&, clang::CXXRecordDecl const*) /tmp/llvm/clang/lib/AST/CXXInheritance.cpp:371:32
 #15 0x00007f5c730e868c clang::CXXRecordDecl::isDerivedFrom(clang::CXXRecordDecl const*, clang::CXXBasePaths&) const::$_0::operator()(clang::CXXBaseSpecifier const*, clang::CXXBasePath&) const /tmp/llvm/clang/lib/AST/CXXInheritance.cpp:83:16
 #16 0x00007f5c730e8625 bool llvm::function_ref<bool (clang::CXXBaseSpecifier const*, clang::CXXBasePath&)>::callback_fn<clang::CXXRecordDecl::isDerivedFrom(clang::CXXRecordDecl const*, clang::CXXBasePaths&) const::$_0>(long, clang::CXXBaseSpecifier const*, clang::CXXBasePath&) /tmp/llvm/llvm/include/llvm/ADT/STLFunctionalExtras.h:46:5
 #17 0x00007f5c730e9cd9 llvm::function_ref<bool (clang::CXXBaseSpecifier const*, clang::CXXBasePath&)>::operator()(clang::CXXBaseSpecifier const*, clang::CXXBasePath&) const /tmp/llvm/llvm/include/llvm/ADT/STLFunctionalExtras.h:69:5
 #18 0x00007f5c730e6e5e clang::CXXBasePaths::lookupInBases(clang::ASTContext&, clang::CXXRecordDecl const*, llvm::function_ref<bool (clang::CXXBaseSpecifier const*, clang::CXXBasePath&)>, bool) /tmp/llvm/clang/lib/AST/CXXInheritance.cpp:242:9
 #19 0x00007f5c730e6586 clang::CXXRecordDecl::lookupInBases(llvm::function_ref<bool (clang::CXXBaseSpecifier const*, clang::CXXBasePath&)>, clang::CXXBasePaths&, bool) const /tmp/llvm/clang/lib/AST/CXXInheritance.cpp:314:7
 #20 0x00007f5c730e650e clang::CXXRecordDecl::isDerivedFrom(clang::CXXRecordDecl const*, clang::CXXBasePaths&) const /tmp/llvm/clang/lib/AST/CXXInheritance.cpp:80:3
 #21 0x00007f5c73dd0869 FindBestPath(clang::Sema&, (anonymous namespace)::EffectiveContext const&, (anonymous namespace)::AccessTarget&, clang::AccessSpecifier, clang::CXXBasePaths&) /tmp/llvm/clang/lib/Sema/SemaAccess.cpp:956:8
 #22 0x00007f5c73dcf305 IsAccessible(clang::Sema&, (anonymous namespace)::EffectiveContext const&, (anonymous namespace)::AccessTarget&) /tmp/llvm/clang/lib/Sema/SemaAccess.cpp:1402:16
 #23 0x00007f5c73dccdee CheckEffectiveAccess(clang::Sema&, (anonymous namespace)::EffectiveContext const&, clang::SourceLocation, (anonymous namespace)::AccessTarget&) /tmp/llvm/clang/lib/Sema/SemaAccess.cpp:1437:3
 #24 0x00007f5c73dcd379 CheckAccess(clang::Sema&, clang::SourceLocation, (anonymous namespace)::AccessTarget&) /tmp/llvm/clang/lib/Sema/SemaAccess.cpp:1501:3
 #25 0x00007f5c73dcedde clang::Sema::CheckLookupAccess(clang::LookupResult const&) /tmp/llvm/clang/lib/Sema/SemaAccess.cpp:1922:5
 #26 0x00007f5c72ba1a83 clang::LookupResult::diagnoseAccess() /tmp/llvm/clang/include/clang/Sema/Lookup.h:765:3

Thanks for this important information. Do you have a small code reproduction for this problem? It would help us to fix it as soon as possible

@glandium
Copy link
Contributor

glandium commented Dec 6, 2024

I was creducing it (well, cvise-ing). Here's a reproducer:

template <typename, typename, bool> struct MozPromise {
  class Private;

private:
  void *mMagic4;
};
template <typename ResolveValueT, typename RejectValueT, bool IsExclusive>
struct MozPromise<ResolveValueT, RejectValueT, IsExclusive>::Private
    : MozPromise {
  void SetTaskPriority() { mMagic4 }
}

@vbe-sc
Copy link
Contributor Author

vbe-sc commented Dec 6, 2024

I was creducing it (well, cvise-ing). Here's a reproducer:

template <typename, typename, bool> struct MozPromise {
  class Private;

private:
  void *mMagic4;
};
template <typename ResolveValueT, typename RejectValueT, bool IsExclusive>
struct MozPromise<ResolveValueT, RejectValueT, IsExclusive>::Private
    : MozPromise {
  void SetTaskPriority() { mMagic4 }
}

Thanks, I'll investigate with it

@vbe-sc
Copy link
Contributor Author

vbe-sc commented Dec 6, 2024

@glandium, I've provided the fix in this PR (#119024).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants