Page MenuHomePhabricator

Handle UTF-16 and UTF-32 constant CFStrings
AcceptedPublic

Authored by spyffe on Nov 30 2016, 5:39 PM.

Details

Reviewers
jingham
Summary

We have a longstanding issue where the expression parser does not handle wide CFStrings (e.g., @"凸凹") correctly, producing the useless error message

Internal error [IRForTarget]: An Objective-C constant string's string initializer is not an array
error: warning: expression result unused
error: The expression could not be prepared to run in the target

This is just a side effect of the fact that we don't handle wide string constants when converting these to CFStringCreateWithBytes. That function takes the string's encoding as an argument, so I made it work and added a testcase.

Diff Detail

Repository
rL LLVM

Event Timeline

spyffe updated this revision to Diff 79847.Nov 30 2016, 5:39 PM
spyffe retitled this revision from to Handle UTF-16 and UTF-32 constant CFStrings.
spyffe updated this object.
spyffe added a reviewer: jingham.
spyffe set the repository for this revision to rL LLVM.
spyffe added a subscriber: Restricted Project.
jingham edited edge metadata.Nov 30 2016, 6:05 PM

Other than the request for a more logging, this seems fine.

source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
514–515

The default case here expresses "I don't know what this string is so I'm just going to try ASCII". That's fine, but we should log the unknown kind so that when this happens in the wild and we can't get a repro case, we'll be able to figure out something from the log.

spyffe updated this revision to Diff 79935.Dec 1 2016, 9:54 AM
spyffe edited edge metadata.

Updated to reflect Jim's comments.

jingham accepted this revision.Dec 1 2016, 11:55 AM
jingham edited edge metadata.

Looks good.

This revision is now accepted and ready to land.Dec 1 2016, 11:55 AM