OLD | NEW |
1 //===--- SemaTemplateInstantiateDecl.cpp - C++ Template Decl Instantiation ===/ | 1 //===--- SemaTemplateInstantiateDecl.cpp - C++ Template Decl Instantiation ===/ |
2 // | 2 // |
3 // The LLVM Compiler Infrastructure | 3 // The LLVM Compiler Infrastructure |
4 // | 4 // |
5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
7 //===----------------------------------------------------------------------===/ | 7 //===----------------------------------------------------------------------===/ |
8 // | 8 // |
9 // This file implements C++ template instantiation for declarations. | 9 // This file implements C++ template instantiation for declarations. |
10 // | 10 // |
(...skipping 1540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1551 | 1551 |
1552 SourceLocation StartLoc = D->getInnerLocStart(); | 1552 SourceLocation StartLoc = D->getInnerLocStart(); |
1553 DeclarationNameInfo NameInfo | 1553 DeclarationNameInfo NameInfo |
1554 = SemaRef.SubstDeclarationNameInfo(D->getNameInfo(), TemplateArgs); | 1554 = SemaRef.SubstDeclarationNameInfo(D->getNameInfo(), TemplateArgs); |
1555 if (CXXConstructorDecl *Constructor = dyn_cast<CXXConstructorDecl>(D)) { | 1555 if (CXXConstructorDecl *Constructor = dyn_cast<CXXConstructorDecl>(D)) { |
1556 Method = CXXConstructorDecl::Create(SemaRef.Context, Record, | 1556 Method = CXXConstructorDecl::Create(SemaRef.Context, Record, |
1557 StartLoc, NameInfo, T, TInfo, | 1557 StartLoc, NameInfo, T, TInfo, |
1558 Constructor->isExplicit(), | 1558 Constructor->isExplicit(), |
1559 Constructor->isInlineSpecified(), | 1559 Constructor->isInlineSpecified(), |
1560 false, Constructor->isConstexpr()); | 1560 false, Constructor->isConstexpr()); |
1561 | |
1562 // Claim that the instantiation of a constructor or constructor template | 1561 // Claim that the instantiation of a constructor or constructor template |
1563 // inherits the same constructor that the template does. | 1562 // inherits the same constructor that the template does. |
1564 if (CXXConstructorDecl *Inh = const_cast<CXXConstructorDecl *>( | 1563 if (const CXXConstructorDecl *Inh = Constructor->getInheritedConstructor()) |
1565 Constructor->getInheritedConstructor())) { | |
1566 // If we're instantiating a specialization of a function template, our | |
1567 // "inherited constructor" will actually itself be a function template. | |
1568 // Instantiate a declaration of it, too. | |
1569 if (FunctionTemplate) { | |
1570 assert(!TemplateParams && Inh->getDescribedFunctionTemplate() && | |
1571 !Inh->getParent()->isDependentContext() && | |
1572 "inheriting constructor template in dependent context?"); | |
1573 Sema::InstantiatingTemplate Inst(SemaRef, Constructor->getLocation(), | |
1574 Inh); | |
1575 if (Inst) | |
1576 return 0; | |
1577 Sema::ContextRAII SavedContext(SemaRef, Inh->getDeclContext()); | |
1578 LocalInstantiationScope LocalScope(SemaRef); | |
1579 | |
1580 // Use the same template arguments that we deduced for the inheriting | |
1581 // constructor. There's no way they could be deduced differently. | |
1582 MultiLevelTemplateArgumentList InheritedArgs; | |
1583 InheritedArgs.addOuterTemplateArguments(TemplateArgs.getInnermost()); | |
1584 Inh = cast_or_null<CXXConstructorDecl>( | |
1585 SemaRef.SubstDecl(Inh, Inh->getDeclContext(), InheritedArgs)); | |
1586 if (!Inh) | |
1587 return 0; | |
1588 } | |
1589 cast<CXXConstructorDecl>(Method)->setInheritedConstructor(Inh); | 1564 cast<CXXConstructorDecl>(Method)->setInheritedConstructor(Inh); |
1590 } | |
1591 } else if (CXXDestructorDecl *Destructor = dyn_cast<CXXDestructorDecl>(D)) { | 1565 } else if (CXXDestructorDecl *Destructor = dyn_cast<CXXDestructorDecl>(D)) { |
1592 Method = CXXDestructorDecl::Create(SemaRef.Context, Record, | 1566 Method = CXXDestructorDecl::Create(SemaRef.Context, Record, |
1593 StartLoc, NameInfo, T, TInfo, | 1567 StartLoc, NameInfo, T, TInfo, |
1594 Destructor->isInlineSpecified(), | 1568 Destructor->isInlineSpecified(), |
1595 false); | 1569 false); |
1596 } else if (CXXConversionDecl *Conversion = dyn_cast<CXXConversionDecl>(D)) { | 1570 } else if (CXXConversionDecl *Conversion = dyn_cast<CXXConversionDecl>(D)) { |
1597 Method = CXXConversionDecl::Create(SemaRef.Context, Record, | 1571 Method = CXXConversionDecl::Create(SemaRef.Context, Record, |
1598 StartLoc, NameInfo, T, TInfo, | 1572 StartLoc, NameInfo, T, TInfo, |
1599 Conversion->isInlineSpecified(), | 1573 Conversion->isInlineSpecified(), |
1600 Conversion->isExplicit(), | 1574 Conversion->isExplicit(), |
(...skipping 2180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3781 E = Pattern->ddiag_end(); I != E; ++I) { | 3755 E = Pattern->ddiag_end(); I != E; ++I) { |
3782 DependentDiagnostic *DD = *I; | 3756 DependentDiagnostic *DD = *I; |
3783 | 3757 |
3784 switch (DD->getKind()) { | 3758 switch (DD->getKind()) { |
3785 case DependentDiagnostic::Access: | 3759 case DependentDiagnostic::Access: |
3786 HandleDependentAccessCheck(*DD, TemplateArgs); | 3760 HandleDependentAccessCheck(*DD, TemplateArgs); |
3787 break; | 3761 break; |
3788 } | 3762 } |
3789 } | 3763 } |
3790 } | 3764 } |
OLD | NEW |