[clang] [analyzer] Turn NodeBuilderContext into a class (PR #84638)
Diego A. Estrada Rivera via cfe-commits
cfe-commits at lists.llvm.org
Sun Mar 10 18:37:54 PDT 2024
https://github.com/diego-est updated https://github.com/llvm/llvm-project/pull/84638
>From 114e22388508cd1ef5174bdda041564691b58032 Mon Sep 17 00:00:00 2001
From: Sunglas <diego.estrada1 at proton.me>
Date: Sat, 9 Mar 2024 12:23:43 -0400
Subject: [PATCH 1/2] [analyzer] Turn NodeBuilderContext into a class
---
.../clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h
index 8e392421fef9bb..24d4afc551355e 100644
--- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h
+++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h
@@ -59,7 +59,7 @@ class CoreEngine {
friend class ExprEngine;
friend class IndirectGotoNodeBuilder;
friend class NodeBuilder;
- friend struct NodeBuilderContext;
+ friend class NodeBuilderContext;
friend class SwitchNodeBuilder;
public:
@@ -194,7 +194,8 @@ class CoreEngine {
};
// TODO: Turn into a class.
-struct NodeBuilderContext {
+class NodeBuilderContext {
+public:
const CoreEngine &Eng;
const CFGBlock *Block;
const LocationContext *LC;
>From a87c924670e00e293ea31d5230c6131509ce26b1 Mon Sep 17 00:00:00 2001
From: Sunglas <diego.estrada1 at proton.me>
Date: Sun, 10 Mar 2024 21:24:23 -0400
Subject: [PATCH 2/2] fix(NodeBuilderContext implementation): changed class
members to private and added the appropriate getters.
Moved every member in NodeBuilderContext to private and added the following getters:
- getEngine
- getLocationContext
Setters are not necessary since the class members are const already.
---
.../clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h
index 24d4afc551355e..0705affa4117d9 100644
--- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h
+++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h
@@ -195,11 +195,11 @@ class CoreEngine {
// TODO: Turn into a class.
class NodeBuilderContext {
-public:
const CoreEngine &Eng;
const CFGBlock *Block;
const LocationContext *LC;
+public:
NodeBuilderContext(const CoreEngine &E, const CFGBlock *B,
const LocationContext *L)
: Eng(E), Block(B), LC(L) {
@@ -209,9 +209,15 @@ class NodeBuilderContext {
NodeBuilderContext(const CoreEngine &E, const CFGBlock *B, ExplodedNode *N)
: NodeBuilderContext(E, B, N->getLocationContext()) {}
+ /// Return the CoreEngine associated with this builder.
+ const CoreEngine &getEngine() const { return Eng; }
+
/// Return the CFGBlock associated with this builder.
const CFGBlock *getBlock() const { return Block; }
+ /// Return the location context associated with this builder.
+ const LocationContext *getLocationContext() const { return LC; }
+
/// Returns the number of times the current basic block has been
/// visited on the exploded graph path.
unsigned blockCount() const {
More information about the cfe-commits
mailing list