Let ctor of DiagnosticInfoWithLocationBase take Function* instead of Function& ?


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.

We might just not want to emit a warning at all in this case. Unfortunately, just printing a warning which says, "There's UB somewhere in your program", is not very helpful. If we'd like to do this, then we need to think about how to feed enough information through the interfaces to make the reporting useful (functions and debug locations).