summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/cpp11-migrate/UseAuto/UseAutoMatchers.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang-tools-extra/cpp11-migrate/UseAuto/UseAutoMatchers.cpp')
-rw-r--r--clang-tools-extra/cpp11-migrate/UseAuto/UseAutoMatchers.cpp25
1 files changed, 9 insertions, 16 deletions
diff --git a/clang-tools-extra/cpp11-migrate/UseAuto/UseAutoMatchers.cpp b/clang-tools-extra/cpp11-migrate/UseAuto/UseAutoMatchers.cpp
index a4ada5a76c1..4f314adb2e3 100644
--- a/clang-tools-extra/cpp11-migrate/UseAuto/UseAutoMatchers.cpp
+++ b/clang-tools-extra/cpp11-migrate/UseAuto/UseAutoMatchers.cpp
@@ -14,6 +14,7 @@
//===----------------------------------------------------------------------===//
#include "UseAutoMatchers.h"
+#include "Core/CustomMatchers.h"
#include "clang/AST/ASTContext.h"
using namespace clang::ast_matchers;
@@ -123,7 +124,7 @@ AST_MATCHER(NamedDecl, hasStdIteratorName) {
///
/// \c recordDecl(hasStdContainerName()) matches \c vector and \c forward_list
/// but not \c my_vec.
-AST_MATCHER_P(NamedDecl, hasStdContainerName, bool, WithStd) {
+AST_MATCHER(NamedDecl, hasStdContainerName) {
static const char *ContainerNames[] = {
"array",
"deque",
@@ -146,13 +147,8 @@ AST_MATCHER_P(NamedDecl, hasStdContainerName, bool, WithStd) {
"stack"
};
- for (unsigned int i = 0;
- i < llvm::array_lengthof(ContainerNames);
- ++i) {
- std::string Name(ContainerNames[i]);
- if (WithStd)
- Name = "std::" + Name;
- if (hasName(Name).matches(Node, Finder, Builder))
+ for (unsigned int i = 0; i < llvm::array_lengthof(ContainerNames); ++i) {
+ if (hasName(ContainerNames[i]).matches(Node, Finder, Builder))
return true;
}
return false;
@@ -170,7 +166,7 @@ TypeMatcher typedefIterator() {
allOf(
namedDecl(hasStdIteratorName()),
hasDeclContext(
- recordDecl(hasStdContainerName(true))
+ recordDecl(hasStdContainerName(), isFromStdNamespace())
)
)
)
@@ -185,7 +181,7 @@ TypeMatcher nestedIterator() {
allOf(
namedDecl(hasStdIteratorName()),
hasDeclContext(
- recordDecl(hasStdContainerName(true))
+ recordDecl(hasStdContainerName(), isFromStdNamespace())
)
)
)
@@ -201,18 +197,15 @@ TypeMatcher iteratorFromUsingDeclaration() {
allOf(
// Unwrap the nested name specifier to test for
// one of the standard containers.
- hasQualifier(allOf(
+ hasQualifier(
specifiesType(
templateSpecializationType(
hasDeclaration(
- namedDecl(hasStdContainerName(false))
+ namedDecl(hasStdContainerName(), isFromStdNamespace())
)
)
- ),
- hasPrefix(
- specifiesNamespace(hasName("std"))
)
- )),
+ ),
// The named type is what comes after the final
// '::' in the type. It should name one of the
// standard iterator names.
OpenPOWER on IntegriCloud