[PATCH] D111283: [clang] template / auto deduction deduces common sugar

David Rector via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 13 06:05:55 PDT 2022


davrec added inline comments.


================
Comment at: clang/lib/AST/ASTContext.cpp:12367
+  case Type::Class:                                                            \
+    llvm_unreachable("Unexpected " Kind ": " #Class);
+
----------------
mizvekov wrote:
> davrec wrote:
> > Could we just return `X` here? Would that just default to the old behavior instead of crashing whenever unforeseen cases arise?  
> No, I think we should enforce the invariants and make sure we are handling everything that can be handled.
> 
> Classing `TemplateTypeParm`  as sugar-free was what was wrong and we missed this on the review.
There might always going to be a few rare corner cases vulnerable to this though, particularly as more types are added and the people adding them don't pay strict attention to how to incorporate them here, and don't write the requisite tests (which seem very difficult to foresee and produce).  When those cases arise we will be crashing even though we could produce a perfectly good program with the intended semantics; the only thing that would suffer for most users is slightly less clear diagnostic messages for those rare cases.  I think it would be better to let those cases gradually percolate to our attention via bug reports concerning those diagnostics, rather than inconveniencing the user and demanding immediate attention via crashes.  Or am I missing something?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111283



More information about the cfe-commits mailing list