Skip to content

Commit

Permalink
[C++20] [Modules] Skip Writing diagnostic options, header search path…
Browse files Browse the repository at this point in the history
…s and pragma diagnostic mappings

It simply wastes of space and time to write diagnostic options, header
search paths and pragma diagnostic mappings for C++20 Named modules.
This patch tries to avoid the unnecessary writings.
  • Loading branch information
ChuanqiXu9 committed Dec 7, 2023
1 parent b499466 commit b768b39
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions clang/include/clang/Frontend/FrontendActions.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@ class GenerateModuleInterfaceAction : public GenerateModuleAction {
private:
bool BeginSourceFileAction(CompilerInstance &CI) override;

std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,
StringRef InFile) override;

std::unique_ptr<raw_pwrite_stream>
CreateOutputFile(CompilerInstance &CI, StringRef InFile) override;
};
Expand Down
10 changes: 10 additions & 0 deletions clang/lib/Frontend/FrontendActions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,16 @@ bool GenerateModuleInterfaceAction::BeginSourceFileAction(
return GenerateModuleAction::BeginSourceFileAction(CI);
}

std::unique_ptr<ASTConsumer>
GenerateModuleInterfaceAction::CreateASTConsumer(CompilerInstance &CI,
StringRef InFile) {
CI.getHeaderSearchOpts().ModulesSkipDiagnosticOptions = true;
CI.getHeaderSearchOpts().ModulesSkipHeaderSearchPaths = true;
CI.getHeaderSearchOpts().ModulesSkipPragmaDiagnosticMappings = true;

return GenerateModuleAction::CreateASTConsumer(CI, InFile);
}

std::unique_ptr<raw_pwrite_stream>
GenerateModuleInterfaceAction::CreateOutputFile(CompilerInstance &CI,
StringRef InFile) {
Expand Down

0 comments on commit b768b39

Please sign in to comment.