[clang] [clang][dataflow] Expose getReferencedDecls for a Stmt. (PR #89444)

Samira Bazuzi via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 19 12:24:40 PDT 2024


https://github.com/bazuzi created https://github.com/llvm/llvm-project/pull/89444

None

>From e7b1540984306bfb36a59fa7692208bfaf2bdc1a Mon Sep 17 00:00:00 2001
From: Samira Bazuzi <bazuzi at google.com>
Date: Fri, 19 Apr 2024 15:09:32 -0400
Subject: [PATCH] [clang][dataflow] Expose getReferencedDecls for a Stmt.

---
 clang/include/clang/Analysis/FlowSensitive/ASTOps.h | 3 +++
 clang/lib/Analysis/FlowSensitive/ASTOps.cpp         | 6 ++++++
 2 files changed, 9 insertions(+)

diff --git a/clang/include/clang/Analysis/FlowSensitive/ASTOps.h b/clang/include/clang/Analysis/FlowSensitive/ASTOps.h
index 27ad32c1694f77..ebc250e64fc33a 100644
--- a/clang/include/clang/Analysis/FlowSensitive/ASTOps.h
+++ b/clang/include/clang/Analysis/FlowSensitive/ASTOps.h
@@ -92,6 +92,9 @@ struct ReferencedDecls {
 /// Returns declarations that are declared in or referenced from `FD`.
 ReferencedDecls getReferencedDecls(const FunctionDecl &FD);
 
+/// Returns declarations that are declared in or referenced from `S`.
+ReferencedDecls getReferencedDecls(const Stmt &S);
+
 } // namespace dataflow
 } // namespace clang
 
diff --git a/clang/lib/Analysis/FlowSensitive/ASTOps.cpp b/clang/lib/Analysis/FlowSensitive/ASTOps.cpp
index 75188aef4d1a43..329d4d8837a9a0 100644
--- a/clang/lib/Analysis/FlowSensitive/ASTOps.cpp
+++ b/clang/lib/Analysis/FlowSensitive/ASTOps.cpp
@@ -246,4 +246,10 @@ ReferencedDecls getReferencedDecls(const FunctionDecl &FD) {
   return Result;
 }
 
+ReferencedDecls getReferencedDecls(const Stmt &S) {
+  ReferencedDecls Result;
+  getReferencedDecls(S, Result);
+  return Result;
+}
+
 } // namespace clang::dataflow



More information about the cfe-commits mailing list