From c2e20d0c42cf085940c9a9cb495a7116d1b0eb07 Mon Sep 17 00:00:00 2001 From: Argyrios Kyrtzidis Date: Thu, 3 Feb 2011 22:01:32 +0000 Subject: [PATCH] [analyzer] Fix a crash until we can handle temporary struct objects properly. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124822 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/StaticAnalyzer/Checkers/ExprEngine.cpp | 6 +++++- test/Analysis/fields.c | 10 ++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/StaticAnalyzer/Checkers/ExprEngine.cpp b/lib/StaticAnalyzer/Checkers/ExprEngine.cpp index 79d2a2b2fc..2dd2202f03 100644 --- a/lib/StaticAnalyzer/Checkers/ExprEngine.cpp +++ b/lib/StaticAnalyzer/Checkers/ExprEngine.cpp @@ -1716,7 +1716,11 @@ void ExprEngine::VisitMemberExpr(const MemberExpr* M, ExplodedNode* Pred, const GRState* state = GetState(*I); SVal baseExprVal = state->getSVal(baseExpr); if (isa(baseExprVal) || - isa(baseExprVal)) { + isa(baseExprVal) || + // FIXME: This can originate by conjuring a symbol for an unknown + // temporary struct object, see test/Analysis/fields.c: + // (p = getit()).x + isa(baseExprVal)) { MakeNode(Dst, M, *I, state->BindExpr(M, UnknownVal())); continue; } diff --git a/test/Analysis/fields.c b/test/Analysis/fields.c index c97d4f82cd..0827f3dbad 100644 --- a/test/Analysis/fields.c +++ b/test/Analysis/fields.c @@ -17,3 +17,13 @@ void f() { struct s a; int *p = &(a.n) + 1; } + +typedef struct { + int x,y; +} Point; + +Point getit(void); +void test() { + Point p; + (void)(p = getit()).x; +} -- 2.40.0