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

via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 19 12:25:10 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Samira Bazuzi (bazuzi)

<details>
<summary>Changes</summary>



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


2 Files Affected:

- (modified) clang/include/clang/Analysis/FlowSensitive/ASTOps.h (+3) 
- (modified) clang/lib/Analysis/FlowSensitive/ASTOps.cpp (+6) 


``````````diff
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

``````````

</details>


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


More information about the cfe-commits mailing list