diff options
Diffstat (limited to 'clang-tools-extra/cpp11-migrate/ReplaceAutoPtr/ReplaceAutoPtrMatchers.cpp')
-rw-r--r-- | clang-tools-extra/cpp11-migrate/ReplaceAutoPtr/ReplaceAutoPtrMatchers.cpp | 34 |
1 files changed, 1 insertions, 33 deletions
diff --git a/clang-tools-extra/cpp11-migrate/ReplaceAutoPtr/ReplaceAutoPtrMatchers.cpp b/clang-tools-extra/cpp11-migrate/ReplaceAutoPtr/ReplaceAutoPtrMatchers.cpp index 1115229d989..e03a2c342f5 100644 --- a/clang-tools-extra/cpp11-migrate/ReplaceAutoPtr/ReplaceAutoPtrMatchers.cpp +++ b/clang-tools-extra/cpp11-migrate/ReplaceAutoPtr/ReplaceAutoPtrMatchers.cpp @@ -14,6 +14,7 @@ //===----------------------------------------------------------------------===// #include "ReplaceAutoPtrMatchers.h" +#include "Core/CustomMatchers.h" const char *AutoPtrTokenId = "AutoPtrTokenId"; const char *AutoPtrOwnershipTransferId = "AutoPtrOwnershipTransferId"; @@ -34,39 +35,6 @@ AST_MATCHER(Expr, isLValue) { return Node.getValueKind() == VK_LValue; } -/// \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"); -} - } // end namespace ast_matchers } // end namespace clang |