diff options
Diffstat (limited to 'llvm/tools/llvm-opt-report/OptReport.cpp')
-rw-r--r-- | llvm/tools/llvm-opt-report/OptReport.cpp | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/llvm/tools/llvm-opt-report/OptReport.cpp b/llvm/tools/llvm-opt-report/OptReport.cpp index 5662c9fbd7b..297b798dc9d 100644 --- a/llvm/tools/llvm-opt-report/OptReport.cpp +++ b/llvm/tools/llvm-opt-report/OptReport.cpp @@ -15,6 +15,7 @@ #include "llvm-c/Remarks.h" #include "llvm/Demangle/Demangle.h" +#include "llvm/Remarks/RemarkFormat.h" #include "llvm/Remarks/RemarkParser.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/Error.h" @@ -27,14 +28,12 @@ #include "llvm/Support/Path.h" #include "llvm/Support/Program.h" #include "llvm/Support/WithColor.h" -#include "llvm/Support/YAMLTraits.h" #include "llvm/Support/raw_ostream.h" #include <cstdlib> #include <map> #include <set> using namespace llvm; -using namespace llvm::yaml; // Mark all our options with this category, everything else (except for -version // and -help) will be hidden. @@ -61,6 +60,11 @@ static cl::opt<bool> NoDemangle("no-demangle", cl::desc("Don't demangle function names"), cl::init(false), cl::cat(OptReportCategory)); +static cl::opt<std::string> ParserFormat("format", + cl::desc("The format of the remarks."), + cl::init("yaml"), + cl::cat(OptReportCategory)); + namespace { // For each location in the source file, the common per-transformation state // collected. @@ -150,8 +154,17 @@ static bool readLocationInfo(LocationInfoTy &LocationInfo) { return false; } + Expected<remarks::Format> Format = remarks::parseFormat(ParserFormat); + if (!Format) { + handleAllErrors(Format.takeError(), [&](const ErrorInfoBase &PE) { + PE.log(WithColor::error()); + WithColor::error() << '\n'; + }); + return false; + } + Expected<std::unique_ptr<remarks::Parser>> MaybeParser = - remarks::createRemarkParser(remarks::Format::YAML, (*Buf)->getBuffer()); + remarks::createRemarkParser(*Format, (*Buf)->getBuffer()); if (!MaybeParser) { handleAllErrors(MaybeParser.takeError(), [&](const ErrorInfoBase &PE) { PE.log(WithColor::error()); |