diff options
| author | Matthias Braun <matze@braunis.de> | 2017-06-06 19:00:54 +0000 |
|---|---|---|
| committer | Matthias Braun <matze@braunis.de> | 2017-06-06 19:00:54 +0000 |
| commit | 49220fb6a132a17278337f770c0de91d37d889d4 (patch) | |
| tree | f622942560ee15c2091469d74d97e15be8895541 /llvm/unittests/Target | |
| parent | dd7c68bc7867adabc34bfe07c1a85c4cb955e088 (diff) | |
| download | bcm5719-llvm-49220fb6a132a17278337f770c0de91d37d889d4.tar.gz bcm5719-llvm-49220fb6a132a17278337f770c0de91d37d889d4.zip | |
UnitTests: Do not use assert() for error checking
Use `if (!X) report_fatal_error()` instead of `assert()` for the ad-hoc
error handling in two unittests. This reduces unnecessary differences
between release and debug builds (motivated by unused variable warnings
triggered in release builds).
llvm-svn: 304814
Diffstat (limited to 'llvm/unittests/Target')
| -rw-r--r-- | llvm/unittests/Target/AArch64/InstSizes.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/llvm/unittests/Target/AArch64/InstSizes.cpp b/llvm/unittests/Target/AArch64/InstSizes.cpp index a4bcd6821ec..c1fe7f22dc5 100644 --- a/llvm/unittests/Target/AArch64/InstSizes.cpp +++ b/llvm/unittests/Target/AArch64/InstSizes.cpp @@ -21,7 +21,8 @@ std::unique_ptr<TargetMachine> createTargetMachine() { std::string Error; const Target *TheTarget = TargetRegistry::lookupTarget(TT, Error); - assert(TheTarget && "Target not registered"); + if (!TheTarget) + report_fatal_error("Target not registered"); return std::unique_ptr<TargetMachine>( TheTarget->createTargetMachine(TT, CPU, FS, TargetOptions(), None, @@ -58,21 +59,24 @@ void runChecks( std::unique_ptr<MemoryBuffer> MBuffer = MemoryBuffer::getMemBuffer(MIRString); std::unique_ptr<MIRParser> MParser = createMIRParser(std::move(MBuffer), Context); - assert(MParser && "Couldn't create MIR parser"); + if (!MParser) + report_fatal_error("Couldn't create MIR parser"); std::unique_ptr<Module> M = MParser->parseIRModule(); - assert(M && "Couldn't parse module"); + if (!M) + report_fatal_error("Couldn't parse module"); M->setTargetTriple(TM->getTargetTriple().getTriple()); M->setDataLayout(TM->createDataLayout()); MachineModuleInfo MMI(TM); bool Res = MParser->parseMachineFunctions(*M, MMI); - (void)Res; - assert(!Res && "Couldn't parse MIR functions"); + if (Res) + report_fatal_error("Couldn't parse MIR functions"); auto F = M->getFunction("sizes"); - assert(F && "Couldn't find intended function"); + if (!F) + report_fatal_error("Couldn't find intended function"); auto &MF = MMI.getOrCreateMachineFunction(*F); Checks(*II, MF); |

