[PATCH] D156693: [clang][ASTImporter]Skip check depth of friend template parameter

Qizhi Hu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 15 02:01:27 PDT 2023


jcsxky added inline comments.


================
Comment at: clang/unittests/AST/StructuralEquivalenceTest.cpp:1709
+      classTemplateDecl(hasName("A")));
+  EXPECT_TRUE(testStructuralMatch(t));
+  EXPECT_TRUE(testStructuralMatch(t, true));
----------------
balazske wrote:
> The intent was to have `EXPECT_FALSE` without ignore depth, and the next test would be not needed. If it does not work with this code a different code can be found. The depth of the (unnamed) template parameter is really different in these cases too, but it is probably not detected by structural equivalence. Maybe `template<int U>` or `template<class T, T U>` is needed. But to document this behavior the current test can be added too, with name `IgnoreTemplateParmDepthAtTemplateTypeParmDecl`, and the new one with name `IgnoreTemplateParmDepthAtNonTypeTemplateParmDecl`.
1. The reason why it's true without ignore depth is that template parameter is 'TemplateTypeParm' in this case. So 
```
IsStructurallyEquivalent(StructuralEquivalenceContext &Context,
                                     TemplateTypeParmDecl *D1,
                                     TemplateTypeParmDecl *D2)
```
will be called and return true. 
2. When process 'NonTypeTemplateParm', 
```
IsStructurallyEquivalent(StructuralEquivalenceContext &Context,
                                     QualType T1, QualType T2)
```
is called and return false as the different depth.
I will add `IgnoreTemplateParmDepthAtNonTypeTemplateParmDecl` to illustrate the difference. Also, next test will be removed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156693



More information about the cfe-commits mailing list