Skip to content

Commit dadf960

Browse files
authored
[lldb][ObjC] Don't query objective-c runtime for decls in C++ contexts (#95963)
1 parent 7ef2bd4 commit dadf960

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ void ClangASTSource::FindExternalVisibleDecls(
637637
FindDeclInModules(context, name);
638638
}
639639

640-
if (!context.m_found_type) {
640+
if (!context.m_found_type && m_ast_context->getLangOpts().ObjC) {
641641
FindDeclInObjCRuntime(context, name);
642642
}
643643
}

lldb/test/API/lang/objcxx/objc-from-cpp-frames-without-debuginfo/TestObjCFromCppFramesWithoutDebugInfo.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,11 @@ def test(self):
1515
(_, process, _, _) = lldbutil.run_to_name_breakpoint(self, "main")
1616

1717
self.assertState(process.GetState(), lldb.eStateStopped)
18+
19+
# Tests that we can use builtin Objective-C identifiers.
1820
self.expect("expr id", error=False)
21+
22+
# Tests that we can lookup Objective-C decls in the ObjC runtime plugin.
23+
self.expect_expr(
24+
"NSString *c; c == nullptr", result_value="true", result_type="bool"
25+
)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// UNSUPPORTED: system-linux, system-windows
2+
3+
// Tests that we don't consult the the Objective-C runtime
4+
// plugin when in a purely C++ context.
5+
//
6+
// RUN: %clangxx_host %p/Inputs/objc-cast.cpp -g -o %t
7+
// RUN: %lldb %t \
8+
// RUN: -o "b main" -o run \
9+
// RUN: -o "expression --language objective-c -- NSString * a; a" \
10+
// RUN: -o "expression --language objective-c++ -- NSString * b; b" \
11+
// RUN: -o "expression NSString" \
12+
// RUN: 2>&1 | FileCheck %s
13+
14+
// CHECK: (lldb) expression --language objective-c -- NSString * a; a
15+
// CHECK-NEXT: (NSString *){{.*}}= nil
16+
17+
// CHECK: (lldb) expression --language objective-c++ -- NSString * b; b
18+
// CHECK-NEXT: (NSString *){{.*}}= nil
19+
20+
// CHECK: (lldb) expression NSString
21+
// CHECK-NEXT: error:{{.*}} use of undeclared identifier 'NSString'

0 commit comments

Comments
 (0)