forked from OSchip/llvm-project
Fixed a bug where we report a single type multiple times in namespaces.
Also added a testcase. <rdar://problem/22786569> llvm-svn: 274580
This commit is contained in:
parent
b395d7271d
commit
8ba1654d48
|
@ -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
|
|
@ -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'])
|
||||
|
|
@ -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;
|
|
@ -0,0 +1,9 @@
|
|||
LEVEL := ../../../make
|
||||
|
||||
DYLIB_NAME := a
|
||||
DYLIB_CXX_SOURCES := a.cpp
|
||||
DYLIB_ONLY := YES
|
||||
|
||||
CXXFLAGS += -fPIC
|
||||
|
||||
include $(LEVEL)/Makefile.rules
|
|
@ -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;
|
|
@ -0,0 +1,9 @@
|
|||
LEVEL := ../../../make
|
||||
|
||||
DYLIB_NAME := b
|
||||
DYLIB_CXX_SOURCES := b.cpp
|
||||
DYLIB_ONLY := YES
|
||||
|
||||
CXXFLAGS += -fPIC
|
||||
|
||||
include $(LEVEL)/Makefile.rules
|
|
@ -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() { }
|
||||
};
|
||||
}
|
|
@ -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
|
||||
}
|
|
@ -743,6 +743,9 @@ ClangASTSource::FindExternalVisibleDecls (NameSearchContext &context,
|
|||
|
||||
do
|
||||
{
|
||||
if (context.m_found.type)
|
||||
break;
|
||||
|
||||
TypeList types;
|
||||
SymbolContext null_sc;
|
||||
const bool exact_match = false;
|
||||
|
@ -751,8 +754,6 @@ ClangASTSource::FindExternalVisibleDecls (NameSearchContext &context,
|
|||
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 (NameSearchContext &context,
|
|||
|
||||
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 (NameSearchContext &context,
|
|||
|
||||
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
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
||||
//------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in New Issue