xref: /llvm-project/clang/test/CodeGen/predefined-expr.c (revision adc402bf3d0565ac2bc7efbdd05f0d846e818041)
1 // RUN: %clang_cc1 %s -triple %itanium_abi_triple -emit-llvm -o - | FileCheck %s
2 // RUN: %clang_cc1 -fms-extensions %s -triple %itanium_abi_triple -emit-llvm -o - | FileCheck %s
3 
4 // CHECK: @__func__.plainFunction = private unnamed_addr constant [14 x i8] c"plainFunction\00"
5 // CHECK: @__PRETTY_FUNCTION__.plainFunction = private unnamed_addr constant [25 x i8] c"void plainFunction(void)\00"
6 // CHECK: @__func__.externFunction = private unnamed_addr constant [15 x i8] c"externFunction\00"
7 // CHECK: @__PRETTY_FUNCTION__.externFunction = private unnamed_addr constant [26 x i8] c"void externFunction(void)\00"
8 // CHECK: @__func__.privateExternFunction = private unnamed_addr constant [22 x i8] c"privateExternFunction\00"
9 // CHECK: @__PRETTY_FUNCTION__.privateExternFunction = private unnamed_addr constant [33 x i8] c"void privateExternFunction(void)\00"
10 // CHECK: @__func__.__captured_stmt = private unnamed_addr constant [25 x i8] c"functionWithCapturedStmt\00"
11 // CHECK: @__PRETTY_FUNCTION__.__captured_stmt = private unnamed_addr constant [36 x i8] c"void functionWithCapturedStmt(void)\00"
12 // CHECK: @__func__.staticFunction = private unnamed_addr constant [15 x i8] c"staticFunction\00"
13 // CHECK: @__PRETTY_FUNCTION__.staticFunction = private unnamed_addr constant [26 x i8] c"void staticFunction(void)\00"
14 
15 int printf(const char *, ...);
16 
plainFunction(void)17 void plainFunction(void) {
18   printf("__func__ %s\n", __func__);
19   printf("__FUNCTION__ %s\n", __FUNCTION__);
20   printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
21 }
22 
externFunction(void)23 extern void externFunction(void) {
24   printf("__func__ %s\n", __func__);
25   printf("__FUNCTION__ %s\n", __FUNCTION__);
26   printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
27 }
28 
privateExternFunction(void)29 __private_extern__ void privateExternFunction(void) {
30   printf("__func__ %s\n", __func__);
31   printf("__FUNCTION__ %s\n", __FUNCTION__);
32   printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
33 }
34 
functionWithCapturedStmt(void)35 void functionWithCapturedStmt(void) {
36   #pragma clang __debug captured
37   {
38     printf("__func__ %s\n", __func__);
39     printf("__FUNCTION__ %s\n", __FUNCTION__);
40     printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
41   }
42 }
43 
staticFunction(void)44 static void staticFunction(void) {
45   printf("__func__ %s\n", __func__);
46   printf("__FUNCTION__ %s\n", __FUNCTION__);
47   printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
48 }
49 
main(void)50 int main(void) {
51   plainFunction();
52   externFunction();
53   privateExternFunction();
54   functionWithCapturedStmt();
55   staticFunction();
56 
57   return 0;
58 }
59