[llvm-branch-commits] [cfe-branch] r120660 - in /cfe/branches/Apple/whitney: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaExpr.cpp test/SemaObjC/direct-synthesized-ivar-access.m
Daniel Dunbar
daniel at zuster.org
Wed Dec 1 18:52:00 PST 2010
Author: ddunbar
Date: Wed Dec 1 20:52:00 2010
New Revision: 120660
URL: http://llvm.org/viewvc/llvm-project?rev=120660&view=rev
Log:
Merge r119543:
--
Author: Fariborz Jahanian <fjahanian at apple.com>
Date: Wed Nov 17 19:41:23 2010 +0000
Warn if direct accessing synthesized ivar backing the property in
nonofragile-abi2. Fixes //rdar://8673791
Added:
cfe/branches/Apple/whitney/test/SemaObjC/direct-synthesized-ivar-access.m
Modified:
cfe/branches/Apple/whitney/include/clang/Basic/DiagnosticSemaKinds.td
cfe/branches/Apple/whitney/lib/Sema/SemaExpr.cpp
Modified: cfe/branches/Apple/whitney/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/include/clang/Basic/DiagnosticSemaKinds.td?rev=120660&r1=120659&r2=120660&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/branches/Apple/whitney/include/clang/Basic/DiagnosticSemaKinds.td Wed Dec 1 20:52:00 2010
@@ -2673,6 +2673,9 @@
def note_condition_assign_silence : Note<
"place parentheses around the assignment to silence this warning">;
+def warn_synthesized_ivar_access : Warning<
+ "direct access of synthesized ivar by using property access %0">,
+ InGroup<NonfragileAbi2>, DefaultIgnore;
def warn_ivar_variable_conflict : Warning<
"when default property synthesis is on, "
"%0 lookup will access property ivar instead of global variable">,
Modified: cfe/branches/Apple/whitney/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/lib/Sema/SemaExpr.cpp?rev=120660&r1=120659&r2=120660&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/lib/Sema/SemaExpr.cpp (original)
+++ cfe/branches/Apple/whitney/lib/Sema/SemaExpr.cpp Wed Dec 1 20:52:00 2010
@@ -1192,9 +1192,15 @@
if (Ex) return Owned(Ex);
// Synthesize ivars lazily
if (getLangOptions().ObjCNonFragileABI2) {
- if (SynthesizeProvisionalIvar(*this, R, II, NameLoc))
+ if (SynthesizeProvisionalIvar(*this, R, II, NameLoc)) {
+ if (const ObjCPropertyDecl *Property =
+ canSynthesizeProvisionalIvar(II)) {
+ Diag(NameLoc, diag::warn_synthesized_ivar_access) << II;
+ Diag(Property->getLocation(), diag::note_property_declare);
+ }
return ActOnIdExpression(S, SS, Id, HasTrailingLParen,
isAddressOfOperand);
+ }
}
// for further use, this must be set to false if in class method.
IvarLookupFollowUp = getCurMethodDecl()->isInstanceMethod();
Added: cfe/branches/Apple/whitney/test/SemaObjC/direct-synthesized-ivar-access.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/test/SemaObjC/direct-synthesized-ivar-access.m?rev=120660&view=auto
==============================================================================
--- cfe/branches/Apple/whitney/test/SemaObjC/direct-synthesized-ivar-access.m (added)
+++ cfe/branches/Apple/whitney/test/SemaObjC/direct-synthesized-ivar-access.m Wed Dec 1 20:52:00 2010
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -Wnonfragile-abi2 -fsyntax-only -fobjc-nonfragile-abi2 -verify %s
+// rdar://8673791
+
+ at interface I {
+}
+
+ at property int IVAR; // expected-note {{property declared here}}
+- (int) OK;
+ at end
+
+ at implementation I
+- (int) Meth { return IVAR; } // expected-warning {{direct access of synthesized ivar by using property access 'IVAR'}}
+- (int) OK { return self.IVAR; }
+ at end
More information about the llvm-branch-commits
mailing list