aboutsummaryrefslogtreecommitdiff
path: root/include/clang/Lex
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-09-15 22:00:41 +0000
committerDouglas Gregor <dgregor@apple.com>2011-09-15 22:00:41 +0000
commitfba18aa8f2cd1994dc65e8cb9f4be201c560dc0b (patch)
tree7d8906cda58e7645cc60254e4ed7bc34f28247f3 /include/clang/Lex
parentdd22509c82eb7681a0f46b41d61cb2e25a4d8fa1 (diff)
Add an experimental flag -fauto-module-import that automatically turns
#include or #import direcctives of framework headers into module imports of the corresponding framework module. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139860 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Lex')
-rw-r--r--include/clang/Lex/DirectoryLookup.h14
-rw-r--r--include/clang/Lex/HeaderSearch.h18
-rw-r--r--include/clang/Lex/Preprocessor.h11
3 files changed, 35 insertions, 8 deletions
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