This improves support for the darwin-specific -fconstant-cfstrings option:

Index: darwin.c
===================================================================
--- darwin.c    (revision 119244)
+++ darwin.c    (working copy)
@@ -1379,8 +1379,28 @@ machopic_select_section (tree exp, int r
 /* APPLE LOCAL begin LLVM */
 #ifdef ENABLE_LLVM
 const char *darwin_objc_llvm_implicit_target_global_var_section(tree decl) {
+  const char *name;
+
+  if (TREE_CODE(decl) == CONST_DECL) {
+    extern int flag_next_runtime;
+    tree typename = TYPE_NAME(TREE_TYPE(decl));
+    if (TREE_CODE(typename) == TYPE_DECL)
+      typename = DECL_NAME(typename);
+    
+    if (!strcmp(IDENTIFIER_POINTER(typename), "__builtin_ObjCString")) {
+      if (flag_next_runtime)
+        return "__OBJC,__cstring_object,regular,no_dead_strip";
+      else
+        return "__OBJC,__string_object,no_dead_strip";
+    } else if (!strcmp(IDENTIFIER_POINTER(typename), "__builtin_CFString")) {
+      return "__DATA,__cfstring";
+    } else {
+      return 0;
+    }
+  }
+  
   /* Get a pointer to the name, past the L_OBJC_ prefix. */
-  const char *name = IDENTIFIER_POINTER (DECL_NAME (decl))+7;
+  name = IDENTIFIER_POINTER (DECL_NAME (decl))+7;
   
   if (!strncmp (name, "CLASS_METHODS_", 14))
     return "__OBJC,__cls_meth, regular, no_dead_strip";
Index: darwin.h
===================================================================
--- darwin.h    (revision 119244)
+++ darwin.h    (working copy)
@@ -1552,11 +1552,12 @@ void add_framework_path (char *);
  * For darwin, we have to handle all of the funny objc sections here.  Note 
that
  * doing this by name is very ugly.
  */
-#define LLVM_IMPLICIT_TARGET_GLOBAL_VAR_SECTION(decl)               \
-  ((DECL_NAME (decl) &&                                             \
-   TREE_CODE (DECL_NAME (decl)) == IDENTIFIER_NODE &&               \
-   IDENTIFIER_POINTER (DECL_NAME (decl)) &&                         \
-   !strncmp (IDENTIFIER_POINTER (DECL_NAME (decl)), "L_OBJC_", 7)) ? \
+#define LLVM_IMPLICIT_TARGET_GLOBAL_VAR_SECTION(decl)                   \
+  (((DECL_NAME (decl) &&                                                \
+    TREE_CODE (DECL_NAME (decl)) == IDENTIFIER_NODE &&                  \
+    IDENTIFIER_POINTER (DECL_NAME (decl)) &&                            \
+    !strncmp (IDENTIFIER_POINTER (DECL_NAME (decl)), "L_OBJC_", 7)) ||  \
+   TREE_CODE(decl) == CONST_DECL) ?                                     \
      darwin_objc_llvm_implicit_target_global_var_section(decl) : 0)
 const char *darwin_objc_llvm_implicit_target_global_var_section(tree);
 

-Chris
_______________________________________________
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits

Reply via email to