summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2009-09-28 23:23:40 +0000
committerFariborz Jahanian <fjahanian@apple.com>2009-09-28 23:23:40 +0000
commit78cfcb56a10e733b248a75e542807b52cf526067 (patch)
treeddd87d91f193124dd9e7051d37787779da02e715 /clang/lib/Sema
parent9df3d6d44882cf469bd2297a61ea0aadbe063682 (diff)
downloadbcm5719-llvm-78cfcb56a10e733b248a75e542807b52cf526067.tar.gz
bcm5719-llvm-78cfcb56a10e733b248a75e542807b52cf526067.zip
Define and use a helper method to call a type conversion
function. llvm-svn: 83027
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r--clang/lib/Sema/Sema.h2
-rw-r--r--clang/lib/Sema/SemaExprCXX.cpp34
-rw-r--r--clang/lib/Sema/SemaOverload.cpp11
3 files changed, 25 insertions, 22 deletions
diff --git a/clang/lib/Sema/Sema.h b/clang/lib/Sema/Sema.h
index be5e551579f..db2bde0d94b 100644
--- a/clang/lib/Sema/Sema.h
+++ b/clang/lib/Sema/Sema.h
@@ -2179,6 +2179,8 @@ public:
Expr *BuildObjCEncodeExpression(SourceLocation AtLoc,
QualType EncodedType,
SourceLocation RParenLoc);
+ CXXMemberCallExpr *BuildCXXMemberCallExpr(Expr *Exp, CXXMethodDecl *Method);
+
virtual ExprResult ParseObjCEncodeExpression(SourceLocation AtLoc,
SourceLocation EncodeLoc,
SourceLocation LParenLoc,
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index 11279708585..183bd8f4c92 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -2080,6 +2080,24 @@ Sema::ActOnConversionOperatorReferenceExpr(Scope *S, ExprArg Base,
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 @@ Sema::OwningExprResult Sema::BuildCXXCastArgument(SourceLocation CastLoc,
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);
}
-
}
}
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 42f3511e579..1283ff4b5eb 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -4895,15 +4895,10 @@ Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Object,
// 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();
OpenPOWER on IntegriCloud