diff options
author | Vedant Kumar <vsk@apple.com> | 2016-05-19 03:54:54 +0000 |
---|---|---|
committer | Vedant Kumar <vsk@apple.com> | 2016-05-19 03:54:54 +0000 |
commit | fa2d595541cf1489af3747cc38c096b2e2cdcc32 (patch) | |
tree | 841c4984685465379f29c36e4753346596df1290 /clang/lib/CodeGen | |
parent | 9152fd17e9a0b2fc8edf41503c026ade1d0d5b1b (diff) | |
download | bcm5719-llvm-fa2d595541cf1489af3747cc38c096b2e2cdcc32.tar.gz bcm5719-llvm-fa2d595541cf1489af3747cc38c096b2e2cdcc32.zip |
Reapply^3 "[ProfileData] (clang) Use Error in InstrProf and Coverage, NFC"
Sync up with "(llvm) Use Error in InstrProf and Coverage".
llvm-svn: 270021
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 8 | ||||
-rw-r--r-- | clang/lib/CodeGen/CodeGenPGO.cpp | 13 |
2 files changed, 12 insertions, 9 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 79da25c13fa..57a6429c4be 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -141,11 +141,13 @@ CodeGenModule::CodeGenModule(ASTContext &C, const HeaderSearchOptions &HSO, if (CodeGenOpts.hasProfileClangUse()) { auto ReaderOrErr = llvm::IndexedInstrProfReader::create( CodeGenOpts.ProfileInstrumentUsePath); - if (std::error_code EC = ReaderOrErr.getError()) { + if (auto E = ReaderOrErr.takeError()) { unsigned DiagID = Diags.getCustomDiagID(DiagnosticsEngine::Error, "Could not read profile %0: %1"); - getDiags().Report(DiagID) << CodeGenOpts.ProfileInstrumentUsePath - << EC.message(); + llvm::handleAllErrors(std::move(E), [&](const llvm::ErrorInfoBase &EI) { + getDiags().Report(DiagID) << CodeGenOpts.ProfileInstrumentUsePath + << EI.message(); + }); } else PGOReader = std::move(ReaderOrErr.get()); } diff --git a/clang/lib/CodeGen/CodeGenPGO.cpp b/clang/lib/CodeGen/CodeGenPGO.cpp index 43bc37c49f7..c19321b5129 100644 --- a/clang/lib/CodeGen/CodeGenPGO.cpp +++ b/clang/lib/CodeGen/CodeGenPGO.cpp @@ -800,20 +800,21 @@ void CodeGenPGO::loadRegionCounts(llvm::IndexedInstrProfReader *PGOReader, bool IsInMainFile) { CGM.getPGOStats().addVisited(IsInMainFile); RegionCounts.clear(); - llvm::ErrorOr<llvm::InstrProfRecord> RecordErrorOr = + llvm::Expected<llvm::InstrProfRecord> RecordExpected = PGOReader->getInstrProfRecord(FuncName, FunctionHash); - if (std::error_code EC = RecordErrorOr.getError()) { - if (EC == llvm::instrprof_error::unknown_function) + if (auto E = RecordExpected.takeError()) { + auto IPE = llvm::InstrProfError::take(std::move(E)); + if (IPE == llvm::instrprof_error::unknown_function) CGM.getPGOStats().addMissing(IsInMainFile); - else if (EC == llvm::instrprof_error::hash_mismatch) + else if (IPE == llvm::instrprof_error::hash_mismatch) CGM.getPGOStats().addMismatched(IsInMainFile); - else if (EC == llvm::instrprof_error::malformed) + else if (IPE == llvm::instrprof_error::malformed) // TODO: Consider a more specific warning for this case. CGM.getPGOStats().addMismatched(IsInMainFile); return; } ProfRecord = - llvm::make_unique<llvm::InstrProfRecord>(std::move(RecordErrorOr.get())); + llvm::make_unique<llvm::InstrProfRecord>(std::move(RecordExpected.get())); RegionCounts = ProfRecord->Counts; } |