11 #include "clang/AST/ASTContext.h"
12 #include "clang/ASTMatchers/ASTMatchFinder.h"
13 #include "clang/ASTMatchers/ASTMatchers.h"
15 using namespace clang::ast_matchers;
22 void UsingNamespaceDirectiveCheck::registerMatchers(
23 ast_matchers::MatchFinder *
Finder) {
26 if (getLangOpts().CPlusPlus)
27 Finder->addMatcher(usingDirectiveDecl().bind(
"usingNamespace"),
this);
31 UsingNamespaceDirectiveCheck::check(
const MatchFinder::MatchResult &
Result) {
32 const auto *U = Result.Nodes.getNodeAs<UsingDirectiveDecl>(
"usingNamespace");
33 SourceLocation
Loc = U->getLocStart();
34 if (U->isImplicit() || !Loc.isValid())
37 diag(Loc,
"do not use namespace using-directives; "
38 "use using-declarations instead");
SourceLocation Loc
'#' location in the include directive
std::unique_ptr< ast_matchers::MatchFinder > Finder