12 #include "clang/AST/ASTContext.h" 13 #include "clang/AST/Decl.h" 14 #include "clang/Basic/SourceManager.h" 21 const auto& SM = D->getASTContext().getSourceManager();
24 SourceLocation SpellingLoc = SM.getSpellingLoc(D->getLocation());
25 if (D->getLocation().isMacroID()) {
26 std::string PrintLoc = SpellingLoc.printToString(SM);
27 if (llvm::StringRef(PrintLoc).startswith(
"<scratch") ||
28 llvm::StringRef(PrintLoc).startswith(
"<command line>")) {
35 SpellingLoc = SM.getExpansionRange(D->getLocation()).getBegin();
43 llvm::raw_string_ostream OS(QName);
44 PrintingPolicy Policy(ND.getASTContext().getLangOpts());
49 Policy.SuppressUnwrittenScope =
true;
50 ND.printQualifiedName(OS, Policy);
52 assert(!StringRef(QName).startswith(
"::"));
std::string printQualifiedName(const NamedDecl &ND)
Returns the qualified name of ND.
Some operations such as code completion produce a set of candidates.
SourceLocation findNameLoc(const clang::Decl *D)
Find the identifier source location of the given D.
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//