diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2012-05-15 22:59:54 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2012-05-15 22:59:54 +0000 |
commit | cebe722ef64e906dff932bd0d1a47081fe079075 (patch) | |
tree | 7e72a7b00d3fdb4bba752c6b5097ae5704b9641f /clang/lib/Edit/RewriteObjCFoundationAPI.cpp | |
parent | 0ebc0fa974335d535403142382fa5704d539be6d (diff) | |
download | bcm5719-llvm-cebe722ef64e906dff932bd0d1a47081fe079075.tar.gz bcm5719-llvm-cebe722ef64e906dff932bd0d1a47081fe079075.zip |
[objcmt] When using NSNumber numberWithInteger:/numberWithUnsignedInteger: be
more liberal in rewriting when the parameter is an enum constant.
Part of rdar://11438360
llvm-svn: 156873
Diffstat (limited to 'clang/lib/Edit/RewriteObjCFoundationAPI.cpp')
-rw-r--r-- | clang/lib/Edit/RewriteObjCFoundationAPI.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/clang/lib/Edit/RewriteObjCFoundationAPI.cpp b/clang/lib/Edit/RewriteObjCFoundationAPI.cpp index 38584d65ef4..5f7bef6f547 100644 --- a/clang/lib/Edit/RewriteObjCFoundationAPI.cpp +++ b/clang/lib/Edit/RewriteObjCFoundationAPI.cpp @@ -684,6 +684,14 @@ static void objectifyExpr(const Expr *E, Commit &commit) { // rewriteToNumericBoxedExpression. //===----------------------------------------------------------------------===// +static bool isEnumConstant(const Expr *E) { + if (const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E->IgnoreParenImpCasts())) + if (const ValueDecl *VD = DRE->getDecl()) + return isa<EnumConstantDecl>(VD); + + return false; +} + static bool rewriteToNumericBoxedExpression(const ObjCMessageExpr *Msg, const NSAPI &NS, Commit &commit) { if (Msg->getNumArgs() != 1) @@ -725,7 +733,7 @@ static bool rewriteToNumericBoxedExpression(const ObjCMessageExpr *Msg, if ((MK == NSAPI::NSNumberWithInteger || MK == NSAPI::NSNumberWithUnsignedInteger) && !isTruncated) { - if (OrigTy->getAs<EnumType>()) + if (OrigTy->getAs<EnumType>() || isEnumConstant(OrigArg)) break; if ((MK==NSAPI::NSNumberWithInteger) == OrigTy->isSignedIntegerType() && OrigTySize >= Ctx.getTypeSize(Ctx.IntTy)) |