[cfe-commits] r67952 - in /cfe/trunk: include/clang/Parse/ lib/Parse/ lib/Sema/ tools/clang-cc/

Chris Lattner sabre at nondot.org
Sat Mar 28 12:18:33 PDT 2009


Author: lattner
Date: Sat Mar 28 14:18:32 2009
New Revision: 67952

URL: http://llvm.org/viewvc/llvm-project?rev=67952&view=rev
Log:
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.


Modified:
    cfe/trunk/include/clang/Parse/Action.h
    cfe/trunk/include/clang/Parse/DeclSpec.h
    cfe/trunk/include/clang/Parse/Ownership.h
    cfe/trunk/include/clang/Parse/Parser.h
    cfe/trunk/include/clang/Parse/Scope.h
    cfe/trunk/lib/Parse/DeclSpec.cpp
    cfe/trunk/lib/Parse/MinimalAction.cpp
    cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp
    cfe/trunk/lib/Parse/ParseDecl.cpp
    cfe/trunk/lib/Parse/ParseDeclCXX.cpp
    cfe/trunk/lib/Parse/ParseExprCXX.cpp
    cfe/trunk/lib/Parse/ParseObjc.cpp
    cfe/trunk/lib/Parse/ParseStmt.cpp
    cfe/trunk/lib/Parse/ParseTemplate.cpp
    cfe/trunk/lib/Parse/Parser.cpp
    cfe/trunk/lib/Sema/IdentifierResolver.cpp
    cfe/trunk/lib/Sema/ParseAST.cpp
    cfe/trunk/lib/Sema/Sema.cpp
    cfe/trunk/lib/Sema/Sema.h
    cfe/trunk/lib/Sema/SemaDecl.cpp
    cfe/trunk/lib/Sema/SemaDeclCXX.cpp
    cfe/trunk/lib/Sema/SemaDeclObjC.cpp
    cfe/trunk/lib/Sema/SemaExpr.cpp
    cfe/trunk/lib/Sema/SemaExprCXX.cpp
    cfe/trunk/lib/Sema/SemaLookup.cpp
    cfe/trunk/lib/Sema/SemaOverload.cpp
    cfe/trunk/lib/Sema/SemaStmt.cpp
    cfe/trunk/lib/Sema/SemaTemplate.cpp
    cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
    cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
    cfe/trunk/lib/Sema/SemaType.cpp
    cfe/trunk/tools/clang-cc/PrintParserCallbacks.cpp

Modified: cfe/trunk/include/clang/Parse/Action.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Action.h?rev=67952&r1=67951&r2=67952&view=diff

==============================================================================
--- cfe/trunk/include/clang/Parse/Action.h (original)
+++ cfe/trunk/include/clang/Parse/Action.h Sat Mar 28 14:18:32 2009
@@ -47,7 +47,7 @@
   template<> struct IsResultPtrLowBitFree<1> { static const bool value = true;};
   template<> struct IsResultPtrLowBitFree<3> { static const bool value = true;};
   template<> struct IsResultPtrLowBitFree<4> { static const bool value = true;};
-
+  
 /// Action - As the parser reads the input file and recognizes the productions
 /// of the grammar, it invokes methods on this class to turn the parsed input
 /// into something useful: e.g. a parse tree.
@@ -69,7 +69,7 @@
   // what types are required to be identical for the actions.
   typedef ActionBase::ExprTy ExprTy;
   typedef ActionBase::StmtTy StmtTy;
-  typedef void DeclTy;
+  typedef OpaquePtr<0> DeclPtrTy;
   typedef void TypeTy;
   typedef void AttrTy;
   typedef void BaseTy;
@@ -85,7 +85,7 @@
   typedef ActionResult<2> TypeResult;
   typedef ActionResult<3> BaseResult;
   typedef ActionResult<4> MemInitResult;
-  typedef ActionResult<5> DeclResult;
+  typedef ActionResult<5, DeclPtrTy> DeclResult;
 
   /// Same, but with ownership.
   typedef ASTOwningResult<&ActionBase::DeleteExpr> OwningExprResult;
@@ -123,7 +123,7 @@
 
   /// getDeclName - Return a pretty name for the specified decl if possible, or
   /// an empty string if not.  This is used for pretty crash reporting. 
-  virtual std::string getDeclName(DeclTy *D) { return ""; }
+  virtual std::string getDeclName(DeclPtrTy D) { return ""; }
   
   //===--------------------------------------------------------------------===//
   // Declaration Tracking Callbacks.
@@ -134,7 +134,7 @@
   /// An optional CXXScopeSpec can be passed to indicate the C++ scope (class or
   /// namespace) that the identifier must be a member of.
   /// i.e. for "foo::bar", 'II' will be "bar" and 'SS' will be "foo::".
-  virtual DeclTy *getTypeName(IdentifierInfo &II, SourceLocation NameLoc,
+  virtual TypeTy *getTypeName(IdentifierInfo &II, SourceLocation NameLoc,
                               Scope *S, const CXXScopeSpec *SS = 0) = 0;
 
   /// isCurrentClassName - Return true if the specified name is the
@@ -148,7 +148,7 @@
   /// optional CXXScope can be passed to indicate the C++ scope in
   /// which the identifier will be found.
   virtual TemplateNameKind isTemplateName(IdentifierInfo &II, Scope *S,
-                                          DeclTy *&TemplateDecl,
+                                          DeclPtrTy &TemplateDecl,
                                           const CXXScopeSpec *SS = 0) = 0;
 
   /// ActOnCXXGlobalScopeSpecifier - Return the object that represents the
@@ -212,16 +212,17 @@
   /// LastInGroup is non-null for cases where one declspec has multiple
   /// declarators on it.  For example in 'int A, B', ActOnDeclarator will be
   /// called with LastInGroup=A when invoked for B.
-  virtual DeclTy *ActOnDeclarator(Scope *S, Declarator &D,DeclTy *LastInGroup) {
-    return 0;
+  virtual DeclPtrTy ActOnDeclarator(Scope *S, Declarator &D,
+                                    DeclPtrTy LastInGroup) {
+    return DeclPtrTy();
   }
 
   /// ActOnParamDeclarator - This callback is invoked when a parameter
   /// declarator is parsed. This callback only occurs for functions
   /// with prototypes. S is the function prototype scope for the
   /// parameters (C++ [basic.scope.proto]).
-  virtual DeclTy *ActOnParamDeclarator(Scope *S, Declarator &D) {
-    return 0;
+  virtual DeclPtrTy ActOnParamDeclarator(Scope *S, Declarator &D) {
+    return DeclPtrTy();
   }
 
   /// AddInitializerToDecl - This action is called immediately after 
@@ -231,7 +232,7 @@
   /// This allows ActOnDeclarator to register "xx" prior to parsing the
   /// initializer. The declaration above should still result in a warning, 
   /// since the reference to "xx" is uninitialized.
-  virtual void AddInitializerToDecl(DeclTy *Dcl, ExprArg Init) {
+  virtual void AddInitializerToDecl(DeclPtrTy Dcl, ExprArg Init) {
     return;
   }
 
@@ -239,19 +240,19 @@
   /// if =delete is parsed. C++0x [dcl.fct.def]p10
   /// Note that this can be called even for variable declarations. It's the
   /// action's job to reject it.
-  virtual void SetDeclDeleted(DeclTy *Dcl, SourceLocation DelLoc) {
+  virtual void SetDeclDeleted(DeclPtrTy Dcl, SourceLocation DelLoc) {
     return;
   }
 
   /// ActOnUninitializedDecl - This action is called immediately after
   /// ActOnDeclarator (when an initializer is *not* present).
-  virtual void ActOnUninitializedDecl(DeclTy *Dcl) {
+  virtual void ActOnUninitializedDecl(DeclPtrTy Dcl) {
     return;
   }
 
   /// FinalizeDeclaratorGroup - After a sequence of declarators are parsed, this
   /// gives the actions implementation a chance to process the group as a whole.
-  virtual DeclTy *FinalizeDeclaratorGroup(Scope *S, DeclTy *Group) {
+  virtual DeclPtrTy FinalizeDeclaratorGroup(Scope *S, DeclPtrTy Group) {
     return Group;
   }
 
@@ -265,30 +266,31 @@
   /// ActOnStartOfFunctionDef - This is called at the start of a function
   /// definition, instead of calling ActOnDeclarator.  The Declarator includes
   /// information about formal arguments that are part of this function.
-  virtual DeclTy *ActOnStartOfFunctionDef(Scope *FnBodyScope, Declarator &D) {
+  virtual DeclPtrTy ActOnStartOfFunctionDef(Scope *FnBodyScope, Declarator &D) {
     // Default to ActOnDeclarator.
     return ActOnStartOfFunctionDef(FnBodyScope,
-                                   ActOnDeclarator(FnBodyScope, D, 0));
+                                   ActOnDeclarator(FnBodyScope, D,DeclPtrTy()));
   }
 
   /// ActOnStartOfFunctionDef - This is called at the start of a function
   /// definition, after the FunctionDecl has already been created.
-  virtual DeclTy *ActOnStartOfFunctionDef(Scope *FnBodyScope, DeclTy *D) {
+  virtual DeclPtrTy ActOnStartOfFunctionDef(Scope *FnBodyScope, DeclPtrTy D) {
     return D;
   }
 
-  virtual void ActOnStartOfObjCMethodDef(Scope *FnBodyScope, DeclTy *D) {
+  virtual void ActOnStartOfObjCMethodDef(Scope *FnBodyScope, DeclPtrTy D) {
     return;
   }
 
   /// ActOnFinishFunctionBody - This is called when a function body has
-  /// completed parsing. Decl is the DeclTy returned by ParseStartOfFunctionDef.
-  virtual DeclTy *ActOnFinishFunctionBody(DeclTy *Decl, StmtArg Body) {
+  /// completed parsing.  Decl is returned by ParseStartOfFunctionDef.
+  virtual DeclPtrTy ActOnFinishFunctionBody(DeclPtrTy Decl, StmtArg Body) {
     return Decl;
   }
 
-  virtual DeclTy *ActOnFileScopeAsmDecl(SourceLocation Loc, ExprArg AsmString) {
-    return 0;
+  virtual DeclPtrTy ActOnFileScopeAsmDecl(SourceLocation Loc,
+                                          ExprArg AsmString) {
+    return DeclPtrTy();
   }
   
   /// ActOnPopScope - This callback is called immediately before the specified
@@ -301,8 +303,8 @@
     
   /// ParsedFreeStandingDeclSpec - This method is invoked when a declspec with
   /// no declarator (e.g. "struct foo;") is parsed.
-  virtual DeclTy *ParsedFreeStandingDeclSpec(Scope *S, DeclSpec &DS) {
-    return 0;
+  virtual DeclPtrTy ParsedFreeStandingDeclSpec(Scope *S, DeclSpec &DS) {
+    return DeclPtrTy();
   }
 
   /// ActOnStartLinkageSpecification - Parsed the beginning of a C++
@@ -312,22 +314,22 @@
   /// by Lang/StrSize. LBraceLoc, if valid, provides the location of
   /// the '{' brace. Otherwise, this linkage specification does not
   /// have any braces.
-  virtual DeclTy *ActOnStartLinkageSpecification(Scope *S,
-                                                 SourceLocation ExternLoc,
-                                                 SourceLocation LangLoc,
-                                                 const char *Lang,
-                                                 unsigned StrSize,
-                                                 SourceLocation LBraceLoc) {
-    return 0;
+  virtual DeclPtrTy ActOnStartLinkageSpecification(Scope *S,
+                                                   SourceLocation ExternLoc,
+                                                   SourceLocation LangLoc,
+                                                   const char *Lang,
+                                                   unsigned StrSize,
+                                                   SourceLocation LBraceLoc) {
+    return DeclPtrTy();
   }
 
   /// ActOnFinishLinkageSpecification - Completely the definition of
   /// the C++ linkage specification LinkageSpec. If RBraceLoc is
   /// valid, it's the position of the closing '}' brace in a linkage
   /// specification that uses braces.
-  virtual DeclTy *ActOnFinishLinkageSpecification(Scope *S,
-                                                  DeclTy *LinkageSpec,
-                                                  SourceLocation RBraceLoc) {
+  virtual DeclPtrTy ActOnFinishLinkageSpecification(Scope *S,
+                                                    DeclPtrTy LinkageSpec,
+                                                    SourceLocation RBraceLoc) {
     return LinkageSpec;
   }
 
@@ -342,7 +344,7 @@
 
   /// ActOnTypeName - A type-name (type-id in C++) was parsed.
   virtual TypeResult ActOnTypeName(Scope *S, Declarator &D) {
-    return 0;
+    return TypeResult();
   }
   
   enum TagKind {
@@ -350,53 +352,54 @@
     TK_Declaration, // Fwd decl of a tag:   'struct foo;'
     TK_Definition   // Definition of a tag: 'struct foo { int X; } Y;'
   };
-  virtual DeclTy *ActOnTag(Scope *S, unsigned TagSpec, TagKind TK,
-                           SourceLocation KWLoc, const CXXScopeSpec &SS,
-                           IdentifierInfo *Name, SourceLocation NameLoc,
-                           AttributeList *Attr, AccessSpecifier AS) {
+  virtual DeclPtrTy ActOnTag(Scope *S, unsigned TagSpec, TagKind TK,
+                             SourceLocation KWLoc, const CXXScopeSpec &SS,
+                             IdentifierInfo *Name, SourceLocation NameLoc,
+                             AttributeList *Attr, AccessSpecifier AS) {
     // TagType is an instance of DeclSpec::TST, indicating what kind of tag this
     // is (struct/union/enum/class).
-    return 0;
+    return DeclPtrTy();
   }
   
   /// Act on @defs() element found when parsing a structure.  ClassName is the
   /// name of the referenced class.   
-  virtual void ActOnDefs(Scope *S, DeclTy *TagD, SourceLocation DeclStart,
+  virtual void ActOnDefs(Scope *S, DeclPtrTy TagD, SourceLocation DeclStart,
                          IdentifierInfo *ClassName,
-                         llvm::SmallVectorImpl<DeclTy*> &Decls) {}
-  virtual DeclTy *ActOnField(Scope *S, DeclTy *TagD, SourceLocation DeclStart,
-                             Declarator &D, ExprTy *BitfieldWidth) {
-    return 0;
+                         llvm::SmallVectorImpl<DeclPtrTy> &Decls) {}
+  virtual DeclPtrTy ActOnField(Scope *S, DeclPtrTy TagD,
+                               SourceLocation DeclStart,
+                               Declarator &D, ExprTy *BitfieldWidth) {
+    return DeclPtrTy();
   }
   
-  virtual DeclTy *ActOnIvar(Scope *S, SourceLocation DeclStart,
-                            Declarator &D, ExprTy *BitfieldWidth,
-                            tok::ObjCKeywordKind visibility) {
-    return 0;
+  virtual DeclPtrTy ActOnIvar(Scope *S, SourceLocation DeclStart,
+                              Declarator &D, ExprTy *BitfieldWidth,
+                              tok::ObjCKeywordKind visibility) {
+    return DeclPtrTy();
   }
   
-  virtual void ActOnFields(Scope* S, SourceLocation RecLoc, DeclTy *TagDecl,
-                           DeclTy **Fields, unsigned NumFields, 
+  virtual void ActOnFields(Scope* S, SourceLocation RecLoc, DeclPtrTy TagDecl,
+                           DeclPtrTy *Fields, unsigned NumFields, 
                            SourceLocation LBrac, SourceLocation RBrac,
                            AttributeList *AttrList) {}
   
   /// ActOnTagStartDefinition - Invoked when we have entered the
   /// scope of a tag's definition (e.g., for an enumeration, class,
   /// struct, or union).
-  virtual void ActOnTagStartDefinition(Scope *S, DeclTy *TagDecl) { }
+  virtual void ActOnTagStartDefinition(Scope *S, DeclPtrTy TagDecl) { }
 
   /// ActOnTagFinishDefinition - Invoked once we have finished parsing
   /// the definition of a tag (enumeration, class, struct, or union).
-  virtual void ActOnTagFinishDefinition(Scope *S, DeclTy *TagDecl) { }
+  virtual void ActOnTagFinishDefinition(Scope *S, DeclPtrTy TagDecl) { }
 
-  virtual DeclTy *ActOnEnumConstant(Scope *S, DeclTy *EnumDecl,
-                                    DeclTy *LastEnumConstant,
-                                    SourceLocation IdLoc, IdentifierInfo *Id,
-                                    SourceLocation EqualLoc, ExprTy *Val) {
-    return 0;
+  virtual DeclPtrTy ActOnEnumConstant(Scope *S, DeclPtrTy EnumDecl,
+                                      DeclPtrTy LastEnumConstant,
+                                      SourceLocation IdLoc, IdentifierInfo *Id,
+                                      SourceLocation EqualLoc, ExprTy *Val) {
+    return DeclPtrTy();
   }
-  virtual void ActOnEnumBody(SourceLocation EnumLoc, DeclTy *EnumDecl,
-                             DeclTy **Elements, unsigned NumElements) {}
+  virtual void ActOnEnumBody(SourceLocation EnumLoc, DeclPtrTy EnumDecl,
+                             DeclPtrTy *Elements, unsigned NumElements) {}
 
   //===--------------------------------------------------------------------===//
   // Statement Parsing Callbacks.
@@ -411,8 +414,8 @@
                                              bool isStmtExpr) {
     return StmtEmpty();
   }
-  virtual OwningStmtResult ActOnDeclStmt(DeclTy *Decl, SourceLocation StartLoc,
-                                   SourceLocation EndLoc) {
+  virtual OwningStmtResult ActOnDeclStmt(DeclPtrTy Decl,SourceLocation StartLoc,
+                                         SourceLocation EndLoc) {
     return StmtEmpty();
   }
 
@@ -521,7 +524,7 @@
   // Objective-c statements
   virtual OwningStmtResult ActOnObjCAtCatchStmt(SourceLocation AtLoc,
                                                 SourceLocation RParen,
-                                                DeclTy *Parm, StmtArg Body,
+                                                DeclPtrTy Parm, StmtArg Body,
                                                 StmtArg CatchList) {
     return StmtEmpty();
   }
@@ -550,12 +553,12 @@
   }
 
   // C++ Statements
-  virtual DeclTy *ActOnExceptionDeclarator(Scope *S, Declarator &D) {
-    return 0;
+  virtual DeclPtrTy ActOnExceptionDeclarator(Scope *S, Declarator &D) {
+    return DeclPtrTy();
   }
 
   virtual OwningStmtResult ActOnCXXCatchBlock(SourceLocation CatchLoc,
-                                              DeclTy *ExceptionDecl,
+                                              DeclPtrTy ExceptionDecl,
                                               StmtArg HandlerBlock) {
     return StmtEmpty();
   }
@@ -658,7 +661,7 @@
                                                     tok::TokenKind OpKind,
                                                     SourceLocation MemberLoc,
                                                     IdentifierInfo &Member,
-                                                    DeclTy *ObjCImpDecl) {
+                                                    DeclPtrTy ObjCImpDecl) {
     return ExprEmpty();
   }
 
@@ -821,40 +824,40 @@
 
   /// ActOnStartNamespaceDef - This is called at the start of a namespace
   /// definition.
-  virtual DeclTy *ActOnStartNamespaceDef(Scope *S, SourceLocation IdentLoc,
-                                        IdentifierInfo *Ident,
-                                        SourceLocation LBrace) {
-    return 0;
+  virtual DeclPtrTy ActOnStartNamespaceDef(Scope *S, SourceLocation IdentLoc,
+                                           IdentifierInfo *Ident,
+                                           SourceLocation LBrace) {
+    return DeclPtrTy();
   }
 
   /// ActOnFinishNamespaceDef - This callback is called after a namespace is
-  /// exited. Decl is the DeclTy returned by ActOnStartNamespaceDef.
-  virtual void ActOnFinishNamespaceDef(DeclTy *Dcl,SourceLocation RBrace) {
+  /// exited. Decl is returned by ActOnStartNamespaceDef.
+  virtual void ActOnFinishNamespaceDef(DeclPtrTy Dcl, SourceLocation RBrace) {
     return;
   }
 
   /// ActOnUsingDirective - This is called when using-directive is parsed.
-  virtual DeclTy *ActOnUsingDirective(Scope *CurScope,
-                                      SourceLocation UsingLoc,
-                                      SourceLocation NamespcLoc,
-                                      const CXXScopeSpec &SS,
-                                      SourceLocation IdentLoc,
-                                      IdentifierInfo *NamespcName,
-                                      AttributeList *AttrList);
+  virtual DeclPtrTy ActOnUsingDirective(Scope *CurScope,
+                                        SourceLocation UsingLoc,
+                                        SourceLocation NamespcLoc,
+                                        const CXXScopeSpec &SS,
+                                        SourceLocation IdentLoc,
+                                        IdentifierInfo *NamespcName,
+                                        AttributeList *AttrList);
 
   /// ActOnNamespaceAliasDef - This is called when a namespace alias definition
   /// is parsed.
-  virtual DeclTy *ActOnNamespaceAliasDef(Scope *CurScope,
-                                         SourceLocation AliasLoc,
-                                         IdentifierInfo *Alias,
-                                         const CXXScopeSpec &SS,
-                                         SourceLocation NamespaceLoc,
-                                         IdentifierInfo *NamespaceName) {
-    return 0;
+  virtual DeclPtrTy ActOnNamespaceAliasDef(Scope *CurScope,
+                                           SourceLocation AliasLoc,
+                                           IdentifierInfo *Alias,
+                                           const CXXScopeSpec &SS,
+                                           SourceLocation NamespaceLoc,
+                                           IdentifierInfo *NamespaceName) {
+    return DeclPtrTy();
   }
                                          
   /// ActOnParamDefaultArgument - Parse default argument for function parameter
-  virtual void ActOnParamDefaultArgument(DeclTy *param,
+  virtual void ActOnParamDefaultArgument(DeclPtrTy param,
                                          SourceLocation EqualLoc,
                                          ExprArg defarg) {
   }
@@ -863,17 +866,17 @@
   /// argument for a function parameter, but we can't parse it yet
   /// because we're inside a class definition. Note that this default
   /// argument will be parsed later.
-  virtual void ActOnParamUnparsedDefaultArgument(DeclTy *param, 
+  virtual void ActOnParamUnparsedDefaultArgument(DeclPtrTy param, 
                                                  SourceLocation EqualLoc) { }
 
   /// ActOnParamDefaultArgumentError - Parsing or semantic analysis of
   /// the default argument for the parameter param failed.
-  virtual void ActOnParamDefaultArgumentError(DeclTy *param) { }
+  virtual void ActOnParamDefaultArgumentError(DeclPtrTy param) { }
 
   /// AddCXXDirectInitializerToDecl - This action is called immediately after 
   /// ActOnDeclarator, when a C++ direct initializer is present.
   /// e.g: "int x(1);"
-  virtual void AddCXXDirectInitializerToDecl(DeclTy *Dcl,
+  virtual void AddCXXDirectInitializerToDecl(DeclPtrTy Dcl,
                                              SourceLocation LParenLoc,
                                              MultiExprArg Exprs,
                                              SourceLocation *CommaLocs,
@@ -889,7 +892,8 @@
   /// Method declaration as if we had just parsed the qualified method
   /// name. However, it should not bring the parameters into scope;
   /// that will be performed by ActOnDelayedCXXMethodParameter.
-  virtual void ActOnStartDelayedCXXMethodDeclaration(Scope *S, DeclTy *Method) {
+  virtual void ActOnStartDelayedCXXMethodDeclaration(Scope *S,
+                                                     DeclPtrTy Method) {
   }
 
   /// ActOnDelayedCXXMethodParameter - We've already started a delayed
@@ -897,7 +901,7 @@
   /// function parameter into scope for use in parsing later parts of
   /// the method declaration. For example, we could see an
   /// ActOnParamDefaultArgument event for this parameter.
-  virtual void ActOnDelayedCXXMethodParameter(Scope *S, DeclTy *Param) {
+  virtual void ActOnDelayedCXXMethodParameter(Scope *S, DeclPtrTy Param) {
   }
 
   /// ActOnFinishDelayedCXXMethodDeclaration - We have finished
@@ -906,14 +910,15 @@
   /// ActOnStartOfFunctionDef action later (not necessarily
   /// immediately!) for this method, if it was also defined inside the
   /// class body.
-  virtual void ActOnFinishDelayedCXXMethodDeclaration(Scope *S, DeclTy *Method){
+  virtual void ActOnFinishDelayedCXXMethodDeclaration(Scope *S,
+                                                      DeclPtrTy Method) {
   }
 
   /// ActOnStaticAssertDeclaration - Parse a C++0x static_assert declaration.
-  virtual DeclTy *ActOnStaticAssertDeclaration(SourceLocation AssertLoc,
-                                               ExprArg AssertExpr,
-                                               ExprArg AssertMessageExpr) {
-    return 0;
+  virtual DeclPtrTy ActOnStaticAssertDeclaration(SourceLocation AssertLoc,
+                                                 ExprArg AssertExpr,
+                                                 ExprArg AssertMessageExpr) {
+    return DeclPtrTy();
   }
 
 
@@ -1014,7 +1019,7 @@
 
   //===---------------------------- C++ Classes ---------------------------===//
   /// ActOnBaseSpecifier - Parsed a base specifier
-  virtual BaseResult ActOnBaseSpecifier(DeclTy *classdecl, 
+  virtual BaseResult ActOnBaseSpecifier(DeclPtrTy classdecl, 
                                         SourceRange SpecifierRange,
                                         bool Virtual, AccessSpecifier Access,
                                         TypeTy *basetype, 
@@ -1022,7 +1027,7 @@
     return 0;
   }
 
-  virtual void ActOnBaseSpecifiers(DeclTy *ClassDecl, BaseTy **Bases, 
+  virtual void ActOnBaseSpecifiers(DeclPtrTy ClassDecl, BaseTy **Bases, 
                                    unsigned NumBases) {
   }
                                    
@@ -1031,13 +1036,15 @@
   /// specifies the bitfield width if there is one and 'Init' specifies the
   /// initializer if any. 'LastInGroup' is non-null for cases where one declspec
   /// has multiple declarators on it.
-  virtual DeclTy *ActOnCXXMemberDeclarator(Scope *S, AccessSpecifier AS,
-                                           Declarator &D, ExprTy *BitfieldWidth,
-                                           ExprTy *Init, DeclTy *LastInGroup) {
-    return 0;
+  virtual DeclPtrTy ActOnCXXMemberDeclarator(Scope *S, AccessSpecifier AS,
+                                             Declarator &D,
+                                             ExprTy *BitfieldWidth,
+                                             ExprTy *Init,
+                                             DeclPtrTy LastInGroup) {
+    return DeclPtrTy();
   }
 
-  virtual MemInitResult ActOnMemInitializer(DeclTy *ConstructorDecl,
+  virtual MemInitResult ActOnMemInitializer(DeclPtrTy ConstructorDecl,
                                             Scope *S,
                                             IdentifierInfo *MemberOrBase,
                                             SourceLocation IdLoc,
@@ -1054,15 +1061,15 @@
   /// a well-formed program), ColonLoc is the location of the ':' that
   /// starts the constructor initializer, and MemInit/NumMemInits
   /// contains the individual member (and base) initializers. 
-  virtual void ActOnMemInitializers(DeclTy *ConstructorDecl, 
+  virtual void ActOnMemInitializers(DeclPtrTy ConstructorDecl, 
                                     SourceLocation ColonLoc,
-                                    MemInitTy **MemInits, unsigned NumMemInits) {
+                                    MemInitTy **MemInits, unsigned NumMemInits){
   }
 
   /// ActOnFinishCXXMemberSpecification - Invoked after all member declarators
   /// are parsed but *before* parsing of inline method definitions.
   virtual void ActOnFinishCXXMemberSpecification(Scope* S, SourceLocation RLoc,
-                                                 DeclTy *TagDecl,
+                                                 DeclPtrTy TagDecl,
                                                  SourceLocation LBrac,
                                                  SourceLocation RBrac) {
   }
@@ -1081,17 +1088,17 @@
   /// the number of enclosing templates (see
   /// ActOnTemplateParameterList) and the number of previous
   /// parameters within this template parameter list.
-  virtual DeclTy *ActOnTypeParameter(Scope *S, bool Typename,
-                                     SourceLocation KeyLoc,
-                                     IdentifierInfo *ParamName,
-                                     SourceLocation ParamNameLoc,
-                                     unsigned Depth, unsigned Position) {
-    return 0;
+  virtual DeclPtrTy ActOnTypeParameter(Scope *S, bool Typename,
+                                       SourceLocation KeyLoc,
+                                       IdentifierInfo *ParamName,
+                                       SourceLocation ParamNameLoc,
+                                       unsigned Depth, unsigned Position) {
+    return DeclPtrTy();
   }
 
   /// ActOnTypeParameterDefault - Adds a default argument (the type
   /// Default) to the given template type parameter (TypeParam). 
-  virtual void ActOnTypeParameterDefault(DeclTy *TypeParam, 
+  virtual void ActOnTypeParameterDefault(DeclPtrTy TypeParam, 
                                          SourceLocation EqualLoc,
                                          SourceLocation DefaultLoc,
                                          TypeTy *Default) {
@@ -1104,15 +1111,15 @@
   /// enclosing templates (see
   /// ActOnTemplateParameterList) and the number of previous
   /// parameters within this template parameter list.
-  virtual DeclTy *ActOnNonTypeTemplateParameter(Scope *S, Declarator &D,
-                                                unsigned Depth, 
-                                                unsigned Position) {
-    return 0;
+  virtual DeclPtrTy ActOnNonTypeTemplateParameter(Scope *S, Declarator &D,
+                                                  unsigned Depth, 
+                                                  unsigned Position) {
+    return DeclPtrTy();
   }
 
   /// \brief Adds a default argument to the given non-type template
   /// parameter.
-  virtual void ActOnNonTypeTemplateParameterDefault(DeclTy *TemplateParam,
+  virtual void ActOnNonTypeTemplateParameterDefault(DeclPtrTy TemplateParam,
                                                     SourceLocation EqualLoc,
                                                     ExprArg Default) {
   }
@@ -1123,19 +1130,19 @@
   /// TemplateParams is the sequence of parameters required by the template,
   /// ParamName is the name of the parameter (null if unnamed), and ParamNameLoc
   /// is the source location of the identifier (if given).
-  virtual DeclTy *ActOnTemplateTemplateParameter(Scope *S,
-                                                 SourceLocation TmpLoc,
-                                                 TemplateParamsTy *Params,
-                                                 IdentifierInfo *ParamName,
-                                                 SourceLocation ParamNameLoc,
-                                                 unsigned Depth,
-                                                 unsigned Position) {
-    return 0;
+  virtual DeclPtrTy ActOnTemplateTemplateParameter(Scope *S,
+                                                   SourceLocation TmpLoc,
+                                                   TemplateParamsTy *Params,
+                                                   IdentifierInfo *ParamName,
+                                                   SourceLocation ParamNameLoc,
+                                                   unsigned Depth,
+                                                   unsigned Position) {
+    return DeclPtrTy();
   }
 
   /// \brief Adds a default argument to the given template template
   /// parameter.
-  virtual void ActOnTemplateTemplateParameterDefault(DeclTy *TemplateParam,
+  virtual void ActOnTemplateTemplateParameterDefault(DeclPtrTy TemplateParam,
                                                      SourceLocation EqualLoc,
                                                      ExprArg Default) {
   }
@@ -1174,7 +1181,7 @@
                              SourceLocation ExportLoc,
                              SourceLocation TemplateLoc, 
                              SourceLocation LAngleLoc,
-                             DeclTy **Params, unsigned NumParams,
+                             DeclPtrTy *Params, unsigned NumParams,
                              SourceLocation RAngleLoc) {
     return 0;
   }
@@ -1188,7 +1195,7 @@
                      AttributeList *Attr,
                      MultiTemplateParamsArg TemplateParameterLists,
                      AccessSpecifier AS) {
-    return 0;
+    return DeclResult();
   }
 
   /// \brief Form a class template specialization from a template and
@@ -1204,14 +1211,14 @@
   /// \param IsSpecialization true when we are naming the class
   /// template specialization as part of an explicit class
   /// specialization or class template partial specialization.
-  virtual TypeResult ActOnClassTemplateId(DeclTy *Template,
+  virtual TypeResult ActOnClassTemplateId(DeclPtrTy Template,
                                           SourceLocation TemplateLoc,
                                           SourceLocation LAngleLoc,
                                           ASTTemplateArgsPtr TemplateArgs,
                                           SourceLocation *TemplateArgLocs,
                                           SourceLocation RAngleLoc,
                                           const CXXScopeSpec *SS) {
-    return 0;
+    return TypeResult();
   };
 
   /// \brief Process the declaration or definition of an explicit
@@ -1264,7 +1271,7 @@
   ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec, TagKind TK,
                                    SourceLocation KWLoc, 
                                    const CXXScopeSpec &SS,
-                                   DeclTy *Template,
+                                   DeclPtrTy Template,
                                    SourceLocation TemplateNameLoc,
                                    SourceLocation LAngleLoc,
                                    ASTTemplateArgsPtr TemplateArgs,
@@ -1272,7 +1279,7 @@
                                    SourceLocation RAngleLoc,
                                    AttributeList *Attr,
                               MultiTemplateParamsArg TemplateParameterLists) {
-    return 0;
+    return DeclResult();
   }
 
   /// \brief Called when the parser has parsed a C++ typename
@@ -1285,7 +1292,7 @@
   virtual TypeResult
   ActOnTypenameType(SourceLocation TypenameLoc, const CXXScopeSpec &SS,
                     const IdentifierInfo &II, SourceLocation IdLoc) {
-    return 0;
+    return TypeResult();
   }
 
   //===----------------------- Obj-C Declarations -------------------------===//
@@ -1293,89 +1300,89 @@
   // ActOnStartClassInterface - this action is called immediately after parsing
   // the prologue for a class interface (before parsing the instance 
   // variables). Instance variables are processed by ActOnFields().
-  virtual DeclTy *ActOnStartClassInterface(SourceLocation AtInterfaceLoc,
-                                           IdentifierInfo *ClassName, 
-                                           SourceLocation ClassLoc,
-                                           IdentifierInfo *SuperName, 
-                                           SourceLocation SuperLoc,
-                                           DeclTy * const *ProtoRefs, 
-                                           unsigned NumProtoRefs,
-                                           SourceLocation EndProtoLoc,
-                                           AttributeList *AttrList) {
-    return 0;
+  virtual DeclPtrTy ActOnStartClassInterface(SourceLocation AtInterfaceLoc,
+                                             IdentifierInfo *ClassName, 
+                                             SourceLocation ClassLoc,
+                                             IdentifierInfo *SuperName, 
+                                             SourceLocation SuperLoc,
+                                             const DeclPtrTy *ProtoRefs, 
+                                             unsigned NumProtoRefs,
+                                             SourceLocation EndProtoLoc,
+                                             AttributeList *AttrList) {
+    return DeclPtrTy();
   }
   
   /// ActOnCompatiblityAlias - this action is called after complete parsing of
   /// @compaatibility_alias declaration. It sets up the alias relationships.
-  virtual DeclTy *ActOnCompatiblityAlias(
+  virtual DeclPtrTy ActOnCompatiblityAlias(
     SourceLocation AtCompatibilityAliasLoc,
     IdentifierInfo *AliasName,  SourceLocation AliasLocation,
     IdentifierInfo *ClassName, SourceLocation ClassLocation) {
-    return 0;
+    return DeclPtrTy();
   }
   
   // ActOnStartProtocolInterface - this action is called immdiately after
   // parsing the prologue for a protocol interface.
-  virtual DeclTy *ActOnStartProtocolInterface(SourceLocation AtProtoLoc,
-                                              IdentifierInfo *ProtocolName, 
-                                              SourceLocation ProtocolLoc,
-                                              DeclTy * const *ProtoRefs,
-                                              unsigned NumProtoRefs,
-                                              SourceLocation EndProtoLoc,
-                                              AttributeList *AttrList) {
-    return 0;
+  virtual DeclPtrTy ActOnStartProtocolInterface(SourceLocation AtProtoLoc,
+                                                IdentifierInfo *ProtocolName, 
+                                                SourceLocation ProtocolLoc,
+                                                const DeclPtrTy *ProtoRefs,
+                                                unsigned NumProtoRefs,
+                                                SourceLocation EndProtoLoc,
+                                                AttributeList *AttrList) {
+    return DeclPtrTy();
   }
   // ActOnStartCategoryInterface - this action is called immdiately after
   // parsing the prologue for a category interface.
-  virtual DeclTy *ActOnStartCategoryInterface(SourceLocation AtInterfaceLoc,
-                                              IdentifierInfo *ClassName, 
-                                              SourceLocation ClassLoc,
-                                              IdentifierInfo *CategoryName, 
-                                              SourceLocation CategoryLoc,
-                                              DeclTy * const *ProtoRefs,
-                                              unsigned NumProtoRefs,
-                                              SourceLocation EndProtoLoc) {
-    return 0;
+  virtual DeclPtrTy ActOnStartCategoryInterface(SourceLocation AtInterfaceLoc,
+                                                IdentifierInfo *ClassName, 
+                                                SourceLocation ClassLoc,
+                                                IdentifierInfo *CategoryName, 
+                                                SourceLocation CategoryLoc,
+                                                const DeclPtrTy *ProtoRefs,
+                                                unsigned NumProtoRefs,
+                                                SourceLocation EndProtoLoc) {
+    return DeclPtrTy();
   }
   // ActOnStartClassImplementation - this action is called immdiately after
   // parsing the prologue for a class implementation. Instance variables are 
   // processed by ActOnFields().
-  virtual DeclTy *ActOnStartClassImplementation(
+  virtual DeclPtrTy ActOnStartClassImplementation(
     SourceLocation AtClassImplLoc,
     IdentifierInfo *ClassName, 
     SourceLocation ClassLoc,
     IdentifierInfo *SuperClassname, 
     SourceLocation SuperClassLoc) {
-    return 0;
+    return DeclPtrTy();
   }
   // ActOnStartCategoryImplementation - this action is called immdiately after
   // parsing the prologue for a category implementation.
-  virtual DeclTy *ActOnStartCategoryImplementation(
+  virtual DeclPtrTy ActOnStartCategoryImplementation(
     SourceLocation AtCatImplLoc,
     IdentifierInfo *ClassName, 
     SourceLocation ClassLoc,
     IdentifierInfo *CatName,
     SourceLocation CatLoc) {
-    return 0;
+    return DeclPtrTy();
   }  
   // ActOnPropertyImplDecl - called for every property implementation
-  virtual DeclTy *ActOnPropertyImplDecl(
+  virtual DeclPtrTy ActOnPropertyImplDecl(
    SourceLocation AtLoc,              // location of the @synthesize/@dynamic
    SourceLocation PropertyNameLoc,    // location for the property name
    bool ImplKind,                     // true for @synthesize, false for
                                       // @dynamic
-   DeclTy *ClassImplDecl,             // class or category implementation
+   DeclPtrTy ClassImplDecl,           // class or category implementation
    IdentifierInfo *propertyId,        // name of property
    IdentifierInfo *propertyIvar) {    // name of the ivar
-    return 0;
+    return DeclPtrTy();
   }
 
   // ActOnMethodDeclaration - called for all method declarations. 
-  virtual DeclTy *ActOnMethodDeclaration(
+  virtual DeclPtrTy ActOnMethodDeclaration(
     SourceLocation BeginLoc,   // location of the + or -.
     SourceLocation EndLoc,     // location of the ; or {.
     tok::TokenKind MethodType, // tok::minus for instance, tok::plus for class.
-    DeclTy *ClassDecl,         // class this methods belongs to.
+    DeclPtrTy ClassDecl,       // class this methods belongs to.
     ObjCDeclSpec &ReturnQT,    // for return type's in inout etc.
     TypeTy *ReturnType,        // the method return type.
     Selector Sel,              // a unique name for the method.
@@ -1387,31 +1394,30 @@
     // tok::objc_not_keyword, tok::objc_optional, tok::objc_required    
     tok::ObjCKeywordKind impKind,
     bool isVariadic = false) {
-    return 0;
+    return DeclPtrTy();
   }
   // ActOnAtEnd - called to mark the @end. For declarations (interfaces,
   // protocols, categories), the parser passes all methods/properties. 
   // For class implementations, these values default to 0. For implementations,
   // methods are processed incrementally (by ActOnMethodDeclaration above).
-  virtual void ActOnAtEnd(
-    SourceLocation AtEndLoc, 
-    DeclTy *classDecl,
-    DeclTy **allMethods = 0, 
-    unsigned allNum = 0,
-    DeclTy **allProperties = 0, 
-    unsigned pNum = 0,
-    DeclTy **allTUVars = 0,
-    unsigned tuvNum = 0) {
+  virtual void ActOnAtEnd(SourceLocation AtEndLoc, 
+                          DeclPtrTy classDecl,
+                          DeclPtrTy *allMethods = 0, 
+                          unsigned allNum = 0,
+                          DeclPtrTy *allProperties = 0, 
+                          unsigned pNum = 0,
+                          DeclPtrTy *allTUVars = 0,
+                          unsigned tuvNum = 0) {
     return;
   }
   // ActOnProperty - called to build one property AST
-  virtual DeclTy *ActOnProperty (Scope *S, SourceLocation AtLoc,
-                                 FieldDeclarator &FD, ObjCDeclSpec &ODS,
-                                 Selector GetterSel, Selector SetterSel,
-                                 DeclTy *ClassCategory,
-                                 bool *OverridingProperty,
-                                 tok::ObjCKeywordKind MethodImplKind) {
-    return 0;
+  virtual DeclPtrTy ActOnProperty(Scope *S, SourceLocation AtLoc,
+                                  FieldDeclarator &FD, ObjCDeclSpec &ODS,
+                                  Selector GetterSel, Selector SetterSel,
+                                  DeclPtrTy ClassCategory,
+                                  bool *OverridingProperty,
+                                  tok::ObjCKeywordKind MethodImplKind) {
+    return DeclPtrTy();
   }
                                      
   virtual OwningExprResult ActOnClassPropertyRefExpr(
@@ -1444,18 +1450,18 @@
     ExprTy **ArgExprs, unsigned NumArgs) {
     return 0;
   }
-  virtual DeclTy *ActOnForwardClassDeclaration(
+  virtual DeclPtrTy ActOnForwardClassDeclaration(
     SourceLocation AtClassLoc,
     IdentifierInfo **IdentList,
     unsigned NumElts) {
-    return 0;
+    return DeclPtrTy();
   }
-  virtual DeclTy *ActOnForwardProtocolDeclaration(
+  virtual DeclPtrTy ActOnForwardProtocolDeclaration(
     SourceLocation AtProtocolLoc,
     const IdentifierLocPair*IdentList,
     unsigned NumElts,
     AttributeList *AttrList) {
-    return 0;
+    return DeclPtrTy();
   }
   
   /// FindProtocolDeclaration - This routine looks up protocols and
@@ -1464,7 +1470,7 @@
   virtual void FindProtocolDeclaration(bool WarnOnDeclarations,
                                        const IdentifierLocPair *ProtocolId,
                                        unsigned NumProtocols,
-                                 llvm::SmallVectorImpl<DeclTy*> &ResProtos) {
+                                 llvm::SmallVectorImpl<DeclPtrTy> &ResProtos) {
   }
 
   //===----------------------- Obj-C Expressions --------------------------===//
@@ -1547,7 +1553,7 @@
 
   /// getTypeName - This looks at the IdentifierInfo::FETokenInfo field to
   /// determine whether the name is a typedef or not in this scope.
-  virtual DeclTy *getTypeName(IdentifierInfo &II, SourceLocation NameLoc,
+  virtual TypeTy *getTypeName(IdentifierInfo &II, SourceLocation NameLoc,
                               Scope *S, const CXXScopeSpec *SS);
 
   /// isCurrentClassName - Always returns false, because MinimalAction
@@ -1556,45 +1562,46 @@
                                   const CXXScopeSpec *SS);
 
   virtual TemplateNameKind isTemplateName(IdentifierInfo &II, Scope *S,
-                                          DeclTy *&TemplateDecl,
+                                          DeclPtrTy &TemplateDecl,
                                           const CXXScopeSpec *SS = 0);
 
   /// ActOnDeclarator - If this is a typedef declarator, we modify the
   /// IdentifierInfo::FETokenInfo field to keep track of this fact, until S is
   /// popped.
-  virtual DeclTy *ActOnDeclarator(Scope *S, Declarator &D, DeclTy *LastInGroup);
+  virtual DeclPtrTy ActOnDeclarator(Scope *S, Declarator &D,
+                                    DeclPtrTy LastInGroup);
   
   /// ActOnPopScope - When a scope is popped, if any typedefs are now 
   /// out-of-scope, they are removed from the IdentifierInfo::FETokenInfo field.
   virtual void ActOnPopScope(SourceLocation Loc, Scope *S);
   virtual void ActOnTranslationUnitScope(SourceLocation Loc, Scope *S);
   
-  virtual DeclTy *ActOnForwardClassDeclaration(SourceLocation AtClassLoc,
-                                               IdentifierInfo **IdentList,
-                                               unsigned NumElts);
-  
-  virtual DeclTy *ActOnStartClassInterface(SourceLocation interLoc,
-                                           IdentifierInfo *ClassName,
-                                           SourceLocation ClassLoc,
-                                           IdentifierInfo *SuperName,
-                                           SourceLocation SuperLoc,
-                                           DeclTy * const *ProtoRefs, 
-                                           unsigned NumProtoRefs,
-                                           SourceLocation EndProtoLoc,
-                                           AttributeList *AttrList);
+  virtual DeclPtrTy ActOnForwardClassDeclaration(SourceLocation AtClassLoc,
+                                                 IdentifierInfo **IdentList,
+                                                 unsigned NumElts);
+  
+  virtual DeclPtrTy ActOnStartClassInterface(SourceLocation interLoc,
+                                             IdentifierInfo *ClassName,
+                                             SourceLocation ClassLoc,
+                                             IdentifierInfo *SuperName,
+                                             SourceLocation SuperLoc,
+                                             const DeclPtrTy *ProtoRefs, 
+                                             unsigned NumProtoRefs,
+                                             SourceLocation EndProtoLoc,
+                                             AttributeList *AttrList);
 };
 
 /// PrettyStackTraceActionsDecl - If a crash occurs in the parser while parsing
 /// something related to a virtualized decl, include that virtualized decl in
 /// the stack trace.
 class PrettyStackTraceActionsDecl : public llvm::PrettyStackTraceEntry {
-  Action::DeclTy *TheDecl;
+  Action::DeclPtrTy TheDecl;
   SourceLocation Loc;
   Action &Actions;
   SourceManager &SM;
   const char *Message;
 public:
-  PrettyStackTraceActionsDecl(Action::DeclTy *Decl, SourceLocation L,
+  PrettyStackTraceActionsDecl(Action::DeclPtrTy Decl, SourceLocation L,
                               Action &actions, SourceManager &sm,
                               const char *Msg)
   : TheDecl(Decl), Loc(L), Actions(actions), SM(sm), Message(Msg) {}

Modified: cfe/trunk/include/clang/Parse/DeclSpec.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/DeclSpec.h?rev=67952&r1=67951&r2=67952&view=diff

==============================================================================
--- cfe/trunk/include/clang/Parse/DeclSpec.h (original)
+++ cfe/trunk/include/clang/Parse/DeclSpec.h Sat Mar 28 14:18:32 2009
@@ -133,7 +133,7 @@
   // List of protocol qualifiers for objective-c classes.  Used for 
   // protocol-qualified interfaces "NString<foo>" and protocol-qualified id
   // "id<foo>".
-  Action::DeclTy * const *ProtocolQualifiers;
+  const Action::DeclPtrTy *ProtocolQualifiers;
   unsigned NumProtocolQualifiers;
   
   // SourceLocation info.  These are null if the item wasn't specified or if
@@ -266,7 +266,7 @@
   bool SetTypeSpecComplex(TSC C, SourceLocation Loc, const char *&PrevSpec);
   bool SetTypeSpecSign(TSS S, SourceLocation Loc, const char *&PrevSpec);
   bool SetTypeSpecType(TST T, SourceLocation Loc, const char *&PrevSpec,
-                       Action::TypeTy *TypeRep = 0);
+                       void *Rep = 0);
   bool SetTypeSpecError();
 
   bool SetTypeQual(TQ T, SourceLocation Loc, const char *&PrevSpec,
@@ -308,18 +308,18 @@
     return AL;
   }
   
-  typedef const Action::DeclTy * const * ProtocolQualifierListTy;
+  typedef const Action::DeclPtrTy *ProtocolQualifierListTy;
   ProtocolQualifierListTy getProtocolQualifiers() const {
     return ProtocolQualifiers;
   }
   unsigned getNumProtocolQualifiers() const {
     return NumProtocolQualifiers;
   }
-  void setProtocolQualifiers(Action::DeclTy* const *Protos, unsigned NumProtos){
-    if (NumProtos == 0) return;
-    ProtocolQualifiers = new Action::DeclTy*[NumProtos];
-    memcpy((void*)ProtocolQualifiers, Protos,sizeof(Action::DeclTy*)*NumProtos);
-    NumProtocolQualifiers = NumProtos;
+  void setProtocolQualifiers(const Action::DeclPtrTy *Protos, unsigned NP) {
+    if (NP == 0) return;
+    ProtocolQualifiers = new Action::DeclPtrTy[NP];
+    memcpy((void*)ProtocolQualifiers, Protos, sizeof(Action::DeclPtrTy)*NP);
+    NumProtocolQualifiers = NP;
   }
   
   /// Finish - This does final analysis of the declspec, issuing diagnostics for
@@ -489,7 +489,7 @@
   struct ParamInfo {
     IdentifierInfo *Ident;
     SourceLocation IdentLoc;
-    Action::DeclTy *Param;
+    Action::DeclPtrTy Param;
 
     /// DefaultArgTokens - When the parameter's default argument
     /// cannot be parsed immediately (because it occurs within the
@@ -499,7 +499,8 @@
     CachedTokens *DefaultArgTokens;
 
     ParamInfo() {}
-    ParamInfo(IdentifierInfo *ident, SourceLocation iloc, Action::DeclTy *param,
+    ParamInfo(IdentifierInfo *ident, SourceLocation iloc,
+              Action::DeclPtrTy param,
               CachedTokens *DefArgTokens = 0)
       : Ident(ident), IdentLoc(iloc), Param(param), 
         DefaultArgTokens(DefArgTokens) {}

Modified: cfe/trunk/include/clang/Parse/Ownership.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Ownership.h?rev=67952&r1=67951&r2=67952&view=diff

==============================================================================
--- cfe/trunk/include/clang/Parse/Ownership.h (original)
+++ cfe/trunk/include/clang/Parse/Ownership.h Sat Mar 28 14:18:32 2009
@@ -14,6 +14,54 @@
 #ifndef LLVM_CLANG_PARSE_OWNERSHIP_H
 #define LLVM_CLANG_PARSE_OWNERSHIP_H
 
+//===----------------------------------------------------------------------===//
+// OpaquePtr
+//===----------------------------------------------------------------------===//
+
+namespace llvm {
+  template <typename T>
+  class PointerLikeTypeInfo;
+}
+
+namespace clang {
+  /// OpaquePtr - This is a very simple POD type that wraps a pointer that the
+  /// Parser doesn't know about but that Sema or another client does.  The UID
+  /// template argument is used to make sure that "Decl" pointers are not
+  /// compatible with "Type" pointers for example.
+  template<int UID>
+  class OpaquePtr {
+    void *Ptr;
+  public:
+    OpaquePtr() : Ptr(0) {}
+    
+    template <typename T>
+    T* getAs() const { return static_cast<T*>(Ptr); }
+    
+    void *get() const { return Ptr; }
+    
+    static OpaquePtr make(void *P) { OpaquePtr R; R.Ptr = P; return R; }
+    void set(void *P) { Ptr = P; }
+    
+    operator bool() const { return Ptr != 0; }
+  };
+}
+
+namespace llvm {
+  template <int UID>
+  class PointerLikeTypeInfo<clang::OpaquePtr<UID> > {
+  public:
+    static inline void *getAsVoidPointer(clang::OpaquePtr<UID> P) {
+      // FIXME: Doesn't work? return P.getAs< void >();
+      return P.get();
+    }
+    static inline clang::OpaquePtr<UID> getFromVoidPointer(void *P) {
+      return clang::OpaquePtr<UID>::make(P);
+    }
+  };
+}
+
+
+
 // -------------------------- About Move Emulation -------------------------- //
 // The smart pointer classes in this file attempt to emulate move semantics
 // as they appear in C++0x with rvalue references. Since C++03 doesn't have
@@ -138,33 +186,37 @@
     /// the action, plus a sense of whether or not it is valid.
     /// When CompressInvalid is true, the "invalid" flag will be
     /// stored in the low bit of the Val pointer. 
-    template<unsigned UID, 
+    template<unsigned UID,
+             typename PtrTy = void*,
              bool CompressInvalid = IsResultPtrLowBitFree<UID>::value>
     class ActionResult {
-      void *Val;
+      PtrTy Val;
       bool Invalid;
 
     public:
-      ActionResult(bool Invalid = false) : Val(0), Invalid(Invalid) {}
+      ActionResult(bool Invalid = false) : Val(PtrTy()), Invalid(Invalid) {}
       template<typename ActualExprTy>
-      ActionResult(ActualExprTy *val) : Val(val), Invalid(false) {}
-      ActionResult(const DiagnosticBuilder &) : Val(0), Invalid(true) {}
+      ActionResult(ActualExprTy val) : Val(val), Invalid(false) {}
+      ActionResult(const DiagnosticBuilder &) : Val(PtrTy()), Invalid(true) {}
 
-      void *get() const { return Val; }
-      void set(void *V) { Val = V; }
+      PtrTy get() const { return Val; }
+      void set(PtrTy V) { Val = V; }
       bool isInvalid() const { return Invalid; }
 
-      const ActionResult &operator=(void *RHS) {
+      const ActionResult &operator=(PtrTy RHS) {
         Val = RHS;
         Invalid = false;
         return *this;
       }
     };
 
+    ///// FIXME: We just lost the ability to bitmangle into DeclPtrTy's and
+    ///// friends!
+
     // This ActionResult partial specialization places the "invalid"
     // flag into the low bit of the pointer.
     template<unsigned UID>
-    class ActionResult<UID, true> {
+    class ActionResult<UID, void*, true> {
       // A pointer whose low bit is 1 if this result is invalid, 0
       // otherwise.
       uintptr_t PtrWithInvalid;

Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=67952&r1=67951&r2=67952&view=diff

==============================================================================
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Sat Mar 28 14:18:32 2009
@@ -119,7 +119,7 @@
   // different actual classes based on the actions in place.
   typedef Action::ExprTy ExprTy;
   typedef Action::StmtTy StmtTy;
-  typedef Action::DeclTy DeclTy;
+  typedef Action::DeclPtrTy DeclPtrTy;
   typedef Action::TypeTy TypeTy;
   typedef Action::BaseTy BaseTy;
   typedef Action::MemInitTy MemInitTy;
@@ -167,7 +167,7 @@
   
   /// ParseTopLevelDecl - Parse one top-level declaration. Returns true if 
   /// the EOF was encountered.
-  bool ParseTopLevelDecl(DeclTy*& Result);
+  bool ParseTopLevelDecl(DeclPtrTy &Result);
   
 private:
   //===--------------------------------------------------------------------===//
@@ -453,9 +453,9 @@
   // Lexing and parsing of C++ inline methods.
 
   struct LexedMethod {
-    Action::DeclTy *D;
+    Action::DeclPtrTy D;
     CachedTokens Toks;
-    explicit LexedMethod(Action::DeclTy *MD) : D(MD) {}
+    explicit LexedMethod(Action::DeclPtrTy MD) : D(MD) {}
   };
 
   /// LateParsedDefaultArgument - Keeps track of a parameter that may
@@ -463,12 +463,12 @@
   /// occurs within a member function declaration inside the class
   /// (C++ [class.mem]p2).
   struct LateParsedDefaultArgument {
-    explicit LateParsedDefaultArgument(Action::DeclTy *P, 
+    explicit LateParsedDefaultArgument(Action::DeclPtrTy P, 
                                        CachedTokens *Toks = 0)
       : Param(P), Toks(Toks) { }
 
     /// Param - The parameter declaration for this parameter.
-    Action::DeclTy *Param;
+    Action::DeclPtrTy Param;
 
     /// Toks - The sequence of tokens that comprises the default
     /// argument expression, not including the '=' or the terminating
@@ -482,10 +482,10 @@
   /// until the class itself is completely-defined, such as a default
   /// argument (C++ [class.mem]p2).
   struct LateParsedMethodDeclaration {
-    explicit LateParsedMethodDeclaration(Action::DeclTy *M) : Method(M) { }
+    explicit LateParsedMethodDeclaration(Action::DeclPtrTy M) : Method(M) { }
 
     /// Method - The method declaration.
-    Action::DeclTy *Method;
+    Action::DeclPtrTy Method;
 
     /// DefaultArgs - Contains the parameters of the function and
     /// their default arguments. At least one of the parameters will
@@ -537,7 +537,7 @@
   }
   void PopTopClassStack() { TopClassStacks.pop(); }
 
-  DeclTy *ParseCXXInlineMethodDef(AccessSpecifier AS, Declarator &D);
+  DeclPtrTy ParseCXXInlineMethodDef(AccessSpecifier AS, Declarator &D);
   void ParseLexedMethodDeclarations();
   void ParseLexedMethodDefs();
   bool ConsumeAndStoreUntil(tok::TokenKind T1, tok::TokenKind T2, 
@@ -547,12 +547,12 @@
 
   //===--------------------------------------------------------------------===//
   // C99 6.9: External Definitions.
-  DeclTy *ParseExternalDeclaration();
-  DeclTy *ParseDeclarationOrFunctionDefinition(
+  DeclPtrTy ParseExternalDeclaration();
+  DeclPtrTy ParseDeclarationOrFunctionDefinition(
             TemplateParameterLists *TemplateParams = 0,
             AccessSpecifier AS = AS_none);
                                                
-  DeclTy *ParseFunctionDefinition(Declarator &D);
+  DeclPtrTy ParseFunctionDefinition(Declarator &D);
   void ParseKNRParamDeclarations(Declarator &D);
   // EndLoc, if non-NULL, is filled with the location of the last token of
   // the simple-asm.
@@ -560,27 +560,27 @@
   OwningExprResult ParseAsmStringLiteral();
 
   // Objective-C External Declarations
-  DeclTy *ParseObjCAtDirectives(); 
-  DeclTy *ParseObjCAtClassDeclaration(SourceLocation atLoc);
-  DeclTy *ParseObjCAtInterfaceDeclaration(SourceLocation atLoc, 
+  DeclPtrTy ParseObjCAtDirectives(); 
+  DeclPtrTy ParseObjCAtClassDeclaration(SourceLocation atLoc);
+  DeclPtrTy ParseObjCAtInterfaceDeclaration(SourceLocation atLoc, 
                                           AttributeList *prefixAttrs = 0);
-  void ParseObjCClassInstanceVariables(DeclTy *interfaceDecl, 
+  void ParseObjCClassInstanceVariables(DeclPtrTy interfaceDecl, 
                                        SourceLocation atLoc);
-  bool ParseObjCProtocolReferences(llvm::SmallVectorImpl<Action::DeclTy*> &P,
+  bool ParseObjCProtocolReferences(llvm::SmallVectorImpl<Action::DeclPtrTy> &P,
                                    bool WarnOnDeclarations, 
                                    SourceLocation &EndProtoLoc);
-  void ParseObjCInterfaceDeclList(DeclTy *interfaceDecl,
+  void ParseObjCInterfaceDeclList(DeclPtrTy interfaceDecl,
                                   tok::ObjCKeywordKind contextKey);
-  DeclTy *ParseObjCAtProtocolDeclaration(SourceLocation atLoc,
-                                         AttributeList *prefixAttrs = 0);
+  DeclPtrTy ParseObjCAtProtocolDeclaration(SourceLocation atLoc,
+                                           AttributeList *prefixAttrs = 0);
   
-  DeclTy *ObjCImpDecl;
+  DeclPtrTy ObjCImpDecl;
 
-  DeclTy *ParseObjCAtImplementationDeclaration(SourceLocation atLoc);
-  DeclTy *ParseObjCAtEndDeclaration(SourceLocation atLoc);
-  DeclTy *ParseObjCAtAliasDeclaration(SourceLocation atLoc);
-  DeclTy *ParseObjCPropertySynthesize(SourceLocation atLoc);
-  DeclTy *ParseObjCPropertyDynamic(SourceLocation atLoc);
+  DeclPtrTy ParseObjCAtImplementationDeclaration(SourceLocation atLoc);
+  DeclPtrTy ParseObjCAtEndDeclaration(SourceLocation atLoc);
+  DeclPtrTy ParseObjCAtAliasDeclaration(SourceLocation atLoc);
+  DeclPtrTy ParseObjCPropertySynthesize(SourceLocation atLoc);
+  DeclPtrTy ParseObjCPropertyDynamic(SourceLocation atLoc);
   
   IdentifierInfo *ParseObjCSelector(SourceLocation &MethodLocation);
   // Definitions for Objective-c context sensitive keywords recognition.
@@ -594,14 +594,14 @@
 
   TypeTy *ParseObjCTypeName(ObjCDeclSpec &DS);
   void ParseObjCMethodRequirement();
-  DeclTy *ParseObjCMethodPrototype(DeclTy *classOrCat,
+  DeclPtrTy ParseObjCMethodPrototype(DeclPtrTy classOrCat,
             tok::ObjCKeywordKind MethodImplKind = tok::objc_not_keyword);
-  DeclTy *ParseObjCMethodDecl(SourceLocation mLoc, tok::TokenKind mType,
-                              DeclTy *classDecl,
+  DeclPtrTy ParseObjCMethodDecl(SourceLocation mLoc, tok::TokenKind mType,
+                                DeclPtrTy classDecl,
             tok::ObjCKeywordKind MethodImplKind = tok::objc_not_keyword);
   void ParseObjCPropertyAttribute(ObjCDeclSpec &DS);
   
-  DeclTy *ParseObjCMethodDefinition();
+  DeclPtrTy ParseObjCMethodDefinition();
   
   //===--------------------------------------------------------------------===//
   // C99 6.5: Expressions.
@@ -807,10 +807,10 @@
   //===--------------------------------------------------------------------===//
   // C99 6.7: Declarations.
   
-  DeclTy *ParseDeclaration(unsigned Context);
-  DeclTy *ParseSimpleDeclaration(unsigned Context);
-  DeclTy *ParseInitDeclaratorListAfterFirstDeclarator(Declarator &D);
-  DeclTy *ParseFunctionStatementBody(DeclTy *Decl);
+  DeclPtrTy ParseDeclaration(unsigned Context);
+  DeclPtrTy ParseSimpleDeclaration(unsigned Context);
+  DeclPtrTy ParseInitDeclaratorListAfterFirstDeclarator(Declarator &D);
+  DeclPtrTy ParseFunctionStatementBody(DeclPtrTy Decl);
   void ParseDeclarationSpecifiers(DeclSpec &DS, 
                                   TemplateParameterLists *TemplateParams = 0,
                                   AccessSpecifier AS = AS_none);
@@ -822,9 +822,9 @@
   void ParseObjCTypeQualifierList(ObjCDeclSpec &DS);
 
   void ParseEnumSpecifier(DeclSpec &DS, AccessSpecifier AS = AS_none);
-  void ParseEnumBody(SourceLocation StartLoc, DeclTy *TagDecl);
+  void ParseEnumBody(SourceLocation StartLoc, DeclPtrTy TagDecl);
   void ParseStructUnionBody(SourceLocation StartLoc, unsigned TagType,
-                            DeclTy *TagDecl);
+                            DeclPtrTy TagDecl);
   void ParseStructDeclaration(DeclSpec &DS,
                               llvm::SmallVectorImpl<FieldDeclarator> &Fields);
                               
@@ -991,13 +991,13 @@
   //===--------------------------------------------------------------------===//
   // C++ 7: Declarations [dcl.dcl]
   
-  DeclTy *ParseNamespace(unsigned Context);
-  DeclTy *ParseLinkage(unsigned Context);
-  DeclTy *ParseUsingDirectiveOrDeclaration(unsigned Context);
-  DeclTy *ParseUsingDirective(unsigned Context, SourceLocation UsingLoc);
-  DeclTy *ParseUsingDeclaration(unsigned Context, SourceLocation UsingLoc);
-  DeclTy *ParseStaticAssertDeclaration();
-  DeclTy *ParseNamespaceAlias(SourceLocation AliasLoc, IdentifierInfo *Alias);
+  DeclPtrTy ParseNamespace(unsigned Context);
+  DeclPtrTy ParseLinkage(unsigned Context);
+  DeclPtrTy ParseUsingDirectiveOrDeclaration(unsigned Context);
+  DeclPtrTy ParseUsingDirective(unsigned Context, SourceLocation UsingLoc);
+  DeclPtrTy ParseUsingDeclaration(unsigned Context, SourceLocation UsingLoc);
+  DeclPtrTy ParseStaticAssertDeclaration();
+  DeclPtrTy ParseNamespaceAlias(SourceLocation AliasLoc, IdentifierInfo *Alias);
   
   //===--------------------------------------------------------------------===//
   // C++ 9: classes [class] and C structs/unions.
@@ -1007,15 +1007,15 @@
                            TemplateParameterLists *TemplateParams = 0,
                            AccessSpecifier AS = AS_none);
   void ParseCXXMemberSpecification(SourceLocation StartLoc, unsigned TagType,
-                                   DeclTy *TagDecl);
-  DeclTy *ParseCXXClassMemberDeclaration(AccessSpecifier AS);
-  void ParseConstructorInitializer(DeclTy *ConstructorDecl);
-  MemInitResult ParseMemInitializer(DeclTy *ConstructorDecl);
+                                   DeclPtrTy TagDecl);
+  DeclPtrTy ParseCXXClassMemberDeclaration(AccessSpecifier AS);
+  void ParseConstructorInitializer(DeclPtrTy ConstructorDecl);
+  MemInitResult ParseMemInitializer(DeclPtrTy ConstructorDecl);
 
   //===--------------------------------------------------------------------===//
   // C++ 10: Derived classes [class.derived]
-  void ParseBaseClause(DeclTy *ClassDecl);
-  BaseResult ParseBaseSpecifier(DeclTy *ClassDecl);
+  void ParseBaseClause(DeclPtrTy ClassDecl);
+  BaseResult ParseBaseSpecifier(DeclPtrTy ClassDecl);
   AccessSpecifier getAccessSpecifierIfPresent() const;
 
   //===--------------------------------------------------------------------===//
@@ -1027,10 +1027,10 @@
 
   //===--------------------------------------------------------------------===//
   // C++ 14: Templates [temp]
-  typedef llvm::SmallVector<DeclTy *, 4> TemplateParameterList;
+  typedef llvm::SmallVector<DeclPtrTy, 4> TemplateParameterList;
 
   // C++ 14.1: Template Parameters [temp.param]
-  DeclTy *ParseTemplateDeclarationOrSpecialization(unsigned Context,
+  DeclPtrTy ParseTemplateDeclarationOrSpecialization(unsigned Context,
                                                    AccessSpecifier AS=AS_none);
   bool ParseTemplateParameters(unsigned Depth, 
                                TemplateParameterList &TemplateParams,
@@ -1038,16 +1038,16 @@
                                SourceLocation &RAngleLoc);
   bool ParseTemplateParameterList(unsigned Depth,
                                   TemplateParameterList &TemplateParams);
-  DeclTy *ParseTemplateParameter(unsigned Depth, unsigned Position);
-  DeclTy *ParseTypeParameter(unsigned Depth, unsigned Position);
-  DeclTy *ParseTemplateTemplateParameter(unsigned Depth, unsigned Position);
-  DeclTy *ParseNonTypeTemplateParameter(unsigned Depth, unsigned Position);
+  DeclPtrTy ParseTemplateParameter(unsigned Depth, unsigned Position);
+  DeclPtrTy ParseTypeParameter(unsigned Depth, unsigned Position);
+  DeclPtrTy ParseTemplateTemplateParameter(unsigned Depth, unsigned Position);
+  DeclPtrTy ParseNonTypeTemplateParameter(unsigned Depth, unsigned Position);
   // C++ 14.3: Template arguments [temp.arg]
   typedef llvm::SmallVector<void *, 16> TemplateArgList;
   typedef llvm::SmallVector<bool, 16> TemplateArgIsTypeList;
   typedef llvm::SmallVector<SourceLocation, 16> TemplateArgLocationList;
 
-  bool ParseTemplateIdAfterTemplateName(DeclTy *Template,
+  bool ParseTemplateIdAfterTemplateName(DeclPtrTy Template,
                                         SourceLocation TemplateNameLoc, 
                                         const CXXScopeSpec *SS,
                                         bool ConsumeLastToken,
@@ -1057,7 +1057,7 @@
                                TemplateArgLocationList &TemplateArgLocations,
                                         SourceLocation &RAngleLoc);
 
-  void AnnotateTemplateIdToken(DeclTy *Template, TemplateNameKind TNK,
+  void AnnotateTemplateIdToken(DeclPtrTy Template, TemplateNameKind TNK,
                                const CXXScopeSpec *SS,
                                SourceLocation TemplateKWLoc = SourceLocation(),
                                bool AllowTypeAnnotation = true);

Modified: cfe/trunk/include/clang/Parse/Scope.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Scope.h?rev=67952&r1=67951&r2=67952&view=diff

==============================================================================
--- cfe/trunk/include/clang/Parse/Scope.h (original)
+++ cfe/trunk/include/clang/Parse/Scope.h Sat Mar 28 14:18:32 2009
@@ -117,7 +117,7 @@
   /// popped, these declarations are removed from the IdentifierTable's notion
   /// of current declaration.  It is up to the current Action implementation to
   /// implement these semantics.
-  typedef llvm::SmallPtrSet<Action::DeclTy*, 32> DeclSetTy;
+  typedef llvm::SmallPtrSet<Action::DeclPtrTy, 32> DeclSetTy;
   DeclSetTy DeclsInScope;
   
   /// Entity - The entity with which this scope is associated. For
@@ -126,7 +126,7 @@
   /// maintained by the Action implementation.
   void *Entity;
 
-  typedef llvm::SmallVector<Action::DeclTy*, 2> UsingDirectivesTy;
+  typedef llvm::SmallVector<Action::DeclPtrTy, 2> UsingDirectivesTy;
   UsingDirectivesTy UsingDirectives;
 
 public:
@@ -191,17 +191,17 @@
   decl_iterator decl_end()   const { return DeclsInScope.end(); }
   bool decl_empty()          const { return DeclsInScope.empty(); }
 
-  void AddDecl(Action::DeclTy *D) {
+  void AddDecl(Action::DeclPtrTy D) {
     DeclsInScope.insert(D);
   }
 
-  void RemoveDecl(Action::DeclTy *D) {
+  void RemoveDecl(Action::DeclPtrTy D) {
     DeclsInScope.erase(D);
   }
 
   /// isDeclScope - Return true if this is the scope that the specified decl is
   /// declared in.
-  bool isDeclScope(Action::DeclTy *D) {
+  bool isDeclScope(Action::DeclPtrTy D) {
     return DeclsInScope.count(D) != 0;
   }
 
@@ -249,7 +249,7 @@
   typedef UsingDirectivesTy::iterator udir_iterator;
   typedef UsingDirectivesTy::const_iterator const_udir_iterator;
 
-  void PushUsingDirective(Action::DeclTy *UDir) {
+  void PushUsingDirective(Action::DeclPtrTy UDir) {
     UsingDirectives.push_back(UDir);
   }
 

Modified: cfe/trunk/lib/Parse/DeclSpec.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/DeclSpec.cpp?rev=67952&r1=67951&r2=67952&view=diff

==============================================================================
--- cfe/trunk/lib/Parse/DeclSpec.cpp (original)
+++ cfe/trunk/lib/Parse/DeclSpec.cpp Sat Mar 28 14:18:32 2009
@@ -225,7 +225,7 @@
 }
 
 bool DeclSpec::SetTypeSpecType(TST T, SourceLocation Loc,
-                               const char *&PrevSpec, Action::TypeTy *Rep) {
+                               const char *&PrevSpec, void *Rep) {
   if (TypeSpecType != TST_unspecified)
     return BadSpecifier((TST)TypeSpecType, PrevSpec);
   TypeSpecType = T;

Modified: cfe/trunk/lib/Parse/MinimalAction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/MinimalAction.cpp?rev=67952&r1=67951&r2=67952&view=diff

==============================================================================
--- cfe/trunk/lib/Parse/MinimalAction.cpp (original)
+++ cfe/trunk/lib/Parse/MinimalAction.cpp Sat Mar 28 14:18:32 2009
@@ -26,19 +26,19 @@
 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 @@
 
 TemplateNameKind 
 MinimalAction::isTemplateName(IdentifierInfo &II, Scope *S,
-                              DeclTy *&TemplateDecl,
+                              DeclPtrTy &TemplateDecl,
                               const CXXScopeSpec *SS) {
   return TNK_Non_template;
 }
@@ -143,12 +143,12 @@
 /// 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 @@
     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 @@
     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 @@
   
   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??");
     

Modified: cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp?rev=67952&r1=67951&r2=67952&view=diff

==============================================================================
--- cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp (original)
+++ cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp Sat Mar 28 14:18:32 2009
@@ -20,14 +20,15 @@
 /// ParseInlineCXXMethodDef - We parsed and verified that the specified
 /// Declarator is a well formed C++ inline method definition. Now lex its body
 /// and store its tokens for parsing after the C++ class is complete.
-Parser::DeclTy *
+Parser::DeclPtrTy
 Parser::ParseCXXInlineMethodDef(AccessSpecifier AS, Declarator &D) {
   assert(D.getTypeObject(0).Kind == DeclaratorChunk::Function &&
          "This isn't a function declarator!");
   assert((Tok.is(tok::l_brace) || Tok.is(tok::colon)) && 
          "Current token not a '{' or ':'!");
 
-  DeclTy *FnD = Actions.ActOnCXXMemberDeclarator(CurScope, AS, D, 0, 0, 0);
+  DeclPtrTy FnD = Actions.ActOnCXXMemberDeclarator(CurScope, AS, D, 0, 0,
+                                                   DeclPtrTy());
 
   // Consume the tokens and store them for later parsing.
 

Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=67952&r1=67951&r2=67952&view=diff

==============================================================================
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Sat Mar 28 14:18:32 2009
@@ -228,7 +228,7 @@
 /// [C++0x] static_assert-declaration
 ///         others... [FIXME]
 ///
-Parser::DeclTy *Parser::ParseDeclaration(unsigned Context) {
+Parser::DeclPtrTy Parser::ParseDeclaration(unsigned Context) {
   switch (Tok.getKind()) {
   case tok::kw_export:
   case tok::kw_template:
@@ -248,7 +248,7 @@
 ///         declaration-specifiers init-declarator-list[opt] ';'
 ///[C90/C++]init-declarator-list ';'                             [TODO]
 /// [OMP]   threadprivate-directive                              [TODO]
-Parser::DeclTy *Parser::ParseSimpleDeclaration(unsigned Context) {
+Parser::DeclPtrTy Parser::ParseSimpleDeclaration(unsigned Context) {
   // Parse the common declaration-specifiers piece.
   DeclSpec DS;
   ParseDeclarationSpecifiers(DS);
@@ -291,12 +291,12 @@
 /// According to the standard grammar, =default and =delete are function
 /// definitions, but that definitely doesn't fit with the parser here.
 ///
-Parser::DeclTy *Parser::
+Parser::DeclPtrTy Parser::
 ParseInitDeclaratorListAfterFirstDeclarator(Declarator &D) {
   
   // Declarators may be grouped together ("int X, *Y, Z();").  Provide info so
   // that they can be chained properly if the actions want this.
-  Parser::DeclTy *LastDeclInGroup = 0;
+  Parser::DeclPtrTy LastDeclInGroup;
   
   // At this point, we know that it is not a function definition.  Parse the
   // rest of the init-declarator-list.
@@ -307,7 +307,7 @@
       OwningExprResult AsmLabel(ParseSimpleAsm(&Loc));
       if (AsmLabel.isInvalid()) {
         SkipUntil(tok::semi);
-        return 0;
+        return DeclPtrTy();
       }
 
       D.setAsmLabel(AsmLabel.release());
@@ -334,7 +334,7 @@
         OwningExprResult Init(ParseInitializer());
         if (Init.isInvalid()) {
           SkipUntil(tok::semi);
-          return 0;
+          return DeclPtrTy();
         }
         Actions.AddInitializerToDecl(LastDeclInGroup, move(Init));
       }
@@ -395,7 +395,7 @@
     // for(is key; in keys) is error.
     if (D.getContext() == Declarator::ForContext && isTokIdentifier_in()) {
       Diag(Tok, diag::err_parse_error);
-      return 0;
+      return DeclPtrTy();
     }
     return Actions.FinalizeDeclaratorGroup(CurScope, LastDeclInGroup);
   }
@@ -411,7 +411,7 @@
   SkipUntil(tok::r_brace, true, true);
   if (Tok.is(tok::semi))
     ConsumeToken();
-  return 0;
+  return DeclPtrTy();
 }
 
 /// ParseSpecifierQualifierList
@@ -560,7 +560,7 @@
         continue;
       
       SourceLocation EndProtoLoc;
-      llvm::SmallVector<DeclTy *, 8> ProtocolDecl;
+      llvm::SmallVector<DeclPtrTy, 8> ProtocolDecl;
       ParseObjCProtocolReferences(ProtocolDecl, false, EndProtoLoc);
       DS.setProtocolQualifiers(&ProtocolDecl[0], ProtocolDecl.size());
       
@@ -614,7 +614,7 @@
         continue;
       
       SourceLocation EndProtoLoc;
-      llvm::SmallVector<DeclTy *, 8> ProtocolDecl;
+      llvm::SmallVector<DeclPtrTy, 8> ProtocolDecl;
       ParseObjCProtocolReferences(ProtocolDecl, false, EndProtoLoc);
       DS.setProtocolQualifiers(&ProtocolDecl[0], ProtocolDecl.size());
       
@@ -809,7 +809,7 @@
         
       {
         SourceLocation EndProtoLoc;
-        llvm::SmallVector<DeclTy *, 8> ProtocolDecl;
+        llvm::SmallVector<DeclPtrTy, 8> ProtocolDecl;
         ParseObjCProtocolReferences(ProtocolDecl, false, EndProtoLoc);
         DS.setProtocolQualifiers(&ProtocolDecl[0], ProtocolDecl.size());
         DS.SetRangeEnd(EndProtoLoc);
@@ -917,7 +917,7 @@
       return true;
     
     SourceLocation EndProtoLoc;
-    llvm::SmallVector<DeclTy *, 8> ProtocolDecl;
+    llvm::SmallVector<DeclPtrTy, 8> ProtocolDecl;
     ParseObjCProtocolReferences(ProtocolDecl, false, EndProtoLoc);
     DS.setProtocolQualifiers(&ProtocolDecl[0], ProtocolDecl.size());
     
@@ -1129,7 +1129,7 @@
 /// [OBC]   '@' 'defs' '(' class-name ')'
 ///
 void Parser::ParseStructUnionBody(SourceLocation RecordLoc,
-                                  unsigned TagType, DeclTy *TagDecl) {
+                                  unsigned TagType, DeclPtrTy TagDecl) {
   PrettyStackTraceActionsDecl CrashInfo(TagDecl, RecordLoc, Actions,
                                         PP.getSourceManager(),
                                         "parsing struct/union body");
@@ -1145,7 +1145,7 @@
     Diag(Tok, diag::ext_empty_struct_union_enum)
       << DeclSpec::getSpecifierName((DeclSpec::TST)TagType);
 
-  llvm::SmallVector<DeclTy*, 32> FieldDecls;
+  llvm::SmallVector<DeclPtrTy, 32> FieldDecls;
   llvm::SmallVector<FieldDeclarator, 8> FieldDeclarators;
 
   // While we still have something to read, read the declarations in the struct.
@@ -1169,9 +1169,9 @@
       for (unsigned i = 0, e = FieldDeclarators.size(); i != e; ++i) {
         FieldDeclarator &FD = FieldDeclarators[i];
         // Install the declarator into the current TagDecl.
-        DeclTy *Field = Actions.ActOnField(CurScope, TagDecl,
-                                           DS.getSourceRange().getBegin(),
-                                           FD.D, FD.BitfieldSize);
+        DeclPtrTy Field = Actions.ActOnField(CurScope, TagDecl,
+                                             DS.getSourceRange().getBegin(),
+                                             FD.D, FD.BitfieldSize);
         FieldDecls.push_back(Field);
       }
     } else { // Handle @defs
@@ -1188,7 +1188,7 @@
         SkipUntil(tok::semi, true, true);
         continue;
       }
-      llvm::SmallVector<DeclTy*, 16> Fields;
+      llvm::SmallVector<DeclPtrTy, 16> Fields;
       Actions.ActOnDefs(CurScope, TagDecl, Tok.getLocation(), 
                         Tok.getIdentifierInfo(), Fields);
       FieldDecls.insert(FieldDecls.end(), Fields.begin(), Fields.end());
@@ -1292,15 +1292,16 @@
     TK = Action::TK_Declaration;
   else
     TK = Action::TK_Reference;
-  DeclTy *TagDecl = Actions.ActOnTag(CurScope, DeclSpec::TST_enum, TK, StartLoc,
-                                     SS, Name, NameLoc, Attr, AS);
+  DeclPtrTy TagDecl = Actions.ActOnTag(CurScope, DeclSpec::TST_enum, TK,
+                                       StartLoc, SS, Name, NameLoc, Attr, AS);
   
   if (Tok.is(tok::l_brace))
     ParseEnumBody(StartLoc, TagDecl);
   
   // TODO: semantic analysis on the declspec for enums.
   const char *PrevSpec = 0;
-  if (DS.SetTypeSpecType(DeclSpec::TST_enum, StartLoc, PrevSpec, TagDecl))
+  if (DS.SetTypeSpecType(DeclSpec::TST_enum, StartLoc, PrevSpec,
+                         TagDecl.getAs<void>()))
     Diag(StartLoc, diag::err_invalid_decl_spec_combination) << PrevSpec;
 }
 
@@ -1314,7 +1315,7 @@
 ///       enumeration-constant:
 ///         identifier
 ///
-void Parser::ParseEnumBody(SourceLocation StartLoc, DeclTy *EnumDecl) {
+void Parser::ParseEnumBody(SourceLocation StartLoc, DeclPtrTy EnumDecl) {
   // Enter the scope of the enum body and start the definition.
   ParseScope EnumScope(this, Scope::DeclScope);
   Actions.ActOnTagStartDefinition(CurScope, EnumDecl);
@@ -1325,9 +1326,9 @@
   if (Tok.is(tok::r_brace) && !getLang().CPlusPlus)
     Diag(Tok, diag::ext_empty_struct_union_enum) << "enum";
   
-  llvm::SmallVector<DeclTy*, 32> EnumConstantDecls;
+  llvm::SmallVector<DeclPtrTy, 32> EnumConstantDecls;
 
-  DeclTy *LastEnumConstDecl = 0;
+  DeclPtrTy LastEnumConstDecl;
   
   // Parse the enumerator-list.
   while (Tok.is(tok::identifier)) {
@@ -1344,11 +1345,11 @@
     }
     
     // Install the enumerator constant into EnumDecl.
-    DeclTy *EnumConstDecl = Actions.ActOnEnumConstant(CurScope, EnumDecl,
-                                                      LastEnumConstDecl,
-                                                      IdentLoc, Ident,
-                                                      EqualLoc,
-                                                      AssignedVal.release());
+    DeclPtrTy EnumConstDecl = Actions.ActOnEnumConstant(CurScope, EnumDecl,
+                                                        LastEnumConstDecl,
+                                                        IdentLoc, Ident,
+                                                        EqualLoc,
+                                                        AssignedVal.release());
     EnumConstantDecls.push_back(EnumConstDecl);
     LastEnumConstDecl = EnumConstDecl;
     
@@ -1366,7 +1367,7 @@
   Actions.ActOnEnumBody(StartLoc, EnumDecl, &EnumConstantDecls[0],
                         EnumConstantDecls.size());
   
-  DeclTy *AttrList = 0;
+  Action::AttrTy *AttrList = 0;
   // If attributes exist after the identifier list, parse them.
   if (Tok.is(tok::kw___attribute))
     AttrList = ParseAttributes(); // FIXME: where do they do?
@@ -2195,7 +2196,7 @@
       
       // Inform the actions module about the parameter declarator, so it gets
       // added to the current scope.
-      DeclTy *Param = Actions.ActOnParamDeclarator(CurScope, ParmDecl);
+      DeclPtrTy Param = Actions.ActOnParamDeclarator(CurScope, ParmDecl);
 
       // Parse the default argument, if any. We parse the default
       // arguments in all dialects; the semantic analysis in
@@ -2300,7 +2301,8 @@
   // identifier in ParamInfo.
   ParamsSoFar.insert(Tok.getIdentifierInfo());
   ParamInfo.push_back(DeclaratorChunk::ParamInfo(Tok.getIdentifierInfo(),
-                                                 Tok.getLocation(), 0));
+                                                 Tok.getLocation(),
+                                                 DeclPtrTy()));
   
   ConsumeToken();  // eat the first identifier.
   
@@ -2327,7 +2329,8 @@
     } else {
       // Remember this identifier in ParamInfo.
       ParamInfo.push_back(DeclaratorChunk::ParamInfo(ParmII,
-                                                     Tok.getLocation(), 0));
+                                                     Tok.getLocation(),
+                                                     DeclPtrTy()));
     }
     
     // Eat the identifier.

Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDeclCXX.cpp?rev=67952&r1=67951&r2=67952&view=diff

==============================================================================
--- cfe/trunk/lib/Parse/ParseDeclCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp Sat Mar 28 14:18:32 2009
@@ -42,7 +42,7 @@
 ///       namespace-alias-definition:  [C++ 7.3.2: namespace.alias]
 ///         'namespace' identifier '=' qualified-namespace-specifier ';'
 ///
-Parser::DeclTy *Parser::ParseNamespace(unsigned Context) {
+Parser::DeclPtrTy Parser::ParseNamespace(unsigned Context) {
   assert(Tok.is(tok::kw_namespace) && "Not a namespace!");
   SourceLocation NamespaceLoc = ConsumeToken();  // eat the 'namespace'.
   
@@ -55,7 +55,7 @@
   }
   
   // Read label attributes, if present.
-  DeclTy *AttrList = 0;
+  Action::AttrTy *AttrList = 0;
   if (Tok.is(tok::kw___attribute))
     // FIXME: save these somewhere.
     AttrList = ParseAttributes();
@@ -70,7 +70,7 @@
     // Enter a scope for the namespace.
     ParseScope NamespaceScope(this, Scope::DeclScope);
 
-    DeclTy *NamespcDecl =
+    DeclPtrTy NamespcDecl =
       Actions.ActOnStartNamespaceDef(CurScope, IdentLoc, Ident, LBrace);
 
     PrettyStackTraceActionsDecl CrashInfo(NamespcDecl, NamespaceLoc, Actions,
@@ -93,14 +93,14 @@
                       diag::err_expected_ident_lbrace);
   }
   
-  return 0;
+  return DeclPtrTy();
 }
 
 /// ParseNamespaceAlias - Parse the part after the '=' in a namespace
 /// alias definition.
 ///
-Parser::DeclTy *Parser::ParseNamespaceAlias(SourceLocation AliasLoc, 
-                                            IdentifierInfo *Alias) {
+Parser::DeclPtrTy Parser::ParseNamespaceAlias(SourceLocation AliasLoc, 
+                                              IdentifierInfo *Alias) {
   assert(Tok.is(tok::equal) && "Not equal token");
   
   ConsumeToken(); // eat the '='.
@@ -113,7 +113,7 @@
     Diag(Tok, diag::err_expected_namespace_name);
     // Skip to end of the definition and eat the ';'.
     SkipUntil(tok::semi);
-    return 0;
+    return DeclPtrTy();
   }
 
   // Parse identifier.
@@ -135,7 +135,7 @@
 ///         'extern' string-literal '{' declaration-seq[opt] '}'
 ///         'extern' string-literal declaration
 ///
-Parser::DeclTy *Parser::ParseLinkage(unsigned Context) {
+Parser::DeclPtrTy Parser::ParseLinkage(unsigned Context) {
   assert(Tok.is(tok::string_literal) && "Not a string literal!");
   llvm::SmallVector<char, 8> LangBuffer;
   // LangBuffer is guaranteed to be big enough.
@@ -146,7 +146,7 @@
   SourceLocation Loc = ConsumeStringToken();
 
   ParseScope LinkageScope(this, Scope::DeclScope);
-  DeclTy *LinkageSpec 
+  DeclPtrTy LinkageSpec 
     = Actions.ActOnStartLinkageSpecification(CurScope, 
                                              /*FIXME: */SourceLocation(),
                                              Loc, LangBufPtr, StrSize,
@@ -170,7 +170,7 @@
 
 /// ParseUsingDirectiveOrDeclaration - Parse C++ using using-declaration or
 /// using-directive. Assumes that current token is 'using'.
-Parser::DeclTy *Parser::ParseUsingDirectiveOrDeclaration(unsigned Context) {
+Parser::DeclPtrTy Parser::ParseUsingDirectiveOrDeclaration(unsigned Context) {
   assert(Tok.is(tok::kw_using) && "Not using token");
 
   // Eat 'using'.
@@ -194,8 +194,8 @@
 ///        'using' 'namespace' ::[opt] nested-name-specifier[opt]
 ///                 namespace-name attributes[opt] ;
 ///
-Parser::DeclTy *Parser::ParseUsingDirective(unsigned Context,
-                                            SourceLocation UsingLoc) {
+Parser::DeclPtrTy Parser::ParseUsingDirective(unsigned Context,
+                                              SourceLocation UsingLoc) {
   assert(Tok.is(tok::kw_namespace) && "Not 'namespace' token");
 
   // Eat 'namespace'.
@@ -215,7 +215,7 @@
     // If there was invalid namespace name, skip to end of decl, and eat ';'.
     SkipUntil(tok::semi);
     // FIXME: Are there cases, when we would like to call ActOnUsingDirective?
-    return 0;
+    return DeclPtrTy();
   }
   
   // Parse identifier.
@@ -242,11 +242,11 @@
 ///               unqualified-id [TODO]
 ///       'using' :: unqualified-id [TODO]
 ///
-Parser::DeclTy *Parser::ParseUsingDeclaration(unsigned Context,
-                                              SourceLocation UsingLoc) {
+Parser::DeclPtrTy Parser::ParseUsingDeclaration(unsigned Context,
+                                                SourceLocation UsingLoc) {
   assert(false && "Not implemented");
   // FIXME: Implement parsing.
-  return 0;
+  return DeclPtrTy();
 }
 
 /// ParseStaticAssertDeclaration - Parse C++0x static_assert-declaratoion.
@@ -254,13 +254,13 @@
 ///      static_assert-declaration:
 ///        static_assert ( constant-expression  ,  string-literal  ) ;
 ///
-Parser::DeclTy *Parser::ParseStaticAssertDeclaration() {
+Parser::DeclPtrTy Parser::ParseStaticAssertDeclaration() {
   assert(Tok.is(tok::kw_static_assert) && "Not a static_assert declaration");
   SourceLocation StaticAssertLoc = ConsumeToken();
   
   if (Tok.isNot(tok::l_paren)) {
     Diag(Tok, diag::err_expected_lparen);
-    return 0;
+    return DeclPtrTy();
   }
   
   SourceLocation LParenLoc = ConsumeParen();
@@ -268,21 +268,21 @@
   OwningExprResult AssertExpr(ParseConstantExpression());
   if (AssertExpr.isInvalid()) {
     SkipUntil(tok::semi);
-    return 0;
+    return DeclPtrTy();
   }
   
   if (ExpectAndConsume(tok::comma, diag::err_expected_comma, "", tok::semi))
-    return 0;
+    return DeclPtrTy();
 
   if (Tok.isNot(tok::string_literal)) {
     Diag(Tok, diag::err_expected_string_literal);
     SkipUntil(tok::semi);
-    return 0;
+    return DeclPtrTy();
   }
   
   OwningExprResult AssertMessage(ParseStringLiteralExpression());
   if (AssertMessage.isInvalid()) 
-    return 0;
+    return DeclPtrTy();
 
   MatchRHSPunctuation(tok::r_paren, LParenLoc);
   
@@ -475,7 +475,7 @@
     TagOrTempResult
       = Actions.ActOnClassTemplateSpecialization(CurScope, TagType, TK,
                        StartLoc, SS,
-                       TemplateId->Template, 
+                       DeclPtrTy::make(TemplateId->Template), 
                        TemplateId->TemplateNameLoc, 
                        TemplateId->LAngleLoc, 
                        TemplateArgsPtr,
@@ -518,7 +518,7 @@
   if (TagOrTempResult.isInvalid())
     DS.SetTypeSpecError();
   else if (DS.SetTypeSpecType(TagType, StartLoc, PrevSpec, 
-                              TagOrTempResult.get()))
+                              TagOrTempResult.get().getAs<void>()))
     Diag(StartLoc, diag::err_invalid_decl_spec_combination) << PrevSpec;
 }
 
@@ -529,8 +529,7 @@
 ///       base-specifier-list:
 ///         base-specifier '...'[opt]
 ///         base-specifier-list ',' base-specifier '...'[opt]
-void Parser::ParseBaseClause(DeclTy *ClassDecl)
-{
+void Parser::ParseBaseClause(DeclPtrTy ClassDecl) {
   assert(Tok.is(tok::colon) && "Not a base clause");
   ConsumeToken();
 
@@ -572,8 +571,7 @@
 ///                        class-name
 ///         access-specifier 'virtual'[opt] ::[opt] nested-name-specifier[opt]
 ///                        class-name
-Parser::BaseResult Parser::ParseBaseSpecifier(DeclTy *ClassDecl)
-{
+Parser::BaseResult Parser::ParseBaseSpecifier(DeclPtrTy ClassDecl) {
   bool IsVirtual = false;
   SourceLocation StartLoc = Tok.getLocation();
 
@@ -666,7 +664,7 @@
 ///       constant-initializer:
 ///         '=' constant-expression
 ///
-Parser::DeclTy *Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS) {
+Parser::DeclPtrTy Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS) {
   // static_assert-declaration
   if (Tok.is(tok::kw_static_assert))
     return ParseStaticAssertDeclaration();
@@ -702,7 +700,7 @@
         return Actions.ParsedFreeStandingDeclSpec(CurScope, DS);
       default:
         Diag(DSStart, diag::err_no_declarators);
-        return 0;
+        return DeclPtrTy();
     }
   }
 
@@ -717,7 +715,7 @@
       SkipUntil(tok::r_brace, true);
       if (Tok.is(tok::semi))
         ConsumeToken();
-      return 0;
+      return DeclPtrTy();
     }
 
     // function-definition:
@@ -727,7 +725,7 @@
         Diag(Tok, diag::err_func_def_no_params);
         ConsumeBrace();
         SkipUntil(tok::r_brace, true);
-        return 0;
+        return DeclPtrTy();
       }
 
       if (DS.getStorageClassSpec() == DeclSpec::SCS_typedef) {
@@ -737,7 +735,7 @@
         // assumes the declarator represents a function, not a typedef.
         ConsumeBrace();
         SkipUntil(tok::r_brace, true);
-        return 0;
+        return DeclPtrTy();
       }
 
       return ParseCXXInlineMethodDef(AS, DeclaratorInfo);
@@ -748,7 +746,7 @@
   //   member-declarator
   //   member-declarator-list ',' member-declarator
 
-  DeclTy *LastDeclInGroup = 0;
+  DeclPtrTy LastDeclInGroup;
   OwningExprResult BitfieldSize(Actions);
   OwningExprResult Init(Actions);
 
@@ -865,7 +863,7 @@
   SkipUntil(tok::r_brace, true, true);
   if (Tok.is(tok::semi))
     ConsumeToken();
-  return 0;
+  return DeclPtrTy();
 }
 
 /// ParseCXXMemberSpecification - Parse the class definition.
@@ -875,7 +873,7 @@
 ///         access-specifier ':' member-specification[opt]
 ///
 void Parser::ParseCXXMemberSpecification(SourceLocation RecordLoc,
-                                         unsigned TagType, DeclTy *TagDecl) {
+                                         unsigned TagType, DeclPtrTy TagDecl) {
   assert((TagType == DeclSpec::TST_struct ||
          TagType == DeclSpec::TST_union  ||
          TagType == DeclSpec::TST_class) && "Invalid TagType!");
@@ -997,7 +995,7 @@
 /// [C++]  mem-initializer-list: 
 ///          mem-initializer 
 ///          mem-initializer , mem-initializer-list 
-void Parser::ParseConstructorInitializer(DeclTy *ConstructorDecl) {
+void Parser::ParseConstructorInitializer(DeclPtrTy ConstructorDecl) {
   assert(Tok.is(tok::colon) && "Constructor initializer always starts with ':'");
 
   SourceLocation ColonLoc = ConsumeToken();
@@ -1035,7 +1033,7 @@
 /// [C++] mem-initializer-id:
 ///         '::'[opt] nested-name-specifier[opt] class-name
 ///         identifier
-Parser::MemInitResult Parser::ParseMemInitializer(DeclTy *ConstructorDecl) {
+Parser::MemInitResult Parser::ParseMemInitializer(DeclPtrTy ConstructorDecl) {
   // FIXME: parse '::'[opt] nested-name-specifier[opt]
 
   if (Tok.isNot(tok::identifier)) {

Modified: cfe/trunk/lib/Parse/ParseExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExprCXX.cpp?rev=67952&r1=67951&r2=67952&view=diff

==============================================================================
--- cfe/trunk/lib/Parse/ParseExprCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExprCXX.cpp Sat Mar 28 14:18:32 2009
@@ -117,7 +117,7 @@
         // an operator and not as part of a simple-template-id.
       }
 
-      DeclTy *Template = 0;
+      DeclPtrTy Template;
       TemplateNameKind TNK = TNK_Non_template;
       // FIXME: If the nested-name-specifier thus far is dependent,
       // set TNK = TNK_Dependent_template_name and skip the

Modified: cfe/trunk/lib/Parse/ParseObjc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseObjc.cpp?rev=67952&r1=67951&r2=67952&view=diff

==============================================================================
--- cfe/trunk/lib/Parse/ParseObjc.cpp (original)
+++ cfe/trunk/lib/Parse/ParseObjc.cpp Sat Mar 28 14:18:32 2009
@@ -28,7 +28,7 @@
 /// [OBJC]  objc-protocol-definition
 /// [OBJC]  objc-method-definition
 /// [OBJC]  '@' 'end'
-Parser::DeclTy *Parser::ParseObjCAtDirectives() {
+Parser::DeclPtrTy Parser::ParseObjCAtDirectives() {
   SourceLocation AtLoc = ConsumeToken(); // the "@"
   
   switch (Tok.getObjCKeywordID()) {
@@ -51,7 +51,7 @@
   default:
     Diag(AtLoc, diag::err_unexpected_at);
     SkipUntil(tok::semi);
-    return 0;
+    return DeclPtrTy();
   }
 }
 
@@ -59,7 +59,7 @@
 /// objc-class-declaration: 
 ///    '@' 'class' identifier-list ';'
 ///  
-Parser::DeclTy *Parser::ParseObjCAtClassDeclaration(SourceLocation atLoc) {
+Parser::DeclPtrTy Parser::ParseObjCAtClassDeclaration(SourceLocation atLoc) {
   ConsumeToken(); // the identifier "class"
   llvm::SmallVector<IdentifierInfo *, 8> ClassNames;
   
@@ -67,7 +67,7 @@
     if (Tok.isNot(tok::identifier)) {
       Diag(Tok, diag::err_expected_ident);
       SkipUntil(tok::semi);
-      return 0;
+      return DeclPtrTy();
     }
     ClassNames.push_back(Tok.getIdentifierInfo());
     ConsumeToken();
@@ -80,7 +80,7 @@
   
   // Consume the ';'.
   if (ExpectAndConsume(tok::semi, diag::err_expected_semi_after, "@class"))
-    return 0;
+    return DeclPtrTy();
   
   return Actions.ActOnForwardClassDeclaration(atLoc,
                                       &ClassNames[0], ClassNames.size());
@@ -114,7 +114,7 @@
 ///     __attribute__((unavailable))
 ///     __attribute__((objc_exception)) - used by NSException on 64-bit
 ///
-Parser::DeclTy *Parser::ParseObjCAtInterfaceDeclaration(
+Parser::DeclPtrTy Parser::ParseObjCAtInterfaceDeclaration(
   SourceLocation atLoc, AttributeList *attrList) {
   assert(Tok.isObjCAtKeyword(tok::objc_interface) &&
          "ParseObjCAtInterfaceDeclaration(): Expected @interface");
@@ -122,7 +122,7 @@
   
   if (Tok.isNot(tok::identifier)) {
     Diag(Tok, diag::err_expected_ident); // missing class or category name.
-    return 0;
+    return DeclPtrTy();
   }
   // We have a class or category name - consume it.
   IdentifierInfo *nameId = Tok.getIdentifierInfo();
@@ -139,26 +139,26 @@
       categoryLoc = ConsumeToken();
     } else if (!getLang().ObjC2) {
       Diag(Tok, diag::err_expected_ident); // missing category name.
-      return 0;
+      return DeclPtrTy();
     }
     if (Tok.isNot(tok::r_paren)) {
       Diag(Tok, diag::err_expected_rparen);
       SkipUntil(tok::r_paren, false); // don't stop at ';'
-      return 0;
+      return DeclPtrTy();
     }
     rparenLoc = ConsumeParen();
     
     // Next, we need to check for any protocol references.
     SourceLocation EndProtoLoc;
-    llvm::SmallVector<DeclTy *, 8> ProtocolRefs;
+    llvm::SmallVector<DeclPtrTy, 8> ProtocolRefs;
     if (Tok.is(tok::less) &&
         ParseObjCProtocolReferences(ProtocolRefs, true, EndProtoLoc))
-      return 0;
+      return DeclPtrTy();
     
     if (attrList) // categories don't support attributes.
       Diag(Tok, diag::err_objc_no_attributes_on_category);
     
-    DeclTy *CategoryType = Actions.ActOnStartCategoryInterface(atLoc, 
+    DeclPtrTy CategoryType = Actions.ActOnStartCategoryInterface(atLoc, 
                                      nameId, nameLoc, categoryId, categoryLoc,
                                      &ProtocolRefs[0], ProtocolRefs.size(),
                                      EndProtoLoc);
@@ -174,19 +174,19 @@
     ConsumeToken();
     if (Tok.isNot(tok::identifier)) {
       Diag(Tok, diag::err_expected_ident); // missing super class name.
-      return 0;
+      return DeclPtrTy();
     }
     superClassId = Tok.getIdentifierInfo();
     superClassLoc = ConsumeToken();
   }
   // Next, we need to check for any protocol references.
-  llvm::SmallVector<Action::DeclTy*, 8> ProtocolRefs;
+  llvm::SmallVector<Action::DeclPtrTy, 8> ProtocolRefs;
   SourceLocation EndProtoLoc;
   if (Tok.is(tok::less) &&
       ParseObjCProtocolReferences(ProtocolRefs, true, EndProtoLoc))
-    return 0;
+    return DeclPtrTy();
   
-  DeclTy *ClsType = 
+  DeclPtrTy ClsType = 
     Actions.ActOnStartClassInterface(atLoc, nameId, nameLoc, 
                                      superClassId, superClassLoc,
                                      &ProtocolRefs[0], ProtocolRefs.size(),
@@ -211,11 +211,11 @@
 ///     @required
 ///     @optional
 ///
-void Parser::ParseObjCInterfaceDeclList(DeclTy *interfaceDecl,
+void Parser::ParseObjCInterfaceDeclList(DeclPtrTy interfaceDecl,
                                         tok::ObjCKeywordKind contextKey) {
-  llvm::SmallVector<DeclTy*, 32> allMethods;
-  llvm::SmallVector<DeclTy*, 16> allProperties;
-  llvm::SmallVector<DeclTy*, 8> allTUVariables;
+  llvm::SmallVector<DeclPtrTy, 32> allMethods;
+  llvm::SmallVector<DeclPtrTy, 16> allProperties;
+  llvm::SmallVector<DeclPtrTy, 8> allTUVariables;
   tok::ObjCKeywordKind MethodImplKind = tok::objc_not_keyword;
   
   SourceLocation AtEndLoc;
@@ -223,7 +223,7 @@
   while (1) {
     // If this is a method prototype, parse it.
     if (Tok.is(tok::minus) || Tok.is(tok::plus)) {
-      DeclTy *methodPrototype = 
+      DeclPtrTy methodPrototype = 
         ParseObjCMethodPrototype(interfaceDecl, MethodImplKind);
       allMethods.push_back(methodPrototype);
       // Consume the ';' here, since ParseObjCMethodPrototype() is re-used for
@@ -253,7 +253,7 @@
       
       // FIXME: as the name implies, this rule allows function definitions.
       // We could pass a flag or check for functions during semantic analysis.
-      DeclTy *VFDecl = ParseDeclarationOrFunctionDefinition();
+      DeclPtrTy VFDecl = ParseDeclarationOrFunctionDefinition();
       allTUVariables.push_back(VFDecl);
       continue;
     }
@@ -337,11 +337,11 @@
                                                          PP.getSelectorTable(),
                                                          FD.D.getIdentifier());
         bool isOverridingProperty = false;
-        DeclTy *Property = Actions.ActOnProperty(CurScope, AtLoc, FD, OCDS,
-                                                 GetterSel, SetterSel,
-                                                 interfaceDecl, 
-                                                 &isOverridingProperty,
-                                                 MethodImplKind);
+        DeclPtrTy Property = Actions.ActOnProperty(CurScope, AtLoc, FD, OCDS,
+                                                   GetterSel, SetterSel,
+                                                   interfaceDecl, 
+                                                   &isOverridingProperty,
+                                                   MethodImplKind);
         if (!isOverridingProperty)
           allProperties.push_back(Property);
       }
@@ -461,14 +461,14 @@
 ///   objc-method-attributes:         [OBJC2]
 ///     __attribute__((deprecated))
 ///
-Parser::DeclTy *Parser::ParseObjCMethodPrototype(DeclTy *IDecl, 
-                          tok::ObjCKeywordKind MethodImplKind) {
+Parser::DeclPtrTy Parser::ParseObjCMethodPrototype(DeclPtrTy IDecl, 
+                                          tok::ObjCKeywordKind MethodImplKind) {
   assert((Tok.is(tok::minus) || Tok.is(tok::plus)) && "expected +/-");
 
   tok::TokenKind methodType = Tok.getKind();  
   SourceLocation mLoc = ConsumeToken();
   
-  DeclTy *MDecl = ParseObjCMethodDecl(mLoc, methodType, IDecl, MethodImplKind);
+  DeclPtrTy MDecl = ParseObjCMethodDecl(mLoc, methodType, IDecl,MethodImplKind);
   // Since this rule is used for both method declarations and definitions,
   // the caller is (optionally) responsible for consuming the ';'.
   return MDecl;
@@ -672,11 +672,10 @@
 ///   objc-keyword-attributes:         [OBJC2]
 ///     __attribute__((unused))
 ///
-Parser::DeclTy *Parser::ParseObjCMethodDecl(SourceLocation mLoc,
-                                            tok::TokenKind mType,
-                                            DeclTy *IDecl,
-                                            tok::ObjCKeywordKind MethodImplKind)
-{
+Parser::DeclPtrTy Parser::ParseObjCMethodDecl(SourceLocation mLoc,
+                                              tok::TokenKind mType,
+                                              DeclPtrTy IDecl,
+                                          tok::ObjCKeywordKind MethodImplKind) {
   // Parse the return type if present.
   TypeTy *ReturnType = 0;
   ObjCDeclSpec DSRet;
@@ -692,7 +691,7 @@
       << SourceRange(mLoc, Tok.getLocation());
     // Skip until we get a ; or {}.
     SkipUntil(tok::r_brace);
-    return 0;
+    return DeclPtrTy();
   }
   
   llvm::SmallVector<Declarator, 8> CargNames;
@@ -789,7 +788,7 @@
 ///     '<' identifier-list '>'
 ///
 bool Parser::
-ParseObjCProtocolReferences(llvm::SmallVectorImpl<Action::DeclTy*> &Protocols,
+ParseObjCProtocolReferences(llvm::SmallVectorImpl<Action::DeclPtrTy> &Protocols,
                             bool WarnOnDeclarations, SourceLocation &EndLoc) {
   assert(Tok.is(tok::less) && "expected <");
   
@@ -847,10 +846,10 @@
 ///   objc-instance-variable-decl:
 ///     struct-declaration 
 ///
-void Parser::ParseObjCClassInstanceVariables(DeclTy *interfaceDecl,
+void Parser::ParseObjCClassInstanceVariables(DeclPtrTy interfaceDecl,
                                              SourceLocation atLoc) {
   assert(Tok.is(tok::l_brace) && "expected {");
-  llvm::SmallVector<DeclTy*, 32> AllIvarDecls;
+  llvm::SmallVector<DeclPtrTy, 32> AllIvarDecls;
   llvm::SmallVector<FieldDeclarator, 8> FieldDeclarators;
 
   ParseScope ClassScope(this, Scope::DeclScope|Scope::ClassScope);
@@ -895,9 +894,9 @@
     for (unsigned i = 0, e = FieldDeclarators.size(); i != e; ++i) {
       FieldDeclarator &FD = FieldDeclarators[i];
       // Install the declarator into interfaceDecl.
-      DeclTy *Field = Actions.ActOnIvar(CurScope,
-                                         DS.getSourceRange().getBegin(),
-                                         FD.D, FD.BitfieldSize, visibility);
+      DeclPtrTy Field = Actions.ActOnIvar(CurScope,
+                                          DS.getSourceRange().getBegin(),
+                                          FD.D, FD.BitfieldSize, visibility);
       AllIvarDecls.push_back(Field);
     }
     
@@ -934,15 +933,15 @@
 ///   "@protocol identifier ;" should be resolved as "@protocol
 ///   identifier-list ;": objc-interface-decl-list may not start with a
 ///   semicolon in the first alternative if objc-protocol-refs are omitted.
-Parser::DeclTy *Parser::ParseObjCAtProtocolDeclaration(SourceLocation AtLoc,
-                                               AttributeList *attrList) {
+Parser::DeclPtrTy Parser::ParseObjCAtProtocolDeclaration(SourceLocation AtLoc,
+                                                      AttributeList *attrList) {
   assert(Tok.isObjCAtKeyword(tok::objc_protocol) &&
          "ParseObjCAtProtocolDeclaration(): Expected @protocol");
   ConsumeToken(); // the "protocol" identifier
   
   if (Tok.isNot(tok::identifier)) {
     Diag(Tok, diag::err_expected_ident); // missing protocol name.
-    return 0;
+    return DeclPtrTy();
   }
   // Save the protocol name, then consume it.
   IdentifierInfo *protocolName = Tok.getIdentifierInfo();
@@ -965,7 +964,7 @@
       if (Tok.isNot(tok::identifier)) {
         Diag(Tok, diag::err_expected_ident);
         SkipUntil(tok::semi);
-        return 0;
+        return DeclPtrTy();
       }
       ProtocolRefs.push_back(IdentifierLocPair(Tok.getIdentifierInfo(),
                                                Tok.getLocation()));
@@ -976,7 +975,7 @@
     }
     // Consume the ';'.
     if (ExpectAndConsume(tok::semi, diag::err_expected_semi_after, "@protocol"))
-      return 0;
+      return DeclPtrTy();
     
     return Actions.ActOnForwardProtocolDeclaration(AtLoc,
                                                    &ProtocolRefs[0], 
@@ -987,12 +986,12 @@
   // Last, and definitely not least, parse a protocol declaration.
   SourceLocation EndProtoLoc;
 
-  llvm::SmallVector<DeclTy *, 8> ProtocolRefs;
+  llvm::SmallVector<DeclPtrTy, 8> ProtocolRefs;
   if (Tok.is(tok::less) &&
       ParseObjCProtocolReferences(ProtocolRefs, true, EndProtoLoc))
-    return 0;
+    return DeclPtrTy();
   
-  DeclTy *ProtoType =
+  DeclPtrTy ProtoType =
     Actions.ActOnStartProtocolInterface(AtLoc, protocolName, nameLoc,
                                         &ProtocolRefs[0], ProtocolRefs.size(),
                                         EndProtoLoc, attrList);
@@ -1010,8 +1009,7 @@
 ///
 ///   objc-category-implementation-prologue:
 ///     @implementation identifier ( identifier )
-
-Parser::DeclTy *Parser::ParseObjCAtImplementationDeclaration(
+Parser::DeclPtrTy Parser::ParseObjCAtImplementationDeclaration(
   SourceLocation atLoc) {
   assert(Tok.isObjCAtKeyword(tok::objc_implementation) &&
          "ParseObjCAtImplementationDeclaration(): Expected @implementation");
@@ -1019,7 +1017,7 @@
   
   if (Tok.isNot(tok::identifier)) {
     Diag(Tok, diag::err_expected_ident); // missing class or category name.
-    return 0;
+    return DeclPtrTy();
   }
   // We have a class or category name - consume it.
   IdentifierInfo *nameId = Tok.getIdentifierInfo();
@@ -1036,19 +1034,19 @@
       categoryLoc = ConsumeToken();
     } else {
       Diag(Tok, diag::err_expected_ident); // missing category name.
-      return 0;
+      return DeclPtrTy();
     }   
     if (Tok.isNot(tok::r_paren)) {
       Diag(Tok, diag::err_expected_rparen);
       SkipUntil(tok::r_paren, false); // don't stop at ';'
-      return 0;
+      return DeclPtrTy();
     }
     rparenLoc = ConsumeParen();
-    DeclTy *ImplCatType = Actions.ActOnStartCategoryImplementation(
+    DeclPtrTy ImplCatType = Actions.ActOnStartCategoryImplementation(
                                     atLoc, nameId, nameLoc, categoryId, 
                                     categoryLoc);
     ObjCImpDecl = ImplCatType;
-    return 0;
+    return DeclPtrTy();
   }
   // We have a class implementation
   SourceLocation superClassLoc;
@@ -1058,12 +1056,12 @@
     ConsumeToken();
     if (Tok.isNot(tok::identifier)) {
       Diag(Tok, diag::err_expected_ident); // missing super class name.
-      return 0;
+      return DeclPtrTy();
     }
     superClassId = Tok.getIdentifierInfo();
     superClassLoc = ConsumeToken(); // Consume super class name
   }
-  DeclTy *ImplClsType = Actions.ActOnStartClassImplementation(
+  DeclPtrTy ImplClsType = Actions.ActOnStartClassImplementation(
                                   atLoc, nameId, nameLoc,
                                   superClassId, superClassLoc);
   
@@ -1071,17 +1069,17 @@
     ParseObjCClassInstanceVariables(ImplClsType/*FIXME*/, atLoc);
   ObjCImpDecl = ImplClsType;
   
-  return 0;
+  return DeclPtrTy();
 }
 
-Parser::DeclTy *Parser::ParseObjCAtEndDeclaration(SourceLocation atLoc) {
+Parser::DeclPtrTy Parser::ParseObjCAtEndDeclaration(SourceLocation atLoc) {
   assert(Tok.isObjCAtKeyword(tok::objc_end) &&
          "ParseObjCAtEndDeclaration(): Expected @end");
-  DeclTy *Result = ObjCImpDecl;
+  DeclPtrTy Result = ObjCImpDecl;
   ConsumeToken(); // the "end" identifier
   if (ObjCImpDecl) {
     Actions.ActOnAtEnd(atLoc, ObjCImpDecl);
-    ObjCImpDecl = 0;
+    ObjCImpDecl = DeclPtrTy();
   }
   else
     Diag(atLoc, diag::warn_expected_implementation); // missing @implementation
@@ -1091,30 +1089,28 @@
 ///   compatibility-alias-decl:
 ///     @compatibility_alias alias-name  class-name ';'
 ///
-Parser::DeclTy *Parser::ParseObjCAtAliasDeclaration(SourceLocation atLoc) {
+Parser::DeclPtrTy Parser::ParseObjCAtAliasDeclaration(SourceLocation atLoc) {
   assert(Tok.isObjCAtKeyword(tok::objc_compatibility_alias) &&
          "ParseObjCAtAliasDeclaration(): Expected @compatibility_alias");
   ConsumeToken(); // consume compatibility_alias
   if (Tok.isNot(tok::identifier)) {
     Diag(Tok, diag::err_expected_ident);
-    return 0;
+    return DeclPtrTy();
   }
   IdentifierInfo *aliasId = Tok.getIdentifierInfo();
   SourceLocation aliasLoc = ConsumeToken(); // consume alias-name
   if (Tok.isNot(tok::identifier)) {
     Diag(Tok, diag::err_expected_ident);
-    return 0;
+    return DeclPtrTy();
   }
   IdentifierInfo *classId = Tok.getIdentifierInfo();
   SourceLocation classLoc = ConsumeToken(); // consume class-name;
   if (Tok.isNot(tok::semi)) {
     Diag(Tok, diag::err_expected_semi_after) << "@compatibility_alias";
-    return 0;
+    return DeclPtrTy();
   }
-  DeclTy *ClsType = Actions.ActOnCompatiblityAlias(atLoc, 
-                                                   aliasId, aliasLoc,
-                                                   classId, classLoc);
-  return ClsType;
+  return Actions.ActOnCompatiblityAlias(atLoc, aliasId, aliasLoc,
+                                        classId, classLoc);
 }
 
 ///   property-synthesis:
@@ -1128,14 +1124,15 @@
 ///     identifier
 ///     identifier '=' identifier
 ///
-Parser::DeclTy *Parser::ParseObjCPropertySynthesize(SourceLocation atLoc) {
+Parser::DeclPtrTy Parser::ParseObjCPropertySynthesize(SourceLocation atLoc) {
   assert(Tok.isObjCAtKeyword(tok::objc_synthesize) &&
          "ParseObjCPropertyDynamic(): Expected '@synthesize'");
   SourceLocation loc = ConsumeToken(); // consume synthesize
   if (Tok.isNot(tok::identifier)) {
     Diag(Tok, diag::err_expected_ident);
-    return 0;
+    return DeclPtrTy();
   }
+  
   while (Tok.is(tok::identifier)) {
     IdentifierInfo *propertyIvar = 0;
     IdentifierInfo *propertyId = Tok.getIdentifierInfo();
@@ -1158,7 +1155,7 @@
   }
   if (Tok.isNot(tok::semi))
     Diag(Tok, diag::err_expected_semi_after) << "@synthesize";
-  return 0;
+  return DeclPtrTy();
 }
 
 ///   property-dynamic:
@@ -1168,13 +1165,13 @@
 ///     identifier
 ///     property-list ',' identifier
 ///
-Parser::DeclTy *Parser::ParseObjCPropertyDynamic(SourceLocation atLoc) {
+Parser::DeclPtrTy Parser::ParseObjCPropertyDynamic(SourceLocation atLoc) {
   assert(Tok.isObjCAtKeyword(tok::objc_dynamic) &&
          "ParseObjCPropertyDynamic(): Expected '@dynamic'");
   SourceLocation loc = ConsumeToken(); // consume dynamic
   if (Tok.isNot(tok::identifier)) {
     Diag(Tok, diag::err_expected_ident);
-    return 0;
+    return DeclPtrTy();
   }
   while (Tok.is(tok::identifier)) {
     IdentifierInfo *propertyId = Tok.getIdentifierInfo();
@@ -1188,7 +1185,7 @@
   }
   if (Tok.isNot(tok::semi))
     Diag(Tok, diag::err_expected_semi_after) << "@dynamic";
-  return 0;
+  return DeclPtrTy();
 }
  
 ///  objc-throw-statement:
@@ -1283,7 +1280,7 @@
 
     SourceLocation AtCatchFinallyLoc = ConsumeToken();
     if (Tok.isObjCAtKeyword(tok::objc_catch)) {
-      DeclTy *FirstPart = 0;
+      DeclPtrTy FirstPart;
       ConsumeToken(); // consume catch
       if (Tok.is(tok::l_paren)) {
         ConsumeParen();
@@ -1348,8 +1345,8 @@
 
 ///   objc-method-def: objc-method-proto ';'[opt] '{' body '}'
 ///
-Parser::DeclTy *Parser::ParseObjCMethodDefinition() {
-  DeclTy *MDecl = ParseObjCMethodPrototype(ObjCImpDecl);
+Parser::DeclPtrTy Parser::ParseObjCMethodDefinition() {
+  DeclPtrTy MDecl = ParseObjCMethodPrototype(ObjCImpDecl);
   
   PrettyStackTraceActionsDecl CrashInfo(MDecl, Tok.getLocation(), Actions,
                                         PP.getSourceManager(),
@@ -1368,7 +1365,7 @@
     
     // If we didn't find the '{', bail out.
     if (Tok.isNot(tok::l_brace))
-      return 0;
+      return DeclPtrTy();
   }
   SourceLocation BraceLoc = Tok.getLocation();
   

Modified: cfe/trunk/lib/Parse/ParseStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseStmt.cpp?rev=67952&r1=67951&r2=67952&view=diff

==============================================================================
--- cfe/trunk/lib/Parse/ParseStmt.cpp (original)
+++ cfe/trunk/lib/Parse/ParseStmt.cpp Sat Mar 28 14:18:32 2009
@@ -101,7 +101,7 @@
   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 @@
   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 @@
       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 @@
       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 @@
   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 @@
 
   // 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))

Modified: cfe/trunk/lib/Parse/ParseTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseTemplate.cpp?rev=67952&r1=67951&r2=67952&view=diff

==============================================================================
--- cfe/trunk/lib/Parse/ParseTemplate.cpp (original)
+++ cfe/trunk/lib/Parse/ParseTemplate.cpp Sat Mar 28 14:18:32 2009
@@ -16,7 +16,6 @@
 #include "clang/Parse/DeclSpec.h"
 #include "clang/Parse/Scope.h"
 #include "AstGuard.h"
-
 using namespace clang;
 
 /// \brief Parse a template declaration or an explicit specialization.
@@ -34,7 +33,7 @@
 ///
 ///       explicit-specialization: [ C++ temp.expl.spec]
 ///         'template' '<' '>' declaration
-Parser::DeclTy *
+Parser::DeclPtrTy
 Parser::ParseTemplateDeclarationOrSpecialization(unsigned Context,
                                                  AccessSpecifier AS) {
   assert((Tok.is(tok::kw_export) || Tok.is(tok::kw_template)) && 
@@ -78,7 +77,7 @@
       TemplateLoc = ConsumeToken();
     } else {
       Diag(Tok.getLocation(), diag::err_expected_template);
-      return 0;
+      return DeclPtrTy();
     }
   
     // Parse the '<' template-parameter-list '>'
@@ -141,7 +140,7 @@
 Parser::ParseTemplateParameterList(unsigned Depth,
                                    TemplateParameterList &TemplateParams) {
   while(1) {
-    if (DeclTy* TmpParam 
+    if (DeclPtrTy TmpParam
           = ParseTemplateParameter(Depth, TemplateParams.size())) {
       TemplateParams.push_back(TmpParam);
     } else {
@@ -183,7 +182,7 @@
 ///         'typename' identifier[opt] '=' type-id
 ///         'template' '<' template-parameter-list '>' 'class' identifier[opt]
 ///         'template' '<' template-parameter-list '>' 'class' identifier[opt] = id-expression
-Parser::DeclTy *
+Parser::DeclPtrTy 
 Parser::ParseTemplateParameter(unsigned Depth, unsigned Position) {
   if(Tok.is(tok::kw_class) ||
      (Tok.is(tok::kw_typename) && 
@@ -210,7 +209,7 @@
 ///         'class' identifier[opt] '=' type-id
 ///         'typename' identifier[opt]
 ///         'typename' identifier[opt] '=' type-id
-Parser::DeclTy *Parser::ParseTypeParameter(unsigned Depth, unsigned Position) {
+Parser::DeclPtrTy Parser::ParseTypeParameter(unsigned Depth, unsigned Position){
   assert((Tok.is(tok::kw_class) || Tok.is(tok::kw_typename)) &&
 	 "A type-parameter starts with 'class' or 'typename'");
 
@@ -230,12 +229,12 @@
     // don't consume this token.
   } else {
     Diag(Tok.getLocation(), diag::err_expected_ident);
-    return 0;
+    return DeclPtrTy();
   }
   
-  DeclTy *TypeParam = Actions.ActOnTypeParameter(CurScope, TypenameKeyword,
-                                                 KeyLoc, ParamName, NameLoc,
-                                                 Depth, Position);
+  DeclPtrTy TypeParam = Actions.ActOnTypeParameter(CurScope, TypenameKeyword,
+                                                   KeyLoc, ParamName, NameLoc,
+                                                   Depth, Position);
 
   // Grab a default type id (if given).
   if(Tok.is(tok::equal)) {
@@ -256,7 +255,7 @@
 ///       type-parameter:    [C++ temp.param]
 ///         'template' '<' template-parameter-list '>' 'class' identifier[opt]
 ///         'template' '<' template-parameter-list '>' 'class' identifier[opt] = id-expression
-Parser::DeclTy * 
+Parser::DeclPtrTy
 Parser::ParseTemplateTemplateParameter(unsigned Depth, unsigned Position) {
   assert(Tok.is(tok::kw_template) && "Expected 'template' keyword");
 
@@ -268,7 +267,7 @@
     ParseScope TemplateParmScope(this, Scope::TemplateParamScope);
     if(!ParseTemplateParameters(Depth + 1, TemplateParams, LAngleLoc,
                                 RAngleLoc)) {
-      return 0;
+      return DeclPtrTy();
     }
   }
 
@@ -277,7 +276,7 @@
   if(!Tok.is(tok::kw_class)) {
     Diag(Tok.getLocation(), diag::err_expected_class_before) 
       << PP.getSpelling(Tok);
-    return 0;
+    return DeclPtrTy();
   }
   SourceLocation ClassLoc = ConsumeToken();
 
@@ -292,7 +291,7 @@
     // don't consume this token.
   } else {
     Diag(Tok.getLocation(), diag::err_expected_ident);
-    return 0;
+    return DeclPtrTy();
   }
 
   TemplateParamsTy *ParamList = 
@@ -302,7 +301,7 @@
                                        TemplateParams.size(),
                                        RAngleLoc);
 
-  Parser::DeclTy * Param
+  Parser::DeclPtrTy Param
     = Actions.ActOnTemplateTemplateParameter(CurScope, TemplateLoc,
                                              ParamList, ParamName,
                                              NameLoc, Depth, Position);
@@ -334,7 +333,7 @@
 /// parameters.
 /// FIXME: We need to make a ParseParameterDeclaration that works for
 /// non-type template parameters and normal function parameters.
-Parser::DeclTy * 
+Parser::DeclPtrTy 
 Parser::ParseNonTypeTemplateParameter(unsigned Depth, unsigned Position) {
   SourceLocation StartLoc = Tok.getLocation();
 
@@ -354,12 +353,12 @@
     // TODO: This is currently a placeholder for some kind of Sema Error.
     Diag(Tok.getLocation(), diag::err_parse_error);
     SkipUntil(tok::comma, tok::greater, true, true);
-    return 0;
+    return DeclPtrTy();
   }
 
   // Create the parameter. 
-  DeclTy *Param = Actions.ActOnNonTypeTemplateParameter(CurScope, ParamDecl,
-                                                        Depth, Position);
+  DeclPtrTy Param = Actions.ActOnNonTypeTemplateParameter(CurScope, ParamDecl,
+                                                          Depth, Position);
 
   // If there is a default value, parse it.
   if (Tok.is(tok::equal)) {
@@ -402,7 +401,7 @@
 /// last token in the stream (e.g., so that it can be replaced with an
 /// annotation token).
 bool 
-Parser::ParseTemplateIdAfterTemplateName(DeclTy *Template,
+Parser::ParseTemplateIdAfterTemplateName(DeclPtrTy Template,
                                          SourceLocation TemplateNameLoc, 
                                          const CXXScopeSpec *SS,
                                          bool ConsumeLastToken,
@@ -495,7 +494,7 @@
 /// replaced with a type annotation token. Otherwise, the
 /// simple-template-id is always replaced with a template-id
 /// annotation token.
-void Parser::AnnotateTemplateIdToken(DeclTy *Template, TemplateNameKind TNK,
+void Parser::AnnotateTemplateIdToken(DeclPtrTy Template, TemplateNameKind TNK,
                                      const CXXScopeSpec *SS, 
                                      SourceLocation TemplateKWLoc,
                                      bool AllowTypeAnnotation) {
@@ -552,7 +551,7 @@
       = TemplateIdAnnotation::Allocate(TemplateArgs.size());
     TemplateId->TemplateNameLoc = TemplateNameLoc;
     TemplateId->Name = Name;
-    TemplateId->Template = Template;
+    TemplateId->Template = Template.getAs<void*>();
     TemplateId->Kind = TNK;
     TemplateId->LAngleLoc = LAngleLoc;
     TemplateId->RAngleLoc = RAngleLoc;
@@ -599,7 +598,7 @@
                                      TemplateId->NumArgs);
 
   Action::TypeResult Type 
-    = Actions.ActOnClassTemplateId(TemplateId->Template, 
+    = Actions.ActOnClassTemplateId(DeclPtrTy::make(TemplateId->Template),
                                    TemplateId->TemplateNameLoc,
                                    TemplateId->LAngleLoc, 
                                    TemplateArgsPtr,

Modified: cfe/trunk/lib/Parse/Parser.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/Parser.cpp?rev=67952&r1=67951&r2=67952&view=diff

==============================================================================
--- cfe/trunk/lib/Parse/Parser.cpp (original)
+++ cfe/trunk/lib/Parse/Parser.cpp Sat Mar 28 14:18:32 2009
@@ -27,7 +27,7 @@
   CurScope = 0;
   NumCachedScopes = 0;
   ParenCount = BracketCount = BraceCount = 0;
-  ObjCImpDecl = 0;
+  ObjCImpDecl = DeclPtrTy();
 
   // Add #pragma handlers. These are removed and destroyed in the
   // destructor.
@@ -324,8 +324,8 @@
 
 /// ParseTopLevelDecl - Parse one top-level declaration, return whatever the
 /// action tells us to.  This returns true if the EOF was encountered.
-bool Parser::ParseTopLevelDecl(DeclTy*& Result) {
-  Result = 0;
+bool Parser::ParseTopLevelDecl(DeclPtrTy &Result) {
+  Result = DeclPtrTy();
   if (Tok.is(tok::eof)) {
     Actions.ActOnEndOfTranslationUnit();
     return true;
@@ -342,7 +342,7 @@
 void Parser::ParseTranslationUnit() {
   Initialize();
 
-  DeclTy *Res;
+  DeclPtrTy Res;
   while (!ParseTopLevelDecl(Res))
     /*parse them all*/;
   
@@ -368,20 +368,20 @@
 /// [GNU] asm-definition:
 ///         simple-asm-expr ';'
 ///
-Parser::DeclTy *Parser::ParseExternalDeclaration() {
+Parser::DeclPtrTy Parser::ParseExternalDeclaration() {
   switch (Tok.getKind()) {
   case tok::semi:
     Diag(Tok, diag::ext_top_level_semi);
     ConsumeToken();
     // TODO: Invoke action for top-level semicolon.
-    return 0;
+    return DeclPtrTy();
   case tok::r_brace:
     Diag(Tok, diag::err_expected_external_declaration);
     ConsumeBrace();
-    return 0;
+    return DeclPtrTy();
   case tok::eof:
     Diag(Tok, diag::err_expected_external_declaration);
-    return 0;
+    return DeclPtrTy();
   case tok::kw___extension__: {
     // __extension__ silences extension warnings in the subexpression.
     ExtensionRAIIObject O(Diags);  // Use RAII to do this.
@@ -396,7 +396,7 @@
 
     if (!Result.isInvalid())
       return Actions.ActOnFileScopeAsmDecl(Tok.getLocation(), move(Result));
-    return 0;
+    return DeclPtrTy();
   }
   case tok::at:
     // @ is not a legal token unless objc is enabled, no need to check.
@@ -405,11 +405,9 @@
   case tok::plus:
     if (getLang().ObjC1)
       return ParseObjCMethodDefinition();
-    else {
-      Diag(Tok, diag::err_expected_external_declaration);
-      ConsumeToken();
-    }
-    return 0;
+    Diag(Tok, diag::err_expected_external_declaration);
+    ConsumeToken();
+    return DeclPtrTy();
   case tok::kw_using:
   case tok::kw_namespace:
   case tok::kw_typedef:
@@ -440,7 +438,7 @@
 /// [!C99]  init-declarator-list ';'                   [TODO: warn in c99 mode]
 /// [OMP]   threadprivate-directive                              [TODO]
 ///
-Parser::DeclTy *
+Parser::DeclPtrTy
 Parser::ParseDeclarationOrFunctionDefinition(
                                   TemplateParameterLists *TemplateParams,
                                   AccessSpecifier AS) {
@@ -464,7 +462,7 @@
         !Tok.isObjCAtKeyword(tok::objc_protocol)) {
       Diag(Tok, diag::err_objc_unexpected_attr);
       SkipUntil(tok::semi); // FIXME: better skip?
-      return 0;
+      return DeclPtrTy();
     }
     const char *PrevSpec = 0;
     if (DS.SetTypeSpecType(DeclSpec::TST_unspecified, AtLoc, PrevSpec))
@@ -491,7 +489,7 @@
     SkipUntil(tok::r_brace, true, true);
     if (Tok.is(tok::semi))
       ConsumeToken();
-    return 0;
+    return DeclPtrTy();
   }
 
   // If the declarator is the start of a function definition, handle it.
@@ -521,7 +519,7 @@
       } else {
         SkipUntil(tok::semi);
       }
-      return 0;
+      return DeclPtrTy();
     }
     return ParseFunctionDefinition(DeclaratorInfo);
   } else {
@@ -530,7 +528,7 @@
     else
       Diag(Tok, diag::err_invalid_token_after_toplevel_declarator);
     SkipUntil(tok::semi);
-    return 0;
+    return DeclPtrTy();
   }
 
   // Parse the init-declarator-list for a normal declaration.
@@ -550,7 +548,7 @@
 /// [C++] function-definition: [C++ 8.4]
 ///         decl-specifier-seq[opt] declarator function-try-block [TODO]
 ///
-Parser::DeclTy *Parser::ParseFunctionDefinition(Declarator &D) {
+Parser::DeclPtrTy Parser::ParseFunctionDefinition(Declarator &D) {
   const DeclaratorChunk &FnTypeInfo = D.getTypeObject(0);
   assert(FnTypeInfo.Kind == DeclaratorChunk::Function &&
          "This isn't a function declarator!");
@@ -584,7 +582,7 @@
 
     // If we didn't find the '{', bail out.
     if (Tok.isNot(tok::l_brace))
-      return 0;
+      return DeclPtrTy();
   }
 
   // Enter a scope for the function body.
@@ -592,7 +590,7 @@
 
   // Tell the actions module that we have entered a function definition with the
   // specified Declarator for the function.
-  DeclTy *Res = Actions.ActOnStartOfFunctionDef(CurScope, D);
+  DeclPtrTy Res = Actions.ActOnStartOfFunctionDef(CurScope, D);
 
   // If we have a colon, then we're probably parsing a C++
   // ctor-initializer.
@@ -652,14 +650,14 @@
 
     // Handle the full declarator list.
     while (1) {
-      DeclTy *AttrList;
+      Action::AttrTy *AttrList;
       // If attributes are present, parse them.
       if (Tok.is(tok::kw___attribute))
         // FIXME: attach attributes too.
         AttrList = ParseAttributes();
 
       // Ask the actions module to compute the type for this declarator.
-      Action::DeclTy *Param =
+      Action::DeclPtrTy Param =
         Actions.ActOnParamDeclarator(CurScope, ParmDeclarator);
 
       if (Param &&
@@ -862,7 +860,7 @@
     
     // If this is a template-id, annotate with a template-id or type token.
     if (NextToken().is(tok::less)) {
-      DeclTy *Template;
+      DeclPtrTy Template;
       if (TemplateNameKind TNK 
             = Actions.isTemplateName(*Tok.getIdentifierInfo(),
                                      CurScope, Template, &SS))

Modified: cfe/trunk/lib/Sema/IdentifierResolver.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/IdentifierResolver.cpp?rev=67952&r1=67951&r2=67952&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/IdentifierResolver.cpp (original)
+++ cfe/trunk/lib/Sema/IdentifierResolver.cpp Sat Mar 28 14:18:32 2009
@@ -112,7 +112,7 @@
            ((DeclContext *)S->getEntity())->isTransparentContext())
       S = S->getParent();
 
-    if (S->isDeclScope(D))
+    if (S->isDeclScope(Action::DeclPtrTy::make(D)))
       return true;
     if (LangOpt.CPlusPlus) {
       // C++ 3.3.2p3:
@@ -129,7 +129,7 @@
       //
       assert(S->getParent() && "No TUScope?");
       if (S->getParent()->getFlags() & Scope::ControlScope)
-        return S->getParent()->isDeclScope(D);
+        return S->getParent()->isDeclScope(Action::DeclPtrTy::make(D));
     }
     return false;
   }

Modified: cfe/trunk/lib/Sema/ParseAST.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/ParseAST.cpp?rev=67952&r1=67951&r2=67952&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/ParseAST.cpp (original)
+++ cfe/trunk/lib/Sema/ParseAST.cpp Sat Mar 28 14:18:32 2009
@@ -44,14 +44,14 @@
   
   Consumer->Initialize(Ctx);
   
-  Parser::DeclTy *ADecl;
+  Parser::DeclPtrTy ADecl;
   
   while (!P.ParseTopLevelDecl(ADecl)) {  // Not end of file.
     // If we got a null return and something *was* parsed, ignore it.  This
     // is due to a top-level semicolon, an action override, or a parse error
     // skipping something.
     if (ADecl) {
-      Decl* D = static_cast<Decl*>(ADecl);      
+      Decl *D = ADecl.getAs<Decl>();      
       Consumer->HandleTopLevelDecl(D);
     }
   };

Modified: cfe/trunk/lib/Sema/Sema.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.cpp?rev=67952&r1=67951&r2=67952&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/Sema.cpp (original)
+++ cfe/trunk/lib/Sema/Sema.cpp Sat Mar 28 14:18:32 2009
@@ -231,10 +231,10 @@
     // Note: we traverse the scope's list of declarations rather than
     // the DeclContext's list, because we only want to see the most
     // recent declaration of each identifier.
-    for (Scope::decl_iterator I = TUScope->decl_begin(), 
-                           IEnd = TUScope->decl_end();
+    for (Scope::decl_iterator I = TUScope->decl_begin(),
+         IEnd = TUScope->decl_end();
          I != IEnd; ++I) {
-      Decl *D = static_cast<Decl *>(*I);
+      Decl *D = (*I).getAs<Decl>();
       if (D->isInvalidDecl())
         continue;
 

Modified: cfe/trunk/lib/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.h?rev=67952&r1=67951&r2=67952&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/Sema.h (original)
+++ cfe/trunk/lib/Sema/Sema.h Sat Mar 28 14:18:32 2009
@@ -307,7 +307,7 @@
   QualType GetTypeForDeclarator(Declarator &D, Scope *S, unsigned Skip = 0);
   DeclarationName GetNameForDeclarator(Declarator &D);
 
-  QualType ObjCGetTypeForMethodDefinition(DeclTy *D);
+  QualType ObjCGetTypeForMethodDefinition(DeclPtrTy D);
 
   bool UnwrapSimilarPointerTypes(QualType& T1, QualType& T2);
 
@@ -326,15 +326,16 @@
 
   /// getDeclName - Return a pretty name for the specified decl if possible, or
   /// an empty string if not.  This is used for pretty crash reporting. 
-  virtual std::string getDeclName(DeclTy *D);
+  virtual std::string getDeclName(DeclPtrTy D);
   
   virtual TypeTy *getTypeName(IdentifierInfo &II, SourceLocation NameLoc, 
                               Scope *S, const CXXScopeSpec *SS);
-  virtual DeclTy *ActOnDeclarator(Scope *S, Declarator &D, DeclTy *LastInGroup){
+  virtual DeclPtrTy ActOnDeclarator(Scope *S, Declarator &D,
+                                    DeclPtrTy LastInGroup){
     return ActOnDeclarator(S, D, LastInGroup, false);
   }
-  DeclTy *ActOnDeclarator(Scope *S, Declarator &D, DeclTy *LastInGroup,
-                          bool IsFunctionDefinition);
+  DeclPtrTy ActOnDeclarator(Scope *S, Declarator &D, DeclPtrTy LastInGroup,
+                            bool IsFunctionDefinition);
   void RegisterLocallyScopedExternCDecl(NamedDecl *ND, NamedDecl *PrevDecl,
                                         Scope *S);
   NamedDecl* ActOnTypedefDeclarator(Scope* S, Declarator& D, DeclContext* DC,
@@ -355,26 +356,26 @@
   bool CheckFunctionDeclaration(FunctionDecl *NewFD, NamedDecl *&PrevDecl,
                                 bool &Redeclaration, 
                                 bool &OverloadableAttrRequired);
-  virtual DeclTy *ActOnParamDeclarator(Scope *S, Declarator &D);
-  virtual void ActOnParamDefaultArgument(DeclTy *param,
+  virtual DeclPtrTy ActOnParamDeclarator(Scope *S, Declarator &D);
+  virtual void ActOnParamDefaultArgument(DeclPtrTy param,
                                          SourceLocation EqualLoc,
                                          ExprArg defarg);
-  virtual void ActOnParamUnparsedDefaultArgument(DeclTy *param, 
+  virtual void ActOnParamUnparsedDefaultArgument(DeclPtrTy param, 
                                                  SourceLocation EqualLoc);
-  virtual void ActOnParamDefaultArgumentError(DeclTy *param);
-  virtual void AddInitializerToDecl(DeclTy *dcl, ExprArg init);
-  void AddInitializerToDecl(DeclTy *dcl, ExprArg init, bool DirectInit);
-  void ActOnUninitializedDecl(DeclTy *dcl);
-  virtual void SetDeclDeleted(DeclTy *dcl, SourceLocation DelLoc);
-  virtual DeclTy *FinalizeDeclaratorGroup(Scope *S, DeclTy *Group);
+  virtual void ActOnParamDefaultArgumentError(DeclPtrTy param);
+  virtual void AddInitializerToDecl(DeclPtrTy dcl, ExprArg init);
+  void AddInitializerToDecl(DeclPtrTy dcl, ExprArg init, bool DirectInit);
+  void ActOnUninitializedDecl(DeclPtrTy dcl);
+  virtual void SetDeclDeleted(DeclPtrTy dcl, SourceLocation DelLoc);
+  virtual DeclPtrTy FinalizeDeclaratorGroup(Scope *S, DeclPtrTy Group);
 
   virtual void ActOnFinishKNRParamDeclarations(Scope *S, Declarator &D);
-  virtual DeclTy *ActOnStartOfFunctionDef(Scope *S, Declarator &D);
-  virtual DeclTy *ActOnStartOfFunctionDef(Scope *S, DeclTy *D);
-  virtual void ActOnStartOfObjCMethodDef(Scope *S, DeclTy *D);
+  virtual DeclPtrTy ActOnStartOfFunctionDef(Scope *S, Declarator &D);
+  virtual DeclPtrTy ActOnStartOfFunctionDef(Scope *S, DeclPtrTy D);
+  virtual void ActOnStartOfObjCMethodDef(Scope *S, DeclPtrTy D);
 
-  virtual DeclTy *ActOnFinishFunctionBody(DeclTy *Decl, StmtArg Body);
-  virtual DeclTy *ActOnFileScopeAsmDecl(SourceLocation Loc, ExprArg expr);
+  virtual DeclPtrTy ActOnFinishFunctionBody(DeclPtrTy Decl, StmtArg Body);
+  virtual DeclPtrTy ActOnFileScopeAsmDecl(SourceLocation Loc, ExprArg expr);
 
   /// Scope actions.
   virtual void ActOnPopScope(SourceLocation Loc, Scope *S);
@@ -382,23 +383,24 @@
 
   /// ParsedFreeStandingDeclSpec - This method is invoked when a declspec with
   /// no declarator (e.g. "struct foo;") is parsed.
-  virtual DeclTy *ParsedFreeStandingDeclSpec(Scope *S, DeclSpec &DS);
+  virtual DeclPtrTy ParsedFreeStandingDeclSpec(Scope *S, DeclSpec &DS);
   
   bool InjectAnonymousStructOrUnionMembers(Scope *S, DeclContext *Owner,
                                            RecordDecl *AnonRecord);
-  virtual DeclTy *BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS, 
-                                              RecordDecl *Record);
+  virtual DeclPtrTy BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS, 
+                                                RecordDecl *Record);
 
-  virtual DeclTy *ActOnTag(Scope *S, unsigned TagSpec, TagKind TK,
-                           SourceLocation KWLoc, const CXXScopeSpec &SS,
-                           IdentifierInfo *Name, SourceLocation NameLoc,
-                           AttributeList *Attr, AccessSpecifier AS);
+  virtual DeclPtrTy ActOnTag(Scope *S, unsigned TagSpec, TagKind TK,
+                             SourceLocation KWLoc, const CXXScopeSpec &SS,
+                             IdentifierInfo *Name, SourceLocation NameLoc,
+                             AttributeList *Attr, AccessSpecifier AS);
   
-  virtual void ActOnDefs(Scope *S, DeclTy *TagD, SourceLocation DeclStart,
+  virtual void ActOnDefs(Scope *S, DeclPtrTy TagD, SourceLocation DeclStart,
                          IdentifierInfo *ClassName,
-                         llvm::SmallVectorImpl<DeclTy*> &Decls);
-  virtual DeclTy *ActOnField(Scope *S, DeclTy *TagD, SourceLocation DeclStart,
-                             Declarator &D, ExprTy *BitfieldWidth);
+                         llvm::SmallVectorImpl<DeclPtrTy> &Decls);
+  virtual DeclPtrTy ActOnField(Scope *S, DeclPtrTy TagD,
+                               SourceLocation DeclStart,
+                               Declarator &D, ExprTy *BitfieldWidth);
 
   FieldDecl *HandleField(Scope *S, RecordDecl *TagD, SourceLocation DeclStart,
                          Declarator &D, Expr *BitfieldWidth,
@@ -410,25 +412,25 @@
                             AccessSpecifier AS, NamedDecl *PrevDecl,
                             Declarator *D = 0);
   
-  virtual DeclTy *ActOnIvar(Scope *S, SourceLocation DeclStart,
-                            Declarator &D, ExprTy *BitfieldWidth,
-                            tok::ObjCKeywordKind visibility);
+  virtual DeclPtrTy ActOnIvar(Scope *S, SourceLocation DeclStart,
+                              Declarator &D, ExprTy *BitfieldWidth,
+                              tok::ObjCKeywordKind visibility);
 
   // This is used for both record definitions and ObjC interface declarations.
   virtual void ActOnFields(Scope* S,
-                           SourceLocation RecLoc, DeclTy *TagDecl,
-                           DeclTy **Fields, unsigned NumFields,
+                           SourceLocation RecLoc, DeclPtrTy TagDecl,
+                           DeclPtrTy *Fields, unsigned NumFields,
                            SourceLocation LBrac, SourceLocation RBrac,
                            AttributeList *AttrList);
 
   /// ActOnTagStartDefinition - Invoked when we have entered the
   /// scope of a tag's definition (e.g., for an enumeration, class,
   /// struct, or union).
-  virtual void ActOnTagStartDefinition(Scope *S, DeclTy *TagDecl);
+  virtual void ActOnTagStartDefinition(Scope *S, DeclPtrTy TagDecl);
 
   /// ActOnTagFinishDefinition - Invoked once we have finished parsing
   /// the definition of a tag (enumeration, class, struct, or union).
-  virtual void ActOnTagFinishDefinition(Scope *S, DeclTy *TagDecl);
+  virtual void ActOnTagFinishDefinition(Scope *S, DeclPtrTy TagDecl);
 
   EnumConstantDecl *CheckEnumConstant(EnumDecl *Enum,
                                       EnumConstantDecl *LastEnumConst,
@@ -436,12 +438,12 @@
                                       IdentifierInfo *Id,
                                       ExprArg val);
 
-  virtual DeclTy *ActOnEnumConstant(Scope *S, DeclTy *EnumDecl,
-                                    DeclTy *LastEnumConstant,
-                                    SourceLocation IdLoc, IdentifierInfo *Id,
-                                    SourceLocation EqualLoc, ExprTy *Val);
-  virtual void ActOnEnumBody(SourceLocation EnumLoc, DeclTy *EnumDecl,
-                             DeclTy **Elements, unsigned NumElements);
+  virtual DeclPtrTy ActOnEnumConstant(Scope *S, DeclPtrTy EnumDecl,
+                                      DeclPtrTy LastEnumConstant,
+                                      SourceLocation IdLoc, IdentifierInfo *Id,
+                                      SourceLocation EqualLoc, ExprTy *Val);
+  virtual void ActOnEnumBody(SourceLocation EnumLoc, DeclPtrTy EnumDecl,
+                             DeclPtrTy *Elements, unsigned NumElements);
 
   DeclContext *getContainingDC(DeclContext *DC);
 
@@ -1082,7 +1084,8 @@
   virtual OwningStmtResult ActOnCompoundStmt(SourceLocation L, SourceLocation R,
                                              MultiStmtArg Elts,
                                              bool isStmtExpr);
-  virtual OwningStmtResult ActOnDeclStmt(DeclTy *Decl, SourceLocation StartLoc,
+  virtual OwningStmtResult ActOnDeclStmt(DeclPtrTy Decl,
+                                         SourceLocation StartLoc,
                                          SourceLocation EndLoc);
   virtual OwningStmtResult ActOnCaseStmt(SourceLocation CaseLoc, ExprArg LHSVal,
                                     SourceLocation DotDotDotLoc, ExprArg RHSVal,
@@ -1147,7 +1150,7 @@
 
   virtual OwningStmtResult ActOnObjCAtCatchStmt(SourceLocation AtLoc,
                                                 SourceLocation RParen,
-                                                DeclTy *Parm, StmtArg Body,
+                                                DeclPtrTy Parm, StmtArg Body,
                                                 StmtArg CatchList);
 
   virtual OwningStmtResult ActOnObjCAtFinallyStmt(SourceLocation AtLoc,
@@ -1164,9 +1167,9 @@
                                                        ExprArg SynchExpr,
                                                        StmtArg SynchBody);
 
-  virtual DeclTy *ActOnExceptionDeclarator(Scope *S, Declarator &D);
+  virtual DeclPtrTy ActOnExceptionDeclarator(Scope *S, Declarator &D);
   virtual OwningStmtResult ActOnCXXCatchBlock(SourceLocation CatchLoc,
-                                              DeclTy *ExDecl,
+                                              DeclPtrTy ExDecl,
                                               StmtArg HandlerBlock);
   virtual OwningStmtResult ActOnCXXTryBlock(SourceLocation TryLoc,
                                             StmtArg TryBlock,
@@ -1255,7 +1258,7 @@
                                                     tok::TokenKind OpKind,
                                                     SourceLocation MemberLoc,
                                                     IdentifierInfo &Member,
-                                                    DeclTy *ImplDecl=0);
+                                                    DeclPtrTy ImplDecl);
   bool ConvertArgumentsForCall(CallExpr *Call, Expr *Fn,
                                FunctionDecl *FDecl,
                                const FunctionProtoType *Proto,
@@ -1358,32 +1361,32 @@
   //===---------------------------- C++ Features --------------------------===//
 
   // Act on C++ namespaces
-  virtual DeclTy *ActOnStartNamespaceDef(Scope *S, SourceLocation IdentLoc,
-                                         IdentifierInfo *Ident,
-                                         SourceLocation LBrace);
-  virtual void ActOnFinishNamespaceDef(DeclTy *Dcl, SourceLocation RBrace);
-
-  virtual DeclTy *ActOnUsingDirective(Scope *CurScope,
-                                      SourceLocation UsingLoc,
-                                      SourceLocation NamespcLoc,
-                                      const CXXScopeSpec &SS,
-                                      SourceLocation IdentLoc,
-                                      IdentifierInfo *NamespcName,
-                                      AttributeList *AttrList);
+  virtual DeclPtrTy ActOnStartNamespaceDef(Scope *S, SourceLocation IdentLoc,
+                                           IdentifierInfo *Ident,
+                                           SourceLocation LBrace);
+  virtual void ActOnFinishNamespaceDef(DeclPtrTy Dcl, SourceLocation RBrace);
+
+  virtual DeclPtrTy ActOnUsingDirective(Scope *CurScope,
+                                        SourceLocation UsingLoc,
+                                        SourceLocation NamespcLoc,
+                                        const CXXScopeSpec &SS,
+                                        SourceLocation IdentLoc,
+                                        IdentifierInfo *NamespcName,
+                                        AttributeList *AttrList);
   
   void PushUsingDirective(Scope *S, UsingDirectiveDecl *UDir);
 
-  virtual DeclTy *ActOnNamespaceAliasDef(Scope *CurScope,
-                                         SourceLocation AliasLoc,
-                                         IdentifierInfo *Alias,
-                                         const CXXScopeSpec &SS,
-                                         SourceLocation NamespaceLoc,
-                                         IdentifierInfo *NamespaceName);
+  virtual DeclPtrTy ActOnNamespaceAliasDef(Scope *CurScope,
+                                           SourceLocation AliasLoc,
+                                           IdentifierInfo *Alias,
+                                           const CXXScopeSpec &SS,
+                                           SourceLocation NamespaceLoc,
+                                           IdentifierInfo *NamespaceName);
   
   /// AddCXXDirectInitializerToDecl - This action is called immediately after 
   /// ActOnDeclarator, when a C++ direct initializer is present.
   /// e.g: "int x(1);"
-  virtual void AddCXXDirectInitializerToDecl(DeclTy *Dcl,
+  virtual void AddCXXDirectInitializerToDecl(DeclPtrTy Dcl,
                                              SourceLocation LParenLoc,
                                              MultiExprArg Exprs,
                                              SourceLocation *CommaLocs,
@@ -1565,15 +1568,15 @@
   //===--------------------------------------------------------------------===//
   // C++ Declarations
   //
-  virtual DeclTy *ActOnStartLinkageSpecification(Scope *S,
-                                                 SourceLocation ExternLoc,
-                                                 SourceLocation LangLoc,
-                                                 const char *Lang,
-                                                 unsigned StrSize,
-                                                 SourceLocation LBraceLoc);
-  virtual DeclTy *ActOnFinishLinkageSpecification(Scope *S,
-                                                  DeclTy *LinkageSpec,
-                                                  SourceLocation RBraceLoc);
+  virtual DeclPtrTy ActOnStartLinkageSpecification(Scope *S,
+                                                   SourceLocation ExternLoc,
+                                                   SourceLocation LangLoc,
+                                                   const char *Lang,
+                                                   unsigned StrSize,
+                                                   SourceLocation LBraceLoc);
+  virtual DeclPtrTy ActOnFinishLinkageSpecification(Scope *S,
+                                                    DeclPtrTy LinkageSpec,
+                                                    SourceLocation RBraceLoc);
 
 
   //===--------------------------------------------------------------------===//
@@ -1582,11 +1585,13 @@
   virtual bool isCurrentClassName(const IdentifierInfo &II, Scope *S,
                                   const CXXScopeSpec *SS);
   
-  virtual DeclTy *ActOnCXXMemberDeclarator(Scope *S, AccessSpecifier AS,
-                                           Declarator &D, ExprTy *BitfieldWidth,
-                                           ExprTy *Init, DeclTy *LastInGroup);
+  virtual DeclPtrTy ActOnCXXMemberDeclarator(Scope *S, AccessSpecifier AS,
+                                             Declarator &D,
+                                             ExprTy *BitfieldWidth,
+                                             ExprTy *Init,
+                                             DeclPtrTy LastInGroup);
 
-  virtual MemInitResult ActOnMemInitializer(DeclTy *ConstructorD,
+  virtual MemInitResult ActOnMemInitializer(DeclPtrTy ConstructorD,
                                             Scope *S,
                                             IdentifierInfo *MemberOrBase,
                                             SourceLocation IdLoc,
@@ -1597,22 +1602,24 @@
 
   void AddImplicitlyDeclaredMembersToClass(CXXRecordDecl *ClassDecl);
 
-  virtual void ActOnMemInitializers(DeclTy *ConstructorDecl, 
+  virtual void ActOnMemInitializers(DeclPtrTy ConstructorDecl, 
                                     SourceLocation ColonLoc,
                                     MemInitTy **MemInits, unsigned NumMemInits);
   
   virtual void ActOnFinishCXXMemberSpecification(Scope* S, SourceLocation RLoc,
-                                                 DeclTy *TagDecl,
+                                                 DeclPtrTy TagDecl,
                                                  SourceLocation LBrac,
                                                  SourceLocation RBrac);
 
-  virtual void ActOnStartDelayedCXXMethodDeclaration(Scope *S, DeclTy *Method);
-  virtual void ActOnDelayedCXXMethodParameter(Scope *S, DeclTy *Param);
-  virtual void ActOnFinishDelayedCXXMethodDeclaration(Scope *S, DeclTy *Method);
-
-  virtual DeclTy *ActOnStaticAssertDeclaration(SourceLocation AssertLoc, 
-                                               ExprArg AssertExpr,
-                                               ExprArg AssertMessageExpr);
+  virtual void ActOnStartDelayedCXXMethodDeclaration(Scope *S,
+                                                     DeclPtrTy Method);
+  virtual void ActOnDelayedCXXMethodParameter(Scope *S, DeclPtrTy Param);
+  virtual void ActOnFinishDelayedCXXMethodDeclaration(Scope *S,
+                                                      DeclPtrTy Method);
+
+  virtual DeclPtrTy ActOnStaticAssertDeclaration(SourceLocation AssertLoc, 
+                                                 ExprArg AssertExpr,
+                                                 ExprArg AssertMessageExpr);
   
   bool CheckConstructorDeclarator(Declarator &D, QualType &R,
                                   FunctionDecl::StorageClass& SC);
@@ -1621,7 +1628,7 @@
                                  FunctionDecl::StorageClass& SC);
   bool CheckConversionDeclarator(Declarator &D, QualType &R,
                                  FunctionDecl::StorageClass& SC);
-  DeclTy *ActOnConversionDeclarator(CXXConversionDecl *Conversion);
+  DeclPtrTy ActOnConversionDeclarator(CXXConversionDecl *Conversion);
 
   //===--------------------------------------------------------------------===//
   // C++ Derived Classes
@@ -1633,7 +1640,7 @@
                                        bool Virtual, AccessSpecifier Access,
                                        QualType BaseType, 
                                        SourceLocation BaseLoc);
-  virtual BaseResult ActOnBaseSpecifier(DeclTy *classdecl, 
+  virtual BaseResult ActOnBaseSpecifier(DeclPtrTy classdecl, 
                                         SourceRange SpecifierRange,
                                         bool Virtual, AccessSpecifier Access,
                                         TypeTy *basetype, SourceLocation 
@@ -1641,7 +1648,7 @@
 
   bool AttachBaseSpecifiers(CXXRecordDecl *Class, CXXBaseSpecifier **Bases,
                             unsigned NumBases);
-  virtual void ActOnBaseSpecifiers(DeclTy *ClassDecl, BaseTy **Bases, 
+  virtual void ActOnBaseSpecifiers(DeclPtrTy ClassDecl, BaseTy **Bases, 
                                    unsigned NumBases);
 
   bool IsDerivedFrom(QualType Derived, QualType Base);
@@ -1686,36 +1693,36 @@
   // C++ Templates [C++ 14]
   //
   virtual TemplateNameKind isTemplateName(IdentifierInfo &II, Scope *S,
-                                          DeclTy *&TemplateDecl,
+                                          DeclPtrTy &TemplateDecl,
                                           const CXXScopeSpec *SS = 0);
   bool DiagnoseTemplateParameterShadow(SourceLocation Loc, Decl *PrevDecl);
-  TemplateDecl *AdjustDeclIfTemplate(DeclTy *&Decl);
+  TemplateDecl *AdjustDeclIfTemplate(DeclPtrTy &Decl);
 
-  virtual DeclTy *ActOnTypeParameter(Scope *S, bool Typename,
-                                     SourceLocation KeyLoc,
-                                     IdentifierInfo *ParamName,
-                                     SourceLocation ParamNameLoc,
-                                     unsigned Depth, unsigned Position);
-  virtual void ActOnTypeParameterDefault(DeclTy *TypeParam, 
+  virtual DeclPtrTy ActOnTypeParameter(Scope *S, bool Typename,
+                                       SourceLocation KeyLoc,
+                                       IdentifierInfo *ParamName,
+                                       SourceLocation ParamNameLoc,
+                                       unsigned Depth, unsigned Position);
+  virtual void ActOnTypeParameterDefault(DeclPtrTy TypeParam, 
                                          SourceLocation EqualLoc,
                                          SourceLocation DefaultLoc,
                                          TypeTy *Default);
 
   QualType CheckNonTypeTemplateParameterType(QualType T, SourceLocation Loc);
-  virtual DeclTy *ActOnNonTypeTemplateParameter(Scope *S, Declarator &D,
-                                                unsigned Depth,
-                                                unsigned Position);
-  virtual void ActOnNonTypeTemplateParameterDefault(DeclTy *TemplateParam,
+  virtual DeclPtrTy ActOnNonTypeTemplateParameter(Scope *S, Declarator &D,
+                                                  unsigned Depth,
+                                                  unsigned Position);
+  virtual void ActOnNonTypeTemplateParameterDefault(DeclPtrTy TemplateParam,
                                                     SourceLocation EqualLoc,
                                                     ExprArg Default);
-  virtual DeclTy *ActOnTemplateTemplateParameter(Scope *S,
-                                                 SourceLocation TmpLoc,
-                                                 TemplateParamsTy *Params,
-                                                 IdentifierInfo *ParamName,
-                                                 SourceLocation ParamNameLoc,
-                                                 unsigned Depth,
-                                                 unsigned Position);
-  virtual void ActOnTemplateTemplateParameterDefault(DeclTy *TemplateParam,
+  virtual DeclPtrTy ActOnTemplateTemplateParameter(Scope *S,
+                                                   SourceLocation TmpLoc,
+                                                   TemplateParamsTy *Params,
+                                                   IdentifierInfo *ParamName,
+                                                   SourceLocation ParamNameLoc,
+                                                   unsigned Depth,
+                                                   unsigned Position);
+  virtual void ActOnTemplateTemplateParameterDefault(DeclPtrTy TemplateParam,
                                                      SourceLocation EqualLoc,
                                                      ExprArg Default);
 
@@ -1724,7 +1731,7 @@
                              SourceLocation ExportLoc,
                              SourceLocation TemplateLoc, 
                              SourceLocation LAngleLoc,
-                             DeclTy **Params, unsigned NumParams,
+                             DeclPtrTy *Params, unsigned NumParams,
                              SourceLocation RAngleLoc);
   bool CheckTemplateParameterList(TemplateParameterList *NewParams,
                                   TemplateParameterList *OldParams);
@@ -1745,7 +1752,7 @@
                                 SourceLocation RAngleLoc);
 
   virtual TypeResult
-  ActOnClassTemplateId(DeclTy *Template, SourceLocation TemplateLoc,
+  ActOnClassTemplateId(DeclPtrTy Template, SourceLocation TemplateLoc,
                        SourceLocation LAngleLoc,
                        ASTTemplateArgsPtr TemplateArgs,
                        SourceLocation *TemplateArgLocs,
@@ -1761,7 +1768,7 @@
   ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec, TagKind TK,
                                    SourceLocation KWLoc, 
                                    const CXXScopeSpec &SS,
-                                   DeclTy *Template,
+                                   DeclPtrTy Template,
                                    SourceLocation TemplateNameLoc,
                                    SourceLocation LAngleLoc,
                                    ASTTemplateArgsPtr TemplateArgs,
@@ -1981,17 +1988,17 @@
   }
   
   // Objective-C declarations.
-  virtual DeclTy *ActOnStartClassInterface(SourceLocation AtInterfaceLoc,
-                                           IdentifierInfo *ClassName,
-                                           SourceLocation ClassLoc,
-                                           IdentifierInfo *SuperName,
-                                           SourceLocation SuperLoc,
-                                           DeclTy * const *ProtoRefs,
-                                           unsigned NumProtoRefs,
-                                           SourceLocation EndProtoLoc,
-                                           AttributeList *AttrList);
+  virtual DeclPtrTy ActOnStartClassInterface(SourceLocation AtInterfaceLoc,
+                                             IdentifierInfo *ClassName,
+                                             SourceLocation ClassLoc,
+                                             IdentifierInfo *SuperName,
+                                             SourceLocation SuperLoc,
+                                             const DeclPtrTy *ProtoRefs,
+                                             unsigned NumProtoRefs,
+                                             SourceLocation EndProtoLoc,
+                                             AttributeList *AttrList);
   
-  virtual DeclTy *ActOnCompatiblityAlias(
+  virtual DeclPtrTy ActOnCompatiblityAlias(
                     SourceLocation AtCompatibilityAliasLoc,
                     IdentifierInfo *AliasName,  SourceLocation AliasLocation,
                     IdentifierInfo *ClassName, SourceLocation ClassLocation);
@@ -2001,40 +2008,40 @@
     SourceLocation &PLoc, SourceLocation PrevLoc,
     const ObjCList<ObjCProtocolDecl> &PList);
                     
-  virtual DeclTy *ActOnStartProtocolInterface(
+  virtual DeclPtrTy ActOnStartProtocolInterface(
                     SourceLocation AtProtoInterfaceLoc,
                     IdentifierInfo *ProtocolName, SourceLocation ProtocolLoc,
-                    DeclTy * const *ProtoRefNames, unsigned NumProtoRefs,
+                    const DeclPtrTy *ProtoRefNames, unsigned NumProtoRefs,
                     SourceLocation EndProtoLoc,
                     AttributeList *AttrList);
   
-  virtual DeclTy *ActOnStartCategoryInterface(SourceLocation AtInterfaceLoc,
-                                              IdentifierInfo *ClassName,
-                                              SourceLocation ClassLoc,
-                                              IdentifierInfo *CategoryName,
-                                              SourceLocation CategoryLoc,
-                                              DeclTy * const *ProtoRefs,
-                                              unsigned NumProtoRefs,
-                                              SourceLocation EndProtoLoc);
+  virtual DeclPtrTy ActOnStartCategoryInterface(SourceLocation AtInterfaceLoc,
+                                                IdentifierInfo *ClassName,
+                                                SourceLocation ClassLoc,
+                                                IdentifierInfo *CategoryName,
+                                                SourceLocation CategoryLoc,
+                                                const DeclPtrTy *ProtoRefs,
+                                                unsigned NumProtoRefs,
+                                                SourceLocation EndProtoLoc);
   
-  virtual DeclTy *ActOnStartClassImplementation(
+  virtual DeclPtrTy ActOnStartClassImplementation(
                     SourceLocation AtClassImplLoc,
                     IdentifierInfo *ClassName, SourceLocation ClassLoc,
                     IdentifierInfo *SuperClassname, 
                     SourceLocation SuperClassLoc);
   
-  virtual DeclTy *ActOnStartCategoryImplementation(
+  virtual DeclPtrTy ActOnStartCategoryImplementation(
                                                   SourceLocation AtCatImplLoc,
                                                   IdentifierInfo *ClassName, 
                                                   SourceLocation ClassLoc,
                                                   IdentifierInfo *CatName,
                                                   SourceLocation CatLoc);
   
-  virtual DeclTy *ActOnForwardClassDeclaration(SourceLocation Loc,
+  virtual DeclPtrTy ActOnForwardClassDeclaration(SourceLocation Loc,
                                                IdentifierInfo **IdentList,
                                                unsigned NumElts);
   
-  virtual DeclTy *ActOnForwardProtocolDeclaration(SourceLocation AtProtocolLoc,
+  virtual DeclPtrTy ActOnForwardProtocolDeclaration(SourceLocation AtProtocolLoc,
                                             const IdentifierLocPair *IdentList,
                                                   unsigned NumElts,
                                                   AttributeList *attrList);
@@ -2042,7 +2049,7 @@
   virtual void FindProtocolDeclaration(bool WarnOnDeclarations,
                                        const IdentifierLocPair *ProtocolId,
                                        unsigned NumProtocols,
-                                   llvm::SmallVectorImpl<DeclTy *> &Protocols);
+                                   llvm::SmallVectorImpl<DeclPtrTy> &Protocols);
   
   /// Ensure attributes are consistent with type. 
   /// \param [in, out] Attributes The attributes to check; they will
@@ -2057,7 +2064,7 @@
   void ComparePropertiesInBaseAndSuper(ObjCInterfaceDecl *IDecl);
   
   void MergeProtocolPropertiesIntoClass(Decl *CDecl,
-                                        DeclTy *MergeProtocols);
+                                        DeclPtrTy MergeProtocols);
   
   void DiagnoseClassExtensionDupMethods(ObjCCategoryDecl *CAT, 
                                         ObjCInterfaceDecl *ID);
@@ -2065,28 +2072,29 @@
   void MergeOneProtocolPropertiesIntoClass(Decl *CDecl,
                                            ObjCProtocolDecl *PDecl);
   
-  virtual void ActOnAtEnd(SourceLocation AtEndLoc, DeclTy *classDecl,
-                      DeclTy **allMethods = 0, unsigned allNum = 0,
-                      DeclTy **allProperties = 0, unsigned pNum = 0,
-                      DeclTy **allTUVars = 0, unsigned tuvNum = 0);
-  
-  virtual DeclTy *ActOnProperty(Scope *S, SourceLocation AtLoc,
-                                FieldDeclarator &FD, ObjCDeclSpec &ODS,
-                                Selector GetterSel, Selector SetterSel,
-                                DeclTy *ClassCategory, bool *OverridingProperty,
-                                tok::ObjCKeywordKind MethodImplKind);
-  
-  virtual DeclTy *ActOnPropertyImplDecl(SourceLocation AtLoc, 
-                                        SourceLocation PropertyLoc,
-                                        bool ImplKind, DeclTy *ClassImplDecl,
-                                        IdentifierInfo *PropertyId,
-                                        IdentifierInfo *PropertyIvar);
+  virtual void ActOnAtEnd(SourceLocation AtEndLoc, DeclPtrTy classDecl,
+                      DeclPtrTy *allMethods = 0, unsigned allNum = 0,
+                      DeclPtrTy *allProperties = 0, unsigned pNum = 0,
+                      DeclPtrTy *allTUVars = 0, unsigned tuvNum = 0);
+  
+  virtual DeclPtrTy ActOnProperty(Scope *S, SourceLocation AtLoc,
+                                  FieldDeclarator &FD, ObjCDeclSpec &ODS,
+                                  Selector GetterSel, Selector SetterSel,
+                                  DeclPtrTy ClassCategory,
+                                  bool *OverridingProperty,
+                                  tok::ObjCKeywordKind MethodImplKind);
+  
+  virtual DeclPtrTy ActOnPropertyImplDecl(SourceLocation AtLoc, 
+                                          SourceLocation PropertyLoc,
+                                          bool ImplKind,DeclPtrTy ClassImplDecl,
+                                          IdentifierInfo *PropertyId,
+                                          IdentifierInfo *PropertyIvar);
   
-  virtual DeclTy *ActOnMethodDeclaration(
+  virtual DeclPtrTy ActOnMethodDeclaration(
     SourceLocation BeginLoc, // location of the + or -.
     SourceLocation EndLoc,   // location of the ; or {.
     tok::TokenKind MethodType, 
-    DeclTy *ClassDecl, ObjCDeclSpec &ReturnQT, TypeTy *ReturnType, 
+    DeclPtrTy ClassDecl, ObjCDeclSpec &ReturnQT, TypeTy *ReturnType, 
     Selector Sel,
     // optional arguments. The number of types/arguments is obtained
     // from the Sel.getNumArgs().

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=67952&r1=67951&r2=67952&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Sat Mar 28 14:18:32 2009
@@ -32,8 +32,8 @@
 
 /// getDeclName - Return a pretty name for the specified decl if possible, or
 /// an empty string if not.  This is used for pretty crash reporting. 
-std::string Sema::getDeclName(DeclTy *d) {
-  Decl *D = static_cast<Decl *>(d);
+std::string Sema::getDeclName(DeclPtrTy d) {
+  Decl *D = d.getAs<Decl>();
   if (NamedDecl *DN = dyn_cast_or_null<NamedDecl>(D))
     return DN->getQualifiedNameAsString();
   return "";
@@ -177,7 +177,7 @@
          ((DeclContext *)S->getEntity())->isTransparentContext())
     S = S->getParent();
 
-  S->AddDecl(D);
+  S->AddDecl(DeclPtrTy::make(D));
 
   // Add scoped declarations into their context, so that they can be
   // found later. Declarations without a context won't be inserted
@@ -207,7 +207,7 @@
             // This is a redeclaration. Remove it from the chain and
             // break out, so that we'll add in the shadowed
             // declaration.
-            S->RemoveDecl(*I);
+            S->RemoveDecl(DeclPtrTy::make(*I));
             if (PrevDecl == *I) {
               IdResolver.RemoveDecl(*I);
               IdResolver.AddDecl(TD);
@@ -238,10 +238,11 @@
                      IdResolver.end(),
                      std::bind1st(std::mem_fun(&NamedDecl::declarationReplaces),
                                   FD));
-    if (Redecl != IdResolver.end() && S->isDeclScope(*Redecl)) {
+    if (Redecl != IdResolver.end() &&
+        S->isDeclScope(DeclPtrTy::make(*Redecl))) {
       // There is already a declaration of a function on our
       // IdResolver chain. Replace it with this declaration.
-      S->RemoveDecl(*Redecl);
+      S->RemoveDecl(DeclPtrTy::make(*Redecl));
       IdResolver.RemoveDecl(*Redecl);
     }
   }
@@ -256,7 +257,7 @@
 
   for (Scope::decl_iterator I = S->decl_begin(), E = S->decl_end();
        I != E; ++I) {
-    Decl *TmpD = static_cast<Decl*>(*I);
+    Decl *TmpD = (*I).getAs<Decl>();
     assert(TmpD && "This decl didn't get pushed??");
 
     assert(isa<NamedDecl>(TmpD) && "Decl isn't NamedDecl?");
@@ -903,7 +904,7 @@
 
 /// ParsedFreeStandingDeclSpec - This method is invoked when a declspec with
 /// no declarator (e.g. "struct foo;") is parsed.
-Sema::DeclTy *Sema::ParsedFreeStandingDeclSpec(Scope *S, DeclSpec &DS) {
+Sema::DeclPtrTy Sema::ParsedFreeStandingDeclSpec(Scope *S, DeclSpec &DS) {
   TagDecl *Tag = 0;
   if (DS.getTypeSpecType() == DeclSpec::TST_class ||
       DS.getTypeSpecType() == DeclSpec::TST_struct ||
@@ -926,7 +927,7 @@
     // about them.
     // FIXME: Should we support Microsoft's extensions in this area?
     if (Record->getDeclName() && getLangOptions().Microsoft)
-      return Tag;
+      return DeclPtrTy::make(Tag);
   }
 
   if (!DS.isMissingDeclaratorOk() && 
@@ -937,15 +938,15 @@
         Tag && isa<EnumDecl>(Tag)) {
       Diag(DS.getSourceRange().getBegin(), diag::ext_typedef_without_a_name)
         << DS.getSourceRange();
-      return Tag;
+      return DeclPtrTy::make(Tag);
     }
 
     Diag(DS.getSourceRange().getBegin(), diag::err_no_declarators)
       << DS.getSourceRange();
-    return 0;
+    return DeclPtrTy();
   }
   
-  return Tag;
+  return DeclPtrTy::make(Tag);
 }
 
 /// InjectAnonymousStructOrUnionMembers - Inject the members of the
@@ -992,7 +993,7 @@
         //   considered to have been defined in the scope in which the
         //   anonymous union is declared.
         Owner->makeDeclVisibleInContext(*F);
-        S->AddDecl(*F);
+        S->AddDecl(DeclPtrTy::make(*F));
         IdResolver.AddDecl(*F);
       }
     } else if (const RecordType *InnerRecordType
@@ -1011,8 +1012,8 @@
 /// anonymous structure or union. Anonymous unions are a C++ feature
 /// (C++ [class.union]) and a GNU C extension; anonymous structures
 /// are a GNU C and GNU C++ extension. 
-Sema::DeclTy *Sema::BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS,
-                                                RecordDecl *Record) {
+Sema::DeclPtrTy Sema::BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS,
+                                                  RecordDecl *Record) {
   DeclContext *Owner = Record->getDeclContext();
 
   // Diagnose whether this anonymous struct/union is an extension.
@@ -1165,7 +1166,7 @@
   if (Invalid)
     Anon->setInvalidDecl();
 
-  return Anon;
+  return DeclPtrTy::make(Anon);
 }
 
 
@@ -1233,10 +1234,11 @@
   return true;
 }
 
-Sema::DeclTy *
-Sema::ActOnDeclarator(Scope *S, Declarator &D, DeclTy *lastDecl,
+Sema::DeclPtrTy 
+Sema::ActOnDeclarator(Scope *S, Declarator &D, DeclPtrTy lastDecl,
                       bool IsFunctionDefinition) {
-  NamedDecl *LastDeclarator = dyn_cast_or_null<NamedDecl>((Decl *)lastDecl);
+  NamedDecl *LastDeclarator =
+    dyn_cast_or_null<NamedDecl>(lastDecl.getAs<Decl>());
   DeclarationName Name = GetNameForDeclarator(D);
 
   // All of these full declarators require an identifier.  If it doesn't have
@@ -1246,7 +1248,7 @@
       Diag(D.getDeclSpec().getSourceRange().getBegin(),
            diag::err_declarator_need_ident)
         << D.getDeclSpec().getSourceRange() << D.getSourceRange();
-    return 0;
+    return DeclPtrTy();
   }
   
   // The scope passed in may not be a decl scope.  Zip up the scope tree until
@@ -1366,7 +1368,7 @@
   }
 
   if (New == 0)
-    return 0;
+    return DeclPtrTy();
   
   // If this has an identifier and is not an invalid redeclaration,
   // add it to the scope stack.
@@ -1376,7 +1378,7 @@
   if (D.getInvalidType() || InvalidDecl)
     New->setInvalidDecl();
   
-  return New;
+  return DeclPtrTy::make(New);
 }
 
 /// TryToFixInvalidVariablyModifiedType - Helper method to turn variable array
@@ -1442,11 +1444,11 @@
   if (S && IdResolver.ReplaceDecl(PrevDecl, ND)) {
     // The previous declaration was found on the identifer resolver
     // chain, so remove it from its scope.
-    while (S && !S->isDeclScope(PrevDecl))
+    while (S && !S->isDeclScope(DeclPtrTy::make(PrevDecl)))
       S = S->getParent();
 
     if (S)
-      S->RemoveDecl(PrevDecl);
+      S->RemoveDecl(DeclPtrTy::make(PrevDecl));
   }
 }
 
@@ -2009,9 +2011,9 @@
     // already checks for that case.
     if (FTI.NumArgs == 1 && !FTI.isVariadic && FTI.ArgInfo[0].Ident == 0 &&
         FTI.ArgInfo[0].Param &&
-        ((ParmVarDecl*)FTI.ArgInfo[0].Param)->getType()->isVoidType()) {
+        FTI.ArgInfo[0].Param.getAs<ParmVarDecl>()->getType()->isVoidType()) {
       // empty arg list, don't push any params.
-      ParmVarDecl *Param = (ParmVarDecl*)FTI.ArgInfo[0].Param;
+      ParmVarDecl *Param = FTI.ArgInfo[0].Param.getAs<ParmVarDecl>();
 
       // In C++, the empty parameter-type-list must be spelled "void"; a
       // typedef of void is not permitted.
@@ -2020,10 +2022,8 @@
         Diag(Param->getLocation(), diag::ext_param_typedef_of_void);
       }
     } else if (FTI.NumArgs > 0 && FTI.ArgInfo[0].Param != 0) {
-      for (unsigned i = 0, e = FTI.NumArgs; i != e; ++i) {
-        ParmVarDecl *PVD = (ParmVarDecl *)FTI.ArgInfo[i].Param;
-        Params.push_back(PVD);
-      }
+      for (unsigned i = 0, e = FTI.NumArgs; i != e; ++i)
+        Params.push_back(FTI.ArgInfo[i].Param.getAs<ParmVarDecl>());
     }
   
     NewFD->setParams(Context, &Params[0], Params.size());
@@ -2267,15 +2267,15 @@
   return true;
 }
 
-void Sema::AddInitializerToDecl(DeclTy *dcl, ExprArg init) {
+void Sema::AddInitializerToDecl(DeclPtrTy dcl, ExprArg init) {
   AddInitializerToDecl(dcl, move(init), /*DirectInit=*/false);
 }
 
 /// AddInitializerToDecl - Adds the initializer Init to the
 /// declaration dcl. If DirectInit is true, this is C++ direct
 /// initialization rather than copy initialization.
-void Sema::AddInitializerToDecl(DeclTy *dcl, ExprArg init, bool DirectInit) {
-  Decl *RealDecl = static_cast<Decl *>(dcl);
+void Sema::AddInitializerToDecl(DeclPtrTy dcl, ExprArg init, bool DirectInit) {
+  Decl *RealDecl = dcl.getAs<Decl>();
   // If there is no declaration, there was an error parsing it.  Just ignore
   // the initializer.
   if (RealDecl == 0)
@@ -2430,8 +2430,8 @@
   return;
 }
 
-void Sema::ActOnUninitializedDecl(DeclTy *dcl) {
-  Decl *RealDecl = static_cast<Decl *>(dcl);
+void Sema::ActOnUninitializedDecl(DeclPtrTy dcl) {
+  Decl *RealDecl = dcl.getAs<Decl>();
 
   // If there is no declaration, there was an error parsing it. Just ignore it.
   if (RealDecl == 0)
@@ -2518,11 +2518,11 @@
 }
 
 /// The declarators are chained together backwards, reverse the list.
-Sema::DeclTy *Sema::FinalizeDeclaratorGroup(Scope *S, DeclTy *group) {
+Sema::DeclPtrTy Sema::FinalizeDeclaratorGroup(Scope *S, DeclPtrTy group) {
   // Often we have single declarators, handle them quickly.
-  Decl *Group = static_cast<Decl*>(group);
+  Decl *Group = group.getAs<Decl>();
   if (Group == 0)
-    return 0;
+    return DeclPtrTy();
   
   Decl *NewGroup = 0;
   if (Group->getNextDeclarator() == 0) 
@@ -2578,12 +2578,12 @@
       }
     }
   }
-  return NewGroup;
+  return DeclPtrTy::make(NewGroup);
 }
 
 /// ActOnParamDeclarator - Called from Parser::ParseFunctionDeclarator()
 /// to introduce parameters into function prototype scope.
-Sema::DeclTy *
+Sema::DeclPtrTy 
 Sema::ActOnParamDeclarator(Scope *S, Declarator &D) {
   const DeclSpec &DS = D.getDeclSpec();
 
@@ -2625,7 +2625,7 @@
         DiagnoseTemplateParameterShadow(D.getIdentifierLoc(), PrevDecl);
         // Just pretend that we didn't see the previous declaration.
         PrevDecl = 0;
-      } else if (S->isDeclScope(PrevDecl)) {
+      } else if (S->isDeclScope(DeclPtrTy::make(PrevDecl))) {
         Diag(D.getIdentifierLoc(), diag::err_param_redefinition) << II;
 
         // Recover by removing the name
@@ -2675,13 +2675,12 @@
   }
 
   // Add the parameter declaration into this scope.
-  S->AddDecl(New);
+  S->AddDecl(DeclPtrTy::make(New));
   if (II)
     IdResolver.AddDecl(New);
 
   ProcessDeclAttributes(New, D);
-  return New;
-
+  return DeclPtrTy::make(New);
 }
 
 void Sema::ActOnFinishKNRParamDeclarations(Scope *S, Declarator &D) {
@@ -2710,7 +2709,8 @@
   } 
 }
 
-Sema::DeclTy *Sema::ActOnStartOfFunctionDef(Scope *FnBodyScope, Declarator &D) {
+Sema::DeclPtrTy Sema::ActOnStartOfFunctionDef(Scope *FnBodyScope,
+                                              Declarator &D) {
   assert(getCurFunctionDecl() == 0 && "Function parsing confused");
   assert(D.getTypeObject(0).Kind == DeclaratorChunk::Function &&
          "Not a function declarator!");
@@ -2723,13 +2723,12 @@
   Scope *ParentScope = FnBodyScope->getParent();
 
   return ActOnStartOfFunctionDef(FnBodyScope,
-                                 ActOnDeclarator(ParentScope, D, 0, 
-                                                 /*IsFunctionDefinition=*/true));
+                                 ActOnDeclarator(ParentScope, D, DeclPtrTy(), 
+                                                /*IsFunctionDefinition=*/true));
 }
 
-Sema::DeclTy *Sema::ActOnStartOfFunctionDef(Scope *FnBodyScope, DeclTy *D) {
-  Decl *decl = static_cast<Decl*>(D);
-  FunctionDecl *FD = cast<FunctionDecl>(decl);
+Sema::DeclPtrTy Sema::ActOnStartOfFunctionDef(Scope *FnBodyScope, DeclPtrTy D) {
+  FunctionDecl *FD = cast<FunctionDecl>(D.getAs<Decl>());
 
   // See if this is a redefinition.
   const FunctionDecl *Definition;
@@ -2778,7 +2777,7 @@
            diag::err_attribute_can_be_applied_only_to_symbol_declaration)
         << "dllimport";
       FD->setInvalidDecl();
-      return FD;
+      return DeclPtrTy::make(FD);
     } else {
       // If a symbol previously declared dllimport is later defined, the
       // attribute is ignored in subsequent references, and a warning is
@@ -2788,7 +2787,7 @@
         << FD->getNameAsCString() << "dllimport";
     }
   }
-  return FD;
+  return DeclPtrTy::make(FD);
 }
 
 static bool StatementCreatesScope(Stmt* S) {
@@ -2868,8 +2867,8 @@
   }
 }
 
-Sema::DeclTy *Sema::ActOnFinishFunctionBody(DeclTy *D, StmtArg BodyArg) {
-  Decl *dcl = static_cast<Decl *>(D);
+Sema::DeclPtrTy Sema::ActOnFinishFunctionBody(DeclPtrTy D, StmtArg BodyArg) {
+  Decl *dcl = D.getAs<Decl>();
   Stmt *Body = static_cast<Stmt*>(BodyArg.release());
   if (FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(dcl)) {
     FD->setBody(cast<CompoundStmt>(Body));
@@ -2879,7 +2878,7 @@
     MD->setBody(cast<CompoundStmt>(Body));
   } else {
     Body->Destroy(Context);
-    return 0;
+    return DeclPtrTy();
   }
   PopDeclContext();
   // Verify and clean out per-function state.
@@ -2974,7 +2973,7 @@
   CurContext = Context.getTranslationUnitDecl();
  
   FunctionDecl *FD = 
-    dyn_cast<FunctionDecl>(static_cast<Decl*>(ActOnDeclarator(TUScope, D, 0)));
+ dyn_cast<FunctionDecl>(ActOnDeclarator(TUScope, D, DeclPtrTy()).getAs<Decl>());
   FD->setImplicit();
 
   CurContext = PrevDC;
@@ -3087,10 +3086,10 @@
 /// former case, Name will be non-null.  In the later case, Name will be null.
 /// TagSpec indicates what kind of tag this is. TK indicates whether this is a
 /// reference/declaration/definition of a tag.
-Sema::DeclTy *Sema::ActOnTag(Scope *S, unsigned TagSpec, TagKind TK,
-                             SourceLocation KWLoc, const CXXScopeSpec &SS,
-                             IdentifierInfo *Name, SourceLocation NameLoc,
-                             AttributeList *Attr, AccessSpecifier AS) {
+Sema::DeclPtrTy Sema::ActOnTag(Scope *S, unsigned TagSpec, TagKind TK,
+                               SourceLocation KWLoc, const CXXScopeSpec &SS,
+                               IdentifierInfo *Name, SourceLocation NameLoc,
+                               AttributeList *Attr, AccessSpecifier AS) {
   // If this is not a definition, it must have a name.
   assert((Name != 0 || TK == TK_Definition) &&
          "Nameless record must be a definition!");
@@ -3197,7 +3196,7 @@
           // For our current ASTs this shouldn't be a problem, but will
           // need to be changed with DeclGroups.
           if (TK == TK_Reference)
-            return PrevDecl;
+            return DeclPtrTy::make(PrevDecl);
 
           // Diagnose attempts to redefine a tag.
           if (TK == TK_Definition) {
@@ -3398,12 +3397,12 @@
     CurContext->addDecl(New);
   }
 
-  return New;
+  return DeclPtrTy::make(New);
 }
 
-void Sema::ActOnTagStartDefinition(Scope *S, DeclTy *TagD) {
+void Sema::ActOnTagStartDefinition(Scope *S, DeclPtrTy TagD) {
   AdjustDeclIfTemplate(TagD);
-  TagDecl *Tag = cast<TagDecl>((Decl *)TagD);
+  TagDecl *Tag = cast<TagDecl>(TagD.getAs<Decl>());
 
   // Enter the tag context.
   PushDeclContext(S, Tag);
@@ -3432,9 +3431,9 @@
   }
 }
 
-void Sema::ActOnTagFinishDefinition(Scope *S, DeclTy *TagD) {
+void Sema::ActOnTagFinishDefinition(Scope *S, DeclPtrTy TagD) {
   AdjustDeclIfTemplate(TagD);
-  TagDecl *Tag = cast<TagDecl>((Decl *)TagD);
+  TagDecl *Tag = cast<TagDecl>(TagD.getAs<Decl>());
 
   if (isa<CXXRecordDecl>(Tag))
     FieldCollector->FinishClass();
@@ -3488,13 +3487,13 @@
 
 /// ActOnField - Each field of a struct/union/class is passed into this in order
 /// to create a FieldDecl object for it.
-Sema::DeclTy *Sema::ActOnField(Scope *S, DeclTy *TagD,
-                               SourceLocation DeclStart, 
-                               Declarator &D, ExprTy *BitfieldWidth) {
-
-  return HandleField(S, static_cast<RecordDecl*>(TagD), DeclStart, D,
-                     static_cast<Expr*>(BitfieldWidth),
-                     AS_public);
+Sema::DeclPtrTy Sema::ActOnField(Scope *S, DeclPtrTy TagD,
+                                 SourceLocation DeclStart, 
+                                 Declarator &D, ExprTy *BitfieldWidth) {
+  FieldDecl *Res = HandleField(S, cast_or_null<RecordDecl>(TagD.getAs<Decl>()),
+                               DeclStart, D, static_cast<Expr*>(BitfieldWidth),
+                               AS_public);
+  return DeclPtrTy::make(Res);
 }
 
 /// HandleField - Analyze a field of a C struct or a C++ data member.
@@ -3647,10 +3646,10 @@
 
 /// ActOnIvar - Each ivar field of an objective-c class is passed into this 
 /// in order to create an IvarDecl object for it.
-Sema::DeclTy *Sema::ActOnIvar(Scope *S,
-                              SourceLocation DeclStart, 
-                              Declarator &D, ExprTy *BitfieldWidth,
-                              tok::ObjCKeywordKind Visibility) {
+Sema::DeclPtrTy Sema::ActOnIvar(Scope *S,
+                                SourceLocation DeclStart, 
+                                Declarator &D, ExprTy *BitfieldWidth,
+                                tok::ObjCKeywordKind Visibility) {
   
   IdentifierInfo *II = D.getIdentifier();
   Expr *BitWidth = (Expr*)BitfieldWidth;
@@ -3713,19 +3712,19 @@
   if (II) {
     // FIXME: When interfaces are DeclContexts, we'll need to add
     // these to the interface.
-    S->AddDecl(NewID);
+    S->AddDecl(DeclPtrTy::make(NewID));
     IdResolver.AddDecl(NewID);
   }
 
-  return NewID;
+  return DeclPtrTy::make(NewID);
 }
 
 void Sema::ActOnFields(Scope* S,
-                       SourceLocation RecLoc, DeclTy *RecDecl,
-                       DeclTy **Fields, unsigned NumFields,
+                       SourceLocation RecLoc, DeclPtrTy RecDecl,
+                       DeclPtrTy *Fields, unsigned NumFields,
                        SourceLocation LBrac, SourceLocation RBrac,
                        AttributeList *Attr) {
-  Decl *EnclosingDecl = static_cast<Decl*>(RecDecl);
+  Decl *EnclosingDecl = RecDecl.getAs<Decl>();
   assert(EnclosingDecl && "missing record or interface decl");
   
   // If the decl this is being inserted into is invalid, then it may be a
@@ -3742,8 +3741,7 @@
 
   RecordDecl *Record = dyn_cast<RecordDecl>(EnclosingDecl);
   for (unsigned i = 0; i != NumFields; ++i) {
-    FieldDecl *FD = cast_or_null<FieldDecl>(static_cast<Decl*>(Fields[i]));
-    assert(FD && "missing field decl");
+    FieldDecl *FD = cast<FieldDecl>(Fields[i].getAs<Decl>());
     
     // Get the type for the field.
     Type *FDTy = FD->getType().getTypePtr();
@@ -3916,13 +3914,14 @@
 }
 
 
-Sema::DeclTy *Sema::ActOnEnumConstant(Scope *S, DeclTy *theEnumDecl,
-                                      DeclTy *lastEnumConst,
-                                      SourceLocation IdLoc, IdentifierInfo *Id,
-                                      SourceLocation EqualLoc, ExprTy *val) {
-  EnumDecl *TheEnumDecl = cast<EnumDecl>(static_cast<Decl*>(theEnumDecl));
+Sema::DeclPtrTy Sema::ActOnEnumConstant(Scope *S, DeclPtrTy theEnumDecl,
+                                        DeclPtrTy lastEnumConst,
+                                        SourceLocation IdLoc,
+                                        IdentifierInfo *Id,
+                                        SourceLocation EqualLoc, ExprTy *val) {
+  EnumDecl *TheEnumDecl = cast<EnumDecl>(theEnumDecl.getAs<Decl>());
   EnumConstantDecl *LastEnumConst =
-    cast_or_null<EnumConstantDecl>(static_cast<Decl*>(lastEnumConst));
+    cast_or_null<EnumConstantDecl>(lastEnumConst.getAs<Decl>());
   Expr *Val = static_cast<Expr*>(val);
 
   // The scope passed in may not be a decl scope.  Zip up the scope tree until
@@ -3951,7 +3950,7 @@
         Diag(IdLoc, diag::err_redefinition) << Id;
       Diag(PrevDecl->getLocation(), diag::note_previous_definition);
       if (Val) Val->Destroy(Context);
-      return 0;
+      return DeclPtrTy();
     }
   }
 
@@ -3962,14 +3961,14 @@
   if (New)
     PushOnScopeChains(New, S);
 
-  return New;
+  return DeclPtrTy::make(New);
 }
 
 // FIXME: For consistency with ActOnFields(), we should have the parser
 // pass in the source location for the left/right braces.
-void Sema::ActOnEnumBody(SourceLocation EnumLoc, DeclTy *EnumDeclX,
-                         DeclTy **Elements, unsigned NumElements) {
-  EnumDecl *Enum = cast<EnumDecl>(static_cast<Decl*>(EnumDeclX));
+void Sema::ActOnEnumBody(SourceLocation EnumLoc, DeclPtrTy EnumDeclX,
+                         DeclPtrTy *Elements, unsigned NumElements) {
+  EnumDecl *Enum = cast<EnumDecl>(EnumDeclX.getAs<Decl>());
   QualType EnumType = Context.getTypeDeclType(Enum);
   
   // TODO: If the result value doesn't fit in an int, it must be a long or long
@@ -3987,7 +3986,7 @@
   
   for (unsigned i = 0; i != NumElements; ++i) {
     EnumConstantDecl *ECD =
-      cast_or_null<EnumConstantDecl>(static_cast<Decl*>(Elements[i]));
+      cast_or_null<EnumConstantDecl>(Elements[i].getAs<Decl>());
     if (!ECD) continue;  // Already issued a diagnostic.
     
     // If the enum value doesn't fit in an int, emit an extension warning.
@@ -4061,7 +4060,7 @@
   // the type of the enum if needed.
   for (unsigned i = 0; i != NumElements; ++i) {
     EnumConstantDecl *ECD =
-      cast_or_null<EnumConstantDecl>(static_cast<Decl*>(Elements[i]));
+      cast_or_null<EnumConstantDecl>(Elements[i].getAs<Decl>());
     if (!ECD) continue;  // Already issued a diagnostic.
 
     // Standard C says the enumerators have int type, but we allow, as an
@@ -4135,10 +4134,11 @@
   Enum->completeDefinition(Context, BestType);
 }
 
-Sema::DeclTy *Sema::ActOnFileScopeAsmDecl(SourceLocation Loc,
-                                          ExprArg expr) {
+Sema::DeclPtrTy Sema::ActOnFileScopeAsmDecl(SourceLocation Loc,
+                                            ExprArg expr) {
   StringLiteral *AsmString = cast<StringLiteral>((Expr*)expr.release());
 
-  return FileScopeAsmDecl::Create(Context, CurContext, Loc, AsmString);
+  return DeclPtrTy::make(FileScopeAsmDecl::Create(Context, CurContext,
+                                                  Loc, AsmString));
 }
 

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=67952&r1=67951&r2=67952&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Sat Mar 28 14:18:32 2009
@@ -105,9 +105,9 @@
 /// provided for a function parameter is well-formed. If so, attach it
 /// to the parameter declaration.
 void
-Sema::ActOnParamDefaultArgument(DeclTy *param, SourceLocation EqualLoc, 
+Sema::ActOnParamDefaultArgument(DeclPtrTy param, SourceLocation EqualLoc, 
                                 ExprArg defarg) {
-  ParmVarDecl *Param = (ParmVarDecl *)param;
+  ParmVarDecl *Param = cast<ParmVarDecl>(param.getAs<Decl>());
   ExprOwningPtr<Expr> DefaultArg(this, (Expr *)defarg.release());
   QualType ParamType = Param->getType();
 
@@ -153,17 +153,17 @@
 /// argument for a function parameter, but we can't parse it yet
 /// because we're inside a class definition. Note that this default
 /// argument will be parsed later.
-void Sema::ActOnParamUnparsedDefaultArgument(DeclTy *param, 
+void Sema::ActOnParamUnparsedDefaultArgument(DeclPtrTy param, 
                                              SourceLocation EqualLoc) {
-  ParmVarDecl *Param = (ParmVarDecl*)param;
+  ParmVarDecl *Param = cast<ParmVarDecl>(param.getAs<Decl>());
   if (Param)
     Param->setUnparsedDefaultArg();
 }
 
 /// ActOnParamDefaultArgumentError - Parsing or semantic analysis of
 /// the default argument for the parameter param failed.
-void Sema::ActOnParamDefaultArgumentError(DeclTy *param) {
-  ((ParmVarDecl*)param)->setInvalidDecl();
+void Sema::ActOnParamDefaultArgumentError(DeclPtrTy param) {
+  cast<ParmVarDecl>(param.getAs<Decl>())->setInvalidDecl();
 }
 
 /// CheckExtraCXXDefaultArguments - Check for any extra default
@@ -179,11 +179,12 @@
   //   parameter pack. If it is specified in a
   //   parameter-declaration-clause, it shall not occur within a
   //   declarator or abstract-declarator of a parameter-declaration.
-  for (unsigned i = 0; i < D.getNumTypeObjects(); ++i) {
+  for (unsigned i = 0, e = D.getNumTypeObjects(); i != e; ++i) {
     DeclaratorChunk &chunk = D.getTypeObject(i);
     if (chunk.Kind == DeclaratorChunk::Function) {
-      for (unsigned argIdx = 0; argIdx < chunk.Fun.NumArgs; ++argIdx) {
-        ParmVarDecl *Param = (ParmVarDecl *)chunk.Fun.ArgInfo[argIdx].Param;
+      for (unsigned argIdx = 0, e = chunk.Fun.NumArgs; argIdx != e; ++argIdx) {
+        ParmVarDecl *Param =
+          cast<ParmVarDecl>(chunk.Fun.ArgInfo[argIdx].Param.getAs<Decl>());
         if (Param->hasUnparsedDefaultArg()) {
           CachedTokens *Toks = chunk.Fun.ArgInfo[argIdx].DefaultArgTokens;
           Diag(Param->getLocation(), diag::err_param_default_argument_nonfunc)
@@ -381,11 +382,11 @@
 ///    class foo : public bar, virtual private baz { 
 /// 'public bar' and 'virtual private baz' are each base-specifiers.
 Sema::BaseResult 
-Sema::ActOnBaseSpecifier(DeclTy *classdecl, SourceRange SpecifierRange,
+Sema::ActOnBaseSpecifier(DeclPtrTy classdecl, SourceRange SpecifierRange,
                          bool Virtual, AccessSpecifier Access,
                          TypeTy *basetype, SourceLocation BaseLoc) {
   AdjustDeclIfTemplate(classdecl);
-  CXXRecordDecl *Class = cast<CXXRecordDecl>((Decl*)classdecl);
+  CXXRecordDecl *Class = cast<CXXRecordDecl>(classdecl.getAs<Decl>());
   QualType BaseType = QualType::getFromOpaquePtr(basetype);
   if (CXXBaseSpecifier *BaseSpec = CheckBaseSpecifier(Class, SpecifierRange,
                                                       Virtual, Access,
@@ -451,13 +452,13 @@
 /// ActOnBaseSpecifiers - Attach the given base specifiers to the
 /// class, after checking whether there are any duplicate base
 /// classes.
-void Sema::ActOnBaseSpecifiers(DeclTy *ClassDecl, BaseTy **Bases, 
+void Sema::ActOnBaseSpecifiers(DeclPtrTy ClassDecl, BaseTy **Bases, 
                                unsigned NumBases) {
   if (!ClassDecl || !Bases || !NumBases)
     return;
 
   AdjustDeclIfTemplate(ClassDecl);
-  AttachBaseSpecifiers(cast<CXXRecordDecl>((Decl*)ClassDecl),
+  AttachBaseSpecifiers(cast<CXXRecordDecl>(ClassDecl.getAs<Decl>()),
                        (CXXBaseSpecifier**)(Bases), NumBases);
 }
 
@@ -470,10 +471,10 @@
 /// bitfield width if there is one and 'InitExpr' specifies the initializer if
 /// any. 'LastInGroup' is non-null for cases where one declspec has multiple
 /// declarators on it.
-Sema::DeclTy *
+Sema::DeclPtrTy
 Sema::ActOnCXXMemberDeclarator(Scope *S, AccessSpecifier AS, Declarator &D,
                                ExprTy *BW, ExprTy *InitExpr,
-                               DeclTy *LastInGroup) {
+                               DeclPtrTy LastInGroup) {
   const DeclSpec &DS = D.getDeclSpec();
   DeclarationName Name = GetNameForDeclarator(D);
   Expr *BitWidth = static_cast<Expr*>(BW);
@@ -552,7 +553,7 @@
                          AS);
     assert(Member && "HandleField never returns null");
   } else {
-    Member = static_cast<Decl*>(ActOnDeclarator(S, D, LastInGroup));
+    Member = ActOnDeclarator(S, D, LastInGroup).getAs<Decl>();
     if (!Member) {
       if (BitWidth) DeleteExpr(BitWidth);
       return LastInGroup;
@@ -590,18 +591,18 @@
   assert((Name || isInstField) && "No identifier for non-field ?");
 
   if (Init)
-    AddInitializerToDecl(Member, ExprArg(*this, Init), false);
+    AddInitializerToDecl(DeclPtrTy::make(Member), ExprArg(*this, Init), false);
 
   if (isInstField) {
     FieldCollector->Add(cast<FieldDecl>(Member));
     return LastInGroup;
   }
-  return Member;
+  return DeclPtrTy::make(Member);
 }
 
 /// ActOnMemInitializer - Handle a C++ member initializer.
 Sema::MemInitResult 
-Sema::ActOnMemInitializer(DeclTy *ConstructorD,
+Sema::ActOnMemInitializer(DeclPtrTy ConstructorD,
                           Scope *S,
                           IdentifierInfo *MemberOrBase,
                           SourceLocation IdLoc,
@@ -610,7 +611,7 @@
                           SourceLocation *CommaLocs,
                           SourceLocation RParenLoc) {
   CXXConstructorDecl *Constructor 
-    = dyn_cast<CXXConstructorDecl>((Decl*)ConstructorD);
+    = dyn_cast<CXXConstructorDecl>(ConstructorD.getAs<Decl>());
   if (!Constructor) {
     // The user wrote a constructor initializer on a function that is
     // not a C++ constructor. Ignore the error for now, because we may
@@ -706,11 +707,11 @@
   return new CXXBaseOrMemberInitializer(BaseType, (Expr **)Args, NumArgs);
 }
 
-void Sema::ActOnMemInitializers(DeclTy *ConstructorDecl, 
+void Sema::ActOnMemInitializers(DeclPtrTy ConstructorDecl, 
                                 SourceLocation ColonLoc,
                                 MemInitTy **MemInits, unsigned NumMemInits) {
   CXXConstructorDecl *Constructor = 
-  dyn_cast<CXXConstructorDecl>((Decl *)ConstructorDecl);
+  dyn_cast<CXXConstructorDecl>(ConstructorDecl.getAs<Decl>());
   
   if (!Constructor) {
     Diag(ColonLoc, diag::err_only_constructors_take_base_inits);
@@ -917,15 +918,15 @@
 }
 
 void Sema::ActOnFinishCXXMemberSpecification(Scope* S, SourceLocation RLoc,
-                                             DeclTy *TagDecl,
+                                             DeclPtrTy TagDecl,
                                              SourceLocation LBrac,
                                              SourceLocation RBrac) {
   TemplateDecl *Template = AdjustDeclIfTemplate(TagDecl);
   ActOnFields(S, RLoc, TagDecl,
-              (DeclTy**)FieldCollector->getCurFields(),
+              (DeclPtrTy*)FieldCollector->getCurFields(),
               FieldCollector->getCurNumFields(), LBrac, RBrac, 0);
 
-  CXXRecordDecl *RD = cast<CXXRecordDecl>((Decl*)TagDecl);
+  CXXRecordDecl *RD = cast<CXXRecordDecl>(TagDecl.getAs<Decl>());
   if (!RD->isAbstract()) {
     // Collect all the pure virtual methods and see if this is an abstract
     // class after all.
@@ -1159,9 +1160,9 @@
 /// Method declaration as if we had just parsed the qualified method
 /// name. However, it should not bring the parameters into scope;
 /// that will be performed by ActOnDelayedCXXMethodParameter.
-void Sema::ActOnStartDelayedCXXMethodDeclaration(Scope *S, DeclTy *MethodD) {
+void Sema::ActOnStartDelayedCXXMethodDeclaration(Scope *S, DeclPtrTy MethodD) {
   CXXScopeSpec SS;
-  FunctionDecl *Method = (FunctionDecl*)MethodD;
+  FunctionDecl *Method = cast<FunctionDecl>(MethodD.getAs<Decl>());
   QualType ClassTy 
     = Context.getTypeDeclType(cast<RecordDecl>(Method->getDeclContext()));
   SS.setScopeRep(
@@ -1174,15 +1175,15 @@
 /// function parameter into scope for use in parsing later parts of
 /// the method declaration. For example, we could see an
 /// ActOnParamDefaultArgument event for this parameter.
-void Sema::ActOnDelayedCXXMethodParameter(Scope *S, DeclTy *ParamD) {
-  ParmVarDecl *Param = (ParmVarDecl*)ParamD;
+void Sema::ActOnDelayedCXXMethodParameter(Scope *S, DeclPtrTy ParamD) {
+  ParmVarDecl *Param = cast<ParmVarDecl>(ParamD.getAs<Decl>());
 
   // If this parameter has an unparsed default argument, clear it out
   // to make way for the parsed default argument.
   if (Param->hasUnparsedDefaultArg())
     Param->setDefaultArg(0);
 
-  S->AddDecl(Param);
+  S->AddDecl(DeclPtrTy::make(Param));
   if (Param->getDeclName())
     IdResolver.AddDecl(Param);
 }
@@ -1193,8 +1194,8 @@
 /// ActOnStartOfFunctionDef action later (not necessarily
 /// immediately!) for this method, if it was also defined inside the
 /// class body.
-void Sema::ActOnFinishDelayedCXXMethodDeclaration(Scope *S, DeclTy *MethodD) {
-  FunctionDecl *Method = (FunctionDecl*)MethodD;
+void Sema::ActOnFinishDelayedCXXMethodDeclaration(Scope *S, DeclPtrTy MethodD) {
+  FunctionDecl *Method = cast<FunctionDecl>(MethodD.getAs<Decl>());
   CXXScopeSpec SS;
   QualType ClassTy 
     = Context.getTypeDeclType(cast<RecordDecl>(Method->getDeclContext()));
@@ -1483,7 +1484,7 @@
 /// the declaration of the given C++ conversion function. This routine
 /// is responsible for recording the conversion function in the C++
 /// class, if possible.
-Sema::DeclTy *Sema::ActOnConversionDeclarator(CXXConversionDecl *Conversion) {
+Sema::DeclPtrTy Sema::ActOnConversionDeclarator(CXXConversionDecl *Conversion) {
   assert(Conversion && "Expected to receive a conversion function declaration");
 
   // Set the lexical context of this conversion function
@@ -1528,14 +1529,14 @@
          Conv != ConvEnd; ++Conv) {
       if (*Conv == Conversion->getPreviousDeclaration()) {
         *Conv = Conversion;
-        return (DeclTy *)Conversion;
+        return DeclPtrTy::make(Conversion);
       }
     }
     assert(Conversion->isInvalidDecl() && "Conversion should not get here.");
   } else 
     ClassDecl->addConversionFunction(Context, Conversion);
 
-  return (DeclTy *)Conversion;
+  return DeclPtrTy::make(Conversion);
 }
 
 //===----------------------------------------------------------------------===//
@@ -1544,10 +1545,10 @@
 
 /// ActOnStartNamespaceDef - This is called at the start of a namespace
 /// definition.
-Sema::DeclTy *Sema::ActOnStartNamespaceDef(Scope *NamespcScope,
-                                           SourceLocation IdentLoc,
-                                           IdentifierInfo *II,
-                                           SourceLocation LBrace) {
+Sema::DeclPtrTy Sema::ActOnStartNamespaceDef(Scope *NamespcScope,
+                                             SourceLocation IdentLoc,
+                                             IdentifierInfo *II,
+                                             SourceLocation LBrace) {
   NamespaceDecl *Namespc =
       NamespaceDecl::Create(Context, CurContext, IdentLoc, II);
   Namespc->setLBracLoc(LBrace);
@@ -1573,9 +1574,9 @@
       Namespc->setOriginalNamespace(OrigNS->getOriginalNamespace());
 
       // Remove the previous declaration from the scope.      
-      if (DeclRegionScope->isDeclScope(OrigNS)) {
+      if (DeclRegionScope->isDeclScope(DeclPtrTy::make(OrigNS))) {
         IdResolver.RemoveDecl(OrigNS);
-        DeclRegionScope->RemoveDecl(OrigNS);
+        DeclRegionScope->RemoveDecl(DeclPtrTy::make(OrigNS));
       }
     } else if (PrevDecl) {
       // This is an invalid name redefinition.
@@ -1597,26 +1598,26 @@
   // each DeclContext for the namespace has the declarations
   // that showed up in that particular namespace definition.
   PushDeclContext(NamespcScope, Namespc);
-  return Namespc;
+  return DeclPtrTy::make(Namespc);
 }
 
 /// ActOnFinishNamespaceDef - This callback is called after a namespace is
 /// exited. Decl is the DeclTy returned by ActOnStartNamespaceDef.
-void Sema::ActOnFinishNamespaceDef(DeclTy *D, SourceLocation RBrace) {
-  Decl *Dcl = static_cast<Decl *>(D);
+void Sema::ActOnFinishNamespaceDef(DeclPtrTy D, SourceLocation RBrace) {
+  Decl *Dcl = D.getAs<Decl>();
   NamespaceDecl *Namespc = dyn_cast_or_null<NamespaceDecl>(Dcl);
   assert(Namespc && "Invalid parameter, expected NamespaceDecl");
   Namespc->setRBracLoc(RBrace);
   PopDeclContext();
 }
 
-Sema::DeclTy *Sema::ActOnUsingDirective(Scope *S,
-                                        SourceLocation UsingLoc,
-                                        SourceLocation NamespcLoc,
-                                        const CXXScopeSpec &SS,
-                                        SourceLocation IdentLoc,
-                                        IdentifierInfo *NamespcName,
-                                        AttributeList *AttrList) {
+Sema::DeclPtrTy Sema::ActOnUsingDirective(Scope *S,
+                                          SourceLocation UsingLoc,
+                                          SourceLocation NamespcLoc,
+                                          const CXXScopeSpec &SS,
+                                          SourceLocation IdentLoc,
+                                          IdentifierInfo *NamespcName,
+                                          AttributeList *AttrList) {
   assert(!SS.isInvalid() && "Invalid CXXScopeSpec.");
   assert(NamespcName && "Invalid NamespcName.");
   assert(IdentLoc.isValid() && "Invalid NamespceName location.");
@@ -1629,7 +1630,7 @@
                                     LookupNamespaceName, false);
   if (R.isAmbiguous()) {
     DiagnoseAmbiguousLookup(R, NamespcName, IdentLoc);
-    return 0;
+    return DeclPtrTy();
   }
   if (NamedDecl *NS = R) {
     assert(isa<NamespaceDecl>(NS) && "expected namespace decl");
@@ -1660,7 +1661,7 @@
 
   // FIXME: We ignore attributes for now.
   delete AttrList;
-  return UDir;
+  return DeclPtrTy::make(UDir);
 }
 
 void Sema::PushUsingDirective(Scope *S, UsingDirectiveDecl *UDir) {
@@ -1672,15 +1673,15 @@
   else
     // Otherwise it is block-sope. using-directives will affect lookup
     // only to the end of scope.
-    S->PushUsingDirective(UDir);
+    S->PushUsingDirective(DeclPtrTy::make(UDir));
 }
 
-Sema::DeclTy *Sema::ActOnNamespaceAliasDef(Scope *S, 
-                                           SourceLocation AliasLoc,
-                                           IdentifierInfo *Alias,
-                                           const CXXScopeSpec &SS,
-                                           SourceLocation NamespaceLoc,
-                                           IdentifierInfo *NamespaceName) {
+Sema::DeclPtrTy Sema::ActOnNamespaceAliasDef(Scope *S, 
+                                             SourceLocation AliasLoc,
+                                             IdentifierInfo *Alias,
+                                             const CXXScopeSpec &SS,
+                                             SourceLocation NamespaceLoc,
+                                             IdentifierInfo *NamespaceName) {
   
   // Check if we have a previous declaration with the same name.
   if (NamedDecl *PrevDecl = LookupName(S, Alias, LookupOrdinaryName)) {
@@ -1690,7 +1691,7 @@
       diag::err_redefinition_different_kind;
     Diag(AliasLoc, DiagID) << Alias;
     Diag(PrevDecl->getLocation(), diag::note_previous_definition);
-    return 0;
+    return DeclPtrTy();
   }
 
   // Lookup the namespace name.
@@ -1698,33 +1699,33 @@
                                     LookupNamespaceName, false);
   if (R.isAmbiguous()) {
     DiagnoseAmbiguousLookup(R, NamespaceName, NamespaceLoc);
-    return 0;
+    return DeclPtrTy();
   }
   
   if (!R) {
     Diag(NamespaceLoc, diag::err_expected_namespace_name) << SS.getRange();
-    return 0;
+    return DeclPtrTy();
   }
   
-  return 0;
+  return DeclPtrTy();
 }
 
 /// AddCXXDirectInitializerToDecl - This action is called immediately after 
 /// ActOnDeclarator, when a C++ direct initializer is present.
 /// e.g: "int x(1);"
-void Sema::AddCXXDirectInitializerToDecl(DeclTy *Dcl, SourceLocation LParenLoc,
+void Sema::AddCXXDirectInitializerToDecl(DeclPtrTy Dcl,
+                                         SourceLocation LParenLoc,
                                          MultiExprArg Exprs,
                                          SourceLocation *CommaLocs,
                                          SourceLocation RParenLoc) {
   unsigned NumExprs = Exprs.size();
   assert(NumExprs != 0 && Exprs.get() && "missing expressions");
-  Decl *RealDecl = static_cast<Decl *>(Dcl);
+  Decl *RealDecl = Dcl.getAs<Decl>();
 
   // If there is no declaration, there was an error parsing it.  Just ignore
   // the initializer.
-  if (RealDecl == 0) {
+  if (RealDecl == 0)
     return;
-  }
   
   VarDecl *VDecl = dyn_cast<VarDecl>(RealDecl);
   if (!VDecl) {
@@ -2411,12 +2412,12 @@
 /// by Lang/StrSize. LBraceLoc, if valid, provides the location of
 /// the '{' brace. Otherwise, this linkage specification does not
 /// have any braces.
-Sema::DeclTy *Sema::ActOnStartLinkageSpecification(Scope *S,
-                                                   SourceLocation ExternLoc,
-                                                   SourceLocation LangLoc,
-                                                   const char *Lang,
-                                                   unsigned StrSize,
-                                                   SourceLocation LBraceLoc) {
+Sema::DeclPtrTy Sema::ActOnStartLinkageSpecification(Scope *S,
+                                                     SourceLocation ExternLoc,
+                                                     SourceLocation LangLoc,
+                                                     const char *Lang,
+                                                     unsigned StrSize,
+                                                     SourceLocation LBraceLoc) {
   LinkageSpecDecl::LanguageIDs Language;
   if (strncmp(Lang, "\"C\"", StrSize) == 0)
     Language = LinkageSpecDecl::lang_c;
@@ -2424,7 +2425,7 @@
     Language = LinkageSpecDecl::lang_cxx;
   else {
     Diag(LangLoc, diag::err_bad_language);
-    return 0;
+    return DeclPtrTy();
   }
   
   // FIXME: Add all the various semantics of linkage specifications
@@ -2434,16 +2435,16 @@
                                                LBraceLoc.isValid());
   CurContext->addDecl(D);
   PushDeclContext(S, D);
-  return D;
+  return DeclPtrTy::make(D);
 }
 
 /// ActOnFinishLinkageSpecification - Completely the definition of
 /// the C++ linkage specification LinkageSpec. If RBraceLoc is
 /// valid, it's the position of the closing '}' brace in a linkage
 /// specification that uses braces.
-Sema::DeclTy *Sema::ActOnFinishLinkageSpecification(Scope *S,
-                                                    DeclTy *LinkageSpec,
-                                                    SourceLocation RBraceLoc) {
+Sema::DeclPtrTy Sema::ActOnFinishLinkageSpecification(Scope *S,
+                                                      DeclPtrTy LinkageSpec,
+                                                      SourceLocation RBraceLoc) {
   if (LinkageSpec)
     PopDeclContext();
   return LinkageSpec;
@@ -2451,8 +2452,7 @@
 
 /// ActOnExceptionDeclarator - Parsed the exception-declarator in a C++ catch
 /// handler.
-Sema::DeclTy *Sema::ActOnExceptionDeclarator(Scope *S, Declarator &D)
-{
+Sema::DeclPtrTy Sema::ActOnExceptionDeclarator(Scope *S, Declarator &D) {
   QualType ExDeclType = GetTypeForDeclarator(D, S);
   SourceLocation Begin = D.getDeclSpec().getSourceRange().getBegin();
 
@@ -2497,11 +2497,10 @@
   if (NamedDecl *PrevDecl = LookupName(S, II, LookupOrdinaryName)) {
     // The scope should be freshly made just for us. There is just no way
     // it contains any previous declaration.
-    assert(!S->isDeclScope(PrevDecl));
+    assert(!S->isDeclScope(DeclPtrTy::make(PrevDecl)));
     if (PrevDecl->isTemplateParameter()) {
       // Maybe we will complain about the shadowed template parameter.
       DiagnoseTemplateParameterShadow(D.getIdentifierLoc(), PrevDecl);
-
     }
   }
 
@@ -2517,17 +2516,17 @@
   }
 
   // Add the exception declaration into this scope.
-  S->AddDecl(ExDecl);
+  S->AddDecl(DeclPtrTy::make(ExDecl));
   if (II)
     IdResolver.AddDecl(ExDecl);
 
   ProcessDeclAttributes(ExDecl, D);
-  return ExDecl;
+  return DeclPtrTy::make(ExDecl);
 }
 
-Sema::DeclTy *Sema::ActOnStaticAssertDeclaration(SourceLocation AssertLoc, 
-                                                 ExprArg assertexpr,
-                                                 ExprArg assertmessageexpr) {
+Sema::DeclPtrTy Sema::ActOnStaticAssertDeclaration(SourceLocation AssertLoc, 
+                                                   ExprArg assertexpr,
+                                                   ExprArg assertmessageexpr) {
   Expr *AssertExpr = (Expr *)assertexpr.get();
   StringLiteral *AssertMessage = 
     cast<StringLiteral>((Expr *)assertmessageexpr.get());
@@ -2537,7 +2536,7 @@
     if (!AssertExpr->isIntegerConstantExpr(Value, Context)) {
       Diag(AssertLoc, diag::err_static_assert_expression_is_not_constant) <<
         AssertExpr->getSourceRange();
-      return 0;
+      return DeclPtrTy();
     }
 
     if (Value == 0) {
@@ -2554,11 +2553,11 @@
                                         AssertExpr, AssertMessage);
   
   CurContext->addDecl(Decl);
-  return Decl;
+  return DeclPtrTy::make(Decl);
 }
 
-void Sema::SetDeclDeleted(DeclTy *dcl, SourceLocation DelLoc) {
-  Decl *Dcl = static_cast<Decl*>(dcl);
+void Sema::SetDeclDeleted(DeclPtrTy dcl, SourceLocation DelLoc) {
+  Decl *Dcl = dcl.getAs<Decl>();
   FunctionDecl *Fn = dyn_cast<FunctionDecl>(Dcl);
   if (!Fn) {
     Diag(DelLoc, diag::err_deleted_non_function);

Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=67952&r1=67951&r2=67952&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Sat Mar 28 14:18:32 2009
@@ -20,9 +20,9 @@
 
 /// ActOnStartOfObjCMethodDef - This routine sets up parameters; invisible
 /// and user declared, in the method definition's AST.
-void Sema::ActOnStartOfObjCMethodDef(Scope *FnBodyScope, DeclTy *D) {
+void Sema::ActOnStartOfObjCMethodDef(Scope *FnBodyScope, DeclPtrTy D) {
   assert(getCurMethodDecl() == 0 && "Method parsing confused");
-  ObjCMethodDecl *MDecl = dyn_cast_or_null<ObjCMethodDecl>((Decl *)D);
+  ObjCMethodDecl *MDecl = dyn_cast_or_null<ObjCMethodDecl>(D.getAs<Decl>());
   
   // If we don't have a valid method decl, simply return.
   if (!MDecl)
@@ -53,11 +53,11 @@
       PushOnScopeChains(*PI, FnBodyScope);
 }
 
-Sema::DeclTy *Sema::
+Sema::DeclPtrTy Sema::
 ActOnStartClassInterface(SourceLocation AtInterfaceLoc,
                          IdentifierInfo *ClassName, SourceLocation ClassLoc,
                          IdentifierInfo *SuperName, SourceLocation SuperLoc,
-                         DeclTy * const *ProtoRefs, unsigned NumProtoRefs,
+                         const DeclPtrTy *ProtoRefs, unsigned NumProtoRefs,
                          SourceLocation EndProtoLoc, AttributeList *AttrList) {
   assert(ClassName && "Missing class identifier");
   
@@ -85,7 +85,7 @@
 
       // Return the previous class interface.
       // FIXME: don't leak the objects passed in!
-      return IDecl;
+      return DeclPtrTy::make(IDecl);
     } else {
       IDecl->setLocation(AtInterfaceLoc);
       IDecl->setForwardDecl(false);
@@ -100,7 +100,7 @@
     // FIXME: PushOnScopeChains
     CurContext->addDecl(IDecl);
     // Remember that this needs to be removed when the scope is popped.
-    TUScope->AddDecl(IDecl);
+    TUScope->AddDecl(DeclPtrTy::make(IDecl));
   }
   
   if (SuperName) {
@@ -160,16 +160,16 @@
   }
   
   CheckObjCDeclScope(IDecl);
-  return IDecl;
+  return DeclPtrTy::make(IDecl);
 }
 
 /// ActOnCompatiblityAlias - this action is called after complete parsing of
 /// @compatibility_alias declaration. It sets up the alias relationships.
-Sema::DeclTy *Sema::ActOnCompatiblityAlias(SourceLocation AtLoc,
-                                           IdentifierInfo *AliasName, 
-                                           SourceLocation AliasLocation,
-                                           IdentifierInfo *ClassName,
-                                           SourceLocation ClassLocation) {
+Sema::DeclPtrTy Sema::ActOnCompatiblityAlias(SourceLocation AtLoc,
+                                             IdentifierInfo *AliasName, 
+                                             SourceLocation AliasLocation,
+                                             IdentifierInfo *ClassName,
+                                             SourceLocation ClassLocation) {
   // Look for previous declaration of alias name
   NamedDecl *ADecl = LookupName(TUScope, AliasName, LookupOrdinaryName);
   if (ADecl) {
@@ -178,7 +178,7 @@
     else
       Diag(AliasLocation, diag::err_conflicting_aliasing_type) << AliasName;
     Diag(ADecl->getLocation(), diag::note_previous_declaration);
-    return 0;
+    return DeclPtrTy();
   }
   // Check for class declaration
   NamedDecl *CDeclU = LookupName(TUScope, ClassName, LookupOrdinaryName);
@@ -196,7 +196,7 @@
     Diag(ClassLocation, diag::warn_undef_interface) << ClassName;
     if (CDeclU)
       Diag(CDeclU->getLocation(), diag::note_previous_declaration);
-    return 0;
+    return DeclPtrTy();
   }
   
   // Everything checked out, instantiate a new alias declaration AST.
@@ -208,9 +208,9 @@
   // FIXME: PushOnScopeChains?
   CurContext->addDecl(AliasDecl);
   if (!CheckObjCDeclScope(AliasDecl))
-    TUScope->AddDecl(AliasDecl);
+    TUScope->AddDecl(DeclPtrTy::make(AliasDecl));
 
-  return AliasDecl;
+  return DeclPtrTy::make(AliasDecl);
 }
 
 void Sema::CheckForwardProtocolDeclarationForCircularDependency(
@@ -232,11 +232,11 @@
   }
 }
 
-Sema::DeclTy *
+Sema::DeclPtrTy
 Sema::ActOnStartProtocolInterface(SourceLocation AtProtoInterfaceLoc,
                                   IdentifierInfo *ProtocolName,
                                   SourceLocation ProtocolLoc,
-                                  DeclTy * const *ProtoRefs,
+                                  const DeclPtrTy *ProtoRefs,
                                   unsigned NumProtoRefs,
                                   SourceLocation EndProtoLoc,
                                   AttributeList *AttrList) {
@@ -251,7 +251,7 @@
       Diag(PDecl->getLocation(), diag::note_previous_definition);
       // Just return the protocol we already had.
       // FIXME: don't leak the objects passed in!
-      return PDecl;
+      return DeclPtrTy::make(PDecl);
     }
     ObjCList<ObjCProtocolDecl> PList;
     PList.set((ObjCProtocolDecl *const*)ProtoRefs, NumProtoRefs, Context); 
@@ -279,7 +279,7 @@
   }
   
   CheckObjCDeclScope(PDecl);  
-  return PDecl;
+  return DeclPtrTy::make(PDecl);
 }
 
 /// FindProtocolDeclaration - This routine looks up protocols and
@@ -289,7 +289,7 @@
 Sema::FindProtocolDeclaration(bool WarnOnDeclarations,
                               const IdentifierLocPair *ProtocolId,
                               unsigned NumProtocols,
-                              llvm::SmallVectorImpl<DeclTy*> &Protocols) {
+                              llvm::SmallVectorImpl<DeclPtrTy> &Protocols) {
   for (unsigned i = 0; i != NumProtocols; ++i) {
     ObjCProtocolDecl *PDecl = ObjCProtocols[ProtocolId[i].first];
     if (!PDecl) {
@@ -305,7 +305,7 @@
     if (WarnOnDeclarations && PDecl->isForwardDecl())
       Diag(ProtocolId[i].second, diag::warn_undef_protocolref)
         << ProtocolId[i].first;
-    Protocols.push_back(PDecl); 
+    Protocols.push_back(DeclPtrTy::make(PDecl));
   }
 }
 
@@ -428,8 +428,8 @@
 /// inherited protocol into the list of properties for class/category 'CDecl'
 ///
 void Sema::MergeProtocolPropertiesIntoClass(Decl *CDecl,
-                                            DeclTy *MergeItsProtocols) {
-  Decl *ClassDecl = static_cast<Decl *>(MergeItsProtocols);
+                                            DeclPtrTy MergeItsProtocols) {
+  Decl *ClassDecl = MergeItsProtocols.getAs<Decl>();
   ObjCInterfaceDecl *IDecl = dyn_cast_or_null<ObjCInterfaceDecl>(CDecl);
 
   if (!IDecl) {
@@ -446,12 +446,12 @@
       // their properties into this class as well.
       for (ObjCCategoryDecl::protocol_iterator P = CatDecl->protocol_begin(),
            E = CatDecl->protocol_end(); P != E; ++P)
-        MergeProtocolPropertiesIntoClass(CatDecl, *P);
+        MergeProtocolPropertiesIntoClass(CatDecl, DeclPtrTy::make(*P));
     } else {
       ObjCProtocolDecl *MD = cast<ObjCProtocolDecl>(ClassDecl);
       for (ObjCProtocolDecl::protocol_iterator P = MD->protocol_begin(),
            E = MD->protocol_end(); P != E; ++P)
-        MergeOneProtocolPropertiesIntoClass(CatDecl, (*P));
+        MergeOneProtocolPropertiesIntoClass(CatDecl, *P);
     }
     return;
   }
@@ -466,12 +466,12 @@
     // their properties into this class as well.
     for (ObjCInterfaceDecl::protocol_iterator P = IDecl->protocol_begin(),
          E = IDecl->protocol_end(); P != E; ++P)
-      MergeProtocolPropertiesIntoClass(IDecl, *P);
+      MergeProtocolPropertiesIntoClass(IDecl, DeclPtrTy::make(*P));
   } else {
     ObjCProtocolDecl *MD = cast<ObjCProtocolDecl>(ClassDecl);
     for (ObjCProtocolDecl::protocol_iterator P = MD->protocol_begin(),
          E = MD->protocol_end(); P != E; ++P)
-      MergeOneProtocolPropertiesIntoClass(IDecl, (*P));
+      MergeOneProtocolPropertiesIntoClass(IDecl, *P);
   }
 }
 
@@ -505,7 +505,7 @@
 }
 
 /// ActOnForwardProtocolDeclaration - 
-Action::DeclTy *
+Action::DeclPtrTy
 Sema::ActOnForwardProtocolDeclaration(SourceLocation AtProtocolLoc,
                                       const IdentifierLocPair *IdentList,
                                       unsigned NumElts,
@@ -531,15 +531,15 @@
                                     &Protocols[0], Protocols.size());
   CurContext->addDecl(PDecl);
   CheckObjCDeclScope(PDecl);
-  return PDecl;
+  return DeclPtrTy::make(PDecl);
 }
 
-Sema::DeclTy *Sema::
+Sema::DeclPtrTy Sema::
 ActOnStartCategoryInterface(SourceLocation AtInterfaceLoc,
                             IdentifierInfo *ClassName, SourceLocation ClassLoc,
                             IdentifierInfo *CategoryName,
                             SourceLocation CategoryLoc,
-                            DeclTy * const *ProtoRefs,
+                            const DeclPtrTy *ProtoRefs,
                             unsigned NumProtoRefs,
                             SourceLocation EndProtoLoc) {
   ObjCCategoryDecl *CDecl = 
@@ -552,7 +552,7 @@
   if (!IDecl || IDecl->isForwardDecl()) {
     CDecl->setInvalidDecl();
     Diag(ClassLoc, diag::err_undef_interface) << ClassName;
-    return CDecl;
+    return DeclPtrTy::make(CDecl);
   }
 
   CDecl->setClassInterface(IDecl);
@@ -580,13 +580,13 @@
   }
   
   CheckObjCDeclScope(CDecl);
-  return CDecl;
+  return DeclPtrTy::make(CDecl);
 }
 
 /// ActOnStartCategoryImplementation - Perform semantic checks on the
 /// category implementation declaration and build an ObjCCategoryImplDecl
 /// object.
-Sema::DeclTy *Sema::ActOnStartCategoryImplementation(
+Sema::DeclPtrTy Sema::ActOnStartCategoryImplementation(
                       SourceLocation AtCatImplLoc,
                       IdentifierInfo *ClassName, SourceLocation ClassLoc,
                       IdentifierInfo *CatName, SourceLocation CatLoc) {
@@ -606,10 +606,10 @@
   ObjCCategoryImpls.push_back(CDecl);
   
   CheckObjCDeclScope(CDecl);
-  return CDecl;
+  return DeclPtrTy::make(CDecl);
 }
 
-Sema::DeclTy *Sema::ActOnStartClassImplementation(
+Sema::DeclPtrTy Sema::ActOnStartClassImplementation(
                       SourceLocation AtClassImplLoc,
                       IdentifierInfo *ClassName, SourceLocation ClassLoc,
                       IdentifierInfo *SuperClassname, 
@@ -666,7 +666,7 @@
     // FIXME: PushOnScopeChains?
     CurContext->addDecl(IDecl);
     // Remember that this needs to be removed when the scope is popped.
-    TUScope->AddDecl(IDecl);
+    TUScope->AddDecl(DeclPtrTy::make(IDecl));
   }
   
   ObjCImplementationDecl* IMPDecl = 
@@ -677,7 +677,7 @@
   CurContext->addDecl(IMPDecl);
 
   if (CheckObjCDeclScope(IMPDecl))
-    return IMPDecl;
+    return DeclPtrTy::make(IMPDecl);
   
   // Check that there is no duplicate implementation of this class.
   if (ObjCImplementations[ClassName])
@@ -685,7 +685,7 @@
     Diag(ClassLoc, diag::err_dup_implementation_class) << ClassName;
   else // add it to the list.
     ObjCImplementations[ClassName] = IMPDecl;
-  return IMPDecl;
+  return DeclPtrTy::make(IMPDecl);
 }
 
 void Sema::CheckImplementationIvars(ObjCImplementationDecl *ImpDecl,
@@ -957,7 +957,7 @@
 }
 
 /// ActOnForwardClassDeclaration - 
-Action::DeclTy *
+Action::DeclPtrTy
 Sema::ActOnForwardClassDeclaration(SourceLocation AtClassLoc,
                                    IdentifierInfo **IdentList,
                                    unsigned NumElts) {
@@ -995,7 +995,7 @@
       // FIXME: PushOnScopeChains?
       CurContext->addDecl(IDecl);
       // Remember that this needs to be removed when the scope is popped.
-      TUScope->AddDecl(IDecl);
+      TUScope->AddDecl(DeclPtrTy::make(IDecl));
     }
 
     Interfaces.push_back(IDecl);
@@ -1006,7 +1006,7 @@
                                                Interfaces.size());
   CurContext->addDecl(CDecl);
   CheckObjCDeclScope(CDecl);
-  return CDecl;  
+  return DeclPtrTy::make(CDecl);
 }
 
 
@@ -1231,12 +1231,12 @@
 
 // Note: For class/category implemenations, allMethods/allProperties is
 // always null.
-void Sema::ActOnAtEnd(SourceLocation AtEndLoc, DeclTy *classDecl,
-                      DeclTy **allMethods, unsigned allNum,
-                      DeclTy **allProperties, unsigned pNum,
-                      DeclTy **allTUVars,
+void Sema::ActOnAtEnd(SourceLocation AtEndLoc, DeclPtrTy classDecl,
+                      DeclPtrTy *allMethods, unsigned allNum,
+                      DeclPtrTy *allProperties, unsigned pNum,
+                      DeclPtrTy *allTUVars,
                       unsigned tuvNum) {
-  Decl *ClassDecl = static_cast<Decl *>(classDecl);
+  Decl *ClassDecl = classDecl.getAs<Decl>();
 
   // FIXME: If we don't have a ClassDecl, we have an error. We should consider
   // always passing in a decl. If the decl has an error, isInvalidDecl()
@@ -1257,7 +1257,7 @@
 
   for (unsigned i = 0; i < allNum; i++ ) {
     ObjCMethodDecl *Method =
-      cast_or_null<ObjCMethodDecl>(static_cast<Decl*>(allMethods[i]));
+      cast_or_null<ObjCMethodDecl>(allMethods[i].getAs<Decl>());
 
     if (!Method) continue;  // Already issued a diagnostic.
     if (Method->isInstanceMethod()) {
@@ -1299,14 +1299,14 @@
     // Compares properties declared in this class to those of its 
     // super class.
     ComparePropertiesInBaseAndSuper(I);
-    MergeProtocolPropertiesIntoClass(I, I);
+    MergeProtocolPropertiesIntoClass(I, DeclPtrTy::make(I));
   } else if (ObjCCategoryDecl *C = dyn_cast<ObjCCategoryDecl>(ClassDecl)) {
     // Categories are used to extend the class by declaring new methods.
     // By the same token, they are also used to add new properties. No 
     // need to compare the added property to those in the class.
 
     // Merge protocol properties into category
-    MergeProtocolPropertiesIntoClass(C, C);
+    MergeProtocolPropertiesIntoClass(C, DeclPtrTy::make(C));
     if (C->getIdentifier() == 0)
       DiagnoseClassExtensionDupMethods(C, C->getClassInterface());
   }
@@ -1341,7 +1341,7 @@
   }
   if (isInterfaceDeclKind)
     for (unsigned i = 0; i < tuvNum; i++) {
-      if (VarDecl *VDecl = dyn_cast<VarDecl>((Decl*)allTUVars[i])) {
+      if (VarDecl *VDecl = dyn_cast<VarDecl>(allTUVars[i].getAs<Decl>())) {
         if (VDecl->getStorageClass() != VarDecl::Extern &&
             VDecl->getStorageClass() != VarDecl::PrivateExtern) {
           NamedDecl  *ClassNameDecl = dyn_cast<NamedDecl>(ClassDecl);
@@ -1374,9 +1374,9 @@
   return ret;
 }
 
-Sema::DeclTy *Sema::ActOnMethodDeclaration(
+Sema::DeclPtrTy Sema::ActOnMethodDeclaration(
     SourceLocation MethodLoc, SourceLocation EndLoc,
-    tok::TokenKind MethodType, DeclTy *classDecl,
+    tok::TokenKind MethodType, DeclPtrTy classDecl,
     ObjCDeclSpec &ReturnQT, TypeTy *ReturnType,
     Selector Sel,
     // optional arguments. The number of types/arguments is obtained
@@ -1385,12 +1385,12 @@
     llvm::SmallVectorImpl<Declarator> &Cdecls,
     AttributeList *AttrList, tok::ObjCKeywordKind MethodDeclKind,
     bool isVariadic) {
-  Decl *ClassDecl = static_cast<Decl*>(classDecl);
+  Decl *ClassDecl = classDecl.getAs<Decl>();
 
   // Make sure we can establish a context for the method.
   if (!ClassDecl) {
     Diag(MethodLoc, diag::error_missing_method_context);
-    return 0;
+    return DeclPtrTy();
   }
   QualType resultDeclType;
   
@@ -1402,7 +1402,7 @@
     if (resultDeclType->isObjCInterfaceType()) {
       Diag(MethodLoc, diag::err_object_cannot_be_by_value)
            << "returned";
-      return 0;
+      return DeclPtrTy();
     }
   } else // get the type for "id".
     resultDeclType = Context.getObjCIdType();
@@ -1436,7 +1436,7 @@
         Diag(MethodLoc, diag::err_object_cannot_be_by_value)
              << "passed";
         ObjCMethod->setInvalidDecl();
-        return 0;
+        return DeclPtrTy();
       }
     } else
       argType = Context.getObjCIdType();
@@ -1495,7 +1495,7 @@
       << ObjCMethod->getDeclName();
     Diag(PrevMethod->getLocation(), diag::note_previous_declaration);
   } 
-  return ObjCMethod;
+  return DeclPtrTy::make(ObjCMethod);
 }
 
 void Sema::CheckObjCPropertyAttributes(QualType PropertyTy, 
@@ -1571,14 +1571,14 @@
   }
 }
 
-Sema::DeclTy *Sema::ActOnProperty(Scope *S, SourceLocation AtLoc, 
-                                  FieldDeclarator &FD,
-                                  ObjCDeclSpec &ODS,
-                                  Selector GetterSel,
-                                  Selector SetterSel,
-                                  DeclTy *ClassCategory,
-                                  bool *isOverridingProperty,
-                                  tok::ObjCKeywordKind MethodImplKind) {
+Sema::DeclPtrTy Sema::ActOnProperty(Scope *S, SourceLocation AtLoc, 
+                                    FieldDeclarator &FD,
+                                    ObjCDeclSpec &ODS,
+                                    Selector GetterSel,
+                                    Selector SetterSel,
+                                    DeclPtrTy ClassCategory,
+                                    bool *isOverridingProperty,
+                                    tok::ObjCKeywordKind MethodImplKind) {
   unsigned Attributes = ODS.getPropertyAttributes();
   bool isReadWrite = ((Attributes & ObjCDeclSpec::DQ_PR_readwrite) ||
                       // default is readwrite!
@@ -1590,7 +1590,7 @@
                     !(Attributes & ObjCDeclSpec::DQ_PR_retain) && 
                     !(Attributes & ObjCDeclSpec::DQ_PR_copy)));
   QualType T = GetTypeForDeclarator(FD.D, S);
-  Decl *ClassDecl = static_cast<Decl *>(ClassCategory);
+  Decl *ClassDecl = ClassCategory.getAs<Decl>();
 
   // May modify Attributes.
   CheckObjCPropertyAttributes(T, AtLoc, Attributes);
@@ -1632,7 +1632,7 @@
           else
             Diag(AtLoc, diag::err_use_continuation_class) << ICDecl->getDeclName();
           *isOverridingProperty = true;
-          return 0;
+          return DeclPtrTy();
         }
         // No matching property found in the main class. Just fall thru
         // and add property to the anonymous category. It looks like
@@ -1641,7 +1641,7 @@
       } else {
         Diag(CDecl->getLocation(), diag::err_continuation_class);
         *isOverridingProperty = true;
-        return 0;
+        return DeclPtrTy();
       }
     }
 
@@ -1691,24 +1691,24 @@
   else if (MethodImplKind == tok::objc_optional)
     PDecl->setPropertyImplementation(ObjCPropertyDecl::Optional);
   
-  return PDecl;
+  return DeclPtrTy::make(PDecl);
 }
 
 /// ActOnPropertyImplDecl - This routine performs semantic checks and
 /// builds the AST node for a property implementation declaration; declared
 /// as @synthesize or @dynamic.
 ///
-Sema::DeclTy *Sema::ActOnPropertyImplDecl(SourceLocation AtLoc, 
-                                          SourceLocation PropertyLoc,
-                                          bool Synthesize, 
-                                          DeclTy *ClassCatImpDecl,
-                                          IdentifierInfo *PropertyId,
-                                          IdentifierInfo *PropertyIvar) {
-  Decl *ClassImpDecl = static_cast<Decl*>(ClassCatImpDecl);
+Sema::DeclPtrTy Sema::ActOnPropertyImplDecl(SourceLocation AtLoc, 
+                                            SourceLocation PropertyLoc,
+                                            bool Synthesize, 
+                                            DeclPtrTy ClassCatImpDecl,
+                                            IdentifierInfo *PropertyId,
+                                            IdentifierInfo *PropertyIvar) {
+  Decl *ClassImpDecl = ClassCatImpDecl.getAs<Decl>();
   // Make sure we have a context for the property implementation declaration.
   if (!ClassImpDecl) {
     Diag(AtLoc, diag::error_missing_property_context);
-    return 0;
+    return DeclPtrTy();
   }
   ObjCPropertyDecl *property = 0;
   ObjCInterfaceDecl* IDecl = 0;
@@ -1727,18 +1727,18 @@
     property = IDecl->FindPropertyDeclaration(PropertyId);
     if (!property) {
       Diag(PropertyLoc, diag::error_bad_property_decl) << IDecl->getDeclName();
-      return 0;
+      return DeclPtrTy();
     }
   }
   else if ((CatImplClass = dyn_cast<ObjCCategoryImplDecl>(ClassImpDecl))) {
     if (Synthesize) {
       Diag(AtLoc, diag::error_synthesize_category_decl);
-      return 0;
+      return DeclPtrTy();
     }    
     IDecl = CatImplClass->getClassInterface();
     if (!IDecl) {
       Diag(AtLoc, diag::error_missing_property_interface);
-      return 0;
+      return DeclPtrTy();
     }
     ObjCCategoryDecl *Category = 
       IDecl->FindCategoryDeclaration(CatImplClass->getIdentifier());
@@ -1746,18 +1746,17 @@
     // If category for this implementation not found, it is an error which
     // has already been reported eralier.
     if (!Category)
-      return 0;
+      return DeclPtrTy();
     // Look for this property declaration in @implementation's category
     property = Category->FindPropertyDeclaration(PropertyId);
     if (!property) {
       Diag(PropertyLoc, diag::error_bad_category_property_decl)
         << Category->getDeclName();
-      return 0;
+      return DeclPtrTy();
     }
-  }
-  else {
+  } else {
     Diag(AtLoc, diag::error_bad_property_context);
-    return 0;
+    return DeclPtrTy();
   }
   ObjCIvarDecl *Ivar = 0;
   // Check that we have a valid, previously declared ivar for @synthesize
@@ -1773,7 +1772,7 @@
                           << PropertyId;
       else
         Diag(PropertyLoc, diag::error_missing_property_ivar_decl) << PropertyId;
-      return 0;
+      return DeclPtrTy();
     }
     QualType PropType = Context.getCanonicalType(property->getType());
     QualType IvarType = Context.getCanonicalType(Ivar->getType());
@@ -1783,40 +1782,37 @@
       if (CheckAssignmentConstraints(PropType, IvarType) != Compatible) {
         Diag(PropertyLoc, diag::error_property_ivar_type)
           << property->getDeclName() << Ivar->getDeclName();
-        return 0;
+        return DeclPtrTy();
       }
-      else {
-        // FIXME! Rules for properties are somewhat different that those
-        // for assignments. Use a new routine to consolidate all cases;
-        // specifically for property redeclarations as well as for ivars.
-        QualType lhsType = 
-                    Context.getCanonicalType(PropType).getUnqualifiedType();
-        QualType rhsType = 
-                    Context.getCanonicalType(IvarType).getUnqualifiedType();
-        if (lhsType != rhsType && 
-            lhsType->isArithmeticType()) {
-          Diag(PropertyLoc, diag::error_property_ivar_type)
-          << property->getDeclName() << Ivar->getDeclName();
-          return 0;
-        }
-        // __weak is explicit. So it works on Canonical type.
-        if (PropType.isObjCGCWeak() && !IvarType.isObjCGCWeak()) {
-          Diag(PropertyLoc, diag::error_weak_property)
-          << property->getDeclName() << Ivar->getDeclName();
-          return 0;
-        }
-        if ((Context.isObjCObjectPointerType(property->getType()) || 
-             PropType.isObjCGCStrong()) && IvarType.isObjCGCWeak()) {
-          Diag(PropertyLoc, diag::error_strong_property)
-          << property->getDeclName() << Ivar->getDeclName();
-          return 0;
-        }
+      
+      // FIXME! Rules for properties are somewhat different that those
+      // for assignments. Use a new routine to consolidate all cases;
+      // specifically for property redeclarations as well as for ivars.
+      QualType lhsType =Context.getCanonicalType(PropType).getUnqualifiedType();
+      QualType rhsType =Context.getCanonicalType(IvarType).getUnqualifiedType();
+      if (lhsType != rhsType && 
+          lhsType->isArithmeticType()) {
+        Diag(PropertyLoc, diag::error_property_ivar_type)
+        << property->getDeclName() << Ivar->getDeclName();
+        return DeclPtrTy();
+      }
+      // __weak is explicit. So it works on Canonical type.
+      if (PropType.isObjCGCWeak() && !IvarType.isObjCGCWeak()) {
+        Diag(PropertyLoc, diag::error_weak_property)
+        << property->getDeclName() << Ivar->getDeclName();
+        return DeclPtrTy();
+      }
+      if ((Context.isObjCObjectPointerType(property->getType()) || 
+           PropType.isObjCGCStrong()) && IvarType.isObjCGCWeak()) {
+        Diag(PropertyLoc, diag::error_strong_property)
+        << property->getDeclName() << Ivar->getDeclName();
+        return DeclPtrTy();
       }
     }
   } else if (PropertyIvar) {
     // @dynamic
     Diag(PropertyLoc, diag::error_dynamic_property_ivar_decl);
-    return 0;
+    return DeclPtrTy();
   }
   assert (property && "ActOnPropertyImplDecl - property declaration missing");
   ObjCPropertyImplDecl *PIDecl = 
@@ -1840,7 +1836,7 @@
     if (ObjCPropertyImplDecl *PPIDecl = IC->FindPropertyImplDecl(PropertyId)) {
       Diag(PropertyLoc, diag::error_property_implemented) << PropertyId;
       Diag(PPIDecl->getLocation(), diag::note_previous_declaration);
-      return 0;
+      return DeclPtrTy();
     }
     IC->addPropertyImplementation(PIDecl);
   }
@@ -1858,12 +1854,12 @@
           CatImplClass->FindPropertyImplDecl(PropertyId)) {
       Diag(PropertyLoc, diag::error_property_implemented) << PropertyId;
       Diag(PPIDecl->getLocation(), diag::note_previous_declaration);
-      return 0;
+      return DeclPtrTy();
     }    
     CatImplClass->addPropertyImplementation(PIDecl);
   }
     
-  return PIDecl;
+  return DeclPtrTy::make(PIDecl);
 }
 
 bool Sema::CheckObjCDeclScope(Decl *D) {
@@ -1882,28 +1878,26 @@
 /// part of the AST generation logic of @defs.
 static void CollectIvars(ObjCInterfaceDecl *Class, RecordDecl *Record,
                          ASTContext& Ctx,
-                         llvm::SmallVectorImpl<Sema::DeclTy*> &ivars) {
+                         llvm::SmallVectorImpl<Sema::DeclPtrTy> &ivars) {
   if (Class->getSuperClass())
     CollectIvars(Class->getSuperClass(), Record, Ctx, ivars);
   
   // For each ivar, create a fresh ObjCAtDefsFieldDecl.
-  for (ObjCInterfaceDecl::ivar_iterator
-       I=Class->ivar_begin(), E=Class->ivar_end(); I!=E; ++I) {
-    
+  for (ObjCInterfaceDecl::ivar_iterator I = Class->ivar_begin(),
+       E = Class->ivar_end(); I != E; ++I) {
     ObjCIvarDecl* ID = *I;
-    ivars.push_back(ObjCAtDefsFieldDecl::Create(Ctx, Record,
-                                                ID->getLocation(),
-                                                ID->getIdentifier(),
-                                                ID->getType(),
-                                                ID->getBitWidth()));
+    Decl *FD = ObjCAtDefsFieldDecl::Create(Ctx, Record, ID->getLocation(),
+                                           ID->getIdentifier(), ID->getType(),
+                                           ID->getBitWidth());
+    ivars.push_back(Sema::DeclPtrTy::make(FD));
   }
 }
 
 /// Called whenever @defs(ClassName) is encountered in the source.  Inserts the
 /// instance variables of ClassName into Decls.
-void Sema::ActOnDefs(Scope *S, DeclTy *TagD, SourceLocation DeclStart, 
+void Sema::ActOnDefs(Scope *S, DeclPtrTy TagD, SourceLocation DeclStart, 
                      IdentifierInfo *ClassName,
-                     llvm::SmallVectorImpl<DeclTy*> &Decls) {
+                     llvm::SmallVectorImpl<DeclPtrTy> &Decls) {
   // Check that ClassName is a valid class
   ObjCInterfaceDecl *Class = getObjCInterfaceDecl(ClassName);
   if (!Class) {
@@ -1911,15 +1905,15 @@
     return;
   }
   // Collect the instance variables
-  CollectIvars(Class, dyn_cast<RecordDecl>((Decl*)TagD), Context, Decls);
+  CollectIvars(Class, dyn_cast<RecordDecl>(TagD.getAs<Decl>()), Context, Decls);
   
   // Introduce all of these fields into the appropriate scope.
-  for (llvm::SmallVectorImpl<DeclTy*>::iterator D = Decls.begin();
+  for (llvm::SmallVectorImpl<DeclPtrTy>::iterator D = Decls.begin();
        D != Decls.end(); ++D) {
-    FieldDecl *FD = cast<FieldDecl>((Decl*)*D);
+    FieldDecl *FD = cast<FieldDecl>(D->getAs<Decl>());
     if (getLangOptions().CPlusPlus)
       PushOnScopeChains(cast<FieldDecl>(FD), S);
-    else if (RecordDecl *Record = dyn_cast<RecordDecl>((Decl*)TagD))
+    else if (RecordDecl *Record = dyn_cast<RecordDecl>(TagD.getAs<Decl>()))
       Record->addDecl(FD);
   }
 }

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=67952&r1=67951&r2=67952&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Sat Mar 28 14:18:32 2009
@@ -876,7 +876,7 @@
       Scope *CheckS = S;
       while (CheckS) {
         if (CheckS->isWithinElse() && 
-            CheckS->getControlParent()->isDeclScope(Var)) {
+            CheckS->getControlParent()->isDeclScope(DeclPtrTy::make(Var))) {
           if (Var->getType()->isBooleanType())
             ExprError(Diag(Loc, diag::warn_value_always_false)
               << Var->getDeclName());
@@ -1743,7 +1743,7 @@
 Sema::ActOnMemberReferenceExpr(Scope *S, ExprArg Base, SourceLocation OpLoc,
                                tok::TokenKind OpKind, SourceLocation MemberLoc,
                                IdentifierInfo &Member,
-                               DeclTy *ObjCImpDecl) {
+                               DeclPtrTy ObjCImpDecl) {
   Expr *BaseExpr = static_cast<Expr *>(Base.release());
   assert(BaseExpr && "no record expression");
 
@@ -1879,7 +1879,7 @@
           // the context as argument to this routine. Ideally, this context need
           // be passed down in the AST node and somehow calculated from the AST
           // for a function decl.
-          Decl *ImplDecl = static_cast<Decl *>(ObjCImpDecl);
+          Decl *ImplDecl = ObjCImpDecl.getAs<Decl>();
           if (ObjCImplementationDecl *IMPD = 
               dyn_cast<ObjCImplementationDecl>(ImplDecl))
             ClassOfMethodDecl = IMPD->getClassInterface();
@@ -4590,13 +4590,13 @@
   // no arguments, not a function that takes a single void argument.
   if (FTI.hasPrototype &&
       FTI.NumArgs == 1 && !FTI.isVariadic && FTI.ArgInfo[0].Ident == 0 &&
-      (!((ParmVarDecl *)FTI.ArgInfo[0].Param)->getType().getCVRQualifiers() &&
-        ((ParmVarDecl *)FTI.ArgInfo[0].Param)->getType()->isVoidType())) {
+     (!FTI.ArgInfo[0].Param.getAs<ParmVarDecl>()->getType().getCVRQualifiers()&&
+        FTI.ArgInfo[0].Param.getAs<ParmVarDecl>()->getType()->isVoidType())) {
     // empty arg list, don't push any params.
     CurBlock->isVariadic = false;
   } else if (FTI.hasPrototype) {
     for (unsigned i = 0, e = FTI.NumArgs; i != e; ++i)
-      CurBlock->Params.push_back((ParmVarDecl *)FTI.ArgInfo[i].Param);
+      CurBlock->Params.push_back(FTI.ArgInfo[i].Param.getAs<ParmVarDecl>());
     CurBlock->isVariadic = FTI.isVariadic;
     QualType T = GetTypeForDeclarator (ParamInfo, CurScope);
 

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=67952&r1=67951&r2=67952&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Sat Mar 28 14:18:32 2009
@@ -664,26 +664,28 @@
   } else if (const RecordType *RT = Ty->getAsRecordType()) {
     RecordDecl *RD = RT->getDecl();
     // The type-specifier-seq shall not declare a new class...
-    if (RD->isDefinition() && (RD->getIdentifier() == 0 || S->isDeclScope(RD)))
+    if (RD->isDefinition() &&
+        (RD->getIdentifier() == 0 || S->isDeclScope(DeclPtrTy::make(RD))))
       Diag(RD->getLocation(), diag::err_type_defined_in_condition);
   } else if (const EnumType *ET = Ty->getAsEnumType()) {
     EnumDecl *ED = ET->getDecl();
     // ...or enumeration.
-    if (ED->isDefinition() && (ED->getIdentifier() == 0 || S->isDeclScope(ED)))
+    if (ED->isDefinition() &&
+        (ED->getIdentifier() == 0 || S->isDeclScope(DeclPtrTy::make(ED))))
       Diag(ED->getLocation(), diag::err_type_defined_in_condition);
   }
 
-  DeclTy *Dcl = ActOnDeclarator(S, D, 0);
+  DeclPtrTy Dcl = ActOnDeclarator(S, D, DeclPtrTy());
   if (!Dcl)
     return ExprError();
   AddInitializerToDecl(Dcl, move(AssignExprVal));
 
   // Mark this variable as one that is declared within a conditional.
-  if (VarDecl *VD = dyn_cast<VarDecl>((Decl *)Dcl))
-    VD->setDeclaredInCondition(true);
-
-  return Owned(new (Context) CXXConditionDeclExpr(StartLoc, EqualLoc,
-                                      cast<VarDecl>(static_cast<Decl *>(Dcl))));
+  // We know that the decl had to be a VarDecl because that is the only type of
+  // decl that can be assigned and the grammar requires an '='.
+  VarDecl *VD = cast<VarDecl>(Dcl.getAs<Decl>());
+  VD->setDeclaredInCondition(true);
+  return Owned(new (Context) CXXConditionDeclExpr(StartLoc, EqualLoc, VD));
 }
 
 /// CheckCXXBooleanCondition - Returns true if a conversion to bool is invalid.

Modified: cfe/trunk/lib/Sema/SemaLookup.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=67952&r1=67951&r2=67952&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaLookup.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLookup.cpp Sat Mar 28 14:18:32 2009
@@ -84,12 +84,11 @@
     AddNamespaceUsingDirectives(Ctx, UDirs, /*ref*/ VisitedNS);
 
   } else {
-    Scope::udir_iterator
-      I = S->using_directives_begin(),
-      End = S->using_directives_end();
+    Scope::udir_iterator I = S->using_directives_begin(),
+                         End = S->using_directives_end();
 
     for (; I != End; ++I) {
-      UsingDirectiveDecl * UD = static_cast<UsingDirectiveDecl*>(*I);
+      UsingDirectiveDecl *UD = I->getAs<UsingDirectiveDecl>();
       UDirs.push_back(UD);
       std::push_heap(UDirs.begin(), UDirs.end(), UsingDirAncestorCompare());
 
@@ -575,7 +574,7 @@
   //
   for (; S && !isNamespaceOrTranslationUnitScope(S); S = S->getParent()) {
     // Check whether the IdResolver has anything in this scope.
-    for (; I != IEnd && S->isDeclScope(*I); ++I) {
+    for (; I != IEnd && S->isDeclScope(DeclPtrTy::make(*I)); ++I) {
       if (isAcceptableLookupResult(*I, NameKind, IDNS)) {
         // We found something.  Look for anything else in our scope
         // with this same name and in an acceptable identifier
@@ -583,7 +582,7 @@
         // need to.
         IdentifierResolver::iterator LastI = I;
         for (++LastI; LastI != IEnd; ++LastI) {
-          if (!S->isDeclScope(*LastI))
+          if (!S->isDeclScope(DeclPtrTy::make(*LastI)))
             break;
         }
         LookupResult Result =
@@ -666,7 +665,7 @@
            "We should have been looking only at file context here already.");
 
     // Check whether the IdResolver has anything in this scope.
-    for (; I != IEnd && S->isDeclScope(*I); ++I) {
+    for (; I != IEnd && S->isDeclScope(DeclPtrTy::make(*I)); ++I) {
       if (isAcceptableLookupResult(*I, NameKind, IDNS)) {
         // We found something.  Look for anything else in our scope
         // with this same name and in an acceptable identifier
@@ -674,7 +673,7 @@
         // need to.
         IdentifierResolver::iterator LastI = I;
         for (++LastI; LastI != IEnd; ++LastI) {
-          if (!S->isDeclScope(*LastI))
+          if (!S->isDeclScope(DeclPtrTy::make(*LastI)))
             break;
         }
         
@@ -790,7 +789,7 @@
         if (NameKind == LookupRedeclarationWithLinkage) {
           // Determine whether this (or a previous) declaration is
           // out-of-scope.
-          if (!LeftStartingScope && !S->isDeclScope(*I))
+          if (!LeftStartingScope && !S->isDeclScope(DeclPtrTy::make(*I)))
             LeftStartingScope = true;
 
           // If we found something outside of our starting scope that
@@ -804,14 +803,15 @@
           // might have a set of overloaded functions.
 
           // Figure out what scope the identifier is in.
-          while (!(S->getFlags() & Scope::DeclScope) || !S->isDeclScope(*I))
+          while (!(S->getFlags() & Scope::DeclScope) ||
+                 !S->isDeclScope(DeclPtrTy::make(*I)))
             S = S->getParent();
 
           // Find the last declaration in this scope (with the same
           // name, naturally).
           IdentifierResolver::iterator LastI = I;
           for (++LastI; LastI != IEnd; ++LastI) {
-            if (!S->isDeclScope(*LastI))
+            if (!S->isDeclScope(DeclPtrTy::make(*LastI)))
               break;
           }
 

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=67952&r1=67951&r2=67952&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Sat Mar 28 14:18:32 2009
@@ -4323,7 +4323,7 @@
                                  Method->getResultType().getNonReferenceType(),
                                  OpLoc);
   return ActOnMemberReferenceExpr(S, ExprArg(*this, Base), OpLoc, tok::arrow,
-                                  MemberLoc, Member).release();
+                                  MemberLoc, Member, DeclPtrTy()).release();
 }
 
 /// FixOverloadedFunctionReference - E is an expression that refers to

Modified: cfe/trunk/lib/Sema/SemaStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmt.cpp?rev=67952&r1=67951&r2=67952&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmt.cpp Sat Mar 28 14:18:32 2009
@@ -37,14 +37,13 @@
   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 @@
 
 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 @@
 /// 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())));
 }
 

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=67952&r1=67951&r2=67952&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Sat Mar 28 14:18:32 2009
@@ -27,21 +27,19 @@
 /// passed to indicate the C++ scope in which the identifier will be
 /// found. 
 TemplateNameKind Sema::isTemplateName(IdentifierInfo &II, Scope *S,
-                                      DeclTy *&Template,
+                                      DeclPtrTy &Template,
                                       const CXXScopeSpec *SS) {
   NamedDecl *IIDecl = LookupParsedName(S, SS, &II, LookupOrdinaryName);
 
   if (IIDecl) {
     if (isa<TemplateDecl>(IIDecl)) {
-      Template = IIDecl;
+      Template = DeclPtrTy::make(IIDecl);
       if (isa<FunctionTemplateDecl>(IIDecl))
         return TNK_Function_template;
-      else if (isa<ClassTemplateDecl>(IIDecl))
+      if (isa<ClassTemplateDecl>(IIDecl))
         return TNK_Class_template;
-      else if (isa<TemplateTemplateParmDecl>(IIDecl))
-        return TNK_Template_template_parm;
-      else
-        assert(false && "Unknown TemplateDecl");
+      assert(isa<TemplateTemplateParmDecl>(IIDecl) && "Unknown TemplateDecl");
+      return TNK_Template_template_parm;
     } else if (CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(IIDecl)) {
       // C++ [temp.local]p1:
       //   Like normal (non-template) classes, class templates have an
@@ -56,11 +54,11 @@
       //   specialization.
       if (Record->isInjectedClassName()) {
         Record = cast<CXXRecordDecl>(Context.getCanonicalDecl(Record));
-        if ((Template = Record->getDescribedClassTemplate()))
+        if ((Template = DeclPtrTy::make(Record->getDescribedClassTemplate())))
           return TNK_Class_template;
-        else if (ClassTemplateSpecializationDecl *Spec
+        if (ClassTemplateSpecializationDecl *Spec
                    = dyn_cast<ClassTemplateSpecializationDecl>(Record)) {
-          Template = Spec->getSpecializedTemplate();
+          Template = DeclPtrTy::make(Spec->getSpecializedTemplate());
           return TNK_Class_template;
         }
       }
@@ -69,7 +67,7 @@
     // FIXME: What follows is a gross hack.
     if (FunctionDecl *FD = dyn_cast<FunctionDecl>(IIDecl)) {
       if (FD->getType()->isDependentType()) {
-        Template = FD;
+        Template = DeclPtrTy::make(FD);
         return TNK_Function_template;
       }
     } else if (OverloadedFunctionDecl *Ovl 
@@ -78,7 +76,7 @@
                                                   FEnd = Ovl->function_end();
            F != FEnd; ++F) {
         if ((*F)->getType()->isDependentType()) {
-          Template = Ovl;
+          Template = DeclPtrTy::make(Ovl);
           return TNK_Function_template;
         }
       }
@@ -110,10 +108,9 @@
 /// AdjustDeclIfTemplate - If the given decl happens to be a template, reset
 /// the parameter D to reference the templated declaration and return a pointer
 /// to the template declaration. Otherwise, do nothing to D and return null.
-TemplateDecl *Sema::AdjustDeclIfTemplate(DeclTy *&D)
-{
-  if(TemplateDecl *Temp = dyn_cast<TemplateDecl>(static_cast<Decl*>(D))) {
-    D = Temp->getTemplatedDecl();
+TemplateDecl *Sema::AdjustDeclIfTemplate(DeclPtrTy &D) {
+  if (TemplateDecl *Temp = dyn_cast<TemplateDecl>(D.getAs<Decl>())) {
+    D = DeclPtrTy::make(Temp->getTemplatedDecl());
     return Temp;
   }
   return 0;
@@ -128,11 +125,11 @@
 /// ParamName is the location of the parameter name (if any). 
 /// If the type parameter has a default argument, it will be added
 /// later via ActOnTypeParameterDefault.
-Sema::DeclTy *Sema::ActOnTypeParameter(Scope *S, bool Typename, 
-				       SourceLocation KeyLoc,
-				       IdentifierInfo *ParamName,
-				       SourceLocation ParamNameLoc,
-                                       unsigned Depth, unsigned Position) {
+Sema::DeclPtrTy Sema::ActOnTypeParameter(Scope *S, bool Typename, 
+                                         SourceLocation KeyLoc,
+                                         IdentifierInfo *ParamName,
+                                         SourceLocation ParamNameLoc,
+                                         unsigned Depth, unsigned Position) {
   assert(S->isTemplateParamScope() && 
 	 "Template type parameter not in template parameter scope!");
   bool Invalid = false;
@@ -156,21 +153,21 @@
 
   if (ParamName) {
     // Add the template parameter into the current scope.
-    S->AddDecl(Param);
+    S->AddDecl(DeclPtrTy::make(Param));
     IdResolver.AddDecl(Param);
   }
 
-  return Param;
+  return DeclPtrTy::make(Param);
 }
 
 /// ActOnTypeParameterDefault - Adds a default argument (the type
 /// Default) to the given template type parameter (TypeParam). 
-void Sema::ActOnTypeParameterDefault(DeclTy *TypeParam, 
+void Sema::ActOnTypeParameterDefault(DeclPtrTy TypeParam, 
                                      SourceLocation EqualLoc,
                                      SourceLocation DefaultLoc, 
                                      TypeTy *DefaultT) {
   TemplateTypeParmDecl *Parm 
-    = cast<TemplateTypeParmDecl>(static_cast<Decl *>(TypeParam));
+    = cast<TemplateTypeParmDecl>(TypeParam.getAs<Decl>());
   QualType Default = QualType::getFromOpaquePtr(DefaultT);
 
   // C++ [temp.param]p14:
@@ -234,9 +231,9 @@
 /// template parameter (e.g., "int Size" in "template<int Size>
 /// class Array") has been parsed. S is the current scope and D is
 /// the parsed declarator.
-Sema::DeclTy *Sema::ActOnNonTypeTemplateParameter(Scope *S, Declarator &D,
-                                                  unsigned Depth, 
-                                                  unsigned Position) {
+Sema::DeclPtrTy Sema::ActOnNonTypeTemplateParameter(Scope *S, Declarator &D,
+                                                    unsigned Depth, 
+                                                    unsigned Position) {
   QualType T = GetTypeForDeclarator(D, S);
 
   assert(S->isTemplateParamScope() &&
@@ -265,19 +262,19 @@
 
   if (D.getIdentifier()) {
     // Add the template parameter into the current scope.
-    S->AddDecl(Param);
+    S->AddDecl(DeclPtrTy::make(Param));
     IdResolver.AddDecl(Param);
   }
-  return Param;
+  return DeclPtrTy::make(Param);
 }
 
 /// \brief Adds a default argument to the given non-type template
 /// parameter.
-void Sema::ActOnNonTypeTemplateParameterDefault(DeclTy *TemplateParamD,
+void Sema::ActOnNonTypeTemplateParameterDefault(DeclPtrTy TemplateParamD,
                                                 SourceLocation EqualLoc,
                                                 ExprArg DefaultE) {
   NonTypeTemplateParmDecl *TemplateParm 
-    = cast<NonTypeTemplateParmDecl>(static_cast<Decl *>(TemplateParamD));
+    = cast<NonTypeTemplateParmDecl>(TemplateParamD.getAs<Decl>());
   Expr *Default = static_cast<Expr *>(DefaultE.get());
   
   // C++ [temp.param]p14:
@@ -297,13 +294,13 @@
 /// ActOnTemplateTemplateParameter - Called when a C++ template template
 /// parameter (e.g. T in template <template <typename> class T> class array)
 /// has been parsed. S is the current scope.
-Sema::DeclTy *Sema::ActOnTemplateTemplateParameter(Scope* S,
-                                                   SourceLocation TmpLoc,
-                                                   TemplateParamsTy *Params,
-                                                   IdentifierInfo *Name,
-                                                   SourceLocation NameLoc,
-                                                   unsigned Depth,
-                                                   unsigned Position)
+Sema::DeclPtrTy Sema::ActOnTemplateTemplateParameter(Scope* S,
+                                                     SourceLocation TmpLoc,
+                                                     TemplateParamsTy *Params,
+                                                     IdentifierInfo *Name,
+                                                     SourceLocation NameLoc,
+                                                     unsigned Depth,
+                                                     unsigned Position)
 {
   assert(S->isTemplateParamScope() &&
          "Template template parameter not in template parameter scope!");
@@ -326,20 +323,20 @@
   // If the tt-param has a name, then link the identifier into the scope
   // and lookup mechanisms.
   if (Name) {
-    S->AddDecl(Param);
+    S->AddDecl(DeclPtrTy::make(Param));
     IdResolver.AddDecl(Param);
   }
 
-  return Param;
+  return DeclPtrTy::make(Param);
 }
 
 /// \brief Adds a default argument to the given template template
 /// parameter.
-void Sema::ActOnTemplateTemplateParameterDefault(DeclTy *TemplateParamD,
+void Sema::ActOnTemplateTemplateParameterDefault(DeclPtrTy TemplateParamD,
                                                  SourceLocation EqualLoc,
                                                  ExprArg DefaultE) {
   TemplateTemplateParmDecl *TemplateParm 
-    = cast<TemplateTemplateParmDecl>(static_cast<Decl *>(TemplateParamD));
+    = cast<TemplateTemplateParmDecl>(TemplateParamD.getAs<Decl>());
 
   // Since a template-template parameter's default argument is an
   // id-expression, it must be a DeclRefExpr.
@@ -374,7 +371,7 @@
                                  SourceLocation ExportLoc,
                                  SourceLocation TemplateLoc, 
                                  SourceLocation LAngleLoc,
-                                 DeclTy **Params, unsigned NumParams,
+                                 DeclPtrTy *Params, unsigned NumParams,
                                  SourceLocation RAngleLoc) {
   if (ExportLoc.isValid())
     Diag(ExportLoc, diag::note_template_export_unsupported);
@@ -522,7 +519,7 @@
     NewTemplate->setInvalidDecl();
     NewClass->setInvalidDecl();
   }
-  return NewTemplate;
+  return DeclPtrTy::make(NewTemplate);
 }
 
 /// \brief Checks the validity of a template parameter list, possibly
@@ -774,13 +771,13 @@
 }
 
 Action::TypeResult
-Sema::ActOnClassTemplateId(DeclTy *TemplateD, SourceLocation TemplateLoc,
+Sema::ActOnClassTemplateId(DeclPtrTy TemplateD, SourceLocation TemplateLoc,
                            SourceLocation LAngleLoc, 
                            ASTTemplateArgsPtr TemplateArgsIn,
                            SourceLocation *TemplateArgLocs,
                            SourceLocation RAngleLoc,
                            const CXXScopeSpec *SS) {
-  TemplateDecl *Template = cast<TemplateDecl>(static_cast<Decl *>(TemplateD));
+  TemplateDecl *Template = cast<TemplateDecl>(TemplateD.getAs<Decl>());
   ClassTemplateDecl *ClassTemplate = cast<ClassTemplateDecl>(Template);
 
   // Translate the parser's template argument list in our AST format.
@@ -1798,7 +1795,7 @@
 Sema::ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec, TagKind TK,
                                        SourceLocation KWLoc, 
                                        const CXXScopeSpec &SS,
-                                       DeclTy *TemplateD,
+                                       DeclPtrTy TemplateD,
                                        SourceLocation TemplateNameLoc,
                                        SourceLocation LAngleLoc,
                                        ASTTemplateArgsPtr TemplateArgsIn,
@@ -1808,7 +1805,7 @@
                                MultiTemplateParamsArg TemplateParameterLists) {
   // Find the class template we're specializing
   ClassTemplateDecl *ClassTemplate 
-    = dyn_cast_or_null<ClassTemplateDecl>(static_cast<Decl *>(TemplateD));
+    = dyn_cast_or_null<ClassTemplateDecl>(TemplateD.getAs<Decl>());
   if (!ClassTemplate)
     return true;
 
@@ -1823,14 +1820,17 @@
   else {
     TemplateParameterList *TemplateParams 
       = static_cast<TemplateParameterList*>(*TemplateParameterLists.get());
-    if (TemplateParameterLists.size() > 1)
-      return Diag(TemplateParams->getTemplateLoc(),
-                  diag::err_template_spec_extra_headers);
+    if (TemplateParameterLists.size() > 1) {
+      Diag(TemplateParams->getTemplateLoc(),
+           diag::err_template_spec_extra_headers);
+      return true;
+    }
 
-    if (TemplateParams->size() > 0)
+    if (TemplateParams->size() > 0) {
       // FIXME: No support for class template partial specialization.
-      return Diag(TemplateParams->getTemplateLoc(), 
-                  diag::unsup_template_partial_spec);
+      Diag(TemplateParams->getTemplateLoc(), diag::unsup_template_partial_spec);
+      return true;
+    }
   }
 
   // Check that the specialization uses the same tag kind as the
@@ -1962,7 +1962,7 @@
   // be seen when iterating through the list of declarations in that
   // context. However, specializations are not found by name lookup.
   CurContext->addDecl(Specialization);
-  return Specialization;
+  return DeclPtrTy::make(Specialization);
 }
 
 Sema::TypeResult
@@ -1974,9 +1974,6 @@
     return true;
 
   QualType T = CheckTypenameType(NNS, II, SourceRange(TypenameLoc, IdLoc));
-  if (T.isNull())
-    return 0;
-
   return T.getAsOpaquePtr();
 }
 

Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp?rev=67952&r1=67951&r2=67952&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp Sat Mar 28 14:18:32 2009
@@ -715,17 +715,16 @@
                                 NumTemplateArgs))
     Invalid = true;
 
-  llvm::SmallVector<DeclTy *, 32> Fields;
+  llvm::SmallVector<DeclPtrTy, 32> Fields;
   for (RecordDecl::decl_iterator Member = Pattern->decls_begin(),
-                              MemberEnd = Pattern->decls_end();
-       Member != MemberEnd; ++Member) {
+       MemberEnd = Pattern->decls_end(); Member != MemberEnd; ++Member) {
     Decl *NewMember = InstantiateDecl(*Member, Instantiation,
                                       TemplateArgs, NumTemplateArgs);
     if (NewMember) {
       if (NewMember->isInvalidDecl())
         Invalid = true;
       else if (FieldDecl *Field = dyn_cast<FieldDecl>(NewMember))
-        Fields.push_back(Field);
+        Fields.push_back(DeclPtrTy::make(Field));
     } else {
       // FIXME: Eventually, a NULL return will mean that one of the
       // instantiations was a semantic disaster, and we'll want to set
@@ -735,7 +734,7 @@
   }
 
   // Finish checking fields.
-  ActOnFields(0, Instantiation->getLocation(), Instantiation,
+  ActOnFields(0, Instantiation->getLocation(), DeclPtrTy::make(Instantiation),
               &Fields[0], Fields.size(), SourceLocation(), SourceLocation(),
               0);
 

Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=67952&r1=67951&r2=67952&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Sat Mar 28 14:18:32 2009
@@ -20,8 +20,7 @@
 
 namespace {
   class VISIBILITY_HIDDEN TemplateDeclInstantiator 
-    : public DeclVisitor<TemplateDeclInstantiator, Decl *> 
-  {
+    : public DeclVisitor<TemplateDeclInstantiator, Decl *> {
     Sema &SemaRef;
     DeclContext *Owner;
     const TemplateArgument *TemplateArgs;
@@ -136,7 +135,7 @@
     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 @@
 
   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 @@
   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 @@
 
     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;

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=67952&r1=67951&r2=67952&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Sat Mar 28 14:18:32 2009
@@ -707,7 +707,8 @@
         llvm::SmallVector<QualType, 16> ArgTys;
         
         for (unsigned i = 0, e = FTI.NumArgs; i != e; ++i) {
-          ParmVarDecl *Param = (ParmVarDecl *)FTI.ArgInfo[i].Param;
+          ParmVarDecl *Param =
+            cast<ParmVarDecl>(FTI.ArgInfo[i].Param.getAs<Decl>());
           QualType ArgTy = Param->getType();
           assert(!ArgTy.isNull() && "Couldn't parse type?");
 
@@ -849,8 +850,8 @@
 
 /// ObjCGetTypeForMethodDefinition - Builds the type for a method definition
 /// declarator
-QualType Sema::ObjCGetTypeForMethodDefinition(DeclTy *D) {
-  ObjCMethodDecl *MDecl = cast<ObjCMethodDecl>(static_cast<Decl *>(D));
+QualType Sema::ObjCGetTypeForMethodDefinition(DeclPtrTy D) {
+  ObjCMethodDecl *MDecl = cast<ObjCMethodDecl>(D.getAs<Decl>());
   QualType T = MDecl->getResultType();
   llvm::SmallVector<QualType, 16> ArgTys;
   

Modified: cfe/trunk/tools/clang-cc/PrintParserCallbacks.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-cc/PrintParserCallbacks.cpp?rev=67952&r1=67951&r2=67952&view=diff

==============================================================================
--- cfe/trunk/tools/clang-cc/PrintParserCallbacks.cpp (original)
+++ cfe/trunk/tools/clang-cc/PrintParserCallbacks.cpp Sat Mar 28 14:18:32 2009
@@ -29,8 +29,8 @@
     /// ActOnDeclarator - This callback is invoked when a declarator is parsed
     /// and 'Init' specifies the initializer if any.  This is for things like:
     /// "int X = 4" or "typedef int foo".
-    virtual DeclTy *ActOnDeclarator(Scope *S, Declarator &D,
-                                    DeclTy *LastInGroup) {
+    virtual DeclPtrTy ActOnDeclarator(Scope *S, Declarator &D,
+                                      DeclPtrTy LastInGroup) {
       llvm::cout << __FUNCTION__ << " ";
       if (IdentifierInfo *II = D.getIdentifier()) {
         llvm::cout << "'" << II->getName() << "'";
@@ -57,15 +57,15 @@
     }
 
 
-    Action::DeclTy *ActOnStartClassInterface(SourceLocation AtInterfaceLoc,
-                                             IdentifierInfo *ClassName,
-                                             SourceLocation ClassLoc,
-                                             IdentifierInfo *SuperName,
-                                             SourceLocation SuperLoc,
-                                             DeclTy * const *ProtoRefs,
-                                             unsigned NumProtocols,
-                                             SourceLocation EndProtoLoc,
-                                             AttributeList *AttrList) {
+    Action::DeclPtrTy ActOnStartClassInterface(SourceLocation AtInterfaceLoc,
+                                               IdentifierInfo *ClassName,
+                                               SourceLocation ClassLoc,
+                                               IdentifierInfo *SuperName,
+                                               SourceLocation SuperLoc,
+                                               const DeclPtrTy *ProtoRefs,
+                                               unsigned NumProtocols,
+                                               SourceLocation EndProtoLoc,
+                                               AttributeList *AttrList) {
       llvm::cout << __FUNCTION__ << "\n";
       return MinimalAction::ActOnStartClassInterface(AtInterfaceLoc,
                                                      ClassName, ClassLoc, 
@@ -76,9 +76,9 @@
 
     /// ActOnForwardClassDeclaration - 
     /// Scope will always be top level file scope. 
-    Action::DeclTy *ActOnForwardClassDeclaration(SourceLocation AtClassLoc,
-                                                 IdentifierInfo **IdentList, 
-                                                 unsigned NumElts) {
+    Action::DeclPtrTy ActOnForwardClassDeclaration(SourceLocation AtClassLoc,
+                                                   IdentifierInfo **IdentList, 
+                                                   unsigned NumElts) {
       llvm::cout << __FUNCTION__ << "\n";
       return MinimalAction::ActOnForwardClassDeclaration(AtClassLoc, IdentList,
                                                          NumElts);
@@ -90,7 +90,7 @@
     /// declarator is parsed. This callback only occurs for functions
     /// with prototypes. S is the function prototype scope for the
     /// parameters (C++ [basic.scope.proto]).
-    virtual DeclTy *ActOnParamDeclarator(Scope *S, Declarator &D) {
+    virtual DeclPtrTy ActOnParamDeclarator(Scope *S, Declarator &D) {
       llvm::cout << __FUNCTION__ << " ";
       if (IdentifierInfo *II = D.getIdentifier()) {
         llvm::cout << "'" << II->getName() << "'";
@@ -98,7 +98,7 @@
         llvm::cout << "<anon>";
       }
       llvm::cout << "\n";
-      return 0;
+      return DeclPtrTy();
     }
     
     /// AddInitializerToDecl - This action is called immediately after 
@@ -108,73 +108,75 @@
     /// This allows ActOnDeclarator to register "xx" prior to parsing the
     /// initializer. The declaration above should still result in a warning, 
     /// since the reference to "xx" is uninitialized.
-    virtual void AddInitializerToDecl(DeclTy *Dcl, ExprArg Init) {
+    virtual void AddInitializerToDecl(DeclPtrTy Dcl, ExprArg Init) {
       llvm::cout << __FUNCTION__ << "\n";
     }
 
     /// FinalizeDeclaratorGroup - After a sequence of declarators are parsed, this
     /// gives the actions implementation a chance to process the group as a whole.
-    virtual DeclTy *FinalizeDeclaratorGroup(Scope *S, DeclTy *Group) {
+    virtual DeclPtrTy FinalizeDeclaratorGroup(Scope *S, DeclPtrTy Group) {
       llvm::cout << __FUNCTION__ << "\n";
-      return 0;
+      return DeclPtrTy();
     }
 
     /// ActOnStartOfFunctionDef - This is called at the start of a function
     /// definition, instead of calling ActOnDeclarator.  The Declarator includes
     /// information about formal arguments that are part of this function.
-    virtual DeclTy *ActOnStartOfFunctionDef(Scope *FnBodyScope, Declarator &D) {
+    virtual DeclPtrTy ActOnStartOfFunctionDef(Scope *FnBodyScope, Declarator &D) {
       llvm::cout << __FUNCTION__ << "\n";
-      return 0;
+      return DeclPtrTy();
     }
 
     /// ActOnStartOfFunctionDef - This is called at the start of a function
     /// definition, after the FunctionDecl has already been created.
-    virtual DeclTy *ActOnStartOfFunctionDef(Scope *FnBodyScope, DeclTy *D) {
+    virtual DeclPtrTy ActOnStartOfFunctionDef(Scope *FnBodyScope, DeclPtrTy D) {
       llvm::cout << __FUNCTION__ << "\n";
-      return 0;
+      return DeclPtrTy();
     }
 
-    virtual void ActOnStartOfObjCMethodDef(Scope *FnBodyScope, DeclTy *D) {
+    virtual void ActOnStartOfObjCMethodDef(Scope *FnBodyScope, DeclPtrTy D) {
       llvm::cout << __FUNCTION__ << "\n";
     }
   
     /// ActOnFunctionDefBody - This is called when a function body has completed
     /// parsing.  Decl is the DeclTy returned by ParseStartOfFunctionDef.
-    virtual DeclTy *ActOnFinishFunctionBody(DeclTy *Decl, StmtArg Body) {
+    virtual DeclPtrTy ActOnFinishFunctionBody(DeclPtrTy Decl, StmtArg Body) {
       llvm::cout << __FUNCTION__ << "\n";
-      return 0;
+      return DeclPtrTy();
     }
 
-    virtual DeclTy *ActOnFileScopeAsmDecl(SourceLocation Loc, ExprArg AsmString) {
+    virtual DeclPtrTy ActOnFileScopeAsmDecl(SourceLocation Loc,
+                                            ExprArg AsmString) {
       llvm::cout << __FUNCTION__ << "\n";
-      return 0;
+      return DeclPtrTy();
     }
   
     /// ParsedFreeStandingDeclSpec - This method is invoked when a declspec with
     /// no declarator (e.g. "struct foo;") is parsed.
-    virtual DeclTy *ParsedFreeStandingDeclSpec(Scope *S, DeclSpec &DS) {
+    virtual DeclPtrTy ParsedFreeStandingDeclSpec(Scope *S, DeclSpec &DS) {
       llvm::cout << __FUNCTION__ << "\n";
-      return 0;
+      return DeclPtrTy();
     }
     
     /// ActOnLinkageSpec - Parsed a C++ linkage-specification that
     /// contained braces. Lang/StrSize contains the language string that
     /// was parsed at location Loc. Decls/NumDecls provides the
     /// declarations parsed inside the linkage specification.
-    virtual DeclTy *ActOnLinkageSpec(SourceLocation Loc, SourceLocation LBrace,
-                                     SourceLocation RBrace, const char *Lang,
-                                     unsigned StrSize, 
-                                     DeclTy **Decls, unsigned NumDecls) {
+    virtual DeclPtrTy ActOnLinkageSpec(SourceLocation Loc,
+                                       SourceLocation LBrace,
+                                       SourceLocation RBrace, const char *Lang,
+                                       unsigned StrSize, 
+                                       DeclPtrTy *Decls, unsigned NumDecls) {
       llvm::cout << __FUNCTION__ << "\n";
-      return 0;
+      return DeclPtrTy();
     }
     
     /// ActOnLinkageSpec - Parsed a C++ linkage-specification without
     /// braces. Lang/StrSize contains the language string that was
     /// parsed at location Loc. D is the declaration parsed.
-    virtual DeclTy *ActOnLinkageSpec(SourceLocation Loc, const char *Lang,
-                                     unsigned StrSize, DeclTy *D) {
-      return 0;
+    virtual DeclPtrTy ActOnLinkageSpec(SourceLocation Loc, const char *Lang,
+                                       unsigned StrSize, DeclPtrTy D) {
+      return DeclPtrTy();
     }
     
     //===--------------------------------------------------------------------===//
@@ -183,58 +185,58 @@
   
     virtual TypeResult ActOnTypeName(Scope *S, Declarator &D) {
       llvm::cout << __FUNCTION__ << "\n";
-      return 0;
+      return TypeResult();
     }
   
-    virtual DeclTy *ActOnTag(Scope *S, unsigned TagType, TagKind TK,
-                             SourceLocation KWLoc, const CXXScopeSpec &SS,
-                             IdentifierInfo *Name, SourceLocation NameLoc,
-                             AttributeList *Attr, AccessSpecifier AS) {
+    virtual DeclPtrTy ActOnTag(Scope *S, unsigned TagType, TagKind TK,
+                               SourceLocation KWLoc, const CXXScopeSpec &SS,
+                               IdentifierInfo *Name, SourceLocation NameLoc,
+                               AttributeList *Attr, AccessSpecifier AS) {
       // TagType is an instance of DeclSpec::TST, indicating what kind of tag this
       // is (struct/union/enum/class).
       llvm::cout << __FUNCTION__ << "\n";
-      return 0;
+      return DeclPtrTy();
     }
   
     /// Act on @defs() element found when parsing a structure.  ClassName is the
     /// name of the referenced class.   
-    virtual void ActOnDefs(Scope *S, DeclTy *TagD, SourceLocation DeclStart,
+    virtual void ActOnDefs(Scope *S, DeclPtrTy TagD, SourceLocation DeclStart,
                            IdentifierInfo *ClassName,
-                           llvm::SmallVectorImpl<DeclTy*> &Decls) {
+                           llvm::SmallVectorImpl<DeclPtrTy> &Decls) {
       llvm::cout << __FUNCTION__ << "\n";
     }
 
-    virtual DeclTy *ActOnField(Scope *S, DeclTy *TagD, 
-                               SourceLocation DeclStart,
-                               Declarator &D, ExprTy *BitfieldWidth) {
+    virtual DeclPtrTy ActOnField(Scope *S, DeclPtrTy TagD, 
+                                 SourceLocation DeclStart,
+                                 Declarator &D, ExprTy *BitfieldWidth) {
       llvm::cout << __FUNCTION__ << "\n";
-      return 0;
+      return DeclPtrTy();
     }
   
-    virtual DeclTy *ActOnIvar(Scope *S, SourceLocation DeclStart,
-                              Declarator &D, ExprTy *BitfieldWidth,
-                              tok::ObjCKeywordKind visibility) {
+    virtual DeclPtrTy ActOnIvar(Scope *S, SourceLocation DeclStart,
+                                Declarator &D, ExprTy *BitfieldWidth,
+                                tok::ObjCKeywordKind visibility) {
       llvm::cout << __FUNCTION__ << "\n";
-      return 0;
+      return DeclPtrTy();
     }
   
-    virtual void ActOnFields(Scope* S, SourceLocation RecLoc, DeclTy *TagDecl,
-                             DeclTy **Fields, unsigned NumFields, 
+    virtual void ActOnFields(Scope* S, SourceLocation RecLoc, DeclPtrTy TagDecl,
+                             DeclPtrTy *Fields, unsigned NumFields, 
                              SourceLocation LBrac, SourceLocation RBrac,
                              AttributeList *AttrList) {
       llvm::cout << __FUNCTION__ << "\n";
     }
   
-    virtual DeclTy *ActOnEnumConstant(Scope *S, DeclTy *EnumDecl,
-                                      DeclTy *LastEnumConstant,
-                                      SourceLocation IdLoc, IdentifierInfo *Id,
-                                      SourceLocation EqualLoc, ExprTy *Val) {
+    virtual DeclPtrTy ActOnEnumConstant(Scope *S, DeclPtrTy EnumDecl,
+                                        DeclPtrTy LastEnumConstant,
+                                        SourceLocation IdLoc,IdentifierInfo *Id,
+                                        SourceLocation EqualLoc, ExprTy *Val) {
       llvm::cout << __FUNCTION__ << "\n";
-      return 0;
+      return DeclPtrTy();
     }
 
-    virtual void ActOnEnumBody(SourceLocation EnumLoc, DeclTy *EnumDecl,
-                               DeclTy **Elements, unsigned NumElements) {
+    virtual void ActOnEnumBody(SourceLocation EnumLoc, DeclPtrTy EnumDecl,
+                               DeclPtrTy *Elements, unsigned NumElements) {
       llvm::cout << __FUNCTION__ << "\n";
     }
 
@@ -254,7 +256,7 @@
       llvm::cout << __FUNCTION__ << "\n";
       return StmtEmpty();
     }
-    virtual OwningStmtResult ActOnDeclStmt(DeclTy *Decl,
+    virtual OwningStmtResult ActOnDeclStmt(DeclPtrTy Decl,
                                            SourceLocation StartLoc,
                                            SourceLocation EndLoc) {
       llvm::cout << __FUNCTION__ << "\n";
@@ -381,7 +383,7 @@
     // Objective-c statements
     virtual OwningStmtResult ActOnObjCAtCatchStmt(SourceLocation AtLoc,
                                                   SourceLocation RParen,
-                                                  DeclTy *Parm, StmtArg Body,
+                                                  DeclPtrTy Parm, StmtArg Body,
                                                   StmtArg CatchList) {
       llvm::cout << __FUNCTION__ << "\n";
       return StmtEmpty();
@@ -415,13 +417,13 @@
     }
 
     // C++ Statements
-    virtual DeclTy *ActOnExceptionDeclarator(Scope *S, Declarator &D) {
+    virtual DeclPtrTy ActOnExceptionDeclarator(Scope *S, Declarator &D) {
       llvm::cout << __FUNCTION__ << "\n";
-      return 0;
+      return DeclPtrTy();
     }
 
     virtual OwningStmtResult ActOnCXXCatchBlock(SourceLocation CatchLoc,
-                                                DeclTy *ExceptionDecl,
+                                                DeclPtrTy ExceptionDecl,
                                                 StmtArg HandlerBlock) {
       llvm::cout << __FUNCTION__ << "\n";
       return StmtEmpty();
@@ -518,7 +520,7 @@
                                                       tok::TokenKind OpKind,
                                                       SourceLocation MemberLoc,
                                                       IdentifierInfo &Member,
-                                                      DeclTy *ImplDecl) {
+                                                      DeclPtrTy ImplDecl) {
       llvm::cout << __FUNCTION__ << "\n";
       return ExprEmpty();
     }
@@ -656,14 +658,14 @@
       return ExprEmpty();
     }
 
-    virtual DeclTy *ActOnStartNamespaceDef(Scope *S, SourceLocation IdentLoc,
-                                          IdentifierInfo *Ident,
-                                          SourceLocation LBrace) {
+    virtual DeclPtrTy ActOnStartNamespaceDef(Scope *S, SourceLocation IdentLoc,
+                                             IdentifierInfo *Ident,
+                                             SourceLocation LBrace) {
       llvm::cout << __FUNCTION__ << "\n";
-      return 0;
+      return DeclPtrTy();
     }
 
-    virtual void ActOnFinishNamespaceDef(DeclTy *Dcl,SourceLocation RBrace) {
+    virtual void ActOnFinishNamespaceDef(DeclPtrTy Dcl, SourceLocation RBrace) {
       llvm::cout << __FUNCTION__ << "\n";
       return;
     }
@@ -671,34 +673,34 @@
 #if 0
     // FIXME: AttrList should be deleted by this function, but the definition
     // would have to be available.
-    virtual DeclTy *ActOnUsingDirective(Scope *CurScope,
-                                        SourceLocation UsingLoc,
-                                        SourceLocation NamespcLoc,
-                                        const CXXScopeSpec &SS,
-                                        SourceLocation IdentLoc,
-                                        IdentifierInfo *NamespcName,
-                                        AttributeList *AttrList) {
+    virtual DeclPtrTy ActOnUsingDirective(Scope *CurScope,
+                                          SourceLocation UsingLoc,
+                                          SourceLocation NamespcLoc,
+                                          const CXXScopeSpec &SS,
+                                          SourceLocation IdentLoc,
+                                          IdentifierInfo *NamespcName,
+                                          AttributeList *AttrList) {
       llvm::cout << __FUNCTION__ << "\n";
-      return 0;
+      return DeclPtrTy();
     }
 #endif
 
-    virtual void ActOnParamDefaultArgument(DeclTy *param,
+    virtual void ActOnParamDefaultArgument(DeclPtrTy param,
                                            SourceLocation EqualLoc,
                                            ExprArg defarg) {
       llvm::cout << __FUNCTION__ << "\n";
     }
 
-    virtual void ActOnParamUnparsedDefaultArgument(DeclTy *param,
+    virtual void ActOnParamUnparsedDefaultArgument(DeclPtrTy param,
                                                    SourceLocation EqualLoc) {
       llvm::cout << __FUNCTION__ << "\n";
     }
 
-    virtual void ActOnParamDefaultArgumentError(DeclTy *param) {
+    virtual void ActOnParamDefaultArgumentError(DeclPtrTy param) {
       llvm::cout << __FUNCTION__ << "\n";
     }
 
-    virtual void AddCXXDirectInitializerToDecl(DeclTy *Dcl,
+    virtual void AddCXXDirectInitializerToDecl(DeclPtrTy Dcl,
                                                SourceLocation LParenLoc,
                                                MultiExprArg Exprs,
                                                SourceLocation *CommaLocs,
@@ -707,25 +709,26 @@
       return;
     }
 
-    virtual void ActOnStartDelayedCXXMethodDeclaration(Scope *S, DeclTy *Method)
+    virtual void ActOnStartDelayedCXXMethodDeclaration(Scope *S,
+                                                       DeclPtrTy Method)
     {
       llvm::cout << __FUNCTION__ << "\n";
     }
 
-    virtual void ActOnDelayedCXXMethodParameter(Scope *S, DeclTy *Param) {
+    virtual void ActOnDelayedCXXMethodParameter(Scope *S, DeclPtrTy Param) {
       llvm::cout << __FUNCTION__ << "\n";
     }
 
     virtual void ActOnFinishDelayedCXXMethodDeclaration(Scope *S,
-                                                        DeclTy *Method) {
+                                                        DeclPtrTy Method) {
       llvm::cout << __FUNCTION__ << "\n";
     }
 
-    virtual DeclTy *ActOnStaticAssertDeclaration(SourceLocation AssertLoc,
-                                                 ExprArg AssertExpr,
-                                                 ExprArg AssertMessageExpr) {
+    virtual DeclPtrTy ActOnStaticAssertDeclaration(SourceLocation AssertLoc,
+                                                   ExprArg AssertExpr,
+                                                   ExprArg AssertMessageExpr) {
       llvm::cout << __FUNCTION__ << "\n";
-      return 0;
+      return DeclPtrTy();
     }
 
     virtual OwningExprResult ActOnCXXNamedCast(SourceLocation OpLoc,





More information about the cfe-commits mailing list