[PATCH] D139986: [WIP][clang][TypePrinter] Teach isSubstitutedDefaultArgument about integral types

Michael Buch via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 15 09:05:20 PST 2022


Michael137 created this revision.
Michael137 added a reviewer: aprantl.
Herald added a project: All.
Michael137 updated this revision to Diff 483168.
Michael137 added a comment.
Michael137 updated this revision to Diff 483184.
Michael137 published this revision for review.
Michael137 added a subscriber: rsmith.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

- Simplify


Michael137 added a comment.

- Fix another test



================
Comment at: clang/test/CodeGenObjCXX/encode.mm:93-94
   // FIXME: This difference is due to D76801. It was probably an unintentional change. Maybe we want to undo it?
-  // CHECKCXX98: @_ZN11rdar93574002ggE ={{.*}} constant [49 x i8] c"{vector<float, rdar9357400::fixed<4, -1> >=[4f]}\00"
-  // CHECKCXX20: @_ZN11rdar93574002ggE ={{.*}} constant [48 x i8] c"{vector<float, rdar9357400::fixed<4, -1>>=[4f]}\00"
+  // CHECKCXX98: @_ZN11rdar93574002ggE ={{.*}} constant [45 x i8] c"{vector<float, rdar9357400::fixed<4> >=[4f]}\00"
+  // CHECKCXX20: @_ZN11rdar93574002ggE ={{.*}} constant [44 x i8] c"{vector<float, rdar9357400::fixed<4>>=[4f]}\00"
   extern const char gg[] = @encode(vector4f);
----------------
@aprantl any idea if this is good/OK? (I guess it probably is - but maybe these strings were never meant to ignore/suppress default arguments of any kind? or maybe this is an ABI sort of thing where it suppressing some but not others is now unchangeable?)


================
Comment at: clang/test/CodeGenObjCXX/encode.mm:93-94
   // FIXME: This difference is due to D76801. It was probably an unintentional change. Maybe we want to undo it?
-  // CHECKCXX98: @_ZN11rdar93574002ggE ={{.*}} constant [49 x i8] c"{vector<float, rdar9357400::fixed<4, -1> >=[4f]}\00"
-  // CHECKCXX20: @_ZN11rdar93574002ggE ={{.*}} constant [48 x i8] c"{vector<float, rdar9357400::fixed<4, -1>>=[4f]}\00"
+  // CHECKCXX98: @_ZN11rdar93574002ggE ={{.*}} constant [45 x i8] c"{vector<float, rdar9357400::fixed<4> >=[4f]}\00"
+  // CHECKCXX20: @_ZN11rdar93574002ggE ={{.*}} constant [44 x i8] c"{vector<float, rdar9357400::fixed<4>>=[4f]}\00"
   extern const char gg[] = @encode(vector4f);
----------------
dblaikie wrote:
> @aprantl any idea if this is good/OK? (I guess it probably is - but maybe these strings were never meant to ignore/suppress default arguments of any kind? or maybe this is an ABI sort of thing where it suppressing some but not others is now unchangeable?)
Good point. There was a thread on the cfe mailing list a while ago about the last time this broke: https://lists.llvm.org/pipermail/cfe-dev/2020-November/067194.html

This was @rsmith's stance:
```
I think some of the other recent TypePrinter changes might also risk
changing the @encode output. Generally it seems unwise for @encode to be
using the type pretty-printer if it wants to be ABI-stable; I don't think
it's reasonable to expect any guarantees as to the stability of
pretty-printed type names. I think USR generation suffers from similar
problems; it too uses the type pretty-printer to generate
supposedly-ABI-stable keys in at least some cases.
```


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 `TemplateUtils`
from with the DWARF CodeGen component.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D139986

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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D139986.483184.patch
Type: text/x-patch
Size: 9204 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20221215/d519b108/attachment.bin>


More information about the cfe-commits mailing list