File: plugin-attribute.cpp

package info (click to toggle)
llvm-toolchain-11 1%3A11.0.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 995,808 kB
  • sloc: cpp: 4,767,656; ansic: 760,916; asm: 477,436; python: 170,940; objc: 69,804; lisp: 29,914; sh: 23,855; f90: 18,173; pascal: 7,551; perl: 7,471; ml: 5,603; awk: 3,489; makefile: 2,573; xml: 915; cs: 573; fortran: 503; javascript: 452
file content (25 lines) | stat: -rw-r--r-- 1,347 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// RUN: %clang -fplugin=%llvmshlibdir/Attribute%pluginext -emit-llvm -S %s -o - 2>&1 | FileCheck %s --check-prefix=ATTRIBUTE
// RUN: not %clang -fplugin=%llvmshlibdir/Attribute%pluginext -emit-llvm -DBAD_ATTRIBUTE -S %s -o - 2>&1 | FileCheck %s --check-prefix=BADATTRIBUTE
// REQUIRES: plugins, examples

void fn1a() __attribute__((example)) { }
[[example]] void fn1b() { }
[[plugin::example]] void fn1c() { }
void fn2() __attribute__((example("somestring"))) { }
// ATTRIBUTE: warning: 'example' attribute only applies to functions
int var1 __attribute__((example("otherstring"))) = 1;

// ATTRIBUTE: [[STR1_VAR:@.+]] = private unnamed_addr constant [10 x i8] c"example()\00"
// ATTRIBUTE: [[STR2_VAR:@.+]] = private unnamed_addr constant [20 x i8] c"example(somestring)\00"
// ATTRIBUTE: @llvm.global.annotations = {{.*}}@{{.*}}fn1a{{.*}}[[STR1_VAR]]{{.*}}@{{.*}}fn1b{{.*}}[[STR1_VAR]]{{.*}}@{{.*}}fn1c{{.*}}[[STR1_VAR]]{{.*}}@{{.*}}fn2{{.*}}[[STR2_VAR]]

#ifdef BAD_ATTRIBUTE
class Example {
  // BADATTRIBUTE: error: 'example' attribute only allowed at file scope
  void __attribute__((example)) fn3();
};
// BADATTRIBUTE: error: 'example' attribute requires a string
void fn4() __attribute__((example(123))) { }
// BADATTRIBUTE: error: 'example' attribute takes no more than 1 argument
void fn5() __attribute__((example("a","b"))) { }
#endif