forked from OSchip/llvm-project
Avoid nullptr dereferencing of 'Constraint'; NFC
Klocwork static code analysis exposed this bug: Pointer 'Constraint' returned from call to function 'cast_or_null<clang::ConceptSpecializationExpr,clang::Expr>' may be NULL and will be dereferenced in the statement following it Replace 'cast_or_null' with 'cast' so that the latter can assert when it encounters a NULL. This also removes an 'assert' that is covered by the previous call to 'cast<>'.
This commit is contained in:
parent
ebf35370ff
commit
98339f14a0
|
@ -1062,11 +1062,8 @@ ReturnTypeRequirement(TemplateParameterList *TPL) :
|
|||
assert(TPL->size() == 1);
|
||||
const TypeConstraint *TC =
|
||||
cast<TemplateTypeParmDecl>(TPL->getParam(0))->getTypeConstraint();
|
||||
assert(TC &&
|
||||
"TPL must have a template type parameter with a type constraint");
|
||||
auto *Constraint =
|
||||
cast_or_null<ConceptSpecializationExpr>(
|
||||
TC->getImmediatelyDeclaredConstraint());
|
||||
cast<ConceptSpecializationExpr>(TC->getImmediatelyDeclaredConstraint());
|
||||
bool Dependent =
|
||||
Constraint->getTemplateArgsAsWritten() &&
|
||||
TemplateSpecializationType::anyInstantiationDependentTemplateArguments(
|
||||
|
|
Loading…
Reference in New Issue