LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 50995 - bugprone-easily-swappable-parameters: Crash with typedef
Summary: bugprone-easily-swappable-parameters: Crash with typedef
Status: RESOLVED FIXED
Alias: None
Product: clang-tools-extra
Classification: Unclassified
Component: clang-tidy (show other bugs)
Version: unspecified
Hardware: PC Linux
: P normal
Assignee: Whisperity
URL: http://reviews.llvm.org/D106946
Keywords:
: 51237 51441 (view as bug list)
Depends on:
Blocks: release-13.0.1
  Show dependency tree
 
Reported: 2021-07-06 07:30 PDT by Volker Reichelt
Modified: 2021-10-11 20:29 PDT (History)
7 users (show)

See Also:
Fixed By Commit(s): 21832121e112d97f1e197b35959867f3a99226ee e097724cb9efbc3a068767ecf264897e97b2e109


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Volker Reichelt 2021-07-06 07:30:50 PDT
The following valid code snippet triggers an assertion in the recently introduced
bugprone-easily-swappable-parameters check:

clang-tidy -checks=-*,bugprone-easily-swappable-parameters bug.cc --

==================================
typedef int X[2];

void foo(int i, const X& x) {}
==================================


clang-tidy: /tmp/LLVM/llvm-project/clang/include/clang/AST/Type.h:684: const clang::ExtQualsTypeCommonBase* clang::QualType::getCommonPtr() const: Assertion `!isNull() && "Cannot retrieve a NULL type pointer"' failed.
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace.
Stack dump:
0.	Program arguments: /LLVM/LLVM-trunk/bin/clang-tidy -checks=-*,bugprone-easily-swappable-parameters bug.cc --
1.	<eof> parser at end of file
 #0 0x0000000002a114c0 PrintStackTraceSignalHandler(void*) Signals.cpp:0:0
 #1 0x0000000002a0f27e SignalHandler(int) Signals.cpp:0:0
 #2 0x00007f7a78084680 __restore_rt sigaction.c:0:0
 #3 0x00007f7a76dd4207 raise (/lib64/libc.so.6+0x36207)
 #4 0x00007f7a76dd58f8 abort (/lib64/libc.so.6+0x378f8)
 #5 0x00007f7a76dcd026 __assert_fail_base (/lib64/libc.so.6+0x2f026)
 #6 0x00007f7a76dcd0d2 (/lib64/libc.so.6+0x2f0d2)
 #7 0x00000000004d4198 clang::tidy::bugprone::model::approximateImplicitConversion(clang::tidy::bugprone::EasilySwappableParametersCheck const&, clang::QualType, clang::QualType, clang::ASTContext const&, clang::tidy::bugprone::model::ImplicitConversionModellingMode) EasilySwappableParametersCheck.cpp:0:0
 #8 0x00000000004d5b3c clang::tidy::bugprone::model::calculateMixability(clang::tidy::bugprone::EasilySwappableParametersCheck const&, clang::QualType, clang::QualType, clang::ASTContext const&, clang::tidy::bugprone::model::ImplicitConversionModellingMode) EasilySwappableParametersCheck.cpp:0:0
 #9 0x00000000004d5702 clang::tidy::bugprone::model::calculateMixability(clang::tidy::bugprone::EasilySwappableParametersCheck const&, clang::QualType, clang::QualType, clang::ASTContext const&, clang::tidy::bugprone::model::ImplicitConversionModellingMode) EasilySwappableParametersCheck.cpp:0:0
#10 0x00000000004d7dc6 clang::tidy::bugprone::model::isLRefEquallyBindingToType(clang::tidy::bugprone::EasilySwappableParametersCheck const&, clang::LValueReferenceType const*, clang::QualType, clang::ASTContext const&, bool, clang::tidy::bugprone::model::ImplicitConversionModellingMode) EasilySwappableParametersCheck.cpp:0:0
#11 0x00000000004d5414 clang::tidy::bugprone::model::calculateMixability(clang::tidy::bugprone::EasilySwappableParametersCheck const&, clang::QualType, clang::QualType, clang::ASTContext const&, clang::tidy::bugprone::model::ImplicitConversionModellingMode) EasilySwappableParametersCheck.cpp:0:0
#12 0x00000000004d634b clang::tidy::bugprone::model::modelMixingRange(clang::tidy::bugprone::EasilySwappableParametersCheck const&, clang::FunctionDecl const*, unsigned long, clang::tidy::bugprone::filter::SimilarlyUsedParameterPairSuppressor const&) EasilySwappableParametersCheck.cpp:0:0
#13 0x00000000004e3bde clang::tidy::bugprone::EasilySwappableParametersCheck::check(clang::ast_matchers::MatchFinder::MatchResult const&) (/LLVM/LLVM-trunk/bin/clang-tidy+0x4e3bde)
#14 0x00000000022a28d6 clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::MatchVisitor::visitMatch(clang::ast_matchers::BoundNodes const&) ASTMatchFinder.cpp:0:0
#15 0x00000000022cc9df clang::ast_matchers::internal::BoundNodesTreeBuilder::visitMatches(clang::ast_matchers::internal::BoundNodesTreeBuilder::Visitor*) (/LLVM/LLVM-trunk/bin/clang-tidy+0x22cc9df)
#16 0x00000000022a35f1 clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::matchWithFilter(clang::DynTypedNode const&) ASTMatchFinder.cpp:0:0
#17 0x00000000022b8b5c clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::TraverseDecl(clang::Decl*) ASTMatchFinder.cpp:0:0
#18 0x00000000022b927a clang::RecursiveASTVisitor<clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor>::TraverseDeclContextHelper(clang::DeclContext*) (.part.0) ASTMatchFinder.cpp:0:0
#19 0x00000000022c61f6 clang::RecursiveASTVisitor<clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor>::TraverseTranslationUnitDecl(clang::TranslationUnitDecl*) ASTMatchFinder.cpp:0:0
#20 0x00000000022b8b67 clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::TraverseDecl(clang::Decl*) ASTMatchFinder.cpp:0:0
#21 0x00000000022b8dca clang::ast_matchers::MatchFinder::matchAST(clang::ASTContext&) (/LLVM/LLVM-trunk/bin/clang-tidy+0x22b8dca)
#22 0x0000000001469048 clang::MultiplexConsumer::HandleTranslationUnit(clang::ASTContext&) (/LLVM/LLVM-trunk/bin/clang-tidy+0x1469048)
#23 0x000000000162f159 clang::ParseAST(clang::Sema&, bool, bool) (/LLVM/LLVM-trunk/bin/clang-tidy+0x162f159)
#24 0x0000000001449949 clang::FrontendAction::Execute() (/LLVM/LLVM-trunk/bin/clang-tidy+0x1449949)
#25 0x00000000013d1b06 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/LLVM/LLVM-trunk/bin/clang-tidy+0x13d1b06)
#26 0x0000000000d79dbd clang::tooling::FrontendActionFactory::runInvocation(std::shared_ptr<clang::CompilerInvocation>, clang::FileManager*, std::shared_ptr<clang::PCHContainerOperations>, clang::DiagnosticConsumer*) (/LLVM/LLVM-trunk/bin/clang-tidy+0xd79dbd)
#27 0x0000000000d27b6a clang::tidy::runClangTidy(clang::tidy::ClangTidyContext&, clang::tooling::CompilationDatabase const&, llvm::ArrayRef<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, llvm::IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem>, bool, bool, llvm::StringRef)::ActionFactory::runInvocation(std::shared_ptr<clang::CompilerInvocation>, clang::FileManager*, std::shared_ptr<clang::PCHContainerOperations>, clang::DiagnosticConsumer*) ClangTidy.cpp:0:0
#28 0x0000000000d74c93 clang::tooling::ToolInvocation::runInvocation(char const*, clang::driver::Compilation*, std::shared_ptr<clang::CompilerInvocation>, std::shared_ptr<clang::PCHContainerOperations>) (/LLVM/LLVM-trunk/bin/clang-tidy+0xd74c93)
#29 0x0000000000d77842 clang::tooling::ToolInvocation::run() (/LLVM/LLVM-trunk/bin/clang-tidy+0xd77842)
#30 0x0000000000d78ced clang::tooling::ClangTool::run(clang::tooling::ToolAction*) (/LLVM/LLVM-trunk/bin/clang-tidy+0xd78ced)
#31 0x0000000000d321c2 clang::tidy::runClangTidy(clang::tidy::ClangTidyContext&, clang::tooling::CompilationDatabase const&, llvm::ArrayRef<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, llvm::IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem>, bool, bool, llvm::StringRef) (/LLVM/LLVM-trunk/bin/clang-tidy+0xd321c2)
#32 0x00000000004359ca clang::tidy::clangTidyMain(int, char const**) (/LLVM/LLVM-trunk/bin/clang-tidy+0x4359ca)
Comment 2 Whisperity 2021-07-28 03:55:43 PDT
*** Bug 51237 has been marked as a duplicate of this bug. ***
Comment 3 Whisperity 2021-07-28 05:08:13 PDT
Fix is produced, and submitted for review.
Comment 4 Whisperity 2021-07-28 05:46:45 PDT
Fix landed to main branch. Keeping the ticket open because this fix SHOULD go in to the upcoming 13.0 release too.
Comment 5 Whisperity 2021-08-05 01:05:29 PDT
@tstellar The commit of the original fix (21832121e112d97f1e197b35959867f3a99226ee) should apply cleanly on top of where 'release/13.x' is now:


commit 0661286a55fb7ef978bd5193fe140191cf7ac445 (upstream/release/13.x)
Author: Eli Friedman <efriedma@quicinc.com>
Date:   Sat Jul 31 13:41:15 2021 -0700

    Fix a couple regression tests I missed updating in 2a284782
Comment 6 Tom Stellard 2021-08-05 10:25:51 PDT
Merged: e097724cb9ef
Comment 7 Whisperity 2021-09-01 01:47:42 PDT
*** Bug 51441 has been marked as a duplicate of this bug. ***
Comment 8 Whisperity 2021-09-02 02:45:33 PDT
*** Bug 51441 has been marked as a duplicate of this bug. ***