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) {
48 for (
const auto &N : llvm::make_second_range(CG)) {
49 if (N && N->getDecl() && N->getDefinition())
50 handleCallGraphNode(Ctx, N.get());
54void CallGraphExtractor::handleCallGraphNode(
const ASTContext &Ctx,
55 const CallGraphNode *N) {
65 auto FnSummary = std::make_unique<CallGraphSummary>();
70 FnSummary->Definition.Line = Loc.
getLine();
71 FnSummary->Definition.Column = Loc.
getColumn();
75 const Decl *CalleeDecl =
Record.Callee->getDecl();
96 if (
const auto *MD = dyn_cast_or_null<CXXMethodDecl>(CalleeDecl);
97 MD && MD->isVirtual()) {
98 FnSummary->VirtualCallees.insert(*CalleeId);
101 FnSummary->DirectCallees.insert(*CalleeId);
104 SummaryBuilder.addSummary(*CallerId, std::move(FnSummary));
107static TUSummaryExtractorRegistry::Add<CallGraphExtractor>
109 "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
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.
volatile int CallGraphExtractorAnchorSource
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