[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / CodeGen / xray-typedevent.cpp
blob57597970cd9e84aff83dbc85367d8704663281e6
1 // RUN: %clang_cc1 -fxray-instrument -x c++ -std=c++11 -triple x86_64-unknown-unknown -emit-llvm -o - %s | FileCheck %s
3 // CHECK-LABEL: @_Z16alwaysInstrumentv
4 [[clang::xray_always_instrument]] void alwaysInstrument() {
5 // Event types would normally come from calling __xray_register_event_type
6 // from compiler-rt
7 auto EventType = 1;
8 static constexpr char kPhase[] = "instrument";
9 __xray_typedevent(EventType, kPhase, 10);
10 // CHECK: call void @llvm.xray.typedevent(i16 {{.*}}, ptr{{.*}}, i32 10)
13 // CHECK-LABEL: @_Z15neverInstrumentv
14 [[clang::xray_never_instrument]] void neverInstrument() {
15 auto EventType = 2;
16 static constexpr char kPhase[] = "never";
17 __xray_typedevent(EventType, kPhase, 5);
18 // CHECK-NOT: call void @llvm.xray.typedevent(i16 {{.*}}, ptr{{.*}}, i32 5)
21 // CHECK-LABEL: @_Z21conditionalInstrumenti
22 [[clang::xray_always_instrument]] void conditionalInstrument(int v) {
23 auto TrueEventType = 3;
24 auto UntrueEventType = 4;
25 static constexpr char kTrue[] = "true";
26 static constexpr char kUntrue[] = "untrue";
27 if (v % 2)
28 __xray_typedevent(TrueEventType, kTrue, 4);
29 else
30 __xray_typedevent(UntrueEventType, kUntrue, 6);
32 // CHECK: call void @llvm.xray.typedevent(i16 {{.*}}, ptr{{.*}}, i32 4)
33 // CHECK: call void @llvm.xray.typedevent(i16 {{.*}}, ptr{{.*}}, i32 6)