summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Stellard <thomas.stellard@amd.com>2014-04-08 18:57:41 +0000
committerTom Stellard <thomas.stellard@amd.com>2014-04-08 18:57:41 +0000
commitef43fc70cb8897573501c3350d2f1ef52e70c3c0 (patch)
tree64462bbad6d3ff0793c2e4090f554dbbfcf6c9fc
parent04344c0f5cb494db992ce099b2e78caa66cdde11 (diff)
downloadclang-ef43fc70cb8897573501c3350d2f1ef52e70c3c0.tar.gz
clang-ef43fc70cb8897573501c3350d2f1ef52e70c3c0.tar.bz2
clang-ef43fc70cb8897573501c3350d2f1ef52e70c3c0.tar.xz
Merging r197445:
------------------------------------------------------------------------ r197445 | rtrieu | 2013-12-16 19:40:40 -0500 (Mon, 16 Dec 2013) | 4 lines For -Wconsumed, walk the namespaces to find if the top most namespace is "std" to determine if a move function is the std::move function. This allows functions like std::__1::move to also be treated a the move function. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_34@205784 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Analysis/Consumed.cpp15
-rw-r--r--test/SemaCXX/warn-consumed-analysis.cpp8
2 files changed, 21 insertions, 2 deletions
diff --git a/lib/Analysis/Consumed.cpp b/lib/Analysis/Consumed.cpp
index 5e1448d0bf..e5ec3e6b92 100644
--- a/lib/Analysis/Consumed.cpp
+++ b/lib/Analysis/Consumed.cpp
@@ -605,14 +605,25 @@ void ConsumedStmtVisitor::VisitBinaryOperator(const BinaryOperator *BinOp) {
}
}
+static bool isStdNamespace(const DeclContext *DC) {
+ if (!DC->isNamespace()) return false;
+ while (DC->getParent()->isNamespace())
+ DC = DC->getParent();
+ const NamespaceDecl *ND = dyn_cast<NamespaceDecl>(DC);
+
+ return ND && ND->getName() == "std" &&
+ ND->getDeclContext()->isTranslationUnit();
+}
+
void ConsumedStmtVisitor::VisitCallExpr(const CallExpr *Call) {
if (const FunctionDecl *FunDecl =
dyn_cast_or_null<FunctionDecl>(Call->getDirectCallee())) {
// Special case for the std::move function.
// TODO: Make this more specific. (Deferred)
- if (FunDecl->getQualifiedNameAsString() == "std::move" &&
- Call->getNumArgs() == 1) {
+ if (Call->getNumArgs() == 1 &&
+ FunDecl->getNameAsString() == "move" &&
+ isStdNamespace(FunDecl->getDeclContext())) {
forwardInfo(Call->getArg(0), Call);
return;
}
diff --git a/test/SemaCXX/warn-consumed-analysis.cpp b/test/SemaCXX/warn-consumed-analysis.cpp
index 5297981ade..2c372c752b 100644
--- a/test/SemaCXX/warn-consumed-analysis.cpp
+++ b/test/SemaCXX/warn-consumed-analysis.cpp
@@ -798,6 +798,12 @@ namespace std {
void move();
template<class T>
void move(T&&);
+
+ namespace __1 {
+ void move();
+ template<class T>
+ void move(T&&);
+ }
}
namespace PR18260 {
@@ -810,5 +816,7 @@ namespace PR18260 {
x.move();
std::move();
std::move(x);
+ std::__1::move();
+ std::__1::move(x);
}
} // end namespace PR18260