Ericsson / clang

Cross Translation Unit analysis capability for Clang Static Analyzer. (Fork of official clang at http://llvm.org/git/clang)
http://clang.llvm.org/
Other
15 stars 10 forks source link

Eliminated wrong cases of 'Missing XxxDecl' messages. #657

Closed balazske closed 5 years ago

balazske commented 5 years ago

Code in ImportDeclContext to re-order decls did not handle correctly if multiple From decls were imported to same To decl.

martong commented 5 years ago

So if I understand correctly then there are cases when we import different decls of a DC into the same decl in the "To" context. I understand that this PR would handle each imported decl only once, so the warning would cease to exists. However, the underlying problem - we import different decls to the same one - is still there. We should try to fix that rather.

balazske commented 5 years ago

There is no case when it is valid to merge multiple decls into one at import? If yes we can check for it and make a correct warning or assert.

martong commented 5 years ago

There is no case when it is valid to merge multiple decls into one at import? If yes we can check for it and make a correct warning or assert.

Yes there are. So, okay we can check for those cases and warn only if that does not stand.

martong commented 5 years ago

I checked this PR on my machine, and looks like the original assertion is not solved. Because in this case it the problem seems to be that we indeed do not import something that we should. That is a CXXDesctructorDecl.

1.      <eof> parser at end of file
2.      While analyzing stack:
        #0 Calling llvm::ConstantData::~ConstantData
        #1 Calling llvm::ConstantTokenNone::~ConstantTokenNone
        #2 Calling llvm::Value::deleteValue at /home/egbomrt/WORK/CodeCheckerProjects/llvm/git/llvm/include/llvm/IR/Value.h:658:51
        #3 Calling llvm::ValueDeleter::operator()
3.      /home/egbomrt/WORK/CodeCheckerProjects/llvm/git/llvm/include/llvm/IR/Constants.h:58:7: Error evaluating destructor
#0 0x00007f146dea1bc4 PrintStackTraceSignalHandler(void*) (/home/egbomrt/WORK/llvm/build/release_assert/bin/../lib/libLLVMSupport.so.7.1+0x108bc4)
#1 0x00007f146de9fd10 llvm::sys::RunSignalHandlers() (/home/egbomrt/WORK/llvm/build/release_assert/bin/../lib/libLLVMSupport.so.7.1+0x106d10)
#2 0x00007f146dea1d72 SignalHandler(int) (/home/egbomrt/WORK/llvm/build/release_assert/bin/../lib/libLLVMSupport.so.7.1+0x108d72)
#3 0x00007f146d882390 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x11390)
#4 0x00007f146c0ed428 gsignal /build/glibc-LK5gWL/glibc-2.23/signal/../sysdeps/unix/sysv/linux/raise.c:54:0
#5 0x00007f146c0ef02a abort /build/glibc-LK5gWL/glibc-2.23/stdlib/abort.c:91:0
#6 0x00007f146c0e5bd7 __assert_fail_base /build/glibc-LK5gWL/glibc-2.23/assert/assert.c:92:0
#7 0x00007f146c0e5c82 (/lib/x86_64-linux-gnu/libc.so.6+0x2dc82)
#8 0x00007f14693d2175 clang::ento::CXXInstanceCall::getDecl() const (/home/egbomrt/WORK/llvm/build/release_assert/bin/../lib/../lib/../lib/libclangStaticAnalyzerCore.so.7.1+0x80175)
#9 0x00007f14693d0cf9 clang::ento::CallEvent::getProgramPoint(bool, clang::ProgramPointTag const*) const (/home/egbomrt/WORK/llvm/build/release_assert/bin/../lib/../lib/../lib/libclangStaticAnalyzerCore.so.7.1+0x7ecf9)
#10 0x00007f14693db858 clang::ento::CheckerManager::runCheckersForCallEvent(bool, clang::ento::ExplodedNodeSet&, clang::ento::ExplodedNodeSet const&, clang::ento::CallEvent const&, clang::ento::ExprEngine&, bool) (/home/egbomrt/WORK/llvm/build/release_assert/bin/../lib/../lib/../lib/libclangStaticAnalyzerCore.so.7.1+0x89858)
#11 0x00007f1469413992 clang::ento::ExprEngine::VisitCXXDestructor(clang::QualType, clang::ento::MemRegion const*, clang::Stmt const*, bool, clang::ento::ExplodedNode*, clang::ento::ExplodedNodeSet&, clang::ento::ExprEngine::EvalCallOptions const&) (/home/egbomrt/WORK/llvm/build/release_assert/bin/../lib/../lib/../lib/libclangStaticAnalyzerCore.so.7.1+0xc1992)
#12 0x00007f14693fa757 clang::ento::ExprEngine::ProcessBaseDtor(clang::CFGBaseDtor, clang::ento::ExplodedNode*, clang::ento::ExplodedNodeSet&) (/home/egbomrt/WORK/llvm/build/release_assert/bin/../lib/../lib/../lib/libclangStaticAnalyzerCore.so.7.1+0xa8757)
#13 0x00007f14693f5d24 clang::ento::ExprEngine::ProcessImplicitDtor(clang::CFGImplicitDtor, clang::ento::ExplodedNode*) (/home/egbomrt/WORK/llvm/build/release_assert/bin/../lib/../lib/../lib/libclangStaticAnalyzerCore.so.7.1+0xa3d24)
#14 0x00007f14693f49a5 clang::ento::ExprEngine::processCFGElement(clang::CFGElement, clang::ento::ExplodedNode*, unsigned int, clang::ento::NodeBuilderContext*) (/home/egbomrt/WORK/llvm/build/release_assert/bin/../lib/../lib/../lib/libclangStaticAnalyzerCore.so.7.1+0xa29a5)
#15 0x00007f14693e7c1a clang::ento::CoreEngine::HandleBlockEntrance(clang::BlockEntrance const&, clang::ento::ExplodedNode*) (/home/egbomrt/WORK/llvm/build/release_assert/bin/../lib/../lib/../lib/libclangStaticAnalyzerCore.so.7.1+0x95c1a)
#16 0x00007f14693e759a clang::ento::CoreEngine::dispatchWorkItem(clang::ento::ExplodedNode*, clang::ProgramPoint, clang::ento::WorkListUnit const&) (/home/egbomrt/WORK/llvm/build/release_assert/bin/../lib/../lib/../lib/libclangStaticAnalyzerCore.so.7.1+0x9559a)
#17 0x00007f14693e7052 clang::ento::CoreEngine::ExecuteWorkList(clang::LocationContext const*, unsigned int, llvm::IntrusiveRefCntPtr<clang::ento::ProgramState const>) (/home/egbomrt/WORK/llvm/build/release_assert/bin/../lib/../lib/../lib/libclangStaticAnalyzerCore.so.7.1+0x95052)
#18 0x00007f14698b22db (anonymous namespace)::AnalysisConsumer::ActionExprEngine(clang::Decl*, bool, clang::ento::ExprEngine::InliningModes, llvm::DenseSet<clang::Decl const*, llvm::DenseMapInfo<clang::Decl const*> >*) (/home/egbomrt/WORK/llvm/build/release_assert/bin/../lib/../lib/libclangStaticAnalyzerFrontend.so.7.1+0x152db)
#19 0x00007f14698b1e75 (anonymous namespace)::AnalysisConsumer::HandleCode(clang::Decl*, unsigned int, clang::ento::ExprEngine::InliningModes, llvm::DenseSet<clang::Decl const*, llvm::DenseMapInfo<clang::Decl const*> >*) (/home/egbomrt/WORK/llvm/build/release_assert/bin/../lib/../lib/libclangStaticAnalyzerFrontend.so.7.1+0x14e75)
#20 0x00007f14698aa409 (anonymous namespace)::AnalysisConsumer::HandleTranslationUnit(clang::ASTContext&) (/home/egbomrt/WORK/llvm/build/release_assert/bin/../lib/../lib/libclangStaticAnalyzerFrontend.so.7.1+0xd409)
#21 0x00007f146a736585 clang::ParseAST(clang::Sema&, bool, bool) (/home/egbomrt/WORK/llvm/build/release_assert/bin/../lib/../lib/libclangParse.so.7.1+0x2c585)
#22 0x00007f146cded358 clang::FrontendAction::Execute() (/home/egbomrt/WORK/llvm/build/release_assert/bin/../lib/libclangFrontend.so.7.1+0xca358)
#23 0x00007f146cda9891 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/home/egbomrt/WORK/llvm/build/release_assert/bin/../lib/libclangFrontend.so.7.1+0x86891)
#24 0x00007f146fd0fe22 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/home/egbomrt/WORK/llvm/build/release_assert/bin/../lib/libclangFrontendTool.so.7.1+0x3e22)
#25 0x000000000040f7e3 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/home/egbomrt/WORK/llvm/build/release_assert/bin/clang-7+0x40f7e3)
#26 0x000000000040dd02 main (/home/egbomrt/WORK/llvm/build/release_assert/bin/clang-7+0x40dd02)
#27 0x00007f146c0d8830 __libc_start_main /build/glibc-LK5gWL/glibc-2.23/csu/../csu/libc-start.c:325:0
#28 0x000000000040b1f9 _start (/home/egbomrt/WORK/llvm/build/release_assert/bin/clang-7+0x40b1f9)
balazske commented 5 years ago

This PR is closed, see #663 instead.