10 #include "clang/AST/ASTContext.h" 11 #include "clang/ASTMatchers/ASTMatchFinder.h" 19 void DontModifyStdNamespaceCheck::registerMatchers(MatchFinder *Finder) {
20 if (!getLangOpts().CPlusPlus)
24 namespaceDecl(unless(isExpansionInSystemHeader()),
25 anyOf(hasName(
"std"), hasName(
"posix")),
26 has(decl(unless(anyOf(
27 functionDecl(isExplicitTemplateSpecialization()),
28 cxxRecordDecl(isExplicitTemplateSpecialization()))))))
33 void DontModifyStdNamespaceCheck::check(
34 const MatchFinder::MatchResult &
Result) {
35 const auto *N = Result.Nodes.getNodeAs<NamespaceDecl>(
"nmspc");
38 if (N->getParent() != Result.Context->getTranslationUnitDecl())
41 diag(N->getLocation(),
42 "modification of %0 namespace can result in undefined behavior")
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
llvm::Optional< llvm::Expected< tooling::AtomicChanges > > Result