Reland "[lldb][NFC] Make ApplyObjcCastHack less scary"

First version had a typo.

llvm-svn: 372077
This commit is contained in:
Raphael Isemann 2019-09-17 07:58:01 +00:00
parent 26a475afe5
commit 3ee98a1455
1 changed files with 5 additions and 9 deletions

View File

@ -313,17 +313,13 @@ void ClangUserExpression::ScanContext(ExecutionContext &exe_ctx, Status &err) {
// count is not available, [myArray count] returns id, which can't be directly
// cast to int without causing a clang error.
static void ApplyObjcCastHack(std::string &expr) {
#define OBJC_CAST_HACK_FROM "(int)["
#define OBJC_CAST_HACK_TO "(int)(long long)["
const std::string from = "(int)[";
const std::string to = "(int)(long long)[";
size_t from_offset;
size_t offset;
while ((from_offset = expr.find(OBJC_CAST_HACK_FROM)) != expr.npos)
expr.replace(from_offset, sizeof(OBJC_CAST_HACK_FROM) - 1,
OBJC_CAST_HACK_TO);
#undef OBJC_CAST_HACK_TO
#undef OBJC_CAST_HACK_FROM
while ((offset = expr.find(from)) != expr.npos)
expr.replace(offset, from.size(), to);
}
bool ClangUserExpression::SetupPersistentState(DiagnosticManager &diagnostic_manager,