Removed the m_decl_objects map from ClangASTContext.

m_decl_objects is problematic because it assumes that each VarDecl has a unique
variable associated with it.  This is not the case in inline contexts.

Also the information in this map can be reconstructed very easily without
maintaining the map.  The rest of the testsuite passes with this cange, and I've
added a testcase covering the inline contexts affected by this.

<rdar://problem/26278502>

llvm-svn: 270474
This commit is contained in:
Sean Callanan
2016-05-23 18:30:59 +00:00
parent 86d5f8ad4c
commit 5ba3215fe3
13 changed files with 42 additions and 80 deletions

View File

@@ -557,12 +557,6 @@ public:
//----------------------------------------------------------------------
// CompilerDecl override functions
//----------------------------------------------------------------------
lldb::VariableSP
DeclGetVariable (void *opaque_decl) override;
void
DeclLinkToObject (void *opaque_decl, std::shared_ptr<void> object) override;
ConstString
DeclGetName (void *opaque_decl) override;
@@ -1218,7 +1212,6 @@ protected:
uint32_t m_pointer_byte_size;
bool m_ast_owned;
bool m_can_evaluate_expressions;
std::map<void *, std::shared_ptr<void>> m_decl_objects;
// clang-format on
private:
//------------------------------------------------------------------

View File

@@ -64,12 +64,6 @@ public:
bool
IsClang () const;
//----------------------------------------------------------------------
// Object linked to the decl
//----------------------------------------------------------------------
lldb::VariableSP
GetAsVariable ();
//----------------------------------------------------------------------
// Accessors
//----------------------------------------------------------------------

View File

@@ -85,17 +85,6 @@ class GoASTContext : public TypeSystem
return ConstString();
}
lldb::VariableSP
DeclGetVariable (void *opaque_decl) override
{
return lldb::VariableSP();
}
void
DeclLinkToObject (void *opaque_decl, std::shared_ptr<void> object) override
{
}
//----------------------------------------------------------------------
// CompilerDeclContext functions
//----------------------------------------------------------------------

View File

@@ -70,12 +70,6 @@ public:
ConstString
DeclGetName(void *opaque_decl) override;
lldb::VariableSP
DeclGetVariable(void *opaque_decl) override;
void
DeclLinkToObject(void *opaque_decl, std::shared_ptr<void> object) override;
//----------------------------------------------------------------------
// CompilerDeclContext functions
//----------------------------------------------------------------------

View File

@@ -127,12 +127,6 @@ public:
virtual ConstString
DeclGetMangledName (void *opaque_decl);
virtual lldb::VariableSP
DeclGetVariable (void *opaque_decl) = 0;
virtual void
DeclLinkToObject (void *opaque_decl, std::shared_ptr<void> object) = 0;
virtual CompilerDeclContext
DeclGetDeclContext (void *opaque_decl);

View File

@@ -0,0 +1,4 @@
from lldbsuite.test import lldbinline
from lldbsuite.test import decorators
lldbinline.MakeInlineTest(__file__, globals(), [])

View File

@@ -0,0 +1,19 @@
#include <stdio.h>
void test1(int) __attribute__ ((always_inline));
void test2(int) __attribute__ ((always_inline));
void test2(int b) {
printf("test2(%d)\n", b); //% self.expect("expression b", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["42"])
}
void test1(int a) {
printf("test1(%d)\n", a);
test2(a+1);//% self.dbg.HandleCommand("step")
//% self.expect("expression b", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["24"])
}
int main() {
test2(42);
test1(23);
}

View File

@@ -1260,7 +1260,16 @@ ClangExpressionDeclMap::FindExternalVisibleDecls (NameSearchContext &context,
bool variable_found = false;
for (CompilerDecl decl : found_decls)
{
var = decl.GetAsVariable();
for (size_t vi = 0, ve = vars->GetSize(); vi != ve; ++vi)
{
VariableSP candidate_var = vars->GetVariableAtIndex(vi);
if (candidate_var->GetDecl() == decl)
{
var = candidate_var;
break;
}
}
if (var)
{
variable_found = true;

View File

@@ -3607,6 +3607,14 @@ DWARFASTParserClang::GetClangDeclForDIE (const DWARFDIE &die)
m_decl_to_die[decl].insert(die.GetDIE());
return decl;
}
if (DWARFDIE abstract_origin_die = die.GetReferencedDIE(DW_AT_abstract_origin))
{
clang::Decl *decl = GetClangDeclForDIE(abstract_origin_die);
m_die_to_decl[die.GetDIE()] = decl;
m_decl_to_die[decl].insert(die.GetDIE());
return decl;
}
clang::Decl *decl = nullptr;
switch (die.Tag())

View File

@@ -9595,24 +9595,6 @@ ClangASTContext::LayoutRecordType(void *baton,
//----------------------------------------------------------------------
// CompilerDecl override functions
//----------------------------------------------------------------------
lldb::VariableSP
ClangASTContext::DeclGetVariable (void *opaque_decl)
{
if (llvm::dyn_cast<clang::VarDecl>((clang::Decl *)opaque_decl))
{
auto decl_search_it = m_decl_objects.find(opaque_decl);
if (decl_search_it != m_decl_objects.end())
return std::static_pointer_cast<Variable>(decl_search_it->second);
}
return VariableSP();
}
void
ClangASTContext::DeclLinkToObject (void *opaque_decl, std::shared_ptr<void> object)
{
if (m_decl_objects.find(opaque_decl) == m_decl_objects.end())
m_decl_objects.insert(std::make_pair(opaque_decl, object));
}
ConstString
ClangASTContext::DeclGetName (void *opaque_decl)

View File

@@ -31,12 +31,6 @@ CompilerDecl::GetMangledName () const
return m_type_system->DeclGetMangledName(m_opaque_decl);
}
lldb::VariableSP
CompilerDecl::GetAsVariable ()
{
return m_type_system->DeclGetVariable(m_opaque_decl);
}
CompilerDeclContext
CompilerDecl::GetDeclContext() const
{

View File

@@ -535,17 +535,6 @@ JavaASTContext::DeclGetName(void *opaque_decl)
return ConstString();
}
lldb::VariableSP
JavaASTContext::DeclGetVariable(void *opaque_decl)
{
return lldb::VariableSP();
}
void
JavaASTContext::DeclLinkToObject(void *opaque_decl, std::shared_ptr<void> object)
{
}
std::vector<CompilerDecl>
JavaASTContext::DeclContextFindDeclByName(void *opaque_decl_ctx, ConstString name, const bool ignore_imported_decls)
{

View File

@@ -252,15 +252,8 @@ Variable::GetDeclContext ()
CompilerDecl
Variable::GetDecl ()
{
CompilerDecl decl;
Type *type = GetType();
if (type)
{
decl = type->GetSymbolFile()->GetDeclForUID(GetID());
if (decl)
decl.GetTypeSystem()->DeclLinkToObject(decl.GetOpaqueDecl(), shared_from_this());
}
return decl;
return type ? type->GetSymbolFile()->GetDeclForUID(GetID()) : CompilerDecl();
}
void