[all-commits] [llvm/llvm-project] 59048f: [clang] Implement evaluation context for checking ...

Matheus Izvekov via All-commits all-commits at lists.llvm.org
Thu Feb 20 10:25:07 PST 2025


  Branch: refs/heads/users/mizvekov/clang-check-template-parameter-eval-context
  Home:   https://github.com/llvm/llvm-project
  Commit: 59048ff6891ecf1286779569165ebff855245684
      https://github.com/llvm/llvm-project/commit/59048ff6891ecf1286779569165ebff855245684
  Author: Matheus Izvekov <mizvekov at gmail.com>
  Date:   2025-02-20 (Thu, 20 Feb 2025)

  Changed paths:
    M clang/docs/ReleaseNotes.rst
    M clang/include/clang/Basic/DiagnosticSemaKinds.td
    M clang/include/clang/Sema/Sema.h
    M clang/lib/Frontend/FrontendActions.cpp
    M clang/lib/Sema/SemaInit.cpp
    M clang/lib/Sema/SemaLambda.cpp
    M clang/lib/Sema/SemaLookup.cpp
    M clang/lib/Sema/SemaTemplate.cpp
    M clang/lib/Sema/SemaTemplateDeduction.cpp
    M clang/lib/Sema/SemaTemplateInstantiate.cpp
    M clang/test/AST/ByteCode/cxx1z.cpp
    M clang/test/AST/ByteCode/cxx20.cpp
    M clang/test/AST/ByteCode/cxx98.cpp
    M clang/test/CXX/basic/basic.lookup/basic.lookup.unqual/p7.cpp
    M clang/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp
    M clang/test/CXX/drs/cwg0xx.cpp
    M clang/test/CXX/drs/cwg10xx.cpp
    M clang/test/CXX/drs/cwg13xx.cpp
    M clang/test/CXX/drs/cwg18xx.cpp
    M clang/test/CXX/drs/cwg1xx.cpp
    M clang/test/CXX/drs/cwg20xx.cpp
    M clang/test/CXX/drs/cwg21xx.cpp
    M clang/test/CXX/drs/cwg3xx.cpp
    M clang/test/CXX/drs/cwg4xx.cpp
    M clang/test/CXX/drs/cwg6xx.cpp
    M clang/test/CXX/expr/expr.const/p3-0x.cpp
    M clang/test/CXX/expr/expr.prim/expr.prim.req/type-requirement.cpp
    M clang/test/CXX/temp/temp.arg/temp.arg.nontype/p1-11.cpp
    M clang/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp
    M clang/test/CXX/temp/temp.arg/temp.arg.nontype/p5.cpp
    M clang/test/CXX/temp/temp.arg/temp.arg.template/p3-0x.cpp
    M clang/test/CXX/temp/temp.arg/temp.arg.template/p3-2a.cpp
    M clang/test/CXX/temp/temp.arg/temp.arg.type/p2.cpp
    M clang/test/CXX/temp/temp.decls/temp.class.spec/p8-1y.cpp
    M clang/test/CXX/temp/temp.decls/temp.variadic/fixed-expansion.cpp
    M clang/test/CXX/temp/temp.decls/temp.variadic/multi-level-substitution.cpp
    M clang/test/CXX/temp/temp.deduct/p9.cpp
    M clang/test/CXX/temp/temp.param/p1.cpp
    M clang/test/CXX/temp/temp.param/p12.cpp
    M clang/test/CXX/temp/temp.param/p15-cxx0x.cpp
    M clang/test/CXX/temp/temp.param/p8-cxx20.cpp
    M clang/test/CXX/temp/temp.res/temp.dep/temp.dep.constexpr/p2.cpp
    M clang/test/CXX/temp/temp.spec/cxx1y-variable-template-no-body.cpp
    M clang/test/CXX/temp/temp.spec/part.spec.cpp
    M clang/test/CXX/temp/temp.spec/temp.expl.spec/p20.cpp
    M clang/test/Misc/integer-literal-printing.cpp
    M clang/test/Modules/malformed-constraint-template-non-type-parm-decl.cpp
    M clang/test/Modules/missing-body-in-import.cpp
    M clang/test/Modules/template-default-args.cpp
    M clang/test/Parser/MicrosoftExtensions.cpp
    M clang/test/Parser/cxx-template-argument.cpp
    M clang/test/Parser/cxx-template-template-recovery.cpp
    M clang/test/Parser/cxx1z-class-template-argument-deduction.cpp
    M clang/test/SemaCXX/access-base-class.cpp
    M clang/test/SemaCXX/alias-template.cpp
    M clang/test/SemaCXX/anonymous-struct.cpp
    M clang/test/SemaCXX/constant-expression-cxx11.cpp
    M clang/test/SemaCXX/constant-expression.cpp
    M clang/test/SemaCXX/cxx1z-noexcept-function-type.cpp
    M clang/test/SemaCXX/cxx2a-consteval.cpp
    M clang/test/SemaCXX/cxx98-compat-flags.cpp
    M clang/test/SemaCXX/cxx98-compat.cpp
    M clang/test/SemaCXX/implicit-member-functions.cpp
    M clang/test/SemaCXX/lambda-expressions.cpp
    M clang/test/SemaCXX/make_integer_seq.cpp
    M clang/test/SemaCXX/type-trait-common-type.cpp
    M clang/test/SemaCXX/undefined-internal.cpp
    M clang/test/SemaCXX/warn-deprecated-specializations-in-system-headers.cpp
    M clang/test/SemaHLSL/BuiltIns/RWBuffers.hlsl
    M clang/test/SemaHLSL/BuiltIns/StructuredBuffers.hlsl
    M clang/test/SemaObjCXX/parameterized_classes_subst.mm
    M clang/test/SemaTemplate/alias-templates.cpp
    M clang/test/SemaTemplate/cwg2398.cpp
    M clang/test/SemaTemplate/default-arguments.cpp
    M clang/test/SemaTemplate/instantiate-member-pointers.cpp
    M clang/test/SemaTemplate/instantiate-template-template-parm.cpp
    M clang/test/SemaTemplate/instantiation-default-1.cpp
    M clang/test/SemaTemplate/instantiation-default-2.cpp
    M clang/test/SemaTemplate/instantiation-dependence.cpp
    M clang/test/SemaTemplate/instantiation-depth-defarg.cpp
    M clang/test/SemaTemplate/instantiation-depth-exception-spec.cpp
    M clang/test/SemaTemplate/instantiation-depth.cpp
    M clang/test/SemaTemplate/ms-unqualified-base-class.cpp
    M clang/test/SemaTemplate/nested-template.cpp
    M clang/test/SemaTemplate/partial-spec-instantiate.cpp
    M clang/test/SemaTemplate/recovery-crash.cpp
    M clang/test/SemaTemplate/stack-exhaustion.cpp
    M clang/test/SemaTemplate/temp_arg.cpp
    M clang/test/SemaTemplate/temp_arg_nontype.cpp
    M clang/test/SemaTemplate/temp_arg_nontype_cxx11.cpp
    M clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
    M clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
    M clang/test/SemaTemplate/temp_arg_nontype_cxx2c.cpp
    M clang/test/SemaTemplate/temp_arg_template.cpp
    M clang/test/SemaTemplate/temp_arg_template_p0522.cpp
    M clang/test/SemaTemplate/temp_arg_type.cpp

  Log Message:
  -----------
  [clang] Implement evaluation context for checking template parameters

Instead of manually adding a note pointing to the relevant template
parameter to every relevant error, which is very easy to miss,
this patch adds a new instantiation context note, so that this
can work using RAII magic.

This fixes a bunch of places where these notes were missing, and is
more future-proof.

Some diagnostics are reworked to make better use of this note:
- Errors about missing template arguments now refer to the parameter
  which is missing an argument.
- Template Template parameter mismatches now refer to template
  parameters as parameters instead of arguments.

It's likely this will add the note to some diagnostics where the
parameter is not super relevant, but this can be reworked with time
and the decrease in maintenance burden makes up for it.

This bypasses the templight dumper for the new context entry, as the
tests are very hard to update.

This depends on #125453, which is needed to avoid losing the context
note for errors occuring during template argument deduction.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list