72 lines · c
1// RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -fclangir -emit-cir -o %t.cir2// RUN: FileCheck %s --input-file=%t.cir --check-prefix=CIR3// RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -fclangir -emit-llvm -o %t-cir.ll4// RUN: FileCheck %s --input-file=%t-cir.ll --check-prefix=LLVM5// RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -emit-llvm -o %t.ll6// RUN: FileCheck %s --input-file=%t.ll --check-prefix=OGCG7 8// CIR: cir.global "private" constant cir_private dso_local @__func__.plainFunction = #cir.const_array<"plainFunction\00" : !cir.array<!s8i x 14>>9// CIR: cir.global "private" constant cir_private dso_local @__PRETTY_FUNCTION__.plainFunction = #cir.const_array<"void plainFunction(void)\00" : !cir.array<!s8i x 25>>10// CIR: cir.global "private" constant cir_private dso_local @__func__.externFunction = #cir.const_array<"externFunction\00" : !cir.array<!s8i x 15>>11// CIR: cir.global "private" constant cir_private dso_local @__PRETTY_FUNCTION__.externFunction = #cir.const_array<"void externFunction(void)\00" : !cir.array<!s8i x 26>>12// CIR: cir.global "private" constant cir_private dso_local @__func__.privateExternFunction = #cir.const_array<"privateExternFunction\00" : !cir.array<!s8i x 22>>13// CIR: cir.global "private" constant cir_private dso_local @__PRETTY_FUNCTION__.privateExternFunction = #cir.const_array<"void privateExternFunction(void)\00" : !cir.array<!s8i x 33>>14// CIR: cir.global "private" constant cir_private dso_local @__func__.staticFunction = #cir.const_array<"staticFunction\00" : !cir.array<!s8i x 15>>15// CIR: cir.global "private" constant cir_private dso_local @__PRETTY_FUNCTION__.staticFunction = #cir.const_array<"void staticFunction(void)\00" : !cir.array<!s8i x 26>>16 17// TODO(cir): These should be unnamed_addr18// LLVM: @__func__.plainFunction = private constant [14 x i8] c"plainFunction\00"19// LLVM: @__PRETTY_FUNCTION__.plainFunction = private constant [25 x i8] c"void plainFunction(void)\00"20// LLVM: @__func__.externFunction = private constant [15 x i8] c"externFunction\00"21// LLVM: @__PRETTY_FUNCTION__.externFunction = private constant [26 x i8] c"void externFunction(void)\00"22// LLVM: @__func__.privateExternFunction = private constant [22 x i8] c"privateExternFunction\00"23// LLVM: @__PRETTY_FUNCTION__.privateExternFunction = private constant [33 x i8] c"void privateExternFunction(void)\00"24// LLVM: @__func__.staticFunction = private constant [15 x i8] c"staticFunction\00"25// LLVM: @__PRETTY_FUNCTION__.staticFunction = private constant [26 x i8] c"void staticFunction(void)\00"26 27// OGCG: @__func__.plainFunction = private unnamed_addr constant [14 x i8] c"plainFunction\00"28// OGCG: @__PRETTY_FUNCTION__.plainFunction = private unnamed_addr constant [25 x i8] c"void plainFunction(void)\00"29// OGCG: @__func__.externFunction = private unnamed_addr constant [15 x i8] c"externFunction\00"30// OGCG: @__PRETTY_FUNCTION__.externFunction = private unnamed_addr constant [26 x i8] c"void externFunction(void)\00"31// OGCG: @__func__.privateExternFunction = private unnamed_addr constant [22 x i8] c"privateExternFunction\00"32// OGCG: @__PRETTY_FUNCTION__.privateExternFunction = private unnamed_addr constant [33 x i8] c"void privateExternFunction(void)\00"33// OGCG: @__func__.staticFunction = private unnamed_addr constant [15 x i8] c"staticFunction\00"34// OGCG: @__PRETTY_FUNCTION__.staticFunction = private unnamed_addr constant [26 x i8] c"void staticFunction(void)\00"35 36int printf(const char *, ...);37 38void plainFunction(void) {39 printf("__func__ %s\n", __func__);40 printf("__FUNCTION__ %s\n", __FUNCTION__);41 printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);42}43 44extern void externFunction(void) {45 printf("__func__ %s\n", __func__);46 printf("__FUNCTION__ %s\n", __FUNCTION__);47 printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);48}49 50__private_extern__ void privateExternFunction(void) {51 printf("__func__ %s\n", __func__);52 printf("__FUNCTION__ %s\n", __FUNCTION__);53 printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);54}55 56// TODO(cir): Add support for __captured_stmt57 58static void staticFunction(void) {59 printf("__func__ %s\n", __func__);60 printf("__FUNCTION__ %s\n", __FUNCTION__);61 printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);62}63 64int main(void) {65 plainFunction();66 externFunction();67 privateExternFunction();68 staticFunction();69 70 return 0;71}72