aboutsummaryrefslogtreecommitdiff
path: root/lib/Parse/ParseStmt.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-03-28 19:18:32 +0000
committerChris Lattner <sabre@nondot.org>2009-03-28 19:18:32 +0000
commitb28317a8e5e0e2953d1e5406d753d6c3c7f1e7d2 (patch)
treede590dbcd3bf708b1f203f27df4eccef59f0235a /lib/Parse/ParseStmt.cpp
parent8054e25b5116e331a2ee4203f5fae2bee1c3cc46 (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/Parse/ParseStmt.cpp')
-rw-r--r--lib/Parse/ParseStmt.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/Parse/ParseStmt.cpp b/lib/Parse/ParseStmt.cpp
index 1d2e82eae3..b996c74fcf 100644
--- a/lib/Parse/ParseStmt.cpp
+++ b/lib/Parse/ParseStmt.cpp
@@ -101,7 +101,7 @@ Parser::ParseStatementOrDeclaration(bool OnlyStatement) {
default: {
if ((getLang().CPlusPlus || !OnlyStatement) && isDeclarationStatement()) {
SourceLocation DeclStart = Tok.getLocation();
- DeclTy *Decl = ParseDeclaration(Declarator::BlockContext);
+ DeclPtrTy Decl = ParseDeclaration(Declarator::BlockContext);
// FIXME: Pass in the right location for the end of the declstmt.
return Actions.ActOnDeclStmt(Decl, DeclStart, DeclStart);
}
@@ -208,7 +208,7 @@ Parser::OwningStmtResult Parser::ParseLabeledStatement() {
SourceLocation ColonLoc = ConsumeToken();
// Read label attributes, if present.
- DeclTy *AttrList = 0;
+ Action::AttrTy *AttrList = 0;
if (Tok.is(tok::kw___attribute))
// TODO: save these somewhere.
AttrList = ParseAttributes();
@@ -444,7 +444,7 @@ Parser::OwningStmtResult Parser::ParseCompoundStatementBody(bool isStmtExpr) {
if (isDeclarationStatement()) {
// FIXME: Save the __extension__ on the decl as a node somehow.
SourceLocation DeclStart = Tok.getLocation();
- DeclTy *Res = ParseDeclaration(Declarator::BlockContext);
+ DeclPtrTy Res = ParseDeclaration(Declarator::BlockContext);
// FIXME: Pass in the right location for the end of the declstmt.
R = Actions.ActOnDeclStmt(Res, DeclStart, DeclStart);
} else {
@@ -912,7 +912,7 @@ Parser::OwningStmtResult Parser::ParseForStatement() {
Diag(Tok, diag::ext_c99_variable_decl_in_for_loop);
SourceLocation DeclStart = Tok.getLocation();
- DeclTy *aBlockVarDecl = ParseSimpleDeclaration(Declarator::ForContext);
+ DeclPtrTy aBlockVarDecl = ParseSimpleDeclaration(Declarator::ForContext);
// FIXME: Pass in the right location for the end of the declstmt.
FirstPart = Actions.ActOnDeclStmt(aBlockVarDecl, DeclStart,
DeclStart);
@@ -1287,7 +1287,7 @@ bool Parser::ParseAsmOperandsOpt(llvm::SmallVectorImpl<std::string> &Names,
return true;
}
-Parser::DeclTy *Parser::ParseFunctionStatementBody(DeclTy *Decl) {
+Parser::DeclPtrTy Parser::ParseFunctionStatementBody(DeclPtrTy Decl) {
assert(Tok.is(tok::l_brace));
SourceLocation LBraceLoc = Tok.getLocation();
@@ -1369,7 +1369,7 @@ Parser::OwningStmtResult Parser::ParseCXXCatchBlock() {
// exception-declaration is equivalent to '...' or a parameter-declaration
// without default arguments.
- DeclTy *ExceptionDecl = 0;
+ DeclPtrTy ExceptionDecl;
if (Tok.isNot(tok::ellipsis)) {
DeclSpec DS;
if (ParseCXXTypeSpecifierSeq(DS))