forked from OSchip/llvm-project
introducing ParmVarWithOriginalTypeDecl class to
keep track of the original parameter decl. types. This is work in progress. llvm-svn: 61286
This commit is contained in:
parent
8a01b79274
commit
7664ffb954
|
@ -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.
|
||||
///
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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.
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
|
Loading…
Reference in New Issue