summaryrefslogtreecommitdiff
path: root/lib/Analysis/CallGraph.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Analysis/CallGraph.cpp')
-rw-r--r--lib/Analysis/CallGraph.cpp42
1 files changed, 40 insertions, 2 deletions
diff --git a/lib/Analysis/CallGraph.cpp b/lib/Analysis/CallGraph.cpp
index 7eda80ea0505e..76be292dad8d2 100644
--- a/lib/Analysis/CallGraph.cpp
+++ b/lib/Analysis/CallGraph.cpp
@@ -79,6 +79,37 @@ public:
VisitChildren(CE);
}
+ void VisitLambdaExpr(LambdaExpr *LE) {
+ if (FunctionTemplateDecl *FTD = LE->getDependentCallOperator())
+ for (FunctionDecl *FD : FTD->specializations())
+ G->VisitFunctionDecl(FD);
+ else if (CXXMethodDecl *MD = LE->getCallOperator())
+ G->VisitFunctionDecl(MD);
+ }
+
+ void VisitCXXNewExpr(CXXNewExpr *E) {
+ if (FunctionDecl *FD = E->getOperatorNew())
+ addCalledDecl(FD);
+ VisitChildren(E);
+ }
+
+ void VisitCXXConstructExpr(CXXConstructExpr *E) {
+ CXXConstructorDecl *Ctor = E->getConstructor();
+ if (FunctionDecl *Def = Ctor->getDefinition())
+ addCalledDecl(Def);
+ VisitChildren(E);
+ }
+
+ // Include the evaluation of the default argument.
+ void VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E) {
+ Visit(E->getExpr());
+ }
+
+ // Include the evaluation of the default initializers in a class.
+ void VisitCXXDefaultInitExpr(CXXDefaultInitExpr *E) {
+ Visit(E->getExpr());
+ }
+
// Adds may-call edges for the ObjC message sends.
void VisitObjCMessageExpr(ObjCMessageExpr *ME) {
if (ObjCInterfaceDecl *IDecl = ME->getReceiverInterface()) {
@@ -143,13 +174,20 @@ bool CallGraph::includeInGraph(const Decl *D) {
void CallGraph::addNodeForDecl(Decl* D, bool IsGlobal) {
assert(D);
- // Allocate a new node, mark it as root, and process it's calls.
+ // Allocate a new node, mark it as root, and process its calls.
CallGraphNode *Node = getOrInsertNode(D);
// Process all the calls by this function as well.
CGBuilder builder(this, Node);
if (Stmt *Body = D->getBody())
builder.Visit(Body);
+
+ // Include C++ constructor member initializers.
+ if (auto constructor = dyn_cast<CXXConstructorDecl>(D)) {
+ for (CXXCtorInitializer *init : constructor->inits()) {
+ builder.Visit(init->getInit());
+ }
+ }
}
CallGraphNode *CallGraph::getNode(const Decl *F) const {
@@ -166,7 +204,7 @@ CallGraphNode *CallGraph::getOrInsertNode(Decl *F) {
if (Node)
return Node.get();
- Node = llvm::make_unique<CallGraphNode>(F);
+ Node = std::make_unique<CallGraphNode>(F);
// Make Root node a parent of all functions to make sure all are reachable.
if (F)
Root->addCallee(Node.get());