Declaration,
/// A preprocessor macro, as defined in a specific location.
Macro,
- /// A recognized symbol from the standard library, like std::string.
- Standard,
};
Symbol(const Decl &D) : Storage(&D) {}
Symbol(struct Macro M) : Storage(M) {}
- Symbol(tooling::stdlib::Symbol S) : Storage(S) {}
Kind kind() const { return static_cast<Kind>(Storage.index()); }
bool operator==(const Symbol &RHS) const { return Storage == RHS.Storage; }
const Decl &declaration() const { return *std::get<Declaration>(Storage); }
struct Macro macro() const { return std::get<Macro>(Storage); }
- tooling::stdlib::Symbol standard() const {
- return std::get<Standard>(Storage);
- }
private:
// FIXME: Add support for macros.
// Order must match Kind enum!
- std::variant<const Decl *, struct Macro, tooling::stdlib::Symbol> Storage;
+ std::variant<const Decl *, struct Macro> Storage;
};
llvm::raw_ostream &operator<<(llvm::raw_ostream &, const Symbol &);
tooling::stdlib::Header standard() const {
return std::get<Standard>(Storage);
}
- StringRef verbatim() const {
- return std::get<Verbatim>(Storage);
- }
+ StringRef verbatim() const { return std::get<Verbatim>(Storage); }
private:
// Order must match Kind enum!
for (auto *Root : ASTRoots) {
auto &SM = Root->getASTContext().getSourceManager();
walkAST(*Root, [&](SourceLocation Loc, NamedDecl &ND, RefType RT) {
+ SymbolReference SymRef{Loc, ND, RT};
if (auto SS = Recognizer(&ND)) {
// FIXME: Also report forward decls from main-file, so that the caller
// can decide to insert/ignore a header.
- return CB({Loc, Symbol(*SS), RT}, findHeaders(*SS, SM, PI));
+ return CB(SymRef, findHeaders(*SS, SM, PI));
}
// FIXME: Extract locations from redecls.
- return CB({Loc, Symbol(ND), RT}, findHeaders(ND.getLocation(), SM, PI));
+ return CB(SymRef, findHeaders(ND.getLocation(), SM, PI));
});
}
for (const SymbolReference &MacroRef : MacroRefs) {