diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-11-01 01:16:03 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-11-01 01:16:03 +0000 |
commit | 76852c218a207ef43583515cb835b6e855353a0f (patch) | |
tree | b055d2ceca0168d9a31f52bb3f34732abb6b49dc /lib/Sema/SemaTemplateInstantiateDecl.cpp | |
parent | d8c4551fa22a9c346e6a9e56333915197c97e394 (diff) |
Rework the AST for the initializer of a delegating constructor, so
that it retains source location information for the type. Aside from
general goodness (being able to walk the types described in that
information), we now have a proper representation for dependent
delegating constructors. Fixes PR10457 (for real).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@143410 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaTemplateInstantiateDecl.cpp')
-rw-r--r-- | lib/Sema/SemaTemplateInstantiateDecl.cpp | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/lib/Sema/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp index a4808f88d2..bb6f2d347f 100644 --- a/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -2744,7 +2744,7 @@ Sema::InstantiateMemInitializers(CXXConstructorDecl *New, if (Init->isPackExpansion()) { // This is a pack expansion. We should expand it now. - TypeLoc BaseTL = Init->getBaseClassInfo()->getTypeLoc(); + TypeLoc BaseTL = Init->getTypeSourceInfo()->getTypeLoc(); SmallVector<UnexpandedParameterPack, 2> Unexpanded; collectUnexpandedParameterPacks(BaseTL, Unexpanded); bool ShouldExpand = false; @@ -2774,7 +2774,7 @@ Sema::InstantiateMemInitializers(CXXConstructorDecl *New, } // Instantiate the base type. - TypeSourceInfo *BaseTInfo = SubstType(Init->getBaseClassInfo(), + TypeSourceInfo *BaseTInfo = SubstType(Init->getTypeSourceInfo(), TemplateArgs, Init->getSourceLocation(), New->getDeclName()); @@ -2809,20 +2809,25 @@ Sema::InstantiateMemInitializers(CXXConstructorDecl *New, } MemInitResult NewInit; - if (Init->isBaseInitializer()) { - TypeSourceInfo *BaseTInfo = SubstType(Init->getBaseClassInfo(), - TemplateArgs, - Init->getSourceLocation(), - New->getDeclName()); - if (!BaseTInfo) { + if (Init->isDelegatingInitializer() || Init->isBaseInitializer()) { + TypeSourceInfo *TInfo = SubstType(Init->getTypeSourceInfo(), + TemplateArgs, + Init->getSourceLocation(), + New->getDeclName()); + if (!TInfo) { AnyErrors = true; New->setInvalidDecl(); continue; } MultiInitializer MultiInit(CreateMultiInitializer(NewArgs, Init)); - NewInit = BuildBaseInitializer(BaseTInfo->getType(), BaseTInfo, MultiInit, - New->getParent(), EllipsisLoc); + + if (Init->isBaseInitializer()) + NewInit = BuildBaseInitializer(TInfo->getType(), TInfo, MultiInit, + New->getParent(), EllipsisLoc); + else + NewInit = BuildDelegatingInitializer(TInfo, MultiInit, + cast<CXXRecordDecl>(CurContext->getParent())); } else if (Init->isMemberInitializer()) { FieldDecl *Member = cast_or_null<FieldDecl>(FindInstantiatedDecl( Init->getMemberLocation(), |