[clang] [Clang][Sema] Fix crash when using name of UnresolvedUsingValueDecl with template arguments (PR #83842)

Lei Wang via cfe-commits cfe-commits at lists.llvm.org
Sat Mar 9 15:46:35 PST 2024


wlei-llvm wrote:

```
clang++ -std=gnu++20  test.cpp

clang-18: /../llvm-project/llvm/include/llvm/Support/Casting.h:578: decltype(auto) llvm::cast(From *) [To = clang::CXXRecordDecl, From = clang::DeclContext]: Assertion `isa<To>(Val) && "cast<Ty>() argument of incompatible type!"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.

1.	test.bk.10.cpp:90:15: current parser token ')'
2.	test.bk.10.cpp:81:1: parsing struct/union/class body '(unnamed class at test.bk.10.cpp:81:1)'
3.	test.bk.10.cpp:87:18: parsing function body '(anonymous class)::get'
4.	test.bk.10.cpp:87:18: in compound statement ('{}')
 #0 0x00007fb54bdf9588 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/wlei/local/upstream/llvm-project/llvm/lib/Support/Unix/Signals.inc:723:13
 #1 0x00007fb54bdf7630 llvm::sys::RunSignalHandlers() /home/wlei/local/upstream/llvm-project/llvm/lib/Support/Signals.cpp:106:18
 #2 0x00007fb54bdf9c5d SignalHandler(int) /home/wlei/local/upstream/llvm-project/llvm/lib/Support/Unix/Signals.inc:413:1
 #3 0x00007fb550812d20 __restore_rt (/lib64/libpthread.so.0+0x12d20)
 #4 0x00007fb54ac4e52f raise (/lib64/libc.so.6+0x4e52f)
 #5 0x00007fb54ac21e65 abort (/lib64/libc.so.6+0x21e65)
 #6 0x00007fb54ac21d39 _nl_load_domain.cold.0 (/lib64/libc.so.6+0x21d39)
 #7 0x00007fb54ac46e86 (/lib64/libc.so.6+0x46e86)
 #8 0x00007fb5485a934c FindDeclaringClass(clang::NamedDecl*) /home/wlei/local/upstream/llvm-project/clang/lib/Sema/SemaAccess.cpp:0:0
 #9 0x00007fb5485a9265 (anonymous namespace)::AccessTarget::initialize() /home/wlei/local/upstream/llvm-project/clang/lib/Sema/SemaAccess.cpp:267:24
#10 0x00007fb5485a686c clang::sema::AccessedEntity::isQuiet() const /home/wlei/local/upstream/llvm-project/clang/include/clang/Sema/DelayedDiagnostic.h:75:50
#11 0x00007fb5485a686c clang::sema::AccessedEntity::setDiag(unsigned int) /home/wlei/local/upstream/llvm-project/clang/include/clang/Sema/DelayedDiagnostic.h:104:5
#12 0x00007fb5485a686c clang::Sema::CheckUnresolvedLookupAccess(clang::UnresolvedLookupExpr*, clang::DeclAccessPair) /home/wlei/local/upstream/llvm-project/clang/lib/Sema/SemaAccess.cpp:1567:10
#13 0x00007fb548c98e83 clang::DeclarationNameInfo::getLoc() const /home/wlei/local/upstream/llvm-project/clang/include/clang/AST/DeclarationName.h:797:42
#14 0x00007fb548c98e83 clang::OverloadExpr::getNameLoc() const /home/wlei/local/upstream/llvm-project/clang/include/clang/AST/ExprCXX.h:3078:55
#15 0x00007fb548c98e83 FinishOverloadedCallExpr(clang::Sema&, clang::Scope*, clang::Expr*, clang::UnresolvedLookupExpr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*, clang::OverloadCandidateSet*, clang::OverloadCandidate**, clang::OverloadingResult, bool) /home/wlei/local/upstream/llvm-project/clang/lib/Sema/SemaOverload.cpp:14062:47
#16 0x00007fb548c98c8f clang::Sema::BuildOverloadedCallExpr(clang::Scope*, clang::Expr*, clang::UnresolvedLookupExpr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*, bool, bool) /home/wlei/local/upstream/llvm-project/clang/lib/Sema/SemaOverload.cpp:14200:10
#17 0x00007fb54890511d clang::Sema::BuildCallExpr(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*, bool, bool) /home/wlei/local/upstream/llvm-project/clang/lib/Sema/SemaExpr.cpp:7276:16
#18 0x00007fb548920e6b clang::Sema::ActOnCallExpr(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*) /home/wlei/local/upstream/llvm-project/clang/lib/Sema/SemaExpr.cpp:7167:7
#19 0x00007fb54bf59dca clang::Parser::ParsePostfixExpressionSuffix(clang::ActionResult<clang::Expr*, true>) /home/wlei/local/upstream/llvm-project/clang/lib/Parse/ParseExpr.cpp:2181:23
#20 0x00007fb54bf5af8a clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, bool&, clang::Parser::TypeCastState, bool, bool*) /home/wlei/local/upstream/llvm-project/clang/lib/Parse/ParseExpr.cpp:1890:7
#21 0x00007fb54bf56e2b clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, clang::Parser::TypeCastState, bool, bool*) /home/wlei/local/upstream/llvm-project/clang/lib/Parse/ParseExpr.cpp:693:20
#22 0x00007fb54bf56e2b clang::Parser:
```


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


More information about the cfe-commits mailing list