[PATCH] D94067: [clang][ASTImporter] Fix a possible assertion failure `NeedsInjectedClassNameType(Decl)'.
Balázs Kéri via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 7 02:21:33 PST 2021
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0877b963ef2d: [clang][ASTImporter] Fix a possible assertion failure… (authored by balazske).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D94067/new/
https://reviews.llvm.org/D94067
Files:
clang/lib/AST/ASTImporter.cpp
clang/unittests/AST/ASTImporterTest.cpp
Index: clang/unittests/AST/ASTImporterTest.cpp
===================================================================
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -6141,6 +6141,41 @@
EXPECT_EQ(ToAttr->getAnnotation(), "A");
}
+TEST_P(ASTImporterOptionSpecificTestBase,
+ ImportOfTemplatedDeclWhenPreviousDeclHasNoDescribedTemplateSet) {
+ Decl *FromTU = getTuDecl(
+ R"(
+
+ namespace std {
+ template<typename T>
+ class basic_stringbuf;
+ }
+ namespace std {
+ class char_traits;
+ template<typename T = char_traits>
+ class basic_stringbuf;
+ }
+ namespace std {
+ template<typename T>
+ class basic_stringbuf {};
+ }
+
+ )",
+ Lang_CXX11);
+
+ auto *From1 = FirstDeclMatcher<ClassTemplateDecl>().match(
+ FromTU,
+ classTemplateDecl(hasName("basic_stringbuf"), unless(isImplicit())));
+ auto *To1 = cast_or_null<ClassTemplateDecl>(Import(From1, Lang_CXX11));
+ EXPECT_TRUE(To1);
+
+ auto *From2 = LastDeclMatcher<ClassTemplateDecl>().match(
+ FromTU,
+ classTemplateDecl(hasName("basic_stringbuf"), unless(isImplicit())));
+ auto *To2 = cast_or_null<ClassTemplateDecl>(Import(From2, Lang_CXX11));
+ EXPECT_TRUE(To2);
+}
+
INSTANTIATE_TEST_CASE_P(ParameterizedTests, ASTImporterLookupTableTest,
DefaultTestValuesForRunOptions, );
Index: clang/lib/AST/ASTImporter.cpp
===================================================================
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -5393,16 +5393,16 @@
CXXRecordDecl *FromTemplated = D->getTemplatedDecl();
+ auto TemplateParamsOrErr = import(D->getTemplateParameters());
+ if (!TemplateParamsOrErr)
+ return TemplateParamsOrErr.takeError();
+
// Create the declaration that is being templated.
CXXRecordDecl *ToTemplated;
if (Error Err = importInto(ToTemplated, FromTemplated))
return std::move(Err);
// Create the class template declaration itself.
- auto TemplateParamsOrErr = import(D->getTemplateParameters());
- if (!TemplateParamsOrErr)
- return TemplateParamsOrErr.takeError();
-
ClassTemplateDecl *D2;
if (GetImportedOrCreateDecl(D2, D, Importer.getToContext(), DC, Loc, Name,
*TemplateParamsOrErr, ToTemplated))
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D94067.315072.patch
Type: text/x-patch
Size: 2376 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210107/cddbf160/attachment.bin>
More information about the cfe-commits
mailing list