summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzhanyong.wan <zhanyong.wan@861a406c-534a-0410-8894-cb66d6ee9925>2009-12-16 19:54:05 +0000
committerzhanyong.wan <zhanyong.wan@861a406c-534a-0410-8894-cb66d6ee9925>2009-12-16 19:54:05 +0000
commit7de3401f5f8c2a61476a3623e9802f973764fc27 (patch)
tree59322de2099c9879b4a10a298ecf6e6b03a63ace
parent348b01a2d08593bd4cb9739a83038143f860edff (diff)
downloadgtest-7de3401f5f8c2a61476a3623e9802f973764fc27.tar.gz
gtest-7de3401f5f8c2a61476a3623e9802f973764fc27.tar.bz2
gtest-7de3401f5f8c2a61476a3623e9802f973764fc27.tar.xz
Turns on -Wshadow (by Preston Jackson).
git-svn-id: http://googletest.googlecode.com/svn/trunk@350 861a406c-534a-0410-8894-cb66d6ee9925
-rw-r--r--include/gtest/gtest-test-part.h18
-rw-r--r--include/gtest/gtest.h4
-rw-r--r--include/gtest/internal/gtest-death-test-internal.h11
-rw-r--r--include/gtest/internal/gtest-param-util.h12
-rw-r--r--include/gtest/internal/gtest-string.h28
-rw-r--r--scons/SConstruct.common1
-rw-r--r--src/gtest-death-test.cc32
-rw-r--r--src/gtest-internal-inl.h8
-rw-r--r--src/gtest.cc43
-rw-r--r--test/gtest-param-test_test.cc4
-rw-r--r--test/gtest_unittest.cc10
-rw-r--r--test/production.h2
-rw-r--r--xcode/Config/General.xcconfig2
13 files changed, 90 insertions, 85 deletions
diff --git a/include/gtest/gtest-test-part.h b/include/gtest/gtest-test-part.h
index 58e7df9..348e4ec 100644
--- a/include/gtest/gtest-test-part.h
+++ b/include/gtest/gtest-test-part.h
@@ -56,15 +56,15 @@ class TestPartResult {
// C'tor. TestPartResult does NOT have a default constructor.
// Always use this constructor (with parameters) to create a
// TestPartResult object.
- TestPartResult(Type type,
- const char* file_name,
- int line_number,
- const char* message)
- : type_(type),
- file_name_(file_name),
- line_number_(line_number),
- summary_(ExtractSummary(message)),
- message_(message) {
+ TestPartResult(Type a_type,
+ const char* a_file_name,
+ int a_line_number,
+ const char* a_message)
+ : type_(a_type),
+ file_name_(a_file_name),
+ line_number_(a_line_number),
+ summary_(ExtractSummary(a_message)),
+ message_(a_message) {
}
// Gets the outcome of the test part.
diff --git a/include/gtest/gtest.h b/include/gtest/gtest.h
index 33e2f7f..c7df7f0 100644
--- a/include/gtest/gtest.h
+++ b/include/gtest/gtest.h
@@ -457,8 +457,8 @@ class TestProperty {
// C'tor. TestProperty does NOT have a default constructor.
// Always use this constructor (with parameters) to create a
// TestProperty object.
- TestProperty(const char* key, const char* value) :
- key_(key), value_(value) {
+ TestProperty(const char* a_key, const char* a_value) :
+ key_(a_key), value_(a_value) {
}
// Gets the user supplied key.
diff --git a/include/gtest/internal/gtest-death-test-internal.h b/include/gtest/internal/gtest-death-test-internal.h
index 5aba1a0..e98650e 100644
--- a/include/gtest/internal/gtest-death-test-internal.h
+++ b/include/gtest/internal/gtest-death-test-internal.h
@@ -189,11 +189,12 @@ bool ExitedUnsuccessfully(int exit_status);
// RUN_ALL_TESTS was called.
class InternalRunDeathTestFlag {
public:
- InternalRunDeathTestFlag(const String& file,
- int line,
- int index,
- int write_fd)
- : file_(file), line_(line), index_(index), write_fd_(write_fd) {}
+ InternalRunDeathTestFlag(const String& a_file,
+ int a_line,
+ int an_index,
+ int a_write_fd)
+ : file_(a_file), line_(a_line), index_(an_index),
+ write_fd_(a_write_fd) {}
~InternalRunDeathTestFlag() {
if (write_fd_ >= 0)
diff --git a/include/gtest/internal/gtest-param-util.h b/include/gtest/internal/gtest-param-util.h
index 19295d7..8dec853 100644
--- a/include/gtest/internal/gtest-param-util.h
+++ b/include/gtest/internal/gtest-param-util.h
@@ -544,12 +544,12 @@ class ParameterizedTestCaseInfo : public ParameterizedTestCaseInfoBase {
// LocalTestInfo structure keeps information about a single test registered
// with TEST_P macro.
struct TestInfo {
- TestInfo(const char* test_case_base_name,
- const char* test_base_name,
- TestMetaFactoryBase<ParamType>* test_meta_factory) :
- test_case_base_name(test_case_base_name),
- test_base_name(test_base_name),
- test_meta_factory(test_meta_factory) {}
+ TestInfo(const char* a_test_case_base_name,
+ const char* a_test_base_name,
+ TestMetaFactoryBase<ParamType>* a_test_meta_factory) :
+ test_case_base_name(a_test_case_base_name),
+ test_base_name(a_test_base_name),
+ test_meta_factory(a_test_meta_factory) {}
const String test_case_base_name;
const String test_base_name;
diff --git a/include/gtest/internal/gtest-string.h b/include/gtest/internal/gtest-string.h
index 4bc8241..076119a 100644
--- a/include/gtest/internal/gtest-string.h
+++ b/include/gtest/internal/gtest-string.h
@@ -190,12 +190,12 @@ class String {
String() : c_str_(NULL), length_(0) {}
// Constructs a String by cloning a 0-terminated C string.
- String(const char* c_str) { // NOLINT
- if (c_str == NULL) {
+ String(const char* a_c_str) { // NOLINT
+ if (a_c_str == NULL) {
c_str_ = NULL;
length_ = 0;
} else {
- ConstructNonNull(c_str, strlen(c_str));
+ ConstructNonNull(a_c_str, strlen(a_c_str));
}
}
@@ -203,8 +203,8 @@ class String {
// buffer. E.g. String("hello", 3) creates the string "hel",
// String("a\0bcd", 4) creates "a\0bc", String(NULL, 0) creates "",
// and String(NULL, 1) results in access violation.
- String(const char* buffer, size_t length) {
- ConstructNonNull(buffer, length);
+ String(const char* buffer, size_t a_length) {
+ ConstructNonNull(buffer, a_length);
}
// The copy c'tor creates a new copy of the string. The two
@@ -247,7 +247,7 @@ class String {
// Returns true iff this String equals the given C string. A NULL
// string and a non-NULL string are considered not equal.
- bool operator==(const char* c_str) const { return Compare(c_str) == 0; }
+ bool operator==(const char* a_c_str) const { return Compare(a_c_str) == 0; }
// Returns true iff this String is less than the given String. A
// NULL string is considered less than "".
@@ -255,7 +255,7 @@ class String {
// Returns true iff this String doesn't equal the given C string. A NULL
// string and a non-NULL string are considered not equal.
- bool operator!=(const char* c_str) const { return !(*this == c_str); }
+ bool operator!=(const char* a_c_str) const { return !(*this == a_c_str); }
// Returns true iff this String ends with the given suffix. *Any*
// String is considered to end with a NULL or empty suffix.
@@ -275,7 +275,9 @@ class String {
const char* c_str() const { return c_str_; }
// Assigns a C string to this object. Self-assignment works.
- const String& operator=(const char* c_str) { return *this = String(c_str); }
+ const String& operator=(const char* a_c_str) {
+ return *this = String(a_c_str);
+ }
// Assigns a String object to this object. Self-assignment works.
const String& operator=(const String& rhs) {
@@ -297,12 +299,12 @@ class String {
// function can only be called when data_ has not been allocated.
// ConstructNonNull(NULL, 0) results in an empty string ("").
// ConstructNonNull(NULL, non_zero) is undefined behavior.
- void ConstructNonNull(const char* buffer, size_t length) {
- char* const str = new char[length + 1];
- memcpy(str, buffer, length);
- str[length] = '\0';
+ void ConstructNonNull(const char* buffer, size_t a_length) {
+ char* const str = new char[a_length + 1];
+ memcpy(str, buffer, a_length);
+ str[a_length] = '\0';
c_str_ = str;
- length_ = length;
+ length_ = a_length;
}
const char* c_str_;
diff --git a/scons/SConstruct.common b/scons/SConstruct.common
index 3f9d9ca..7f6db15 100644
--- a/scons/SConstruct.common
+++ b/scons/SConstruct.common
@@ -193,6 +193,7 @@ class SConstructHelper:
env.Append(CCFLAGS=['-fno-exceptions',
'-Wall',
'-Werror',
+ '-Wshadow',
])
if optimized:
env.Append(CCFLAGS=['-O2'], CPPDEFINES=['NDEBUG', '_NDEBUG'])
diff --git a/src/gtest-death-test.cc b/src/gtest-death-test.cc
index 106b01c..5f2fbbc 100644
--- a/src/gtest-death-test.cc
+++ b/src/gtest-death-test.cc
@@ -308,9 +308,9 @@ String DeathTest::last_death_test_message_;
// Provides cross platform implementation for some death functionality.
class DeathTestImpl : public DeathTest {
protected:
- DeathTestImpl(const char* statement, const RE* regex)
- : statement_(statement),
- regex_(regex),
+ DeathTestImpl(const char* a_statement, const RE* a_regex)
+ : statement_(a_statement),
+ regex_(a_regex),
spawned_(false),
status_(-1),
outcome_(IN_PROGRESS),
@@ -326,11 +326,11 @@ class DeathTestImpl : public DeathTest {
const char* statement() const { return statement_; }
const RE* regex() const { return regex_; }
bool spawned() const { return spawned_; }
- void set_spawned(bool spawned) { spawned_ = spawned; }
+ void set_spawned(bool is_spawned) { spawned_ = is_spawned; }
int status() const { return status_; }
- void set_status(int status) { status_ = status; }
+ void set_status(int a_status) { status_ = a_status; }
DeathTestOutcome outcome() const { return outcome_; }
- void set_outcome(DeathTestOutcome outcome) { outcome_ = outcome; }
+ void set_outcome(DeathTestOutcome an_outcome) { outcome_ = an_outcome; }
int read_fd() const { return read_fd_; }
void set_read_fd(int fd) { read_fd_ = fd; }
int write_fd() const { return write_fd_; }
@@ -705,8 +705,8 @@ class ForkingDeathTest : public DeathTestImpl {
};
// Constructs a ForkingDeathTest.
-ForkingDeathTest::ForkingDeathTest(const char* statement, const RE* regex)
- : DeathTestImpl(statement, regex),
+ForkingDeathTest::ForkingDeathTest(const char* a_statement, const RE* a_regex)
+ : DeathTestImpl(a_statement, a_regex),
child_pid_(-1) {}
// Waits for the child in a death test to exit, returning its exit
@@ -718,18 +718,18 @@ int ForkingDeathTest::Wait() {
ReadAndInterpretStatusByte();
- int status;
- GTEST_DEATH_TEST_CHECK_SYSCALL_(waitpid(child_pid_, &status, 0));
- set_status(status);
- return status;
+ int status_value;
+ GTEST_DEATH_TEST_CHECK_SYSCALL_(waitpid(child_pid_, &status_value, 0));
+ set_status(status_value);
+ return status_value;
}
// A concrete death test class that forks, then immediately runs the test
// in the child process.
class NoExecDeathTest : public ForkingDeathTest {
public:
- NoExecDeathTest(const char* statement, const RE* regex) :
- ForkingDeathTest(statement, regex) { }
+ NoExecDeathTest(const char* a_statement, const RE* a_regex) :
+ ForkingDeathTest(a_statement, a_regex) { }
virtual TestRole AssumeRole();
};
@@ -782,9 +782,9 @@ DeathTest::TestRole NoExecDeathTest::AssumeRole() {
// only this specific death test to be run.
class ExecDeathTest : public ForkingDeathTest {
public:
- ExecDeathTest(const char* statement, const RE* regex,
+ ExecDeathTest(const char* a_statement, const RE* a_regex,
const char* file, int line) :
- ForkingDeathTest(statement, regex), file_(file), line_(line) { }
+ ForkingDeathTest(a_statement, a_regex), file_(file), line_(line) { }
virtual TestRole AssumeRole();
private:
// The name of the file in which the death test is located.
diff --git a/src/gtest-internal-inl.h b/src/gtest-internal-inl.h
index 45a4c10..596dc55 100644
--- a/src/gtest-internal-inl.h
+++ b/src/gtest-internal-inl.h
@@ -902,15 +902,15 @@ class UnitTestImpl {
#endif // GTEST_HAS_PARAM_TEST
// Sets the TestCase object for the test that's currently running.
- void set_current_test_case(TestCase* current_test_case) {
- current_test_case_ = current_test_case;
+ void set_current_test_case(TestCase* a_current_test_case) {
+ current_test_case_ = a_current_test_case;
}
// Sets the TestInfo object for the test that's currently running. If
// current_test_info is NULL, the assertion results will be stored in
// ad_hoc_test_result_.
- void set_current_test_info(TestInfo* current_test_info) {
- current_test_info_ = current_test_info;
+ void set_current_test_info(TestInfo* a_current_test_info) {
+ current_test_info_ = a_current_test_info;
}
// Registers all parameterized tests defined using TEST_P and
diff --git a/src/gtest.cc b/src/gtest.cc
index aa50b25..bd16bc6 100644
--- a/src/gtest.cc
+++ b/src/gtest.cc
@@ -2123,14 +2123,14 @@ bool Test::HasNonfatalFailure() {
// Constructs a TestInfo object. It assumes ownership of the test factory
// object via impl_.
-TestInfo::TestInfo(const char* test_case_name,
- const char* name,
- const char* test_case_comment,
- const char* comment,
+TestInfo::TestInfo(const char* a_test_case_name,
+ const char* a_name,
+ const char* a_test_case_comment,
+ const char* a_comment,
internal::TypeId fixture_class_id,
internal::TestFactoryBase* factory) {
- impl_ = new internal::TestInfoImpl(this, test_case_name, name,
- test_case_comment, comment,
+ impl_ = new internal::TestInfoImpl(this, a_test_case_name, a_name,
+ a_test_case_comment, a_comment,
fixture_class_id, factory);
}
@@ -2368,11 +2368,11 @@ int TestCase::total_test_count() const {
// name: name of the test case
// set_up_tc: pointer to the function that sets up the test case
// tear_down_tc: pointer to the function that tears down the test case
-TestCase::TestCase(const char* name, const char* comment,
+TestCase::TestCase(const char* a_name, const char* a_comment,
Test::SetUpTestCaseFunc set_up_tc,
Test::TearDownTestCaseFunc tear_down_tc)
- : name_(name),
- comment_(comment),
+ : name_(a_name),
+ comment_(a_comment),
test_info_list_(new internal::Vector<TestInfo*>),
test_indices_(new internal::Vector<int>),
set_up_tc_(set_up_tc),
@@ -4022,8 +4022,9 @@ int UnitTestImpl::RunAllTests() {
// Runs the tests only if there was no fatal failure during global
// set-up.
if (!Test::HasFatalFailure()) {
- for (int i = 0; i < total_test_case_count(); i++) {
- GetMutableTestCase(i)->Run();
+ for (int test_index = 0; test_index < total_test_case_count();
+ test_index++) {
+ GetMutableTestCase(test_index)->Run();
}
}
@@ -4297,18 +4298,18 @@ void UnitTestImpl::UnshuffleTests() {
// TestInfoImpl constructor. The new instance assumes ownership of the test
// factory object.
TestInfoImpl::TestInfoImpl(TestInfo* parent,
- const char* test_case_name,
- const char* name,
- const char* test_case_comment,
- const char* comment,
- TypeId fixture_class_id,
+ const char* a_test_case_name,
+ const char* a_name,
+ const char* a_test_case_comment,
+ const char* a_comment,
+ TypeId a_fixture_class_id,
internal::TestFactoryBase* factory) :
parent_(parent),
- test_case_name_(String(test_case_name)),
- name_(String(name)),
- test_case_comment_(String(test_case_comment)),
- comment_(String(comment)),
- fixture_class_id_(fixture_class_id),
+ test_case_name_(String(a_test_case_name)),
+ name_(String(a_name)),
+ test_case_comment_(String(a_test_case_comment)),
+ comment_(String(a_comment)),
+ fixture_class_id_(a_fixture_class_id),
should_run_(false),
is_disabled_(false),
matches_filter_(false),
diff --git a/test/gtest-param-test_test.cc b/test/gtest-param-test_test.cc
index ecb5fdb..e718ffb 100644
--- a/test/gtest-param-test_test.cc
+++ b/test/gtest-param-test_test.cc
@@ -205,7 +205,7 @@ TEST(RangeTest, IntRangeWithCustomStepOverUpperBound) {
// copy constructor, operator=(), operator+(), and operator<().
class DogAdder {
public:
- explicit DogAdder(const char* value) : value_(value) {}
+ explicit DogAdder(const char* a_value) : value_(a_value) {}
DogAdder(const DogAdder& other) : value_(other.value_.c_str()) {}
DogAdder operator=(const DogAdder& other) {
@@ -243,7 +243,7 @@ TEST(RangeTest, WorksWithACustomType) {
class IntWrapper {
public:
- explicit IntWrapper(int value) : value_(value) {}
+ explicit IntWrapper(int a_value) : value_(a_value) {}
IntWrapper(const IntWrapper& other) : value_(other.value_) {}
IntWrapper operator=(const IntWrapper& other) {
diff --git a/test/gtest_unittest.cc b/test/gtest_unittest.cc
index bf41de7..5e79c5a 100644
--- a/test/gtest_unittest.cc
+++ b/test/gtest_unittest.cc
@@ -4009,7 +4009,7 @@ TEST(AssertionTest, NonFixtureSubroutine) {
// An uncopyable class.
class Uncopyable {
public:
- explicit Uncopyable(int value) : value_(value) {}
+ explicit Uncopyable(int a_value) : value_(a_value) {}
int value() const { return value_; }
bool operator==(const Uncopyable& rhs) const {
@@ -5095,7 +5095,7 @@ TEST(AssertionResultTest, StreamingWorks) {
// both in the global namespace.
class Base {
public:
- explicit Base(int x) : x_(x) {}
+ explicit Base(int an_x) : x_(an_x) {}
int x() const { return x_; }
private:
int x_;
@@ -5122,7 +5122,7 @@ TEST(MessageTest, CanStreamUserTypeInGlobalNameSpace) {
namespace {
class MyTypeInUnnamedNameSpace : public Base {
public:
- explicit MyTypeInUnnamedNameSpace(int x): Base(x) {}
+ explicit MyTypeInUnnamedNameSpace(int an_x): Base(an_x) {}
};
std::ostream& operator<<(std::ostream& os,
const MyTypeInUnnamedNameSpace& val) {
@@ -5147,7 +5147,7 @@ TEST(MessageTest, CanStreamUserTypeInUnnamedNameSpace) {
namespace namespace1 {
class MyTypeInNameSpace1 : public Base {
public:
- explicit MyTypeInNameSpace1(int x): Base(x) {}
+ explicit MyTypeInNameSpace1(int an_x): Base(an_x) {}
};
std::ostream& operator<<(std::ostream& os,
const MyTypeInNameSpace1& val) {
@@ -5172,7 +5172,7 @@ TEST(MessageTest, CanStreamUserTypeInUserNameSpace) {
namespace namespace2 {
class MyTypeInNameSpace2 : public ::Base {
public:
- explicit MyTypeInNameSpace2(int x): Base(x) {}
+ explicit MyTypeInNameSpace2(int an_x): Base(an_x) {}
};
} // namespace namespace2
std::ostream& operator<<(std::ostream& os,
diff --git a/test/production.h b/test/production.h
index 59970da..8f16fff 100644
--- a/test/production.h
+++ b/test/production.h
@@ -48,7 +48,7 @@ class PrivateCode {
int x() const { return x_; }
private:
- void set_x(int x) { x_ = x; }
+ void set_x(int an_x) { x_ = an_x; }
int x_;
};
diff --git a/xcode/Config/General.xcconfig b/xcode/Config/General.xcconfig
index 9fcada1..f23e322 100644
--- a/xcode/Config/General.xcconfig
+++ b/xcode/Config/General.xcconfig
@@ -17,7 +17,7 @@ ZERO_LINK = NO
PREBINDING = NO
// Strictest warning policy
-WARNING_CFLAGS = -Wall -Werror -Wendif-labels -Wnewline-eof -Wno-sign-compare
+WARNING_CFLAGS = -Wall -Werror -Wendif-labels -Wnewline-eof -Wno-sign-compare -Wshadow
// Work around Xcode bugs by using external strip. See:
// http://lists.apple.com/archives/Xcode-users/2006/Feb/msg00050.html