Author: alexshap Date: Tue Sep 13 14:17:20 2016 New Revision: 281373 URL: http://llvm.org/viewvc/llvm-project?rev=281373&view=rev Log: [analyzer] Fix ExprEngine::VisitMemberExpr
AST may contain intermediate ParenExpr nodes between MemberExpr and ArrayToPointerDecay. This diff adjusts the check in ExprEngine::VisitMemberExpr accordingly. Test plan: make -j8 check-clang-analysis Differential revision: https://reviews.llvm.org/D24484 Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp cfe/trunk/test/Analysis/array-struct.c Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp?rev=281373&r1=281372&r2=281373&view=diff ============================================================================== --- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp (original) +++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp Tue Sep 13 14:17:20 2016 @@ -2044,7 +2044,7 @@ void ExprEngine::VisitMemberExpr(const M if (!M->isGLValue()) { assert(M->getType()->isArrayType()); const ImplicitCastExpr *PE = - dyn_cast<ImplicitCastExpr>((*I)->getParentMap().getParent(M)); + dyn_cast<ImplicitCastExpr>((*I)->getParentMap().getParentIgnoreParens(M)); if (!PE || PE->getCastKind() != CK_ArrayToPointerDecay) { llvm_unreachable("should always be wrapped in ArrayToPointerDecay"); } Modified: cfe/trunk/test/Analysis/array-struct.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/array-struct.c?rev=281373&r1=281372&r2=281373&view=diff ============================================================================== --- cfe/trunk/test/Analysis/array-struct.c (original) +++ cfe/trunk/test/Analysis/array-struct.c Tue Sep 13 14:17:20 2016 @@ -135,6 +135,17 @@ void f14() { void bar(int*); +struct s3 gets3() { + struct s3 s; + return s; +} + +void accessArrayFieldNoCrash() { + bar(gets3().a); + bar((gets3().a)); + bar(((gets3().a))); +} + // Test if the array is correctly invalidated. void f15() { int a[10]; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits