[cfe-commits] r101550 - in /cfe/trunk/lib/Sema: Sema.h SemaExprCXX.cpp
Douglas Gregor
dgregor at apple.com
Fri Apr 16 15:17:37 PDT 2010
Author: dgregor
Date: Fri Apr 16 17:17:36 2010
New Revision: 101550
URL: http://llvm.org/viewvc/llvm-project?rev=101550&view=rev
Log:
Make Sema::BuildCXXCastArgument static, since it now only has one caller. No functionality change
Modified:
cfe/trunk/lib/Sema/Sema.h
cfe/trunk/lib/Sema/SemaExprCXX.cpp
Modified: cfe/trunk/lib/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.h?rev=101550&r1=101549&r2=101550&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/Sema.h (original)
+++ cfe/trunk/lib/Sema/Sema.h Fri Apr 16 17:17:36 2010
@@ -2113,12 +2113,6 @@
bool RequiresZeroInit = false,
bool BaseInitialization = false);
- OwningExprResult BuildCXXCastArgument(SourceLocation CastLoc,
- QualType Ty,
- CastExpr::CastKind Kind,
- CXXMethodDecl *Method,
- ExprArg Arg);
-
/// BuildCXXDefaultArgExpr - Creates a CXXDefaultArgExpr, instantiating
/// the default expr if needed.
OwningExprResult BuildCXXDefaultArgExpr(SourceLocation CallLoc,
Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=101550&r1=101549&r2=101550&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Fri Apr 16 17:17:36 2010
@@ -1487,6 +1487,44 @@
return PerformImplicitConversion(From, ToType, ICS, Action);
}
+static Sema::OwningExprResult BuildCXXCastArgument(Sema &S,
+ SourceLocation CastLoc,
+ QualType Ty,
+ CastExpr::CastKind Kind,
+ CXXMethodDecl *Method,
+ Sema::ExprArg Arg) {
+ Expr *From = Arg.takeAs<Expr>();
+
+ switch (Kind) {
+ default: assert(0 && "Unhandled cast kind!");
+ case CastExpr::CK_ConstructorConversion: {
+ ASTOwningVector<&ActionBase::DeleteExpr> ConstructorArgs(S);
+
+ if (S.CompleteConstructorCall(cast<CXXConstructorDecl>(Method),
+ Sema::MultiExprArg(S, (void **)&From, 1),
+ CastLoc, ConstructorArgs))
+ return S.ExprError();
+
+ Sema::OwningExprResult Result =
+ S.BuildCXXConstructExpr(CastLoc, Ty, cast<CXXConstructorDecl>(Method),
+ move_arg(ConstructorArgs));
+ if (Result.isInvalid())
+ return S.ExprError();
+
+ return S.MaybeBindToTemporary(Result.takeAs<Expr>());
+ }
+
+ case CastExpr::CK_UserDefinedConversion: {
+ assert(!From->getType()->isPointerType() && "Arg can't have pointer type!");
+
+ // Create an implicit call expr that calls it.
+ // FIXME: pass the FoundDecl for the user-defined conversion here
+ CXXMemberCallExpr *CE = S.BuildCXXMemberCallExpr(From, Method, Method);
+ return S.MaybeBindToTemporary(CE);
+ }
+ }
+}
+
/// PerformImplicitConversion - Perform an implicit conversion of the
/// expression From to the type ToType using the pre-computed implicit
/// conversion sequence ICS. Returns true if there was an error, false
@@ -1538,7 +1576,8 @@
}
OwningExprResult CastArg
- = BuildCXXCastArgument(From->getLocStart(),
+ = BuildCXXCastArgument(*this,
+ From->getLocStart(),
ToType.getNonReferenceType(),
CastKind, cast<CXXMethodDecl>(FD),
Owned(From));
@@ -2850,43 +2889,6 @@
return CE;
}
-Sema::OwningExprResult Sema::BuildCXXCastArgument(SourceLocation CastLoc,
- QualType Ty,
- CastExpr::CastKind Kind,
- CXXMethodDecl *Method,
- ExprArg Arg) {
- Expr *From = Arg.takeAs<Expr>();
-
- switch (Kind) {
- default: assert(0 && "Unhandled cast kind!");
- case CastExpr::CK_ConstructorConversion: {
- ASTOwningVector<&ActionBase::DeleteExpr> ConstructorArgs(*this);
-
- if (CompleteConstructorCall(cast<CXXConstructorDecl>(Method),
- MultiExprArg(*this, (void **)&From, 1),
- CastLoc, ConstructorArgs))
- return ExprError();
-
- OwningExprResult Result =
- BuildCXXConstructExpr(CastLoc, Ty, cast<CXXConstructorDecl>(Method),
- move_arg(ConstructorArgs));
- if (Result.isInvalid())
- return ExprError();
-
- return MaybeBindToTemporary(Result.takeAs<Expr>());
- }
-
- case CastExpr::CK_UserDefinedConversion: {
- assert(!From->getType()->isPointerType() && "Arg can't have pointer type!");
-
- // Create an implicit call expr that calls it.
- // FIXME: pass the FoundDecl for the user-defined conversion here
- CXXMemberCallExpr *CE = BuildCXXMemberCallExpr(From, Method, Method);
- return MaybeBindToTemporary(CE);
- }
- }
-}
-
Sema::OwningExprResult Sema::ActOnFinishFullExpr(ExprArg Arg) {
Expr *FullExpr = Arg.takeAs<Expr>();
if (FullExpr)
More information about the cfe-commits
mailing list