Skip to content

Commit 9cbf2dd

Browse files
authored
[analyzer] Print the callee name in CallEnter in exploded-graph-rewriter (#116225)
![image](https://github.com/user-attachments/assets/22a82950-d6e1-4e1f-8f82-2f33240b382a)
1 parent e0b76ba commit 9cbf2dd

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

clang/lib/Analysis/ProgramPoint.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
#include "clang/Analysis/ProgramPoint.h"
1515
#include "clang/AST/ASTContext.h"
16+
#include "clang/Analysis/AnalysisDeclContext.h"
1617
#include "clang/Basic/JsonSupport.h"
1718

1819
using namespace clang;
@@ -81,7 +82,10 @@ void ProgramPoint::printJson(llvm::raw_ostream &Out, const char *NL) const {
8182
llvm_unreachable("BlockExitKind");
8283
break;
8384
case ProgramPoint::CallEnterKind:
84-
Out << "CallEnter\"";
85+
Out << "CallEnter\", \"callee_decl\": \"";
86+
Out << AnalysisDeclContext::getFunctionName(
87+
castAs<CallEnter>().getCalleeContext()->getDecl())
88+
<< '\"';
8589
break;
8690
case ProgramPoint::CallExitBeginKind:
8791
Out << "CallExitBegin\"";

clang/utils/analyzer/exploded-graph-rewriter.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ def __init__(self, json_pp):
8686
if json_pp["location"] is not None
8787
else None
8888
)
89+
elif self.kind == "CallEnter":
90+
self.callee_decl = json_pp.get("callee_decl", "None")
8991
elif self.kind == "BlockEntrance":
9092
self.block_id = json_pp["block_id"]
9193

@@ -618,6 +620,13 @@ def visit_program_point(self, p):
618620
'<font color="%s">%s</font></td>'
619621
'<td align="left">[B%d]</td></tr>' % (color, p.kind, p.block_id)
620622
)
623+
elif p.kind == "CallEnter":
624+
self._dump(
625+
'<td width="0"></td>'
626+
'<td align="left" width="0">'
627+
'<font color="%s">%s</font></td>'
628+
'<td align="left">%s</td></tr>' % (color, p.kind, p.callee_decl)
629+
)
621630
else:
622631
# TODO: Print more stuff for other kinds of points.
623632
self._dump(

0 commit comments

Comments
 (0)