[PATCH] D151529: [NFC][CLANG] Fix nullptr dereference issue in DeduceTemplateArgumentsByTypeMatch()

Soumi Manna via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue May 30 08:42:28 PDT 2023


Manna updated this revision to Diff 526647.
Manna added a comment.

Thank you @erichkeane for reviews!

I have updated assert message.


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

https://reviews.llvm.org/D151529

Files:
  clang/lib/Sema/SemaTemplateDeduction.cpp


Index: clang/lib/Sema/SemaTemplateDeduction.cpp
===================================================================
--- clang/lib/Sema/SemaTemplateDeduction.cpp
+++ clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -1703,10 +1703,12 @@
       if (!IAA)
         return Sema::TDK_NonDeducedMismatch;
 
+      const auto *IAP = S.Context.getAsIncompleteArrayType(P);
+      assert(IAP && "Template parameter not of incomplete array type");
+
       return DeduceTemplateArgumentsByTypeMatch(
-          S, TemplateParams,
-          S.Context.getAsIncompleteArrayType(P)->getElementType(),
-          IAA->getElementType(), Info, Deduced, TDF & TDF_IgnoreQualifiers);
+          S, TemplateParams, IAP->getElementType(), IAA->getElementType(), Info,
+          Deduced, TDF & TDF_IgnoreQualifiers);
     }
 
     //     T [integer-constant]


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D151529.526647.patch
Type: text/x-patch
Size: 833 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230530/e328d541/attachment.bin>


More information about the cfe-commits mailing list