summaryrefslogtreecommitdiffstats
path: root/clang/lib/Analysis/Consumed.cpp
diff options
context:
space:
mode:
authorRichard Trieu <rtrieu@google.com>2013-12-17 00:40:40 +0000
committerRichard Trieu <rtrieu@google.com>2013-12-17 00:40:40 +0000
commitc689691618e8a3e8169ff2a0c399166569a74e23 (patch)
tree0a715136f36a74c94459ad418cdffa036712dd9f /clang/lib/Analysis/Consumed.cpp
parent8dcf98547e1ecf019ae5083bda1e4d55f22847e0 (diff)
downloadbcm5719-llvm-c689691618e8a3e8169ff2a0c399166569a74e23.tar.gz
bcm5719-llvm-c689691618e8a3e8169ff2a0c399166569a74e23.zip
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. llvm-svn: 197445
Diffstat (limited to 'clang/lib/Analysis/Consumed.cpp')
-rw-r--r--clang/lib/Analysis/Consumed.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/clang/lib/Analysis/Consumed.cpp b/clang/lib/Analysis/Consumed.cpp
index 5e1448d0bf3..e5ec3e6b927 100644
--- a/clang/lib/Analysis/Consumed.cpp
+++ b/clang/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;
}
OpenPOWER on IntegriCloud