diff options
| author | Richard Smith <richard-llvm@metafoo.co.uk> | 2014-12-06 01:13:41 +0000 | 
|---|---|---|
| committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2014-12-06 01:13:41 +0000 | 
| commit | 4a89a06d0d90b101e8866ecc4a5d239f32f9a243 (patch) | |
| tree | 6be5871acc23b2eff1a861acf23923a199bb2a05 | |
| parent | ceeb74e606f4c4ad22dd4d471a4b2b901987eff0 (diff) | |
| download | bcm5719-llvm-4a89a06d0d90b101e8866ecc4a5d239f32f9a243.tar.gz bcm5719-llvm-4a89a06d0d90b101e8866ecc4a5d239f32f9a243.zip  | |
PR21217: Slightly more eagerly load -fmodule-map-file= files and provide
diagnostics if they don't exist. Based on a patch by John Thompson!
llvm-svn: 223561
| -rw-r--r-- | clang/include/clang/Frontend/FrontendOptions.h | 3 | ||||
| -rw-r--r-- | clang/include/clang/Lex/HeaderSearchOptions.h | 3 | ||||
| -rw-r--r-- | clang/lib/Frontend/CompilerInstance.cpp | 8 | ||||
| -rw-r--r-- | clang/lib/Frontend/CompilerInvocation.cpp | 4 | ||||
| -rw-r--r-- | clang/lib/Lex/HeaderSearch.cpp | 12 | 
5 files changed, 12 insertions, 18 deletions
diff --git a/clang/include/clang/Frontend/FrontendOptions.h b/clang/include/clang/Frontend/FrontendOptions.h index 4e93b4ee108..71c5aa47af9 100644 --- a/clang/include/clang/Frontend/FrontendOptions.h +++ b/clang/include/clang/Frontend/FrontendOptions.h @@ -233,6 +233,9 @@ public:    /// The list of plugins to load.    std::vector<std::string> Plugins; +  /// \brief The list of module map files to load before processing the input. +  std::vector<std::string> ModuleMapFiles; +    /// \brief The list of additional prebuilt module files to load before    /// processing the input.    std::vector<std::string> ModuleFiles; diff --git a/clang/include/clang/Lex/HeaderSearchOptions.h b/clang/include/clang/Lex/HeaderSearchOptions.h index 06024b2e90f..4e6e46939f7 100644 --- a/clang/include/clang/Lex/HeaderSearchOptions.h +++ b/clang/include/clang/Lex/HeaderSearchOptions.h @@ -129,9 +129,6 @@ public:    /// of computing the module hash.    llvm::SetVector<std::string> ModulesIgnoreMacros; -  /// \brief The set of user-provided module-map-files. -  llvm::SetVector<std::string> ModuleMapFiles; -    /// \brief The set of user-provided virtual filesystem overlay files.    std::vector<std::string> VFSOverlayFiles; diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp index dcc824723aa..a5165ad6211 100644 --- a/clang/lib/Frontend/CompilerInstance.cpp +++ b/clang/lib/Frontend/CompilerInstance.cpp @@ -371,6 +371,14 @@ void CompilerInstance::createPreprocessor(TranslationUnitKind TUKind) {      AttachHeaderIncludeGen(*PP, /*ShowAllHeaders=*/false, /*OutputPath=*/"",                             /*ShowDepth=*/true, /*MSStyle=*/true);    } + +  // Load all explictly-specified module map files. +  for (const auto &Filename : getFrontendOpts().ModuleMapFiles) { +    if (auto *File = getFileManager().getFile(Filename)) +      PP->getHeaderSearchInfo().loadModuleMapFile(File, /*IsSystem*/false); +    else +      getDiagnostics().Report(diag::err_module_map_not_found) << Filename; +  }  }  // ASTContext diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 65ffd5475ca..f01663858e0 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -848,6 +848,7 @@ static InputKind ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args,    Opts.ASTDumpLookups = Args.hasArg(OPT_ast_dump_lookups);    Opts.UseGlobalModuleIndex = !Args.hasArg(OPT_fno_modules_global_index);    Opts.GenerateGlobalModuleIndex = Opts.UseGlobalModuleIndex; +  Opts.ModuleMapFiles = Args.getAllArgValues(OPT_fmodule_map_file);    Opts.ModuleFiles = Args.getAllArgValues(OPT_fmodule_file);    Opts.CodeCompleteOpts.IncludeMacros @@ -1019,9 +1020,6 @@ static void ParseHeaderSearchArgs(HeaderSearchOptions &Opts, ArgList &Args) {      StringRef MacroDef = (*it)->getValue();      Opts.ModulesIgnoreMacros.insert(MacroDef.split('=').first);    } -  std::vector<std::string> ModuleMapFiles = -      Args.getAllArgValues(OPT_fmodule_map_file); -  Opts.ModuleMapFiles.insert(ModuleMapFiles.begin(), ModuleMapFiles.end());    // Add -I..., -F..., and -index-header-map options in order.    bool IsIndexHeaderMap = false; diff --git a/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp index bbbcf3abec6..a3f3737521e 100644 --- a/clang/lib/Lex/HeaderSearch.cpp +++ b/clang/lib/Lex/HeaderSearch.cpp @@ -569,18 +569,6 @@ const FileEntry *HeaderSearch::LookupFile(      ArrayRef<std::pair<const FileEntry *, const DirectoryEntry *>> Includers,      SmallVectorImpl<char> *SearchPath, SmallVectorImpl<char> *RelativePath,      ModuleMap::KnownHeader *SuggestedModule, bool SkipCache) { -  if (!HSOpts->ModuleMapFiles.empty()) { -    // Preload all explicitly specified module map files. This enables modules -    // map files lying in a directory structure separate from the header files -    // that they describe. These cannot be loaded lazily upon encountering a -    // header file, as there is no other known mapping from a header file to its -    // module map file. -    for (const auto &Filename : HSOpts->ModuleMapFiles) -      if (const FileEntry *File = FileMgr.getFile(Filename)) -        loadModuleMapFile(File, /*IsSystem=*/false); -    HSOpts->ModuleMapFiles.clear(); -  } -    if (SuggestedModule)      *SuggestedModule = ModuleMap::KnownHeader();  | 

