FlameTop created this revision. FlameTop added reviewers: zaks.anna, dcoughlin. FlameTop added a subscriber: cfe-commits.
ExprEngine::VisitLvalArraySubscriptExpr contains an assert to ensure it is passed either a GLvalue or a small number of C exemptions. This change adds vector types to the assert as these also can be rvalues. A provided test ensures the assertion no longer fires for vector rvalues. https://reviews.llvm.org/D27043 Files: llvm/tools/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp llvm/tools/clang/test/Analysis/crash-vector-rvalue.c Index: llvm/tools/clang/test/Analysis/crash-vector-rvalue.c =================================================================== --- /dev/null +++ llvm/tools/clang/test/Analysis/crash-vector-rvalue.c @@ -0,0 +1,7 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=core -verify %s +typedef int vec __attribute__((__vector_size__(4)));; +vec bar(); +int foo() { + int op = bar()[2]; + return op; +} Index: llvm/tools/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp =================================================================== --- llvm/tools/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp +++ llvm/tools/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp @@ -1973,7 +1973,8 @@ StmtNodeBuilder Bldr(checkerPreStmt, Dst, *currBldrCtx); assert(A->isGLValue() || - (!AMgr.getLangOpts().CPlusPlus && + A->getBase()->getType()->isVectorType() || + (!AMgr.getLangOpts().CPlusPlus && A->getType().isCForbiddenLValueType())); for (ExplodedNodeSet::iterator it = checkerPreStmt.begin(),
Index: llvm/tools/clang/test/Analysis/crash-vector-rvalue.c =================================================================== --- /dev/null +++ llvm/tools/clang/test/Analysis/crash-vector-rvalue.c @@ -0,0 +1,7 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=core -verify %s +typedef int vec __attribute__((__vector_size__(4)));; +vec bar(); +int foo() { + int op = bar()[2]; + return op; +} Index: llvm/tools/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp =================================================================== --- llvm/tools/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp +++ llvm/tools/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp @@ -1973,7 +1973,8 @@ StmtNodeBuilder Bldr(checkerPreStmt, Dst, *currBldrCtx); assert(A->isGLValue() || - (!AMgr.getLangOpts().CPlusPlus && + A->getBase()->getType()->isVectorType() || + (!AMgr.getLangOpts().CPlusPlus && A->getType().isCForbiddenLValueType())); for (ExplodedNodeSet::iterator it = checkerPreStmt.begin(),
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits