10 #include "clang/AST/ASTContext.h"
11 #include "clang/ASTMatchers/ASTMatchFinder.h"
19 void DontModifyStdNamespaceCheck::registerMatchers(MatchFinder *Finder) {
21 namespaceDecl(unless(isExpansionInSystemHeader()),
22 hasAnyName(
"std",
"posix"),
23 has(decl(unless(anyOf(
30 void DontModifyStdNamespaceCheck::check(
31 const MatchFinder::MatchResult &Result) {
32 const auto *N = Result.Nodes.getNodeAs<NamespaceDecl>(
"nmspc");
35 if (N->getParent() != Result.Context->getTranslationUnitDecl())
38 diag(N->getLocation(),
39 "modification of %0 namespace can result in undefined behavior")