mirror of
https://github.com/google/googletest.git
synced 2025-11-10 06:55:56 -05:00
Apply clang-tidy modernize-use-nullptr to googletest.
Now that googletest has moved to C++11, it should no longer use NULL or 0 for the null pointer. This patch converts all such usages to nullptr using clang-tidy. This prevents LLVM from issuing -Wzero-as-null-pointer-constant warnings. PiperOrigin-RevId: 215814400
This commit is contained in:
committed by
Gennadiy Civil
parent
f13bbe2992
commit
4bb49ed640
@@ -137,7 +137,7 @@ template <typename T>
|
||||
class BuiltInDefaultValue<T*> {
|
||||
public:
|
||||
static bool Exists() { return true; }
|
||||
static T* Get() { return NULL; }
|
||||
static T* Get() { return nullptr; }
|
||||
};
|
||||
|
||||
// The following specializations define the default values for
|
||||
@@ -220,11 +220,11 @@ class DefaultValue {
|
||||
// Unsets the default value for type T.
|
||||
static void Clear() {
|
||||
delete producer_;
|
||||
producer_ = NULL;
|
||||
producer_ = nullptr;
|
||||
}
|
||||
|
||||
// Returns true iff the user has set the default value for type T.
|
||||
static bool IsSet() { return producer_ != NULL; }
|
||||
static bool IsSet() { return producer_ != nullptr; }
|
||||
|
||||
// Returns true if T has a default return value set by the user or there
|
||||
// exists a built-in default value.
|
||||
@@ -236,8 +236,8 @@ class DefaultValue {
|
||||
// otherwise returns the built-in default value. Requires that Exists()
|
||||
// is true, which ensures that the return value is well-defined.
|
||||
static T Get() {
|
||||
return producer_ == NULL ?
|
||||
internal::BuiltInDefaultValue<T>::Get() : producer_->Produce();
|
||||
return producer_ == nullptr ? internal::BuiltInDefaultValue<T>::Get()
|
||||
: producer_->Produce();
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -282,12 +282,10 @@ class DefaultValue<T&> {
|
||||
}
|
||||
|
||||
// Unsets the default value for type T&.
|
||||
static void Clear() {
|
||||
address_ = NULL;
|
||||
}
|
||||
static void Clear() { address_ = nullptr; }
|
||||
|
||||
// Returns true iff the user has set the default value for type T&.
|
||||
static bool IsSet() { return address_ != NULL; }
|
||||
static bool IsSet() { return address_ != nullptr; }
|
||||
|
||||
// Returns true if T has a default return value set by the user or there
|
||||
// exists a built-in default value.
|
||||
@@ -299,8 +297,8 @@ class DefaultValue<T&> {
|
||||
// otherwise returns the built-in default value if there is one;
|
||||
// otherwise aborts the process.
|
||||
static T& Get() {
|
||||
return address_ == NULL ?
|
||||
internal::BuiltInDefaultValue<T&>::Get() : *address_;
|
||||
return address_ == nullptr ? internal::BuiltInDefaultValue<T&>::Get()
|
||||
: *address_;
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -318,11 +316,11 @@ class DefaultValue<void> {
|
||||
|
||||
// Points to the user-set default value for type T.
|
||||
template <typename T>
|
||||
typename DefaultValue<T>::ValueProducer* DefaultValue<T>::producer_ = NULL;
|
||||
typename DefaultValue<T>::ValueProducer* DefaultValue<T>::producer_ = nullptr;
|
||||
|
||||
// Points to the user-set default value for type T&.
|
||||
template <typename T>
|
||||
T* DefaultValue<T&>::address_ = NULL;
|
||||
T* DefaultValue<T&>::address_ = nullptr;
|
||||
|
||||
// Implement this interface to define an action for function type F.
|
||||
template <typename F>
|
||||
@@ -1108,8 +1106,9 @@ Action<To>::Action(const Action<From>& from)
|
||||
#if GTEST_LANG_CXX11
|
||||
fun_(from.fun_),
|
||||
#endif
|
||||
impl_(from.impl_ == NULL ? NULL
|
||||
: new internal::ActionAdaptor<To, From>(from)) {
|
||||
impl_(from.impl_ == nullptr
|
||||
? nullptr
|
||||
: new internal::ActionAdaptor<To, From>(from)) {
|
||||
}
|
||||
|
||||
// Creates an action that returns 'value'. 'value' is passed by value
|
||||
|
||||
Reference in New Issue
Block a user