Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1593,7 +1593,9 @@ bool SymbolFileDWARF::CompleteType(CompilerType &compiler_type) {
DWARFASTParser *dwarf_ast = GetDWARFParser(*def_die.GetCU());
if (!dwarf_ast)
return false;
Type *type = GetDIEToType().lookup(decl_die.GetDIE());
Type *type = decl_die.GetDWARF()->GetDIEToType().lookup(decl_die.GetDIE());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you edit down your commit message into a comment that explains the double-lookup here?

assert(type);

if (decl_die != def_die) {
GetDIEToType()[def_die.GetDIE()] = type;
DWARFASTParserClang *ast_parser =
Expand Down
3 changes: 3 additions & 0 deletions lldb/test/API/lang/cpp/typedef-to-outer-fwd/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
CXX_SOURCES := lib.cpp main.cpp

include Makefile.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import lldb
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil


class TestCaseTypedefToOuterFwd(TestBase):
"""
We are stopped in main.o, which only sees a forward declaration
of FooImpl. We then try to get the FooImpl::Ref typedef (whose
definition is in lib.o). Make sure we correctly resolve this
typedef.
"""

def test(self):
self.build()
(_, _, thread, _) = lldbutil.run_to_source_breakpoint(
self, "return", lldb.SBFileSpec("main.cpp")
)

foo = thread.frames[0].FindVariable("foo")
self.assertSuccess(foo.GetError(), "Found foo")

foo_type = foo.GetType()
self.assertTrue(foo_type)

impl = foo_type.GetPointeeType()
self.assertTrue(impl)

ref = impl.FindDirectNestedType("Ref")
self.assertTrue(ref)

self.assertEqual(ref.GetCanonicalType(), foo_type)
15 changes: 15 additions & 0 deletions lldb/test/API/lang/cpp/typedef-to-outer-fwd/lib.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include "lib.h"

template <typename T> struct FooImpl {
using Ref = FooImpl<T> *;

Ref Create() { return new FooImpl<T>(); }
};

Foo getString() {
FooImpl<char> impl;
Foo ret;
ret.impl = impl.Create();

return ret;
}
10 changes: 10 additions & 0 deletions lldb/test/API/lang/cpp/typedef-to-outer-fwd/lib.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#ifndef LIB_H_IN
#define LIB_H_IN

template <typename T> struct FooImpl;

struct Foo {
FooImpl<char> *impl = nullptr;
};

#endif // LIB_H_IN
8 changes: 8 additions & 0 deletions lldb/test/API/lang/cpp/typedef-to-outer-fwd/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include "lib.h"

extern Foo getString();

int main() {
FooImpl<char> *foo = getString().impl;
return 0;
}
Loading