1 // RUN: %clang_cc1 -triple %ms_abi_triple -fms-extensions -std=c++11 -emit-llvm -O2 -o - %s | FileCheck %s
2 // RUN: %clang_cc1 -triple x86_64-w64-windows-gnu -std=c++11 -emit-llvm -O2 -o - %s | FileCheck %s
4 // The x86_64-w64-windows-gnu version tests mingw target, which relies on
5 // __declspec(...) being defined as __attribute__((...)) by compiler built-in.
8 void (*func_ptr
)() = &target_func
;
10 // The "guard_nocf" attribute must be added.
11 __declspec(guard(nocf
)) void nocf0() {
15 // CHECK: call{{.*}}[[NOCF:#[0-9]+]]
17 // Explicitly test using the GNU-style attribute without relying on the
18 // __declspec define for mingw.
19 // The "guard_nocf" attribute must be added.
20 __attribute__((guard(nocf
))) void nocf0_gnu_style() {
23 // CHECK-LABEL: nocf0_gnu_style
24 // CHECK: call{{.*}}[[NOCF:#[0-9]+]]
26 // Test using the c++-style attribute.
27 // The "guard_nocf" attribute must be added.
28 [[clang::guard(nocf
)]] void nocf0_cxx_style() {
31 // CHECK-LABEL: nocf0_cxx_style
32 // CHECK: call{{.*}}[[NOCF:#[0-9]+]]
34 // The "guard_nocf" attribute must *not* be added.
39 // CHECK: call{{.*}}[[CF:#[0-9]+]]
41 // If the modifier is present on either the function declaration or definition,
42 // the "guard_nocf" attribute must be added.
43 __declspec(guard(nocf
)) void nocf1();
48 // CHECK: call{{.*}}[[NOCF:#[0-9]+]]
51 __declspec(guard(nocf
)) void nocf2() {
55 // CHECK: call{{.*}}[[NOCF:#[0-9]+]]
57 // When inlining a function, the "guard_nocf" attribute on indirect calls must
63 // CHECK: call{{.*}}[[NOCF:#[0-9]+]]
65 // When inlining into a function marked as __declspec(guard(nocf)), the
66 // "guard_nocf" attribute must *not* be added to the inlined calls.
67 __declspec(guard(nocf
)) void cf1() {
71 // CHECK: call{{.*}}[[CF:#[0-9]+]]
73 // When the __declspec(guard(nocf)) modifier is present on an override function,
74 // the "guard_nocf" attribute must be added.
79 struct Derived
: Base
{
80 __declspec(guard(nocf
)) void nocf4() override
{
86 // CHECK: call{{.*}}[[NOCF:#[0-9]+]]
88 // When the modifier is not present on an override function, the "guard_nocf"
89 // attribute must *not* be added, even if the modifier is present on the virtual
92 __declspec(guard(nocf
)) virtual void cf2();
95 struct Derived1
: Base1
{
102 // CHECK: call{{.*}}[[CF:#[0-9]+]]
104 // CHECK: attributes [[NOCF]] = { {{.*}}"guard_nocf"{{.*}} }
105 // CHECK-NOT: attributes [[CF]] = { {{.*}}"guard_nocf"{{.*}} }