]> granicus.if.org Git - clang/commit
Add pragma to perform module import and use it in -E output.
authorRichard Smith <richard-llvm@metafoo.co.uk>
Sat, 29 Apr 2017 00:34:47 +0000 (00:34 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Sat, 29 Apr 2017 00:34:47 +0000 (00:34 +0000)
commitee60c74826a0ec615fcc7fef362686f4aae95c1a
tree571977cdcc552e6b3ccdd3f9ebbb3af053fa9644
parent538445b124c198013a391d78bb2865221ce88dce
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.)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@301725 91177308-0d34-0410-b5e6-96231b3b80d8
18 files changed:
include/clang/Basic/DiagnosticLexKinds.td
include/clang/Lex/Preprocessor.h
lib/Frontend/PrintPreprocessedOutput.cpp
lib/Frontend/Rewrite/InclusionRewriter.cpp
lib/Lex/PPDirectives.cpp
lib/Lex/Pragma.cpp
test/Frontend/rewrite-includes-modules.c
test/Modules/crash-vfs-path-emptydir-entries.m
test/Modules/crash-vfs-path-symlink-component.m
test/Modules/crash-vfs-path-symlink-topheader.m
test/Modules/crash-vfs-path-traversal.m
test/Modules/crash-vfs-relative-overlay.m
test/Modules/import-syntax.c [new file with mode: 0644]
test/Modules/preprocess-module.cpp
test/Modules/preprocess.cpp
test/Modules/preprocess.m
test/Preprocessor/pp-modules.c
test/Preprocessor/pragma_module.c [new file with mode: 0644]