[clang] [clang][ASTImporter] skip TemplateTypeParmDecl in VisitTypeAliasTemplateDecl (PR #74919)
Balázs Kéri via cfe-commits
cfe-commits at lists.llvm.org
Tue Dec 12 06:30:20 PST 2023
balazske wrote:
The `VisitTypeAliasTemplateDecl` function should be re-designed to check for structural equivalence at import. The following test does not pass because an existing `TypeAliasTemplateDecl` declaration with the same name is always found and returned, without check for structural equivalence.
```
TEST_P(ASTImporterOptionSpecificTestBase, ImportTypeAliasTemplateDecl1) {
const char *ToCode =
R"(
struct S;
template <typename, typename>
using Callable = S;
)";
const char *Code =
R"(
struct S;
template <typename>
using Callable = S;
)";
Decl *ToTU = getToTuDecl(ToCode, Lang_CXX17);
Decl *FromTU = getTuDecl(Code, Lang_CXX17);
auto *FromCallable = FirstDeclMatcher<TypeAliasTemplateDecl>().match(
FromTU, typeAliasTemplateDecl(hasName("Callable")));
auto *ToCallable = FirstDeclMatcher<TypeAliasTemplateDecl>().match(
ToTU, typeAliasTemplateDecl(hasName("Callable")));
auto *ImportedCallable = Import(FromCallable, Lang_CXX17);
EXPECT_TRUE(ImportedCallable);
EXPECT_NE(ImportedCallable, ToCallable);
}
```
Additionally I discovered that import of `ClassTemplateDecl` is not correct too: If there is an object with the same name that is not a `ClassTemplateDecl`, it is just ignored at import. This is not correct, the existing object may cause name conflict (for example it can be a non-template `RecordDecl`). (I found this when checking the questions in my last comment.) This is an independent problem but should be fixed.
https://github.com/llvm/llvm-project/pull/74919
More information about the cfe-commits
mailing list