Go to the documentation of this file.
13 #include "llvm/ADT/SmallString.h"
14 #include "llvm/Support/Path.h"
16 using namespace clang;
22 llvm::stable_sort(Decls,
35 "Occurrences should be associated with their canonical decl");
37 Decls.emplace_back(Roles,
Offset, D, Relations);
44 Decls.emplace_back(Roles,
Offset, Name, MI);
49 std::remove_if(Decls.begin(), Decls.end(), [](
const DeclOccurrence &D) {
50 if (const auto *MI = D.DeclOrMacro.dyn_cast<const MacroInfo *>())
51 return MI->isUsedForHeaderGuard();
54 Decls.erase(It, Decls.end());
58 OS <<
"DECLS BEGIN ---\n";
59 for (
auto &DclInfo : Decls) {
60 if (
const auto *D = DclInfo.DeclOrMacro.dyn_cast<
const Decl *>()) {
63 OS << llvm::sys::path::filename(PLoc.
getFilename()) <<
':'
66 if (
const auto *ND = dyn_cast<NamedDecl>(D)) {
67 OS <<
' ' << ND->getDeclName();
70 const auto *MI = DclInfo.DeclOrMacro.get<
const MacroInfo *>();
73 OS << llvm::sys::path::filename(PLoc.
getFilename()) <<
':'
75 OS <<
' ' << DclInfo.MacroName->getName();
80 OS <<
"DECLS END ---\n";
unsigned getLine() const
Return the presumed line number of this location.
void removeHeaderGuardMacros()
Remove any macro occurrences for header guards.
Encodes a location in the source.
void addDeclOccurence(SymbolRoleSet Roles, unsigned Offset, const Decl *D, ArrayRef< SymbolRelation > Relations)
Adds an occurrence of the canonical declaration D at the supplied Offset.
Encapsulates the data about a macro definition (e.g.
This class handles loading and caching of source files into memory.
const char * getFilename() const
Return the presumed filename of this location.
void print(llvm::raw_ostream &OS, SourceManager &SM) const
unsigned getColumn() const
Return the presumed column number of this location.
void addMacroOccurence(SymbolRoleSet Roles, unsigned Offset, const IdentifierInfo *Name, const MacroInfo *MI)
Adds an occurrence of the given macro at the supplied Offset.
Decl - This represents one declaration (or definition), e.g.
One of these records is kept for each identifier that is lexed.
ArrayRef< DeclOccurrence > getDeclOccurrencesSortedByOffset() const
Represents an unpacked "presumed" location which can be presented to the user.
bool isCanonicalDecl() const
Whether this particular Decl is a canonical one.