diff options
author | Steve Naroff <snaroff@apple.com> | 2008-05-31 03:35:42 +0000 |
---|---|---|
committer | Steve Naroff <snaroff@apple.com> | 2008-05-31 03:35:42 +0000 |
commit | 7691d9b77b01bf9df6c51e7cb8b43ec150f50b7b (patch) | |
tree | 053fd0fe3b089f704f9b1940b9abb2e287eada16 | |
parent | 94a82c930278809a04976ee13013e6e980b18345 (diff) |
Hack RewriteObjC::RewriteObjCStringLiteral() to include the filename in the generated code (replacing any non-alphanumeric characters with "_"). This allows header files to contain ObjCStringLiterals.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51811 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | Driver/RewriteObjC.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Driver/RewriteObjC.cpp b/Driver/RewriteObjC.cpp index 6d49c7eef0..d1c6b9710a 100644 --- a/Driver/RewriteObjC.cpp +++ b/Driver/RewriteObjC.cpp @@ -1801,6 +1801,17 @@ Stmt *RewriteObjC::RewriteObjCStringLiteral(ObjCStringLiteral *Exp) { 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; |