Enhance MLIRContext and operations with the ability to register diagnostic
handlers and to feed them with errors and warnings produced by the compiler.
Enhance Operation to be able to get its own MLIRContext on demand, simplifying
some clients.  Change the verifier to emit certain errors with the diagnostic
handler.

This is steps towards reworking the verifier and diagnostic propagation but is
itself not particularly useful.  More to come.

PiperOrigin-RevId: 206948643
diff --git a/lib/IR/Instructions.cpp b/lib/IR/Instructions.cpp
index c3f0b1e..0076d01 100644
--- a/lib/IR/Instructions.cpp
+++ b/lib/IR/Instructions.cpp
@@ -16,7 +16,7 @@
 // =============================================================================
 
 #include "mlir/IR/Instructions.h"
-#include "mlir/IR/BasicBlock.h"
+#include "mlir/IR/CFGFunction.h"
 using namespace mlir;
 
 /// Replace all uses of 'this' value with the new value, updating anything in
@@ -69,6 +69,11 @@
   free(this);
 }
 
+/// Return the context this operation is associated with.
+MLIRContext *Instruction::getContext() const {
+  return getFunction()->getContext();
+}
+
 CFGFunction *Instruction::getFunction() const {
   return getBlock()->getFunction();
 }