llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.66k stars 11.85k forks source link

Handle FloatingLiteral, CharacterLiteral, and ImaginaryLiteral in GRExprEngine::VisitLValue #8047

Closed llvmbot closed 14 years ago

llvmbot commented 14 years ago
Bugzilla Link 7675
Resolution FIXED
Resolved on Jul 28, 2010 20:33
Version trunk
OS Linux
Attachments itm.cpp
Reporter LLVM Bugzilla Contributor
CC @tkremenek,@xuzhongxing

Extended Description

$ clang++ --version clang version 2.8 (trunk 108821) Target: i386-pc-linux-gnu Thread model: posix $ clang++ --analyze itm.cpp clang: /usr/src/llvm/src.llvm/tools/clang/lib/Checker/GRExprEngine.cpp:1075: void clang::GRExprEngine::VisitLValue(const clang::Expr, clang::ExplodedNode, clang::ExplodedNodeSet&): Assertion `(isa(Ex->getType().getDesugaredType()) || isa(Ex->getType().getDesugaredType())) && "Other kinds of expressions with non-aggregate/union/class types" " do not have lvalues."' failed. 0 clang 0x098d87dc 1 clang 0x098d8674 2 0xb775b400 __kernel_sigreturn + 0 3 libc.so.6 0xb74cdb82 abort + 386 4 libc.so.6 0xb74c38b8 assert_fail + 248 5 clang 0x08e8b1f9 clang::GRExprEngine::VisitLValue(clang::Expr const, clang::ExplodedNode, clang::ExplodedNodeSet&) + 1629 6 clang 0x08e8ed72 clang::GRExprEngine::VisitCall(clang::CallExpr const, clang::ExplodedNode, clang::ConstExprIterator, clang::ConstExprIterator, clang::ExplodedNodeSet&, bool) + 592 7 clang 0x08e8a32e clang::GRExprEngine::Visit(clang::Stmt const, clang::ExplodedNode, clang::ExplodedNodeSet&) + 1372 8 clang 0x08e89c80 clang::GRExprEngine::ProcessStmt(clang::CFGElement, clang::GRStmtNodeBuilder&) + 1532 9 clang 0x08e81b42 clang::GRCoreEngine::ProcessStmt(clang::CFGElement, clang::GRStmtNodeBuilder&) + 42 10 clang 0x08e829fb clang::GRCoreEngine::HandlePostStmt(clang::PostStmt const&, clang::CFGBlock const, unsigned int, clang::ExplodedNode) + 247 11 clang 0x08e82045 clang::GRCoreEngine::ExecuteWorkList(clang::LocationContext const, unsigned int) + 1025 12 clang 0x08e1a53a clang::GRExprEngine::ExecuteWorkList(clang::LocationContext const, unsigned int) + 46 13 clang 0x08e1767f 14 clang 0x08e1776e 15 clang 0x08e177f4 16 clang 0x08e173e7 17 clang 0x08e16e38 18 clang 0x08c2f073 clang::ParseAST(clang::Preprocessor&, clang::ASTConsumer, clang::ASTContext&, bool, bool, clang::CodeCompleteConsumer) + 727 19 clang 0x089dd853 clang::ASTFrontendAction::ExecuteAction() + 271 20 clang 0x089dd4c4 clang::FrontendAction::Execute() + 316 21 clang 0x089c8647 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 779 22 clang 0x0898a212 cc1_main(char const, char const, char const, void) + 1721 23 clang 0x08992f5d main + 495 24 libc.so.6 0xb74b6c76 libc_start_main + 230 25 clang 0x08988d81 Stack dump:

  1. Program arguments: /usr/src/llvm/dist/bin/clang -cc1 -triple i386-pc-linux-gnu -analyze -disable-free -main-file-name itm.cpp -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-check-dead-stores -analyzer-check-objc-mem -analyzer-eagerly-assume -analyzer-check-objc-methodsigs -analyzer-check-objc-unused-ivars -analyzer-output plist -w -mrelocation-model static -mdisable-fp-elim -mconstructor-aliases -target-cpu pentium4 -resource-dir /usr/src/llvm/dist/lib/clang/2.8 -ferror-limit 19 -fmessage-length 117 -fexceptions -fgnu-runtime -fdiagnostics-show-option -fcolor-diagnostics -o itm.plist -x c++ itm.cpp
  2. parser at end of file
  3. itm.cpp:237:9: Error evaluating statement
  4. itm.cpp:237:9: Error evaluating statement
  5. itm.cpp:237:15: Error evaluating statement clang: error: clang frontend command failed due to signal 6 (use -v to see invocation)

Please note that the actual compilation works fine.

tkremenek commented 14 years ago

I can only guess, but it seems that in the switch in function GRExprEngine::VisitLValue Stmt::FloatingLiteralClass in unhandled.

Index: lib/Checker/GRExprEngine.cpp

--- lib/Checker/GRExprEngine.cpp (revision 109275) +++ lib/Checker/GRExprEngine.cpp (working copy) @@ -1058,6 +1058,7 @@ // In C++, binding an rvalue to a reference requires to create an object. case Stmt::CXXBoolLiteralExprClass: case Stmt::IntegerLiteralClass:

  • case Stmt::FloatingLiteralClass: CreateCXXTemporaryObject(Ex, Pred, Dst); return;

I am unable to compile clang now, so I can't test it. But changing floats to ints in reduced test case causes clang to not crash.

Sorry for the spamming, but of course there can be other *LiteralClass that need to be handled in the same way, I am not sure if I found all of them: FloatingLiteralClass CharacterLiteralClass ImaginaryLiteral (?)

Yes, all of these cases need to be handled.

Fixed here:

http://llvm.org/viewvc/llvm-project?view=rev&revision=109719

llvmbot commented 14 years ago

I can only guess, but it seems that in the switch in function GRExprEngine::VisitLValue Stmt::FloatingLiteralClass in unhandled.

Index: lib/Checker/GRExprEngine.cpp

--- lib/Checker/GRExprEngine.cpp (revision 109275) +++ lib/Checker/GRExprEngine.cpp (working copy) @@ -1058,6 +1058,7 @@ // In C++, binding an rvalue to a reference requires to create an object. case Stmt::CXXBoolLiteralExprClass: case Stmt::IntegerLiteralClass:

  • case Stmt::FloatingLiteralClass: CreateCXXTemporaryObject(Ex, Pred, Dst); return;

I am unable to compile clang now, so I can't test it. But changing floats to ints in reduced test case causes clang to not crash.

Sorry for the spamming, but of course there can be other *LiteralClass that need to be handled in the same way, I am not sure if I found all of them: FloatingLiteralClass CharacterLiteralClass ImaginaryLiteral (?)

llvmbot commented 14 years ago

I can only guess, but it seems that in the switch in function GRExprEngine::VisitLValue Stmt::FloatingLiteralClass in unhandled.

Index: lib/Checker/GRExprEngine.cpp

--- lib/Checker/GRExprEngine.cpp (revision 109275) +++ lib/Checker/GRExprEngine.cpp (working copy) @@ -1058,6 +1058,7 @@ // In C++, binding an rvalue to a reference requires to create an object. case Stmt::CXXBoolLiteralExprClass: case Stmt::IntegerLiteralClass:

I am unable to compile clang now, so I can't test it. But changing floats to ints in reduced test case causes clang to not crash.

llvmbot commented 14 years ago

smaller testcase

llvmbot commented 14 years ago

assigned to @tkremenek