[lldb][Expression] Don't create Objective-C IR checker for pure-C++ targets/frames (#144503)
There's no need to create this utility function (and run it) for
targets/frames that aren't Objective-C/Objective-C++.
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/IRDynamicChecks.cpp b/lldb/source/Plugins/ExpressionParser/Clang/IRDynamicChecks.cpp
index 6ef5d3f..be17c54 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/IRDynamicChecks.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/IRDynamicChecks.cpp
@@ -18,6 +18,7 @@
#include "lldb/Expression/UtilityFunction.h"
#include "lldb/Target/ExecutionContext.h"
+#include "lldb/Target/Language.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/StackFrame.h"
#include "lldb/Target/Target.h"
@@ -46,7 +47,13 @@
ObjCLanguageRuntime *objc_language_runtime =
ObjCLanguageRuntime::Get(*process);
- if (objc_language_runtime) {
+ SourceLanguage lang = process->GetTarget().GetLanguage();
+ if (!lang)
+ if (auto *frame = exe_ctx.GetFramePtr())
+ lang = frame->GetLanguage();
+
+ if (objc_language_runtime &&
+ Language::LanguageIsObjC(lang.AsLanguageType())) {
Expected<std::unique_ptr<UtilityFunction>> checker_fn =
objc_language_runtime->CreateObjectChecker(VALID_OBJC_OBJECT_CHECK_NAME, exe_ctx);
if (!checker_fn)