9 #include "clang/AST/ASTContext.h" 10 #include "clang/ASTMatchers/ASTMatchFinder.h" 14 namespace ast_matchers {
32 isInAbseilFile, AST_POLYMORPHIC_SUPPORTED_TYPES(Decl, Stmt, TypeLoc,
33 NestedNameSpecifierLoc)) {
34 auto &SourceManager = Finder->getASTContext().getSourceManager();
35 SourceLocation
Loc = SourceManager.getSpellingLoc(Node.getBeginLoc());
38 const FileEntry *FileEntry =
39 SourceManager.getFileEntryForID(SourceManager.getFileID(Loc));
44 StringRef
Path = FileEntry->getName();
45 static constexpr llvm::StringLiteral AbslPrefix(
"absl/");
46 size_t PrefixPosition = Path.find(AbslPrefix);
47 if (PrefixPosition == StringRef::npos)
49 Path = Path.drop_front(PrefixPosition + AbslPrefix.size());
50 static const char *AbseilLibraries[] = {
51 "algorithm",
"base",
"container",
"debugging",
"flags",
52 "hash",
"iterator",
"memory",
"meta",
"numeric",
53 "random",
"strings",
"synchronization",
"time",
"types",
56 std::begin(AbseilLibraries), std::end(AbseilLibraries),
57 [&](
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++ -*-===//