Skip to content

Commit 98339f1

Browse files
schittirAaronBallman
authored andcommitted
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<>'.
1 parent ebf3537 commit 98339f1

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

clang/lib/Sema/SemaConcept.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,11 +1062,8 @@ ReturnTypeRequirement(TemplateParameterList *TPL) :
10621062
assert(TPL->size() == 1);
10631063
const TypeConstraint *TC =
10641064
cast<TemplateTypeParmDecl>(TPL->getParam(0))->getTypeConstraint();
1065-
assert(TC &&
1066-
"TPL must have a template type parameter with a type constraint");
10671065
auto *Constraint =
1068-
cast_or_null<ConceptSpecializationExpr>(
1069-
TC->getImmediatelyDeclaredConstraint());
1066+
cast<ConceptSpecializationExpr>(TC->getImmediatelyDeclaredConstraint());
10701067
bool Dependent =
10711068
Constraint->getTemplateArgsAsWritten() &&
10721069
TemplateSpecializationType::anyInstantiationDependentTemplateArguments(

0 commit comments

Comments
 (0)