[llvm] r259704 - Silence -Wsign-conversion issue in ProgramTest.cpp
Reid Kleckner via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 3 13:41:12 PST 2016
Author: rnk
Date: Wed Feb 3 15:41:12 2016
New Revision: 259704
URL: http://llvm.org/viewvc/llvm-project?rev=259704&view=rev
Log:
Silence -Wsign-conversion issue in ProgramTest.cpp
Unfortunately, ProgramInfo::ProcessId is signed on Unix and unsigned on
Windows, breaking the standard fix of using '0U' in the gtest
expectation.
Modified:
llvm/trunk/include/llvm/Support/Program.h
llvm/trunk/unittests/Support/ProgramTest.cpp
Modified: llvm/trunk/include/llvm/Support/Program.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Program.h?rev=259704&r1=259703&r2=259704&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/Program.h (original)
+++ llvm/trunk/include/llvm/Support/Program.h Wed Feb 3 15:41:12 2016
@@ -44,6 +44,8 @@ struct ProcessInfo {
#error "ProcessInfo is not defined for this platform!"
#endif
+ static const ProcessId InvalidPid = 0;
+
/// The process identifier.
ProcessId Pid;
Modified: llvm/trunk/unittests/Support/ProgramTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/ProgramTest.cpp?rev=259704&r1=259703&r2=259704&view=diff
==============================================================================
--- llvm/trunk/unittests/Support/ProgramTest.cpp (original)
+++ llvm/trunk/unittests/Support/ProgramTest.cpp Wed Feb 3 15:41:12 2016
@@ -223,7 +223,7 @@ TEST_F(ProgramEnvTest, TestExecuteNoWait
ProcessInfo PI1 = ExecuteNoWait(Executable, argv, getEnviron(), nullptr, 0,
&Error, &ExecutionFailed);
ASSERT_FALSE(ExecutionFailed) << Error;
- ASSERT_NE(PI1.Pid, 0) << "Invalid process id";
+ ASSERT_NE(PI1.Pid, ProcessInfo::InvalidPid) << "Invalid process id";
unsigned LoopCount = 0;
@@ -242,7 +242,7 @@ TEST_F(ProgramEnvTest, TestExecuteNoWait
ProcessInfo PI2 = ExecuteNoWait(Executable, argv, getEnviron(), nullptr, 0,
&Error, &ExecutionFailed);
ASSERT_FALSE(ExecutionFailed) << Error;
- ASSERT_NE(PI2.Pid, 0) << "Invalid process id";
+ ASSERT_NE(PI2.Pid, ProcessInfo::InvalidPid) << "Invalid process id";
// Test that Wait() with SecondsToWait=0 performs a non-blocking wait. In this
// cse, LoopCount should be greater than 1 (more than one increment occurs).
@@ -304,7 +304,7 @@ TEST(ProgramTest, TestExecuteNegative) {
bool ExecutionFailed;
ProcessInfo PI = ExecuteNoWait(Executable, argv, nullptr, nullptr, 0,
&Error, &ExecutionFailed);
- ASSERT_EQ(PI.Pid, 0)
+ ASSERT_EQ(PI.Pid, ProcessInfo::InvalidPid)
<< "On error ExecuteNoWait should return an invalid ProcessInfo";
ASSERT_TRUE(ExecutionFailed);
ASSERT_FALSE(Error.empty());
More information about the llvm-commits
mailing list