[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
Thu Mar 7 10:27:00 PST 2024
wlei-llvm wrote:
Hi:
We hit a crash/assertion, and bisected to this. Here is the stack dump:
```
clang++: /home/wlei/local/upstream/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.
Stack dump:
0. Program arguments: /home/wlei/local/upstream/llvm-build/bin/clang++ @/tmp/fbcc.xxbvookk/compiler.argsfile
1. fbcode/multifeed/ranking/user_profile/GFIHCountsMap.cpp:633:55: current parser token ')'
2. fbcode/multifeed/ranking/user_profile/GFIHCountsMap.cpp:26:1: parsing namespace 'facebook'
3. fbcode/multifeed/ranking/user_profile/GFIHCountsMap.cpp:622:29: parsing function body 'facebook::multifeed::ranking::GFIHCountsMap::getTotalAggregationIfConfigured'
4. fbcode/multifeed/ranking/user_profile/GFIHCountsMap.cpp:622:29: in compound statement ('{}')
#0 0x00007f25c2bf9588 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/wlei/local/upstream/llvm-project/llvm/lib/Support/Unix/Signals.inc:723:13
#1 0x00007f25c2bf7630 llvm::sys::RunSignalHandlers() /home/wlei/local/upstream/llvm-project/llvm/lib/Support/Signals.cpp:106:18
#2 0x00007f25c2bf8c41 llvm::sys::CleanupOnSignal(unsigned long) /home/wlei/local/upstream/llvm-project/llvm/lib/Support/Unix/Signals.inc:0:3
#3 0x00007f25c2b3f908 (anonymous namespace)::CrashRecoveryContextImpl::HandleCrash(int, unsigned long) /home/wlei/local/upstream/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:73:5
#4 0x00007f25c2b3f908 CrashRecoverySignalHandler(int) /home/wlei/local/upstream/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:390:51
#5 0x00007f25c7612d20 __restore_rt (/lib64/libpthread.so.0+0x12d20)
#6 0x00007f25c1a4e52f raise (/lib64/libc.so.6+0x4e52f)
#7 0x00007f25c1a21e65 abort (/lib64/libc.so.6+0x21e65)
#8 0x00007f25c1a21d39 _nl_load_domain.cold.0 (/lib64/libc.so.6+0x21d39)
#9 0x00007f25c1a46e86 (/lib64/libc.so.6+0x46e86)
#10 0x00007f25bf3a934c FindDeclaringClass(clang::NamedDecl*) /home/wlei/local/upstream/llvm-project/clang/lib/Sema/SemaAccess.cpp:0:0
#11 0x00007f25bf3a9265 (anonymous namespace)::AccessTarget::initialize() /home/wlei/local/upstream/llvm-project/clang/lib/Sema/SemaAccess.cpp:267:24
#12 0x00007f25bf3a686c clang::sema::AccessedEntity::isQuiet() const /home/wlei/local/upstream/llvm-project/clang/include/clang/Sema/DelayedDiagnostic.h:75:50
#13 0x00007f25bf3a686c clang::sema::AccessedEntity::setDiag(unsigned int) /home/wlei/local/upstream/llvm-project/clang/include/clang/Sema/DelayedDiagnostic.h:104:5
#14 0x00007f25bf3a686c clang::Sema::CheckUnresolvedLookupAccess(clang::UnresolvedLookupExpr*, clang::DeclAccessPair) /home/wlei/local/upstream/llvm-project/clang/lib/Sema/SemaAccess.cpp:1567:10
#15 0x00007f25bfa98e83 clang::DeclarationNameInfo::getLoc() const /home/wlei/local/upstream/llvm-project/clang/include/clang/AST/DeclarationName.h:797:42
#16 0x00007f25bfa98e83 clang::OverloadExpr::getNameLoc() const /home/wlei/local/upstream/llvm-project/clang/include/clang/AST/ExprCXX.h:3078:55
#17 0x00007f25bfa98e83 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
#18 0x00007f25bfa98c8f 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
#19 0x00007f25bf70511d 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
#20 0x00007f25bf720e6b 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
#21 0x00007f25c2d59dca clang::Parser::ParsePostfixExpressionSuffix(clang::ActionResult<clang::Expr*, true>) /home/wlei/local/upstream/llvm-project/clang/lib/Parse/ParseExpr.cpp:2181:23
#22 0x00007f25c2d5af8a 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
#23 0x00007f25c2d56e2b 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
#24 0x00007f25c2d56e2b clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState) /home/wlei/local/upstream/llvm-project/clang/lib/Parse/ParseExpr.cpp:176:20
#25 0x00007f25c2d63a8a clang::Parser::ParseExpressionList(llvm::SmallVectorImpl<clang::Expr*>&, llvm::function_ref<void ()>, bool, bool) /home/wlei/local/upstream/llvm-project/clang/lib/Parse/ParseExpr.cpp:0:14
#26 0x00007f25c2d1f05b clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*) /home/wlei/local/upstream/llvm-project/clang/lib/Parse/ParseDecl.cpp:2751:21
#27 0x00007f25c2d1c1dd clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::Parser::ParsedTemplateInfo&, clang::SourceLocation*, clang::Parser::ForRangeInit*) /home/wlei/local/upstream/llvm-project/clang/lib/Parse/ParseDecl.cpp:2414:7
#28 0x00007f25c2d1b34d clang::Parser::ParseSimpleDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, bool, clang::Parser::ForRangeInit*, clang::SourceLocation*) /home/wlei/local/upstream/llvm-project/clang/lib/Parse/ParseDecl.cpp:0:10
#29 0x00007f25c2d1ad8f clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::SourceLocation*) /home/wlei/local/upstream/llvm-project/clang/lib/Parse/ParseDecl.cpp:0:0
#30 0x00007f25c2dc5004 clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::ParsedAttributes&, clang::ParsedAttributes&) /home/wlei/local/upstream/llvm-project/clang/lib/Parse/ParseStmt.cpp:0:16
#31 0x00007f25c2dc4462 clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*) /home/wlei/local/upstream/llvm-project/clang/lib/Parse/ParseStmt.cpp:118:20
```
Is this a known issue or any thing obvious to fix? If not, I will try to get a reduced reproducer.
https://github.com/llvm/llvm-project/pull/83842
More information about the cfe-commits
mailing list