Modernize remaining uses of 0/NULL instead of nullptr (C++11)

Using clang-tidy's `modernize-use-nullptr`.
https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-nullptr.html
This commit is contained in:
Rémi Verschelde 2020-05-14 10:15:48 +02:00
parent 5f5f53e8eb
commit 1a8167867b
21 changed files with 37 additions and 37 deletions

View file

@ -1,5 +1,5 @@
---
Checks: 'clang-diagnostic-*,clang-analyzer-*,-*,modernize-use-default-member-init'
Checks: 'clang-diagnostic-*,clang-analyzer-*,-*,modernize-use-default-member-init,modernize-use-nullptr'
WarningsAsErrors: ''
HeaderFilterRegex: '.*'
AnalyzeTemporaryDtors: false

View file

@ -75,7 +75,7 @@ public:
return method == StringName() && object == 0;
}
_FORCE_INLINE_ bool is_custom() const {
return method == StringName() && custom != 0;
return method == StringName() && custom != nullptr;
}
_FORCE_INLINE_ bool is_standard() const {
return method != StringName();

View file

@ -132,7 +132,7 @@ public:
}
_FORCE_INLINE_ void clear() { resize(0); }
_FORCE_INLINE_ bool empty() const { return _ptr == 0; }
_FORCE_INLINE_ bool empty() const { return _ptr == nullptr; }
_FORCE_INLINE_ void set(int p_index, const T &p_elem) {

View file

@ -107,7 +107,7 @@ private:
hash_table_power = MIN_HASH_TABLE_POWER;
elements = 0;
for (int i = 0; i < (1 << MIN_HASH_TABLE_POWER); i++)
hash_table[i] = 0;
hash_table[i] = nullptr;
}
void erase_hash_table() {
@ -115,7 +115,7 @@ private:
ERR_FAIL_COND_MSG(elements, "Cannot erase hash table if there are still elements inside.");
memdelete_arr(hash_table);
hash_table = 0;
hash_table = nullptr;
hash_table_power = 0;
elements = 0;
}
@ -155,7 +155,7 @@ private:
for (int i = 0; i < (1 << new_hash_table_power); i++) {
new_hash_table[i] = 0;
new_hash_table[i] = nullptr;
}
if (hash_table) {
@ -541,7 +541,7 @@ public:
memdelete_arr(hash_table);
}
hash_table = 0;
hash_table = nullptr;
hash_table_power = 0;
elements = 0;
}

View file

@ -66,7 +66,7 @@ protected:
int offset;
} cache;
virtual int read_data_block(int p_offset, int p_size, uint8_t *p_dest = 0) const = 0;
virtual int read_data_block(int p_offset, int p_size, uint8_t *p_dest = nullptr) const = 0;
void set_cache_size(int p_size);
int get_cache_size();

View file

@ -182,14 +182,14 @@ public:
*/
_FORCE_INLINE_ const Element *front() const {
return _data ? _data->first : 0;
return _data ? _data->first : nullptr;
};
/**
* return an iterator to the beginning of the list.
*/
_FORCE_INLINE_ Element *front() {
return _data ? _data->first : 0;
return _data ? _data->first : nullptr;
};
/**
@ -197,7 +197,7 @@ public:
*/
_FORCE_INLINE_ const Element *back() const {
return _data ? _data->last : 0;
return _data ? _data->last : nullptr;
};
/**
@ -205,7 +205,7 @@ public:
*/
_FORCE_INLINE_ Element *back() {
return _data ? _data->last : 0;
return _data ? _data->last : nullptr;
};
/**
@ -225,7 +225,7 @@ public:
n->value = (T &)value;
n->prev_ptr = _data->last;
n->next_ptr = 0;
n->next_ptr = nullptr;
n->data = _data;
if (_data->last) {
@ -264,7 +264,7 @@ public:
Element *n = memnew_allocator(Element, A);
n->value = (T &)value;
n->prev_ptr = 0;
n->prev_ptr = nullptr;
n->next_ptr = _data->first;
n->data = _data;

View file

@ -69,8 +69,8 @@ public:
Vector3 get_median_point() const;
Vector3 get_closest_point_to(const Vector3 &p_point) const;
bool intersects_ray(const Vector3 &p_from, const Vector3 &p_dir, Vector3 *p_intersection = 0) const;
bool intersects_segment(const Vector3 &p_from, const Vector3 &p_dir, Vector3 *p_intersection = 0) const;
bool intersects_ray(const Vector3 &p_from, const Vector3 &p_dir, Vector3 *p_intersection = nullptr) const;
bool intersects_segment(const Vector3 &p_from, const Vector3 &p_dir, Vector3 *p_intersection = nullptr) const;
ClockDirection get_clock_dir() const; ///< todo, test if this is returning the proper clockwisity

View file

@ -190,7 +190,7 @@ public:
return dP.length(); // Return the closest distance.
}
static inline bool ray_intersects_triangle(const Vector3 &p_from, const Vector3 &p_dir, const Vector3 &p_v0, const Vector3 &p_v1, const Vector3 &p_v2, Vector3 *r_res = 0) {
static inline bool ray_intersects_triangle(const Vector3 &p_from, const Vector3 &p_dir, const Vector3 &p_v0, const Vector3 &p_v1, const Vector3 &p_v2, Vector3 *r_res = nullptr) {
Vector3 e1 = p_v1 - p_v0;
Vector3 e2 = p_v2 - p_v0;
Vector3 h = p_dir.cross(e2);
@ -225,7 +225,7 @@ public:
return false;
}
static inline bool segment_intersects_triangle(const Vector3 &p_from, const Vector3 &p_to, const Vector3 &p_v0, const Vector3 &p_v1, const Vector3 &p_v2, Vector3 *r_res = 0) {
static inline bool segment_intersects_triangle(const Vector3 &p_from, const Vector3 &p_to, const Vector3 &p_v0, const Vector3 &p_v1, const Vector3 &p_v2, Vector3 *r_res = nullptr) {
Vector3 rel = p_to - p_from;
Vector3 e1 = p_v1 - p_v0;
@ -262,7 +262,7 @@ public:
return false;
}
static inline bool segment_intersects_sphere(const Vector3 &p_from, const Vector3 &p_to, const Vector3 &p_sphere_pos, real_t p_sphere_radius, Vector3 *r_res = 0, Vector3 *r_norm = 0) {
static inline bool segment_intersects_sphere(const Vector3 &p_from, const Vector3 &p_to, const Vector3 &p_sphere_pos, real_t p_sphere_radius, Vector3 *r_res = nullptr, Vector3 *r_norm = nullptr) {
Vector3 sphere_pos = p_sphere_pos - p_from;
Vector3 rel = (p_to - p_from);
@ -298,7 +298,7 @@ public:
return true;
}
static inline bool segment_intersects_cylinder(const Vector3 &p_from, const Vector3 &p_to, real_t p_height, real_t p_radius, Vector3 *r_res = 0, Vector3 *r_norm = 0) {
static inline bool segment_intersects_cylinder(const Vector3 &p_from, const Vector3 &p_to, real_t p_height, real_t p_radius, Vector3 *r_res = nullptr, Vector3 *r_norm = nullptr) {
Vector3 rel = (p_to - p_from);
real_t rel_l = rel.length();

View file

@ -56,7 +56,7 @@ public:
/* intersections */
bool intersect_3(const Plane &p_plane1, const Plane &p_plane2, Vector3 *r_result = 0) const;
bool intersect_3(const Plane &p_plane1, const Plane &p_plane2, Vector3 *r_result = nullptr) const;
bool intersects_ray(const Vector3 &p_from, const Vector3 &p_dir, Vector3 *p_intersection) const;
bool intersects_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 *p_intersection) const;

View file

@ -142,13 +142,13 @@ template <typename T>
T *memnew_arr_template(size_t p_elements, const char *p_descr = "") {
if (p_elements == 0)
return 0;
return nullptr;
/** overloading operator new[] cannot be done , because it may not return the real allocated address (it may pad the 'element count' before the actual array). Because of that, it must be done by hand. This is the
same strategy used by std::vector, and the Vector class, so it should be safe.*/
size_t len = sizeof(T) * p_elements;
uint64_t *mem = (uint64_t *)Memory::alloc_static(len, true);
T *failptr = 0; //get rid of a warning
T *failptr = nullptr; //get rid of a warning
ERR_FAIL_COND_V(!mem, failptr);
*(mem - 1) = p_elements;

View file

@ -85,7 +85,7 @@ class StringName {
StringName(_Data *p_data) { _data = p_data; }
public:
operator const void *() const { return (_data && (_data->cname || !_data->name.empty())) ? (void *)1 : 0; }
operator const void *() const { return (_data && (_data->cname || !_data->name.empty())) ? (void *)1 : nullptr; }
bool operator==(const String &p_name) const;
bool operator==(const char *p_name) const;

View file

@ -477,6 +477,6 @@ ShaderGlobalsEditor::ShaderGlobalsEditor() {
interface->connect("var_changed", Callable(this, "_changed"));
}
ShaderGlobalsEditor::~ShaderGlobalsEditor() {
inspector->edit(NULL);
inspector->edit(nullptr);
memdelete(interface);
}

View file

@ -363,7 +363,7 @@ MainLoop *test() {
Set<String> types;
types.insert("spatial");
Error err = sl.compile(code, dt, rm, types, NULL);
Error err = sl.compile(code, dt, rm, types, nullptr);
if (err) {

View file

@ -1289,7 +1289,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
gdfs->state.instance = p_instance;
p_instance->pending_func_states.add(&gdfs->instances_list);
} else {
gdfs->state.instance = NULL;
gdfs->state.instance = nullptr;
}
}
#ifdef DEBUG_ENABLED

View file

@ -295,7 +295,7 @@ void CSharpLanguage::get_reserved_words(List<String> *p_words) const {
"when",
"where",
"yield",
0
nullptr
};
const char **w = _reserved_words;

View file

@ -78,7 +78,7 @@ Error get_assembly_dependencies(GDMonoAssembly *p_assembly, const Vector<String>
if (r_assembly_dependencies.has(ref_name))
continue;
GDMonoAssembly *ref_assembly = NULL;
GDMonoAssembly *ref_assembly = nullptr;
{
MonoAssemblyName *ref_aname = mono_assembly_name_new("A"); // We can't allocate an empty MonoAssemblyName, hence "A"

View file

@ -87,6 +87,6 @@ EditorDebuggerServerWebSocket::~EditorDebuggerServerWebSocket() {
}
EditorDebuggerServer *EditorDebuggerServerWebSocket::create(const String &p_protocol) {
ERR_FAIL_COND_V(p_protocol != "ws://", NULL);
ERR_FAIL_COND_V(p_protocol != "ws://", nullptr);
return memnew(EditorDebuggerServerWebSocket);
}

View file

@ -123,12 +123,12 @@ RemoteDebuggerPeerWebSocket::RemoteDebuggerPeerWebSocket(Ref<WebSocketPeer> p_pe
}
RemoteDebuggerPeer *RemoteDebuggerPeerWebSocket::create(const String &p_uri) {
ERR_FAIL_COND_V(!p_uri.begins_with("ws://") && !p_uri.begins_with("wss://"), NULL);
ERR_FAIL_COND_V(!p_uri.begins_with("ws://") && !p_uri.begins_with("wss://"), nullptr);
RemoteDebuggerPeerWebSocket *peer = memnew(RemoteDebuggerPeerWebSocket);
Error err = peer->connect_to_host(p_uri);
if (err != OK) {
memdelete(peer);
return NULL;
return nullptr;
}
return peer;
}

View file

@ -544,7 +544,7 @@ public:
void clear();
TreeItem *create_item(TreeItem *p_parent = 0, int p_idx = -1);
TreeItem *create_item(TreeItem *p_parent = nullptr, int p_idx = -1);
TreeItem *get_root();
TreeItem *get_last_item();

View file

@ -206,7 +206,7 @@ void ShaderGlobalsOverride::_get_property_list(List<PropertyInfo> *p_list) const
Override o;
o.in_use = false;
Callable::CallError ce;
o.override = Variant::construct(pinfo.type, NULL, 0, ce);
o.override = Variant::construct(pinfo.type, nullptr, 0, ce);
overrides[variables[i]] = o;
}

View file

@ -4896,7 +4896,7 @@ void RasterizerStorageRD::_update_decal_atlas() {
Vector<DecalAtlas::SortItem> itemsv;
itemsv.resize(decal_atlas.textures.size());
int base_size = 8;
const RID *K = NULL;
const RID *K = nullptr;
int idx = 0;
while ((K = decal_atlas.textures.next(K))) {
@ -5050,7 +5050,7 @@ void RasterizerStorageRD::_update_decal_atlas() {
RD::DrawListID draw_list = RD::get_singleton()->draw_list_begin(mm.fb, RD::INITIAL_ACTION_CLEAR, RD::FINAL_ACTION_READ, RD::INITIAL_ACTION_DROP, RD::FINAL_ACTION_DISCARD, cc);
const RID *K = NULL;
const RID *K = nullptr;
while ((K = decal_atlas.textures.next(K))) {
DecalAtlas::Texture *t = decal_atlas.textures.getptr(*K);
Texture *src_tex = texture_owner.getornull(*K);
@ -5459,7 +5459,7 @@ Vector<StringName> RasterizerStorageRD::global_variable_get_list() const {
ERR_FAIL_V_MSG(Vector<StringName>(), "This function should never be used outside the editor, it can severely damage performance.");
}
const StringName *K = NULL;
const StringName *K = nullptr;
Vector<StringName> names;
while ((K = global_variables.variables.next(K))) {
names.push_back(*K);