mwyman updated this revision to Diff 440311.
mwyman added a comment.

Added codegen test.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D128556/new/

https://reviews.llvm.org/D128556

Files:
  clang/lib/Sema/SemaLookup.cpp
  clang/test/CodeGenObjC/ivar-implicit-self-shadow.m


Index: clang/test/CodeGenObjC/ivar-implicit-self-shadow.m
===================================================================
--- /dev/null
+++ clang/test/CodeGenObjC/ivar-implicit-self-shadow.m
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -triple x86_64-apple-iossimulator -fobjc-arc -x objective-c 
-emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK
+// RUN: %clang_cc1 -triple x86_64-apple-iossimulator -fobjc-arc -x 
objective-c++ -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK
+
+__attribute__((objc_root_class))
+@interface Foo
+@end
+
+extern Foo *CreateObject(void) __attribute__((ns_returns_retained));
+
+@implementation Foo {
+  int _ivar;
+}
+
+// CHECK-LABEL: define{{.*}}-[Foo foo]"(ptr noundef %self, ptr noundef %_cmd) 
#0 {
+- (void)foo {
+  {
+    Foo *self = CreateObject();
+    _ivar = 42;
+    // CHECK:       [[PTR:%.*]] = load ptr, ptr %self.addr, align 8
+    // CHECK-NEXT:  [[IVAR:%.*]] = load i64, ptr @"OBJC_IVAR_$_Foo._ivar", 
align 8, {{.*}}
+    // CHECK-NEXT:  [[OFFSET:%.*]] = getelementptr inbounds i8, ptr [[PTR]], 
i64 [[IVAR]]
+    // CHECK-NEXT:  store i32 42, ptr [[OFFSET]]
+  }
+}
+@end
+
Index: clang/lib/Sema/SemaLookup.cpp
===================================================================
--- clang/lib/Sema/SemaLookup.cpp
+++ clang/lib/Sema/SemaLookup.cpp
@@ -1313,6 +1313,9 @@
             R.setShadowed();
             continue;
           }
+        } else if (NameKind == LookupObjCImplicitSelfParam &&
+                   !isa<ImplicitParamDecl>(*I)) {
+          continue;
         } else {
           // We found something in this scope, we should not look at the
           // namespace scope


Index: clang/test/CodeGenObjC/ivar-implicit-self-shadow.m
===================================================================
--- /dev/null
+++ clang/test/CodeGenObjC/ivar-implicit-self-shadow.m
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -triple x86_64-apple-iossimulator -fobjc-arc -x objective-c -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK
+// RUN: %clang_cc1 -triple x86_64-apple-iossimulator -fobjc-arc -x objective-c++ -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK
+
+__attribute__((objc_root_class))
+@interface Foo
+@end
+
+extern Foo *CreateObject(void) __attribute__((ns_returns_retained));
+
+@implementation Foo {
+  int _ivar;
+}
+
+// CHECK-LABEL: define{{.*}}-[Foo foo]"(ptr noundef %self, ptr noundef %_cmd) #0 {
+- (void)foo {
+  {
+    Foo *self = CreateObject();
+    _ivar = 42;
+    // CHECK:       [[PTR:%.*]] = load ptr, ptr %self.addr, align 8
+    // CHECK-NEXT:  [[IVAR:%.*]] = load i64, ptr @"OBJC_IVAR_$_Foo._ivar", align 8, {{.*}}
+    // CHECK-NEXT:  [[OFFSET:%.*]] = getelementptr inbounds i8, ptr [[PTR]], i64 [[IVAR]]
+    // CHECK-NEXT:  store i32 42, ptr [[OFFSET]]
+  }
+}
+@end
+
Index: clang/lib/Sema/SemaLookup.cpp
===================================================================
--- clang/lib/Sema/SemaLookup.cpp
+++ clang/lib/Sema/SemaLookup.cpp
@@ -1313,6 +1313,9 @@
             R.setShadowed();
             continue;
           }
+        } else if (NameKind == LookupObjCImplicitSelfParam &&
+                   !isa<ImplicitParamDecl>(*I)) {
+          continue;
         } else {
           // We found something in this scope, we should not look at the
           // namespace scope
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to