forked from OSchip/llvm-project
Added some strength to the checks that prevent
"id" from being found by the parser as an externally-defined type. Before, "id" would sometimes make it through if it was defined in a namespace, but this sometimes caused confusion, for example when it conflicted with std::locale::id. llvm-svn: 146891
This commit is contained in:
parent
cdd7e8b14a
commit
bfb7c68b5f
|
@ -574,12 +574,13 @@ ClangASTSource::FindExternalVisibleDecls (NameSearchContext &context,
|
|||
TypeList types;
|
||||
SymbolContext null_sc;
|
||||
|
||||
if (name == id_name || name == Class_name)
|
||||
break;
|
||||
|
||||
if (module_sp && namespace_decl)
|
||||
module_sp->FindTypes(null_sc, name, &namespace_decl, true, 1, types);
|
||||
else if(name != id_name && name != Class_name)
|
||||
else
|
||||
m_target->GetImages().FindTypes(null_sc, name, true, 1, types);
|
||||
else
|
||||
break;
|
||||
|
||||
if (types.GetSize())
|
||||
{
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
LEVEL = ../../../make
|
||||
|
||||
CXX_SOURCES := main.cpp
|
||||
|
||||
include $(LEVEL)/Makefile.rules
|
|
@ -0,0 +1,69 @@
|
|||
"""Test that the expression parser doesn't get confused by 'id' and 'Class'"""
|
||||
|
||||
import os, time
|
||||
import unittest2
|
||||
import lldb
|
||||
import lldbutil
|
||||
from lldbtest import *
|
||||
|
||||
class TestObjCBuiltinTypes(TestBase):
|
||||
|
||||
mydir = os.path.join("lang", "objc", "objc-builtin-types")
|
||||
|
||||
@unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
|
||||
@python_api_test
|
||||
|
||||
def test_with_dsym_and_python_api(self):
|
||||
"""Test expression parser respect for ObjC built-in types."""
|
||||
self.buildDsym()
|
||||
self.objc_builtin_types()
|
||||
|
||||
@python_api_test
|
||||
def test_with_dwarf_and_python_api(self):
|
||||
"""Test expression parser respect for ObjC built-in types."""
|
||||
self.buildDwarf()
|
||||
self.objc_builtin_types()
|
||||
|
||||
def setUp(self):
|
||||
# Call super's setUp().
|
||||
TestBase.setUp(self)
|
||||
# Find the line numbers to break inside main().
|
||||
self.main_source = "main.cpp"
|
||||
self.break_line = line_number(self.main_source, '// Set breakpoint here.')
|
||||
|
||||
#<rdar://problem/10591460> [regression] Can't print ivar value: error: reference to 'id' is ambiguous
|
||||
def objc_builtin_types(self):
|
||||
"""Test expression parser respect for ObjC built-in types."""
|
||||
exe = os.path.join(os.getcwd(), "a.out")
|
||||
|
||||
target = self.dbg.CreateTarget(exe)
|
||||
self.assertTrue(target, VALID_TARGET)
|
||||
|
||||
bpt = target.BreakpointCreateByLocation(self.main_source, self.break_line)
|
||||
self.assertTrue(bpt, VALID_BREAKPOINT)
|
||||
|
||||
# Now launch the process, and do not stop at entry point.
|
||||
process = target.LaunchSimple (None, None, os.getcwd())
|
||||
|
||||
self.assertTrue(process, PROCESS_IS_VALID)
|
||||
|
||||
# The stop reason of the thread should be breakpoint.
|
||||
thread_list = lldbutil.get_threads_stopped_at_breakpoint (process, bpt)
|
||||
|
||||
# Make sure we stopped at the first breakpoint.
|
||||
self.assertTrue (len(thread_list) != 0, "No thread stopped at our breakpoint.")
|
||||
self.assertTrue (len(thread_list) == 1, "More than one thread stopped at our breakpoint.")
|
||||
|
||||
# Now make sure we can call a function in the class method we've stopped in.
|
||||
frame = thread_list[0].GetFrameAtIndex(0)
|
||||
self.assertTrue (frame, "Got a valid frame 0 frame.")
|
||||
|
||||
self.expect("expr (foo)", patterns = ["\(ns::id\) \$.* = 0"])
|
||||
|
||||
self.expect("expr id my_id = 0; my_id", patterns = ["\(id\) \$.* = 0x0"])
|
||||
|
||||
if __name__ == '__main__':
|
||||
import atexit
|
||||
lldb.SBDebugger.Initialize()
|
||||
atexit.register(lambda: lldb.SBDebugger.Terminate())
|
||||
unittest2.main()
|
|
@ -0,0 +1,9 @@
|
|||
namespace ns {
|
||||
typedef int id;
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
ns::id foo = 0;
|
||||
return foo; // Set breakpoint here.
|
||||
}
|
Loading…
Reference in New Issue