[PATCH] D37196: [Clang] Bug 32352 - Provide a way for OptimizationRemarkEmitter::allowExtraAnalysis to check if (specific) remarks are enabled
Vivek Pandya via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 5 10:09:32 PDT 2017
vivekvpandya updated this revision to Diff 113879.
vivekvpandya added a comment.
Clang-formated
https://reviews.llvm.org/D37196
Files:
lib/CodeGen/CodeGenAction.cpp
Index: lib/CodeGen/CodeGenAction.cpp
===================================================================
--- lib/CodeGen/CodeGenAction.cpp
+++ lib/CodeGen/CodeGenAction.cpp
@@ -224,10 +224,10 @@
void *OldContext = Ctx.getInlineAsmDiagnosticContext();
Ctx.setInlineAsmDiagnosticHandler(InlineAsmDiagHandler, this);
- LLVMContext::DiagnosticHandlerTy OldDiagnosticHandler =
- Ctx.getDiagnosticHandler();
- void *OldDiagnosticContext = Ctx.getDiagnosticContext();
- Ctx.setDiagnosticHandler(DiagnosticHandler, this);
+ //LLVMContext::DiagnosticHandlerTy OldDiagnosticHandler =
+ // Ctx.getDiagnosticHandler();
+ // void *OldDiagnosticContext = Ctx.getDiagnosticContext();
+ // Ctx.setDiagnosticHandler(DiagnosticHandler, this);
Ctx.setDiagnosticsHotnessRequested(CodeGenOpts.DiagnosticsWithHotness);
if (CodeGenOpts.DiagnosticsHotnessThreshold != 0)
Ctx.setDiagnosticsHotnessThreshold(
@@ -264,7 +264,7 @@
Ctx.setInlineAsmDiagnosticHandler(OldHandler, OldContext);
- Ctx.setDiagnosticHandler(OldDiagnosticHandler, OldDiagnosticContext);
+ //Ctx.setDiagnosticHandler(OldDiagnosticHandler, OldDiagnosticContext);
if (OptRecordFile)
OptRecordFile->keep();
@@ -756,6 +756,32 @@
}
#undef ComputeDiagID
+class ClangDiagnosticHandler final : public DiagnosticHandler {
+public:
+ ClangDiagnosticHandler(const CodeGenOptions &CGOpts, void *DiagContext)
+ : DiagnosticHandler(DiagContext), CodeGenOpts(CGOpts) {}
+
+ bool handleDiagnostics(const DiagnosticInfo &DI) override {
+ ((BackendConsumer *)DiagnosticContext)->DiagnosticHandlerImpl(DI);
+ return true;
+ }
+ bool isAnalysisRemarkEnable(const std::string &PassName) {
+ return (CodeGenOpts.OptimizationRemarkAnalysisPattern &&
+ CodeGenOpts.OptimizationRemarkAnalysisPattern->match(PassName));
+ }
+ bool isMissedOptRemarkEnable(const std::string &PassName) {
+ return (CodeGenOpts.OptimizationRemarkMissedPattern &&
+ CodeGenOpts.OptimizationRemarkMissedPattern->match(PassName));
+ }
+ bool isPassedOptRemarkEnable(const std::string &PassName) {
+ return (CodeGenOpts.OptimizationRemarkPattern &&
+ CodeGenOpts.OptimizationRemarkPattern->match(PassName));
+ }
+
+private:
+ const CodeGenOptions &CodeGenOpts;
+};
+
CodeGenAction::CodeGenAction(unsigned _Act, LLVMContext *_VMContext)
: Act(_Act), VMContext(_VMContext ? _VMContext : new LLVMContext),
OwnsVMContext(!_VMContext) {}
@@ -853,7 +879,8 @@
CI.getLangOpts(), CI.getFrontendOpts().ShowTimers, InFile,
std::move(LinkModules), std::move(OS), *VMContext, CoverageInfo));
BEConsumer = Result.get();
-
+ VMContext->setDiagnosticHandler(llvm::make_unique<ClangDiagnosticHandler>(
+ CI.getCodeGenOpts(), Result.get()));
// Enable generating macro debug info only when debug info is not disabled and
// also macro debug info is enabled.
if (CI.getCodeGenOpts().getDebugInfo() != codegenoptions::NoDebugInfo &&
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D37196.113879.patch
Type: text/x-patch
Size: 3044 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170905/40cffd77/attachment-0001.bin>
More information about the cfe-commits
mailing list