diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2018-07-28 11:06:01 +0000 | 
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2018-07-28 11:06:01 +0000 | 
| commit | 486754660bb926339aefcf012a3f848592babb8b (patch) | |
| tree | ecdbc446c9876f4f120f701c243373cd3cb43db3 /lib/Frontend/FrontendAction.cpp | |
| parent | 55e6d896ad333f07bb3b1ba487df214fc268a4ab (diff) | |
Notes
Diffstat (limited to 'lib/Frontend/FrontendAction.cpp')
| -rw-r--r-- | lib/Frontend/FrontendAction.cpp | 41 | 
1 files changed, 27 insertions, 14 deletions
diff --git a/lib/Frontend/FrontendAction.cpp b/lib/Frontend/FrontendAction.cpp index 12226b231417..a5929424e52a 100644 --- a/lib/Frontend/FrontendAction.cpp +++ b/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. @@ -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))  | 
