11 #include "clang/AST/ASTContext.h"
12 #include "clang/ASTMatchers/ASTMatchFinder.h"
20 void NoNamespaceCheck::registerMatchers(MatchFinder *Finder) {
22 namespaceDecl(hasName(
"::absl"), unless(isInAbseilFile()))
23 .bind(
"abslNamespace"),
27 void NoNamespaceCheck::check(
const MatchFinder::MatchResult &Result) {
28 const auto *abslNamespaceDecl =
29 Result.Nodes.getNodeAs<NamespaceDecl>(
"abslNamespace");
31 diag(abslNamespaceDecl->getLocation(),
32 "namespace 'absl' is reserved for implementation of the Abseil library "
33 "and should not be opened in user code");