[cfe-commits] r79013 - in /cfe/trunk: include/clang/AST/ExprCXX.h lib/Sema/SemaDeclCXX.cpp lib/Sema/SemaExpr.cpp lib/Sema/SemaOverload.cpp lib/Sema/TreeTransform.h
Fariborz Jahanian
fjahanian at apple.com
Fri Aug 14 11:48:15 PDT 2009
On Aug 14, 2009, at 11:30 AM, Anders Carlsson wrote:
> Author: andersca
> Date: Fri Aug 14 13:30:22 2009
> New Revision: 79013
>
> URL: http://llvm.org/viewvc/llvm-project?rev=79013&view=rev
> Log:
> Make the CXXDefaultArgExpr constructor protected and add a static
> Create function.
What is the utility of declaring this static function and moving the
one liner into that?
- Fariborz
>
>
> Modified:
> cfe/trunk/include/clang/AST/ExprCXX.h
> cfe/trunk/lib/Sema/SemaDeclCXX.cpp
> cfe/trunk/lib/Sema/SemaExpr.cpp
> cfe/trunk/lib/Sema/SemaOverload.cpp
> cfe/trunk/lib/Sema/TreeTransform.h
>
> Modified: cfe/trunk/include/clang/AST/ExprCXX.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExprCXX.h?rev=79013&r1=79012&r2=79013&view=diff
>
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- cfe/trunk/include/clang/AST/ExprCXX.h (original)
> +++ cfe/trunk/include/clang/AST/ExprCXX.h Fri Aug 14 13:30:22 2009
> @@ -382,14 +382,20 @@
> /// supply arguments for all of the parameters.
> class CXXDefaultArgExpr : public Expr {
> ParmVarDecl *Param;
> +
> +protected:
> + CXXDefaultArgExpr(StmtClass SC, ParmVarDecl *param)
> + : Expr(SC, param->hasUnparsedDefaultArg() ?
> + param->getType().getNonReferenceType()
> + : param->getDefaultArg()->getType()),
> + Param(param) { }
> +
> public:
> // Param is the parameter whose default argument is used by this
> // expression.
> - explicit CXXDefaultArgExpr(ParmVarDecl *param)
> - : Expr(CXXDefaultArgExprClass,
> - param->hasUnparsedDefaultArg()? param-
> >getType().getNonReferenceType()
> - : param->getDefaultArg()-
> >getType()),
> - Param(param) { }
> + static CXXDefaultArgExpr *Create(ASTContext &C, ParmVarDecl
> *Param) {
> + return new (C) CXXDefaultArgExpr(CXXDefaultArgExprClass, Param);
> + }
>
> // Retrieve the parameter that the argument was created from.
> const ParmVarDecl *getParam() const { return Param; }
>
> Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=79013&r1=79012&r2=79013&view=diff
>
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Fri Aug 14 13:30:22 2009
> @@ -2394,7 +2394,7 @@
> for (unsigned I = 0, N = E->getNumTemporaries(); I != N; ++I)
> ExprTemporaries.push_back(E->getTemporary(I));
> }
> - Expr *Arg = new (C) CXXDefaultArgExpr(FDecl->getParamDecl(j));
> + Expr *Arg = CXXDefaultArgExpr::Create(C, FDecl->getParamDecl(j));
> Temp->setArg(j, Arg);
> }
> return Temp;
>
> Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=79013&r1=79012&r2=79013&view=diff
>
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaExpr.cpp Fri Aug 14 13:30:22 2009
> @@ -2657,7 +2657,7 @@
> }
>
> // We already type-checked the argument, so we know it works.
> - Arg = new (Context) CXXDefaultArgExpr(FDecl->getParamDecl(i));
> + Arg = CXXDefaultArgExpr::Create(Context, FDecl-
> >getParamDecl(i));
> }
>
> QualType ArgType = Arg->getType();
>
> Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=79013&r1=79012&r2=79013&view=diff
>
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaOverload.cpp Fri Aug 14 13:30:22 2009
> @@ -4531,7 +4531,7 @@
> QualType ProtoArgType = Proto->getArgType(i);
> IsError |= PerformCopyInitialization(Arg, ProtoArgType,
> "passing");
> } else {
> - Arg = new (Context) CXXDefaultArgExpr(Method->getParamDecl(i));
> + Arg = CXXDefaultArgExpr::Create(Context, Method-
> >getParamDecl(i));
> }
>
> TheCall->setArg(i + 1, Arg);
>
> Modified: cfe/trunk/lib/Sema/TreeTransform.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=79013&r1=79012&r2=79013&view=diff
>
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- cfe/trunk/lib/Sema/TreeTransform.h (original)
> +++ cfe/trunk/lib/Sema/TreeTransform.h Fri Aug 14 13:30:22 2009
> @@ -1021,7 +1021,7 @@
> /// require any semantic analysis. Subclasses may override this
> routine to
> /// provide different behavior.
> OwningExprResult RebuildCXXDefaultArgExpr(ParmVarDecl *Param) {
> - return getSema().Owned(new (getSema().Context)
> CXXDefaultArgExpr(Param));
> + return
> getSema().Owned(CXXDefaultArgExpr::Create(getSema().Context, Param));
> }
>
> /// \brief Build a new C++ zero-initialization expression.
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
More information about the cfe-commits
mailing list