]> granicus.if.org Git - llvm/commitdiff
UnitTests: Replace some if(x)report_fatal_error() with EXPECT_TRUE(!x)
authorMatthias Braun <matze@braunis.de>
Thu, 15 Jun 2017 22:31:08 +0000 (22:31 +0000)
committerMatthias Braun <matze@braunis.de>
Thu, 15 Jun 2017 22:31:08 +0000 (22:31 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@305519 91177308-0d34-0410-b5e6-96231b3b80d8

unittests/MI/LiveIntervalTest.cpp
unittests/Target/AArch64/InstSizes.cpp

index 7118a43e6d8848312a76988731ce8c9ebd3554ef..43dfa4a79787fed0148a0d43f5cb78a927740650 100644 (file)
@@ -151,8 +151,7 @@ body: |
   std::unique_ptr<MIRParser> MIR;
   std::unique_ptr<Module> M = parseMIR(Context, PM, MIR, *TM, MIRString,
                                        "func");
-  if (!M)
-    report_fatal_error("Could not parse MIR code\n");
+  EXPECT_TRUE(M);
 
   PM.add(new TestPass(T));
 
index c1fe7f22dc5a2f19dc8ce3cd8916b323b14c8962..32b91da0910f257d1fc54081c30b5f072e950df8 100644 (file)
@@ -21,8 +21,7 @@ std::unique_ptr<TargetMachine> createTargetMachine() {
 
   std::string Error;
   const Target *TheTarget = TargetRegistry::lookupTarget(TT, Error);
-  if (!TheTarget)
-    report_fatal_error("Target not registered");
+  EXPECT_TRUE(TheTarget);
 
   return std::unique_ptr<TargetMachine>(
       TheTarget->createTargetMachine(TT, CPU, FS, TargetOptions(), None,
@@ -59,24 +58,20 @@ void runChecks(
   std::unique_ptr<MemoryBuffer> MBuffer = MemoryBuffer::getMemBuffer(MIRString);
   std::unique_ptr<MIRParser> MParser =
       createMIRParser(std::move(MBuffer), Context);
-  if (!MParser)
-    report_fatal_error("Couldn't create MIR parser");
+  EXPECT_TRUE(MParser);
 
   std::unique_ptr<Module> M = MParser->parseIRModule();
-  if (!M)
-    report_fatal_error("Couldn't parse module");
+  EXPECT_TRUE(M);
 
   M->setTargetTriple(TM->getTargetTriple().getTriple());
   M->setDataLayout(TM->createDataLayout());
 
   MachineModuleInfo MMI(TM);
   bool Res = MParser->parseMachineFunctions(*M, MMI);
-  if (Res)
-    report_fatal_error("Couldn't parse MIR functions");
+  EXPECT_FALSE(Res);
 
   auto F = M->getFunction("sizes");
-  if (!F)
-    report_fatal_error("Couldn't find intended function");
+  EXPECT_TRUE(F);
   auto &MF = MMI.getOrCreateMachineFunction(*F);
 
   Checks(*II, MF);