19#include "llvm/ADT/STLExtras.h"
31 void HandleTranslationUnit(ASTContext &Ctx)
override;
33 void handleCallGraphNode(
const ASTContext &Ctx,
const CallGraphNode *N);
37void CallGraphExtractor::HandleTranslationUnit(
ASTContext &Ctx) {
42 for (
const auto &N : llvm::make_second_range(CG)) {
43 if (N && N->getDecl() && N->getDefinition())
44 handleCallGraphNode(Ctx, N.get());
48void CallGraphExtractor::handleCallGraphNode(
const ASTContext &Ctx,
49 const CallGraphNode *N) {
59 auto FnSummary = std::make_unique<CallGraphSummary>();
64 FnSummary->Definition.Line = Loc.
getLine();
65 FnSummary->Definition.Column = Loc.
getColumn();
69 const Decl *CalleeDecl =
Record.Callee->getDecl();
86 if (
const auto *MD = dyn_cast_or_null<CXXMethodDecl>(CalleeDecl);
87 MD && MD->isVirtual()) {
88 FnSummary->VirtualCallees.insert(*CalleeId);
91 FnSummary->DirectCallees.insert(*CalleeId);
94 SummaryBuilder.addSummary(*CallerId, std::move(FnSummary));
97static TUSummaryExtractorRegistry::Add<CallGraphExtractor>
99 "Extracts static call-graph information");
Defines the clang::ASTContext interface.
This file defines AnalysisDeclContext, a class that manages the analysis context data for context sen...
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
llvm::MachO::Record Record
volatile int CallGraphExtractorAnchorSource
Defines the SourceManager interface.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
SourceManager & getSourceManager()
TranslationUnitDecl * getTranslationUnitDecl() const
static std::string getFunctionName(const Decl *D)
FunctionDecl * getDefinition() const
llvm::iterator_range< iterator > callees()
Iterator access to callees/children of the node.
void addToCallGraph(Decl *D)
Populate the call graph with the functions in the given declaration.
bool isTemplated() const
Determine whether this declaration is a templated entity (whether it is.
unsigned getColumn() const
Return the presumed column number of this location.
const char * getFilename() const
Return the presumed filename of this location.
unsigned getLine() const
Return the presumed line number of this location.
PresumedLoc getPresumedLoc(SourceLocation Loc, bool UseLineDirectives=true) const
Returns the "presumed" location of a SourceLocation specifies.
std::variant< struct RequiresDecl, struct HeaderDecl, struct UmbrellaDirDecl, struct ModuleDecl, struct ExcludeDecl, struct ExportDecl, struct ExportAsDecl, struct ExternModuleDecl, struct UseDecl, struct LinkDecl, struct ConfigMacrosDecl, struct ConflictDecl > Decl
All declarations that can appear in a module declaration.
The JSON file list parser is used to communicate input to InstallAPI.
bool isa(CodeGen::Address addr)
U cast(CodeGen::Address addr)
static constexpr llvm::StringLiteral Name