From 0f30a3b68fa8d687d041c8cd69ed8018d1ed0c84 Mon Sep 17 00:00:00 2001 From: Adrian Prantl Date: Wed, 13 Feb 2019 18:10:41 +0000 Subject: Deserialize Clang module search path from DWARF This patch properly extracts the full submodule path as well as its search paths from DWARF import decls and passes it on to the ClangModulesDeclVendor. rdar://problem/47970144 Differential Revision: https://reviews.llvm.org/D58090 llvm-svn: 353961 --- .../lldbsuite/test/lang/cpp/modules-import/Bar.h | 1 + .../lldbsuite/test/lang/cpp/modules-import/Foo.h | 1 + .../test/lang/cpp/modules-import/Makefile | 6 +++++ .../cpp/modules-import/TestCXXModulesImport.py | 31 ++++++++++++++++++++++ .../test/lang/cpp/modules-import/main.cpp | 7 +++++ .../test/lang/cpp/modules-import/module.modulemap | 7 +++++ 6 files changed, 53 insertions(+) create mode 100644 lldb/packages/Python/lldbsuite/test/lang/cpp/modules-import/Bar.h create mode 100644 lldb/packages/Python/lldbsuite/test/lang/cpp/modules-import/Foo.h create mode 100644 lldb/packages/Python/lldbsuite/test/lang/cpp/modules-import/Makefile create mode 100644 lldb/packages/Python/lldbsuite/test/lang/cpp/modules-import/TestCXXModulesImport.py create mode 100644 lldb/packages/Python/lldbsuite/test/lang/cpp/modules-import/main.cpp create mode 100644 lldb/packages/Python/lldbsuite/test/lang/cpp/modules-import/module.modulemap (limited to 'lldb/packages/Python/lldbsuite/test/lang/cpp') diff --git a/lldb/packages/Python/lldbsuite/test/lang/cpp/modules-import/Bar.h b/lldb/packages/Python/lldbsuite/test/lang/cpp/modules-import/Bar.h new file mode 100644 index 00000000000..3d9a88c024d --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/lang/cpp/modules-import/Bar.h @@ -0,0 +1 @@ +struct Bar { int success; }; diff --git a/lldb/packages/Python/lldbsuite/test/lang/cpp/modules-import/Foo.h b/lldb/packages/Python/lldbsuite/test/lang/cpp/modules-import/Foo.h new file mode 100644 index 00000000000..1fe02e89786 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/lang/cpp/modules-import/Foo.h @@ -0,0 +1 @@ +struct Foo {}; diff --git a/lldb/packages/Python/lldbsuite/test/lang/cpp/modules-import/Makefile b/lldb/packages/Python/lldbsuite/test/lang/cpp/modules-import/Makefile new file mode 100644 index 00000000000..796b4dc5ef3 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/lang/cpp/modules-import/Makefile @@ -0,0 +1,6 @@ +LEVEL = ../../../make +CXX_SOURCES := main.cpp + +CFLAGS += $(MANDATORY_MODULE_BUILD_CFLAGS) + +include $(LEVEL)/Makefile.rules diff --git a/lldb/packages/Python/lldbsuite/test/lang/cpp/modules-import/TestCXXModulesImport.py b/lldb/packages/Python/lldbsuite/test/lang/cpp/modules-import/TestCXXModulesImport.py new file mode 100644 index 00000000000..9601db2586a --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/lang/cpp/modules-import/TestCXXModulesImport.py @@ -0,0 +1,31 @@ +"""Test that importing modules in C++ works as expected.""" + +from __future__ import print_function + + +from distutils.version import StrictVersion +import unittest2 +import os +import time +import lldb +import platform + +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class CXXModulesImportTestCase(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + @skipUnlessDarwin + @skipIf(macos_version=["<", "10.12"]) + def test_expr(self): + self.build() + exe = self.getBuildArtifact("a.out") + target, process, thread, bkpt = lldbutil.run_to_source_breakpoint( + self, 'break here', lldb.SBFileSpec('main.cpp')) + + self.expect("expr -- @import Bar") + self.expect("expr -- Bar()", substrs = ["success"]) diff --git a/lldb/packages/Python/lldbsuite/test/lang/cpp/modules-import/main.cpp b/lldb/packages/Python/lldbsuite/test/lang/cpp/modules-import/main.cpp new file mode 100644 index 00000000000..a6acf9a1a69 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/lang/cpp/modules-import/main.cpp @@ -0,0 +1,7 @@ +#include "Foo.h" + +int main(int argc, char **argv) { + Foo foo; + // break here. + return 0; +} diff --git a/lldb/packages/Python/lldbsuite/test/lang/cpp/modules-import/module.modulemap b/lldb/packages/Python/lldbsuite/test/lang/cpp/modules-import/module.modulemap new file mode 100644 index 00000000000..4221d0f9134 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/lang/cpp/modules-import/module.modulemap @@ -0,0 +1,7 @@ +module Foo { + header "Foo.h" +} + +module Bar { + header "Bar.h" +} -- cgit v1.2.3