Author: spyffe Date: Tue Jul 5 17:06:01 2016 New Revision: 274580 URL: http://llvm.org/viewvc/llvm-project?rev=274580&view=rev Log: Fixed a bug where we report a single type multiple times in namespaces.
Also added a testcase. <rdar://problem/22786569> Added: lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/ lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/Makefile lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/TestNamespaceDefinitions.py lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/a.cpp lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/a.mk lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/b.cpp lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/b.mk lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/foo.h lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/main.cpp Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangASTSource.h Added: lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/Makefile?rev=274580&view=auto ============================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/Makefile (added) +++ lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/Makefile Tue Jul 5 17:06:01 2016 @@ -0,0 +1,19 @@ +LEVEL := ../../../make + +LD_EXTRAS := -L. -l$(LIB_PREFIX)a -l$(LIB_PREFIX)b +CXX_SOURCES := main.cpp + +include $(LEVEL)/Makefile.rules + +.PHONY: +a.out: lib_a lib_b + +lib_%: + $(MAKE) -f $*.mk + +hidden_lib_d: + $(MAKE) -C hidden + +clean:: + $(MAKE) -f a.mk clean + $(MAKE) -f b.mk clean Added: lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/TestNamespaceDefinitions.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/TestNamespaceDefinitions.py?rev=274580&view=auto ============================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/TestNamespaceDefinitions.py (added) +++ lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/TestNamespaceDefinitions.py Tue Jul 5 17:06:01 2016 @@ -0,0 +1,57 @@ +"""Test that forward declarations don't cause bogus conflicts in namespaced types""" + +from __future__ import print_function + + + +import unittest2 +import lldb +from lldbsuite.test.lldbtest import * +import lldbsuite.test.lldbutil as lldbutil + +class NamespaceDefinitionsTestCase(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + def test_expr(self): + self.build() + self.common_setup() + + self.expect("expression -- Foo::MyClass()", VARIABLES_DISPLAYED_CORRECTLY, + substrs = ['thing = ']) + + def setUp(self): + # Call super's setUp(). + TestBase.setUp(self) + # Find the line number to break inside main(). + self.source = 'main.cpp' + self.line = line_number(self.source, '// Set breakpoint here') + self.shlib_names = ["a", "b"] + + def common_setup(self): + # Run in synchronous mode + self.dbg.SetAsync(False) + + # Create a target by the debugger. + target = self.dbg.CreateTarget("a.out") + self.assertTrue(target, VALID_TARGET) + + # Break inside the foo function which takes a bar_ptr argument. + lldbutil.run_break_set_by_file_and_line (self, self.source, self.line, num_expected_locations=1, loc_exact=True) + + # Register our shared libraries for remote targets so they get automatically uploaded + environment = self.registerSharedLibrariesWithTarget(target, self.shlib_names) + + # Now launch the process, and do not stop at entry point. + process = target.LaunchSimple (None, environment, self.get_process_working_directory()) + self.assertTrue(process, PROCESS_IS_VALID) + + # The stop reason of the thread should be breakpoint. + self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, + substrs = ['stopped', + 'stop reason = breakpoint']) + + # The breakpoint should have a hit count of 1. + self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE, + substrs = [' resolved, hit count = 1']) + Added: lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/a.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/a.cpp?rev=274580&view=auto ============================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/a.cpp (added) +++ lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/a.cpp Tue Jul 5 17:06:01 2016 @@ -0,0 +1,16 @@ +//===-- a.cpp ---------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "foo.h" + +class ThingInside { + int a; +}; + +Foo::MyClass a_class; Added: lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/a.mk URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/a.mk?rev=274580&view=auto ============================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/a.mk (added) +++ lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/a.mk Tue Jul 5 17:06:01 2016 @@ -0,0 +1,9 @@ +LEVEL := ../../../make + +DYLIB_NAME := a +DYLIB_CXX_SOURCES := a.cpp +DYLIB_ONLY := YES + +CXXFLAGS += -fPIC + +include $(LEVEL)/Makefile.rules Added: lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/b.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/b.cpp?rev=274580&view=auto ============================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/b.cpp (added) +++ lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/b.cpp Tue Jul 5 17:06:01 2016 @@ -0,0 +1,12 @@ +//===-- b.cpp ---------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "foo.h" + +Foo::MyClass b_class; Added: lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/b.mk URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/b.mk?rev=274580&view=auto ============================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/b.mk (added) +++ lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/b.mk Tue Jul 5 17:06:01 2016 @@ -0,0 +1,9 @@ +LEVEL := ../../../make + +DYLIB_NAME := b +DYLIB_CXX_SOURCES := b.cpp +DYLIB_ONLY := YES + +CXXFLAGS += -fPIC + +include $(LEVEL)/Makefile.rules Added: lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/foo.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/foo.h?rev=274580&view=auto ============================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/foo.h (added) +++ lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/foo.h Tue Jul 5 17:06:01 2016 @@ -0,0 +1,18 @@ +//===-- foo.h ---------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +class ThingInside; + +namespace Foo { + class MyClass { + ThingInside *thing; + public: + MyClass() { } + }; +} Added: lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/main.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/main.cpp?rev=274580&view=auto ============================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/main.cpp (added) +++ lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/main.cpp Tue Jul 5 17:06:01 2016 @@ -0,0 +1,16 @@ +//===-- main.cpp ------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include <stdio.h> + +int +main (int argc, char const *argv[]) +{ + return 0; // Set breakpoint here +} Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp?rev=274580&r1=274579&r2=274580&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp (original) +++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp Tue Jul 5 17:06:01 2016 @@ -743,6 +743,9 @@ ClangASTSource::FindExternalVisibleDecls do { + if (context.m_found.type) + break; + TypeList types; SymbolContext null_sc; const bool exact_match = false; @@ -751,8 +754,6 @@ ClangASTSource::FindExternalVisibleDecls module_sp->FindTypesInNamespace(null_sc, name, &namespace_decl, 1, types); else m_target->GetImages().FindTypes(null_sc, name, exact_match, 1, searched_symbol_files, types); - - bool found_a_type = false; if (size_t num_types = types.GetSize()) { @@ -785,12 +786,12 @@ ClangASTSource::FindExternalVisibleDecls context.AddTypeDecl(copied_clang_type); - found_a_type = true; + context.m_found.type = true; break; } } - if (!found_a_type) + if (!context.m_found.type) { // Try the modules next. @@ -835,13 +836,13 @@ ClangASTSource::FindExternalVisibleDecls context.AddNamedDecl(copied_named_decl); - found_a_type = true; + context.m_found.type = true; } } } while (0); } - if (!found_a_type) + if (!context.m_found.type) { do { Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangASTSource.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangASTSource.h?rev=274580&r1=274579&r2=274580&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangASTSource.h (original) +++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangASTSource.h Tue Jul 5 17:06:01 2016 @@ -431,6 +431,7 @@ struct NameSearchContext { bool function_with_type_info : 1; bool function : 1; bool local_vars_nsp : 1; + bool type : 1; } m_found; //------------------------------------------------------------------ _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits