[llvm] r305519 - UnitTests: Replace some if(x)report_fatal_error() with EXPECT_TRUE(!x)
David Blaikie via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 15 15:39:44 PDT 2017
I think these should be ASSERT_TRUE, though - since EXPECT doesn't halt
execution of the test, so it'll hit UB on the following line where the
pointer is dereferenced, etc?
On Thu, Jun 15, 2017 at 3:31 PM Matthias Braun via llvm-commits <
llvm-commits at lists.llvm.org> wrote:
> Author: matze
> Date: Thu Jun 15 17:31:08 2017
> New Revision: 305519
>
> URL: http://llvm.org/viewvc/llvm-project?rev=305519&view=rev
> Log:
> UnitTests: Replace some if(x)report_fatal_error() with EXPECT_TRUE(!x)
>
> Modified:
> llvm/trunk/unittests/MI/LiveIntervalTest.cpp
> llvm/trunk/unittests/Target/AArch64/InstSizes.cpp
>
> Modified: llvm/trunk/unittests/MI/LiveIntervalTest.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/MI/LiveIntervalTest.cpp?rev=305519&r1=305518&r2=305519&view=diff
>
> ==============================================================================
> --- llvm/trunk/unittests/MI/LiveIntervalTest.cpp (original)
> +++ llvm/trunk/unittests/MI/LiveIntervalTest.cpp Thu Jun 15 17:31:08 2017
> @@ -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));
>
>
> Modified: llvm/trunk/unittests/Target/AArch64/InstSizes.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Target/AArch64/InstSizes.cpp?rev=305519&r1=305518&r2=305519&view=diff
>
> ==============================================================================
> --- llvm/trunk/unittests/Target/AArch64/InstSizes.cpp (original)
> +++ llvm/trunk/unittests/Target/AArch64/InstSizes.cpp Thu Jun 15 17:31:08
> 2017
> @@ -21,8 +21,7 @@ std::unique_ptr<TargetMachine> createTar
>
> 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);
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170615/bbbb3fb8/attachment.html>
More information about the llvm-commits
mailing list