[cfe-commits] r57164 - in /cfe/trunk: lib/Lex/Preprocessor.cpp test/CodeGen/cfstring2.c

Chris Lattner sabre at nondot.org
Mon Oct 6 00:43:11 PDT 2008


Author: lattner
Date: Mon Oct  6 02:43:09 2008
New Revision: 57164

URL: http://llvm.org/viewvc/llvm-project?rev=57164&view=rev
Log:
__CONSTANT_CFSTRINGS__ should be defined even in C mode, otherwise the CFSTR
won't expand to the builtin.  This fixes rdar://6248329


Added:
    cfe/trunk/test/CodeGen/cfstring2.c
Modified:
    cfe/trunk/lib/Lex/Preprocessor.cpp

Modified: cfe/trunk/lib/Lex/Preprocessor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Preprocessor.cpp?rev=57164&r1=57163&r2=57164&view=diff

==============================================================================
--- cfe/trunk/lib/Lex/Preprocessor.cpp (original)
+++ cfe/trunk/lib/Lex/Preprocessor.cpp Mon Oct  6 02:43:09 2008
@@ -488,12 +488,12 @@
 
     if (PP.getLangOptions().NeXTRuntime)
       DefineBuiltinMacro(Buf, "__NEXT_RUNTIME__=1");
-
-    // darwin_constant_cfstrings controls this. This is also dependent
-    // on other things like the runtime I believe.
-    DefineBuiltinMacro(Buf, "__CONSTANT_CFSTRINGS__=1");
   }
   
+  // darwin_constant_cfstrings controls this. This is also dependent
+  // on other things like the runtime I believe.  This is set even for C code.
+  DefineBuiltinMacro(Buf, "__CONSTANT_CFSTRINGS__=1");
+  
   if (PP.getLangOptions().ObjC2)
     DefineBuiltinMacro(Buf, "OBJC_NEW_PROPERTIES");
 

Added: cfe/trunk/test/CodeGen/cfstring2.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/cfstring2.c?rev=57164&view=auto

==============================================================================
--- cfe/trunk/test/CodeGen/cfstring2.c (added)
+++ cfe/trunk/test/CodeGen/cfstring2.c Mon Oct  6 02:43:09 2008
@@ -0,0 +1,13 @@
+// RUN: clang -emit-llvm %s -o %t
+
+#ifdef __APPLE__
+#include <Carbon/Carbon.h>
+
+void f() {
+  CFSTR("Hello, World!");
+}
+
+// rdar://6248329
+void *G = CFSTR("yo joe");
+
+#endif





More information about the cfe-commits mailing list