10 #include "clang/AST/ASTContext.h" 11 #include "clang/ASTMatchers/ASTMatchFinder.h" 15 namespace ast_matchers {
33 isInAbseilFile, AST_POLYMORPHIC_SUPPORTED_TYPES(Decl, Stmt, TypeLoc,
34 NestedNameSpecifierLoc)) {
35 auto &SourceManager = Finder->getASTContext().getSourceManager();
36 SourceLocation
Loc = SourceManager.getSpellingLoc(Node.getBeginLoc());
39 const FileEntry *FileEntry =
40 SourceManager.getFileEntryForID(SourceManager.getFileID(Loc));
45 StringRef
Path = FileEntry->getName();
46 static constexpr llvm::StringLiteral AbslPrefix(
"absl/");
47 size_t PrefixPosition = Path.find(AbslPrefix);
48 if (PrefixPosition == StringRef::npos)
50 Path = Path.drop_front(PrefixPosition + AbslPrefix.size());
51 static const char *AbseilLibraries[] = {
52 "algorithm",
"base",
"container",
"debugging",
"flags",
53 "hash",
"iterator",
"memory",
"meta",
"numeric",
54 "random",
"strings",
"synchronization",
"time",
"types",
57 std::begin(AbseilLibraries), std::end(AbseilLibraries),
58 [&](
const char *Library) {
return Path.startswith(Library); });
SourceLocation Loc
'#' location in the include directive
AST_POLYMORPHIC_MATCHER(isInAbseilFile, AST_POLYMORPHIC_SUPPORTED_TYPES(Decl, Stmt, TypeLoc, NestedNameSpecifierLoc))
Matches AST nodes that were found within Abseil files.
std::vector< HeaderHandle > Path
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//