[PATCH] D108481: Avoid nullptr dereferencing of 'Constraint'

Sindhu Chittireddy via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 23 12:55:23 PDT 2021


schittir updated this revision to Diff 368183.
schittir added a comment.

1. Removed the useless assert on TC.
2. Retained the change from `cast_or_null` to `cast`


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D108481/new/

https://reviews.llvm.org/D108481

Files:
  clang/lib/Sema/SemaConcept.cpp


Index: clang/lib/Sema/SemaConcept.cpp
===================================================================
--- clang/lib/Sema/SemaConcept.cpp
+++ clang/lib/Sema/SemaConcept.cpp
@@ -1062,11 +1062,8 @@
   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(


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D108481.368183.patch
Type: text/x-patch
Size: 775 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210823/3323cd09/attachment.bin>


More information about the cfe-commits mailing list