[all-commits] [llvm/llvm-project] 98afcb: [clang][AST][NFC] Expose clang::isSubstitutedDefau...

Michael137 via All-commits all-commits at lists.llvm.org
Fri Dec 16 03:39:18 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 98afcbab66505661045dccb85ee9acdbf9410047
      https://github.com/llvm/llvm-project/commit/98afcbab66505661045dccb85ee9acdbf9410047
  Author: Michael Buch <michaelbuch12 at gmail.com>
  Date:   2022-12-16 (Fri, 16 Dec 2022)

  Changed paths:
    M clang/include/clang/AST/Type.h
    M clang/lib/AST/TypePrinter.cpp

  Log Message:
  -----------
  [clang][AST][NFC] Expose clang::isSubstitutedDefaultArgument to clang/AST consumers

**Summary**
A use-case has come up in DWARF CodeGen where we want to determine
whether a particular template argument matches the default template
parameter declaration.

Re-using this TypePrinter component there allows us to avoid duplicating
most of this code and immediately allows us to cover a wider range
of use-cases than the DWARF CodeGen does today.


  Commit: 1706f34d604ec304af58a7b95dbc127bd77e17fa
      https://github.com/llvm/llvm-project/commit/1706f34d604ec304af58a7b95dbc127bd77e17fa
  Author: Michael Buch <michaelbuch12 at gmail.com>
  Date:   2022-12-16 (Fri, 16 Dec 2022)

  Changed paths:
    M clang/lib/AST/TypePrinter.cpp
    M clang/test/CXX/temp/temp.arg/temp.arg.template/p3-0x.cpp
    M clang/test/CodeGenObjCXX/encode.mm
    M clang/test/Misc/diag-template-diffing.cpp
    M clang/test/Misc/diag-template.cpp
    M clang/test/SemaCUDA/device-use-host-var.cu
    M clang/test/SemaCXX/co_await-range-for-exp-namespace.cpp
    M clang/test/SemaCXX/co_await-range-for.cpp
    M clang/test/SemaCXX/coroutines-exp-namespace.cpp
    M clang/test/SemaCXX/coroutines.cpp
    M clang/test/SemaCXX/cxx11-call-to-deleted-constructor.cpp
    M clang/test/SemaTemplate/deduction-guide.cpp
    M clang/test/SemaTemplate/dependent-names.cpp

  Log Message:
  -----------
  [clang][TypePrinter] Teach isSubstitutedDefaultArgument about integral types

This patch handles default integral non-type template parameters.

After this patch the clang TypePrinter will omit default integral
template arguments when the `PrintingPolicy::SuppressDefaultTemplateArgs`
option is specified and sets us up to be able to re-use
`clang::isSubstitutedDefaultArgument` from the DWARF CodeGen
component.

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


  Commit: 8d3843badb8a32a56531e383a2a9eb5b07ae8b0d
      https://github.com/llvm/llvm-project/commit/8d3843badb8a32a56531e383a2a9eb5b07ae8b0d
  Author: Michael Buch <michaelbuch12 at gmail.com>
  Date:   2022-12-16 (Fri, 16 Dec 2022)

  Changed paths:
    M clang/lib/CodeGen/CGDebugInfo.cpp
    M clang/test/CodeGenCXX/debug-info-template-parameter.cpp

  Log Message:
  -----------
  [clang][DebugInfo] Simplify logic to determine DW_AT_default_value for template parameters

DWARFv5 added support for labelling template parameters with
DW_AT_default_value to indicate whether the particular instantiation
defaulted parameter. The current implementation only supports a limited
set of possible cases. Namely for non-value-dependent integral template
parameters and simple type template parameters.

Useful cases that don't work are:
1. Type template parameters with defaults that are
   themselves templates. E.g.,
```
template<typename T1, typename T2 = Foo<T1>> class C1;
template<typename T = Foo<int>> class C2;
etc.
```
2. Template template parameters

`clang::isSubstitutedDefaultArgument` already implement the required logic
to determine whether a template argument is defaulted. This patch re-uses
this logic for DWARF CodeGen.

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


  Commit: 2dff41c320fcf6230bea68568b14ca101c96d187
      https://github.com/llvm/llvm-project/commit/2dff41c320fcf6230bea68568b14ca101c96d187
  Author: Michael Buch <michaelbuch12 at gmail.com>
  Date:   2022-12-16 (Fri, 16 Dec 2022)

  Changed paths:
    M llvm/include/llvm/IR/DIBuilder.h
    M llvm/lib/IR/DIBuilder.cpp

  Log Message:
  -----------
  [llvm][DebugInfo] Add IsDefault parameter to DIBuilder::createTemplateTemplateParameter

This is in preparation for Clang to emit `DW_AT_default_value`
for defaulted template template parameters.

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


  Commit: 2c22cfd4c95606adec311dece051e95e86e3f0f3
      https://github.com/llvm/llvm-project/commit/2c22cfd4c95606adec311dece051e95e86e3f0f3
  Author: Michael Buch <michaelbuch12 at gmail.com>
  Date:   2022-12-16 (Fri, 16 Dec 2022)

  Changed paths:
    M clang/lib/CodeGen/CGDebugInfo.cpp
    M clang/test/CodeGenCXX/debug-info-template-parameter.cpp

  Log Message:
  -----------
  [clang][DebugInfo] Add DW_AT_default_value support for template template parameters

After this patch, in the following snippet:
```
template <typename T> Foo {};

template <template <typename T> class CT = Foo> Bar {};

Bar<> b;
```

The debug-info entry for the `CT` template parameter will have
a `DW_AT_default_value (true)` attached to it.

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


Compare: https://github.com/llvm/llvm-project/compare/07e1c9978d56...2c22cfd4c956


More information about the All-commits mailing list