[PATCH] D134180: [clang] Fix a nullptr-access crash in CheckTemplateArgument.

Adam Czachorowski via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 19 06:32:52 PDT 2022


adamcz accepted this revision.
adamcz added inline comments.
This revision is now accepted and ready to land.


================
Comment at: clang/lib/Sema/SemaTemplate.cpp:6960
+    if (ParamType.isNull())
+      return ExprError();
     // CheckNonTypeTemplateParameterType will produce a diagnostic if there's
----------------
So this can only happen when Result is TDK_AlreadyDiagnosed above, right? In that case, I would handle such case explicitly in the code above, like:
if (Result == TDK_AlreadyDiagnosed) return ExprError();
else if (Result != TDK_Success) { ... }
Seems like it would be more readable. 

However, I am definitely not opposed to keeping this check here as well, in case there are other ways to get into this situation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134180



More information about the cfe-commits mailing list