[clang] [analyzer] Print the callee name in CallEnter in exploded-graph-rewriter (PR #116225)
Balazs Benics via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 15 05:17:58 PST 2024
https://github.com/steakhal updated https://github.com/llvm/llvm-project/pull/116225
>From 68086287a41c534704cdbc88027f61090b0540ea Mon Sep 17 00:00:00 2001
From: Balazs Benics <benicsbalazs at gmail.com>
Date: Thu, 14 Nov 2024 14:25:31 +0100
Subject: [PATCH 1/2] [analyzer] Print the callee name in CallEnter in
exploded-graph-rewriter
---
clang/lib/Analysis/ProgramPoint.cpp | 6 +++++-
clang/utils/analyzer/exploded-graph-rewriter.py | 9 +++++++++
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/clang/lib/Analysis/ProgramPoint.cpp b/clang/lib/Analysis/ProgramPoint.cpp
index 768345c8425f02..7945c5c2fc27fc 100644
--- a/clang/lib/Analysis/ProgramPoint.cpp
+++ b/clang/lib/Analysis/ProgramPoint.cpp
@@ -13,6 +13,7 @@
#include "clang/Analysis/ProgramPoint.h"
#include "clang/AST/ASTContext.h"
+#include "clang/Analysis/AnalysisDeclContext.h"
#include "clang/Basic/JsonSupport.h"
using namespace clang;
@@ -81,7 +82,10 @@ void ProgramPoint::printJson(llvm::raw_ostream &Out, const char *NL) const {
llvm_unreachable("BlockExitKind");
break;
case ProgramPoint::CallEnterKind:
- Out << "CallEnter\"";
+ Out << "CallEnter\", \"callee_decl\": \"";
+ Out << AnalysisDeclContext::getFunctionName(
+ castAs<CallEnter>().getCalleeContext()->getDecl())
+ << '\"';
break;
case ProgramPoint::CallExitBeginKind:
Out << "CallExitBegin\"";
diff --git a/clang/utils/analyzer/exploded-graph-rewriter.py b/clang/utils/analyzer/exploded-graph-rewriter.py
index 5eaa7738103f79..cfb36e7d4eb20e 100755
--- a/clang/utils/analyzer/exploded-graph-rewriter.py
+++ b/clang/utils/analyzer/exploded-graph-rewriter.py
@@ -86,6 +86,8 @@ def __init__(self, json_pp):
if json_pp["location"] is not None
else None
)
+ elif self.kind == "CallEnter":
+ self.callee_decl = json_pp["callee_decl"] if "callee_decl" in json_pp else "None"
elif self.kind == "BlockEntrance":
self.block_id = json_pp["block_id"]
@@ -618,6 +620,13 @@ def visit_program_point(self, p):
'<font color="%s">%s</font></td>'
'<td align="left">[B%d]</td></tr>' % (color, p.kind, p.block_id)
)
+ elif p.kind == "CallEnter":
+ self._dump(
+ '<td width="0"></td>'
+ '<td align="left" width="0">'
+ '<font color="%s">%s</font></td>'
+ '<td align="left">%s</td></tr>' % (color, p.kind, p.callee_decl)
+ )
else:
# TODO: Print more stuff for other kinds of points.
self._dump(
>From 436da81d8c9d9386f70b4257bf01bb930610cb4d Mon Sep 17 00:00:00 2001
From: Balazs Benics <benicsbalazs at gmail.com>
Date: Fri, 15 Nov 2024 14:16:43 +0100
Subject: [PATCH 2/2] Apply review suggestion
---
clang/utils/analyzer/exploded-graph-rewriter.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang/utils/analyzer/exploded-graph-rewriter.py b/clang/utils/analyzer/exploded-graph-rewriter.py
index cfb36e7d4eb20e..eca0f17beb40a0 100755
--- a/clang/utils/analyzer/exploded-graph-rewriter.py
+++ b/clang/utils/analyzer/exploded-graph-rewriter.py
@@ -87,7 +87,7 @@ def __init__(self, json_pp):
else None
)
elif self.kind == "CallEnter":
- self.callee_decl = json_pp["callee_decl"] if "callee_decl" in json_pp else "None"
+ self.callee_decl = json_pp.get("callee_decl", "None")
elif self.kind == "BlockEntrance":
self.block_id = json_pp["block_id"]
More information about the cfe-commits
mailing list