[cfe-commits] r61286 - in /cfe/trunk: include/clang/AST/Decl.h include/clang/AST/DeclBase.h lib/AST/Decl.cpp lib/AST/DeclSerialization.cpp
Douglas Gregor
dgregor at apple.com
Sat Dec 20 14:52:59 PST 2008
On Dec 20, 2008, at 12:56 PM, Fariborz Jahanian wrote:
> 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.
Great!
>
> +/// 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; }
I think getQualType should be removed. Instead, we add a member
function getOriginalType() to ParmVarDecl that looks like this:
QualType getOriginalType() const {
if (const ParmVarWithOriginalTypeDecl *PVD =
dyn_cast<ParmVarWithOriginalTypeDecl>(this))
return PVD->OriginalType;
return getType();
}
That way, ParmVarWithOriginalTypeDecl could be hidden almost
completely from clients, who will won't need to ever name this type
except when the parameter is originally created.
Please make sure to update classof() in ParmVarDecl to account for
this new subclass.
- Doug
More information about the cfe-commits
mailing list