Issue 154066
Summary clang tidy assertion error on `bugprone-unchecked-optional-access`
Labels clang
Assignees
Reporter bhershko
    Using clang 20.1.0, x86-64 on linux, SUSE-SLES15.

Assertion error reported:
```
clang-tidy: /clang/clangsources/llvm-20.1.0.src/tools/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp:933: void clang::dataflow::Environment::setValue(const clang::Expr&, clang::dataflow::Value&): Assertion `CanonE.isPRValue()' failed.
```
Stack trace:
```
#0 0x0000000004728cbb llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/clang/20.1.0/bin/clang-tidy+0x4728cbb)
 #1 0x00000000047260db llvm::sys::RunSignalHandlers() (/clang/20.1.0/bin/clang-tidy+0x47260db)
 #2 0x00000000047261f9 SignalHandler(int) Signals.cpp:0:0
 #3 0x00001555554f6430 __restore_rt (/lib64/libpthread.so.0+0x16430)
 #4 0x0000155554e48cdb raise (/lib64/libc.so.6+0x4acdb)
 #5 0x0000155554e4a395 abort (/lib64/libc.so.6+0x4c395)
 #6 0x0000155554e40c1d __assert_fail_base (/lib64/libc.so.6+0x42c1d)
 #7 0x0000155554e40ca2 (/lib64/libc.so.6+0x42ca2)
 #8 0x0000000001537c28 clang::dataflow::Environment::setValue(clang::Expr const&, clang::dataflow::Value&) (/clang/20.1.0/bin/clang-tidy+0x1537c28)
 #9 0x00000000014f1c01 std::_Function_handler<void (clang::Stmt const*, clang::ast_matchers::MatchFinder::MatchResult const&, clang::dataflow::TransferState<clang::dataflow::CachedConstAccessorsLattice<clang::dataflow::NoopLattice>>&), clang::dataflow::ASTMatchSwitchBuilder<clang::Stmt, clang::dataflow::TransferState<clang::dataflow::CachedConstAccessorsLattice<clang::dataflow::NoopLattice>>, void>&& clang::dataflow::ASTMatchSwitchBuilder<clang::Stmt, clang::dataflow::TransferState<clang::dataflow::CachedConstAccessorsLattice<clang::dataflow::NoopLattice>>, void>::CaseOf<clang::CXXOperatorCallExpr>(clang::ast_matchers::internal::Matcher<clang::Stmt>, std::function<void (clang::CXXOperatorCallExpr const*, clang::ast_matchers::MatchFinder::MatchResult const&, clang::dataflow::TransferState<clang::dataflow::CachedConstAccessorsLattice<clang::dataflow::NoopLattice>>&)>) &&::'lambda'(clang::Stmt const*, clang::ast_matchers::MatchFinder::MatchResult const&, clang::dataflow::TransferState<clang::dataflow::CachedConstAccessorsLattice<clang::dataflow::NoopLattice>>&)>::_M_invoke(std::_Any_data const&, clang::Stmt const*&&, clang::ast_matchers::MatchFinder::MatchResult const&, clang::dataflow::TransferState<clang::dataflow::CachedConstAccessorsLattice<clang::dataflow::NoopLattice>>&) (/clang/20.1.0/bin/clang-tidy+0x14f1c01)
#10 0x00000000014f8053 std::_Function_handler<void (clang::Stmt const&, clang::ASTContext&, clang::dataflow::TransferState<clang::dataflow::CachedConstAccessorsLattice<clang::dataflow::NoopLattice>>&), clang::dataflow::ASTMatchSwitchBuilder<clang::Stmt, clang::dataflow::TransferState<clang::dataflow::CachedConstAccessorsLattice<clang::dataflow::NoopLattice>>, void>::Build() &&::'lambda'(clang::Stmt const&, clang::ASTContext&, clang::dataflow::TransferState<clang::dataflow::CachedConstAccessorsLattice<clang::dataflow::NoopLattice>>&)>::_M_invoke(std::_Any_data const&, clang::Stmt const&, clang::ASTContext&, clang::dataflow::TransferState<clang::dataflow::CachedConstAccessorsLattice<clang::dataflow::NoopLattice>>&) (/clang/20.1.0/bin/clang-tidy+0x14f8053)
#11 0x00000000014f5415 clang::dataflow::UncheckedOptionalAccessModel::transfer(clang::CFGElement const&, clang::dataflow::CachedConstAccessorsLattice<clang::dataflow::NoopLattice>&, clang::dataflow::Environment&) (/clang/20.1.0/bin/clang-tidy+0x14f5415)
#12 0x0000000001554574 clang::dataflow::transferCFGBlock(clang::CFGBlock const&, clang::dataflow::(anonymous namespace)::AnalysisContext&, clang::dataflow::CFGEltCallbacksTypeErased const&) TypeErasedDataflowAnalysis.cpp:0:0
#13 0x0000000001555a1f clang::dataflow::runTypeErasedDataflowAnalysis(clang::dataflow::AdornedCFG const&, clang::dataflow::TypeErasedDataflowAnalysis&, clang::dataflow::Environment const&, clang::dataflow::CFGEltCallbacksTypeErased const&, int) (/clang/20.1.0/bin/clang-tidy+0x1555a1f)
#14 0x0000000000dd94b9 llvm::Expected<llvm::SmallVector<clang::SourceLocation, llvm::CalculateSmallVectorDefaultInlinedElements<clang::SourceLocation>::value>> clang::dataflow::diagnoseFunction<clang::dataflow::UncheckedOptionalAccessModel, clang::SourceLocation>(clang::FunctionDecl const&, clang::ASTContext&, clang::dataflow::DiagnosisCallbacks<clang::dataflow::UncheckedOptionalAccessModel, clang::SourceLocation>, long, int) (/clang/20.1.0/bin/clang-tidy+0xdd94b9)
#15 0x0000000000dd9dce clang::tidy::bugprone::UncheckedOptionalAccessCheck::check(clang::ast_matchers::MatchFinder::MatchResult const&) (/clang/20.1.0/bin/clang-tidy+0xdd9dce)
#16 0x0000000002fe7e13 clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::MatchVisitor::visitMatch(clang::ast_matchers::BoundNodes const&) ASTMatchFinder.cpp:0:0
#17 0x000000000301afe1 clang::ast_matchers::internal::BoundNodesTreeBuilder::visitMatches(clang::ast_matchers::internal::BoundNodesTreeBuilder::Visitor*) (/clang/20.1.0/bin/clang-tidy+0x301afe1)
#18 0x0000000002fe8ef2 clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::matchWithFilter(clang::DynTypedNode const&) ASTMatchFinder.cpp:0:0
#19 0x0000000003003910 clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::TraverseDecl(clang::Decl*) ASTMatchFinder.cpp:0:0
#20 0x0000000003003a1a clang::RecursiveASTVisitor<clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor>::TraverseDeclContextHelper(clang::DeclContext*) ASTMatchFinder.cpp
:0:0
#21 0x0000000003014edb clang::RecursiveASTVisitor<clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor>::TraverseTranslationUnitDecl(clang::TranslationUnitDecl*) ASTMatch
Finder.cpp:0:0
#22 0x000000000300391b clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::TraverseDecl(clang::Decl*) ASTMatchFinder.cpp:0:0
#23 0x0000000003003c9c clang::ast_matchers::MatchFinder::matchAST(clang::ASTContext&) (/clang/20.1.0/bin/clang-tidy+0x3003c9c)
#24 0x0000000001db4928 clang::MultiplexConsumer::HandleTranslationUnit(clang::ASTContext&) (/clang/20.1.0/bin/clang-tidy+0x1db4928)
#25 0x00000000020814ac clang::ParseAST(clang::Sema&, bool, bool) (/clang/20.1.0/bin/clang-tidy+0x20814ac)
#26 0x0000000001d6f1e3 clang::FrontendAction::Execute() (/clang/20.1.0/bin/clang-tidy+0x1d6f1e3)
#27 0x0000000001ce6e9a clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/clang/20.1.0/bin/clang-tidy+0x1ce6e9a)
#28 0x000000000167845f clang::tooling::FrontendActionFactory::runInvocation(std::shared_ptr<clang::CompilerInvocation>, clang::FileManager*, std::shared_ptr<clang::PCHContainerOperations>
, clang::DiagnosticConsumer*) (/clang/20.1.0/bin/clang-tidy+0x167845f)
#29 0x0000000001615dca clang::tidy::runClangTidy(clang::tidy::ClangTidyContext&, clang::tooling::CompilationDatabase const&, llvm::ArrayRef<std::__cxx11::basic_string<char, std::char_trai
ts<char>, std::allocator<char>>>, llvm::IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem>, bool, bool, llvm::StringRef)::ActionFactory::runInvocation(std::shared_ptr<clang::CompilerInvocat
ion>, clang::FileManager*, std::shared_ptr<clang::PCHContainerOperations>, clang::DiagnosticConsumer*) ClangTidy.cpp:0:0
#30 0x00000000016705fc clang::tooling::ToolInvocation::runInvocation(char const*, clang::driver::Compilation*, std::shared_ptr<clang::CompilerInvocation>, std::shared_ptr<clang::PCHContai
nerOperations>) (/clang/20.1.0/bin/clang-tidy+0x16705fc)
#31 0x0000000001673a46 clang::tooling::ToolInvocation::run() (/clang/20.1.0/bin/clang-tidy+0x1673a46)
#32 0x0000000001675cf5 clang::tooling::ClangTool::run(clang::tooling::ToolAction*) (/clang/20.1.0/bin/clang-tidy+0x1675cf5)
#33 0x00000000016240b6 clang::tidy::runClangTidy(clang::tidy::ClangTidyContext&, clang::tooling::CompilationDatabase const&, llvm::ArrayRef<std::__cxx11::basic_string<char, std::char_trai
ts<char>, std::allocator<char>>>, llvm::IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem>, bool, bool, llvm::StringRef) (/clang/20.1.0/bin/clang-tidy+0x16240b6)
#34 0x0000000000b8c5d4 clang::tidy::clangTidyMain(int, char const**) (/clang/20.1.0/bin/clang-tidy+0xb8c5d4)
#35 0x0000155554e331fd __libc_start_main (/lib64/libc.so.6+0x351fd)
#36 0x0000000000b817ca _start /home/abuild/rpmbuild/BUILD/glibc-2.31/csu/../sysdeps/x86_64/start.S:122:0
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to