[Remarks] Extend -fsave-optimization-record to specify the format

Use -fsave-optimization-record=<format> to specify a different format
than the default, which is YAML.

For now, only YAML is supported.

llvm-svn: 363573
diff --git a/clang/lib/CodeGen/CodeGenAction.cpp b/clang/lib/CodeGen/CodeGenAction.cpp
index e8022c0..0ae9ea4 100644
--- a/clang/lib/CodeGen/CodeGenAction.cpp
+++ b/clang/lib/CodeGen/CodeGenAction.cpp
@@ -266,6 +266,7 @@
       Expected<std::unique_ptr<llvm::ToolOutputFile>> OptRecordFileOrErr =
           setupOptimizationRemarks(Ctx, CodeGenOpts.OptRecordFile,
                                    CodeGenOpts.OptRecordPasses,
+                                   CodeGenOpts.OptRecordFormat,
                                    CodeGenOpts.DiagnosticsWithHotness,
                                    CodeGenOpts.DiagnosticsHotnessThreshold);
 
@@ -279,6 +280,10 @@
             [&](const RemarkSetupPatternError &E) {
               Diags.Report(diag::err_drv_optimization_remark_pattern)
                   << E.message() << CodeGenOpts.OptRecordPasses;
+            },
+            [&](const RemarkSetupFormatError &E) {
+              Diags.Report(diag::err_drv_optimization_remark_format)
+                  << CodeGenOpts.OptRecordFormat;
             });
         return;
       }