summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaInit.cpp
diff options
context:
space:
mode:
authorRichard Trieu <rtrieu@google.com>2015-07-29 23:47:19 +0000
committerRichard Trieu <rtrieu@google.com>2015-07-29 23:47:19 +0000
commit1993dc8b15d4d8835e773499240fad2da1152fb2 (patch)
tree1109c4ae70643e68fc780103d7718f4f5bed06c4 /clang/lib/Sema/SemaInit.cpp
parentb98aa4359af0c69365bfd471c95df34127e1e16b (diff)
downloadbcm5719-llvm-1993dc8b15d4d8835e773499240fad2da1152fb2.tar.gz
bcm5719-llvm-1993dc8b15d4d8835e773499240fad2da1152fb2.zip
Fix -Wredundant-move warning.
Without DR1579 implemented, the only case for -Wredundant-move is for a parameter being returned with the same type as the function return type. Also include a check to verify that the move constructor will be used by matching nodes in the AST dump. llvm-svn: 243594
Diffstat (limited to 'clang/lib/Sema/SemaInit.cpp')
-rw-r--r--clang/lib/Sema/SemaInit.cpp33
1 files changed, 3 insertions, 30 deletions
diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index f66bc7f37ad..adec512693f 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -5944,24 +5944,6 @@ static void CheckMoveOnConstruction(Sema &S, const Expr *InitExpr,
return;
InitExpr = CCE->getArg(0)->IgnoreImpCasts();
-
- // Remove implicit temporary and constructor nodes.
- if (const MaterializeTemporaryExpr *MTE =
- dyn_cast<MaterializeTemporaryExpr>(InitExpr)) {
- InitExpr = MTE->GetTemporaryExpr()->IgnoreImpCasts();
- while (const CXXConstructExpr *CCE =
- dyn_cast<CXXConstructExpr>(InitExpr)) {
- if (isa<CXXTemporaryObjectExpr>(CCE))
- return;
- if (CCE->getNumArgs() == 0)
- return;
- if (CCE->getNumArgs() > 1 && !isa<CXXDefaultArgExpr>(CCE->getArg(1)))
- return;
- InitExpr = CCE->getArg(0);
- }
- InitExpr = InitExpr->IgnoreImpCasts();
- DiagID = diag::warn_redundant_move_on_return;
- }
}
// Find the std::move call and get the argument.
@@ -5991,24 +5973,15 @@ static void CheckMoveOnConstruction(Sema &S, const Expr *InitExpr,
return;
if (!S.Context.hasSameUnqualifiedType(DestType, SourceType)) {
- if (CXXRecordDecl *RD = SourceType->getAsCXXRecordDecl()) {
- for (auto* Construct : RD->ctors()) {
- if (Construct->isCopyConstructor() && Construct->isDeleted())
- return;
- }
- }
+ return;
}
// If we're returning a function parameter, copy elision
// is not possible.
if (isa<ParmVarDecl>(VD))
DiagID = diag::warn_redundant_move_on_return;
-
- if (DiagID == 0) {
- DiagID = S.Context.hasSameUnqualifiedType(DestType, VD->getType())
- ? diag::warn_pessimizing_move_on_return
- : diag::warn_redundant_move_on_return;
- }
+ else
+ DiagID = diag::warn_pessimizing_move_on_return;
} else {
DiagID = diag::warn_pessimizing_move_on_initialization;
const Expr *ArgStripped = Arg->IgnoreImplicit()->IgnoreParens();
OpenPOWER on IntegriCloud