[Lldb-commits] [lldb] r372017 - [lldb][NFC] Make ApplyObjcCastHack less scary
Raphael Isemann via lldb-commits
lldb-commits at lists.llvm.org
Mon Sep 16 11:02:21 PDT 2019
Author: teemperor
Date: Mon Sep 16 11:02:21 2019
New Revision: 372017
URL: http://llvm.org/viewvc/llvm-project?rev=372017&view=rev
Log:
[lldb][NFC] Make ApplyObjcCastHack less scary
Modified:
lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp?rev=372017&r1=372016&r2=372017&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp (original)
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp Mon Sep 16 11:02:21 2019
@@ -313,17 +313,13 @@ void ClangUserExpression::ScanContext(Ex
// 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)["
+ std::string from = "(int)[";
+ 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, to.size(), to);
}
bool ClangUserExpression::SetupPersistentState(DiagnosticManager &diagnostic_manager,
More information about the lldb-commits
mailing list