File tree Expand file tree Collapse file tree 7 files changed +60
-2
lines changed
source/Plugins/SymbolFile/DWARF
test/API/lang/cpp/decl-from-submodule Expand file tree Collapse file tree 7 files changed +60
-2
lines changed Original file line number Diff line number Diff line change @@ -1221,17 +1221,25 @@ bool SymbolFileDWARF::ParseImportedModules(
12211221 SourceModule module ;
12221222 module .path .push_back (ConstString (name));
12231223
1224+ const char *include_path = module_die.GetAttributeValueAsString (
1225+ DW_AT_LLVM_include_path, nullptr );
12241226 DWARFDIE parent_die = module_die;
12251227 while ((parent_die = parent_die.GetParent ())) {
12261228 if (parent_die.Tag () != DW_TAG_module)
12271229 break ;
12281230 if (const char *name =
12291231 parent_die.GetAttributeValueAsString (DW_AT_name, nullptr ))
12301232 module .path .push_back (ConstString (name));
1233+
1234+ // Inferred submodule declarations may not have a
1235+ // DW_AT_LLVM_include_path. Pick the parent (aka umbrella) module's
1236+ // include path instead.
1237+ if (!include_path)
1238+ include_path = parent_die.GetAttributeValueAsString (
1239+ DW_AT_LLVM_include_path, nullptr );
12311240 }
12321241 std::reverse (module .path .begin (), module .path .end ());
1233- if (const char *include_path = module_die.GetAttributeValueAsString (
1234- DW_AT_LLVM_include_path, nullptr )) {
1242+ if (include_path) {
12351243 FileSpec include_spec (include_path, dwarf_cu->GetPathStyle ());
12361244 MakeAbsoluteAndRemap (include_spec, *dwarf_cu,
12371245 m_objfile_sp->GetModule ());
Original file line number Diff line number Diff line change 1+ CXX_SOURCES := main.cpp
2+ CXXFLAGS_EXTRAS = $(MANDATORY_MODULE_BUILD_CFLAGS )
3+
4+ include Makefile.rules
Original file line number Diff line number Diff line change 1+ """Test that decl lookup into submodules in C++ works as expected."""
2+
3+ import lldb
4+ import shutil
5+
6+ from lldbsuite .test .decorators import *
7+ from lldbsuite .test .lldbtest import *
8+ from lldbsuite .test import lldbutil
9+
10+
11+ class DeclFromSubmoduleTestCase (TestBase ):
12+ # Requires DWARF debug info which is not retained when linking with link.exe.
13+ @skipIfWindows
14+ def test_expr (self ):
15+ self .build ()
16+ lldbutil .run_to_source_breakpoint (self , "return 0" , lldb .SBFileSpec ("main.cpp" ))
17+
18+ # FIXME: LLDB finds the decl for 'func' in the submodules correctly and hands it to Clang
19+ # but Sema rejects using the decl during name lookup because it is not marked "Visible".
20+ # However, this assertions still ensures that we at least don't fail to compile the
21+ # submodule (which would cause other errors to appear before the expression error, hence
22+ # we use "startstr").
23+ self .expect (
24+ "expr func(1, 2)" ,
25+ error = True ,
26+ startstr = "error: <user expression 0>:1:1: 'func' has unknown return type" ,
27+ )
Original file line number Diff line number Diff line change 1+ // nodebug to force LLDB to find the decls in modules
2+ [[gnu ::nodebug ]] inline int func (int x ) { return x ; }
Original file line number Diff line number Diff line change 1+ // nodebug to force LLDB to find the decls in modules
2+ [[gnu ::nodebug ]] inline int func (int x , int y ) { return x + y ; }
Original file line number Diff line number Diff line change 1+ #include " TopLevel/module1.h"
2+ #include " TopLevel/module2.h"
3+
4+ int main () {
5+ func (1 );
6+ func (2 , 3 );
7+
8+ return 0 ;
9+ }
Original file line number Diff line number Diff line change 1+ module TopLevel {
2+ umbrella "TopLevel"
3+ explicit module * {
4+ export *
5+ }
6+ }
You can’t perform that action at this time.
0 commit comments