<div dir="ltr"><div>Hi,</div><div><br></div><div>My question is motivated by <a href="https://reviews.llvm.org/D36368">https://reviews.llvm.org/D36368</a> (current WIP diff - <a href="https://github.com/llvm/llvm-project/compare/main...reikdas:array-axel">https://github.com/llvm/llvm-project/compare/main...reikdas:array-axel</a>).</div><div><br></div><div>For the following code snippet - <br></div><div><br></div><div><span style="font-family:monospace">constexpr const char **kZero[] = {};</span></div><div><span style="font-family:monospace"><br></span></div><div><span style="font-family:monospace">// Let's call this (1)<br></span></div><div><span style="font-family:monospace">template <const char *const *const *, typename T> class Jolumn {};<br></span></div><div><span style="font-family:monospace">Jolumn<kZero, double>();</span></div><div><span style="font-family:monospace"><br></span></div><div><span style="font-family:monospace">// Let's call this (2)<br></span></div><div><span style="font-family:monospace">template <const char** const (*)[0], typename T> class Iolumn {};</span></div><div><span style="font-family:monospace">Iolumn<&kZero, double>();</span><br></div><div><br></div><div>I want to be able to detect if an ampersand should be printed for (1) and (2) (it shouldn't be for (1) and should be for (2)).<br></div><div><br></div><div>Looking at the type dumps,</div><div>the parameter type(the first parameter type for both class Jolumn and class Iolumn) is represented as - <br></div><div><span style="font-family:monospace">ConstantArrayType 0x560d4eab8000 'const char **const [0]' 0 <br>`-QualType 0x560d4eab7de1 'const char **const' const<br>  `-PointerType 0x560d4eab7de0 'const char **'<br>    `-PointerType 0x560d4ea72930 'const char *'<br>      `-QualType 0x560d4ea71e61 'const char' const<br>        `-BuiltinType 0x560d4ea71e60 'char'</span></div><div><br></div><div>the argument type for kZero in (1) is represented as -</div><div><span style="font-family:monospace">PointerType 0x5560fe683130 'const char *const *const *'<br>`-QualType 0x5560fe683101 'const char *const *const' const<br>  `-PointerType 0x5560fe683100 'const char *const *'<br>    `-QualType 0x5560fe63d951 'const char *const' const<br>      `-PointerType 0x5560fe63d950 'const char *'<br>        `-QualType 0x5560fe63ce81 'const char' const<br>          `-BuiltinType 0x5560fe63ce80 'char'</span></div><div><br></div><div>the argument type for &kZero in (2) is represented as -</div><div><span style="font-family:monospace">PointerType 0x560d4eab8100 'const char **const (*)[0]'<br>`-QualType 0x560d4eab7fc1 'const char **const[0]' const<br>  `-ConstantArrayType 0x560d4eab7fc0 'const char **[0]' 0 <br>    `-PointerType 0x560d4eab7de0 'const char **'<br>      `-PointerType 0x560d4ea72930 'const char *'<br>        `-QualType 0x560d4ea71e61 'const char' const<br>          `-BuiltinType 0x560d4ea71e60 'char'</span></div><div><br></div><div>From the clang::Type, how do I detect that an ampersand should not be printed for the argument kZero (1), but should be printed for the argument &kZero (2)?<br></div><div><br></div><div>Comparing the pointer depths of the two as suggested in the review or comparing the innermost clang::PointerType give the same result for both the argument types.<br></div><div>I also cycled through the relevant boolean methods in <a href="https://clang.llvm.org/doxygen/classclang_1_1Type.html">https://clang.llvm.org/doxygen/classclang_1_1Type.html</a>, but the methods gave the same results for both the argument types.</div><div><br></div><div>I would really appreciate any help. <br></div><div><br></div><div>Thanks!<br></div><div><br></div><br>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div>Pratyush Das<br></div></div></div></div></div></div>