summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-opt-report/OptReport.cpp
diff options
context:
space:
mode:
authorFrancis Visoiu Mistrih <francisvm@yahoo.com>2019-07-24 16:36:35 +0000
committerFrancis Visoiu Mistrih <francisvm@yahoo.com>2019-07-24 16:36:35 +0000
commitc5cc9efa075b6fcd8cfe16d59764dcbebc949b8c (patch)
treeebf1b2ea26344a71bcd96d7e7b19afb8b25d76d2 /llvm/tools/llvm-opt-report/OptReport.cpp
parent419f1a4185d551594dc453b258bc4b8417edcfeb (diff)
downloadbcm5719-llvm-c5cc9efa075b6fcd8cfe16d59764dcbebc949b8c.tar.gz
bcm5719-llvm-c5cc9efa075b6fcd8cfe16d59764dcbebc949b8c.zip
[Remarks] Simplify the creation of remark serializers
Introduce two new functions to create a serializer, and add support for more combinations to the YAMLStrTabSerializer. llvm-svn: 366919
Diffstat (limited to 'llvm/tools/llvm-opt-report/OptReport.cpp')
-rw-r--r--llvm/tools/llvm-opt-report/OptReport.cpp19
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());
OpenPOWER on IntegriCloud