plugin-annotate-functions.c 1.1 KB

12345678910111213141516171819202122232425
  1. // RUN: %clang -fplugin=%llvmshlibdir/AnnotateFunctions%pluginext -emit-llvm -DPRAGMA_ON -S %s -o - | FileCheck %s --check-prefix=PRAGMA
  2. // RUN: %clang -fplugin=%llvmshlibdir/AnnotateFunctions%pluginext -emit-llvm -S %s -o - | FileCheck %s --check-prefix=NOPRAGMA
  3. // RUN: not %clang -fplugin=%llvmshlibdir/AnnotateFunctions%pluginext -emit-llvm -DBAD_PRAGMA -S %s -o - 2>&1 | FileCheck %s --check-prefix=BADPRAGMA
  4. // REQUIRES: plugins, examples
  5. #ifdef PRAGMA_ON
  6. #pragma enable_annotate
  7. #endif
  8. // BADPRAGMA: warning: extra tokens at end of #pragma directive
  9. #ifdef BAD_PRAGMA
  10. #pragma enable_annotate something
  11. #endif
  12. // PRAGMA: [[STR_VAR:@.+]] = private unnamed_addr constant [19 x i8] c"example_annotation\00"
  13. // PRAGMA: @llvm.global.annotations = {{.*}}@fn1{{.*}}[[STR_VAR]]{{.*}}@fn2{{.*}}[[STR_VAR]]
  14. // NOPRAGMA-NOT: [[STR_VAR:@.+]] = private unnamed_addr constant [19 x i8] c"example_annotation\00"
  15. // NOPRAGMA-NOT: @llvm.global.annotations = {{.*}}@fn1{{.*}}[[STR_VAR]]{{.*}}@fn2{{.*}}[[STR_VAR]]
  16. void fn1() { }
  17. void fn2() { }
  18. // BADPRAGMA: error: #pragma enable_annotate not allowed after declarations
  19. #ifdef BAD_PRAGMA
  20. #pragma enable_annotate
  21. #endif