[all-commits] [llvm/llvm-project] e621da: [clang] Template Specialization Resugaring - TypeDecl

Matheus Izvekov via All-commits all-commits at lists.llvm.org
Fri Mar 21 11:09:30 PDT 2025


  Branch: refs/heads/users/mizvekov/clang-resugar-typedecl
  Home:   https://github.com/llvm/llvm-project
  Commit: e621da3ff081f9efee76ed83b1a21627e0904ed0
      https://github.com/llvm/llvm-project/commit/e621da3ff081f9efee76ed83b1a21627e0904ed0
  Author: Matheus Izvekov <mizvekov at gmail.com>
  Date:   2025-03-21 (Fri, 21 Mar 2025)

  Changed paths:
    M clang-tools-extra/clang-tidy/readability/QualifiedAutoCheck.cpp
    M clang/include/clang/AST/ASTContext.h
    M clang/include/clang/AST/Type.h
    M clang/include/clang/Sema/Sema.h
    M clang/lib/AST/ASTContext.cpp
    M clang/lib/Sema/SemaCXXScopeSpec.cpp
    M clang/lib/Sema/SemaCoroutine.cpp
    M clang/lib/Sema/SemaDecl.cpp
    M clang/lib/Sema/SemaDeclCXX.cpp
    M clang/lib/Sema/SemaTemplate.cpp
    M clang/lib/Sema/SemaTemplateDeduction.cpp
    M clang/lib/Sema/SemaType.cpp
    M clang/test/AST/ast-dump-openmp-begin-declare-variant_reference.cpp
    M clang/test/AST/ast-dump-template-name.cpp
    M clang/test/CXX/temp/temp.param/p15-cxx0x.cpp
    A clang/test/Sema/Resugar/resugar-types.cpp
    M lldb/test/API/commands/expression/import-std-module/iterator/TestIteratorFromStdModule.py

  Log Message:
  -----------
  [clang] Template Specialization Resugaring - TypeDecl

This is the introductory patch for a larger work which
intends to solve the long standing C++ issue with losing
type sugar when acessing template specializations.

The well known example here is specializing a template
with `std::string`, but getting diagnostics related to
`std::basic_string<char>` instead.

This implements a transform which, upon member access,
propagates type sugar from the naming context into the
accessed entity.

It also implements a single use of this transform,
resugaring access to TypeDecls.

For more details and discussion see:
https://discourse.llvm.org/t/rfc-improving-diagnostics-with-template-specialization-resugaring/64294

This is ready for review, although maybe not finished and
there is some more stuff that could be done either here
or in follow ups.

* Its worth exploring if a global resugaring cache is
  worthwhile, besides the current operational cache.
  A global cache would be more expensive to index, so there
  is a tradeoff, and maybe should be used of the whole
  result of the operation, while keeping the existing
  cache for sub-results.
* It would be ideal if the transform could live in ASTContext
  instead of Sema. There are a few dependencies that would
  have to be tackled.
  * Template arguments deduced for partial specializations.
  * Some kinds of type adjustments currently require Sema.

Differential Revision: https://reviews.llvm.org/D127695



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