aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/clang/Driver/CC1Options.td5
-rw-r--r--include/clang/Driver/Options.td3
-rw-r--r--include/clang/Frontend/PreprocessorOptions.h5
-rw-r--r--include/clang/Lex/DirectoryLookup.h14
-rw-r--r--include/clang/Lex/HeaderSearch.h18
-rw-r--r--include/clang/Lex/Preprocessor.h11
6 files changed, 47 insertions, 9 deletions
diff --git a/include/clang/Driver/CC1Options.td b/include/clang/Driver/CC1Options.td
index 0609e75a25..356a76e1e7 100644
--- a/include/clang/Driver/CC1Options.td
+++ b/include/clang/Driver/CC1Options.td
@@ -607,7 +607,10 @@ def fmodule_cache_path : Separate<"-fmodule-cache-path">,
HelpText<"Specify the module cache path">;
def fdisable_module_hash : Flag<"-fdisable-module-hash">,
HelpText<"Disable the module hash">;
-
+def fauto_module_import : Flag<"-fauto-module-import">,
+ HelpText<"Automatically translate #include/#import into module imports "
+ "when possible">;
+
def F : JoinedOrSeparate<"-F">, MetaVarName<"<directory>">,
HelpText<"Add directory to framework include search path">;
def I : JoinedOrSeparate<"-I">, MetaVarName<"<directory>">,
diff --git a/include/clang/Driver/Options.td b/include/clang/Driver/Options.td
index 55bf2e9db3..d9f34f55ac 100644
--- a/include/clang/Driver/Options.td
+++ b/include/clang/Driver/Options.td
@@ -344,6 +344,9 @@ def fmsc_version : Joined<"-fmsc-version=">, Group<f_Group>;
def fdelayed_template_parsing : Flag<"-fdelayed-template-parsing">, Group<f_Group>;
def fmodule_cache_path : Separate<"-fmodule-cache-path">, Group<i_Group>,
Flags<[NoForward]>;
+def fauto_module_import : Flag <"-fauto-module-import">, Group<f_Group>,
+ Flags<[NoForward]>;
+
def fmudflapth : Flag<"-fmudflapth">, Group<f_Group>;
def fmudflap : Flag<"-fmudflap">, Group<f_Group>;
def fnested_functions : Flag<"-fnested-functions">, Group<f_Group>;
diff --git a/include/clang/Frontend/PreprocessorOptions.h b/include/clang/Frontend/PreprocessorOptions.h
index 0259cfd260..30a34060b2 100644
--- a/include/clang/Frontend/PreprocessorOptions.h
+++ b/include/clang/Frontend/PreprocessorOptions.h
@@ -50,6 +50,10 @@ public:
/// record of all macro definitions and
/// expansions.
+ /// \brief Whether we should automatically translate #include or #import
+ /// operations into module imports when possible.
+ unsigned AutoModuleImport : 1;
+
/// \brief Whether the detailed preprocessing record includes nested macro
/// expansions.
unsigned DetailedRecordIncludesNestedMacroExpansions : 1;
@@ -162,6 +166,7 @@ public:
public:
PreprocessorOptions() : UsePredefines(true), DetailedRecord(false),
+ AutoModuleImport(false),
DetailedRecordIncludesNestedMacroExpansions(true),
DisablePCHValidation(false), DisableStatCache(false),
DumpDeserializedPCHDecls(false),
diff --git a/include/clang/Lex/DirectoryLookup.h b/include/clang/Lex/DirectoryLookup.h
index ae5eabc690..f7da61b0ed 100644
--- a/include/clang/Lex/DirectoryLookup.h
+++ b/include/clang/Lex/DirectoryLookup.h
@@ -140,15 +140,25 @@ public:
/// \param RelativePath If not NULL, will be set to the path relative to
/// SearchPath at which the file was found. This only differs from the
/// Filename for framework includes.
+ ///
+ /// \param BuildingModule The name of the module we're currently building.
+ ///
+ /// \param SuggestedModule If non-null, and the file found is semantically
+ /// part of a known module, this will be set to the name of the module that
+ /// could be imported instead of preprocessing/parsing the file found.
const FileEntry *LookupFile(StringRef Filename, HeaderSearch &HS,
SmallVectorImpl<char> *SearchPath,
- SmallVectorImpl<char> *RelativePath) const;
+ SmallVectorImpl<char> *RelativePath,
+ StringRef BuildingModule,
+ StringRef *SuggestedModule) const;
private:
const FileEntry *DoFrameworkLookup(
StringRef Filename, HeaderSearch &HS,
SmallVectorImpl<char> *SearchPath,
- SmallVectorImpl<char> *RelativePath) const;
+ SmallVectorImpl<char> *RelativePath,
+ StringRef BuildingModule,
+ StringRef *SuggestedModule) const;
};
diff --git a/include/clang/Lex/HeaderSearch.h b/include/clang/Lex/HeaderSearch.h
index 86aa7c974a..84d59f793b 100644
--- a/include/clang/Lex/HeaderSearch.h
+++ b/include/clang/Lex/HeaderSearch.h
@@ -132,6 +132,9 @@ class HeaderSearch {
/// \brief The path to the module cache.
std::string ModuleCachePath;
+ /// \brief The name of the module we're building.
+ std::string BuildingModule;
+
/// FileInfo - This contains all of the preprocessor-specific data about files
/// that are included. The vector is indexed by the FileEntry's UID.
///
@@ -196,9 +199,11 @@ public:
//LookupFileCache.clear();
}
- /// \brief Set the path to the module cache.
- void setModuleCachePath(StringRef Path) {
- ModuleCachePath = Path;
+ /// \brief Set the path to the module cache and the name of the module
+ /// we're building
+ void configureModules(StringRef CachePath, StringRef BuildingModule) {
+ ModuleCachePath = CachePath;
+ this->BuildingModule = BuildingModule;
}
/// ClearFileInfo - Forget everything we know about headers so far.
@@ -240,12 +245,17 @@ public:
/// \param RelativePath If non-null, will be set to the path relative to
/// SearchPath at which the file was found. This only differs from the
/// Filename for framework includes.
+ ///
+ /// \param SuggestedModule If non-null, and the file found is semantically
+ /// part of a known module, this will be set to the name of the module that
+ /// could be imported instead of preprocessing/parsing the file found.
const FileEntry *LookupFile(StringRef Filename, bool isAngled,
const DirectoryLookup *FromDir,
const DirectoryLookup *&CurDir,
const FileEntry *CurFileEnt,
SmallVectorImpl<char> *SearchPath,
- SmallVectorImpl<char> *RelativePath);
+ SmallVectorImpl<char> *RelativePath,
+ StringRef *SuggestedModule);
/// LookupSubframeworkHeader - Look up a subframework for the specified
/// #include file. For example, if #include'ing <HIToolbox/HIToolbox.h> from
diff --git a/include/clang/Lex/Preprocessor.h b/include/clang/Lex/Preprocessor.h
index c404149f18..fc0e98b8b8 100644
--- a/include/clang/Lex/Preprocessor.h
+++ b/include/clang/Lex/Preprocessor.h
@@ -106,7 +106,8 @@ class Preprocessor : public llvm::RefCountedBase<Preprocessor> {
bool KeepComments : 1;
bool KeepMacroComments : 1;
bool SuppressIncludeNotFoundError : 1;
-
+ bool AutoModuleImport : 1;
+
// State that changes while the preprocessor runs:
bool InMacroArgs : 1; // True if parsing fn macro invocation args.
@@ -383,6 +384,11 @@ public:
return SuppressIncludeNotFoundError;
}
+ /// \brief Specify whether automatic module imports are enabled.
+ void setAutoModuleImport(bool AutoModuleImport = true) {
+ this->AutoModuleImport = AutoModuleImport;
+ }
+
/// isCurrentLexer - Return true if we are lexing directly from the specified
/// lexer.
bool isCurrentLexer(const PreprocessorLexer *L) const {
@@ -973,7 +979,8 @@ public:
bool isAngled, const DirectoryLookup *FromDir,
const DirectoryLookup *&CurDir,
SmallVectorImpl<char> *SearchPath,
- SmallVectorImpl<char> *RelativePath);
+ SmallVectorImpl<char> *RelativePath,
+ StringRef *SuggestedModule);
/// GetCurLookup - The DirectoryLookup structure used to find the current
/// FileEntry, if CurLexer is non-null and if applicable. This allows us to