From c51c38b4ec63ca17f5d38ec73b218a0247b39ace Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Sat, 29 Apr 2017 00:34:47 +0000 Subject: Add pragma to perform module import and use it in -E output. Many of our supported configurations support modules but do not have any first-class syntax to perform a module import. This leaves us with a problem: there is no way to represent the expansion of a #include that imports a module in the -E output for such languages. (We don't want to just leave it as a #include because that requires the consumer of the preprocessed source to have the same file system layout and include paths as the creator.) This patch adds a new pragma: #pragma clang module import MODULE.NAME.HERE that imports a module, and changes -E and -frewrite-includes to use it when rewriting a #include that maps to a module import. We don't make any attempt to use a native language syntax import if one exists, to get more consistent output. (If in the future, @import and #include have different semantics in some way, the pragma will track the #include semantics.) llvm-svn: 301725 --- clang/test/Preprocessor/pragma_module.c | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 clang/test/Preprocessor/pragma_module.c (limited to 'clang/test/Preprocessor/pragma_module.c') diff --git a/clang/test/Preprocessor/pragma_module.c b/clang/test/Preprocessor/pragma_module.c new file mode 100644 index 00000000000..d734f66efce --- /dev/null +++ b/clang/test/Preprocessor/pragma_module.c @@ -0,0 +1,11 @@ +// RUN: %clang -cc1 -E -fmodules %s -verify + +// Just checking the syntax here; the semantics are tested elsewhere. +#pragma clang module import // expected-error {{expected identifier in module name}} +#pragma clang module import ! // expected-error {{expected identifier in module name}} +#pragma clang module import if // expected-error {{expected identifier in module name}} +#pragma clang module import foo ? bar // expected-error {{expected '.' or end of directive after module name}} +#pragma clang module import foo. // expected-error {{expected identifier}} +#pragma clang module import foo.bar.baz.quux // expected-error {{module 'foo' not found}} + +#error here // expected-error {{here}} -- cgit v1.2.3