From da8c0e4a3c0d91f5870f6f14237c81f3f143b84d Mon Sep 17 00:00:00 2001 From: Adrian Prantl Date: Tue, 19 Mar 2019 15:38:26 +0000 Subject: Improve error handling for Clang module imports. rdar://problem/48883558 Differential Revision: https://reviews.llvm.org/D59524 llvm-svn: 356462 --- .../lldbsuite/test/lang/cpp/modules-import/Bar.h | 1 - .../lldbsuite/test/lang/cpp/modules-import/Foo.h | 1 - .../test/lang/cpp/modules-import/Inputs/Bar.h | 1 + .../test/lang/cpp/modules-import/Inputs/Foo.h | 1 + .../cpp/modules-import/Inputs/module.modulemap | 7 ++++++ .../test/lang/cpp/modules-import/Makefile | 3 +-- .../cpp/modules-import/TestCXXModulesImport.py | 27 +++++++++++++++++----- .../test/lang/cpp/modules-import/module.modulemap | 7 ------ 8 files changed, 31 insertions(+), 17 deletions(-) delete mode 100644 lldb/packages/Python/lldbsuite/test/lang/cpp/modules-import/Bar.h delete 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/Inputs/Bar.h create mode 100644 lldb/packages/Python/lldbsuite/test/lang/cpp/modules-import/Inputs/Foo.h create mode 100644 lldb/packages/Python/lldbsuite/test/lang/cpp/modules-import/Inputs/module.modulemap delete mode 100644 lldb/packages/Python/lldbsuite/test/lang/cpp/modules-import/module.modulemap (limited to 'lldb/packages/Python/lldbsuite/test/lang/cpp/modules-import') 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 deleted file mode 100644 index 3d9a88c024d..00000000000 --- a/lldb/packages/Python/lldbsuite/test/lang/cpp/modules-import/Bar.h +++ /dev/null @@ -1 +0,0 @@ -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 deleted file mode 100644 index 1fe02e89786..00000000000 --- a/lldb/packages/Python/lldbsuite/test/lang/cpp/modules-import/Foo.h +++ /dev/null @@ -1 +0,0 @@ -struct Foo {}; diff --git a/lldb/packages/Python/lldbsuite/test/lang/cpp/modules-import/Inputs/Bar.h b/lldb/packages/Python/lldbsuite/test/lang/cpp/modules-import/Inputs/Bar.h new file mode 100644 index 00000000000..3d9a88c024d --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/lang/cpp/modules-import/Inputs/Bar.h @@ -0,0 +1 @@ +struct Bar { int success; }; diff --git a/lldb/packages/Python/lldbsuite/test/lang/cpp/modules-import/Inputs/Foo.h b/lldb/packages/Python/lldbsuite/test/lang/cpp/modules-import/Inputs/Foo.h new file mode 100644 index 00000000000..1fe02e89786 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/lang/cpp/modules-import/Inputs/Foo.h @@ -0,0 +1 @@ +struct Foo {}; diff --git a/lldb/packages/Python/lldbsuite/test/lang/cpp/modules-import/Inputs/module.modulemap b/lldb/packages/Python/lldbsuite/test/lang/cpp/modules-import/Inputs/module.modulemap new file mode 100644 index 00000000000..4221d0f9134 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/lang/cpp/modules-import/Inputs/module.modulemap @@ -0,0 +1,7 @@ +module Foo { + header "Foo.h" +} + +module Bar { + header "Bar.h" +} diff --git a/lldb/packages/Python/lldbsuite/test/lang/cpp/modules-import/Makefile b/lldb/packages/Python/lldbsuite/test/lang/cpp/modules-import/Makefile index 796b4dc5ef3..2b8f23bcec7 100644 --- a/lldb/packages/Python/lldbsuite/test/lang/cpp/modules-import/Makefile +++ b/lldb/packages/Python/lldbsuite/test/lang/cpp/modules-import/Makefile @@ -1,6 +1,5 @@ LEVEL = ../../../make CXX_SOURCES := main.cpp - -CFLAGS += $(MANDATORY_MODULE_BUILD_CFLAGS) +CFLAGS_EXTRAS = $(MANDATORY_MODULE_BUILD_CFLAGS) -I$(BUILDDIR)/include 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 index 74ac4005673..cee551d2bc8 100644 --- a/lldb/packages/Python/lldbsuite/test/lang/cpp/modules-import/TestCXXModulesImport.py +++ b/lldb/packages/Python/lldbsuite/test/lang/cpp/modules-import/TestCXXModulesImport.py @@ -2,13 +2,9 @@ from __future__ import print_function - -from distutils.version import StrictVersion import unittest2 -import os -import time import lldb -import platform +import shutil from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * @@ -19,13 +15,32 @@ class CXXModulesImportTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) + def build(self): + include = self.getBuildArtifact('include') + lldbutil.mkdir_p(include) + for f in ['Foo.h', 'Bar.h', 'module.modulemap']: + shutil.copyfile(self.getSourcePath(os.path.join('Inputs', f)), + os.path.join(include, f)) + super(CXXModulesImportTestCase, self).build() + @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 -l Objective-C++ -- @import Bar") self.expect("expr -- Bar()", substrs = ["success"]) + self.expect("expr -l Objective-C++ -- @import THIS_MODULE_DOES_NOT_EXIST", + error=True) + + @skipUnlessDarwin + @skipIf(macos_version=["<", "10.12"]) + def test_expr_failing_import(self): + self.build() + shutil.rmtree(self.getBuildArtifact('include')) + target, process, thread, bkpt = lldbutil.run_to_source_breakpoint( + self, 'break here', lldb.SBFileSpec('main.cpp')) + + self.expect("expr -l Objective-C++ -- @import Bar", error=True) 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 deleted file mode 100644 index 4221d0f9134..00000000000 --- a/lldb/packages/Python/lldbsuite/test/lang/cpp/modules-import/module.modulemap +++ /dev/null @@ -1,7 +0,0 @@ -module Foo { - header "Foo.h" -} - -module Bar { - header "Bar.h" -} -- cgit v1.2.3