[cfe-commits] r57693 - in /cfe/trunk: lib/Analysis/GRExprEngine.cpp test/Analysis/ObjCProperties.m
Ted Kremenek
kremenek at apple.com
Fri Oct 17 10:24:14 PDT 2008
Author: kremenek
Date: Fri Oct 17 12:24:14 2008
New Revision: 57693
URL: http://llvm.org/viewvc/llvm-project?rev=57693&view=rev
Log:
"Implement" GRExprEngine::VisitLValue for ObjCPropertyRefExpr. This is only a bandid; we need to properly handle properties by using locv/nonloc objects and specially handling property assignments in the transfer function for BinaryOperator.
Added:
cfe/trunk/test/Analysis/ObjCProperties.m
Modified:
cfe/trunk/lib/Analysis/GRExprEngine.cpp
Modified: cfe/trunk/lib/Analysis/GRExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/GRExprEngine.cpp?rev=57693&r1=57692&r2=57693&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/GRExprEngine.cpp (original)
+++ cfe/trunk/lib/Analysis/GRExprEngine.cpp Fri Oct 17 12:24:14 2008
@@ -431,6 +431,21 @@
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;
}
}
Added: cfe/trunk/test/Analysis/ObjCProperties.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/ObjCProperties.m?rev=57693&view=auto
==============================================================================
--- cfe/trunk/test/Analysis/ObjCProperties.m (added)
+++ cfe/trunk/test/Analysis/ObjCProperties.m Fri Oct 17 12:24:14 2008
@@ -0,0 +1,20 @@
+// RUN: clang -checker-simple %s -verify
+
+// The point of this test cases is to exercise properties in the static
+// analyzer
+
+ at interface MyClass {
+ at private
+ id _X;
+}
+- (id)initWithY:(id)Y;
+ at property(copy, readonly) id X;
+ at end
+
+ at implementation MyClass
+ at synthesize X = _X;
+- (id)initWithY:(id)Y {
+ self.X = Y;
+ return self;
+}
+ at end
More information about the cfe-commits
mailing list