diff options
author | Chris Lattner <sabre@nondot.org> | 2011-02-17 20:34:02 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2011-02-17 20:34:02 +0000 |
commit | 57ad37823e198f977cac605dbfbaefb4daf325e9 (patch) | |
tree | 6a224b2610fe145e615126e76e465f9cbdf77401 /lib/Sema/SemaTemplateInstantiateDecl.cpp | |
parent | d8e54990ade0dd5566f8e3aa2e62def08753d1e9 (diff) |
Step #2/N of __label__ support: keep pushing LabelDecl forward,
making them be template instantiated in a more normal way and
make them handle attributes like other decls.
This fixes the used/unused label handling stuff, making it use
the same infrastructure as other decls.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125771 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaTemplateInstantiateDecl.cpp')
-rw-r--r-- | lib/Sema/SemaTemplateInstantiateDecl.cpp | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/lib/Sema/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp index 9197b50330..ecb9019136 100644 --- a/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -101,6 +101,14 @@ TemplateDeclInstantiator::VisitTranslationUnitDecl(TranslationUnitDecl *D) { } Decl * +TemplateDeclInstantiator::VisitLabelDecl(LabelDecl *D) { + LabelDecl *Inst = LabelDecl::Create(SemaRef.Context, Owner, D->getLocation(), + D->getIdentifier()); + Owner->addDecl(Inst); + return Inst; +} + +Decl * TemplateDeclInstantiator::VisitNamespaceDecl(NamespaceDecl *D) { assert(false && "Namespaces cannot be instantiated"); return D; @@ -2863,13 +2871,24 @@ NamedDecl *Sema::FindInstantiatedDecl(SourceLocation Loc, NamedDecl *D, typedef LocalInstantiationScope::DeclArgumentPack DeclArgumentPack; llvm::PointerUnion<Decl *, DeclArgumentPack *> *Found = CurrentInstantiationScope->findInstantiationOf(D); - assert(Found); - if (Decl *FD = Found->dyn_cast<Decl *>()) - return cast<NamedDecl>(FD); + if (Found) { + if (Decl *FD = Found->dyn_cast<Decl *>()) + return cast<NamedDecl>(FD); + + unsigned PackIdx = ArgumentPackSubstitutionIndex; + return cast<NamedDecl>((*Found->get<DeclArgumentPack *>())[PackIdx]); + } + + // If we didn't find the decl, then we must have a label decl that hasn't + // been found yet. Lazily instantiate it and return it now. + assert(isa<LabelDecl>(D)); + + Decl *Inst = SubstDecl(D, CurContext, TemplateArgs); + assert(Inst && "Failed to instantiate label??"); - unsigned PackIdx = ArgumentPackSubstitutionIndex; - return cast<NamedDecl>((*Found->get<DeclArgumentPack *>())[PackIdx]); + CurrentInstantiationScope->InstantiatedLocal(D, Inst); + return cast<LabelDecl>(Inst); } if (CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(D)) { |