summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/cpp11-migrate/Core
diff options
context:
space:
mode:
authorAriel J. Bernal <ariel.j.bernal@intel.com>2013-07-15 15:37:05 +0000
committerAriel J. Bernal <ariel.j.bernal@intel.com>2013-07-15 15:37:05 +0000
commit601858aed76429a0ddf2324b05946d13e59a6471 (patch)
tree6df1b20597e7c8f1245cb33948b57a87167f36d3 /clang-tools-extra/cpp11-migrate/Core
parenteaa534450c2ce54ad6fd7400d387e4de997817a6 (diff)
downloadbcm5719-llvm-601858aed76429a0ddf2324b05946d13e59a6471.tar.gz
bcm5719-llvm-601858aed76429a0ddf2324b05946d13e59a6471.zip
Fix UseAuto not transforming iterator when non-fully qualifiers are used and
using inline namespaces is specified. UseAuto used to fail to transform iterators when using inline namespaces and non-fully qualified types, relying on a using directive previously declared. - This fix uses the already define isFromStdNamespace matcher. - Fixed tests and added a new test using inline namespaces. - Added CustomMatchers to reuse common matchers among transforms. llvm-svn: 186327
Diffstat (limited to 'clang-tools-extra/cpp11-migrate/Core')
-rw-r--r--clang-tools-extra/cpp11-migrate/Core/CustomMatchers.h59
1 files changed, 59 insertions, 0 deletions
diff --git a/clang-tools-extra/cpp11-migrate/Core/CustomMatchers.h b/clang-tools-extra/cpp11-migrate/Core/CustomMatchers.h
new file mode 100644
index 00000000000..9af04977996
--- /dev/null
+++ b/clang-tools-extra/cpp11-migrate/Core/CustomMatchers.h
@@ -0,0 +1,59 @@
+//===-- Core/CustomMatchers.h - Perf measurement helpers -----------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// \brief This file provides custom matchers to be used by different
+/// transforms that requier the same matchers.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef CPP11_MIGRATE_CUSTOMMATCHERS_H
+#define CPP11_MIGRATE_CUSTOMMATCHERS_H
+
+#include "clang/ASTMatchers/ASTMatchers.h"
+
+namespace clang {
+namespace ast_matchers {
+
+/// \brief Matches declarations whose declaration context is the C++ standard
+/// library namespace \c std.
+///
+/// Note that inline namespaces are silently ignored during the lookup since
+/// both libstdc++ and libc++ are known to use them for versioning purposes.
+///
+/// Given
+/// \code
+/// namespace ns {
+/// struct my_type {};
+/// using namespace std;
+/// }
+///
+/// using std::vector;
+/// using ns::my_type;
+/// using ns::list;
+/// \endcode
+/// usingDecl(hasAnyUsingShadowDecl(hasTargetDecl(isFromStdNamespace())))
+/// matches "using std::vector" and "using ns::list".
+AST_MATCHER(Decl, isFromStdNamespace) {
+ const DeclContext *D = Node.getDeclContext();
+
+ while (D->isInlineNamespace())
+ D = D->getParent();
+
+ if (!D->isNamespace() || !D->getParent()->isTranslationUnit())
+ return false;
+
+ const IdentifierInfo *Info = cast<NamespaceDecl>(D)->getIdentifier();
+
+ return Info && Info->isStr("std");
+}
+} // namespace ast_matchers
+} // namespace clang
+
+#endif // CPP11_MIGRATE_CUSTOMMATCHERS_H
OpenPOWER on IntegriCloud