[cfe-commits] r124822 - in /cfe/trunk: lib/StaticAnalyzer/Checkers/ExprEngine.cpp test/Analysis/fields.c

Argyrios Kyrtzidis akyrtzi at gmail.com
Thu Feb 3 14:01:32 PST 2011


Author: akirtzidis
Date: Thu Feb  3 16:01:32 2011
New Revision: 124822

URL: http://llvm.org/viewvc/llvm-project?rev=124822&view=rev
Log:
[analyzer] Fix a crash until we can handle temporary struct objects properly.

Modified:
    cfe/trunk/lib/StaticAnalyzer/Checkers/ExprEngine.cpp
    cfe/trunk/test/Analysis/fields.c

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/ExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/ExprEngine.cpp?rev=124822&r1=124821&r2=124822&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/ExprEngine.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/ExprEngine.cpp Thu Feb  3 16:01:32 2011
@@ -1716,7 +1716,11 @@
     const GRState* state = GetState(*I);
     SVal baseExprVal = state->getSVal(baseExpr);
     if (isa<nonloc::LazyCompoundVal>(baseExprVal) ||
-        isa<nonloc::CompoundVal>(baseExprVal)) {
+        isa<nonloc::CompoundVal>(baseExprVal) ||
+        // FIXME: This can originate by conjuring a symbol for an unknown
+        // temporary struct object, see test/Analysis/fields.c:
+        // (p = getit()).x
+        isa<nonloc::SymbolVal>(baseExprVal)) {
       MakeNode(Dst, M, *I, state->BindExpr(M, UnknownVal()));
       continue;
     }

Modified: cfe/trunk/test/Analysis/fields.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/fields.c?rev=124822&r1=124821&r2=124822&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/fields.c (original)
+++ cfe/trunk/test/Analysis/fields.c Thu Feb  3 16:01:32 2011
@@ -17,3 +17,13 @@
   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;
+}





More information about the cfe-commits mailing list