20#include "llvm/ADT/STLExtras.h"
32 void HandleTranslationUnit(ASTContext &Ctx)
override;
34 void handleCallGraphNode(
const ASTContext &Ctx,
const CallGraphNode *N);
38void CallGraphExtractor::HandleTranslationUnit(
ASTContext &Ctx) {
43 for (
const auto &N : llvm::make_second_range(CG)) {
44 if (N && N->getDecl() && N->getDefinition())
45 handleCallGraphNode(Ctx, N.get());
49void CallGraphExtractor::handleCallGraphNode(
const ASTContext &Ctx,
50 const CallGraphNode *N) {
60 auto FnSummary = std::make_unique<CallGraphSummary>();
65 FnSummary->Definition.Line = Loc.
getLine();
66 FnSummary->Definition.Column = Loc.
getColumn();
70 const Decl *CalleeDecl =
Record.Callee->getDecl();
87 EntityId CalleeId = SummaryBuilder.addEntity(*CalleeName);
88 if (
const auto *MD = dyn_cast_or_null<CXXMethodDecl>(CalleeDecl);
89 MD && MD->isVirtual()) {
90 FnSummary->VirtualCallees.insert(CalleeId);
93 FnSummary->DirectCallees.insert(CalleeId);
96 EntityId CallerId = SummaryBuilder.addEntity(*CallerName);
97 SummaryBuilder.addSummary(CallerId, std::move(FnSummary));
100static TUSummaryExtractorRegistry::Add<CallGraphExtractor>
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.
std::optional< EntityName > getEntityName(const Decl *D)
Maps a declaration to an EntityName.
The JSON file list parser is used to communicate input to InstallAPI.
bool isa(CodeGen::Address addr)