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 | b28317a8e5e0e2953d1e5406d753d6c3c7f1e7d2 (patch) | |
tree | de590dbcd3bf708b1f203f27df4eccef59f0235a /lib/Sema/SemaStmt.cpp | |
parent | 8054e25b5116e331a2ee4203f5fae2bee1c3cc46 (diff) |
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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67952 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaStmt.cpp')
-rw-r--r-- | lib/Sema/SemaStmt.cpp | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp index 4082d485b8..b331911099 100644 --- a/lib/Sema/SemaStmt.cpp +++ b/lib/Sema/SemaStmt.cpp @@ -37,14 +37,13 @@ Sema::OwningStmtResult Sema::ActOnNullStmt(SourceLocation SemiLoc) { return Owned(new (Context) NullStmt(SemiLoc)); } -Sema::OwningStmtResult Sema::ActOnDeclStmt(DeclTy *decl, +Sema::OwningStmtResult Sema::ActOnDeclStmt(DeclPtrTy decl, SourceLocation StartLoc, SourceLocation EndLoc) { - if (decl == 0) + Decl *D = decl.getAs<Decl>(); + if (D == 0) return StmtError(); - Decl *D = static_cast<Decl *>(decl); - // This is a temporary hack until we are always passing around // DeclGroupRefs. llvm::SmallVector<Decl*, 10> decls; @@ -1001,10 +1000,10 @@ Sema::OwningStmtResult Sema::ActOnAsmStmt(SourceLocation AsmLoc, Action::OwningStmtResult Sema::ActOnObjCAtCatchStmt(SourceLocation AtLoc, - SourceLocation RParen, DeclTy *Parm, + SourceLocation RParen, DeclPtrTy Parm, StmtArg Body, StmtArg catchList) { Stmt *CatchList = static_cast<Stmt*>(catchList.release()); - ParmVarDecl *PVD = static_cast<ParmVarDecl*>(Parm); + ParmVarDecl *PVD = cast_or_null<ParmVarDecl>(Parm.getAs<Decl>()); // PVD == 0 implies @catch(...). if (PVD) { @@ -1071,11 +1070,11 @@ Sema::ActOnObjCAtSynchronizedStmt(SourceLocation AtLoc, ExprArg SynchExpr, /// ActOnCXXCatchBlock - Takes an exception declaration and a handler block /// and creates a proper catch handler from them. Action::OwningStmtResult -Sema::ActOnCXXCatchBlock(SourceLocation CatchLoc, DeclTy *ExDecl, +Sema::ActOnCXXCatchBlock(SourceLocation CatchLoc, DeclPtrTy ExDecl, StmtArg HandlerBlock) { // There's nothing to test that ActOnExceptionDecl didn't already test. return Owned(new (Context) CXXCatchStmt(CatchLoc, - static_cast<VarDecl*>(ExDecl), + cast_or_null<VarDecl>(ExDecl.getAs<Decl>()), static_cast<Stmt*>(HandlerBlock.release()))); } |