summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaExprObjC.cpp
diff options
context:
space:
mode:
authorPatrick Beard <pcbeard@mac.com>2012-05-01 21:47:19 +0000
committerPatrick Beard <pcbeard@mac.com>2012-05-01 21:47:19 +0000
commit2565c596316978c5658cd474710dd7696edb0dc3 (patch)
tree5ab7608d9867809c5ec5eab5a02054a885c4a001 /clang/lib/Sema/SemaExprObjC.cpp
parentafd3d0ba405608d5a93d3364bef0ebf103245ee5 (diff)
downloadbcm5719-llvm-2565c596316978c5658cd474710dd7696edb0dc3.tar.gz
bcm5719-llvm-2565c596316978c5658cd474710dd7696edb0dc3.zip
Clean up changes suggested by Douglas Gregor:
BuildObjCNumericLiteral() and BuildObjCBoxedExpr() now both using PerformCopyInitialization() rather than PerformImplicitConversion(), which suppresses errors. In BuildObjCBoxedExpr(): no longer calling .getCanonicalType(), ValueType->getAs() will remove the minimal amount of sugar. Using ValueType->isBuiltinType() instead of isa<BuiltinType>(ValueType). llvm-svn: 155949
Diffstat (limited to 'clang/lib/Sema/SemaExprObjC.cpp')
-rw-r--r--clang/lib/Sema/SemaExprObjC.cpp32
1 files changed, 19 insertions, 13 deletions
diff --git a/clang/lib/Sema/SemaExprObjC.cpp b/clang/lib/Sema/SemaExprObjC.cpp
index 12f5dc72884..b45b7c92ce2 100644
--- a/clang/lib/Sema/SemaExprObjC.cpp
+++ b/clang/lib/Sema/SemaExprObjC.cpp
@@ -237,9 +237,6 @@ static ObjCMethodDecl *getNSNumberFactoryMethod(Sema &S, SourceLocation Loc,
/// BuildObjCNumericLiteral - builds an ObjCBoxedExpr AST node for the
/// numeric literal expression. Type of the expression will be "NSNumber *".
ExprResult Sema::BuildObjCNumericLiteral(SourceLocation AtLoc, Expr *Number) {
- // compute the effective range of the literal, including the leading '@'.
- SourceRange SR(AtLoc, Number->getSourceRange().getEnd());
-
// Determine the type of the literal.
QualType NumberType = Number->getType();
if (CharacterLiteral *Char = dyn_cast<CharacterLiteral>(Number)) {
@@ -266,21 +263,27 @@ ExprResult Sema::BuildObjCNumericLiteral(SourceLocation AtLoc, Expr *Number) {
// Look for the appropriate method within NSNumber.
// Construct the literal.
+ SourceRange NR(Number->getSourceRange());
ObjCMethodDecl *Method = getNSNumberFactoryMethod(*this, AtLoc, NumberType,
- true, Number->getSourceRange());
+ true, NR);
if (!Method)
return ExprError();
// Convert the number to the type that the parameter expects.
- QualType ArgType = Method->param_begin()[0]->getType();
- ExprResult ConvertedNumber = PerformImplicitConversion(Number, ArgType,
- AA_Sending);
+ ParmVarDecl *ParamDecl = Method->param_begin()[0];
+ InitializedEntity Entity = InitializedEntity::InitializeParameter(Context,
+ ParamDecl);
+ ExprResult ConvertedNumber = PerformCopyInitialization(Entity,
+ SourceLocation(),
+ Owned(Number));
if (ConvertedNumber.isInvalid())
return ExprError();
Number = ConvertedNumber.get();
+ // Use the effective source range of the literal, including the leading '@'.
return MaybeBindToTemporary(
- new (Context) ObjCBoxedExpr(Number, NSNumberPointer, Method, SR));
+ new (Context) ObjCBoxedExpr(Number, NSNumberPointer, Method,
+ SourceRange(AtLoc, NR.getEnd())));
}
ExprResult Sema::ActOnObjCBoolLiteral(SourceLocation AtLoc,
@@ -408,7 +411,7 @@ ExprResult Sema::BuildObjCBoxedExpr(SourceRange SR, Expr *ValueExpr) {
return ExprError();
}
ValueExpr = RValue.get();
- QualType ValueType(ValueExpr->getType().getCanonicalType());
+ QualType ValueType(ValueExpr->getType());
if (const PointerType *PT = ValueType->getAs<PointerType>()) {
QualType PointeeType = PT->getPointeeType();
if (Context.hasSameUnqualifiedType(PointeeType, Context.CharTy)) {
@@ -475,7 +478,7 @@ ExprResult Sema::BuildObjCBoxedExpr(SourceRange SR, Expr *ValueExpr) {
BoxingMethod = StringWithUTF8StringMethod;
BoxedType = NSStringPointer;
}
- } else if (isa<BuiltinType>(ValueType)) {
+ } else if (ValueType->isBuiltinType()) {
// The other types we support are numeric, char and BOOL/bool. We could also
// provide limited support for structure types, such as NSRange, NSRect, and
// NSSize. See NSValue (NSValueGeometryExtensions) in <Foundation/NSGeometry.h>
@@ -519,9 +522,12 @@ ExprResult Sema::BuildObjCBoxedExpr(SourceRange SR, Expr *ValueExpr) {
}
// Convert the expression to the type that the parameter requires.
- QualType ArgType = BoxingMethod->param_begin()[0]->getType();
- ExprResult ConvertedValueExpr = PerformImplicitConversion(ValueExpr, ArgType,
- AA_Sending);
+ ParmVarDecl *ParamDecl = BoxingMethod->param_begin()[0];
+ InitializedEntity Entity = InitializedEntity::InitializeParameter(Context,
+ ParamDecl);
+ ExprResult ConvertedValueExpr = PerformCopyInitialization(Entity,
+ SourceLocation(),
+ Owned(ValueExpr));
if (ConvertedValueExpr.isInvalid())
return ExprError();
ValueExpr = ConvertedValueExpr.get();
OpenPOWER on IntegriCloud