aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenAction.cpp
diff options
context:
space:
mode:
authorBob Haarman <llvm@inglorion.net>2021-08-21 00:14:32 +0000
committerBob Haarman <llvm@inglorion.net>2021-08-24 21:25:49 +0000
commit1c829ce1e3627cf9b22da33943dc2e423ded11c4 (patch)
tree4aeb596a6e88f6500438f1feddec081f2f1c6c7e /clang/lib/CodeGen/CodeGenAction.cpp
parentec8d87e9f56203df851e2d20750224d4a04803be (diff)
downloadllvm-1c829ce1e3627cf9b22da33943dc2e423ded11c4.zip
llvm-1c829ce1e3627cf9b22da33943dc2e423ded11c4.tar.gz
llvm-1c829ce1e3627cf9b22da33943dc2e423ded11c4.tar.bz2
[clang][codegen] Set CurLinkModule in CodeGenAction::ExecuteAction
CodeGenAction::ExecuteAction creates a BackendConsumer for the purpose of handling diagnostics. The BackendConsumer's DiagnosticHandlerImpl method expects CurLinkModule to be set, but this did not happen on the code path that goes through ExecuteAction. This change makes it so that the BackendConsumer constructor used by ExecuteAction requires the Module to be specified and passes the appropriate module in ExecuteAction. The change also adds a test that fails without this change and passes with it. To make the test work, the FIXME in the handling of DK_Linker diagnostics was addressed so that warnings and notes are no longer silently discarded. Since this introduces a new warning diagnostic, a flag to control it (-Wlinker-warnings) has also been added. Reviewed By: xur Differential Revision: https://reviews.llvm.org/D108603
Diffstat (limited to 'clang/lib/CodeGen/CodeGenAction.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenAction.cpp18
1 files changed, 7 insertions, 11 deletions
diff --git a/clang/lib/CodeGen/CodeGenAction.cpp b/clang/lib/CodeGen/CodeGenAction.cpp
index b30bd11..e66e41d 100644
--- a/clang/lib/CodeGen/CodeGenAction.cpp
+++ b/clang/lib/CodeGen/CodeGenAction.cpp
@@ -160,7 +160,7 @@ namespace clang {
const PreprocessorOptions &PPOpts,
const CodeGenOptions &CodeGenOpts,
const TargetOptions &TargetOpts,
- const LangOptions &LangOpts,
+ const LangOptions &LangOpts, llvm::Module *Module,
SmallVector<LinkModule, 4> LinkModules, LLVMContext &C,
CoverageSourceInfo *CoverageInfo = nullptr)
: Diags(Diags), Action(Action), HeaderSearchOpts(HeaderSearchOpts),
@@ -170,7 +170,7 @@ namespace clang {
LLVMIRGenerationRefCount(0),
Gen(CreateLLVMCodeGen(Diags, "", HeaderSearchOpts, PPOpts,
CodeGenOpts, C, CoverageInfo)),
- LinkModules(std::move(LinkModules)) {
+ LinkModules(std::move(LinkModules)), CurLinkModule(Module) {
TimerIsEnabled = CodeGenOpts.TimePasses;
llvm::TimePassesIsEnabled = CodeGenOpts.TimePasses;
llvm::TimePassesPerRun = CodeGenOpts.TimePassesPerRun;
@@ -779,11 +779,7 @@ void BackendConsumer::DiagnosticHandlerImpl(const DiagnosticInfo &DI) {
ComputeDiagID(Severity, backend_frame_larger_than, DiagID);
break;
case DK_Linker:
- assert(CurLinkModule);
- // FIXME: stop eating the warnings and notes.
- if (Severity != DS_Error)
- return;
- DiagID = diag::err_fe_cannot_link_module;
+ ComputeDiagID(Severity, linking_module, DiagID);
break;
case llvm::DK_OptimizationRemark:
// Optimization remarks are always handled completely by this
@@ -845,9 +841,9 @@ void BackendConsumer::DiagnosticHandlerImpl(const DiagnosticInfo &DI) {
DI.print(DP);
}
- if (DiagID == diag::err_fe_cannot_link_module) {
- Diags.Report(diag::err_fe_cannot_link_module)
- << CurLinkModule->getModuleIdentifier() << MsgStorage;
+ if (DI.getKind() == DK_Linker) {
+ assert(CurLinkModule && "CurLinkModule must be set for linker diagnostics");
+ Diags.Report(DiagID) << CurLinkModule->getModuleIdentifier() << MsgStorage;
return;
}
@@ -1088,7 +1084,7 @@ void CodeGenAction::ExecuteAction() {
// BackendConsumer.
BackendConsumer Result(BA, CI.getDiagnostics(), CI.getHeaderSearchOpts(),
CI.getPreprocessorOpts(), CI.getCodeGenOpts(),
- CI.getTargetOpts(), CI.getLangOpts(),
+ CI.getTargetOpts(), CI.getLangOpts(), TheModule.get(),
std::move(LinkModules), *VMContext, nullptr);
// PR44896: Force DiscardValueNames as false. DiscardValueNames cannot be
// true here because the valued names are needed for reading textual IR.