summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CodeGenModule.cpp
diff options
context:
space:
mode:
authorSteve Naroff <snaroff@apple.com>2009-04-13 19:08:08 +0000
committerSteve Naroff <snaroff@apple.com>2009-04-13 19:08:08 +0000
commit84073ec51f39cf6d4b8cbd43187583f5b98d131a (patch)
tree28b00041665a79cb20142c5a7a5af42d77e3c553 /clang/lib/CodeGen/CodeGenModule.cpp
parent1daeb69f957e9cb53de55b2baa2f577b8b637963 (diff)
downloadbcm5719-llvm-84073ec51f39cf6d4b8cbd43187583f5b98d131a.tar.gz
bcm5719-llvm-84073ec51f39cf6d4b8cbd43187583f5b98d131a.zip
Fixed crasher in <rdar://problem/6780904> [irgen] Assertion failed: (Result == conversionOK && "UTF-8 to UTF-16 conversion failed"), function GetAddrOfConstantCFString, file CodeGenModule.cpp, line 1063.
Still a diagnostic related FIXME (will discuss with Daniel/Fariborz offline). llvm-svn: 68975
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp27
1 files changed, 18 insertions, 9 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index ce893dbcfd6..797c0cef000 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -1060,16 +1060,25 @@ GetAddrOfConstantCFString(const StringLiteral *Literal) {
Result = ConvertUTF8toUTF16(&FromPtr, FromPtr+Literal->getByteLength(),
&ToPtr, ToPtr+Literal->getByteLength(),
strictConversion);
- assert(Result == conversionOK && "UTF-8 to UTF-16 conversion failed");
+ if (Result == conversionOK) {
+ // FIXME: Storing UTF-16 in a C string is a hack to test Unicode strings
+ // without doing more surgery to this routine. Since we aren't explicitly
+ // checking for endianness here, it's also a bug (when generating code for
+ // a target that doesn't match the host endianness). Modeling this as an
+ // i16 array is likely the cleanest solution.
+ StringLength = ToPtr-&ToBuf[0];
+ str.assign((char *)&ToBuf[0], StringLength*2);// Twice as many UTF8 chars.
+ isUTF16 = true;
+ } else if (Result == sourceIllegal) {
+ // FIXME: GCC currently emits the following warning (in the backend):
+ // "warning: input conversion stopped due to an input byte that does not
+ // belong to the input codeset UTF-8"
+ // The clang backend doesn't currently emit any warnings.
+ str.assign(Literal->getStrData(), Literal->getByteLength());
+ StringLength = str.length();
+ } else
+ assert(Result == conversionOK && "UTF-8 to UTF-16 conversion failed");
- // FIXME: Storing UTF-16 in a C string is a hack to test Unicode strings
- // without doing more surgery to this routine. Since we aren't explicitly
- // checking for endianness here, it's also a bug (when generating code for
- // a target that doesn't match the host endianness). Modeling this as an i16
- // array is likely the cleanest solution.
- StringLength = ToPtr-&ToBuf[0];
- str.assign((char *)&ToBuf[0], StringLength*2); // Twice as many UTF8 chars.
- isUTF16 = true;
} else {
str.assign(Literal->getStrData(), Literal->getByteLength());
StringLength = str.length();
OpenPOWER on IntegriCloud