tnode_t::try_get_child() to properly implement null check.

try_get_child() was taking the address of a reference; clang was thereby
assuming it could not be null and so was dropping the null check. Ensure
we do not dereference a null pointer.

Fixes #4678
This commit is contained in:
ridiculousfish 2018-01-28 15:07:19 -08:00
parent c92bb703dc
commit 5b3729842c

View file

@ -143,7 +143,7 @@ class tnode_t {
static_assert(child_type_possible_at_index<Type, ChildType, Index>(),
"Cannot contain a child of this type");
const parse_node_t *child = nullptr;
if (nodeptr) child = &get_child_node<Index>();
if (nodeptr) child = tree->get_child(*nodeptr, Index);
if (child && child->type == ChildType::token) return {tree, child};
return {};
}