[PATCH] D36368: Fix type printing of array template args

Pratyush Das via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 29 03:30:26 PDT 2021


reikdas added inline comments.


================
Comment at: clang/lib/AST/TemplateBase.cpp:109
+  }
+  return true;
+}
----------------
rjmccall wrote:
> Hmm.  This seems unnecessarily complex.  Oh, and I think I suggested the comparison wrong for pointer depth.
> 
> Is there a case where the following doesn't work?
> 
> ```
> static unsigned getArrayDepth(QualType type) {
>   unsigned count = 0;
>   while (const auto *arrayType = type->getAsArrayTypeUnsafe()) {
>     count++;
>     type = arrayType->getElementType();
>   }
>   return count;
> }
> 
> static bool needsAmpersandOnTemplateArg(QualType paramType, QualType argType,
>                                         ASTContext &Ctx) {
>   if (!paramType->isPointerType())
>     return false;
>   if (argType->isFunctionType())
>     return true;
>   if (argType->isArrayType())
>     return getArrayDepth(argType) < getArrayDepth(paramType->getPointeeType());
>   return false;
> }
> ```
Many tests fail with this. 

For eg., the tests added to `SemaTemplate/temp_arg_nontype_cxx11.cpp`


```

********************
FAIL: Clang :: SemaTemplate/temp_arg_nontype_cxx11.cpp (13255 of 27894)
******************** TEST 'Clang :: SemaTemplate/temp_arg_nontype_cxx11.cpp' FAILED ********************
Script:
--
: 'RUN: at line 1';   /home/reik/llvm-project/build/bin/clang -cc1 -internal-isystem /home/reik/llvm-project/build/lib/clang/13.0.0/include -nostdsysteminc -fsyntax-only -verify -std=c++11 /home/reik/llvm-project/clang/test/SemaTemplate/temp_arg_nontype_cxx11.cpp
--
Exit Code: 1

Command Output (stderr):
--
error: 'error' diagnostics expected but not seen: 
  File /home/reik/llvm-project/clang/test/SemaTemplate/temp_arg_nontype_cxx11.cpp Line 102: <&kEta,
  File /home/reik/llvm-project/clang/test/SemaTemplate/temp_arg_nontype_cxx11.cpp Line 103: <&kDes,
  File /home/reik/llvm-project/clang/test/SemaTemplate/temp_arg_nontype_cxx11.cpp Line 104: <&kEta,
  File /home/reik/llvm-project/clang/test/SemaTemplate/temp_arg_nontype_cxx11.cpp Line 105: <&kDes,
  File /home/reik/llvm-project/clang/test/SemaTemplate/temp_arg_nontype_cxx11.cpp Line 106: <&kNull,
  File /home/reik/llvm-project/clang/test/SemaTemplate/temp_arg_nontype_cxx11.cpp Line 108: <&kZero,
error: 'error' diagnostics seen but not expected: 
  File /home/reik/llvm-project/clang/test/SemaTemplate/temp_arg_nontype_cxx11.cpp Line 102: no member named 'ls' in 'Folumn<kEta, double>'
  File /home/reik/llvm-project/clang/test/SemaTemplate/temp_arg_nontype_cxx11.cpp Line 103: no member named 'ls' in 'Folumn<kDes, double>'
  File /home/reik/llvm-project/clang/test/SemaTemplate/temp_arg_nontype_cxx11.cpp Line 104: no member named 'ls' in 'Golumn<kEta, double>'
  File /home/reik/llvm-project/clang/test/SemaTemplate/temp_arg_nontype_cxx11.cpp Line 105: no member named 'ls' in 'Golumn<kDes, double>'
  File /home/reik/llvm-project/clang/test/SemaTemplate/temp_arg_nontype_cxx11.cpp Line 106: no member named 'ls' in 'Holumn<kNull, double>'
  File /home/reik/llvm-project/clang/test/SemaTemplate/temp_arg_nontype_cxx11.cpp Line 108: no member named 'ls' in 'Iolumn<kZero, double>'
12 errors generated.

--
```




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

https://reviews.llvm.org/D36368



More information about the llvm-commits mailing list