[PATCH] D69950: Reapply "Fix crash on switch conditions of non-integer types in templates"

Elizabeth Andrews via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 7 08:18:46 PST 2019


eandrews created this revision.
eandrews added reviewers: rnk, gribozavr, gribozavr2, Szelethus, erichkeane, riccibruno.

This patch reapplies D61027 <https://reviews.llvm.org/D61027>. When D61027 <https://reviews.llvm.org/D61027> was previously committed (76945821b9cad3), buildbots failed due to clang-tidy test fails. The test fails are because some errors in templates are now diagnosed earlier (does not wait till instantiation).  I have modified the tests to add checks for these diagnostics/prevent these diagnostics.

Since I have not worked on clang-tidy in the past, I am hoping someone with more familiarity in this area can take a look and review my changes. There are no code changes in this second attempt (compared to D61027 <https://reviews.llvm.org/D61027>). I have only modified failing tests.

Summary of code changes (pasted from D61027 <https://reviews.llvm.org/D61027>) is below -

Clang currently crashes for switch statements inside a template when the condition is a non-integer field member because contextual implicit conversion is skipped when parsing the condition. This conversion is however later checked in an assert when the case statement is handled. The conversion is skipped when parsing the condition because the field member is set as type-dependent based on its containing class. This patch sets the type dependency based on the field's type instead. This patch fixes Bug 40982.


https://reviews.llvm.org/D69950

Files:
  clang-tools-extra/test/clang-tidy/checkers/bugprone-string-integer-assignment.cpp
  clang-tools-extra/test/clang-tidy/checkers/misc-unused-parameters.cpp
  clang/lib/AST/Expr.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/SemaCXX/constant-expression-cxx2a.cpp
  clang/test/SemaTemplate/dependent-names.cpp
  clang/test/SemaTemplate/enum-argument.cpp
  clang/test/SemaTemplate/member-access-expr.cpp
  clang/test/SemaTemplate/non-integral-switch-cond.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D69950.228248.patch
Type: text/x-patch
Size: 5538 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20191107/05a550fe/attachment.bin>


More information about the cfe-commits mailing list