llvm.org GIT mirror llvm / 85ec803
[llvm-exegesis] Fix error propagation from yaml writing (from serialization) Investigating https://bugs.llvm.org/show_bug.cgi?id=41448 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@358076 91177308-0d34-0410-b5e6-96231b3b80d8 Roman Lebedev 1 year, 7 months ago
2 changed file(s) with 19 addition(s) and 10 deletion(s). Raw diff Collapse all Expand all
364364 }
365365 }
366366
367 void InstructionBenchmark::writeYamlTo(const LLVMState &State,
368 llvm::raw_ostream &OS) {
367 llvm::Error InstructionBenchmark::writeYamlTo(const LLVMState &State,
368 llvm::raw_ostream &OS) {
369369 llvm::yaml::Output Yout(OS, nullptr /*Ctx*/, 200 /*WrapColumn*/);
370370 YamlContext Context(State);
371371 Yout.beginDocuments();
372372 llvm::yaml::yamlize(Yout, *this, /*unused*/ true, Context);
373 if (!Context.getLastError().empty())
374 return llvm::make_error(Context.getLastError());
373375 Yout.endDocuments();
374 }
375
376 void InstructionBenchmark::readYamlFrom(const LLVMState &State,
377 llvm::StringRef InputContent) {
376 return Error::success();
377 }
378
379 llvm::Error InstructionBenchmark::readYamlFrom(const LLVMState &State,
380 llvm::StringRef InputContent) {
378381 llvm::yaml::Input Yin(InputContent);
379382 YamlContext Context(State);
380383 if (Yin.setCurrentDocument())
381384 llvm::yaml::yamlize(Yin, *this, /*unused*/ true, Context);
385 if (!Context.getLastError().empty())
386 return llvm::make_error(Context.getLastError());
387 return Error::success();
382388 }
383389
384390 llvm::Error InstructionBenchmark::writeYaml(const LLVMState &State,
385391 const llvm::StringRef Filename) {
386392 if (Filename == "-") {
387 writeYamlTo(State, llvm::outs());
393 if (auto Err = writeYamlTo(State, llvm::outs()))
394 return std::move(Err);
388395 } else {
389396 int ResultFD = 0;
390397 if (auto E = llvm::errorCodeToError(
393400 return E;
394401 }
395402 llvm::raw_fd_ostream Ostr(ResultFD, true /*shouldClose*/);
396 writeYamlTo(State, Ostr);
403 if (auto Err = writeYamlTo(State, Ostr))
404 return std::move(Err);
397405 }
398406 return llvm::Error::success();
399407 }
7878 static llvm::Expected>
7979 readYamls(const LLVMState &State, llvm::StringRef Filename);
8080
81 void readYamlFrom(const LLVMState &State, llvm::StringRef InputContent);
81 llvm::Error readYamlFrom(const LLVMState &State,
82 llvm::StringRef InputContent);
8283
8384 // Write functions, non-const because of YAML traits.
84 void writeYamlTo(const LLVMState &State, llvm::raw_ostream &S);
85 llvm::Error writeYamlTo(const LLVMState &State, llvm::raw_ostream &S);
8586
8687 llvm::Error writeYaml(const LLVMState &State, const llvm::StringRef Filename);
8788 };