[cfe-commits] r83027 - in /cfe/trunk/lib/Sema: Sema.h SemaExprCXX.cpp SemaOverload.cpp
Fariborz Jahanian
fjahanian at apple.com
Mon Sep 28 16:23:40 PDT 2009
Author: fjahanian
Date: Mon Sep 28 18:23:40 2009
New Revision: 83027
URL: http://llvm.org/viewvc/llvm-project?rev=83027&view=rev
Log:
Define and use a helper method to call a type conversion
function.
Modified:
cfe/trunk/lib/Sema/Sema.h
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp
Modified: cfe/trunk/lib/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.h?rev=83027&r1=83026&r2=83027&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/Sema.h (original)
+++ cfe/trunk/lib/Sema/Sema.h Mon Sep 28 18:23:40 2009
@@ -2179,6 +2179,8 @@
Expr *BuildObjCEncodeExpression(SourceLocation AtLoc,
QualType EncodedType,
SourceLocation RParenLoc);
+ CXXMemberCallExpr *BuildCXXMemberCallExpr(Expr *Exp, CXXMethodDecl *Method);
+
virtual ExprResult ParseObjCEncodeExpression(SourceLocation AtLoc,
SourceLocation EncodeLoc,
SourceLocation LParenLoc,
Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=83027&r1=83026&r2=83027&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Mon Sep 28 18:23:40 2009
@@ -2080,6 +2080,24 @@
ConvName, DeclPtrTy(), SS);
}
+CXXMemberCallExpr *Sema::BuildCXXMemberCallExpr(Expr *Exp,
+ CXXMethodDecl *Method) {
+ MemberExpr *ME =
+ new (Context) MemberExpr(Exp, /*IsArrow=*/false, Method,
+ SourceLocation(), Method->getType());
+ QualType ResultType;
+ if (const CXXConversionDecl *Conv = dyn_cast<CXXConversionDecl>(Method))
+ ResultType = Conv->getConversionType().getNonReferenceType();
+ else
+ ResultType = Method->getResultType().getNonReferenceType();
+
+ CXXMemberCallExpr *CE =
+ new (Context) CXXMemberCallExpr(Context, ME, 0, 0,
+ ResultType,
+ SourceLocation());
+ return CE;
+}
+
Sema::OwningExprResult Sema::BuildCXXCastArgument(SourceLocation CastLoc,
QualType Ty,
CastExpr::CastKind Kind,
@@ -2108,22 +2126,10 @@
if (PerformObjectArgumentInitialization(From, Method))
return ExprError();
- // Create an implicit member expr to refer to the conversion operator.
- MemberExpr *ME =
- new (Context) MemberExpr(From, /*IsArrow=*/false, Method,
- SourceLocation(), Method->getType());
-
-
- // And an implicit call expr that calls it.
- QualType ResultType = Method->getResultType().getNonReferenceType();
- CXXMemberCallExpr *CE =
- new (Context) CXXMemberCallExpr(Context, ME, 0, 0,
- ResultType,
- SourceLocation());
-
+ // Create an implicit call expr that calls it.
+ CXXMemberCallExpr *CE = BuildCXXMemberCallExpr(From, Method);
return Owned(CE);
}
-
}
}
Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=83027&r1=83026&r2=83027&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Mon Sep 28 18:23:40 2009
@@ -4895,15 +4895,10 @@
// on the object argument, then let ActOnCallExpr finish the job.
// Create an implicit member expr to refer to the conversion operator.
- MemberExpr *ME =
- new (Context) MemberExpr(Object, /*IsArrow=*/false, Conv,
- SourceLocation(), Conv->getType());
- QualType ResultType = Conv->getConversionType().getNonReferenceType();
+ // and then call it.
CXXMemberCallExpr *CE =
- new (Context) CXXMemberCallExpr(Context, ME, 0, 0,
- ResultType,
- SourceLocation());
-
+ BuildCXXMemberCallExpr(Object, Conv);
+
return ActOnCallExpr(S, ExprArg(*this, CE), LParenLoc,
MultiExprArg(*this, (ExprTy**)Args, NumArgs),
CommaLocs, RParenLoc).release();
More information about the cfe-commits
mailing list