@@ -33,14 +33,10 @@ using namespace serialization;
3333
3434namespace {
3535
36- // Helper function that returns dependent decl context for the declaration
37- // passed in the argument.
38- template <typename DCT> DCT *getDependentDeclContext (Decl *D) {
39- if (auto *DC = llvm::dyn_cast_or_null<DCT>(D->getDeclContext ());
40- DC && DC->isDependentContext () && DC->isThisDeclarationADefinition ()) {
41- return DC;
42- }
43- return nullptr ;
36+ // Helper function that returns true if the decl passed in the argument is
37+ // a defintion in dependent contxt.
38+ template <typename DT> bool isDefinitionInDependentContext (DT *D) {
39+ return D->isDependentContext () && D->isThisDeclarationADefinition ();
4440}
4541
4642} // namespace
@@ -820,9 +816,11 @@ void ASTDeclWriter::VisitFunctionDecl(FunctionDecl *D) {
820816 // For a friend function defined inline within a class template, we have to
821817 // force the definition to be the one inside the definition of the template
822818 // class. Remember this relation to deserialize them together.
823- if (auto *RD = getDependentDeclContext<CXXRecordDecl>(D))
819+ if (auto *RD = dyn_cast<CXXRecordDecl>(D->getLexicalParent ());
820+ isDefinitionInDependentContext (RD)) {
824821 Writer.RelatedDeclsMap [Writer.GetDeclRef (RD)].push_back (
825822 Writer.GetDeclRef (D));
823+ }
826824 }
827825
828826 Record.push_back (D->param_size ());
@@ -1589,7 +1587,8 @@ void ASTDeclWriter::VisitCXXRecordDecl(CXXRecordDecl *D) {
15891587 }
15901588 // For lambdas inside template functions, remember the mapping to
15911589 // deserialize them together.
1592- if (auto *FD = getDependentDeclContext<FunctionDecl>(D)) {
1590+ if (auto *FD = llvm::dyn_cast_or_null<FunctionDecl>(D->getDeclContext ());
1591+ FD && isDefinitionInDependentContext (FD)) {
15931592 Writer.RelatedDeclsMap [Writer.GetDeclRef (FD)].push_back (
15941593 Writer.GetDeclRef (D));
15951594 }
0 commit comments