From: Alexander Shaposhnikov Date: Tue, 13 Sep 2016 19:17:20 +0000 (+0000) Subject: [analyzer] Fix ExprEngine::VisitMemberExpr X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6956d290341b3ceb7fb7599c9c772c08b0c2450a;p=platform%2Fupstream%2Fllvm.git [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 llvm-svn: 281373 --- diff --git a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp index 97f4d9f..a99ee88 100644 --- a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp +++ b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp @@ -2044,7 +2044,7 @@ void ExprEngine::VisitMemberExpr(const MemberExpr *M, ExplodedNode *Pred, if (!M->isGLValue()) { assert(M->getType()->isArrayType()); const ImplicitCastExpr *PE = - dyn_cast((*I)->getParentMap().getParent(M)); + dyn_cast((*I)->getParentMap().getParentIgnoreParens(M)); if (!PE || PE->getCastKind() != CK_ArrayToPointerDecay) { llvm_unreachable("should always be wrapped in ArrayToPointerDecay"); } diff --git a/clang/test/Analysis/array-struct.c b/clang/test/Analysis/array-struct.c index 28e09ad..18f226a 100644 --- a/clang/test/Analysis/array-struct.c +++ b/clang/test/Analysis/array-struct.c @@ -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];