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

Vladislav Belov via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 6 01:14:50 PST 2024


vbe-sc wrote:

> 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 

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


More information about the cfe-commits mailing list