]> granicus.if.org Git - clang/commitdiff
introducing ParmVarWithOriginalTypeDecl class to
authorFariborz Jahanian <fjahanian@apple.com>
Sat, 20 Dec 2008 20:56:12 +0000 (20:56 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Sat, 20 Dec 2008 20:56:12 +0000 (20:56 +0000)
keep track of the original parameter decl. types.
This is work in progress.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61286 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/Decl.h
include/clang/AST/DeclBase.h
lib/AST/Decl.cpp
lib/AST/DeclSerialization.cpp

index c3589cdfd73bacfdbdb7fb48fa6cad81042f71f4..8aaf5d6b6cd2dc254d89a575bd77abf7e295e84d 100644 (file)
@@ -471,7 +471,7 @@ class ParmVarDecl : public VarDecl {
   
   /// Default argument, if any.  [C++ Only]
   Expr *DefaultArg;
-
+protected:
   ParmVarDecl(DeclContext *DC, SourceLocation L,
               IdentifierInfo *Id, QualType T, StorageClass S,
               Expr *DefArg, ScopedDecl *PrevDecl)
@@ -509,6 +509,44 @@ protected:
   friend Decl* Decl::Create(llvm::Deserializer& D, ASTContext& C);
 };
 
+/// ParmVarWithOriginalTypeDecl - Represent a parameter to a function, when
+/// the type of the parameter has been promoted. This node represents the
+/// parameter to the function with its original type.
+///
+class ParmVarWithOriginalTypeDecl : public ParmVarDecl {
+private:
+  QualType OriginalType;
+
+  ParmVarWithOriginalTypeDecl(DeclContext *DC, SourceLocation L,
+                              IdentifierInfo *Id, QualType T, 
+                              QualType OT, StorageClass S,
+                              Expr *DefArg, ScopedDecl *PrevDecl)
+  : ParmVarDecl(DC, L, Id, T, S, DefArg, PrevDecl), OriginalType(OT) {}
+public:
+    static ParmVarWithOriginalTypeDecl *Create(ASTContext &C, DeclContext *DC,
+                               SourceLocation L,IdentifierInfo *Id,
+                               QualType T, QualType OT,
+                               StorageClass S, Expr *DefArg,
+                               ScopedDecl *PrevDecl);
+  QualType getQualType() const { return OriginalType; }
+  
+  // Implement isa/cast/dyncast/etc.
+  static bool classof(const Decl *D) { return D->getKind() == OriginalParmVar; }
+  static bool classof(const ParmVarWithOriginalTypeDecl *D) { return true; }
+    
+protected:
+  /// EmitImpl - Serialize this ParmVarWithOriginalTypeDecl. 
+  /// Called by Decl::Emit.
+  virtual void EmitImpl(llvm::Serializer& S) const;
+    
+  /// CreateImpl - Deserialize a ParmVarWithOriginalTypeDecl.  
+  /// Called by Decl::Create.
+  static ParmVarWithOriginalTypeDecl* CreateImpl(llvm::Deserializer& D, 
+                                                 ASTContext& C);
+    
+  friend Decl* Decl::Create(llvm::Deserializer& D, ASTContext& C);
+};
+  
 /// FunctionDecl - An instance of this class is created to represent a
 /// function declaration or definition. 
 ///
index 358067661629d8e60efb9858d98a74949c561a86..68a484666e73680972767af29c6817b7dbd3891f 100644 (file)
@@ -78,6 +78,7 @@ public:
                  ImplicitParam,
                  CXXClassVar,
                  ParmVar,
+                   OriginalParmVar,
                 NonTypeTemplateParm,
            ObjCInterface,  // [DeclContext]
            ObjCCompatibleAlias,
@@ -186,6 +187,7 @@ public:
     case Typedef:
     case Var:
     case ParmVar:
+    case OriginalParmVar:
     case EnumConstant:
     case NonTypeTemplateParm:
     case Field:
index be8cbe7344dc657652f4b8ae2ffe9f96029ea863..021becc85a2ee6664cb49f26982f9a57e65d2097 100644 (file)
@@ -57,6 +57,16 @@ ParmVarDecl *ParmVarDecl::Create(ASTContext &C, DeclContext *DC,
   return new (Mem) ParmVarDecl(DC, L, Id, T, S, DefArg, PrevDecl);
 }
 
+ParmVarWithOriginalTypeDecl *ParmVarWithOriginalTypeDecl::Create(
+                                 ASTContext &C, DeclContext *DC,
+                                 SourceLocation L, IdentifierInfo *Id,
+                                 QualType T, QualType OT, StorageClass S,
+                                 Expr *DefArg, ScopedDecl *PrevDecl) {
+  void *Mem = C.getAllocator().Allocate<ParmVarWithOriginalTypeDecl>();
+  return new (Mem) ParmVarWithOriginalTypeDecl(DC, L, Id, T, OT, S, 
+                                               DefArg, PrevDecl);
+}
+
 FunctionDecl *FunctionDecl::Create(ASTContext &C, DeclContext *DC,
                                    SourceLocation L, 
                                    DeclarationName N, QualType T, 
index c853b1b84c267b87ee26e897d95230f4e8758b37..c09b0edca7b58762b0377ab3cac0b7c026d66aa2 100644 (file)
@@ -72,6 +72,10 @@ Decl* Decl::Create(Deserializer& D, ASTContext& C) {
       Dcl = ParmVarDecl::CreateImpl(D, C);
       break;
       
+    case OriginalParmVar:
+      Dcl = ParmVarWithOriginalTypeDecl::CreateImpl(D, C);
+      break;
+      
     case Function:
       Dcl = FunctionDecl::CreateImpl(D, C);
       break;
@@ -403,6 +407,26 @@ ParmVarDecl* ParmVarDecl::CreateImpl(Deserializer& D, ASTContext& C) {
   return decl;
 }
 
+//===----------------------------------------------------------------------===//
+//      ParmVarWithOriginalTypeDecl Serialization.
+//===----------------------------------------------------------------------===//
+
+void ParmVarWithOriginalTypeDecl::EmitImpl(llvm::Serializer& S) const {
+  ParmVarDecl::EmitImpl(S);
+  S.Emit(OriginalType);
+}
+
+ParmVarWithOriginalTypeDecl* ParmVarWithOriginalTypeDecl::CreateImpl(
+                                              Deserializer& D, ASTContext& C) {
+  void *Mem = C.getAllocator().Allocate<ParmVarWithOriginalTypeDecl>();
+  ParmVarWithOriginalTypeDecl* decl = new (Mem)
+    ParmVarWithOriginalTypeDecl(0, SourceLocation(), NULL, QualType(), 
+                                QualType(), None, NULL, NULL);
+  
+  decl->ParmVarDecl::ReadImpl(D, C);
+  decl->OriginalType = QualType::ReadVal(D);
+  return decl;
+}
 //===----------------------------------------------------------------------===//
 //      EnumDecl Serialization.
 //===----------------------------------------------------------------------===//