diff options
Diffstat (limited to 'gnu/llvm/tools/clang/lib/Frontend/FrontendAction.cpp')
| -rw-r--r-- | gnu/llvm/tools/clang/lib/Frontend/FrontendAction.cpp | 47 |
1 files changed, 30 insertions, 17 deletions
diff --git a/gnu/llvm/tools/clang/lib/Frontend/FrontendAction.cpp b/gnu/llvm/tools/clang/lib/Frontend/FrontendAction.cpp index 12226b23141..74550c41039 100644 --- a/gnu/llvm/tools/clang/lib/Frontend/FrontendAction.cpp +++ b/gnu/llvm/tools/clang/lib/Frontend/FrontendAction.cpp @@ -79,7 +79,7 @@ public: } }; -/// \brief Dumps deserialized declarations. +/// Dumps deserialized declarations. class DeserializedDeclsDumper : public DelegatingDeserializationListener { public: explicit DeserializedDeclsDumper(ASTDeserializationListener *Previous, @@ -88,15 +88,17 @@ public: void DeclRead(serialization::DeclID ID, const Decl *D) override { llvm::outs() << "PCH DECL: " << D->getDeclKindName(); - if (const NamedDecl *ND = dyn_cast<NamedDecl>(D)) - llvm::outs() << " - " << *ND; + if (const NamedDecl *ND = dyn_cast<NamedDecl>(D)) { + llvm::outs() << " - "; + ND->printQualifiedName(llvm::outs()); + } llvm::outs() << "\n"; DelegatingDeserializationListener::DeclRead(ID, D); } }; -/// \brief Checks deserialized declarations and emits error if a name +/// Checks deserialized declarations and emits error if a name /// matches one given in command-line using -error-on-deserialized-decl. class DeserializedDeclsChecker : public DelegatingDeserializationListener { ASTContext &Ctx; @@ -153,6 +155,10 @@ FrontendAction::CreateWrappedASTConsumer(CompilerInstance &CI, if (FrontendPluginRegistry::begin() == FrontendPluginRegistry::end()) return Consumer; + // If this is a code completion run, avoid invoking the plugin consumers + if (CI.hasCodeCompletionConsumer()) + return Consumer; + // Collect the list of plugins that go before the main action (in Consumers) // or after it (in AfterConsumers) std::vector<std::unique_ptr<ASTConsumer>> Consumers; @@ -282,7 +288,7 @@ static void addHeaderInclude(StringRef HeaderName, Includes += "}\n"; } -/// \brief Collect the set of header includes needed to construct the given +/// Collect the set of header includes needed to construct the given /// module and update the TopHeaders file set of the module. /// /// \param Module The module we're collecting includes from. @@ -339,7 +345,7 @@ static std::error_code collectModuleHeaderIncludes( vfs::FileSystem &FS = *FileMgr.getVirtualFileSystem(); for (vfs::recursive_directory_iterator Dir(FS, DirNative, EC), End; Dir != End && !EC; Dir.increment(EC)) { - // Check whether this entry has an extension typically associated with + // Check whether this entry has an extension typically associated with // headers. if (!llvm::StringSwitch<bool>(llvm::sys::path::extension(Dir->getName())) .Cases(".h", ".H", ".hh", ".hpp", true) @@ -352,7 +358,7 @@ static std::error_code collectModuleHeaderIncludes( if (!Header) continue; - // If this header is marked 'unavailable' in this module, don't include + // If this header is marked 'unavailable' in this module, don't include // it. if (ModMap.isHeaderUnavailableInModule(Header, Module)) continue; @@ -425,7 +431,7 @@ static Module *prepareToBuildModule(CompilerInstance &CI, CI.getDiagnostics().Report(diag::err_missing_module_name); // FIXME: Eventually, we could consider asking whether there was just - // a single module described in the module map, and use that as a + // a single module described in the module map, and use that as a // default. Then it would be fairly trivial to just "compile" a module // map with a single module (the common case). return nullptr; @@ -760,6 +766,22 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI, if (!BeginSourceFileAction(CI)) goto failure; + // If we were asked to load any module map files, do so now. + for (const auto &Filename : CI.getFrontendOpts().ModuleMapFiles) { + if (auto *File = CI.getFileManager().getFile(Filename)) + CI.getPreprocessor().getHeaderSearchInfo().loadModuleMapFile( + File, /*IsSystem*/false); + else + CI.getDiagnostics().Report(diag::err_module_map_not_found) << Filename; + } + + // Add a module declaration scope so that modules from -fmodule-map-file + // arguments may shadow modules found implicitly in search paths. + CI.getPreprocessor() + .getHeaderSearchInfo() + .getModuleMap() + .finishModuleDeclarationScope(); + // Create the AST context and consumer unless this is a preprocessor only // action. if (!usesPreprocessorOnly()) { @@ -849,15 +871,6 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI, "doesn't support modules"); } - // If we were asked to load any module map files, do so now. - for (const auto &Filename : CI.getFrontendOpts().ModuleMapFiles) { - if (auto *File = CI.getFileManager().getFile(Filename)) - CI.getPreprocessor().getHeaderSearchInfo().loadModuleMapFile( - File, /*IsSystem*/false); - else - CI.getDiagnostics().Report(diag::err_module_map_not_found) << Filename; - } - // If we were asked to load any module files, do so now. for (const auto &ModuleFile : CI.getFrontendOpts().ModuleFiles) if (!CI.loadModuleFile(ModuleFile)) |
