hiraditya updated this revision to Diff 377895.
hiraditya added a comment.
Herald added a subscriber: jdoerfert.

Added SemaObjc test case.


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

https://reviews.llvm.org/D111286

Files:
  clang/include/clang/Basic/Attr.td
  clang/test/CodeGen/instrument-objc-method.m
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/SemaObjC/attr-noinstrument.m


Index: clang/test/SemaObjC/attr-noinstrument.m
===================================================================
--- /dev/null
+++ clang/test/SemaObjC/attr-noinstrument.m
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -fsyntax-only -triple x86_64-apple-darwin10.4 -verify 
-Wno-objc-root-class %s
+// RUN: %clang_cc1 -x objective-c++ -fsyntax-only -triple 
x86_64-apple-darwin10.4 -verify -Wno-objc-root-class %s
+
+// expected-no-diagnostics
+@interface A
++ (void)F __attribute__((no_instrument_function)); // no warning
+- (void)f __attribute__((objc_direct, no_instrument_function));
+- (void)g;
+@end
+
+@implementation A
++ (void)F __attribute__((no_instrument_function))
+{
+  [self F];
+}
+
+- (void)f
+{
+  [self g];
+}
+
+- (void)g
+{
+}
+@end
Index: clang/test/Misc/pragma-attribute-supported-attributes-list.test
===================================================================
--- clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -98,7 +98,7 @@
 // CHECK-NEXT: NoDuplicate (SubjectMatchRule_function)
 // CHECK-NEXT: NoEscape (SubjectMatchRule_variable_is_parameter)
 // CHECK-NEXT: NoInline (SubjectMatchRule_function)
-// CHECK-NEXT: NoInstrumentFunction (SubjectMatchRule_function)
+// CHECK-NEXT: NoInstrumentFunction (SubjectMatchRule_function, 
SubjectMatchRule_objc_method)
 // CHECK-NEXT: NoMerge (SubjectMatchRule_function)
 // CHECK-NEXT: NoMicroMips (SubjectMatchRule_function)
 // CHECK-NEXT: NoMips16 (SubjectMatchRule_function)
Index: clang/test/CodeGen/instrument-objc-method.m
===================================================================
--- /dev/null
+++ clang/test/CodeGen/instrument-objc-method.m
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -S -triple x86_64-apple-darwin10 
-debug-info-kind=standalone -emit-llvm -o - %s -finstrument-functions | 
FileCheck %s
+// RUN: %clang_cc1 -S -triple x86_64-apple-darwin10 
-debug-info-kind=standalone -emit-llvm -o - %s -finstrument-function-entry-bare 
| FileCheck -check-prefix=BARE %s
+
+
+@interface ObjCClass
+@end
+
+@implementation ObjCClass
+
+// CHECK: @"\01+[ObjCClass initialize]"
+// CHECK: call void @__cyg_profile_func_enter
+// CHECK: call void @__cyg_profile_func_exit
+// BARE: @"\01+[ObjCClass initialize]"
+// BARE: call void @__cyg_profile_func_enter
++ (void)initialize
+{
+}
+
+// CHECK: @"\01+[ObjCClass load]"
+// CHECK-NOT: call void @__cyg_profile_func_enter
+// BARE: @"\01+[ObjCClass load]"
+// BARE-NOT: call void @__cyg_profile_func_enter
++ (void)load __attribute__((no_instrument_function))
+{
+}
+
+// CHECK: @"\01-[ObjCClass dealloc]"
+// CHECK-NOT: call void @__cyg_profile_func_enter
+// BARE: @"\01-[ObjCClass dealloc]"
+// BARE-NOT: call void @__cyg_profile_func_enter
+-(void)dealloc __attribute__((no_instrument_function))
+{
+}
+
+// CHECK: declare void @__cyg_profile_func_enter(i8*, i8*)
+// CHECK: declare void @__cyg_profile_func_exit(i8*, i8*)
+// BARE: declare void @__cyg_profile_func_enter_bare
+@end
Index: clang/include/clang/Basic/Attr.td
===================================================================
--- clang/include/clang/Basic/Attr.td
+++ clang/include/clang/Basic/Attr.td
@@ -1979,7 +1979,7 @@
 
 def NoInstrumentFunction : InheritableAttr {
   let Spellings = [GCC<"no_instrument_function">];
-  let Subjects = SubjectList<[Function]>;
+  let Subjects = SubjectList<[Function, ObjCMethod]>;
   let Documentation = [Undocumented];
   let SimpleHandler = 1;
 }


Index: clang/test/SemaObjC/attr-noinstrument.m
===================================================================
--- /dev/null
+++ clang/test/SemaObjC/attr-noinstrument.m
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -fsyntax-only -triple x86_64-apple-darwin10.4 -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -x objective-c++ -fsyntax-only -triple x86_64-apple-darwin10.4 -verify -Wno-objc-root-class %s
+
+// expected-no-diagnostics
+@interface A
++ (void)F __attribute__((no_instrument_function)); // no warning
+- (void)f __attribute__((objc_direct, no_instrument_function));
+- (void)g;
+@end
+
+@implementation A
++ (void)F __attribute__((no_instrument_function))
+{
+  [self F];
+}
+
+- (void)f
+{
+  [self g];
+}
+
+- (void)g
+{
+}
+@end
Index: clang/test/Misc/pragma-attribute-supported-attributes-list.test
===================================================================
--- clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -98,7 +98,7 @@
 // CHECK-NEXT: NoDuplicate (SubjectMatchRule_function)
 // CHECK-NEXT: NoEscape (SubjectMatchRule_variable_is_parameter)
 // CHECK-NEXT: NoInline (SubjectMatchRule_function)
-// CHECK-NEXT: NoInstrumentFunction (SubjectMatchRule_function)
+// CHECK-NEXT: NoInstrumentFunction (SubjectMatchRule_function, SubjectMatchRule_objc_method)
 // CHECK-NEXT: NoMerge (SubjectMatchRule_function)
 // CHECK-NEXT: NoMicroMips (SubjectMatchRule_function)
 // CHECK-NEXT: NoMips16 (SubjectMatchRule_function)
Index: clang/test/CodeGen/instrument-objc-method.m
===================================================================
--- /dev/null
+++ clang/test/CodeGen/instrument-objc-method.m
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -S -triple x86_64-apple-darwin10 -debug-info-kind=standalone -emit-llvm -o - %s -finstrument-functions | FileCheck %s
+// RUN: %clang_cc1 -S -triple x86_64-apple-darwin10 -debug-info-kind=standalone -emit-llvm -o - %s -finstrument-function-entry-bare | FileCheck -check-prefix=BARE %s
+
+
+@interface ObjCClass
+@end
+
+@implementation ObjCClass
+
+// CHECK: @"\01+[ObjCClass initialize]"
+// CHECK: call void @__cyg_profile_func_enter
+// CHECK: call void @__cyg_profile_func_exit
+// BARE: @"\01+[ObjCClass initialize]"
+// BARE: call void @__cyg_profile_func_enter
++ (void)initialize
+{
+}
+
+// CHECK: @"\01+[ObjCClass load]"
+// CHECK-NOT: call void @__cyg_profile_func_enter
+// BARE: @"\01+[ObjCClass load]"
+// BARE-NOT: call void @__cyg_profile_func_enter
++ (void)load __attribute__((no_instrument_function))
+{
+}
+
+// CHECK: @"\01-[ObjCClass dealloc]"
+// CHECK-NOT: call void @__cyg_profile_func_enter
+// BARE: @"\01-[ObjCClass dealloc]"
+// BARE-NOT: call void @__cyg_profile_func_enter
+-(void)dealloc __attribute__((no_instrument_function))
+{
+}
+
+// CHECK: declare void @__cyg_profile_func_enter(i8*, i8*)
+// CHECK: declare void @__cyg_profile_func_exit(i8*, i8*)
+// BARE: declare void @__cyg_profile_func_enter_bare
+@end
Index: clang/include/clang/Basic/Attr.td
===================================================================
--- clang/include/clang/Basic/Attr.td
+++ clang/include/clang/Basic/Attr.td
@@ -1979,7 +1979,7 @@
 
 def NoInstrumentFunction : InheritableAttr {
   let Spellings = [GCC<"no_instrument_function">];
-  let Subjects = SubjectList<[Function]>;
+  let Subjects = SubjectList<[Function, ObjCMethod]>;
   let Documentation = [Undocumented];
   let SimpleHandler = 1;
 }
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to