Skip to content

[analyzer] Print the callee name in CallEnter in exploded-graph-rewriter #116225

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 15, 2024
Merged

[analyzer] Print the callee name in CallEnter in exploded-graph-rewriter #116225

merged 2 commits into from
Nov 15, 2024

Conversation

steakhal
Copy link
Contributor

image

@steakhal steakhal requested a review from NagyDonat November 14, 2024 13:27
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:analysis labels Nov 14, 2024
@llvmbot
Copy link
Member

llvmbot commented Nov 14, 2024

@llvm/pr-subscribers-clang
@llvm/pr-subscribers-clang-analysis

@llvm/pr-subscribers-clang-static-analyzer-1

Author: Balazs Benics (steakhal)

Changes

image


Full diff: https://github.com/llvm/llvm-project/pull/116225.diff

2 Files Affected:

  • (modified) clang/lib/Analysis/ProgramPoint.cpp (+5-1)
  • (modified) clang/utils/analyzer/exploded-graph-rewriter.py (+9)
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(

Copy link

github-actions bot commented Nov 14, 2024

✅ With the latest revision this PR passed the Python code formatter.

Copy link
Contributor

@NagyDonat NagyDonat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, with one minor simplification suggestion marked in an inline comment.

Disclaimer: I don't use this exploded-graph-rewriter tool, but the change seems to be straightforward and useful.

@steakhal steakhal merged commit 9cbf2dd into llvm:main Nov 15, 2024
5 of 8 checks passed
@steakhal steakhal deleted the bb/call-enter-egraph-rewriter-improvement branch November 15, 2024 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:analysis clang:static analyzer clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants