[cfe-commits] r111901 - in /cfe/trunk: include/clang/Parse/ include/clang/Sema/ lib/Parse/ lib/Sema/

John McCall rjmccall at apple.com
Mon Aug 23 22:47:05 PDT 2010


Author: rjmccall
Date: Tue Aug 24 00:47:05 2010
New Revision: 111901

URL: http://llvm.org/viewvc/llvm-project?rev=111901&view=rev
Log:
Abstract out passing around types and kill off ActionBase.


Modified:
    cfe/trunk/include/clang/Parse/Parser.h
    cfe/trunk/include/clang/Sema/Action.h
    cfe/trunk/include/clang/Sema/AttributeList.h
    cfe/trunk/include/clang/Sema/DeclSpec.h
    cfe/trunk/include/clang/Sema/Designator.h
    cfe/trunk/include/clang/Sema/Ownership.h
    cfe/trunk/include/clang/Sema/ParsedTemplate.h
    cfe/trunk/include/clang/Sema/Sema.h
    cfe/trunk/lib/Parse/ParseDecl.cpp
    cfe/trunk/lib/Parse/ParseDeclCXX.cpp
    cfe/trunk/lib/Parse/ParseExpr.cpp
    cfe/trunk/lib/Parse/ParseExprCXX.cpp
    cfe/trunk/lib/Parse/ParseInit.cpp
    cfe/trunk/lib/Parse/ParseObjc.cpp
    cfe/trunk/lib/Parse/ParseTemplate.cpp
    cfe/trunk/lib/Parse/Parser.cpp
    cfe/trunk/lib/Sema/Action.cpp
    cfe/trunk/lib/Sema/AttributeList.cpp
    cfe/trunk/lib/Sema/DeclSpec.cpp
    cfe/trunk/lib/Sema/SemaCXXCast.cpp
    cfe/trunk/lib/Sema/SemaCXXScopeSpec.cpp
    cfe/trunk/lib/Sema/SemaCodeComplete.cpp
    cfe/trunk/lib/Sema/SemaDecl.cpp
    cfe/trunk/lib/Sema/SemaDeclAttr.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/SemaExprObjC.cpp
    cfe/trunk/lib/Sema/SemaTemplate.cpp
    cfe/trunk/lib/Sema/SemaType.cpp
    cfe/trunk/lib/Sema/TreeTransform.h

Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=111901&r1=111900&r2=111901&view=diff
==============================================================================
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Tue Aug 24 00:47:05 2010
@@ -149,7 +149,6 @@
   typedef Expr ExprTy;
   typedef Stmt StmtTy;
   typedef OpaquePtr<DeclGroupRef> DeclGroupPtrTy;
-  typedef Action::TypeTy TypeTy;
   typedef CXXBaseSpecifier BaseTy;
   typedef CXXBaseOrMemberInitializer MemInitTy;
   typedef NestedNameSpecifier CXXScopeTy;
@@ -350,6 +349,15 @@
     return PP.LookAhead(0);
   }
 
+  /// getTypeAnnotation - Read a parsed type out of an annotation token.
+  static ParsedType getTypeAnnotation(Token &Tok) {
+    return ParsedType::getFromOpaquePtr(Tok.getAnnotationValue());
+  }
+
+  static void setTypeAnnotation(Token &Tok, ParsedType T) {
+    Tok.setAnnotationValue(T.getAsOpaquePtr());
+  }
+
   /// TryAnnotateTypeOrScopeToken - If the current token position is on a
   /// typename (possibly qualified in C++) or a C++ scope specifier not followed
   /// by a typename, TryAnnotateTypeOrScopeToken will replace one or more tokens
@@ -908,7 +916,7 @@
 
   bool isTokIdentifier_in() const;
 
-  TypeTy *ParseObjCTypeName(ObjCDeclSpec &DS, bool IsParameter);
+  ParsedType ParseObjCTypeName(ObjCDeclSpec &DS, bool IsParameter);
   void ParseObjCMethodRequirement();
   Decl *ParseObjCMethodPrototype(Decl *classOrCat,
             tok::ObjCKeywordKind MethodImplKind = tok::objc_not_keyword);
@@ -937,17 +945,17 @@
   OwningExprResult ParseCastExpression(bool isUnaryExpression,
                                        bool isAddressOfOperand,
                                        bool &NotCastExpr,
-                                       TypeTy *TypeOfCast);
+                                       ParsedType TypeOfCast);
   OwningExprResult ParseCastExpression(bool isUnaryExpression,
                                        bool isAddressOfOperand = false,
-                                       TypeTy *TypeOfCast = 0);
+                                       ParsedType TypeOfCast = ParsedType());
   OwningExprResult ParsePostfixExpressionSuffix(OwningExprResult LHS);
   OwningExprResult ParseSizeofAlignofExpression();
   OwningExprResult ParseBuiltinPrimaryExpression();
 
   OwningExprResult ParseExprAfterTypeofSizeofAlignof(const Token &OpTok,
                                                      bool &isCastExpr,
-                                                     TypeTy *&CastTy,
+                                                     ParsedType &CastTy,
                                                      SourceRange &CastRange);
 
   typedef llvm::SmallVector<Expr*, 20> ExprListTy;
@@ -971,16 +979,16 @@
   };
   OwningExprResult ParseParenExpression(ParenParseOption &ExprType,
                                         bool stopIfCastExpr,
-                                        TypeTy *TypeOfCast,
-                                        TypeTy *&CastTy,
+                                        ParsedType TypeOfCast,
+                                        ParsedType &CastTy,
                                         SourceLocation &RParenLoc);
 
   OwningExprResult ParseCXXAmbiguousParenExpression(ParenParseOption &ExprType,
-                                                    TypeTy *&CastTy,
+                                                    ParsedType &CastTy,
                                                     SourceLocation LParenLoc,
                                                     SourceLocation &RParenLoc);
 
-  OwningExprResult ParseCompoundLiteralExpression(TypeTy *Ty,
+  OwningExprResult ParseCompoundLiteralExpression(ParsedType Ty,
                                                   SourceLocation LParenLoc,
                                                   SourceLocation RParenLoc);
 
@@ -991,7 +999,7 @@
   OwningExprResult ParseCXXIdExpression(bool isAddressOfOperand = false);
 
   bool ParseOptionalCXXScopeSpecifier(CXXScopeSpec &SS,
-                                      TypeTy *ObjectType,
+                                      ParsedType ObjectType,
                                       bool EnteringContext,
                                       bool *MayBePseudoDestructor = 0);
 
@@ -1008,7 +1016,7 @@
   OwningExprResult ParseCXXPseudoDestructor(ExprArg Base, SourceLocation OpLoc,
                                             tok::TokenKind OpKind,
                                             CXXScopeSpec &SS,
-                                            Action::TypeTy *ObjectType);
+                                            ParsedType ObjectType);
 
   //===--------------------------------------------------------------------===//
   // C++ 9.3.2: C++ 'this' pointer
@@ -1019,8 +1027,8 @@
   OwningExprResult ParseThrowExpression();
   // EndLoc is filled with the location of the last token of the specification.
   bool ParseExceptionSpecification(SourceLocation &EndLoc,
-                                   llvm::SmallVector<TypeTy*, 2> &Exceptions,
-                                   llvm::SmallVector<SourceRange, 2> &Ranges,
+                                   llvm::SmallVectorImpl<ParsedType> &Exns,
+                                   llvm::SmallVectorImpl<SourceRange> &Ranges,
                                    bool &hasAnyExceptionSpec);
 
   //===--------------------------------------------------------------------===//
@@ -1088,11 +1096,11 @@
   OwningExprResult ParseObjCMessageExpression();
   OwningExprResult ParseObjCMessageExpressionBody(SourceLocation LBracloc,
                                                   SourceLocation SuperLoc,
-                                                  TypeTy *ReceiverType,
+                                                  ParsedType ReceiverType,
                                                   ExprArg ReceiverExpr);
   OwningExprResult ParseAssignmentExprWithObjCMessageExprStart(
       SourceLocation LBracloc, SourceLocation SuperLoc,
-      TypeTy *ReceiverType, ExprArg ReceiverExpr);
+      ParsedType ReceiverType, ExprArg ReceiverExpr);
   bool ParseObjCXXMessageReceiver(bool &IsExpr, void *&TypeOrExpr);
 
   //===--------------------------------------------------------------------===//
@@ -1455,17 +1463,17 @@
                                     IdentifierInfo *Name,
                                     SourceLocation NameLoc,
                                     bool EnteringContext,
-                                    TypeTy *ObjectType,
+                                    ParsedType ObjectType,
                                     UnqualifiedId &Id,
                                     bool AssumeTemplateId,
                                     SourceLocation TemplateKWLoc);
   bool ParseUnqualifiedIdOperator(CXXScopeSpec &SS, bool EnteringContext,
-                                  TypeTy *ObjectType,
+                                  ParsedType ObjectType,
                                   UnqualifiedId &Result);
   bool ParseUnqualifiedId(CXXScopeSpec &SS, bool EnteringContext,
                           bool AllowDestructorName,
                           bool AllowConstructorName,
-                          TypeTy *ObjectType,
+                          ParsedType ObjectType,
                           UnqualifiedId &Result);
     
   //===--------------------------------------------------------------------===//

Modified: cfe/trunk/include/clang/Sema/Action.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Action.h?rev=111901&r1=111900&r2=111901&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/Action.h (original)
+++ cfe/trunk/include/clang/Sema/Action.h Tue Aug 24 00:47:05 2010
@@ -26,13 +26,14 @@
 
 namespace clang {
   // Semantic.
-  class DeclSpec;
-  class ObjCDeclSpec;
+  class AttributeList;
   class CXXScopeSpec;
   class Declarator;
-  class AttributeList;
-  class TemplateParameterList;
+  class DeclSpec;
   struct FieldDeclarator;
+  class ObjCDeclSpec;
+  class TemplateParameterList;
+
   // Parse.
   class Scope;
   class Action;
@@ -54,7 +55,7 @@
 /// All of the methods here are optional except getTypeName() and
 /// isCurrentClassName(), which must be specified in order for the
 /// parse to complete accurately.
-class Action : public ActionBase {
+class Action {
   /// \brief The parser's current scope.
   ///
   /// The parser maintains this state here so that is accessible to \c Action 
@@ -75,8 +76,18 @@
 
   // Types - Though these don't actually enforce strong typing, they document
   // what types are required to be identical for the actions.
-  typedef ActionBase::ExprTy ExprTy;
-  typedef ActionBase::StmtTy StmtTy;
+  // Types - Though these don't actually enforce strong typing, they document
+  // what types are required to be identical for the actions.
+  typedef OpaquePtr<DeclGroupRef> DeclGroupPtrTy;
+  typedef OpaquePtr<TemplateName> TemplateTy;
+  typedef OpaquePtr<QualType> TypeTy;
+  typedef Attr AttrTy;
+  typedef CXXBaseSpecifier BaseTy;
+  typedef CXXBaseOrMemberInitializer MemInitTy;
+  typedef Expr ExprTy;
+  typedef Stmt StmtTy;
+  typedef TemplateParameterList TemplateParamsTy;
+  typedef NestedNameSpecifier CXXScopeTy;
 
   /// Expr/Stmt/Type/BaseResult - Provide a unique type to wrap
   /// ExprTy/StmtTy/TypeTy/BaseTy, providing strong typing and
@@ -105,7 +116,7 @@
 
   class FullExprArg {
   public:
-    FullExprArg(ActionBase &actions) : E(0) { }
+    FullExprArg(Action &actions) : E(0) { }
                 
     // FIXME: The const_cast here is ugly. RValue references would make this
     // much nicer (or we could duplicate a bunch of the move semantics
@@ -207,10 +218,10 @@
   /// 
   /// \returns the type referred to by this identifier, or NULL if the type
   /// does not name an identifier.
-  virtual TypeTy *getTypeName(IdentifierInfo &II, SourceLocation NameLoc,
-                              Scope *S, CXXScopeSpec *SS = 0,
-                              bool isClassName = false,
-                              TypeTy *ObjectType = 0) = 0;
+  virtual ParsedType getTypeName(IdentifierInfo &II, SourceLocation NameLoc,
+                                 Scope *S, CXXScopeSpec *SS = 0,
+                                 bool isClassName = false,
+                                 ParsedType ObjectType = ParsedType()) = 0;
 
   /// isTagName() - This method is called *for error recovery purposes only*
   /// to determine if the specified name is a valid tag name ("struct foo").  If
@@ -247,7 +258,7 @@
                                        SourceLocation IILoc,
                                        Scope *S,
                                        CXXScopeSpec *SS,
-                                       TypeTy *&SuggestedType) {
+                                       ParsedType &SuggestedType) {
     return false;
   }
                                        
@@ -293,7 +304,7 @@
                                           CXXScopeSpec &SS,
                                           bool hasTemplateKeyword,
                                           UnqualifiedId &Name,
-                                          TypeTy *ObjectType,
+                                          ParsedType ObjectType,
                                           bool EnteringContext,
                                           TemplateTy &Template,
                                       bool &MemberOfUnknownSpecialization) = 0;
@@ -343,7 +354,7 @@
   virtual bool isNonTypeNestedNameSpecifier(Scope *S, CXXScopeSpec &SS,
                                             SourceLocation IdLoc,
                                             IdentifierInfo &II,
-                                            TypeTy *ObjectType) {
+                                            ParsedType ObjectType) {
     return false;
   }
   
@@ -386,7 +397,7 @@
                                                   SourceLocation IdLoc,
                                                   SourceLocation CCLoc,
                                                   IdentifierInfo &II,
-                                                  TypeTy *ObjectType,
+                                                  ParsedType ObjectType,
                                                   bool EnteringContext) {
     return 0;
   }
@@ -400,7 +411,7 @@
   virtual bool IsInvalidUnlessNestedName(Scope *S,
                                          CXXScopeSpec &SS,
                                          IdentifierInfo &II,
-                                         TypeTy *ObjectType,
+                                         ParsedType ObjectType,
                                          bool EnteringContext) {
     return false;
   }
@@ -415,7 +426,7 @@
   /// CCLoc is the location of the trailing '::'.
   virtual CXXScopeTy *ActOnCXXNestedNameSpecifier(Scope *S,
                                                   const CXXScopeSpec &SS,
-                                                  TypeTy *Type,
+                                                  ParsedType Type,
                                                   SourceRange TypeRange,
                                                   SourceLocation CCLoc) {
     return 0;
@@ -1116,9 +1127,10 @@
   }
 
   virtual OwningExprResult ActOnParenOrParenListExpr(SourceLocation L,
-                                              SourceLocation R,
-                                              MultiExprArg Val,
-                                              TypeTy *TypeOfCast=0) {
+                                                     SourceLocation R,
+                                                     MultiExprArg Val,
+                                                     ParsedType TypeOfCast
+                                                       = ParsedType()) {
     return ExprEmpty();
   }
 
@@ -1194,7 +1206,7 @@
   }
 
   virtual OwningExprResult ActOnCompoundLiteral(SourceLocation LParen,
-                                                TypeTy *Ty,
+                                                ParsedType Ty,
                                                 SourceLocation RParen,
                                                 ExprArg Op) {
     return ExprEmpty();
@@ -1225,12 +1237,12 @@
   }
 
   virtual OwningExprResult ActOnCastExpr(Scope *S, SourceLocation LParenLoc,
-                                         TypeTy *Ty, SourceLocation RParenLoc,
+                                         ParsedType Ty, SourceLocation RParenLoc,
                                          ExprArg Op) {
     return ExprEmpty();
   }
 
-  virtual bool TypeIsVectorType(TypeTy *Ty) {
+  virtual bool TypeIsVectorType(ParsedType Ty) {
     return false;
   }
 
@@ -1275,7 +1287,7 @@
   virtual OwningExprResult ActOnBuiltinOffsetOf(Scope *S,
                                                 SourceLocation BuiltinLoc,
                                                 SourceLocation TypeLoc,
-                                                TypeTy *Arg1,
+                                                ParsedType Arg1,
                                                 OffsetOfComponent *CompPtr,
                                                 unsigned NumComponents,
                                                 SourceLocation RParenLoc) {
@@ -1284,7 +1296,8 @@
 
   // __builtin_types_compatible_p(type1, type2)
   virtual OwningExprResult ActOnTypesCompatibleExpr(SourceLocation BuiltinLoc,
-                                                    TypeTy *arg1, TypeTy *arg2,
+                                                    ParsedType arg1,
+                                                    ParsedType arg2,
                                                     SourceLocation RPLoc) {
     return ExprEmpty();
   }
@@ -1297,7 +1310,7 @@
 
   // __builtin_va_arg(expr, type)
   virtual OwningExprResult ActOnVAArg(SourceLocation BuiltinLoc,
-                                      ExprArg expr, TypeTy *type,
+                                      ExprArg expr, ParsedType type,
                                       SourceLocation RPLoc) {
     return ExprEmpty();
   }
@@ -1354,7 +1367,7 @@
                                         CXXScopeSpec &SS,
                                         SourceLocation IdentLoc,
                                         IdentifierInfo *NamespcName,
-                                        AttributeList *AttrList);
+                                        AttributeList *AttrList) = 0;
 
   /// ActOnNamespaceAliasDef - This is called when a namespace alias definition
   /// is parsed.
@@ -1412,7 +1425,7 @@
                                           UnqualifiedId &Name,
                                           AttributeList *AttrList,
                                           bool IsTypeName,
-                                          SourceLocation TypenameLoc);
+                                          SourceLocation TypenameLoc) = 0;
 
   /// ActOnParamDefaultArgument - Parse default argument for function parameter
   virtual void ActOnParamDefaultArgument(Decl *param,
@@ -1535,10 +1548,10 @@
   /// \brief Parsed a destructor name or pseudo-destructor name. 
   ///
   /// \returns the type being destructed.
-  virtual TypeTy *getDestructorName(SourceLocation TildeLoc,
+  virtual ParsedType getDestructorName(SourceLocation TildeLoc,
                                     IdentifierInfo &II, SourceLocation NameLoc,
                                     Scope *S, CXXScopeSpec &SS,
-                                    TypeTy *ObjectType,
+                                    ParsedType ObjectType,
                                     bool EnteringContext) {
     return getTypeName(II, NameLoc, S, &SS, false, ObjectType);
   }
@@ -1548,7 +1561,7 @@
   virtual OwningExprResult ActOnCXXNamedCast(SourceLocation OpLoc,
                                              tok::TokenKind Kind,
                                              SourceLocation LAngleBracketLoc,
-                                             TypeTy *Ty,
+                                             ParsedType Ty,
                                              SourceLocation RAngleBracketLoc,
                                              SourceLocation LParenLoc,
                                              ExprArg Op,
@@ -1590,7 +1603,7 @@
   /// or class type construction ("ClassType(x,y,z)")
   /// or creation of a value-initialized type ("int()").
   virtual OwningExprResult ActOnCXXTypeConstructExpr(SourceRange TypeRange,
-                                                     TypeTy *TypeRep,
+                                                     ParsedType TypeRep,
                                                      SourceLocation LParenLoc,
                                                      MultiExprArg Exprs,
                                                      SourceLocation *CommaLocs,
@@ -1681,7 +1694,7 @@
   virtual OwningExprResult ActOnUnaryTypeTrait(UnaryTypeTrait OTT,
                                                SourceLocation KWLoc,
                                                SourceLocation LParen,
-                                               TypeTy *Ty,
+                                               ParsedType Ty,
                                                SourceLocation RParen) {
     return ExprEmpty();
   }
@@ -1714,7 +1727,7 @@
                                                         ExprArg Base,
                                                         SourceLocation OpLoc,
                                                         tok::TokenKind OpKind,
-                                                        TypeTy *&ObjectType,
+                                                        ParsedType &ObjectType,
                                                   bool &MayBePseudoDestructor) {
     return ExprEmpty();
   }
@@ -1776,7 +1789,7 @@
   virtual BaseResult ActOnBaseSpecifier(Decl *classdecl,
                                         SourceRange SpecifierRange,
                                         bool Virtual, AccessSpecifier Access,
-                                        TypeTy *basetype,
+                                        ParsedType basetype,
                                         SourceLocation BaseLoc) {
     return BaseResult();
   }
@@ -1813,7 +1826,7 @@
                                             Scope *S,
                                             CXXScopeSpec &SS,
                                             IdentifierInfo *MemberOrBase,
-                                            TypeTy *TemplateTypeTy,
+                                            ParsedType TemplateTypeTy,
                                             SourceLocation IdLoc,
                                             SourceLocation LParenLoc,
                                             ExprTy **Args, unsigned NumArgs,
@@ -1895,7 +1908,7 @@
                                        SourceLocation ParamNameLoc,
                                        unsigned Depth, unsigned Position,
                                        SourceLocation EqualLoc,
-                                       TypeTy *DefaultArg) {
+                                       ParsedType DefaultArg) {
     return 0;
   }
 
@@ -2095,7 +2108,7 @@
                                                 SourceLocation TemplateKWLoc,
                                                 CXXScopeSpec &SS,
                                                 UnqualifiedId &Name,
-                                                TypeTy *ObjectType,
+                                                ParsedType ObjectType,
                                                 bool EnteringContext,
                                                 TemplateTy &Template) {
     return TNK_Non_template;
@@ -2350,7 +2363,7 @@
   virtual TypeResult
   ActOnTypenameType(Scope *S, SourceLocation TypenameLoc, 
                     const CXXScopeSpec &SS, SourceLocation TemplateLoc, 
-                    TypeTy *Ty) {
+                    ParsedType Ty) {
     return TypeResult();
   }
 
@@ -2455,7 +2468,7 @@
     SourceLocation NameLoc;
     // The Type is null if no type was specified, and the DeclSpec is invalid
     // in this case.
-    TypeTy *Type;
+    ParsedType Type;
     ObjCDeclSpec DeclSpec;
 
     /// ArgAttrs - Attribute list for this argument.
@@ -2467,9 +2480,9 @@
     SourceLocation BeginLoc,   // location of the + or -.
     SourceLocation EndLoc,     // location of the ; or {.
     tok::TokenKind MethodType, // tok::minus for instance, tok::plus for class.
-    Decl *ClassDecl,       // class this methods belongs to.
+    Decl *ClassDecl,           // class this methods belongs to.
     ObjCDeclSpec &ReturnQT,    // for return type's in inout etc.
-    TypeTy *ReturnType,        // the method return type.
+    ParsedType ReturnType,     // the method return type.
     Selector Sel,              // a unique name for the method.
     ObjCArgInfo *ArgInfo,      // ArgInfo: Has 'Sel.getNumArgs()' entries.
     DeclaratorChunk::ParamInfo *CParamInfo, unsigned CNumArgs, // c-style args
@@ -2556,7 +2569,7 @@
                                              SourceLocation NameLoc,
                                              bool IsSuper,
                                              bool HasTrailingDot,
-                                             TypeTy *&ReceiverType);
+                                             ParsedType &ReceiverType) = 0;
 
   /// \brief Parsed a message send to 'super'.
   ///
@@ -2584,7 +2597,7 @@
   /// \param RBrac The location of the closing square bracket ']'.
   /// \param Args The message arguments.
   virtual OwningExprResult ActOnClassMessage(Scope *S,
-                                             TypeTy *Receiver,
+                                             ParsedType Receiver,
                                              Selector Sel,
                                              SourceLocation LBracLoc, 
                                              SourceLocation SelectorLoc,
@@ -2643,7 +2656,7 @@
   virtual ExprResult ParseObjCEncodeExpression(SourceLocation AtLoc,
                                                SourceLocation EncLoc,
                                                SourceLocation LParenLoc,
-                                               TypeTy *Ty,
+                                               ParsedType Ty,
                                                SourceLocation RParenLoc) {
     return ExprResult();
   }
@@ -3043,7 +3056,7 @@
   /// \param Receiver The type of the class that is receiving a message.
   /// \param SelIdents The identifiers that describe the selector (thus far).
   /// \param NumSelIdents The number of identifiers in \p SelIdents.
-  virtual void CodeCompleteObjCClassMessage(Scope *S, TypeTy *Receiver,
+  virtual void CodeCompleteObjCClassMessage(Scope *S, ParsedType Receiver,
                                             IdentifierInfo **SelIdents,
                                             unsigned NumSelIdents) { }
   
@@ -3169,7 +3182,7 @@
   /// declaration or definition occurs.
   virtual void CodeCompleteObjCMethodDecl(Scope *S, 
                                           bool IsInstanceMethod,
-                                          TypeTy *ReturnType,
+                                          ParsedType ReturnType,
                                           Decl *IDecl) {
   }
   
@@ -3194,7 +3207,7 @@
   virtual void CodeCompleteObjCMethodDeclSelector(Scope *S, 
                                                   bool IsInstanceMethod,
                                                   bool AtParameterName,
-                                                  TypeTy *ReturnType,
+                                                  ParsedType ReturnType,
                                                   IdentifierInfo **SelIdents,
                                                   unsigned NumSelIdents) { }
   

Modified: cfe/trunk/include/clang/Sema/AttributeList.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/AttributeList.h?rev=111901&r1=111900&r2=111901&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/AttributeList.h (original)
+++ cfe/trunk/include/clang/Sema/AttributeList.h Tue Aug 24 00:47:05 2010
@@ -39,7 +39,7 @@
   SourceLocation ScopeLoc;
   IdentifierInfo *ParmName;
   SourceLocation ParmLoc;
-  ActionBase::ExprTy **Args;
+  Expr **Args;
   unsigned NumArgs;
   AttributeList *Next;
   bool DeclspecAttribute, CXX0XAttribute;
@@ -151,16 +151,16 @@
   unsigned getNumArgs() const { return NumArgs; }
 
   /// getArg - Return the specified argument.
-  ActionBase::ExprTy *getArg(unsigned Arg) const {
+  Expr *getArg(unsigned Arg) const {
     assert(Arg < NumArgs && "Arg access out of range!");
     return Args[Arg];
   }
 
   class arg_iterator {
-    ActionBase::ExprTy** X;
+    Expr** X;
     unsigned Idx;
   public:
-    arg_iterator(ActionBase::ExprTy** x, unsigned idx) : X(x), Idx(idx) {}
+    arg_iterator(Expr** x, unsigned idx) : X(x), Idx(idx) {}
 
     arg_iterator& operator++() {
       ++Idx;
@@ -177,7 +177,7 @@
       return !operator==(I);
     }
 
-    ActionBase::ExprTy* operator*() const {
+    Expr* operator*() const {
       return X[Idx];
     }
 

Modified: cfe/trunk/include/clang/Sema/DeclSpec.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/DeclSpec.h?rev=111901&r1=111900&r2=111901&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/DeclSpec.h (original)
+++ cfe/trunk/include/clang/Sema/DeclSpec.h Tue Aug 24 00:47:05 2010
@@ -21,6 +21,7 @@
 #define LLVM_CLANG_SEMA_DECLSPEC_H
 
 #include "clang/Sema/AttributeList.h"
+#include "clang/Sema/Ownership.h"
 #include "clang/Lex/Token.h"
 #include "clang/Basic/OperatorKinds.h"
 #include "clang/Basic/Specifiers.h"
@@ -61,7 +62,7 @@
   SourceLocation getEndLoc() const { return Range.getEnd(); }
 
   NestedNameSpecifier *getScopeRep() const { return ScopeRep; }
-  void setScopeRep(ActionBase::CXXScopeTy *S) { ScopeRep = S; }
+  void setScopeRep(NestedNameSpecifier *S) { ScopeRep = S; }
 
   /// No scope specifier.
   bool isEmpty() const { return !Range.isValid(); }
@@ -197,10 +198,11 @@
 
   /*SCS*/unsigned StorageClassSpecAsWritten : 3;
 
-  /// TypeRep - This contains action-specific information about a specific TST.
-  /// For example, for a typedef or struct, it might contain the declaration for
-  /// these.
-  void *TypeRep;
+  union {
+    UnionParsedType TypeRep;
+    Decl *DeclRep;
+    Expr *ExprRep;
+  };
 
   // attributes.
   AttributeList *AttrList;
@@ -231,6 +233,17 @@
   void SaveWrittenBuiltinSpecs();
   void SaveStorageSpecifierAsWritten();
 
+  static bool isTypeRep(TST T) {
+    return (T == TST_typename || T == TST_typeofType);
+  }
+  static bool isExprRep(TST T) {
+    return (T == TST_typeofExpr || T == TST_decltype);
+  }
+  static bool isDeclRep(TST T) {
+    return (T == TST_enum || T == TST_struct ||
+            T == TST_union || T == TST_class);
+  }
+
   DeclSpec(const DeclSpec&);       // DO NOT IMPLEMENT
   void operator=(const DeclSpec&); // DO NOT IMPLEMENT
 public:
@@ -254,7 +267,6 @@
       Friend_specified(false),
       Constexpr_specified(false),
       StorageClassSpecAsWritten(SCS_unspecified),
-      TypeRep(0),
       AttrList(0),
       ProtocolQualifiers(0),
       NumProtocolQualifiers(0),
@@ -294,7 +306,18 @@
   bool isTypeAltiVecPixel() const { return TypeAltiVecPixel; }
   bool isTypeAltiVecBool() const { return TypeAltiVecBool; }
   bool isTypeSpecOwned() const { return TypeSpecOwned; }
-  void *getTypeRep() const { return TypeRep; }
+  ParsedType getRepAsType() const {
+    assert(isTypeRep((TST) TypeSpecType) && "DeclSpec does not store a type");
+    return TypeRep;
+  }
+  Decl *getRepAsDecl() const {
+    assert(isDeclRep((TST) TypeSpecType) && "DeclSpec does not store a decl");
+    return DeclRep;
+  }
+  Expr *getRepAsExpr() const {
+    assert(isExprRep((TST) TypeSpecType) && "DeclSpec does not store an expr");
+    return ExprRep;
+  }
   CXXScopeSpec &getTypeSpecScope() { return TypeScope; }
   const CXXScopeSpec &getTypeSpecScope() const { return TypeScope; }
 
@@ -391,13 +414,30 @@
   bool SetTypeSpecSign(TSS S, SourceLocation Loc, const char *&PrevSpec,
                        unsigned &DiagID);
   bool SetTypeSpecType(TST T, SourceLocation Loc, const char *&PrevSpec,
-                       unsigned &DiagID, void *Rep = 0, bool Owned = false);
+                       unsigned &DiagID);
+  bool SetTypeSpecType(TST T, SourceLocation Loc, const char *&PrevSpec,
+                       unsigned &DiagID, ParsedType Rep);
+  bool SetTypeSpecType(TST T, SourceLocation Loc, const char *&PrevSpec,
+                       unsigned &DiagID, Decl *Rep, bool Owned);
+  bool SetTypeSpecType(TST T, SourceLocation Loc, const char *&PrevSpec,
+                       unsigned &DiagID, Expr *Rep);
   bool SetTypeAltiVecVector(bool isAltiVecVector, SourceLocation Loc,
                        const char *&PrevSpec, unsigned &DiagID);
   bool SetTypeAltiVecPixel(bool isAltiVecPixel, SourceLocation Loc,
                        const char *&PrevSpec, unsigned &DiagID);
   bool SetTypeSpecError();
-  void UpdateTypeRep(void *Rep) { TypeRep = Rep; }
+  void UpdateDeclRep(Decl *Rep) {
+    assert(isDeclRep((TST) TypeSpecType));
+    DeclRep = Rep;
+  }
+  void UpdateTypeRep(ParsedType Rep) {
+    assert(isTypeRep((TST) TypeSpecType));
+    TypeRep = Rep;
+  }
+  void UpdateExprRep(Expr *Rep) {
+    assert(isExprRep((TST) TypeSpecType));
+    ExprRep = Rep;
+  }
 
   bool SetTypeQual(TQ T, SourceLocation Loc, const char *&PrevSpec,
                    unsigned &DiagID, const LangOptions &Lang);
@@ -589,15 +629,15 @@
     
     /// \brief When Kind == IK_ConversionFunctionId, the type that the 
     /// conversion function names.
-    ActionBase::TypeTy *ConversionFunctionId;
+    UnionParsedType ConversionFunctionId;
 
     /// \brief When Kind == IK_ConstructorName, the class-name of the type
     /// whose constructor is being referenced.
-    ActionBase::TypeTy *ConstructorName;
+    UnionParsedType ConstructorName;
     
     /// \brief When Kind == IK_DestructorName, the type referred to by the
     /// class-name.
-    ActionBase::TypeTy *DestructorName;
+    UnionParsedType DestructorName;
     
     /// \brief When Kind == IK_TemplateId or IK_ConstructorTemplateId,
     /// the template-id annotation that contains the template name and
@@ -674,7 +714,7 @@
   ///
   /// \param EndLoc the location of the last token that makes up the type name.
   void setConversionFunctionId(SourceLocation OperatorLoc, 
-                               ActionBase::TypeTy *Ty,
+                               ParsedType Ty,
                                SourceLocation EndLoc) {
     Kind = IK_ConversionFunctionId;
     StartLocation = OperatorLoc;
@@ -705,7 +745,7 @@
   /// \param ClassNameLoc the location of the class name.
   ///
   /// \param EndLoc the location of the last token that makes up the type name.
-  void setConstructorName(ActionBase::TypeTy *ClassType, 
+  void setConstructorName(ParsedType ClassType, 
                           SourceLocation ClassNameLoc,
                           SourceLocation EndLoc) {
     Kind = IK_ConstructorName;
@@ -728,7 +768,8 @@
   /// name.
   ///
   /// \param ClassType the name of the class referred to by the destructor name.
-  void setDestructorName(SourceLocation TildeLoc, ActionBase::TypeTy *ClassType,
+  void setDestructorName(SourceLocation TildeLoc,
+                         ParsedType ClassType,
                          SourceLocation EndLoc) {
     Kind = IK_DestructorName;
     StartLocation = TildeLoc;
@@ -831,7 +872,7 @@
   };
 
   struct TypeAndRange {
-    ActionBase::TypeTy *Ty;
+    ParsedType Ty;
     SourceRange Range;
   };
 
@@ -1032,7 +1073,7 @@
                                      unsigned TypeQuals, bool hasExceptionSpec,
                                      SourceLocation ThrowLoc,
                                      bool hasAnyExceptionSpec,
-                                     ActionBase::TypeTy **Exceptions,
+                                     ParsedType *Exceptions,
                                      SourceRange *ExceptionRanges,
                                      unsigned NumExceptions,
                                      SourceLocation LPLoc, SourceLocation RPLoc,
@@ -1116,7 +1157,7 @@
   AttributeList *AttrList;
 
   /// AsmLabel - The asm label, if specified.
-  ActionBase::ExprTy *AsmLabel;
+  Expr *AsmLabel;
 
   /// InlineParams - This is a local array used for the first function decl
   /// chunk to avoid going to the heap for the common case when we have one
@@ -1315,8 +1356,8 @@
     return false;
   }
 
-  void setAsmLabel(ActionBase::ExprTy *E) { AsmLabel = E; }
-  ActionBase::ExprTy *getAsmLabel() const { return AsmLabel; }
+  void setAsmLabel(Expr *E) { AsmLabel = E; }
+  Expr *getAsmLabel() const { return AsmLabel; }
 
   void setExtension(bool Val = true) { Extension = Val; }
   bool getExtension() const { return Extension; }
@@ -1334,7 +1375,7 @@
 /// structure field declarators, which is basically just a bitfield size.
 struct FieldDeclarator {
   Declarator D;
-  ActionBase::ExprTy *BitfieldSize;
+  Expr *BitfieldSize;
   explicit FieldDeclarator(DeclSpec &DS) : D(DS, Declarator::MemberContext) {
     BitfieldSize = 0;
   }

Modified: cfe/trunk/include/clang/Sema/Designator.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Designator.h?rev=111901&r1=111900&r2=111901&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/Designator.h (original)
+++ cfe/trunk/include/clang/Sema/Designator.h Tue Aug 24 00:47:05 2010
@@ -7,8 +7,8 @@
 //
 //===----------------------------------------------------------------------===//
 //
-// This file defines interfaces used to represent Designators in the parser and
-// is the input to Actions module.
+// This file defines interfaces used to represent designators (a la
+// C99 designated initializers) during parsing.
 //
 //===----------------------------------------------------------------------===//
 
@@ -19,7 +19,9 @@
 
 namespace clang {
 
-/// Designator - This class is a discriminated union which holds the various
+/// Designator - A designator in a C99 designated initializer.
+///
+/// This class is a discriminated union which holds the various
 /// different sorts of designators possible.  A Designation is an array of
 /// these.  An example of a designator are things like this:
 ///     [8] .field [47]        // C99 designation: 3 designators
@@ -41,12 +43,12 @@
     unsigned NameLoc;
   };
   struct ArrayDesignatorInfo {
-    ActionBase::ExprTy *Index;
+    Expr *Index;
     unsigned LBracketLoc;
     mutable unsigned  RBracketLoc;
   };
   struct ArrayRangeDesignatorInfo {
-    ActionBase::ExprTy *Start, *End;
+    Expr *Start, *End;
     unsigned LBracketLoc, EllipsisLoc;
     mutable unsigned RBracketLoc;
   };
@@ -79,16 +81,16 @@
     return SourceLocation::getFromRawEncoding(FieldInfo.NameLoc);
   }
 
-  ActionBase::ExprTy *getArrayIndex() const {
+  Expr *getArrayIndex() const {
     assert(isArrayDesignator() && "Invalid accessor");
     return ArrayInfo.Index;
   }
 
-  ActionBase::ExprTy *getArrayRangeStart() const {
+  Expr *getArrayRangeStart() const {
     assert(isArrayRangeDesignator() && "Invalid accessor");
     return ArrayRangeInfo.Start;
   }
-  ActionBase::ExprTy *getArrayRangeEnd() const {
+  Expr *getArrayRangeEnd() const {
     assert(isArrayRangeDesignator() && "Invalid accessor");
     return ArrayRangeInfo.End;
   }
@@ -126,7 +128,7 @@
     return D;
   }
 
-  static Designator getArray(ActionBase::ExprTy *Index,
+  static Designator getArray(Expr *Index,
                              SourceLocation LBracketLoc) {
     Designator D;
     D.Kind = ArrayDesignator;
@@ -136,8 +138,8 @@
     return D;
   }
 
-  static Designator getArrayRange(ActionBase::ExprTy *Start,
-                                  ActionBase::ExprTy *End,
+  static Designator getArrayRange(Expr *Start,
+                                  Expr *End,
                                   SourceLocation LBracketLoc,
                                   SourceLocation EllipsisLoc) {
     Designator D;
@@ -159,35 +161,13 @@
       ArrayRangeInfo.RBracketLoc = RBracketLoc.getRawEncoding();
   }
 
-  /// ClearExprs - Null out any expression references, which prevents them from
-  /// being 'delete'd later.
-  void ClearExprs(Action &Actions) {
-    switch (Kind) {
-    case FieldDesignator: return;
-    case ArrayDesignator:
-      ArrayInfo.Index = 0;
-      return;
-    case ArrayRangeDesignator:
-      ArrayRangeInfo.Start = 0;
-      ArrayRangeInfo.End = 0;
-      return;
-    }
-  }
-
-  /// FreeExprs - Release any unclaimed memory for the expressions in this
-  /// designator.
-  void FreeExprs(Action &Actions) {
-    switch (Kind) {
-    case FieldDesignator: return; // nothing to free.
-    case ArrayDesignator:
-      Actions.DeleteExpr(getArrayIndex());
-      return;
-    case ArrayRangeDesignator:
-      Actions.DeleteExpr(getArrayRangeStart());
-      Actions.DeleteExpr(getArrayRangeEnd());
-      return;
-    }
-  }
+  /// ClearExprs - Null out any expression references, which prevents
+  /// them from being 'delete'd later.
+  void ClearExprs(Action &Actions) {}
+
+  /// FreeExprs - Release any unclaimed memory for the expressions in
+  /// this designator.
+  void FreeExprs(Action &Actions) {}
 };
 
 
@@ -221,17 +201,11 @@
 
   /// ClearExprs - Null out any expression references, which prevents them from
   /// being 'delete'd later.
-  void ClearExprs(Action &Actions) {
-    for (unsigned i = 0, e = Designators.size(); i != e; ++i)
-      Designators[i].ClearExprs(Actions);
-  }
+  void ClearExprs(Action &Actions) {}
 
   /// FreeExprs - Release any unclaimed memory for the expressions in this
   /// designation.
-  void FreeExprs(Action &Actions) {
-    for (unsigned i = 0, e = Designators.size(); i != e; ++i)
-      Designators[i].FreeExprs(Actions);
-  }
+  void FreeExprs(Action &Actions) {}
 };
 
 } // end namespace clang

Modified: cfe/trunk/include/clang/Sema/Ownership.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Ownership.h?rev=111901&r1=111900&r2=111901&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/Ownership.h (original)
+++ cfe/trunk/include/clang/Sema/Ownership.h Tue Aug 24 00:47:05 2010
@@ -22,7 +22,7 @@
 //===----------------------------------------------------------------------===//
 
 namespace clang {
-  class ActionBase;
+  class Action;
   class Attr;
   class CXXBaseOrMemberInitializer;
   class CXXBaseSpecifier;
@@ -30,6 +30,7 @@
   class DeclGroupRef;
   class Expr;
   class NestedNameSpecifier;
+  class QualType;
   class Stmt;
   class TemplateName;
   class TemplateParameterList;
@@ -43,12 +44,12 @@
     void *Ptr;
     explicit OpaquePtr(void *Ptr) : Ptr(Ptr) {}
 
+    typedef llvm::PointerLikeTypeTraits<PtrTy> Traits;
+
   public:
     OpaquePtr() : Ptr(0) {}
 
-    static OpaquePtr make(PtrTy P) {
-      OpaquePtr OP; OP.set(P); return OP;
-    }
+    static OpaquePtr make(PtrTy P) { OpaquePtr OP; OP.set(P); return OP; }
 
     template <typename T> T* getAs() const {
       return get();
@@ -59,11 +60,11 @@
     }
 
     PtrTy get() const {
-      return llvm::PointerLikeTypeTraits<PtrTy>::getFromVoidPointer(Ptr);
+      return Traits::getFromVoidPointer(Ptr);
     }
 
     void set(PtrTy P) {
-      Ptr = llvm::PointerLikeTypeTraits<PtrTy>::getAsVoidPointer(P);
+      Ptr = Traits::getAsVoidPointer(P);
     }
 
     operator bool() const { return Ptr != 0; }
@@ -71,6 +72,25 @@
     void *getAsOpaquePtr() const { return Ptr; }
     static OpaquePtr getFromOpaquePtr(void *P) { return OpaquePtr(P); }
   };
+
+  /// UnionOpaquePtr - A version of OpaquePtr suitable for membership
+  /// in a union.
+  template <class T> struct UnionOpaquePtr {
+    void *Ptr;
+
+    static UnionOpaquePtr make(OpaquePtr<T> P) {
+      UnionOpaquePtr OP = { P.getAsOpaquePtr() };
+      return OP;
+    }
+
+    OpaquePtr<T> get() const { return OpaquePtr<T>::getFromOpaquePtr(Ptr); }
+    operator OpaquePtr<T>() const { return get(); }
+
+    UnionOpaquePtr &operator=(OpaquePtr<T> P) {
+      Ptr = P.getAsOpaquePtr();
+      return *this;
+    }
+  };
 }
 
 namespace llvm {
@@ -178,19 +198,6 @@
 // move_* functions, which help the compiler out with some explicit
 // conversions.
 
-namespace llvm {
-  template<>
-  class PointerLikeTypeTraits<clang::ActionBase*> {
-    typedef clang::ActionBase* PT;
-  public:
-    static inline void *getAsVoidPointer(PT P) { return P; }
-    static inline PT getFromVoidPointer(void *P) {
-      return static_cast<PT>(P);
-    }
-    enum { NumLowBitsAvailable = 2 };
-  };
-}
-
 namespace clang {
   // Basic
   class DiagnosticBuilder;
@@ -203,109 +210,80 @@
     static const bool value = false;
   };
 
-  /// ActionBase - A small part split from Action because of the horrible
-  /// definition order dependencies between Action and the smart pointers.
-  class ActionBase {
+  /// ActionResult - This structure is used while parsing/acting on
+  /// expressions, stmts, etc.  It encapsulates both the object returned by
+  /// 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<class PtrTy,
+           bool CompressInvalid = IsResultPtrLowBitFree<PtrTy>::value>
+  class ActionResult {
+    PtrTy Val;
+    bool Invalid;
+
   public:
-    /// Out-of-line virtual destructor to provide home for this class.
-    virtual ~ActionBase();
+    ActionResult(bool Invalid = false) : Val(PtrTy()), Invalid(Invalid) {}
+    ActionResult(PtrTy val) : Val(val), Invalid(false) {}
+    ActionResult(const DiagnosticBuilder &) : Val(PtrTy()), Invalid(true) {}
+
+    // These two overloads prevent void* -> bool conversions.
+    ActionResult(const void *);
+    ActionResult(volatile void *);
 
-    // Types - Though these don't actually enforce strong typing, they document
-    // what types are required to be identical for the actions.
-    typedef OpaquePtr<DeclGroupRef> DeclGroupPtrTy;
-    typedef OpaquePtr<TemplateName> TemplateTy;
-    typedef Attr AttrTy;
-    typedef CXXBaseSpecifier BaseTy;
-    typedef CXXBaseOrMemberInitializer MemInitTy;
-    typedef Expr ExprTy;
-    typedef Stmt StmtTy;
-    typedef TemplateParameterList TemplateParamsTy;
-    typedef NestedNameSpecifier CXXScopeTy;
-    typedef void TypeTy;  // FIXME: Change TypeTy to use OpaquePtr<N>.
-
-    /// ActionResult - This structure is used while parsing/acting on
-    /// expressions, stmts, etc.  It encapsulates both the object returned by
-    /// 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<class PtrTy,
-             bool CompressInvalid = IsResultPtrLowBitFree<PtrTy>::value>
-    class ActionResult {
-      PtrTy Val;
-      bool Invalid;
-
-    public:
-      ActionResult(bool Invalid = false) : Val(PtrTy()), Invalid(Invalid) {}
-      ActionResult(PtrTy val) : Val(val), Invalid(false) {}
-      ActionResult(const DiagnosticBuilder &) : Val(PtrTy()), Invalid(true) {}
-
-      // These two overloads prevent void* -> bool conversions.
-      ActionResult(const void *);
-      ActionResult(volatile void *);
-
-      PtrTy get() const { return Val; }
-      void set(PtrTy V) { Val = V; }
-      bool isInvalid() const { return Invalid; }
-
-      const ActionResult &operator=(PtrTy RHS) {
-        Val = RHS;
-        Invalid = false;
-        return *this;
-      }
-    };
-
-    // This ActionResult partial specialization places the "invalid"
-    // flag into the low bit of the pointer.
-    template<typename PtrTy>
-    class ActionResult<PtrTy, true> {
-      // A pointer whose low bit is 1 if this result is invalid, 0
-      // otherwise.
-      uintptr_t PtrWithInvalid;
-      typedef llvm::PointerLikeTypeTraits<PtrTy> PtrTraits;
-    public:
-      ActionResult(bool Invalid = false)
-        : PtrWithInvalid(static_cast<uintptr_t>(Invalid)) { }
-
-      ActionResult(PtrTy V) {
-        void *VP = PtrTraits::getAsVoidPointer(V);
-        PtrWithInvalid = reinterpret_cast<uintptr_t>(VP);
-        assert((PtrWithInvalid & 0x01) == 0 && "Badly aligned pointer");
-      }
-
-      // These two overloads prevent void* -> bool conversions.
-      ActionResult(const void *);
-      ActionResult(volatile void *);
-
-      ActionResult(const DiagnosticBuilder &) : PtrWithInvalid(0x01) { }
-
-      PtrTy get() const {
-        void *VP = reinterpret_cast<void *>(PtrWithInvalid & ~0x01);
-        return PtrTraits::getFromVoidPointer(VP);
-      }
-
-      void set(PtrTy V) {
-        void *VP = PtrTraits::getAsVoidPointer(V);
-        PtrWithInvalid = reinterpret_cast<uintptr_t>(VP);
-        assert((PtrWithInvalid & 0x01) == 0 && "Badly aligned pointer");
-      }
-
-      bool isInvalid() const { return PtrWithInvalid & 0x01; }
-
-      const ActionResult &operator=(PtrTy RHS) {
-        void *VP = PtrTraits::getAsVoidPointer(RHS);
-        PtrWithInvalid = reinterpret_cast<uintptr_t>(VP);
-        assert((PtrWithInvalid & 0x01) == 0 && "Badly aligned pointer");
-        return *this;
-      }
-    };
-
-    /// Deletion callbacks - Since the parser doesn't know the concrete types of
-    /// the AST nodes being generated, it must do callbacks to delete objects
-    /// when recovering from errors. These are in ActionBase because the smart
-    /// pointers need access to them.
-    virtual void DeleteExpr(ExprTy *E) {}
-    virtual void DeleteStmt(StmtTy *S) {}
-    virtual void DeleteTemplateParams(TemplateParamsTy *P) {}
+    PtrTy get() const { return Val; }
+    void set(PtrTy V) { Val = V; }
+    bool isInvalid() const { return Invalid; }
+
+    const ActionResult &operator=(PtrTy RHS) {
+      Val = RHS;
+      Invalid = false;
+      return *this;
+    }
+  };
+
+  // This ActionResult partial specialization places the "invalid"
+  // flag into the low bit of the pointer.
+  template<typename PtrTy>
+  class ActionResult<PtrTy, true> {
+    // A pointer whose low bit is 1 if this result is invalid, 0
+    // otherwise.
+    uintptr_t PtrWithInvalid;
+    typedef llvm::PointerLikeTypeTraits<PtrTy> PtrTraits;
+  public:
+    ActionResult(bool Invalid = false)
+      : PtrWithInvalid(static_cast<uintptr_t>(Invalid)) { }
+
+    ActionResult(PtrTy V) {
+      void *VP = PtrTraits::getAsVoidPointer(V);
+      PtrWithInvalid = reinterpret_cast<uintptr_t>(VP);
+      assert((PtrWithInvalid & 0x01) == 0 && "Badly aligned pointer");
+    }
+
+    // These two overloads prevent void* -> bool conversions.
+    ActionResult(const void *);
+    ActionResult(volatile void *);
+
+    ActionResult(const DiagnosticBuilder &) : PtrWithInvalid(0x01) { }
+
+    PtrTy get() const {
+      void *VP = reinterpret_cast<void *>(PtrWithInvalid & ~0x01);
+      return PtrTraits::getFromVoidPointer(VP);
+    }
+
+    void set(PtrTy V) {
+      void *VP = PtrTraits::getAsVoidPointer(V);
+      PtrWithInvalid = reinterpret_cast<uintptr_t>(VP);
+      assert((PtrWithInvalid & 0x01) == 0 && "Badly aligned pointer");
+    }
+
+    bool isInvalid() const { return PtrWithInvalid & 0x01; }
+
+    const ActionResult &operator=(PtrTy RHS) {
+      void *VP = PtrTraits::getAsVoidPointer(RHS);
+      PtrWithInvalid = reinterpret_cast<uintptr_t>(VP);
+      assert((PtrWithInvalid & 0x01) == 0 && "Badly aligned pointer");
+      return *this;
+    }
   };
 
   /// ASTOwningResult - A moveable smart pointer for AST nodes that also
@@ -318,7 +296,7 @@
 
   template <class PtrTy> class ASTOwningResult {
   public:
-    typedef ActionBase::ActionResult<PtrTy> DumbResult;
+    typedef ActionResult<PtrTy> DumbResult;
 
   private:
     DumbResult Result;
@@ -377,8 +355,8 @@
 
   public:
     // Normal copying implicitly defined
-    explicit ASTMultiPtr(ActionBase &) : Nodes(0), Count(0) {}
-    ASTMultiPtr(ActionBase &, PtrTy *nodes, unsigned count)
+    explicit ASTMultiPtr(Action &) : Nodes(0), Count(0) {}
+    ASTMultiPtr(Action &, PtrTy *nodes, unsigned count)
       : Nodes(nodes), Count(count) {}
     // Fake mover in Parse/AstGuard.h needs this:
     ASTMultiPtr(PtrTy *nodes, unsigned count) : Nodes(nodes), Count(count) {}
@@ -401,7 +379,7 @@
     mutable unsigned Count;
 
   public:
-    ASTTemplateArgsPtr(ActionBase &actions, ParsedTemplateArgument *args,
+    ASTTemplateArgsPtr(Action &actions, ParsedTemplateArgument *args,
                        unsigned count) :
       Args(args), Count(count) { }
 
@@ -439,7 +417,7 @@
     ASTOwningVector &operator=(ASTOwningVector &); // do not implement
 
   public:
-    explicit ASTOwningVector(ActionBase &Actions)
+    explicit ASTOwningVector(Action &Actions)
     { }
 
     PtrTy *take() {
@@ -487,13 +465,18 @@
     static const bool value = true;
   };
 
-  typedef ActionBase::ActionResult<Expr*> ExprResult;
-  typedef ActionBase::ActionResult<Stmt*> StmtResult;
-  typedef ActionBase::ActionResult<void*> TypeResult;
-  typedef ActionBase::ActionResult<CXXBaseSpecifier*> BaseResult;
-  typedef ActionBase::ActionResult<CXXBaseOrMemberInitializer*> MemInitResult;
+  /// An opaque type for threading parsed type information through the
+  /// parser.
+  typedef OpaquePtr<QualType> ParsedType;
+  typedef UnionOpaquePtr<QualType> UnionParsedType;
+
+  typedef ActionResult<Expr*> ExprResult;
+  typedef ActionResult<Stmt*> StmtResult;
+  typedef ActionResult<ParsedType> TypeResult;
+  typedef ActionResult<CXXBaseSpecifier*> BaseResult;
+  typedef ActionResult<CXXBaseOrMemberInitializer*> MemInitResult;
 
-  typedef ActionBase::ActionResult<Decl*> DeclResult;
+  typedef ActionResult<Decl*> DeclResult;
   typedef OpaquePtr<TemplateName> ParsedTemplateTy;
 
   typedef ASTOwningResult<Expr*> OwningExprResult;

Modified: cfe/trunk/include/clang/Sema/ParsedTemplate.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/ParsedTemplate.h?rev=111901&r1=111900&r2=111901&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/ParsedTemplate.h (original)
+++ cfe/trunk/include/clang/Sema/ParsedTemplate.h Tue Aug 24 00:47:05 2010
@@ -52,7 +52,7 @@
     ///
     /// \param TemplateLoc the location of the template name.
     ParsedTemplateArgument(const CXXScopeSpec &SS,
-                           ActionBase::TemplateTy Template, 
+                           ParsedTemplateTy Template, 
                            SourceLocation TemplateLoc) 
       : Kind(ParsedTemplateArgument::Template),
         Arg(Template.getAsOpaquePtr()), 
@@ -65,9 +65,9 @@
     KindType getKind() const { return Kind; }
     
     /// \brief Retrieve the template type argument's type.
-    ActionBase::TypeTy *getAsType() const {
+    ParsedType getAsType() const {
       assert(Kind == Type && "Not a template type argument");
-      return Arg;
+      return ParsedType::getFromOpaquePtr(Arg);
     }
     
     /// \brief Retrieve the non-type template argument's expression.
@@ -77,9 +77,9 @@
     }
     
     /// \brief Retrieve the template template argument's template name.
-    ActionBase::TemplateTy getAsTemplate() const {
+    ParsedTemplateTy getAsTemplate() const {
       assert(Kind == Template && "Not a template template argument");
-      return ActionBase::TemplateTy::getFromOpaquePtr(Arg);
+      return ParsedTemplateTy::getFromOpaquePtr(Arg);
     }
     
     /// \brief Retrieve the location of the template argument.

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=111901&r1=111900&r2=111901&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Tue Aug 24 00:47:05 2010
@@ -791,11 +791,11 @@
                                        TagDecl **OwnedDecl = 0);
   TypeSourceInfo *GetTypeSourceInfoForDeclarator(Declarator &D, QualType T,
                                                TypeSourceInfo *ReturnTypeInfo);
-  /// \brief Create a LocInfoType to hold the given QualType and TypeSourceInfo.
-  QualType CreateLocInfoType(QualType T, TypeSourceInfo *TInfo);
+  /// \brief Package the given type and TSI into a ParsedType.
+  ParsedType CreateParsedType(QualType T, TypeSourceInfo *TInfo);
   DeclarationNameInfo GetNameForDeclarator(Declarator &D);
   DeclarationNameInfo GetNameFromUnqualifiedId(const UnqualifiedId &Name);
-  static QualType GetTypeFromParser(TypeTy *Ty, TypeSourceInfo **TInfo = 0);
+  static QualType GetTypeFromParser(ParsedType Ty, TypeSourceInfo **TInfo = 0);
   bool CheckSpecifiedExceptionType(QualType T, const SourceRange &Range);
   bool CheckDistantExceptionSpec(QualType T);
   bool CheckEquivalentExceptionSpec(FunctionDecl *Old, FunctionDecl *New);
@@ -844,24 +844,24 @@
 
   void DiagnoseUseOfUnimplementedSelectors();
 
-  virtual TypeTy *getTypeName(IdentifierInfo &II, SourceLocation NameLoc,
-                              Scope *S, CXXScopeSpec *SS = 0,
-                              bool isClassName = false,
-                              TypeTy *ObjectType = 0);
+  virtual ParsedType getTypeName(IdentifierInfo &II, SourceLocation NameLoc,
+                                 Scope *S, CXXScopeSpec *SS = 0,
+                                 bool isClassName = false,
+                                 ParsedType ObjectType = ParsedType());
   virtual DeclSpec::TST isTagName(IdentifierInfo &II, Scope *S);
   virtual bool DiagnoseUnknownTypeName(const IdentifierInfo &II,
                                        SourceLocation IILoc,
                                        Scope *S,
                                        CXXScopeSpec *SS,
-                                       TypeTy *&SuggestedType);
+                                       ParsedType &SuggestedType);
 
   virtual Decl *ActOnDeclarator(Scope *S, Declarator &D) {
     return HandleDeclarator(S, D, MultiTemplateParamsArg(*this), false);
   }
 
   Decl *HandleDeclarator(Scope *S, Declarator &D,
-                             MultiTemplateParamsArg TemplateParameterLists,
-                             bool IsFunctionDefinition);
+                         MultiTemplateParamsArg TemplateParameterLists,
+                         bool IsFunctionDefinition);
   void RegisterLocallyScopedExternCDecl(NamedDecl *ND,
                                         const LookupResult &Previous,
                                         Scope *S);
@@ -1985,9 +1985,10 @@
   virtual OwningExprResult ActOnParenExpr(SourceLocation L, SourceLocation R,
                                           ExprArg Val);
   virtual OwningExprResult ActOnParenOrParenListExpr(SourceLocation L,
-                                              SourceLocation R,
-                                              MultiExprArg Val,
-                                              TypeTy *TypeOfCast=0);
+                                                     SourceLocation R,
+                                                     MultiExprArg Val,
+                                                     ParsedType TypeOfCast
+                                                       = ParsedType());
 
   /// ActOnStringLiteral - The specified tokens were lexed as pasted string
   /// fragments (e.g. "foo" "bar" L"baz").
@@ -2096,14 +2097,14 @@
                                          SourceLocation RParenLoc);
 
   virtual OwningExprResult ActOnCastExpr(Scope *S, SourceLocation LParenLoc,
-                                         TypeTy *Ty, SourceLocation RParenLoc,
+                                         ParsedType Ty, SourceLocation RParenLoc,
                                          ExprArg Op);
   OwningExprResult BuildCStyleCastExpr(SourceLocation LParenLoc,
                                        TypeSourceInfo *Ty,
                                        SourceLocation RParenLoc,
                                        ExprArg Op);
 
-  virtual bool TypeIsVectorType(TypeTy *Ty) {
+  virtual bool TypeIsVectorType(ParsedType Ty) {
     return GetTypeFromParser(Ty)->isVectorType();
   }
 
@@ -2113,7 +2114,7 @@
                                             TypeSourceInfo *TInfo);
 
   virtual OwningExprResult ActOnCompoundLiteral(SourceLocation LParenLoc,
-                                                TypeTy *Ty,
+                                                ParsedType Ty,
                                                 SourceLocation RParenLoc,
                                                 ExprArg Op);
 
@@ -2164,14 +2165,15 @@
   virtual OwningExprResult ActOnBuiltinOffsetOf(Scope *S,
                                                 SourceLocation BuiltinLoc,
                                                 SourceLocation TypeLoc,
-                                                TypeTy *Arg1,
+                                                ParsedType Arg1,
                                                 OffsetOfComponent *CompPtr,
                                                 unsigned NumComponents,
                                                 SourceLocation RParenLoc);
 
   // __builtin_types_compatible_p(type1, type2)
   virtual OwningExprResult ActOnTypesCompatibleExpr(SourceLocation BuiltinLoc,
-                                                    TypeTy *arg1, TypeTy *arg2,
+                                                    ParsedType arg1,
+                                                    ParsedType arg2,
                                                     SourceLocation RPLoc);
   OwningExprResult BuildTypesCompatibleExpr(SourceLocation BuiltinLoc,
                                             TypeSourceInfo *argTInfo1,
@@ -2185,7 +2187,7 @@
 
   // __builtin_va_arg(expr, type)
   virtual OwningExprResult ActOnVAArg(SourceLocation BuiltinLoc,
-                                      ExprArg expr, TypeTy *type,
+                                      ExprArg expr, ParsedType type,
                                       SourceLocation RPLoc);
   OwningExprResult BuildVAArgExpr(SourceLocation BuiltinLoc,
                                   ExprArg expr, TypeSourceInfo *TInfo,
@@ -2401,17 +2403,17 @@
                                SourceLocation Loc,
                                ASTOwningVector<Expr*> &ConvertedArgs);
 
-  virtual TypeTy *getDestructorName(SourceLocation TildeLoc,
-                                    IdentifierInfo &II, SourceLocation NameLoc,
-                                    Scope *S, CXXScopeSpec &SS,
-                                    TypeTy *ObjectType,
-                                    bool EnteringContext);
+  virtual ParsedType getDestructorName(SourceLocation TildeLoc,
+                                       IdentifierInfo &II, SourceLocation NameLoc,
+                                       Scope *S, CXXScopeSpec &SS,
+                                       ParsedType ObjectType,
+                                       bool EnteringContext);
 
   /// ActOnCXXNamedCast - Parse {dynamic,static,reinterpret,const}_cast's.
   virtual OwningExprResult ActOnCXXNamedCast(SourceLocation OpLoc,
                                              tok::TokenKind Kind,
                                              SourceLocation LAngleBracketLoc,
-                                             TypeTy *Ty,
+                                             ParsedType Ty,
                                              SourceLocation RAngleBracketLoc,
                                              SourceLocation LParenLoc,
                                              ExprArg E,
@@ -2459,7 +2461,7 @@
   /// or class type construction ("ClassType(x,y,z)")
   /// or creation of a value-initialized type ("int()").
   virtual OwningExprResult ActOnCXXTypeConstructExpr(SourceRange TypeRange,
-                                                     TypeTy *TypeRep,
+                                                     ParsedType TypeRep,
                                                      SourceLocation LParenLoc,
                                                      MultiExprArg Exprs,
                                                      SourceLocation *CommaLocs,
@@ -2522,14 +2524,14 @@
   virtual OwningExprResult ActOnUnaryTypeTrait(UnaryTypeTrait OTT,
                                                SourceLocation KWLoc,
                                                SourceLocation LParen,
-                                               TypeTy *Ty,
+                                               ParsedType Ty,
                                                SourceLocation RParen);
 
   virtual OwningExprResult ActOnStartCXXMemberReference(Scope *S,
                                                         ExprArg Base,
                                                         SourceLocation OpLoc,
                                                         tok::TokenKind OpKind,
-                                                        TypeTy *&ObjectType,
+                                                        ParsedType &ObjectType,
                                                    bool &MayBePseudoDestructor);
 
   OwningExprResult DiagnoseDtorReference(SourceLocation NameLoc,
@@ -2585,7 +2587,7 @@
   virtual bool isNonTypeNestedNameSpecifier(Scope *S, CXXScopeSpec &SS,
                                             SourceLocation IdLoc,
                                             IdentifierInfo &II,
-                                            TypeTy *ObjectType);
+                                            ParsedType ObjectType);
 
   CXXScopeTy *BuildCXXNestedNameSpecifier(Scope *S,
                                           CXXScopeSpec &SS,
@@ -2602,13 +2604,13 @@
                                                   SourceLocation IdLoc,
                                                   SourceLocation CCLoc,
                                                   IdentifierInfo &II,
-                                                  TypeTy *ObjectType,
+                                                  ParsedType ObjectType,
                                                   bool EnteringContext);
 
   virtual bool IsInvalidUnlessNestedName(Scope *S,
                                          CXXScopeSpec &SS,
                                          IdentifierInfo &II,
-                                         TypeTy *ObjectType,
+                                         ParsedType ObjectType,
                                          bool EnteringContext);
 
   /// ActOnCXXNestedNameSpecifier - Called during parsing of a
@@ -2621,7 +2623,7 @@
   /// CCLoc is the location of the trailing '::'.
   virtual CXXScopeTy *ActOnCXXNestedNameSpecifier(Scope *S,
                                                   const CXXScopeSpec &SS,
-                                                  TypeTy *Type,
+                                                  ParsedType Type,
                                                   SourceRange TypeRange,
                                                   SourceLocation CCLoc);
 
@@ -2668,7 +2670,7 @@
   virtual ExprResult ParseObjCEncodeExpression(SourceLocation AtLoc,
                                                SourceLocation EncodeLoc,
                                                SourceLocation LParenLoc,
-                                               TypeTy *Ty,
+                                               ParsedType Ty,
                                                SourceLocation RParenLoc);
 
   // ParseObjCSelectorExpression - Build selector expression for @selector
@@ -2719,7 +2721,7 @@
                                             Scope *S,
                                             CXXScopeSpec &SS,
                                             IdentifierInfo *MemberOrBase,
-                                            TypeTy *TemplateTypeTy,
+                                            ParsedType TemplateTypeTy,
                                             SourceLocation IdLoc,
                                             SourceLocation LParenLoc,
                                             ExprTy **Args, unsigned NumArgs,
@@ -2850,7 +2852,7 @@
   virtual BaseResult ActOnBaseSpecifier(Decl *classdecl,
                                         SourceRange SpecifierRange,
                                         bool Virtual, AccessSpecifier Access,
-                                        TypeTy *basetype, SourceLocation
+                                        ParsedType basetype, SourceLocation
                                         BaseLoc);
 
   bool AttachBaseSpecifiers(CXXRecordDecl *Class, CXXBaseSpecifier **Bases,
@@ -2992,7 +2994,7 @@
                                           CXXScopeSpec &SS,
                                           bool hasTemplateKeyword,
                                           UnqualifiedId &Name,
-                                          TypeTy *ObjectType,
+                                          ParsedType ObjectType,
                                           bool EnteringContext,
                                           TemplateTy &Template,
                                           bool &MemberOfUnknownSpecialization);
@@ -3014,7 +3016,7 @@
                                        SourceLocation ParamNameLoc,
                                        unsigned Depth, unsigned Position,
                                        SourceLocation EqualLoc,
-                                       TypeTy *DefaultArg);
+                                       ParsedType DefaultArg);
 
   QualType CheckNonTypeTemplateParameterType(QualType T, SourceLocation Loc);
   virtual Decl *ActOnNonTypeTemplateParameter(Scope *S, Declarator &D,
@@ -3098,7 +3100,7 @@
                                                   SourceLocation TemplateKWLoc,
                                                       CXXScopeSpec &SS,
                                                       UnqualifiedId &Name,
-                                                      TypeTy *ObjectType,
+                                                      ParsedType ObjectType,
                                                       bool EnteringContext,
                                                       TemplateTy &Template);
 
@@ -3302,7 +3304,7 @@
   virtual TypeResult
   ActOnTypenameType(Scope *S, SourceLocation TypenameLoc, 
                     const CXXScopeSpec &SS, SourceLocation TemplateLoc, 
-                    TypeTy *Ty);
+                    ParsedType Ty);
 
   QualType CheckTypenameType(ElaboratedTypeKeyword Keyword,
                              NestedNameSpecifier *NNS,
@@ -3316,6 +3318,8 @@
                                                     DeclarationName Name);
   bool RebuildNestedNameSpecifierInCurrentInstantiation(CXXScopeSpec &SS);
 
+  OwningExprResult RebuildExprInCurrentInstantiation(Expr *E);
+
   std::string
   getTemplateArgumentBindingsText(const TemplateParameterList *Params,
                                   const TemplateArgumentList &Args);
@@ -4135,7 +4139,7 @@
     SourceLocation BeginLoc, // location of the + or -.
     SourceLocation EndLoc,   // location of the ; or {.
     tok::TokenKind MethodType,
-    Decl *ClassDecl, ObjCDeclSpec &ReturnQT, TypeTy *ReturnType,
+    Decl *ClassDecl, ObjCDeclSpec &ReturnQT, ParsedType ReturnType,
     Selector Sel,
     // optional arguments. The number of types/arguments is obtained
     // from the Sel.getNumArgs().
@@ -4170,7 +4174,7 @@
                                              SourceLocation NameLoc,
                                              bool IsSuper,
                                              bool HasTrailingDot,
-                                             TypeTy *&ReceiverType);
+                                             ParsedType &ReceiverType);
 
   virtual OwningExprResult ActOnSuperMessage(Scope *S, SourceLocation SuperLoc,
                                              Selector Sel,
@@ -4189,7 +4193,7 @@
                                      MultiExprArg Args);
 
   virtual OwningExprResult ActOnClassMessage(Scope *S,
-                                             TypeTy *Receiver,
+                                             ParsedType Receiver,
                                              Selector Sel,
                                              SourceLocation LBracLoc,
                                              SourceLocation SelectorLoc,
@@ -4684,7 +4688,7 @@
   virtual void CodeCompleteObjCSuperMessage(Scope *S, SourceLocation SuperLoc,
                                             IdentifierInfo **SelIdents,
                                             unsigned NumSelIdents);
-  virtual void CodeCompleteObjCClassMessage(Scope *S, TypeTy *Receiver,
+  virtual void CodeCompleteObjCClassMessage(Scope *S, ParsedType Receiver,
                                             IdentifierInfo **SelIdents,
                                             unsigned NumSelIdents);
   virtual void CodeCompleteObjCInstanceMessage(Scope *S, ExprTy *Receiver,
@@ -4713,12 +4717,12 @@
                                                       Decl *ObjCImpDecl);
   virtual void CodeCompleteObjCMethodDecl(Scope *S,
                                           bool IsInstanceMethod,
-                                          TypeTy *ReturnType,
+                                          ParsedType ReturnType,
                                           Decl *IDecl);
   virtual void CodeCompleteObjCMethodDeclSelector(Scope *S, 
                                                   bool IsInstanceMethod,
                                                   bool AtParameterName,
-                                                  TypeTy *ReturnType,
+                                                  ParsedType ReturnType,
                                                   IdentifierInfo **SelIdents,
                                                   unsigned NumSelIdents);
   void GatherGlobalCodeCompletions(

Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=111901&r1=111900&r2=111901&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Tue Aug 24 00:47:05 2010
@@ -773,7 +773,7 @@
 
   // This is almost certainly an invalid type name. Let the action emit a 
   // diagnostic and attempt to recover.
-  Action::TypeTy *T = 0;
+  ParsedType T;
   if (Actions.DiagnoseUnknownTypeName(*Tok.getIdentifierInfo(), Loc,
                                       getCurScope(), SS, T)) {
     // The action emitted a diagnostic, so we don't have to.
@@ -783,8 +783,7 @@
       // name token, and we're done.
       const char *PrevSpec;
       unsigned DiagID;
-      DS.SetTypeSpecType(DeclSpec::TST_typename, Loc, PrevSpec, DiagID, T, 
-                         false);
+      DS.SetTypeSpecType(DeclSpec::TST_typename, Loc, PrevSpec, DiagID, T);
       DS.SetRangeEnd(Tok.getLocation());
       ConsumeToken();
       
@@ -981,10 +980,11 @@
       if (Next.is(tok::annot_typename)) {
         DS.getTypeSpecScope() = SS;
         ConsumeToken(); // The C++ scope.
-        if (Tok.getAnnotationValue())
+        if (Tok.getAnnotationValue()) {
+          ParsedType T = getTypeAnnotation(Tok);
           isInvalid = DS.SetTypeSpecType(DeclSpec::TST_typename, Loc, 
-                                         PrevSpec, DiagID, 
-                                         Tok.getAnnotationValue());
+                                         PrevSpec, DiagID, T);
+        }
         else
           DS.SetTypeSpecError();
         DS.SetRangeEnd(Tok.getAnnotationEndLoc());
@@ -1013,8 +1013,9 @@
           << Next.getIdentifierInfo();
       }
 
-      TypeTy *TypeRep = Actions.getTypeName(*Next.getIdentifierInfo(),
-                                            Next.getLocation(), getCurScope(), &SS);
+      ParsedType TypeRep = Actions.getTypeName(*Next.getIdentifierInfo(),
+                                               Next.getLocation(),
+                                               getCurScope(), &SS);
 
       // If the referenced identifier is not a type, then this declspec is
       // erroneous: We already checked about that it has no type specifier, and
@@ -1041,10 +1042,11 @@
     }
 
     case tok::annot_typename: {
-      if (Tok.getAnnotationValue())
+      if (Tok.getAnnotationValue()) {
+        ParsedType T = getTypeAnnotation(Tok);
         isInvalid = DS.SetTypeSpecType(DeclSpec::TST_typename, Loc, PrevSpec,
-                                       DiagID, Tok.getAnnotationValue());
-      else
+                                       DiagID, T);
+      } else
         DS.SetTypeSpecError();
       
       if (isInvalid)
@@ -1097,12 +1099,13 @@
         break;
 
       // It has to be available as a typedef too!
-      TypeTy *TypeRep = Actions.getTypeName(*Tok.getIdentifierInfo(),
-                                            Tok.getLocation(), getCurScope());
+      ParsedType TypeRep =
+        Actions.getTypeName(*Tok.getIdentifierInfo(),
+                            Tok.getLocation(), getCurScope());
 
       // If this is not a typedef name, don't parse it as part of the declspec,
       // it must be an implicit int or an error.
-      if (TypeRep == 0) {
+      if (!TypeRep) {
         if (ParseImplicitInt(DS, 0, TemplateInfo, AS)) continue;
         goto DoneWithDeclSpec;
       }
@@ -1520,10 +1523,10 @@
 
   // simple-type-specifier:
   case tok::annot_typename: {
-    if (Tok.getAnnotationValue())
+    if (ParsedType T = getTypeAnnotation(Tok)) {
       isInvalid = DS.SetTypeSpecType(DeclSpec::TST_typename, Loc, PrevSpec,
-                                     DiagID, Tok.getAnnotationValue());
-    else
+                                     DiagID, T);
+    } else
       DS.SetTypeSpecError();
     DS.SetRangeEnd(Tok.getAnnotationEndLoc());
     ConsumeToken(); // The typename
@@ -1930,7 +1933,7 @@
 
   CXXScopeSpec &SS = DS.getTypeSpecScope();
   if (getLang().CPlusPlus) {
-    if (ParseOptionalCXXScopeSpecifier(SS, 0, false))
+    if (ParseOptionalCXXScopeSpecifier(SS, ParsedType(), false))
       return;
 
     if (SS.isSet() && Tok.isNot(tok::identifier)) {
@@ -2016,7 +2019,7 @@
     }
     
     if (DS.SetTypeSpecType(DeclSpec::TST_typename, TSTLoc, PrevSpec, DiagID,
-                           Type.get(), false))
+                           Type.get()))
       Diag(StartLoc, DiagID) << PrevSpec;
     
     return;
@@ -2037,8 +2040,8 @@
   if (Tok.is(tok::l_brace))
     ParseEnumBody(StartLoc, TagDecl);
 
-  // FIXME: The DeclSpec should keep the locations of both the keyword and the
-  // name (if there is one).
+  // FIXME: The DeclSpec should keep the locations of both the keyword
+  // and the name (if there is one).
   if (DS.SetTypeSpecType(DeclSpec::TST_enum, TSTLoc, PrevSpec, DiagID,
                          TagDecl, Owned))
     Diag(StartLoc, DiagID) << PrevSpec;
@@ -2371,7 +2374,7 @@
 
   // Parse the C++ scope specifier.
   CXXScopeSpec SS;
-  if (ParseOptionalCXXScopeSpecifier(SS, 0, true)) {
+  if (ParseOptionalCXXScopeSpecifier(SS, ParsedType(), true)) {
     TPA.Revert();
     return false;
   }
@@ -2527,7 +2530,7 @@
       (Tok.is(tok::coloncolon) || Tok.is(tok::identifier) ||
        Tok.is(tok::annot_cxxscope))) {
     CXXScopeSpec SS;
-    ParseOptionalCXXScopeSpecifier(SS, /*ObjectType=*/0, true); // ignore fail
+    ParseOptionalCXXScopeSpecifier(SS, ParsedType(), true); // ignore fail
 
     if (SS.isNotEmpty()) {
       if (Tok.isNot(tok::star)) {
@@ -2686,8 +2689,7 @@
   if (getLang().CPlusPlus && D.mayHaveIdentifier()) {
     // ParseDeclaratorInternal might already have parsed the scope.
     if (D.getCXXScopeSpec().isEmpty()) {
-      ParseOptionalCXXScopeSpecifier(D.getCXXScopeSpec(), /*ObjectType=*/0,
-                                     true);
+      ParseOptionalCXXScopeSpecifier(D.getCXXScopeSpec(), ParsedType(), true);
     }
 
     if (D.getCXXScopeSpec().isValid()) {
@@ -2716,7 +2718,7 @@
                              /*EnteringContext=*/true, 
                              /*AllowDestructorName=*/true, 
                              AllowConstructorName,
-                             /*ObjectType=*/0,
+                             ParsedType(),
                              D.getName()) ||
           // Once we're past the identifier, if the scope was bad, mark the
           // whole declarator bad.
@@ -2951,7 +2953,7 @@
     bool hasExceptionSpec = false;
     SourceLocation ThrowLoc;
     bool hasAnyExceptionSpec = false;
-    llvm::SmallVector<TypeTy*, 2> Exceptions;
+    llvm::SmallVector<ParsedType, 2> Exceptions;
     llvm::SmallVector<SourceRange, 2> ExceptionRanges;
     if (getLang().CPlusPlus) {
       ParseTypeQualifierListOpt(DS, false /*no attributes*/);
@@ -3178,7 +3180,7 @@
   bool hasExceptionSpec = false;
   SourceLocation ThrowLoc;
   bool hasAnyExceptionSpec = false;
-  llvm::SmallVector<TypeTy*, 2> Exceptions;
+  llvm::SmallVector<ParsedType, 2> Exceptions;
   llvm::SmallVector<SourceRange, 2> ExceptionRanges;
   
   if (getLang().CPlusPlus) {
@@ -3418,7 +3420,7 @@
   const bool hasParens = Tok.is(tok::l_paren);
 
   bool isCastExpr;
-  TypeTy *CastTy;
+  ParsedType CastTy;
   SourceRange CastRange;
   OwningExprResult Operand = ParseExprAfterTypeofSizeofAlignof(OpTok,
                                                                isCastExpr,
@@ -3458,7 +3460,7 @@
   unsigned DiagID;
   // Check for duplicate type specifiers (e.g. "int typeof(int)").
   if (DS.SetTypeSpecType(DeclSpec::TST_typeofExpr, StartLoc, PrevSpec,
-                         DiagID, Operand.release()))
+                         DiagID, Operand.get()))
     Diag(StartLoc, DiagID) << PrevSpec;
 }
 

Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDeclCXX.cpp?rev=111901&r1=111900&r2=111901&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDeclCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp Tue Aug 24 00:47:05 2010
@@ -141,7 +141,7 @@
 
   CXXScopeSpec SS;
   // Parse (optional) nested-name-specifier.
-  ParseOptionalCXXScopeSpecifier(SS, /*ObjectType=*/0, false);
+  ParseOptionalCXXScopeSpecifier(SS, ParsedType(), false);
 
   if (SS.isInvalid() || Tok.isNot(tok::identifier)) {
     Diag(Tok, diag::err_expected_namespace_name);
@@ -274,7 +274,7 @@
 
   CXXScopeSpec SS;
   // Parse (optional) nested-name-specifier.
-  ParseOptionalCXXScopeSpecifier(SS, /*ObjectType=*/0, false);
+  ParseOptionalCXXScopeSpecifier(SS, ParsedType(), false);
 
   IdentifierInfo *NamespcName = 0;
   SourceLocation IdentLoc = SourceLocation();
@@ -336,7 +336,7 @@
     IsTypeName = false;
 
   // Parse nested-name-specifier.
-  ParseOptionalCXXScopeSpecifier(SS, /*ObjectType=*/0, false);
+  ParseOptionalCXXScopeSpecifier(SS, ParsedType(), false);
 
   // Check nested-name specifier.
   if (SS.isInvalid()) {
@@ -352,7 +352,7 @@
                          /*EnteringContext=*/false,
                          /*AllowDestructorName=*/true,
                          /*AllowConstructorName=*/true,
-                         /*ObjectType=*/0,
+                         ParsedType(),
                          Name)) {
     SkipUntil(tok::semi);
     return 0;
@@ -485,7 +485,7 @@
       AnnotateTemplateIdTokenAsType(SS);
 
       assert(Tok.is(tok::annot_typename) && "template-id -> type failed");
-      TypeTy *Type = Tok.getAnnotationValue();
+      ParsedType Type = getTypeAnnotation(Tok);
       EndLocation = Tok.getAnnotationEndLoc();
       ConsumeToken();
 
@@ -538,13 +538,13 @@
     // Retrieve the type from the annotation token, consume that token, and
     // return.
     EndLocation = Tok.getAnnotationEndLoc();
-    TypeTy *Type = Tok.getAnnotationValue();
+    ParsedType Type = getTypeAnnotation(Tok);
     ConsumeToken();
     return Type;
   }
 
   // We have an identifier; check whether it is actually a type.
-  TypeTy *Type = Actions.getTypeName(*Id, IdLoc, getCurScope(), SS, true);
+  ParsedType Type = Actions.getTypeName(*Id, IdLoc, getCurScope(), SS, true);
   if (!Type) {
     Diag(IdLoc, diag::err_expected_class_name);
     return true;
@@ -682,7 +682,7 @@
     // "FOO : BAR" is not a potential typo for "FOO::BAR".
     ColonProtectionRAIIObject X(*this);
 
-    if (ParseOptionalCXXScopeSpecifier(SS, /*ObjectType=*/0, true))
+    if (ParseOptionalCXXScopeSpecifier(SS, ParsedType(), true))
       DS.SetTypeSpecError();
     if (SS.isSet())
       if (Tok.isNot(tok::identifier) && Tok.isNot(tok::annot_template_id))
@@ -962,27 +962,25 @@
       ParseStructUnionBody(StartLoc, TagType, TagOrTempResult.get());
   }
 
-  void *Result;
+  // FIXME: The DeclSpec should keep the locations of both the keyword and the
+  // name (if there is one).
+  SourceLocation TSTLoc = NameLoc.isValid()? NameLoc : StartLoc;
+
+  const char *PrevSpec = 0;
+  unsigned DiagID;
+  bool Result;
   if (!TypeResult.isInvalid()) {
-    TagType = DeclSpec::TST_typename;
-    Result = TypeResult.get();
-    Owned = false;
+    Result = DS.SetTypeSpecType(DeclSpec::TST_typename, TSTLoc,
+                                PrevSpec, DiagID, TypeResult.get());
   } else if (!TagOrTempResult.isInvalid()) {
-    Result = TagOrTempResult.get();
+    Result = DS.SetTypeSpecType(TagType, TSTLoc, PrevSpec, DiagID,
+                                TagOrTempResult.get(), Owned);
   } else {
     DS.SetTypeSpecError();
     return;
   }
 
-  const char *PrevSpec = 0;
-  unsigned DiagID;
-
-  // FIXME: The DeclSpec should keep the locations of both the keyword and the
-  // name (if there is one).
-  SourceLocation TSTLoc = NameLoc.isValid()? NameLoc : StartLoc;
-
-  if (DS.SetTypeSpecType(TagType, TSTLoc, PrevSpec, DiagID,
-                         Result, Owned))
+  if (Result)
     Diag(StartLoc, DiagID) << PrevSpec;
 
   // At this point, we've successfully parsed a class-specifier in 'definition'
@@ -1138,8 +1136,7 @@
 
   // Parse optional '::' and optional nested-name-specifier.
   CXXScopeSpec SS;
-  ParseOptionalCXXScopeSpecifier(SS, /*ObjectType=*/0,
-                                 /*EnteringContext=*/false);
+  ParseOptionalCXXScopeSpecifier(SS, ParsedType(), /*EnteringContext=*/false);
 
   // The location of the base class itself.
   SourceLocation BaseLoc = Tok.getLocation();
@@ -1252,11 +1249,11 @@
     if (isAccessDecl) {
       // Collect the scope specifier token we annotated earlier.
       CXXScopeSpec SS;
-      ParseOptionalCXXScopeSpecifier(SS, /*ObjectType*/ 0, false);
+      ParseOptionalCXXScopeSpecifier(SS, ParsedType(), false);
 
       // Try to parse an unqualified-id.
       UnqualifiedId Name;
-      if (ParseUnqualifiedId(SS, false, true, true, /*ObjectType*/ 0, Name)) {
+      if (ParseUnqualifiedId(SS, false, true, true, ParsedType(), Name)) {
         SkipUntil(tok::semi);
         return;
       }
@@ -1748,8 +1745,8 @@
 Parser::MemInitResult Parser::ParseMemInitializer(Decl *ConstructorDecl) {
   // parse '::'[opt] nested-name-specifier[opt]
   CXXScopeSpec SS;
-  ParseOptionalCXXScopeSpecifier(SS, /*ObjectType=*/0, false);
-  TypeTy *TemplateTypeTy = 0;
+  ParseOptionalCXXScopeSpecifier(SS, ParsedType(), false);
+  ParsedType TemplateTypeTy;
   if (Tok.is(tok::annot_template_id)) {
     TemplateIdAnnotation *TemplateId
       = static_cast<TemplateIdAnnotation *>(Tok.getAnnotationValue());
@@ -1757,7 +1754,7 @@
         TemplateId->Kind == TNK_Dependent_template_name) {
       AnnotateTemplateIdTokenAsType(&SS);
       assert(Tok.is(tok::annot_typename) && "template-id -> type failed");
-      TemplateTypeTy = Tok.getAnnotationValue();
+      TemplateTypeTy = getTypeAnnotation(Tok);
     }
   }
   if (!TemplateTypeTy && Tok.isNot(tok::identifier)) {
@@ -1806,9 +1803,9 @@
 ///         type-id-list ',' type-id
 ///
 bool Parser::ParseExceptionSpecification(SourceLocation &EndLoc,
-                                         llvm::SmallVector<TypeTy*, 2>
+                                         llvm::SmallVectorImpl<ParsedType>
                                              &Exceptions,
-                                         llvm::SmallVector<SourceRange, 2>
+                                         llvm::SmallVectorImpl<SourceRange>
                                              &Ranges,
                                          bool &hasAnyExceptionSpec) {
   assert(Tok.is(tok::kw_throw) && "expected throw");
@@ -2068,9 +2065,10 @@
     EnterExpressionEvaluationContext Unevaluated(Actions,
                                                   Action::Unevaluated);
     SourceLocation TypeLoc = Tok.getLocation();
-    TypeTy *Ty = ParseTypeName().get();
+    ParsedType Ty = ParseTypeName().get();
     SourceRange TypeRange(Start, Tok.getLocation());
-    return Actions.ActOnSizeOfAlignOfExpr(TypeLoc, false, true, Ty, TypeRange);
+    return Actions.ActOnSizeOfAlignOfExpr(TypeLoc, false, true,
+                                          Ty.getAsOpaquePtr(), TypeRange);
   } else
     return ParseConstantExpression();
 }

Modified: cfe/trunk/lib/Parse/ParseExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=111901&r1=111900&r2=111901&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseExpr.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExpr.cpp Tue Aug 24 00:47:05 2010
@@ -244,7 +244,7 @@
 Parser::OwningExprResult
 Parser::ParseAssignmentExprWithObjCMessageExprStart(SourceLocation LBracLoc,
                                                     SourceLocation SuperLoc,
-                                                    TypeTy *ReceiverType,
+                                                    ParsedType ReceiverType,
                                                     Expr *ReceiverExpr) {
   OwningExprResult R
     = ParseObjCMessageExpressionBody(LBracLoc, SuperLoc,
@@ -423,7 +423,7 @@
 ///
 Parser::OwningExprResult Parser::ParseCastExpression(bool isUnaryExpression,
                                                      bool isAddressOfOperand,
-                                                     TypeTy *TypeOfCast) {
+                                                     ParsedType TypeOfCast) {
   bool NotCastExpr;
   OwningExprResult Res = ParseCastExpression(isUnaryExpression,
                                              isAddressOfOperand,
@@ -548,7 +548,7 @@
 Parser::OwningExprResult Parser::ParseCastExpression(bool isUnaryExpression,
                                                      bool isAddressOfOperand,
                                                      bool &NotCastExpr,
-                                                     TypeTy *TypeOfCast) {
+                                                     ParsedType TypeOfCast) {
   OwningExprResult Res;
   tok::TokenKind SavedKind = Tok.getKind();
   NotCastExpr = false;
@@ -570,7 +570,7 @@
     // not start a cast expression.
     ParenParseOption ParenExprType =
       (isUnaryExpression && !getLang().CPlusPlus)? CompoundLiteral : CastExpr;
-    TypeTy *CastTy;
+    ParsedType CastTy;
     SourceLocation LParenLoc = Tok.getLocation();
     SourceLocation RParenLoc;
     
@@ -826,7 +826,7 @@
         // type, translate it into a type and continue parsing as a
         // cast expression.
         CXXScopeSpec SS;
-        ParseOptionalCXXScopeSpecifier(SS, /*ObjectType=*/0, false);
+        ParseOptionalCXXScopeSpecifier(SS, ParsedType(), false);
         AnnotateTemplateIdTokenAsType(&SS);
         return ParseCastExpression(isUnaryExpression, isAddressOfOperand,
                                    NotCastExpr, TypeOfCast);
@@ -1027,7 +1027,7 @@
       SourceLocation OpLoc = ConsumeToken();  // Eat the "." or "->" token.
 
       CXXScopeSpec SS;
-      Action::TypeTy *ObjectType = 0;
+      ParsedType ObjectType;
       bool MayBePseudoDestructor = false;
       if (getLang().CPlusPlus && !LHS.isInvalid()) {
         LHS = Actions.ActOnStartCXXMemberReference(getCurScope(), LHS.take(),
@@ -1039,7 +1039,7 @@
         ParseOptionalCXXScopeSpecifier(SS, ObjectType, false,
                                        &MayBePseudoDestructor);
         if (SS.isNotEmpty())
-          ObjectType = 0;
+          ObjectType = ParsedType();
       }
 
       if (Tok.is(tok::code_completion)) {
@@ -1108,7 +1108,7 @@
 Parser::OwningExprResult
 Parser::ParseExprAfterTypeofSizeofAlignof(const Token &OpTok,
                                           bool &isCastExpr,
-                                          TypeTy *&CastTy,
+                                          ParsedType &CastTy,
                                           SourceRange &CastRange) {
 
   assert((OpTok.is(tok::kw_typeof)    || OpTok.is(tok::kw_sizeof) ||
@@ -1151,8 +1151,7 @@
     EnterExpressionEvaluationContext Unevaluated(Actions,
                                                  Action::Unevaluated);
     Operand = ParseParenExpression(ExprType, true/*stopIfCastExpr*/, 
-                                   0/*TypeOfCast*/,
-                                   CastTy, RParenLoc);
+                                   ParsedType(), CastTy, RParenLoc);
     CastRange = SourceRange(LParenLoc, RParenLoc);
 
     // If ParseParenExpression parsed a '(typename)' sequence only, then this is
@@ -1192,7 +1191,7 @@
   ConsumeToken();
 
   bool isCastExpr;
-  TypeTy *CastTy;
+  ParsedType CastTy;
   SourceRange CastRange;
   OwningExprResult Operand = ParseExprAfterTypeofSizeofAlignof(OpTok,
                                                                isCastExpr,
@@ -1202,7 +1201,8 @@
   if (isCastExpr)
     return Actions.ActOnSizeOfAlignOfExpr(OpTok.getLocation(),
                                           OpTok.is(tok::kw_sizeof),
-                                          /*isType=*/true, CastTy,
+                                          /*isType=*/true,
+                                          CastTy.getAsOpaquePtr(),
                                           CastRange);
 
   // If we get here, the operand to the sizeof/alignof was an expresion.
@@ -1414,14 +1414,14 @@
 ///
 Parser::OwningExprResult
 Parser::ParseParenExpression(ParenParseOption &ExprType, bool stopIfCastExpr,
-                             TypeTy *TypeOfCast, TypeTy *&CastTy,
+                             ParsedType TypeOfCast, ParsedType &CastTy,
                              SourceLocation &RParenLoc) {
   assert(Tok.is(tok::l_paren) && "Not a paren expr!");
   GreaterThanIsOperatorScope G(GreaterThanIsOperator, true);
   SourceLocation OpenLoc = ConsumeParen();
   OwningExprResult Result(true);
   bool isAmbiguousTypeId;
-  CastTy = 0;
+  CastTy = ParsedType();
 
   if (ExprType >= CompoundStmt && Tok.is(tok::l_brace)) {
     Diag(Tok, diag::ext_gnu_statement_expr);
@@ -1532,7 +1532,7 @@
 ///         '(' type-name ')' '{' initializer-list ',' '}'
 ///
 Parser::OwningExprResult
-Parser::ParseCompoundLiteralExpression(TypeTy *Ty,
+Parser::ParseCompoundLiteralExpression(ParsedType Ty,
                                        SourceLocation LParenLoc,
                                        SourceLocation RParenLoc) {
   assert(Tok.is(tok::l_brace) && "Not a compound literal!");

Modified: cfe/trunk/lib/Parse/ParseExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExprCXX.cpp?rev=111901&r1=111900&r2=111901&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseExprCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExprCXX.cpp Tue Aug 24 00:47:05 2010
@@ -57,7 +57,7 @@
 ///
 /// \returns true if there was an error parsing a scope specifier
 bool Parser::ParseOptionalCXXScopeSpecifier(CXXScopeSpec &SS,
-                                            Action::TypeTy *ObjectType,
+                                            ParsedType ObjectType,
                                             bool EnteringContext,
                                             bool *MayBePseudoDestructor) {
   assert(getLang().CPlusPlus &&
@@ -104,7 +104,7 @@
       //
       // To implement this, we clear out the object type as soon as we've
       // seen a leading '::' or part of a nested-name-specifier.
-      ObjectType = 0;
+      ObjectType = ParsedType();
       
       if (Tok.is(tok::code_completion)) {
         // Code completion for a nested-name-specifier, where the code
@@ -212,13 +212,13 @@
           HasScopeSpecifier = true;
         }
 
-        if (TypeToken.getAnnotationValue())
-          SS.setScopeRep(
-            Actions.ActOnCXXNestedNameSpecifier(getCurScope(), SS,
-                                                TypeToken.getAnnotationValue(),
+        if (ParsedType T = getTypeAnnotation(TypeToken)) {
+          CXXScopeTy *Scope =
+            Actions.ActOnCXXNestedNameSpecifier(getCurScope(), SS, T,
                                                 TypeToken.getAnnotationRange(),
-                                                CCLoc));
-        else
+                                                CCLoc);
+          SS.setScopeRep(Scope);
+        } else
           SS.setScopeRep(0);
         SS.setEndLoc(CCLoc);
         continue;
@@ -403,14 +403,14 @@
   //   '::' unqualified-id
   //
   CXXScopeSpec SS;
-  ParseOptionalCXXScopeSpecifier(SS, /*ObjectType=*/0, false);
+  ParseOptionalCXXScopeSpecifier(SS, ParsedType(), false);
   
   UnqualifiedId Name;
   if (ParseUnqualifiedId(SS, 
                          /*EnteringContext=*/false, 
                          /*AllowDestructorName=*/false, 
                          /*AllowConstructorName=*/false, 
-                         /*ObjectType=*/0,
+                         /*ObjectType=*/ ParsedType(),
                          Name))
     return ExprError();
 
@@ -519,7 +519,7 @@
       return ExprError();
 
     Result = Actions.ActOnCXXTypeid(OpLoc, LParenLoc, /*isType=*/true,
-                                    Ty.get(), RParenLoc);
+                                    Ty.get().getAsOpaquePtr(), RParenLoc);
   } else {
     // C++0x [expr.typeid]p3:
     //   When typeid is applied to an expression other than an lvalue of a
@@ -565,7 +565,7 @@
 Parser::ParseCXXPseudoDestructor(ExprArg Base, SourceLocation OpLoc,
                                  tok::TokenKind OpKind,
                                  CXXScopeSpec &SS,
-                                 Action::TypeTy *ObjectType) {
+                                 ParsedType ObjectType) {
   // We're parsing either a pseudo-destructor-name or a dependent
   // member access that has the same form as a
   // pseudo-destructor-name. We parse both in the same way and let
@@ -680,7 +680,7 @@
 Parser::OwningExprResult
 Parser::ParseCXXTypeConstructExpression(const DeclSpec &DS) {
   Declarator DeclaratorInfo(DS, Declarator::TypeNameContext);
-  TypeTy *TypeRep = Actions.ActOnTypeName(getCurScope(), DeclaratorInfo).get();
+  ParsedType TypeRep = Actions.ActOnTypeName(getCurScope(), DeclaratorInfo).get();
 
   assert(Tok.is(tok::l_paren) && "Expected '('!");
   SourceLocation LParenLoc = ConsumeParen();
@@ -876,7 +876,7 @@
   // type-name
   case tok::annot_typename: {
     DS.SetTypeSpecType(DeclSpec::TST_typename, Loc, PrevSpec, DiagID,
-                       Tok.getAnnotationValue());
+                       getTypeAnnotation(Tok));
     break;
   }
 
@@ -1004,7 +1004,7 @@
                                           IdentifierInfo *Name,
                                           SourceLocation NameLoc,
                                           bool EnteringContext,
-                                          TypeTy *ObjectType,
+                                          ParsedType ObjectType,
                                           UnqualifiedId &Id,
                                           bool AssumeTemplateId,
                                           SourceLocation TemplateKWLoc) {
@@ -1085,7 +1085,7 @@
                                    EnteringContext, Template,
                                    MemberOfUnknownSpecialization);
       
-      if (TNK == TNK_Non_template && Id.DestructorName == 0) {
+      if (TNK == TNK_Non_template && !Id.DestructorName.get()) {
         Diag(NameLoc, diag::err_destructor_template_id)
           << Name << SS.getRange();
         return true;        
@@ -1203,7 +1203,7 @@
 ///
 /// \returns true if parsing fails, false otherwise.
 bool Parser::ParseUnqualifiedIdOperator(CXXScopeSpec &SS, bool EnteringContext,
-                                        TypeTy *ObjectType,
+                                        ParsedType ObjectType,
                                         UnqualifiedId &Result) {
   assert(Tok.is(tok::kw_operator) && "Expected 'operator' keyword");
   
@@ -1382,7 +1382,7 @@
 bool Parser::ParseUnqualifiedId(CXXScopeSpec &SS, bool EnteringContext,
                                 bool AllowDestructorName,
                                 bool AllowConstructorName,
-                                TypeTy *ObjectType,
+                                ParsedType ObjectType,
                                 UnqualifiedId &Result) {
 
   // Handle 'A::template B'. This is for template-ids which have not
@@ -1516,17 +1516,17 @@
     SourceLocation ClassNameLoc = ConsumeToken();
     
     if (TemplateSpecified || Tok.is(tok::less)) {
-      Result.setDestructorName(TildeLoc, 0, ClassNameLoc);
+      Result.setDestructorName(TildeLoc, ParsedType(), ClassNameLoc);
       return ParseUnqualifiedIdTemplateId(SS, ClassName, ClassNameLoc,
                                           EnteringContext, ObjectType, Result,
                                           TemplateSpecified, TemplateKWLoc);
     }
     
     // Note that this is a destructor name.
-    Action::TypeTy *Ty = Actions.getDestructorName(TildeLoc, *ClassName, 
-                                                   ClassNameLoc, getCurScope(),
-                                                   SS, ObjectType,
-                                                   EnteringContext);
+    ParsedType Ty = Actions.getDestructorName(TildeLoc, *ClassName, 
+                                              ClassNameLoc, getCurScope(),
+                                              SS, ObjectType,
+                                              EnteringContext);
     if (!Ty)
       return true;
 
@@ -1804,7 +1804,7 @@
 /// based on the context past the parens.
 Parser::OwningExprResult
 Parser::ParseCXXAmbiguousParenExpression(ParenParseOption &ExprType,
-                                         TypeTy *&CastTy,
+                                         ParsedType &CastTy,
                                          SourceLocation LParenLoc,
                                          SourceLocation &RParenLoc) {
   assert(getLang().CPlusPlus && "Should only be called for C++!");
@@ -1812,7 +1812,7 @@
   assert(isTypeIdInParens() && "Not a type-id!");
 
   OwningExprResult Result(true);
-  CastTy = 0;
+  CastTy = ParsedType();
 
   // We need to disambiguate a very ugly part of the C++ syntax:
   //
@@ -1857,7 +1857,8 @@
       // will be consumed.
       Result = ParseCastExpression(false/*isUnaryExpression*/,
                                    false/*isAddressofOperand*/,
-                                   NotCastExpr, 0/*TypeOfCast*/);
+                                   NotCastExpr,
+                                   ParsedType()/*TypeOfCast*/);
     }
 
     // If we parsed a cast-expression, it's really a type-id, otherwise it's

Modified: cfe/trunk/lib/Parse/ParseInit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseInit.cpp?rev=111901&r1=111900&r2=111901&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseInit.cpp (original)
+++ cfe/trunk/lib/Parse/ParseInit.cpp Tue Aug 24 00:47:05 2010
@@ -149,7 +149,8 @@
           NextToken().isNot(tok::period) && getCurScope()->isInObjcMethodScope()) {
         CheckArrayDesignatorSyntax(*this, StartLoc, Desig);
         return ParseAssignmentExprWithObjCMessageExprStart(StartLoc,
-                                                           ConsumeToken(), 0, 
+                                                           ConsumeToken(),
+                                                           ParsedType(), 
                                                            0);
       }
 
@@ -167,7 +168,7 @@
         CheckArrayDesignatorSyntax(*this, StartLoc, Desig);
         return ParseAssignmentExprWithObjCMessageExprStart(StartLoc, 
                                                            SourceLocation(), 
-                                                           TypeOrExpr,
+                                   ParsedType::getFromOpaquePtr(TypeOrExpr),
                                                            0);
       }
 
@@ -179,7 +180,7 @@
     } else if (getLang().ObjC1 && Tok.is(tok::identifier)) {
       IdentifierInfo *II = Tok.getIdentifierInfo();
       SourceLocation IILoc = Tok.getLocation();
-      TypeTy *ReceiverType;
+      ParsedType ReceiverType;
       // Three cases. This is a message send to a type: [type foo]
       // This is a message send to super:  [super foo]
       // This is a message sent to an expr:  [super.bar foo]
@@ -194,7 +195,7 @@
         if (Kind == Action::ObjCSuperMessage)
           return ParseAssignmentExprWithObjCMessageExprStart(StartLoc,
                                                              ConsumeToken(),
-                                                             0,
+                                                             ParsedType(),
                                                              0);
         ConsumeToken(); // the identifier
         if (!ReceiverType) {
@@ -239,7 +240,8 @@
       CheckArrayDesignatorSyntax(*this, Tok.getLocation(), Desig);
       return ParseAssignmentExprWithObjCMessageExprStart(StartLoc,
                                                          SourceLocation(),
-                                                         0, Idx.take());
+                                                         ParsedType(),
+                                                         Idx.take());
     }
 
     // If this is a normal array designator, remember it.

Modified: cfe/trunk/lib/Parse/ParseObjc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseObjc.cpp?rev=111901&r1=111900&r2=111901&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseObjc.cpp (original)
+++ cfe/trunk/lib/Parse/ParseObjc.cpp Tue Aug 24 00:47:05 2010
@@ -720,7 +720,7 @@
 ///     '(' objc-type-qualifiers[opt] type-name ')'
 ///     '(' objc-type-qualifiers[opt] ')'
 ///
-Parser::TypeTy *Parser::ParseObjCTypeName(ObjCDeclSpec &DS, bool IsParameter) {
+ParsedType Parser::ParseObjCTypeName(ObjCDeclSpec &DS, bool IsParameter) {
   assert(Tok.is(tok::l_paren) && "expected (");
 
   SourceLocation LParenLoc = ConsumeParen();
@@ -729,7 +729,7 @@
   // Parse type qualifiers, in, inout, etc.
   ParseObjCTypeQualifierList(DS, IsParameter);
 
-  TypeTy *Ty = 0;
+  ParsedType Ty;
   if (isTypeSpecifierQualifier()) {
     TypeResult TypeSpec = ParseTypeName();
     if (!TypeSpec.isInvalid())
@@ -786,12 +786,12 @@
 
   if (Tok.is(tok::code_completion)) {
     Actions.CodeCompleteObjCMethodDecl(getCurScope(), mType == tok::minus, 
-                                       /*ReturnType=*/0, IDecl);
+                                       /*ReturnType=*/ ParsedType(), IDecl);
     ConsumeCodeCompletionToken();
   }
 
   // Parse the return type if present.
-  TypeTy *ReturnType = 0;
+  ParsedType ReturnType;
   ObjCDeclSpec DSRet;
   if (Tok.is(tok::l_paren))
     ReturnType = ParseObjCTypeName(DSRet, false);
@@ -852,7 +852,7 @@
     }
     ConsumeToken(); // Eat the ':'.
 
-    ArgInfo.Type = 0;
+    ArgInfo.Type = ParsedType();
     if (Tok.is(tok::l_paren)) // Parse the argument type if present.
       ArgInfo.Type = ParseObjCTypeName(ArgInfo.DeclSpec, true);
 
@@ -1822,7 +1822,7 @@
     return true;
 
   IsExpr = false;
-  TypeOrExpr = Type.get();
+  TypeOrExpr = Type.get().getAsOpaquePtr();
   return false;
 }
 
@@ -1867,8 +1867,8 @@
     // get in Objective-C.
     if (Tok.is(tok::identifier) && Tok.getIdentifierInfo() == Ident_super &&
         NextToken().isNot(tok::period) && getCurScope()->isInObjcMethodScope())
-      return ParseObjCMessageExpressionBody(LBracLoc, ConsumeToken(), 0, 
-                                            0);
+      return ParseObjCMessageExpressionBody(LBracLoc, ConsumeToken(),
+                                            ParsedType(), 0);
 
     // Parse the receiver, which is either a type or an expression.
     bool IsExpr;
@@ -1879,23 +1879,26 @@
     }
 
     if (IsExpr)
-      return ParseObjCMessageExpressionBody(LBracLoc, SourceLocation(), 0,
+      return ParseObjCMessageExpressionBody(LBracLoc, SourceLocation(),
+                                            ParsedType(),
                                             static_cast<Expr*>(TypeOrExpr));
 
     return ParseObjCMessageExpressionBody(LBracLoc, SourceLocation(), 
-                                          TypeOrExpr, 0);
+                              ParsedType::getFromOpaquePtr(TypeOrExpr),
+                                          0);
   }
   
   if (Tok.is(tok::identifier)) {
     IdentifierInfo *Name = Tok.getIdentifierInfo();
     SourceLocation NameLoc = Tok.getLocation();
-    TypeTy *ReceiverType;
+    ParsedType ReceiverType;
     switch (Actions.getObjCMessageKind(getCurScope(), Name, NameLoc,
                                        Name == Ident_super,
                                        NextToken().is(tok::period),
                                        ReceiverType)) {
     case Action::ObjCSuperMessage:
-      return ParseObjCMessageExpressionBody(LBracLoc, ConsumeToken(), 0, 0);
+      return ParseObjCMessageExpressionBody(LBracLoc, ConsumeToken(),
+                                            ParsedType(), 0);
 
     case Action::ObjCClassMessage:
       if (!ReceiverType) {
@@ -1921,8 +1924,8 @@
     return move(Res);
   }
 
-  return ParseObjCMessageExpressionBody(LBracLoc, SourceLocation(), 0, 
-                                        Res.take());
+  return ParseObjCMessageExpressionBody(LBracLoc, SourceLocation(),
+                                        ParsedType(), Res.take());
 }
 
 /// \brief Parse the remainder of an Objective-C message following the
@@ -1966,7 +1969,7 @@
 Parser::OwningExprResult
 Parser::ParseObjCMessageExpressionBody(SourceLocation LBracLoc,
                                        SourceLocation SuperLoc,
-                                       TypeTy *ReceiverType,
+                                       ParsedType ReceiverType,
                                        ExprArg ReceiverExpr) {
   if (Tok.is(tok::code_completion)) {
     if (SuperLoc.isValid())

Modified: cfe/trunk/lib/Parse/ParseTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseTemplate.cpp?rev=111901&r1=111900&r2=111901&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseTemplate.cpp (original)
+++ cfe/trunk/lib/Parse/ParseTemplate.cpp Tue Aug 24 00:47:05 2010
@@ -481,7 +481,7 @@
   // Per C++0x [basic.scope.pdecl]p9, we parse the default argument before
   // we introduce the type parameter into the local scope.
   SourceLocation EqualLoc;
-  TypeTy *DefaultArg = 0;
+  ParsedType DefaultArg;
   if (Tok.is(tok::equal)) {
     EqualLoc = ConsumeToken();
     DefaultArg = ParseTypeName().get();
@@ -587,7 +587,7 @@
   // Parse this as a typename.
   Declarator ParamDecl(DS, Declarator::TemplateParamContext);
   ParseDeclarator(ParamDecl);
-  if (DS.getTypeSpecType() == DeclSpec::TST_unspecified && !DS.getTypeRep()) {
+  if (DS.getTypeSpecType() == DeclSpec::TST_unspecified) {
     // This probably shouldn't happen - and it's more of a Sema thing, but
     // basically we didn't parse the type name because we couldn't associate
     // it with an AST node. we should just skip to the comma or greater.
@@ -785,7 +785,7 @@
     }
 
     Tok.setKind(tok::annot_typename);
-    Tok.setAnnotationValue(Type.get());
+    setTypeAnnotation(Tok, Type.get());
     if (SS && SS->isNotEmpty())
       Tok.setLocation(SS->getBeginLoc());
     else if (TemplateKWLoc.isValid())
@@ -858,7 +858,7 @@
                                   TemplateId->RAngleLoc);
   // Create the new "type" annotation token.
   Tok.setKind(tok::annot_typename);
-  Tok.setAnnotationValue(Type.isInvalid()? 0 : Type.get());
+  setTypeAnnotation(Tok, Type.isInvalid() ? ParsedType() : Type.get());
   if (SS && SS->isNotEmpty()) // it was a C++ qualified type name.
     Tok.setLocation(SS->getBeginLoc());
   // End location stays the same
@@ -893,7 +893,7 @@
   // followed by a token that terminates a template argument, such as ',', 
   // '>', or (in some cases) '>>'.
   CXXScopeSpec SS; // nested-name-specifier, if present
-  ParseOptionalCXXScopeSpecifier(SS, /*ObjectType=*/0, 
+  ParseOptionalCXXScopeSpecifier(SS, ParsedType(),
                                  /*EnteringContext=*/false);
   
   if (SS.isSet() && Tok.is(tok::kw_template)) {
@@ -912,8 +912,9 @@
       // template argument.
       TemplateTy Template;
       if (isEndOfTemplateArgument(Tok) &&
-          Actions.ActOnDependentTemplateName(getCurScope(), TemplateLoc, SS, Name, 
-                                             /*ObjectType=*/0,
+          Actions.ActOnDependentTemplateName(getCurScope(), TemplateLoc,
+                                             SS, Name, 
+                                             /*ObjectType=*/ ParsedType(),
                                              /*EnteringContext=*/false,
                                              Template))
         return ParsedTemplateArgument(SS, Template, Name.StartLocation);
@@ -930,7 +931,7 @@
       TemplateNameKind TNK = Actions.isTemplateName(getCurScope(), SS,
                                                /*hasTemplateKeyword=*/false,
                                                     Name,
-                                                    /*ObjectType=*/0, 
+                                               /*ObjectType=*/ ParsedType(), 
                                                     /*EnteringContext=*/false, 
                                                     Template,
                                                 MemberOfUnknownSpecialization);
@@ -965,7 +966,8 @@
     if (TypeArg.isInvalid())
       return ParsedTemplateArgument();
     
-    return ParsedTemplateArgument(ParsedTemplateArgument::Type, TypeArg.get(), 
+    return ParsedTemplateArgument(ParsedTemplateArgument::Type,
+                                  TypeArg.get().getAsOpaquePtr(), 
                                   Loc);
   }
   

Modified: cfe/trunk/lib/Parse/Parser.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/Parser.cpp?rev=111901&r1=111900&r2=111901&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/Parser.cpp (original)
+++ cfe/trunk/lib/Parse/Parser.cpp Tue Aug 24 00:47:05 2010
@@ -921,7 +921,7 @@
     //            simple-template-id
     SourceLocation TypenameLoc = ConsumeToken();
     CXXScopeSpec SS;
-    if (ParseOptionalCXXScopeSpecifier(SS, /*ObjectType=*/0, false))
+    if (ParseOptionalCXXScopeSpecifier(SS, /*ObjectType=*/ParsedType(), false))
       return true;
     if (!SS.isSet()) {
       Diag(Tok.getLocation(), diag::err_expected_qualified_after_typename);
@@ -949,7 +949,7 @@
       if (Tok.getAnnotationValue())
         Ty = Actions.ActOnTypenameType(getCurScope(), TypenameLoc, SS, 
                                        SourceLocation(),
-                                       Tok.getAnnotationValue());
+                                       getTypeAnnotation(Tok));
       else
         Ty = true;
     } else {
@@ -960,7 +960,7 @@
 
     SourceLocation EndLoc = Tok.getLastLoc();
     Tok.setKind(tok::annot_typename);
-    Tok.setAnnotationValue(Ty.isInvalid()? 0 : Ty.get());
+    setTypeAnnotation(Tok, Ty.isInvalid() ? ParsedType() : Ty.get());
     Tok.setAnnotationEndLoc(EndLoc);
     Tok.setLocation(TypenameLoc);
     PP.AnnotateCachedTokens(Tok);
@@ -972,17 +972,18 @@
 
   CXXScopeSpec SS;
   if (getLang().CPlusPlus)
-    if (ParseOptionalCXXScopeSpecifier(SS, /*ObjectType=*/0, EnteringContext))
+    if (ParseOptionalCXXScopeSpecifier(SS, ParsedType(), EnteringContext))
       return true;
 
   if (Tok.is(tok::identifier)) {
     // Determine whether the identifier is a type name.
-    if (TypeTy *Ty = Actions.getTypeName(*Tok.getIdentifierInfo(),
-                                         Tok.getLocation(), getCurScope(), &SS)) {
+    if (ParsedType Ty = Actions.getTypeName(*Tok.getIdentifierInfo(),
+                                            Tok.getLocation(), getCurScope(),
+                                            &SS)) {
       // This is a typename. Replace the current token in-place with an
       // annotation type token.
       Tok.setKind(tok::annot_typename);
-      Tok.setAnnotationValue(Ty);
+      setTypeAnnotation(Tok, Ty);
       Tok.setAnnotationEndLoc(Tok.getLocation());
       if (SS.isNotEmpty()) // it was a C++ qualified type name.
         Tok.setLocation(SS.getBeginLoc());
@@ -1009,7 +1010,8 @@
       if (TemplateNameKind TNK
           = Actions.isTemplateName(getCurScope(), SS,
                                    /*hasTemplateKeyword=*/false, TemplateName,
-                                   /*ObjectType=*/0, EnteringContext,
+                                   /*ObjectType=*/ ParsedType(),
+                                   EnteringContext,
                                    Template, MemberOfUnknownSpecialization)) {
         // Consume the identifier.
         ConsumeToken();
@@ -1077,7 +1079,7 @@
          "Cannot be a type or scope token!");
 
   CXXScopeSpec SS;
-  if (ParseOptionalCXXScopeSpecifier(SS, /*ObjectType=*/0, EnteringContext))
+  if (ParseOptionalCXXScopeSpecifier(SS, ParsedType(), EnteringContext))
     return true;
   if (SS.isEmpty())
     return false;

Modified: cfe/trunk/lib/Sema/Action.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Action.cpp?rev=111901&r1=111900&r2=111901&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/Action.cpp (original)
+++ cfe/trunk/lib/Sema/Action.cpp Tue Aug 24 00:47:05 2010
@@ -34,71 +34,5 @@
   OS << '\n';
 }
 
-///  Out-of-line virtual destructor to provide home for ActionBase class.
-ActionBase::~ActionBase() {}
-
 ///  Out-of-line virtual destructor to provide home for Action class.
 Action::~Action() {}
-
-Action::ObjCMessageKind Action::getObjCMessageKind(Scope *S,
-                                                   IdentifierInfo *Name,
-                                                   SourceLocation NameLoc,
-                                                   bool IsSuper,
-                                                   bool HasTrailingDot,
-                                                   TypeTy *&ReceiverType) {
-  ReceiverType = 0;
-
-  if (IsSuper && !HasTrailingDot && S->isInObjcMethodScope())
-    return ObjCSuperMessage;
-      
-  if (TypeTy *TyName = getTypeName(*Name, NameLoc, S)) {
-    DeclSpec DS;
-    const char *PrevSpec = 0;
-    unsigned DiagID = 0;
-    if (!DS.SetTypeSpecType(DeclSpec::TST_typename, NameLoc, PrevSpec,
-                            DiagID, TyName)) {
-      DS.SetRangeEnd(NameLoc);
-      Declarator DeclaratorInfo(DS, Declarator::TypeNameContext);
-      TypeResult Ty = ActOnTypeName(S, DeclaratorInfo);
-      if (!Ty.isInvalid())
-        ReceiverType = Ty.get();
-    }
-    return ObjCClassMessage;
-  }
-      
-  return ObjCInstanceMessage;
-}
-
-// Defined out-of-line here because of dependecy on AttributeList
-Decl *Action::ActOnUsingDirective(Scope *CurScope,
-                                  SourceLocation UsingLoc,
-                                  SourceLocation NamespcLoc,
-                                  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;
-}
-
-// Defined out-of-line here because of dependency on AttributeList
-Decl *Action::ActOnUsingDeclaration(Scope *CurScope,
-                                    AccessSpecifier AS,
-                                    bool HasUsingKeyword,
-                                    SourceLocation UsingLoc,
-                                    CXXScopeSpec &SS,
-                                    UnqualifiedId &Name,
-                                    AttributeList *AttrList,
-                                    bool IsTypeName,
-                                    SourceLocation TypenameLoc) {
-
-  // 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;
-}

Modified: cfe/trunk/lib/Sema/AttributeList.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/AttributeList.cpp?rev=111901&r1=111900&r2=111901&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/AttributeList.cpp (original)
+++ cfe/trunk/lib/Sema/AttributeList.cpp Tue Aug 24 00:47:05 2010
@@ -19,7 +19,7 @@
 AttributeList::AttributeList(IdentifierInfo *aName, SourceLocation aLoc,
                              IdentifierInfo *sName, SourceLocation sLoc,
                              IdentifierInfo *pName, SourceLocation pLoc,
-                             ActionBase::ExprTy **ExprList, unsigned numArgs,
+                             Expr **ExprList, unsigned numArgs,
                              AttributeList *n, bool declspec, bool cxx0x)
   : AttrName(aName), AttrLoc(aLoc), ScopeName(sName), ScopeLoc(sLoc),
     ParmName(pName), ParmLoc(pLoc), NumArgs(numArgs), Next(n),
@@ -28,7 +28,7 @@
   if (numArgs == 0)
     Args = 0;
   else {
-    Args = new ActionBase::ExprTy*[numArgs];
+    Args = new Expr*[numArgs];
     memcpy(Args, ExprList, numArgs*sizeof(Args[0]));
   }
 }

Modified: cfe/trunk/lib/Sema/DeclSpec.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/DeclSpec.cpp?rev=111901&r1=111900&r2=111901&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/DeclSpec.cpp (original)
+++ cfe/trunk/lib/Sema/DeclSpec.cpp Tue Aug 24 00:47:05 2010
@@ -54,7 +54,7 @@
                                              bool hasExceptionSpec,
                                              SourceLocation ThrowLoc,
                                              bool hasAnyExceptionSpec,
-                                             ActionBase::TypeTy **Exceptions,
+                                             ParsedType *Exceptions,
                                              SourceRange *ExceptionRanges,
                                              unsigned NumExceptions,
                                              SourceLocation LPLoc,
@@ -291,7 +291,63 @@
 bool DeclSpec::SetTypeSpecType(TST T, SourceLocation Loc,
                                const char *&PrevSpec,
                                unsigned &DiagID,
-                               void *Rep, bool Owned) {
+                               ParsedType Rep) {
+  assert(isTypeRep(T) && "T does not store a type");
+  assert(Rep && "no type provided!");
+  if (TypeSpecType != TST_unspecified) {
+    PrevSpec = DeclSpec::getSpecifierName((TST) TypeSpecType);
+    DiagID = diag::err_invalid_decl_spec_combination;
+    return true;
+  }
+  TypeSpecType = T;
+  TypeRep = Rep;
+  TSTLoc = Loc;
+  TypeSpecOwned = false;
+  return false;
+}
+
+bool DeclSpec::SetTypeSpecType(TST T, SourceLocation Loc,
+                               const char *&PrevSpec,
+                               unsigned &DiagID,
+                               Expr *Rep) {
+  assert(isExprRep(T) && "T does not store an expr");
+  assert(Rep && "no expression provided!");
+  if (TypeSpecType != TST_unspecified) {
+    PrevSpec = DeclSpec::getSpecifierName((TST) TypeSpecType);
+    DiagID = diag::err_invalid_decl_spec_combination;
+    return true;
+  }
+  TypeSpecType = T;
+  ExprRep = Rep;
+  TSTLoc = Loc;
+  TypeSpecOwned = false;
+  return false;
+}
+
+bool DeclSpec::SetTypeSpecType(TST T, SourceLocation Loc,
+                               const char *&PrevSpec,
+                               unsigned &DiagID,
+                               Decl *Rep, bool Owned) {
+  assert(isDeclRep(T) && "T does not store a decl");
+  // Unlike the other cases, we don't assert that we actually get a decl.
+
+  if (TypeSpecType != TST_unspecified) {
+    PrevSpec = DeclSpec::getSpecifierName((TST) TypeSpecType);
+    DiagID = diag::err_invalid_decl_spec_combination;
+    return true;
+  }
+  TypeSpecType = T;
+  DeclRep = Rep;
+  TSTLoc = Loc;
+  TypeSpecOwned = Owned;
+  return false;
+}
+
+bool DeclSpec::SetTypeSpecType(TST T, SourceLocation Loc,
+                               const char *&PrevSpec,
+                               unsigned &DiagID) {
+  assert(!isDeclRep(T) && !isTypeRep(T) && !isExprRep(T) &&
+         "rep required for these type-spec kinds!");
   if (TypeSpecType != TST_unspecified) {
     PrevSpec = DeclSpec::getSpecifierName((TST) TypeSpecType);
     DiagID = diag::err_invalid_decl_spec_combination;
@@ -303,9 +359,8 @@
     return false;
   }
   TypeSpecType = T;
-  TypeRep = Rep;
   TSTLoc = Loc;
-  TypeSpecOwned = Owned;
+  TypeSpecOwned = false;
   if (TypeAltiVecVector && !TypeAltiVecBool && (TypeSpecType == TST_double)) {
     PrevSpec = DeclSpec::getSpecifierName((TST) TypeSpecType);
     DiagID = diag::err_invalid_vector_decl_spec;
@@ -341,7 +396,6 @@
 
 bool DeclSpec::SetTypeSpecError() {
   TypeSpecType = TST_error;
-  TypeRep = 0;
   TSTLoc = SourceLocation();
   return false;
 }
@@ -577,11 +631,8 @@
 
 bool DeclSpec::isMissingDeclaratorOk() {
   TST tst = getTypeSpecType();
-  return (tst == TST_union
-       || tst == TST_struct
-       || tst == TST_class
-       || tst == TST_enum
-          ) && getTypeRep() != 0 && StorageClassSpec != DeclSpec::SCS_typedef;
+  return isDeclRep(tst) && getRepAsDecl() != 0 &&
+    StorageClassSpec != DeclSpec::SCS_typedef;
 }
 
 void UnqualifiedId::clear() {

Modified: cfe/trunk/lib/Sema/SemaCXXCast.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCXXCast.cpp?rev=111901&r1=111900&r2=111901&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaCXXCast.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCXXCast.cpp Tue Aug 24 00:47:05 2010
@@ -118,7 +118,7 @@
 /// ActOnCXXNamedCast - Parse {dynamic,static,reinterpret,const}_cast's.
 Action::OwningExprResult
 Sema::ActOnCXXNamedCast(SourceLocation OpLoc, tok::TokenKind Kind,
-                        SourceLocation LAngleBracketLoc, TypeTy *Ty,
+                        SourceLocation LAngleBracketLoc, ParsedType Ty,
                         SourceLocation RAngleBracketLoc,
                         SourceLocation LParenLoc, ExprArg E,
                         SourceLocation RParenLoc) {

Modified: cfe/trunk/lib/Sema/SemaCXXScopeSpec.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCXXScopeSpec.cpp?rev=111901&r1=111900&r2=111901&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaCXXScopeSpec.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCXXScopeSpec.cpp Tue Aug 24 00:47:05 2010
@@ -283,7 +283,7 @@
 bool Sema::isNonTypeNestedNameSpecifier(Scope *S, CXXScopeSpec &SS,
                                         SourceLocation IdLoc,
                                         IdentifierInfo &II,
-                                        TypeTy *ObjectTypePtr) {
+                                        ParsedType ObjectTypePtr) {
   QualType ObjectType = GetTypeFromParser(ObjectTypePtr);
   LookupResult Found(*this, &II, IdLoc, LookupNestedNameSpecifierName);
   
@@ -567,10 +567,10 @@
                                                     SourceLocation IdLoc,
                                                     SourceLocation CCLoc,
                                                     IdentifierInfo &II,
-                                                    TypeTy *ObjectTypePtr,
+                                                    ParsedType ObjectTypePtr,
                                                     bool EnteringContext) {
   return BuildCXXNestedNameSpecifier(S, SS, IdLoc, CCLoc, II,
-                                     QualType::getFromOpaquePtr(ObjectTypePtr),
+                                     GetTypeFromParser(ObjectTypePtr),
                                      /*ScopeLookupResult=*/0, EnteringContext,
                                      false);
 }
@@ -582,21 +582,20 @@
 ///
 /// The arguments are the same as those passed to ActOnCXXNestedNameSpecifier.
 bool Sema::IsInvalidUnlessNestedName(Scope *S, CXXScopeSpec &SS,
-                                     IdentifierInfo &II, TypeTy *ObjectType,
+                                     IdentifierInfo &II, ParsedType ObjectType,
                                      bool EnteringContext) {
   return BuildCXXNestedNameSpecifier(S, SS, SourceLocation(), SourceLocation(),
-                                     II, QualType::getFromOpaquePtr(ObjectType),
+                                     II, GetTypeFromParser(ObjectType),
                                      /*ScopeLookupResult=*/0, EnteringContext,
                                      true);
 }
 
 Sema::CXXScopeTy *Sema::ActOnCXXNestedNameSpecifier(Scope *S,
                                                     const CXXScopeSpec &SS,
-                                                    TypeTy *Ty,
+                                                    ParsedType Ty,
                                                     SourceRange TypeRange,
                                                     SourceLocation CCLoc) {
-  NestedNameSpecifier *Prefix
-    = static_cast<NestedNameSpecifier *>(SS.getScopeRep());
+  NestedNameSpecifier *Prefix = SS.getScopeRep();
   QualType T = GetTypeFromParser(Ty);
   return NestedNameSpecifier::Create(Context, Prefix, /*FIXME:*/false,
                                      T.getTypePtr());

Modified: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCodeComplete.cpp?rev=111901&r1=111900&r2=111901&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp Tue Aug 24 00:47:05 2010
@@ -3741,14 +3741,14 @@
     // Fall through
   }
 
-  TypeTy *Receiver = 0;
+  ParsedType Receiver;
   if (CDecl)
-    Receiver = Context.getObjCInterfaceType(CDecl).getAsOpaquePtr();
+    Receiver = ParsedType::make(Context.getObjCInterfaceType(CDecl));
   return CodeCompleteObjCClassMessage(S, Receiver, SelIdents, 
                                       NumSelIdents);
 }
 
-void Sema::CodeCompleteObjCClassMessage(Scope *S, TypeTy *Receiver,
+void Sema::CodeCompleteObjCClassMessage(Scope *S, ParsedType Receiver,
                                         IdentifierInfo **SelIdents,
                                         unsigned NumSelIdents) {
   typedef CodeCompleteConsumer::Result Result;
@@ -4295,7 +4295,7 @@
 
 void Sema::CodeCompleteObjCMethodDecl(Scope *S, 
                                       bool IsInstanceMethod,
-                                      TypeTy *ReturnTy,
+                                      ParsedType ReturnTy,
                                       Decl *IDecl) {
   // Determine the return type of the method we're declaring, if
   // provided.
@@ -4445,7 +4445,7 @@
 void Sema::CodeCompleteObjCMethodDeclSelector(Scope *S, 
                                               bool IsInstanceMethod,
                                               bool AtParameterName,
-                                              TypeTy *ReturnTy,
+                                              ParsedType ReturnTy,
                                               IdentifierInfo **SelIdents,
                                               unsigned NumSelIdents) {
   // If we have an external source, load the entire class method

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=111901&r1=111900&r2=111901&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Aug 24 00:47:05 2010
@@ -59,14 +59,14 @@
 ///
 /// If name lookup results in an ambiguity, this routine will complain
 /// and then return NULL.
-Sema::TypeTy *Sema::getTypeName(IdentifierInfo &II, SourceLocation NameLoc,
-                                Scope *S, CXXScopeSpec *SS,
-                                bool isClassName,
-                                TypeTy *ObjectTypePtr) {
+ParsedType Sema::getTypeName(IdentifierInfo &II, SourceLocation NameLoc,
+                             Scope *S, CXXScopeSpec *SS,
+                             bool isClassName,
+                             ParsedType ObjectTypePtr) {
   // Determine where we will perform name lookup.
   DeclContext *LookupCtx = 0;
   if (ObjectTypePtr) {
-    QualType ObjectType = QualType::getFromOpaquePtr(ObjectTypePtr);
+    QualType ObjectType = ObjectTypePtr.get();
     if (ObjectType->isRecordType())
       LookupCtx = computeDeclContext(ObjectType);
   } else if (SS && SS->isNotEmpty()) {
@@ -84,22 +84,22 @@
         // We therefore do not perform any name lookup if the result would
         // refer to a member of an unknown specialization.
         if (!isClassName)
-          return 0;
+          return ParsedType();
         
         // We know from the grammar that this name refers to a type,
         // so build a dependent node to describe the type.
-        return CheckTypenameType(ETK_None,
-                                 (NestedNameSpecifier *)SS->getScopeRep(), II,
-                                 SourceLocation(), SS->getRange(), NameLoc
-                                 ).getAsOpaquePtr();
+        QualType T =
+          CheckTypenameType(ETK_None, SS->getScopeRep(), II,
+                            SourceLocation(), SS->getRange(), NameLoc);
+        return ParsedType::make(T);
       }
       
-      return 0;
+      return ParsedType();
     }
     
     if (!LookupCtx->isDependentContext() &&
         RequireCompleteDeclContext(*SS, LookupCtx))
-      return 0;
+      return ParsedType();
   }
 
   // FIXME: LookupNestedNameSpecifierName isn't the right kind of
@@ -135,7 +135,7 @@
   case LookupResult::FoundOverloaded:
   case LookupResult::FoundUnresolvedValue:
     Result.suppressDiagnostics();
-    return 0;
+    return ParsedType();
 
   case LookupResult::Ambiguous:
     // Recover from type-hiding ambiguities by hiding the type.  We'll
@@ -145,7 +145,7 @@
     // that only makes sense if the identifier was treated like a type.
     if (Result.getAmbiguityKind() == LookupResult::AmbiguousTagHiding) {
       Result.suppressDiagnostics();
-      return 0;
+      return ParsedType();
     }
 
     // Look to see if we have a type anywhere in the list of results.
@@ -167,7 +167,7 @@
       // will produce the ambiguity, or will complain that it expected
       // a type name.
       Result.suppressDiagnostics();
-      return 0;
+      return ParsedType();
     }
 
     // We found a type within the ambiguous lookup; diagnose the
@@ -198,10 +198,10 @@
   } else {
     // If it's not plausibly a type, suppress diagnostics.
     Result.suppressDiagnostics();
-    return 0;
+    return ParsedType();
   }
 
-  return T.getAsOpaquePtr();
+  return ParsedType::make(T);
 }
 
 /// isTagName() - This method is called *for error recovery purposes only*
@@ -232,9 +232,9 @@
                                    SourceLocation IILoc,
                                    Scope *S,
                                    CXXScopeSpec *SS,
-                                   TypeTy *&SuggestedType) {
+                                   ParsedType &SuggestedType) {
   // We don't have anything to suggest (yet).
-  SuggestedType = 0;
+  SuggestedType = ParsedType();
   
   // There may have been a typo in the name of the type. Look up typo
   // results, in case we have something that we can suggest.
@@ -282,7 +282,7 @@
     TemplateTy TemplateResult;
     bool MemberOfUnknownSpecialization;
     if (isTemplateName(S, SS ? *SS : EmptySS, /*hasTemplateKeyword=*/false,
-                       Name, 0, true, TemplateResult,
+                       Name, ParsedType(), true, TemplateResult,
                        MemberOfUnknownSpecialization) == TNK_Type_template) {
       TemplateName TplName = TemplateResult.getAsVal<TemplateName>();
       Diag(IILoc, diag::err_template_missing_args) << TplName;
@@ -1594,7 +1594,7 @@
       DS.getTypeSpecType() == DeclSpec::TST_struct ||
       DS.getTypeSpecType() == DeclSpec::TST_union ||
       DS.getTypeSpecType() == DeclSpec::TST_enum) {
-    TagD = static_cast<Decl *>(DS.getTypeRep());
+    TagD = DS.getRepAsDecl();
 
     if (!TagD) // We probably had an error
       return 0;
@@ -2123,11 +2123,10 @@
   switch (DS.getTypeSpecType()) {
   case DeclSpec::TST_typename:
   case DeclSpec::TST_typeofType:
-  case DeclSpec::TST_typeofExpr:
   case DeclSpec::TST_decltype: {
     // Grab the type from the parser.
     TypeSourceInfo *TSI = 0;
-    QualType T = S.GetTypeFromParser(DS.getTypeRep(), &TSI);
+    QualType T = S.GetTypeFromParser(DS.getRepAsType(), &TSI);
     if (T.isNull() || !T->isDependentType()) break;
 
     // Make sure there's a type source info.  This isn't really much
@@ -2141,8 +2140,16 @@
     if (!TSI) return true;
 
     // Store the new type back in the decl spec.
-    QualType LocType = S.CreateLocInfoType(TSI->getType(), TSI);
-    DS.UpdateTypeRep(LocType.getAsOpaquePtr());
+    ParsedType LocType = S.CreateParsedType(TSI->getType(), TSI);
+    DS.UpdateTypeRep(LocType);
+    break;
+  }
+
+  case DeclSpec::TST_typeofExpr: {
+    Expr *E = DS.getRepAsExpr();
+    OwningExprResult Result = S.RebuildExprInCurrentInstantiation(E);
+    if (Result.isInvalid()) return true;
+    DS.UpdateExprRep(Result.get());
     break;
   }
 
@@ -4478,13 +4485,13 @@
   }
 }
 
-Sema::DeclGroupPtrTy Sema::FinalizeDeclaratorGroup(Scope *S, const DeclSpec &DS,
-                                                   Decl **Group,
-                                                   unsigned NumDecls) {
+Sema::DeclGroupPtrTy
+Sema::FinalizeDeclaratorGroup(Scope *S, const DeclSpec &DS,
+                              Decl **Group, unsigned NumDecls) {
   llvm::SmallVector<Decl*, 8> Decls;
 
   if (DS.isTypeSpecOwned())
-    Decls.push_back((Decl*)DS.getTypeRep());
+    Decls.push_back(DS.getRepAsDecl());
 
   for (unsigned i = 0; i != NumDecls; ++i)
     if (Decl *D = Group[i])

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=111901&r1=111900&r2=111901&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Tue Aug 24 00:47:05 2010
@@ -291,13 +291,13 @@
   if (!II)
     II = &S.Context.Idents.get("id");
   
-  Sema::TypeTy *TypeRep = S.getTypeName(*II, Attr.getLoc(), 
+  ParsedType TypeRep = S.getTypeName(*II, Attr.getLoc(), 
                         S.getScopeForContext(d->getDeclContext()->getParent()));
   if (!TypeRep) {
     S.Diag(Attr.getLoc(), diag::err_iboutletcollection_type) << II;
     return;
   }
-  QualType QT(QualType::getFromOpaquePtr(TypeRep));
+  QualType QT = TypeRep.get();
   // Diagnose use of non-object type in iboutletcollection attribute.
   // FIXME. Gnu attribute extension ignores use of builtin types in
   // attributes. So, __attribute__((iboutletcollection(char))) will be

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=111901&r1=111900&r2=111901&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Tue Aug 24 00:47:05 2010
@@ -584,7 +584,7 @@
 Sema::BaseResult
 Sema::ActOnBaseSpecifier(Decl *classdecl, SourceRange SpecifierRange,
                          bool Virtual, AccessSpecifier Access,
-                         TypeTy *basetype, SourceLocation BaseLoc) {
+                         ParsedType basetype, SourceLocation BaseLoc) {
   if (!classdecl)
     return true;
 
@@ -906,7 +906,7 @@
     isFunc = true;
   else if (D.getNumTypeObjects() == 0 &&
            D.getDeclSpec().getTypeSpecType() == DeclSpec::TST_typename) {
-    QualType TDType = GetTypeFromParser(DS.getTypeRep());
+    QualType TDType = GetTypeFromParser(DS.getRepAsType());
     isFunc = TDType->isFunctionType();
   }
 
@@ -1058,7 +1058,7 @@
                           Scope *S,
                           CXXScopeSpec &SS,
                           IdentifierInfo *MemberOrBase,
-                          TypeTy *TemplateTypeTy,
+                          ParsedType TemplateTypeTy,
                           SourceLocation IdLoc,
                           SourceLocation LParenLoc,
                           ExprTy **Args, unsigned NumArgs,

Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=111901&r1=111900&r2=111901&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Tue Aug 24 00:47:05 2010
@@ -1466,7 +1466,7 @@
 Decl *Sema::ActOnMethodDeclaration(
     SourceLocation MethodLoc, SourceLocation EndLoc,
     tok::TokenKind MethodType, Decl *ClassDecl,
-    ObjCDeclSpec &ReturnQT, TypeTy *ReturnType,
+    ObjCDeclSpec &ReturnQT, ParsedType ReturnType,
     Selector Sel,
     // optional arguments. The number of types/arguments is obtained
     // from the Sel.getNumArgs().

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=111901&r1=111900&r2=111901&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Aug 24 00:47:05 2010
@@ -2215,7 +2215,7 @@
 
   if (isType) {
     TypeSourceInfo *TInfo;
-    (void) GetTypeFromParser(TyOrEx, &TInfo);
+    (void) GetTypeFromParser(ParsedType::getFromOpaquePtr(TyOrEx), &TInfo);
     return CreateSizeOfAlignOfExpr(TInfo, OpLoc, isSizeof, ArgRange);
   }
 
@@ -3792,7 +3792,7 @@
 }
 
 Action::OwningExprResult
-Sema::ActOnCompoundLiteral(SourceLocation LParenLoc, TypeTy *Ty,
+Sema::ActOnCompoundLiteral(SourceLocation LParenLoc, ParsedType Ty,
                            SourceLocation RParenLoc, Expr *InitExpr) {
   assert((Ty != 0) && "ActOnCompoundLiteral(): missing type");
   // FIXME: put back this assert when initializers are worked out.
@@ -4047,7 +4047,7 @@
 }
 
 Action::OwningExprResult
-Sema::ActOnCastExpr(Scope *S, SourceLocation LParenLoc, TypeTy *Ty,
+Sema::ActOnCastExpr(Scope *S, SourceLocation LParenLoc, ParsedType Ty,
                     SourceLocation RParenLoc, Expr *castExpr) {
   assert((Ty != 0) && (castExpr != 0) &&
          "ActOnCastExpr(): missing type or expr");
@@ -4148,7 +4148,7 @@
 Action::OwningExprResult Sema::ActOnParenOrParenListExpr(SourceLocation L,
                                                   SourceLocation R,
                                                   MultiExprArg Val,
-                                                  TypeTy *TypeOfCast) {
+                                                  ParsedType TypeOfCast) {
   unsigned nexprs = Val.size();
   Expr **exprs = reinterpret_cast<Expr**>(Val.release());
   assert((exprs != 0) && "ActOnParenOrParenListExpr() missing expr list");
@@ -6988,7 +6988,7 @@
 Sema::OwningExprResult Sema::ActOnBuiltinOffsetOf(Scope *S,
                                                   SourceLocation BuiltinLoc,
                                                   SourceLocation TypeLoc,
-                                                  TypeTy *argty,
+                                                  ParsedType argty,
                                                   OffsetOfComponent *CompPtr,
                                                   unsigned NumComponents,
                                                   SourceLocation RPLoc) {
@@ -7007,7 +7007,7 @@
 
 
 Sema::OwningExprResult Sema::ActOnTypesCompatibleExpr(SourceLocation BuiltinLoc,
-                                                      TypeTy *arg1,TypeTy *arg2,
+                                                      ParsedType arg1,ParsedType arg2,
                                                       SourceLocation RPLoc) {
   TypeSourceInfo *argTInfo1;
   QualType argT1 = GetTypeFromParser(arg1, &argTInfo1);
@@ -7297,7 +7297,7 @@
 }
 
 Sema::OwningExprResult Sema::ActOnVAArg(SourceLocation BuiltinLoc,
-                                        Expr *expr, TypeTy *type,
+                                        Expr *expr, ParsedType type,
                                         SourceLocation RPLoc) {
   TypeSourceInfo *TInfo;
   QualType T = GetTypeFromParser(type, &TInfo);

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=111901&r1=111900&r2=111901&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Tue Aug 24 00:47:05 2010
@@ -27,12 +27,12 @@
 #include "llvm/ADT/STLExtras.h"
 using namespace clang;
 
-Action::TypeTy *Sema::getDestructorName(SourceLocation TildeLoc,
-                                        IdentifierInfo &II, 
-                                        SourceLocation NameLoc,
-                                        Scope *S, CXXScopeSpec &SS,
-                                        TypeTy *ObjectTypePtr,
-                                        bool EnteringContext) {
+ParsedType Sema::getDestructorName(SourceLocation TildeLoc,
+                                   IdentifierInfo &II, 
+                                   SourceLocation NameLoc,
+                                   Scope *S, CXXScopeSpec &SS,
+                                   ParsedType ObjectTypePtr,
+                                   bool EnteringContext) {
   // Determine where to perform name lookup.
 
   // FIXME: This area of the standard is very messy, and the current
@@ -149,7 +149,7 @@
 
     // FIXME: Should we be suppressing ambiguities here?
     if (Found.isAmbiguous())
-      return 0;
+      return ParsedType();
 
     if (TypeDecl *Type = Found.getAsSingle<TypeDecl>()) {
       QualType T = Context.getTypeDeclType(Type);
@@ -158,7 +158,7 @@
           Context.hasSameUnqualifiedType(T, SearchType)) {
         // We found our type!
 
-        return T.getAsOpaquePtr();
+        return ParsedType::make(T);
       }
     }
 
@@ -191,7 +191,7 @@
               = dyn_cast<ClassTemplateSpecializationDecl>(Record->getDecl())) {
           if (Spec->getSpecializedTemplate()->getCanonicalDecl() ==
                 Template->getCanonicalDecl())
-            return MemberOfType.getAsOpaquePtr();
+            return ParsedType::make(MemberOfType);
         }
 
         continue;
@@ -210,7 +210,7 @@
         // specialized.
         if (TemplateDecl *SpecTemplate = SpecName.getAsTemplateDecl()) {
           if (SpecTemplate->getCanonicalDecl() == Template->getCanonicalDecl())
-            return MemberOfType.getAsOpaquePtr();
+            return ParsedType::make(MemberOfType);
 
           continue;
         }
@@ -221,7 +221,7 @@
                                     = SpecName.getAsDependentTemplateName()) {
           if (DepTemplate->isIdentifier() &&
               DepTemplate->getIdentifier() == Template->getIdentifier())
-            return MemberOfType.getAsOpaquePtr();
+            return ParsedType::make(MemberOfType);
 
           continue;
         }
@@ -242,8 +242,10 @@
       Range = SourceRange(NameLoc);
     }
 
-    return CheckTypenameType(ETK_None, NNS, II, SourceLocation(),
-                             Range, NameLoc).getAsOpaquePtr();
+    QualType T = CheckTypenameType(ETK_None, NNS, II,
+                                   SourceLocation(),
+                                   Range, NameLoc);
+    return ParsedType::make(T);
   }
 
   if (ObjectTypePtr)
@@ -252,7 +254,7 @@
   else
     Diag(NameLoc, diag::err_destructor_class_name);
 
-  return 0;
+  return ParsedType();
 }
 
 /// \brief Build a C++ typeid expression with a type operand.
@@ -350,7 +352,8 @@
   if (isType) {
     // The operand is a type; handle it as such.
     TypeSourceInfo *TInfo = 0;
-    QualType T = GetTypeFromParser(TyOrExpr, &TInfo);
+    QualType T = GetTypeFromParser(ParsedType::getFromOpaquePtr(TyOrExpr),
+                                   &TInfo);
     if (T.isNull())
       return ExprError();
     
@@ -480,7 +483,7 @@
 /// or class type construction ("ClassType(x,y,z)")
 /// or creation of a value-initialized type ("int()").
 Action::OwningExprResult
-Sema::ActOnCXXTypeConstructExpr(SourceRange TypeRange, TypeTy *TypeRep,
+Sema::ActOnCXXTypeConstructExpr(SourceRange TypeRange, ParsedType TypeRep,
                                 SourceLocation LParenLoc,
                                 MultiExprArg exprs,
                                 SourceLocation *CommaLocs,
@@ -1922,7 +1925,7 @@
 Sema::OwningExprResult Sema::ActOnUnaryTypeTrait(UnaryTypeTrait OTT,
                                                  SourceLocation KWLoc,
                                                  SourceLocation LParen,
-                                                 TypeTy *Ty,
+                                                 ParsedType Ty,
                                                  SourceLocation RParen) {
   QualType T = GetTypeFromParser(Ty);
 
@@ -2678,7 +2681,7 @@
 
 Sema::OwningExprResult
 Sema::ActOnStartCXXMemberReference(Scope *S, Expr *Base, SourceLocation OpLoc,
-                                   tok::TokenKind OpKind, TypeTy *&ObjectType,
+                                   tok::TokenKind OpKind, ParsedType &ObjectType,
                                    bool &MayBePseudoDestructor) {
   // Since this might be a postfix expression, get rid of ParenListExprs.
   OwningExprResult Result = MaybeConvertParenListExprToParenExpr(S, Base);
@@ -2695,7 +2698,7 @@
       if (const PointerType *Ptr = BaseType->getAs<PointerType>())
         BaseType = Ptr->getPointeeType();
     
-    ObjectType = BaseType.getAsOpaquePtr();
+    ObjectType = ParsedType::make(BaseType);
     MayBePseudoDestructor = true;
     return Owned(Base);
   }
@@ -2741,7 +2744,7 @@
     //
     // This also indicates that we should be parsing a
     // pseudo-destructor-name.
-    ObjectType = 0;
+    ObjectType = ParsedType();
     MayBePseudoDestructor = true;
     return Owned(Base);
   }
@@ -2757,7 +2760,7 @@
   //   unqualified-id, and the type of the object expression is of a class
   //   type C (or of pointer to a class type C), the unqualified-id is looked
   //   up in the scope of class C. [...]
-  ObjectType = BaseType.getAsOpaquePtr();
+  ObjectType = ParsedType::make(BaseType);
   return move(Base);
 }
 
@@ -2909,12 +2912,12 @@
 
   // Compute the object type that we should use for name lookup purposes. Only
   // record types and dependent types matter.
-  void *ObjectTypePtrForLookup = 0;
+  ParsedType ObjectTypePtrForLookup;
   if (!SS.isSet()) {
-    ObjectTypePtrForLookup = const_cast<RecordType*>(
-                                               ObjectType->getAs<RecordType>());
-    if (!ObjectTypePtrForLookup && ObjectType->isDependentType())
-      ObjectTypePtrForLookup = Context.DependentTy.getAsOpaquePtr();
+    if (const Type *T = ObjectType->getAs<RecordType>())
+      ObjectTypePtrForLookup = ParsedType::make(QualType(T, 0));
+    else if (ObjectType->isDependentType())
+      ObjectTypePtrForLookup = ParsedType::make(Context.DependentTy);
   }
   
   // Convert the name of the type being destructed (following the ~) into a 
@@ -2923,9 +2926,9 @@
   TypeSourceInfo *DestructedTypeInfo = 0;
   PseudoDestructorTypeStorage Destructed;
   if (SecondTypeName.getKind() == UnqualifiedId::IK_Identifier) {
-    TypeTy *T = getTypeName(*SecondTypeName.Identifier, 
-                            SecondTypeName.StartLocation,
-                            S, &SS, true, ObjectTypePtrForLookup);
+    ParsedType T = getTypeName(*SecondTypeName.Identifier, 
+                               SecondTypeName.StartLocation,
+                               S, &SS, true, ObjectTypePtrForLookup);
     if (!T && 
         ((SS.isSet() && !computeDeclContext(SS, false)) ||
          (!SS.isSet() && ObjectType->isDependentType()))) {
@@ -2979,9 +2982,9 @@
   if (FirstTypeName.getKind() == UnqualifiedId::IK_TemplateId || 
       FirstTypeName.Identifier) {
     if (FirstTypeName.getKind() == UnqualifiedId::IK_Identifier) {
-      TypeTy *T = getTypeName(*FirstTypeName.Identifier, 
-                              FirstTypeName.StartLocation,
-                              S, &SS, false, ObjectTypePtrForLookup);
+      ParsedType T = getTypeName(*FirstTypeName.Identifier, 
+                                 FirstTypeName.StartLocation,
+                                 S, &SS, false, ObjectTypePtrForLookup);
       if (!T) {
         Diag(FirstTypeName.StartLocation, 
              diag::err_pseudo_dtor_destructor_non_type)

Modified: cfe/trunk/lib/Sema/SemaExprObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprObjC.cpp?rev=111901&r1=111900&r2=111901&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprObjC.cpp Tue Aug 24 00:47:05 2010
@@ -135,7 +135,7 @@
 Sema::ExprResult Sema::ParseObjCEncodeExpression(SourceLocation AtLoc,
                                                  SourceLocation EncodeLoc,
                                                  SourceLocation LParenLoc,
-                                                 TypeTy *ty,
+                                                 ParsedType ty,
                                                  SourceLocation RParenLoc) {
   // FIXME: Preserve type source info ?
   TypeSourceInfo *TInfo;
@@ -531,8 +531,8 @@
                                                SourceLocation NameLoc,
                                                bool IsSuper,
                                                bool HasTrailingDot,
-                                               TypeTy *&ReceiverType) {
-  ReceiverType = 0;
+                                               ParsedType &ReceiverType) {
+  ReceiverType = ParsedType();
 
   // If the identifier is "super" and there is no trailing dot, we're
   // messaging super.
@@ -579,7 +579,7 @@
     //  We have a class message, and T is the type we're
     //  messaging. Build source-location information for it.
     TypeSourceInfo *TSInfo = Context.getTrivialTypeSourceInfo(T, NameLoc);
-    ReceiverType = CreateLocInfoType(T, TSInfo).getAsOpaquePtr();
+    ReceiverType = CreateParsedType(T, TSInfo);
     return ObjCClassMessage;
   }
   }
@@ -606,7 +606,7 @@
 
         QualType T = Context.getObjCInterfaceType(Class);
         TypeSourceInfo *TSInfo = Context.getTrivialTypeSourceInfo(T, NameLoc);
-        ReceiverType = CreateLocInfoType(T, TSInfo).getAsOpaquePtr();
+        ReceiverType = CreateParsedType(T, TSInfo);
         return ObjCClassMessage;
       }
     } else if (Result.empty() && Corrected.getAsIdentifierInfo() &&
@@ -780,7 +780,7 @@
 // ArgExprs is optional - if it is present, the number of expressions
 // is obtained from Sel.getNumArgs().
 Sema::OwningExprResult Sema::ActOnClassMessage(Scope *S, 
-                                               TypeTy *Receiver,
+                                               ParsedType Receiver,
                                                Selector Sel,
                                                SourceLocation LBracLoc,
                                                SourceLocation SelectorLoc,

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=111901&r1=111900&r2=111901&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Tue Aug 24 00:47:05 2010
@@ -104,7 +104,7 @@
                                       CXXScopeSpec &SS,
                                       bool hasTemplateKeyword,
                                       UnqualifiedId &Name,
-                                      TypeTy *ObjectTypePtr,
+                                      ParsedType ObjectTypePtr,
                                       bool EnteringContext,
                                       TemplateTy &TemplateResult,
                                       bool &MemberOfUnknownSpecialization) {
@@ -131,7 +131,7 @@
     return TNK_Non_template;
   }
 
-  QualType ObjectType = QualType::getFromOpaquePtr(ObjectTypePtr);
+  QualType ObjectType = ObjectTypePtr.get();
 
   LookupResult R(*this, TName, Name.getSourceRange().getBegin(), 
                  LookupOrdinaryName);
@@ -472,7 +472,7 @@
                                SourceLocation ParamNameLoc,
                                unsigned Depth, unsigned Position,
                                SourceLocation EqualLoc,
-                               TypeTy *DefaultArg) {
+                               ParsedType DefaultArg) {
   assert(S->isTemplateParamScope() &&
          "Template type parameter not in template parameter scope!");
   bool Invalid = false;
@@ -1540,7 +1540,7 @@
   for (unsigned i = 0, e = TL.getNumArgs(); i != e; ++i)
     TL.setArgLocInfo(i, TemplateArgs[i].getLocInfo());
 
-  return CreateLocInfoType(Result, DI).getAsOpaquePtr();
+  return CreateParsedType(Result, DI);
 }
 
 Sema::TypeResult Sema::ActOnTagTemplateIdType(TypeResult TypeResult,
@@ -1575,7 +1575,7 @@
     = TypeWithKeyword::getKeywordForTagTypeKind(TagKind);
   QualType ElabType = Context.getElaboratedType(Keyword, /*NNS=*/0, Type);
 
-  return ElabType.getAsOpaquePtr();
+  return ParsedType::make(ElabType);
 }
 
 Sema::OwningExprResult Sema::BuildTemplateIdExpr(const CXXScopeSpec &SS,
@@ -1661,7 +1661,7 @@
                                                   SourceLocation TemplateKWLoc,
                                                   CXXScopeSpec &SS,
                                                   UnqualifiedId &Name,
-                                                  TypeTy *ObjectType,
+                                                  ParsedType ObjectType,
                                                   bool EnteringContext,
                                                   TemplateTy &Result) {
   if (TemplateKWLoc.isValid() && S && !S->getTemplateParamParent() &&
@@ -1673,7 +1673,7 @@
   if (SS.isSet())
     LookupCtx = computeDeclContext(SS, EnteringContext);
   if (!LookupCtx && ObjectType)
-    LookupCtx = computeDeclContext(QualType::getFromOpaquePtr(ObjectType));
+    LookupCtx = computeDeclContext(ObjectType.get());
   if (LookupCtx) {
     // C++0x [temp.names]p5:
     //   If a name prefixed by the keyword template is not the name of
@@ -5224,7 +5224,7 @@
   }
 
   ElaboratedTypeKeyword Kwd = TypeWithKeyword::getKeywordForTagTypeKind(Kind);
-  return Context.getDependentNameType(Kwd, NNS, Name).getAsOpaquePtr();
+  return ParsedType::make(Context.getDependentNameType(Kwd, NNS, Name));
 }
 
 Sema::TypeResult
@@ -5259,13 +5259,13 @@
     cast<TypeSpecTypeLoc>(TL.getNamedTypeLoc()).setNameLoc(IdLoc);
   }
   
-  return CreateLocInfoType(T, TSI).getAsOpaquePtr();
+  return CreateParsedType(T, TSI);
 }
 
 Sema::TypeResult
 Sema::ActOnTypenameType(Scope *S, SourceLocation TypenameLoc, 
                         const CXXScopeSpec &SS, SourceLocation TemplateLoc, 
-                        TypeTy *Ty) {
+                        ParsedType Ty) {
   if (TypenameLoc.isValid() && S && !S->getTemplateParamParent() &&
       !getLangOptions().CPlusPlus0x)
     Diag(TypenameLoc, diag::ext_typename_outside_of_template)
@@ -5296,7 +5296,7 @@
     TL.setQualifierRange(SS.getRange());
 
     TypeSourceInfo *TSI = Builder.getTypeSourceInfo(Context, T);
-    return CreateLocInfoType(T, TSI).getAsOpaquePtr();
+    return CreateParsedType(T, TSI);
   }
 
   // TODO: it's really silly that we make a template specialization
@@ -5327,7 +5327,7 @@
   }
   TL.setKeywordLoc(TypenameLoc);
   TL.setQualifierRange(SS.getRange());
-  return CreateLocInfoType(T, TSI).getAsOpaquePtr();
+  return CreateParsedType(T, TSI);
 }
 
 /// \brief Build the type that describes a C++ typename specifier,
@@ -5485,6 +5485,12 @@
   return Rebuilder.TransformType(T);
 }
 
+OwningExprResult Sema::RebuildExprInCurrentInstantiation(Expr *E) {
+  CurrentInstantiationRebuilder Rebuilder(*this, E->getExprLoc(),
+                                          DeclarationName());
+  return Rebuilder.TransformExpr(E);
+}
+
 bool Sema::RebuildNestedNameSpecifierInCurrentInstantiation(CXXScopeSpec &SS) {
   if (SS.isInvalid()) return true;
 

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=111901&r1=111900&r2=111901&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Tue Aug 24 00:47:05 2010
@@ -265,8 +265,7 @@
   case DeclSpec::TST_enum:
   case DeclSpec::TST_union:
   case DeclSpec::TST_struct: {
-    TypeDecl *D 
-      = dyn_cast_or_null<TypeDecl>(static_cast<Decl *>(DS.getTypeRep()));
+    TypeDecl *D = dyn_cast_or_null<TypeDecl>(DS.getRepAsDecl());
     if (!D) {
       // This can happen in C++ with ambiguous lookups.
       Result = Context.IntTy;
@@ -298,7 +297,7 @@
     assert(DS.getTypeSpecWidth() == 0 && DS.getTypeSpecComplex() == 0 &&
            DS.getTypeSpecSign() == 0 &&
            "Can't handle qualifiers on typedef names yet!");
-    Result = TheSema.GetTypeFromParser(DS.getTypeRep());
+    Result = TheSema.GetTypeFromParser(DS.getRepAsType());
     if (Result.isNull())
       TheDeclarator.setInvalidType(true);
     else if (DeclSpec::ProtocolQualifierListTy PQ
@@ -337,13 +336,13 @@
   }
   case DeclSpec::TST_typeofType:
     // FIXME: Preserve type source info.
-    Result = TheSema.GetTypeFromParser(DS.getTypeRep());
+    Result = TheSema.GetTypeFromParser(DS.getRepAsType());
     assert(!Result.isNull() && "Didn't get a type for typeof?");
     // TypeQuals handled by caller.
     Result = Context.getTypeOfType(Result);
     break;
   case DeclSpec::TST_typeofExpr: {
-    Expr *E = static_cast<Expr *>(DS.getTypeRep());
+    Expr *E = DS.getRepAsExpr();
     assert(E && "Didn't get an expression for typeof?");
     // TypeQuals handled by caller.
     Result = TheSema.BuildTypeofExprType(E);
@@ -354,7 +353,7 @@
     break;
   }
   case DeclSpec::TST_decltype: {
-    Expr *E = static_cast<Expr *>(DS.getTypeRep());
+    Expr *E = DS.getRepAsExpr();
     assert(E && "Didn't get an expression for decltype?");
     // TypeQuals handled by caller.
     Result = TheSema.BuildDecltypeType(E);
@@ -926,8 +925,8 @@
   return Context.getBlockPointerType(T);
 }
 
-QualType Sema::GetTypeFromParser(TypeTy *Ty, TypeSourceInfo **TInfo) {
-  QualType QT = QualType::getFromOpaquePtr(Ty);
+QualType Sema::GetTypeFromParser(ParsedType Ty, TypeSourceInfo **TInfo) {
+  QualType QT = Ty.get();
   if (QT.isNull()) {
     if (TInfo) *TInfo = 0;
     return QualType();
@@ -969,7 +968,7 @@
     T = ConvertDeclSpecToType(*this, D, FnAttrsFromDeclSpec);
     
     if (!D.isInvalidType() && D.getDeclSpec().isTypeSpecOwned()) {
-      TagDecl* Owned = cast<TagDecl>((Decl *)D.getDeclSpec().getTypeRep());
+      TagDecl* Owned = cast<TagDecl>(D.getDeclSpec().getRepAsDecl());
       // Owned is embedded if it was defined here, or if it is the
       // very first (i.e., canonical) declaration of this tag type.
       Owned->setEmbeddedInDeclarator(Owned->isDefinition() ||
@@ -1188,7 +1187,7 @@
       if (getLangOptions().CPlusPlus && D.getDeclSpec().isTypeSpecOwned()) {
         // C++ [dcl.fct]p6:
         //   Types shall not be defined in return or parameter types.
-        TagDecl *Tag = cast<TagDecl>((Decl *)D.getDeclSpec().getTypeRep());
+        TagDecl *Tag = cast<TagDecl>(D.getDeclSpec().getRepAsDecl());
         if (Tag->isDefinition())
           Diag(Tag->getLocation(), diag::err_type_defined_in_result_type)
             << Context.getTypeDeclType(Tag);
@@ -1472,7 +1471,7 @@
     }
     void VisitTemplateSpecializationTypeLoc(TemplateSpecializationTypeLoc TL) {
       TypeSourceInfo *TInfo = 0;
-      Sema::GetTypeFromParser(DS.getTypeRep(), &TInfo);
+      Sema::GetTypeFromParser(DS.getRepAsType(), &TInfo);
 
       // If we got no declarator info from previous Sema routines,
       // just fill with the typespec loc.
@@ -1500,9 +1499,9 @@
       assert(DS.getTypeSpecType() == DeclSpec::TST_typeofType);
       TL.setTypeofLoc(DS.getTypeSpecTypeLoc());
       TL.setParensRange(DS.getTypeofParensRange());
-      assert(DS.getTypeRep());
+      assert(DS.getRepAsType());
       TypeSourceInfo *TInfo = 0;
-      Sema::GetTypeFromParser(DS.getTypeRep(), &TInfo);
+      Sema::GetTypeFromParser(DS.getRepAsType(), &TInfo);
       TL.setUnderlyingTInfo(TInfo);
     }
     void VisitBuiltinTypeLoc(BuiltinTypeLoc TL) {
@@ -1525,7 +1524,7 @@
         = TypeWithKeyword::getKeywordForTypeSpec(DS.getTypeSpecType());
       if (Keyword == ETK_Typename) {
         TypeSourceInfo *TInfo = 0;
-        Sema::GetTypeFromParser(DS.getTypeRep(), &TInfo);
+        Sema::GetTypeFromParser(DS.getRepAsType(), &TInfo);
         if (TInfo) {
           TL.copy(cast<ElaboratedTypeLoc>(TInfo->getTypeLoc()));
           return;
@@ -1543,7 +1542,7 @@
         = TypeWithKeyword::getKeywordForTypeSpec(DS.getTypeSpecType());
       if (Keyword == ETK_Typename) {
         TypeSourceInfo *TInfo = 0;
-        Sema::GetTypeFromParser(DS.getTypeRep(), &TInfo);
+        Sema::GetTypeFromParser(DS.getRepAsType(), &TInfo);
         if (TInfo) {
           TL.copy(cast<DependentNameTypeLoc>(TInfo->getTypeLoc()));
           return;
@@ -1563,7 +1562,7 @@
         = TypeWithKeyword::getKeywordForTypeSpec(DS.getTypeSpecType());
       if (Keyword == ETK_Typename) {
         TypeSourceInfo *TInfo = 0;
-        Sema::GetTypeFromParser(DS.getTypeRep(), &TInfo);
+        Sema::GetTypeFromParser(DS.getRepAsType(), &TInfo);
         if (TInfo) {
           TL.copy(cast<DependentTemplateSpecializationTypeLoc>(
                     TInfo->getTypeLoc()));
@@ -1668,24 +1667,21 @@
     CurrTL = CurrTL.getNextTypeLoc().getUnqualifiedLoc();
   }
   
-  TypeSpecLocFiller(D.getDeclSpec()).Visit(CurrTL);
-  
-  // We have source information for the return type that was not in the
-  // declaration specifiers; copy that information into the current type
-  // location so that it will be retained. This occurs, for example, with 
-  // a C++ conversion function, where the return type occurs within the
-  // declarator-id rather than in the declaration specifiers.
-  if (ReturnTypeInfo && D.getDeclSpec().getTypeSpecType() == TST_unspecified) {
+  // If we have different source information for the return type, use
+  // that.  This really only applies to C++ conversion functions.
+  if (ReturnTypeInfo) {
     TypeLoc TL = ReturnTypeInfo->getTypeLoc();
     assert(TL.getFullDataSize() == CurrTL.getFullDataSize());
     memcpy(CurrTL.getOpaqueData(), TL.getOpaqueData(), TL.getFullDataSize());
+  } else {
+    TypeSpecLocFiller(D.getDeclSpec()).Visit(CurrTL);
   }
       
   return TInfo;
 }
 
 /// \brief Create a LocInfoType to hold the given QualType and TypeSourceInfo.
-QualType Sema::CreateLocInfoType(QualType T, TypeSourceInfo *TInfo) {
+ParsedType Sema::CreateParsedType(QualType T, TypeSourceInfo *TInfo) {
   // FIXME: LocInfoTypes are "transient", only needed for passing to/from Parser
   // and Sema during declaration parsing. Try deallocating/caching them when
   // it's appropriate, instead of allocating them and keeping them around.
@@ -1693,7 +1689,7 @@
   new (LocT) LocInfoType(T, TInfo);
   assert(LocT->getTypeClass() != T->getTypeClass() &&
          "LocInfoType's TypeClass conflicts with an existing Type class");
-  return QualType(LocT, 0);
+  return ParsedType::make(QualType(LocT, 0));
 }
 
 void LocInfoType::getAsStringInternal(std::string &Str,
@@ -1727,8 +1723,7 @@
         << Context.getTypeDeclType(OwnedTag);
   }
 
-  T = CreateLocInfoType(T, TInfo);
-  return T.getAsOpaquePtr();
+  return CreateParsedType(T, TInfo);
 }
 
 

Modified: cfe/trunk/lib/Sema/TreeTransform.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=111901&r1=111900&r2=111901&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/TreeTransform.h (original)
+++ cfe/trunk/lib/Sema/TreeTransform.h Tue Aug 24 00:47:05 2010
@@ -1500,7 +1500,7 @@
                                                 Expr *Sub,
                                                 SourceLocation RParenLoc) {
     return getSema().ActOnCXXTypeConstructExpr(TypeRange,
-                                               TInfo->getType().getAsOpaquePtr(),
+                                             ParsedType::make(TInfo->getType()),
                                                LParenLoc,
                                          Sema::MultiExprArg(getSema(), &Sub, 1),
                                                /*CommaLocs=*/0,
@@ -1572,7 +1572,7 @@
                                                QualType T,
                                                SourceLocation RParenLoc) {
     return getSema().ActOnCXXTypeConstructExpr(SourceRange(TypeStartLoc),
-                                               T.getAsOpaquePtr(), LParenLoc,
+                                               ParsedType::make(T), LParenLoc,
                                                MultiExprArg(getSema(), 0, 0),
                                                0, RParenLoc);
   }
@@ -1630,7 +1630,7 @@
                                          QualType T,
                                          SourceLocation RParenLoc) {
     return getSema().ActOnUnaryTypeTrait(Trait, StartLoc, LParenLoc,
-                                         T.getAsOpaquePtr(), RParenLoc);
+                                         ParsedType::make(T), RParenLoc);
   }
 
   /// \brief Build a new (previously unresolved) declaration reference
@@ -1696,7 +1696,7 @@
                                                  SourceLocation *Commas,
                                                  SourceLocation RParenLoc) {
     return getSema().ActOnCXXTypeConstructExpr(SourceRange(TypeBeginLoc),
-                                               T.getAsOpaquePtr(),
+                                               ParsedType::make(T),
                                                LParenLoc,
                                                move(Args),
                                                Commas,
@@ -1715,7 +1715,7 @@
                                                      SourceLocation RParenLoc) {
     return getSema().ActOnCXXTypeConstructExpr(SourceRange(TypeBeginLoc,
                                                            /*FIXME*/LParenLoc),
-                                               T.getAsOpaquePtr(),
+                                               ParsedType::make(T),
                                                LParenLoc,
                                                move(Args),
                                                Commas,
@@ -5391,7 +5391,7 @@
   if (Base.isInvalid())
     return SemaRef.ExprError();
 
-  Sema::TypeTy *ObjectTypePtr = 0;
+  ParsedType ObjectTypePtr;
   bool MayBePseudoDestructor = false;
   Base = SemaRef.ActOnStartCXXMemberReference(0, Base.get(), 
                                               E->getOperatorLoc(),
@@ -5401,7 +5401,7 @@
   if (Base.isInvalid())
     return SemaRef.ExprError();
                                               
-  QualType ObjectType = QualType::getFromOpaquePtr(ObjectTypePtr);
+  QualType ObjectType = ObjectTypePtr.get();
   NestedNameSpecifier *Qualifier
     = getDerived().TransformNestedNameSpecifier(E->getQualifier(),
                                                 E->getQualifierRange(),
@@ -5429,7 +5429,7 @@
       SS.setRange(E->getQualifierRange());
     }
     
-    Sema::TypeTy *T = SemaRef.getDestructorName(E->getTildeLoc(),
+    ParsedType T = SemaRef.getDestructorName(E->getTildeLoc(),
                                               *E->getDestroyedTypeIdentifier(),
                                                 E->getDestroyedTypeLoc(),
                                                 /*Scope=*/0,
@@ -5814,7 +5814,7 @@
       return SemaRef.ExprError();
 
     // Start the member reference and compute the object's type.
-    Sema::TypeTy *ObjectTy = 0;
+    ParsedType ObjectTy;
     bool MayBePseudoDestructor = false;
     Base = SemaRef.ActOnStartCXXMemberReference(0, Base.get(),
                                                 E->getOperatorLoc(),
@@ -5824,7 +5824,7 @@
     if (Base.isInvalid())
       return SemaRef.ExprError();
 
-    ObjectType = QualType::getFromOpaquePtr(ObjectTy);
+    ObjectType = ObjectTy.get();
     BaseType = ((Expr*) Base.get())->getType();
   } else {
     OldBase = 0;
@@ -6556,7 +6556,7 @@
                                        /*FIXME:*/getDerived().getBaseLocation(),
                                        SS,
                                        Name,
-                                       ObjectType.getAsOpaquePtr(),
+                                       ParsedType::make(ObjectType),
                                        /*EnteringContext=*/false,
                                        Template);
   return Template.template getAsVal<TemplateName>();
@@ -6579,7 +6579,7 @@
                                        /*FIXME:*/getDerived().getBaseLocation(),
                                        SS,
                                        Name,
-                                       ObjectType.getAsOpaquePtr(),
+                                       ParsedType::make(ObjectType),
                                        /*EnteringContext=*/false,
                                        Template);
   return Template.template getAsVal<TemplateName>();





More information about the cfe-commits mailing list