This revision was automatically updated to reflect the committed changes. Closed by commit rL281373: [analyzer] Fix ExprEngine::VisitMemberExpr (authored by alexshap).
Changed prior to commit: https://reviews.llvm.org/D24484?vs=71082&id=71218#toc Repository: rL LLVM https://reviews.llvm.org/D24484 Files: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp cfe/trunk/test/Analysis/array-struct.c Index: cfe/trunk/test/Analysis/array-struct.c =================================================================== --- cfe/trunk/test/Analysis/array-struct.c +++ cfe/trunk/test/Analysis/array-struct.c @@ -135,6 +135,17 @@ 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]; Index: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp =================================================================== --- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp +++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp @@ -2044,7 +2044,7 @@ 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"); }
Index: cfe/trunk/test/Analysis/array-struct.c =================================================================== --- cfe/trunk/test/Analysis/array-struct.c +++ cfe/trunk/test/Analysis/array-struct.c @@ -135,6 +135,17 @@ 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]; Index: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp =================================================================== --- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp +++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp @@ -2044,7 +2044,7 @@ 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"); }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits