llvm-for-llvmta/tools/clang/test/CodeGenCXX/attr-annotate2.cpp

23 lines
1.3 KiB
C++
Raw Normal View History

2022-04-25 13:02:35 +02:00
// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
// RUN: %clang_cc1 %s -S -emit-llvm -triple x86_64-unknown-linux-gnu -o - | FileCheck %s
// CHECK: @[[STR:.*]] = private unnamed_addr constant [45 x i8] c"_Generic selection expression should be fine\00", section "llvm.metadata"
// CHECK-NEXT: @[[FILENAME:.*]] = private unnamed_addr constant {{.*}}, section "llvm.metadata"
// CHECK-NEXT: @[[ARGS:.*]] = private unnamed_addr constant { i32 } zeroinitializer, section "llvm.metadata"
// CHECK-LABEL: @_Z1fv(
// CHECK-NEXT: entry:
// CHECK-NEXT: [[N:%.*]] = alloca i32, align 4
// CHECK-NEXT: [[J:%.*]] = alloca i32, align 4
// CHECK-NEXT: store i32 10, i32* [[N]], align 4
// CHECK-NEXT: [[J1:%.*]] = bitcast i32* [[J]] to i8*
// CHECK-NEXT: call void @llvm.var.annotation(i8* [[J1]], i8* getelementptr inbounds ([45 x i8], [45 x i8]* @[[STR]], i32 0, i32 0), i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* @[[FILENAME]], i32 0, i32 0), i32 {{.*}}, i8* bitcast ({ i32 }* @[[ARGS]] to i8*))
// CHECK-NEXT: store i32 0, i32* [[J]], align 4
// CHECK-NEXT: ret void
//
void f() {
int n = 10;
[[clang::annotate("_Generic selection expression should be fine", _Generic(n, int : 0, default : 1))]]
int j = 0; // second arg should resolve to 0 fine
}