1 // RUN: %clang -fplugin=%llvmshlibdir/Attribute%pluginext -emit-llvm -S %s -o - 2>&1 | FileCheck %s --check-prefix=ATTRIBUTE
2 // RUN: not %clang -fplugin=%llvmshlibdir/Attribute%pluginext -emit-llvm -DBAD_ATTRIBUTE -S %s -o - 2>&1 | FileCheck %s --check-prefix=BADATTRIBUTE
3 // REQUIRES: plugins, examples
4
fn1a()5 void fn1a() __attribute__((example)) { }
fn1b()6 [[example]] void fn1b() { }
fn1c()7 [[plugin::example]] void fn1c() { }
fn2()8 void fn2() __attribute__((example("somestring"))) { }
9 // ATTRIBUTE: warning: 'example' attribute only applies to functions
10 int var1 __attribute__((example("otherstring"))) = 1;
11
12 // ATTRIBUTE: [[STR1_VAR:@.+]] = private unnamed_addr constant [10 x i8] c"example()\00"
13 // ATTRIBUTE: [[STR2_VAR:@.+]] = private unnamed_addr constant [20 x i8] c"example(somestring)\00"
14 // ATTRIBUTE: @llvm.global.annotations = {{.*}}@{{.*}}fn1a{{.*}}[[STR1_VAR]]{{.*}}@{{.*}}fn1b{{.*}}[[STR1_VAR]]{{.*}}@{{.*}}fn1c{{.*}}[[STR1_VAR]]{{.*}}@{{.*}}fn2{{.*}}[[STR2_VAR]]
15
16 #ifdef BAD_ATTRIBUTE
17 class Example {
18 // BADATTRIBUTE: error: 'example' attribute only allowed at file scope
19 void __attribute__((example)) fn3();
20 };
21 // BADATTRIBUTE: error: 'example' attribute requires a string
fn4()22 void fn4() __attribute__((example(123))) { }
23 // BADATTRIBUTE: error: 'example' attribute takes no more than 1 argument
fn5()24 void fn5() __attribute__((example("a","b"))) { }
25 #endif
26