diff options
author | Chris Lattner <sabre@nondot.org> | 2009-03-28 19:18:32 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-03-28 19:18:32 +0000 |
commit | 83f095cc7e24c6735753c1f2951fabe98d3f3953 (patch) | |
tree | b617e7dd8950123d7781e7c1c2c6bc93c66cd2da /clang/lib/Sema/SemaTemplateInstantiateDecl.cpp | |
parent | b7de9b77040010e5a91ba9d55b99f9bd45984322 (diff) | |
download | bcm5719-llvm-83f095cc7e24c6735753c1f2951fabe98d3f3953.tar.gz bcm5719-llvm-83f095cc7e24c6735753c1f2951fabe98d3f3953.zip |
Introduce a new OpaquePtr<N> struct type, which is a simple POD wrapper for a
pointer. Its purpose in life is to be a glorified void*, but which does not
implicitly convert to void* or other OpaquePtr's with a different UID.
Introduce Action::DeclPtrTy which is a typedef for OpaquePtr<0>. Change the
entire parser/sema interface to use DeclPtrTy instead of DeclTy*. This
makes the C++ compiler enforce that these aren't convertible to other opaque
types.
We should also convert ExprTy, StmtTy, TypeTy, AttrTy, BaseTy, etc,
but I don't plan to do that in the short term.
The one outstanding known problem with this patch is that we lose the
bitmangling optimization where ActionResult<DeclPtrTy> doesn't know how to
bitmangle the success bit into the low bit of DeclPtrTy. I will rectify
this with a subsequent patch.
llvm-svn: 67952
Diffstat (limited to 'clang/lib/Sema/SemaTemplateInstantiateDecl.cpp')
-rw-r--r-- | clang/lib/Sema/SemaTemplateInstantiateDecl.cpp | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp index adddb2997a5..e7210b3431b 100644 --- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -20,8 +20,7 @@ using namespace clang; namespace { class VISIBILITY_HIDDEN TemplateDeclInstantiator - : public DeclVisitor<TemplateDeclInstantiator, Decl *> - { + : public DeclVisitor<TemplateDeclInstantiator, Decl *> { Sema &SemaRef; DeclContext *Owner; const TemplateArgument *TemplateArgs; @@ -136,7 +135,7 @@ Decl *TemplateDeclInstantiator::VisitVarDecl(VarDecl *D) { if (Init.isInvalid()) Var->setInvalidDecl(); else - SemaRef.AddInitializerToDecl(Var, move(Init), + SemaRef.AddInitializerToDecl(Sema::DeclPtrTy::make(Var), move(Init), D->hasCXXDirectInitializer()); } @@ -204,9 +203,9 @@ Decl *TemplateDeclInstantiator::VisitStaticAssertDecl(StaticAssertDecl *D) { OwningExprResult Message = SemaRef.Clone(D->getMessage()); Decl *StaticAssert - = (Decl *)SemaRef.ActOnStaticAssertDeclaration(D->getLocation(), - move(InstantiatedAssertExpr), - move(Message)); + = SemaRef.ActOnStaticAssertDeclaration(D->getLocation(), + move(InstantiatedAssertExpr), + move(Message)).getAs<Decl>(); return StaticAssert; } @@ -218,7 +217,7 @@ Decl *TemplateDeclInstantiator::VisitEnumDecl(EnumDecl *D) { Owner->addDecl(Enum); Enum->startDefinition(); - llvm::SmallVector<Sema::DeclTy *, 16> Enumerators; + llvm::SmallVector<Sema::DeclPtrTy, 16> Enumerators; EnumConstantDecl *LastEnumConst = 0; for (EnumDecl::enumerator_iterator EC = D->enumerator_begin(), @@ -250,12 +249,12 @@ Decl *TemplateDeclInstantiator::VisitEnumDecl(EnumDecl *D) { if (EnumConst) { Enum->addDecl(EnumConst); - Enumerators.push_back(EnumConst); + Enumerators.push_back(Sema::DeclPtrTy::make(EnumConst)); LastEnumConst = EnumConst; } } - SemaRef.ActOnEnumBody(Enum->getLocation(), Enum, + SemaRef.ActOnEnumBody(Enum->getLocation(), Sema::DeclPtrTy::make(Enum), &Enumerators[0], Enumerators.size()); return Enum; |