Currently the constructor of class DiagnosticInfoWithLocationBase takes a Function reference:
/// \p Fn is the function where the diagnostic is being emitted. \p Loc is
/// the location information to use in the diagnostic.
DiagnosticInfoWithLocationBase(enum DiagnosticKind Kind,
enum DiagnosticSeverity Severity,
const Function &Fn,
const DiagnosticLocation &Loc)
However, if we want to emit diagnostics via calls like emitUndefinedBehaviorOptimizedWarning, the Function object may be unavailable. For example, in the interim of inlining, under the context of Analysis/InstructionSimplify, the Instruction in the context has no parent BB.
So how about let the constructor takes a Function ptr? All the use of Function object is to print out function name. Using pointer, we can let if print somthing like "<optimized out function>" if it is null.