[cfe-commits] r51811 - /cfe/trunk/Driver/RewriteObjC.cpp

Steve Naroff snaroff at apple.com
Fri May 30 20:35:43 PDT 2008


Author: snaroff
Date: Fri May 30 22:35:42 2008
New Revision: 51811

URL: http://llvm.org/viewvc/llvm-project?rev=51811&view=rev
Log:
Hack RewriteObjC::RewriteObjCStringLiteral() to include the filename in the generated code (replacing any non-alphanumeric characters with "_"). This allows header files to contain ObjCStringLiterals.

Modified:
    cfe/trunk/Driver/RewriteObjC.cpp

Modified: cfe/trunk/Driver/RewriteObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/RewriteObjC.cpp?rev=51811&r1=51810&r2=51811&view=diff

==============================================================================
--- cfe/trunk/Driver/RewriteObjC.cpp (original)
+++ cfe/trunk/Driver/RewriteObjC.cpp Fri May 30 22:35:42 2008
@@ -1801,6 +1801,17 @@
   QualType strType = getConstantStringStructType();
 
   std::string S = "__NSConstantStringImpl_";
+
+  std::string tmpName = InFileName;
+  unsigned i;
+  for (i=0; i < tmpName.length(); i++) {
+    char c = tmpName.at(i);
+    // replace any non alphanumeric characters with '_'.
+    if (!isalpha(c) && (c < '0' || c > '9'))
+      tmpName[i] = '_';
+  }
+  S += tmpName;
+  S += "_";
   S += utostr(NumObjCStringLiterals++);
 
   Preamble += "static __NSConstantStringImpl " + S;





More information about the cfe-commits mailing list