]> granicus.if.org Git - clang/commitdiff
"Implement" GRExprEngine::VisitLValue for ObjCPropertyRefExpr. This is only a bandid...
authorTed Kremenek <kremenek@apple.com>
Fri, 17 Oct 2008 17:24:14 +0000 (17:24 +0000)
committerTed Kremenek <kremenek@apple.com>
Fri, 17 Oct 2008 17:24:14 +0000 (17:24 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57693 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/GRExprEngine.cpp
test/Analysis/ObjCProperties.m [new file with mode: 0644]

index d8ab4b1275660a6f8cfab929b42597453bfd47e4..bdf42e99c5305d201c783465f52b31286517ff27 100644 (file)
@@ -431,6 +431,21 @@ void GRExprEngine::VisitLValue(Expr* Ex, NodeTy* Pred, NodeSet& Dst) {
     case Stmt::MemberExprClass:
       VisitMemberExpr(cast<MemberExpr>(Ex), Pred, Dst, true);
       return;
+      
+    case Stmt::ObjCPropertyRefExprClass:
+      // FIXME: Property assignments are lvalues, but not really "locations".
+      //  e.g.:  self.x = something;
+      //  Here the "self.x" really can translate to a method call (setter) when
+      //  the assignment is made.  Moreover, the entire assignment expression
+      //  evaluate to whatever "something" is, not calling the "getter" for
+      //  the property (which would make sense since it can have side effects).
+      //  We'll probably treat this as a location, but not one that we can
+      //  take the address of.  Perhaps we need a new SVal class for cases
+      //  like thsis?
+      //  Note that we have a similar problem for bitfields, since they don't
+      //  have "locations" in the sense that we can take their address.
+      Dst.Add(Pred);
+      return;      
   }
 }
 
diff --git a/test/Analysis/ObjCProperties.m b/test/Analysis/ObjCProperties.m
new file mode 100644 (file)
index 0000000..03eefc2
--- /dev/null
@@ -0,0 +1,20 @@
+// RUN: clang -checker-simple %s -verify
+
+// The point of this test cases is to exercise properties in the static
+// analyzer
+
+@interface MyClass {
+@private
+    id _X;
+}
+- (id)initWithY:(id)Y;
+@property(copy, readonly) id X;
+@end
+
+@implementation MyClass
+@synthesize X = _X;
+- (id)initWithY:(id)Y {
+  self.X = Y;
+  return self;
+}
+@end