Revert "Handle diagnostic warnings in Frontend diagnostic handler."

This commit is missing tests and there are a few points that need to be
addressed before a new user-facing option can be added:

  http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20140714/110198.html

This reverts commit r213112.

llvm-svn: 213260
This commit is contained in:
Alp Toker 2014-07-17 12:29:08 +00:00
parent 4d7e7a2082
commit 5c37d70e9e
3 changed files with 12 additions and 31 deletions

View File

@ -41,8 +41,6 @@ def remark_fe_backend_optimization_remark_missed : Remark<"%0">, BackendInfo,
InGroup<BackendOptimizationRemarkMissed>, DefaultRemark; InGroup<BackendOptimizationRemarkMissed>, DefaultRemark;
def remark_fe_backend_optimization_remark_analysis : Remark<"%0">, BackendInfo, def remark_fe_backend_optimization_remark_analysis : Remark<"%0">, BackendInfo,
InGroup<BackendOptimizationRemarkAnalysis>, DefaultRemark; InGroup<BackendOptimizationRemarkAnalysis>, DefaultRemark;
def warn_fe_backend_optimization_warning : Warning<"%0">, BackendInfo,
InGroup<BackendOptimizationWarnings>, DefaultWarn;
def note_fe_backend_optimization_remark_invalid_loc : Note<"could " def note_fe_backend_optimization_remark_invalid_loc : Note<"could "
"not determine the original source location for %0:%1:%2">; "not determine the original source location for %0:%1:%2">;

View File

@ -704,7 +704,6 @@ def RemarkBackendPlugin : DiagGroup<"remark-backend-plugin">;
def BackendOptimizationRemark : DiagGroup<"pass">; def BackendOptimizationRemark : DiagGroup<"pass">;
def BackendOptimizationRemarkMissed : DiagGroup<"pass-missed">; def BackendOptimizationRemarkMissed : DiagGroup<"pass-missed">;
def BackendOptimizationRemarkAnalysis : DiagGroup<"pass-analysis">; def BackendOptimizationRemarkAnalysis : DiagGroup<"pass-analysis">;
def BackendOptimizationWarnings : DiagGroup<"optimization-warning">;
// Instrumentation based profiling warnings. // Instrumentation based profiling warnings.
def ProfileInstrOutOfDate : DiagGroup<"profile-instr-out-of-date">; def ProfileInstrOutOfDate : DiagGroup<"profile-instr-out-of-date">;

View File

@ -238,16 +238,15 @@ namespace clang {
/// \brief Specialized handlers for optimization remarks. /// \brief Specialized handlers for optimization remarks.
/// Note that these handlers only accept remarks and they always handle /// Note that these handlers only accept remarks and they always handle
/// them. /// them.
void EmitOptimizationMessage(const llvm::DiagnosticInfoOptimizationBase &D, void
unsigned DiagID); EmitOptimizationRemark(const llvm::DiagnosticInfoOptimizationBase &D,
unsigned DiagID);
void void
OptimizationRemarkHandler(const llvm::DiagnosticInfoOptimizationRemark &D); OptimizationRemarkHandler(const llvm::DiagnosticInfoOptimizationRemark &D);
void OptimizationRemarkHandler( void OptimizationRemarkHandler(
const llvm::DiagnosticInfoOptimizationRemarkMissed &D); const llvm::DiagnosticInfoOptimizationRemarkMissed &D);
void OptimizationRemarkHandler( void OptimizationRemarkHandler(
const llvm::DiagnosticInfoOptimizationRemarkAnalysis &D); const llvm::DiagnosticInfoOptimizationRemarkAnalysis &D);
void OptimizationWarningHandler(
const llvm::DiagnosticInfoOptimizationWarning &D);
}; };
void BackendConsumer::anchor() {} void BackendConsumer::anchor() {}
@ -417,11 +416,10 @@ BackendConsumer::StackSizeDiagHandler(const llvm::DiagnosticInfoStackSize &D) {
return false; return false;
} }
void BackendConsumer::EmitOptimizationMessage( void BackendConsumer::EmitOptimizationRemark(
const llvm::DiagnosticInfoOptimizationBase &D, unsigned DiagID) { const llvm::DiagnosticInfoOptimizationBase &D, unsigned DiagID) {
// We only support warnings and remarks. // We only support remarks.
assert(D.getSeverity() == llvm::DS_Remark || assert(D.getSeverity() == llvm::DS_Remark);
D.getSeverity() == llvm::DS_Warning);
SourceManager &SourceMgr = Context->getSourceManager(); SourceManager &SourceMgr = Context->getSourceManager();
FileManager &FileMgr = SourceMgr.getFileManager(); FileManager &FileMgr = SourceMgr.getFileManager();
@ -444,12 +442,8 @@ void BackendConsumer::EmitOptimizationMessage(
if (const Decl *FD = Gen->GetDeclForMangledName(D.getFunction().getName())) if (const Decl *FD = Gen->GetDeclForMangledName(D.getFunction().getName()))
Loc = FD->getASTContext().getFullLoc(FD->getBodyRBrace()); Loc = FD->getASTContext().getFullLoc(FD->getBodyRBrace());
// Flag value not used by all optimization messages. Diags.Report(Loc, DiagID) << AddFlagValue(D.getPassName())
if (D.getPassName()) << D.getMsg().str();
Diags.Report(Loc, DiagID) << AddFlagValue(D.getPassName())
<< D.getMsg().str();
else
Diags.Report(Loc, DiagID) << D.getMsg().str();
if (DILoc.isInvalid()) if (DILoc.isInvalid())
// If we were not able to translate the file:line:col information // If we were not able to translate the file:line:col information
@ -466,7 +460,7 @@ void BackendConsumer::OptimizationRemarkHandler(
// expression that matches the name of the pass name in \p D. // expression that matches the name of the pass name in \p D.
if (CodeGenOpts.OptimizationRemarkPattern && if (CodeGenOpts.OptimizationRemarkPattern &&
CodeGenOpts.OptimizationRemarkPattern->match(D.getPassName())) CodeGenOpts.OptimizationRemarkPattern->match(D.getPassName()))
EmitOptimizationMessage(D, diag::remark_fe_backend_optimization_remark); EmitOptimizationRemark(D, diag::remark_fe_backend_optimization_remark);
} }
void BackendConsumer::OptimizationRemarkHandler( void BackendConsumer::OptimizationRemarkHandler(
@ -476,8 +470,8 @@ void BackendConsumer::OptimizationRemarkHandler(
// name in \p D. // name in \p D.
if (CodeGenOpts.OptimizationRemarkMissedPattern && if (CodeGenOpts.OptimizationRemarkMissedPattern &&
CodeGenOpts.OptimizationRemarkMissedPattern->match(D.getPassName())) CodeGenOpts.OptimizationRemarkMissedPattern->match(D.getPassName()))
EmitOptimizationMessage(D, EmitOptimizationRemark(D,
diag::remark_fe_backend_optimization_remark_missed); diag::remark_fe_backend_optimization_remark_missed);
} }
void BackendConsumer::OptimizationRemarkHandler( void BackendConsumer::OptimizationRemarkHandler(
@ -487,15 +481,10 @@ void BackendConsumer::OptimizationRemarkHandler(
// name in \p D. // name in \p D.
if (CodeGenOpts.OptimizationRemarkAnalysisPattern && if (CodeGenOpts.OptimizationRemarkAnalysisPattern &&
CodeGenOpts.OptimizationRemarkAnalysisPattern->match(D.getPassName())) CodeGenOpts.OptimizationRemarkAnalysisPattern->match(D.getPassName()))
EmitOptimizationMessage( EmitOptimizationRemark(
D, diag::remark_fe_backend_optimization_remark_analysis); D, diag::remark_fe_backend_optimization_remark_analysis);
} }
void BackendConsumer::OptimizationWarningHandler(
const llvm::DiagnosticInfoOptimizationWarning &D) {
EmitOptimizationMessage(D, diag::warn_fe_backend_optimization_warning);
}
/// \brief This function is invoked when the backend needs /// \brief This function is invoked when the backend needs
/// to report something to the user. /// to report something to the user.
void BackendConsumer::DiagnosticHandlerImpl(const DiagnosticInfo &DI) { void BackendConsumer::DiagnosticHandlerImpl(const DiagnosticInfo &DI) {
@ -529,11 +518,6 @@ void BackendConsumer::DiagnosticHandlerImpl(const DiagnosticInfo &DI) {
OptimizationRemarkHandler( OptimizationRemarkHandler(
cast<DiagnosticInfoOptimizationRemarkAnalysis>(DI)); cast<DiagnosticInfoOptimizationRemarkAnalysis>(DI));
return; return;
case llvm::DK_OptimizationWarning:
// Optimization warnings are always handled completely by this
// handler.
OptimizationWarningHandler(cast<DiagnosticInfoOptimizationWarning>(DI));
return;
default: default:
// Plugin IDs are not bound to any value as they are set dynamically. // Plugin IDs are not bound to any value as they are set dynamically.
ComputeDiagRemarkID(Severity, backend_plugin, DiagID); ComputeDiagRemarkID(Severity, backend_plugin, DiagID);