[all-commits] [llvm/llvm-project] bcd9ba: [clang] Track the templated entity in type substit...

Matheus Izvekov via All-commits all-commits at lists.llvm.org
Sat Oct 15 13:09:21 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: bcd9ba2b7e64f6ce54defd2fa73fc8e0fee5707c
      https://github.com/llvm/llvm-project/commit/bcd9ba2b7e64f6ce54defd2fa73fc8e0fee5707c
  Author: Matheus Izvekov <mizvekov at gmail.com>
  Date:   2022-10-15 (Sat, 15 Oct 2022)

  Changed paths:
    M clang-tools-extra/clang-tidy/hicpp/ExceptionBaseclassCheck.cpp
    M clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
    M clang-tools-extra/clangd/AST.cpp
    M clang/include/clang/AST/ASTContext.h
    M clang/include/clang/AST/ASTNodeTraverser.h
    M clang/include/clang/AST/DeclTemplate.h
    M clang/include/clang/AST/DeclarationName.h
    M clang/include/clang/AST/ExprCXX.h
    M clang/include/clang/AST/JSONNodeDumper.h
    M clang/include/clang/AST/PropertiesBase.td
    M clang/include/clang/AST/TemplateName.h
    M clang/include/clang/AST/TextNodeDumper.h
    M clang/include/clang/AST/Type.h
    M clang/include/clang/AST/TypeProperties.td
    M clang/include/clang/Sema/Template.h
    M clang/lib/AST/ASTContext.cpp
    M clang/lib/AST/ASTImporter.cpp
    M clang/lib/AST/ASTStructuralEquivalence.cpp
    M clang/lib/AST/DeclTemplate.cpp
    M clang/lib/AST/ExprCXX.cpp
    M clang/lib/AST/JSONNodeDumper.cpp
    M clang/lib/AST/ODRHash.cpp
    M clang/lib/AST/TemplateName.cpp
    M clang/lib/AST/TextNodeDumper.cpp
    M clang/lib/AST/Type.cpp
    M clang/lib/AST/TypePrinter.cpp
    M clang/lib/Sema/SemaConcept.cpp
    M clang/lib/Sema/SemaExprCXX.cpp
    M clang/lib/Sema/SemaTemplate.cpp
    M clang/lib/Sema/SemaTemplateDeduction.cpp
    M clang/lib/Sema/SemaTemplateInstantiate.cpp
    M clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
    M clang/lib/Sema/SemaTemplateVariadic.cpp
    M clang/lib/Sema/TreeTransform.h
    M clang/lib/Serialization/ASTReaderDecl.cpp
    M clang/lib/Serialization/ASTReaderStmt.cpp
    M clang/lib/Serialization/ASTWriterDecl.cpp
    M clang/lib/Serialization/ASTWriterStmt.cpp
    M clang/lib/StaticAnalyzer/Checkers/MismatchedIteratorChecker.cpp
    M clang/test/AST/ast-dump-openmp-begin-declare-variant_reference.cpp
    M clang/test/AST/ast-dump-template-decls.cpp
    M clang/test/AST/deduction-guides.cpp
    M clang/test/SemaTemplate/deduction-guide.cpp
    M clang/test/SemaTemplate/make_integer_seq.cpp
    M clang/test/SemaTemplate/type_pack_element.cpp
    M lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

  Log Message:
  -----------
  [clang] Track the templated entity in type substitution.

This is a change to how we represent type subsitution in the AST.
Instead of only storing the replaced type, we track the templated
entity we are substituting, plus an index.
We modify MLTAL to track the templated entity at each level.

Otherwise, it's much more expensive to go from the template parameter back
to the templated entity, and not possible to do in some cases, as when
we instantiate outer templates, parameters might still reference the
original entity.

This also allows us to very cheaply lookup the templated entity we saw in
the naming context and find the corresponding argument it was replaced
from, such as for implementing template specialization resugaring.

Signed-off-by: Matheus Izvekov <mizvekov at gmail.com>

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




More information about the All-commits mailing list