[cfe-commits] r61286 - in /cfe/trunk: include/clang/AST/Decl.h include/clang/AST/DeclBase.h lib/AST/Decl.cpp lib/AST/DeclSerialization.cpp

Fariborz Jahanian fjahanian at apple.com
Sat Dec 20 12:56:13 PST 2008


Author: fjahanian
Date: Sat Dec 20 14:56:12 2008
New Revision: 61286

URL: http://llvm.org/viewvc/llvm-project?rev=61286&view=rev
Log:
introducing ParmVarWithOriginalTypeDecl class to
keep track of the original parameter decl. types.
This is work in progress.

Modified:
    cfe/trunk/include/clang/AST/Decl.h
    cfe/trunk/include/clang/AST/DeclBase.h
    cfe/trunk/lib/AST/Decl.cpp
    cfe/trunk/lib/AST/DeclSerialization.cpp

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=61286&r1=61285&r2=61286&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Sat Dec 20 14:56:12 2008
@@ -471,7 +471,7 @@
   
   /// 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 @@
   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. 
 ///

Modified: cfe/trunk/include/clang/AST/DeclBase.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclBase.h?rev=61286&r1=61285&r2=61286&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/DeclBase.h (original)
+++ cfe/trunk/include/clang/AST/DeclBase.h Sat Dec 20 14:56:12 2008
@@ -78,6 +78,7 @@
                  ImplicitParam,
                  CXXClassVar,
                  ParmVar,
+                   OriginalParmVar,
   	         NonTypeTemplateParm,
            ObjCInterface,  // [DeclContext]
            ObjCCompatibleAlias,
@@ -186,6 +187,7 @@
     case Typedef:
     case Var:
     case ParmVar:
+    case OriginalParmVar:
     case EnumConstant:
     case NonTypeTemplateParm:
     case Field:

Modified: cfe/trunk/lib/AST/Decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=61286&r1=61285&r2=61286&view=diff

==============================================================================
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Sat Dec 20 14:56:12 2008
@@ -57,6 +57,16 @@
   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, 

Modified: cfe/trunk/lib/AST/DeclSerialization.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclSerialization.cpp?rev=61286&r1=61285&r2=61286&view=diff

==============================================================================
--- cfe/trunk/lib/AST/DeclSerialization.cpp (original)
+++ cfe/trunk/lib/AST/DeclSerialization.cpp Sat Dec 20 14:56:12 2008
@@ -72,6 +72,10 @@
       Dcl = ParmVarDecl::CreateImpl(D, C);
       break;
       
+    case OriginalParmVar:
+      Dcl = ParmVarWithOriginalTypeDecl::CreateImpl(D, C);
+      break;
+      
     case Function:
       Dcl = FunctionDecl::CreateImpl(D, C);
       break;
@@ -404,6 +408,26 @@
 }
 
 //===----------------------------------------------------------------------===//
+//      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.
 //===----------------------------------------------------------------------===//
 





More information about the cfe-commits mailing list