declare_variant_implementation_vendor_codegen.cpp 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple %itanium_abi_triple -emit-llvm %s -fexceptions -fcxx-exceptions -o - -fsanitize-address-use-after-scope | FileCheck %s
  2. // RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple %itanium_abi_triple -fexceptions -fcxx-exceptions -emit-pch -o %t -fopenmp-version=50 %s
  3. // RUN: %clang_cc1 -fopenmp -x c++ -triple %itanium_abi_triple -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - -fopenmp-version=50 | FileCheck %s
  4. // expected-no-diagnostics
  5. // CHECK-NOT: ret i32 {{1|4}}
  6. // CHECK-DAG: @_Z3barv = {{.*}}alias i32 (), i32 ()* @_Z3foov
  7. // CHECK-DAG: @_ZN16SpecSpecialFuncs6MethodEv = {{.*}}alias i32 (%struct.SpecSpecialFuncs*), i32 (%struct.SpecSpecialFuncs*)* @_ZN16SpecSpecialFuncs7method_Ev
  8. // CHECK-DAG: @_ZN16SpecSpecialFuncs6methodEv = linkonce_odr {{.*}}alias i32 (%struct.SpecSpecialFuncs*), i32 (%struct.SpecSpecialFuncs*)* @_ZN16SpecSpecialFuncs7method_Ev
  9. // CHECK-DAG: @_ZN12SpecialFuncs6methodEv = linkonce_odr {{.*}}alias i32 (%struct.SpecialFuncs*), i32 (%struct.SpecialFuncs*)* @_ZN12SpecialFuncs7method_Ev
  10. // CHECK-DAG: @_Z4callv = {{.*}}alias i32 (), i32 ()* @_Z4testv
  11. // CHECK-DAG: @_ZL9stat_usedv = internal alias i32 (), i32 ()* @_ZL10stat_used_v
  12. // CHECK-DAG: @_ZN12SpecialFuncs6MethodEv = {{.*}}alias i32 (%struct.SpecialFuncs*), i32 (%struct.SpecialFuncs*)* @_ZN12SpecialFuncs7method_Ev
  13. // CHECK-DAG: declare {{.*}}i32 @_Z5bazzzv()
  14. // CHECK-DAG: declare {{.*}}i32 @_Z3bazv()
  15. // CHECK-DAG: ret i32 2
  16. // CHECK-DAG: ret i32 3
  17. // CHECK-DAG: ret i32 5
  18. // CHECK-DAG: ret i32 6
  19. // CHECK-DAG: ret i32 7
  20. // CHECK-NOT: ret i32 {{1|4}}
  21. #ifndef HEADER
  22. #define HEADER
  23. int foo() { return 2; }
  24. #pragma omp declare variant(foo) match(implementation = {vendor(llvm)})
  25. int bar() { return 1; }
  26. int bazzz();
  27. #pragma omp declare variant(bazzz) match(implementation = {vendor(llvm)})
  28. int baz() { return 1; }
  29. int test();
  30. #pragma omp declare variant(test) match(implementation = {vendor(llvm)})
  31. int call() { return 1; }
  32. static int stat_unused_();
  33. #pragma omp declare variant(stat_unused_) match(implementation = {vendor(llvm)})
  34. static int stat_unused() { return 1; }
  35. static int stat_used_();
  36. #pragma omp declare variant(stat_used_) match(implementation = {vendor(llvm)})
  37. static int stat_used() { return 1; }
  38. int main() { return bar() + baz() + call() + stat_used(); }
  39. int test() { return 3; }
  40. static int stat_unused_() { return 4; }
  41. static int stat_used_() { return 5; }
  42. struct SpecialFuncs {
  43. void vd() {}
  44. SpecialFuncs();
  45. ~SpecialFuncs();
  46. int method_() { return 6; }
  47. #pragma omp declare variant(SpecialFuncs::method_) \
  48. match(implementation = {vendor(llvm)})
  49. int method() { return 1; }
  50. #pragma omp declare variant(SpecialFuncs::method_) \
  51. match(implementation = {vendor(llvm)})
  52. int Method();
  53. } s;
  54. int SpecialFuncs::Method() { return 1; }
  55. struct SpecSpecialFuncs {
  56. void vd() {}
  57. SpecSpecialFuncs();
  58. ~SpecSpecialFuncs();
  59. int method_();
  60. #pragma omp declare variant(SpecSpecialFuncs::method_) \
  61. match(implementation = {vendor(llvm)})
  62. int method() { return 1; }
  63. #pragma omp declare variant(SpecSpecialFuncs::method_) \
  64. match(implementation = {vendor(llvm)})
  65. int Method();
  66. } s1;
  67. int SpecSpecialFuncs::method_() { return 7; }
  68. int SpecSpecialFuncs::Method() { return 1; }
  69. void xxx() {
  70. (void)s.method();
  71. (void)s1.method();
  72. }
  73. #endif // HEADER