xref: /llvm-project/clang/test/CodeGen/2007-06-15-AnnotateAttribute.c (revision d7fcb5b6b5280dc61d5afe0920bb78a82cfe2f27)
1 // RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
2 
3 // CHECK: @.str.3 = private unnamed_addr constant [28 x i8] c"GlobalValAnnotationWithArgs\00", section "llvm.metadata"
4 // CHECK-NEXT: @.args = private unnamed_addr constant { i32, %struct.TestStruct } { i32 42, %struct.TestStruct { i32 1, i32 2 } }, section "llvm.metadata"
5 
6 // CHECK: llvm.global.annotations
7 
8 // CHECK: llvm.var.annotation
9 // CHECK: llvm.var.annotation
10 // CHECK: llvm.var.annotation
11 
12 /* Global variable with attribute */
13 int X __attribute__((annotate("GlobalValAnnotation")));
14 
15 /* Function with attribute */
16 int foo(int y) __attribute__((annotate("GlobalValAnnotation")))
17                __attribute__((noinline));
18 
foo(int y)19 int foo(int y __attribute__((annotate("LocalValAnnotation")))) {
20   int x __attribute__((annotate("LocalValAnnotation")));
21   x = 34;
22   return y + x;
23 }
24 
25 /* Attribute with struct argument. */
26 struct TestStruct {
27   int a;
28   int b;
29 };
30 int Y __attribute__((annotate(
31   "GlobalValAnnotationWithArgs",
32   42,
33   (struct TestStruct) { .a = 1, .b = 2 }
34 )));
35 
36 
main(void)37 int main(void) {
38   static int a __attribute__((annotate("GlobalValAnnotation")));
39   a = foo(2);
40   return 0;
41 }
42