[PATCH] D77598: Integral template argument suffix and cast printing

David Blaikie via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Oct 10 09:36:07 PDT 2021


dblaikie added inline comments.


================
Comment at: clang/lib/AST/DeclPrinter.cpp:1101
       Out << ", ";
-    Args[I].print(Policy, Out);
+    if (TemplOverloaded || !Params)
+      Args[I].print(Policy, Out, /*IncludeType*/ true);
----------------
dblaikie wrote:
> Looks like this (& the `TemplOverloaded` in the other function, below) is undertested.
> 
> Hardcoding:
> true in this function results in no failures
> false in this function results in 1 failure in `SemaTemplate/temp_arg_enum_printing.cpp`
>  - this failure, at least to me, seems to not have much to do with overloading - at least syntactically foo<2> (where the parameter is an enum type) doesn't compile, not due to any overloading ambiguity, but due to a lack of implicit conversion from int to the enum type, I think? and the example doesn't look like it involves any overloading... 
> 
> true in the other overload results in no failures
> false in the other overload results in no failures
> 
> I came across this because I was confused by how this feature works - when the suffixes are used and when they are not to better understand the implications this might have for debug info. (though I'm still generally leaning towards just always putting the suffixes on for debug info)
> 
> @rsmith - could you give an example of what you meant by passing in a parameter when the template is overloaded & that should use the suffix? My simple examples, like this:
> ```
> template<unsigned V>
> void f1() { }
> template<long L>
> void f1() { }
> int main() {
>   f1<3U>();
> }
> ```
> That's just ambiguous, apparently, and doesn't compile despite the type suffix on the literal. If I put a parameter on one of the functions it doesn't seem to trigger the "TemplOverloaded" case - both instantiations still get un-suffixed names "f1<3>"... 
Ping on this (posted https://reviews.llvm.org/D111477 for some further discussion on the debug info side of things)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D77598/new/

https://reviews.llvm.org/D77598



More information about the cfe-commits mailing list