void LLVMContext::diagnose(const DiagnosticInfo &DI) {
// If there is a report handler, use it.
- if (pImpl->DiagnosticHandler != 0) {
+ if (pImpl->DiagnosticHandler) {
pImpl->DiagnosticHandler(DI, pImpl->DiagnosticContext);
return;
}
+
+ // Optimization remarks are selective. They need to check whether
+ // the regexp pattern, passed via -pass-remarks, matches the name
+ // of the pass that is emitting the diagnostic. If there is no match,
+ // ignore the diagnostic and return.
+ if (DI.getKind() == llvm::DK_OptimizationRemark &&
+ !pImpl->optimizationRemarksEnabledFor(
+ cast<DiagnosticInfoOptimizationRemark>(DI).getPassName()))
+ return;
+
// Otherwise, print the message with a prefix based on the severity.
std::string MsgStorage;
raw_string_ostream Stream(MsgStorage);
E = pImpl->CustomMDKindNames.end(); I != E; ++I)
Names[I->second] = I->first();
}
+
+//===----------------------------------------------------------------------===//
+// Pass Run Listeners
+//===----------------------------------------------------------------------===//
+/// Notify that we finished running a pass.
+void LLVMContext::notifyPassRun(Pass *P, Module *M, Function *F, BasicBlock *BB)
+{
+ pImpl->notifyPassRun(this, P, M, F, BB);
+}
+/// Register the given PassRunListener to receive notifyPassRun() callbacks
+/// whenever a pass ran. The context will take ownership of the listener and
+/// free it when the context is destroyed.
+void LLVMContext::addRunListener(PassRunListener *L) {
+ pImpl->addRunListener(L);
+}
+/// Unregister a PassRunListener so that it no longer receives notifyPassRun()
+/// callbacks. Remove and free the listener from the context.
+void LLVMContext::removeRunListener(PassRunListener *L) {
+ pImpl->removeRunListener(L);
+}