summaryrefslogtreecommitdiffstats
path: root/llvm/lib/LTO/ThinLTOCodeGenerator.cpp
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2016-11-11 19:50:24 +0000
committerPeter Collingbourne <peter@pcc.me.uk>2016-11-11 19:50:24 +0000
commitcd513a41c17a3591e764b1ff986ae501a28cc5f5 (patch)
tree87db3a383097fc45a617ddc23c42b96e481efddd /llvm/lib/LTO/ThinLTOCodeGenerator.cpp
parentc0032b717886f4923b682f0f5972ab4ab9c32640 (diff)
downloadbcm5719-llvm-cd513a41c17a3591e764b1ff986ae501a28cc5f5.tar.gz
bcm5719-llvm-cd513a41c17a3591e764b1ff986ae501a28cc5f5.zip
Bitcode: Clean up error handling for certain bitcode query functions.
The functions getBitcodeTargetTriple(), isBitcodeContainingObjCCategory(), getBitcodeProducerString() and hasGlobalValueSummary() now return errors via their return value rather than via the diagnostic handler. To make this work, re-implement these functions using non-member functions so that they can be used without the LLVMContext required by BitcodeReader. Differential Revision: https://reviews.llvm.org/D26532 llvm-svn: 286623
Diffstat (limited to 'llvm/lib/LTO/ThinLTOCodeGenerator.cpp')
-rw-r--r--llvm/lib/LTO/ThinLTOCodeGenerator.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/llvm/lib/LTO/ThinLTOCodeGenerator.cpp b/llvm/lib/LTO/ThinLTOCodeGenerator.cpp
index 400b80dfc62..77f1d342e11 100644
--- a/llvm/lib/LTO/ThinLTOCodeGenerator.cpp
+++ b/llvm/lib/LTO/ThinLTOCodeGenerator.cpp
@@ -453,14 +453,23 @@ void ThinLTOCodeGenerator::addModule(StringRef Identifier, StringRef Data) {
if (Modules.empty()) {
// First module added, so initialize the triple and some options
LLVMContext Context;
- Triple TheTriple(getBitcodeTargetTriple(Buffer, Context));
+ StringRef TripleStr;
+ ErrorOr<std::string> TripleOrErr =
+ expectedToErrorOrAndEmitErrors(Context, getBitcodeTargetTriple(Buffer));
+ if (TripleOrErr)
+ TripleStr = *TripleOrErr;
+ Triple TheTriple(TripleStr);
initTMBuilder(TMBuilder, Triple(TheTriple));
}
#ifndef NDEBUG
else {
LLVMContext Context;
- assert(TMBuilder.TheTriple.str() ==
- getBitcodeTargetTriple(Buffer, Context) &&
+ StringRef TripleStr;
+ ErrorOr<std::string> TripleOrErr =
+ expectedToErrorOrAndEmitErrors(Context, getBitcodeTargetTriple(Buffer));
+ if (TripleOrErr)
+ TripleStr = *TripleOrErr;
+ assert(TMBuilder.TheTriple.str() == TripleStr &&
"ThinLTO modules with different triple not supported");
}
#endif
OpenPOWER on IntegriCloud