aboutsummaryrefslogtreecommitdiff
path: root/lib/Parse/MinimalAction.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/MinimalAction.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/MinimalAction.cpp')
-rw-r--r--lib/Parse/MinimalAction.cpp42
1 files changed, 21 insertions, 21 deletions
diff --git a/lib/Parse/MinimalAction.cpp b/lib/Parse/MinimalAction.cpp
index 776d701c32..049228f56c 100644
--- a/lib/Parse/MinimalAction.cpp
+++ b/lib/Parse/MinimalAction.cpp
@@ -26,19 +26,19 @@ ActionBase::~ActionBase() {}
Action::~Action() {}
// Defined out-of-line here because of dependecy on AttributeList
-Action::DeclTy *Action::ActOnUsingDirective(Scope *CurScope,
- SourceLocation UsingLoc,
- SourceLocation NamespcLoc,
- const CXXScopeSpec &SS,
- SourceLocation IdentLoc,
- IdentifierInfo *NamespcName,
- AttributeList *AttrList) {
+Action::DeclPtrTy Action::ActOnUsingDirective(Scope *CurScope,
+ SourceLocation UsingLoc,
+ SourceLocation NamespcLoc,
+ const CXXScopeSpec &SS,
+ SourceLocation IdentLoc,
+ IdentifierInfo *NamespcName,
+ AttributeList *AttrList) {
// FIXME: Parser seems to assume that Action::ActOn* takes ownership over
// passed AttributeList, however other actions don't free it, is it
// temporary state or bug?
delete AttrList;
- return 0;
+ return DeclPtrTy();
}
@@ -135,7 +135,7 @@ bool MinimalAction::isCurrentClassName(const IdentifierInfo &, Scope *,
TemplateNameKind
MinimalAction::isTemplateName(IdentifierInfo &II, Scope *S,
- DeclTy *&TemplateDecl,
+ DeclPtrTy &TemplateDecl,
const CXXScopeSpec *SS) {
return TNK_Non_template;
}
@@ -143,12 +143,12 @@ MinimalAction::isTemplateName(IdentifierInfo &II, Scope *S,
/// ActOnDeclarator - If this is a typedef declarator, we modify the
/// IdentifierInfo::FETokenInfo field to keep track of this fact, until S is
/// popped.
-Action::DeclTy *
-MinimalAction::ActOnDeclarator(Scope *S, Declarator &D, DeclTy *LastInGroup) {
+Action::DeclPtrTy
+MinimalAction::ActOnDeclarator(Scope *S, Declarator &D, DeclPtrTy LastInGroup) {
IdentifierInfo *II = D.getIdentifier();
// If there is no identifier associated with this declarator, bail out.
- if (II == 0) return 0;
+ if (II == 0) return DeclPtrTy();
TypeNameInfo *weCurrentlyHaveTypeInfo = II->getFETokenInfo<TypeNameInfo>();
bool isTypeName =
@@ -162,29 +162,29 @@ MinimalAction::ActOnDeclarator(Scope *S, Declarator &D, DeclTy *LastInGroup) {
getTable(TypeNameInfoTablePtr)->AddEntry(isTypeName, II);
// Remember that this needs to be removed when the scope is popped.
- S->AddDecl(II);
+ S->AddDecl(DeclPtrTy::make(II));
}
- return 0;
+ return DeclPtrTy();
}
-Action::DeclTy *
+Action::DeclPtrTy
MinimalAction::ActOnStartClassInterface(SourceLocation AtInterfaceLoc,
IdentifierInfo *ClassName,
SourceLocation ClassLoc,
IdentifierInfo *SuperName,
SourceLocation SuperLoc,
- DeclTy * const *ProtoRefs,
+ const DeclPtrTy *ProtoRefs,
unsigned NumProtocols,
SourceLocation EndProtoLoc,
AttributeList *AttrList) {
// Allocate and add the 'TypeNameInfo' "decl".
getTable(TypeNameInfoTablePtr)->AddEntry(true, ClassName);
- return 0;
+ return DeclPtrTy();
}
/// ActOnForwardClassDeclaration -
/// Scope will always be top level file scope.
-Action::DeclTy *
+Action::DeclPtrTy
MinimalAction::ActOnForwardClassDeclaration(SourceLocation AtClassLoc,
IdentifierInfo **IdentList, unsigned NumElts) {
for (unsigned i = 0; i != NumElts; ++i) {
@@ -192,9 +192,9 @@ MinimalAction::ActOnForwardClassDeclaration(SourceLocation AtClassLoc,
getTable(TypeNameInfoTablePtr)->AddEntry(true, IdentList[i]);
// Remember that this needs to be removed when the scope is popped.
- TUScope->AddDecl(IdentList[i]);
+ TUScope->AddDecl(DeclPtrTy::make(IdentList[i]));
}
- return 0;
+ return DeclPtrTy();
}
/// ActOnPopScope - When a scope is popped, if any typedefs are now
@@ -204,7 +204,7 @@ void MinimalAction::ActOnPopScope(SourceLocation Loc, Scope *S) {
for (Scope::decl_iterator I = S->decl_begin(), E = S->decl_end();
I != E; ++I) {
- IdentifierInfo &II = *static_cast<IdentifierInfo*>(*I);
+ IdentifierInfo &II = *(*I).getAs<IdentifierInfo>();
TypeNameInfo *TI = II.getFETokenInfo<TypeNameInfo>();
assert(TI && "This decl didn't get pushed??");