-
Notifications
You must be signed in to change notification settings - Fork 10
ASTImporter::Imported - VisitClassTemplateDecl assertion fix #316
ASTImporter::Imported - VisitClassTemplateDecl assertion fix #316
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good, nice fix! Some nits inline.
unittests/AST/ASTImporterTest.cpp
Outdated
TEST_F(Fixture, | ||
ImportTemplatedDecl) { | ||
auto Code = | ||
R"( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code could be a one-line string literal rather than a multi-line raw string literal
unittests/AST/ASTImporterTest.cpp
Outdated
template<class X> struct S{}; | ||
)"; | ||
Decl *FromTU = getTuDecl(Code, Lang_CXX); | ||
ClassTemplateDecl *From = FirstDeclMatcher<ClassTemplateDecl>().match(FromTU, classTemplateDecl()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use auto here and bellow to avoid repeating type name.
lib/AST/ASTImporter.cpp
Outdated
@@ -2023,6 +2023,14 @@ Decl *ASTNodeImporter::VisitRecordDecl(RecordDecl *D) { | |||
Found = Tag->getDecl(); | |||
} | |||
|
|||
if (D->getDescribedTemplate()) { | |||
if (ClassTemplateDecl *Template = dyn_cast<ClassTemplateDecl>(Found)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not use braces for this if and it's else branch.
unittests/AST/ASTImporterTest.cpp
Outdated
} | ||
)"; | ||
Decl *FromTU = getTuDecl(Code, Lang_CXX); | ||
NamespaceDecl *FromNs = FirstDeclMatcher<NamespaceDecl>().match(FromTU, namespaceDecl()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use auto *
where type name is repeated.
Fix for assertion "Try to import an already imported Decl" that occurs through calling ASTNodeImporter::VisitClassTemplateDecl. The problem is related to import of a CXXRecordDecl that is part of a template ("template describing record"). If the describing record is imported (on its own, not as part of the described template) and this is already existing it is not found and imported redundantly. When the described template is imported (already during import of the describing record) the existing template is found and the assertion is triggered.
770d119
to
ee3e2c4
Compare
Code was reformatted. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LG!
@@ -814,6 +814,60 @@ TEST(ImportDecl, ImportFunctionTemplateDecl) { | |||
has(returnStmt(has(integerLiteral(equals(2))))))))))))))))))); | |||
} | |||
|
|||
TEST(ImportDecl, DISABLED_ImportTemplateDefaultArgument) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nobody (even I) has noticed that this test case does not belong here. This is a test for #310 .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't worry, this is TDD, first we have the test, then in an other PR we make it pass! :)
11 tests fail after merging this. |
After merge of #314 (that contains this change too) I did not have failed tests ( |
Phabricator review: |
Fix for assertion
"Try to import an already imported Decl"
that occurs through calling
ASTNodeImporter::VisitClassTemplateDecl.
Fix for #312 .