xref: /llvm-project/clang/test/CodeGen/cfstring.c (revision 170c194ec19c76deee33d8aa8b288368c574f7a0)
1 // REQUIRES: x86-registered-target
2 
3 // RUN: %clang_cc1 -triple x86_64-macho -emit-llvm %s -o %t
4 // RUN: %clang_cc1 -triple x86_64-macho -emit-llvm %s -o %t -fexperimental-new-constant-interpreter
5 
6 // Check that the backing store of CFStrings are constant with the
7 // -fwritable-strings flag.
8 //
9 // RUN: %clang_cc1 -triple x86_64-macho -fwritable-strings -emit-llvm %s -o - | FileCheck %s
10 //
11 // CHECK: @.str = private unnamed_addr constant [14 x i8] c"Hello, World!\00", section "__TEXT,__cstring,cstring_literals", align 1
12 // CHECK: @.str.1 = private unnamed_addr constant [7 x i8] c"yo joe\00", section "__TEXT,__cstring,cstring_literals", align 1
13 // CHECK: @.str.3 = private unnamed_addr constant [16 x i8] c"Goodbye, World!\00", section "__TEXT,__cstring,cstring_literals", align 1
14 
15 #define CFSTR __builtin___CFStringMakeConstantString
16 
f(void)17 void f(void) {
18   CFSTR("Hello, World!");
19 }
20 
21 void *G = CFSTR("yo joe");
22 
h(void)23 void h(void) {
24   static void* h = CFSTR("Goodbye, World!");
25 }
26