From bd7e8442b8c352823c144ea1dc50c4d37b6d9bb4 Mon Sep 17 00:00:00 2001 From: Ben Clayton Date: Wed, 5 May 2021 10:48:22 +0000 Subject: [PATCH] sem: Add constructor nullptr assertions Catch the nullptrs early. Change-Id: Ie8ee30355c79c6cbd589831f6587752b125d45c0 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49754 Commit-Queue: Ben Clayton Reviewed-by: Antonio Maiorano Reviewed-by: James Price --- src/sem/call_target.cc | 4 +++- src/sem/expression.cc | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/sem/call_target.cc b/src/sem/call_target.cc index 0ce35e9498..e3c87ff881 100644 --- a/src/sem/call_target.cc +++ b/src/sem/call_target.cc @@ -22,7 +22,9 @@ namespace tint { namespace sem { CallTarget::CallTarget(sem::Type* return_type, const ParameterList& parameters) - : return_type_(return_type), parameters_(parameters) {} + : return_type_(return_type), parameters_(parameters) { + TINT_ASSERT(return_type); +} CallTarget::~CallTarget() = default; diff --git a/src/sem/expression.cc b/src/sem/expression.cc index 254c559b88..83d16d7ca1 100644 --- a/src/sem/expression.cc +++ b/src/sem/expression.cc @@ -24,7 +24,9 @@ Expression::Expression(ast::Expression* declaration, Statement* statement) : declaration_(declaration), type_(type->UnwrapIfNeeded()), - statement_(statement) {} + statement_(statement) { + TINT_ASSERT(type_); +} } // namespace sem } // namespace tint