[clang] [analyzer] Turn NodeBuilderContext into a class (PR #84638)

2024-03-09 Thread Diego A. Estrada Rivera via cfe-commits

https://github.com/diego-est created 
https://github.com/llvm/llvm-project/pull/84638

>From issue #73088. I changed `NodeBuilderContext` into a class. Additionally, 
>there were some other mentions of the former being a struct which I also 
>changed into a class. This is my first time working with an issue so I will be 
>open to hearing any advice or changes that need to be done.

>From 114e22388508cd1ef5174bdda041564691b58032 Mon Sep 17 00:00:00 2001
From: Sunglas 
Date: Sat, 9 Mar 2024 12:23:43 -0400
Subject: [PATCH] [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;

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [analyzer] Turn NodeBuilderContext into a class (PR #84638)

2024-03-10 Thread Diego A. Estrada Rivera via cfe-commits

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 
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 
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 {

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [analyzer] Turn NodeBuilderContext into a class (PR #84638)

2024-03-10 Thread Diego A. Estrada Rivera via cfe-commits

diego-est wrote:

I added the appropriate functions and moved the class members into private. 
Additionally I ran `make check-all` to make sure the now-private members 
wouldn't cause any issues with the rest of the codebase, all the checks passed.

https://github.com/llvm/llvm-project/pull/84638
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [analyzer] Turn NodeBuilderContext into a class (PR #84638)

2024-03-12 Thread Diego A. Estrada Rivera via cfe-commits

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 
Date: Sat, 9 Mar 2024 12:23:43 -0400
Subject: [PATCH 1/3] [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 
Date: Sun, 10 Mar 2024 21:24:23 -0400
Subject: [PATCH 2/3] 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 {

>From 0d4adf0600c1a86b092fec52749bd781e0ecfd6d Mon Sep 17 00:00:00 2001
From: Sunglas 
Date: Tue, 12 Mar 2024 07:33:34 -0400
Subject: [PATCH 3/3] fix(NodeBuilderContext API): fixed accesses to
 NodeBuilderContext private member accesses.

The files CheckerManager.h, CoreEngine.h, ExprEngine.h and CoreEngine.cpp all 
had bad private member accesses.
---
 clang/include/clang/StaticAnalyzer/Core/CheckerManager.h| 2 +-
 .../clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h| 1 -
 .../clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h| 2 +-
 clang/lib/StaticAnalyzer/Core/CoreEngine.cpp| 6 +++---
 4 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/clang/include/clang/StaticAnalyzer/Core/CheckerManager.h 
b/clang/include/clang/StaticAnalyzer/Core/CheckerManager.h
index a45ba1bc573e1e..ad25d18f280700 100644
--- a/clang/include/clang/StaticAnalyzer/Core/CheckerManager.h
+++ b/clang/include/clang/StaticAnalyzer/Core/CheckerManager.h
@@ -49,7 +49,7 @@ class ExplodedNodeSet;
 class ExprEngine;
 struct EvalCallOptions;
 class MemRegion;
-struct NodeBuilderContext;
+class NodeBuilderContext;
 class ObjCMethodCall;
 class RegionAndSymbolInvalidationTraits;
 class SVal;
diff --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h 
b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h
index 0705affa4117d9..0ef353bf9731ca 100644
--- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h
+++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h
@@ -193,7 +193,6 @@ class CoreEngine {
   DataTag::Factory &getDataTags() { return DataTags; }
 };
 
-// TODO: Turn into a class.
 class NodeBuilderContext {
   const CoreEngine &Eng;
   const CFGBlock *Block;
diff --git a/clang/include/clang/StaticAnalyzer/Co

[clang] [analyzer] Turn NodeBuilderContext into a class (PR #84638)

2024-03-12 Thread Diego A. Estrada Rivera via cfe-commits


@@ -194,11 +194,12 @@ class CoreEngine {
 };
 
 // TODO: Turn into a class.

diego-est wrote:

Done.

https://github.com/llvm/llvm-project/pull/84638
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [analyzer] Turn NodeBuilderContext into a class (PR #84638)

2024-03-12 Thread Diego A. Estrada Rivera via cfe-commits

diego-est wrote:

Seems like it wasn't as easy as just making them private. I think I found all 
the places where there were private member accesses. The tests passed on my 
side again and the github-pull-requests action. The code_formatter action keeps 
failing because of the documentation on something I didn't touch (but seems to 
be fixed high upstream). Everything should be fixed now.

https://github.com/llvm/llvm-project/pull/84638
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [analyzer] Turn NodeBuilderContext into a class (PR #84638)

2024-03-12 Thread Diego A. Estrada Rivera via cfe-commits

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 
Date: Sat, 9 Mar 2024 12:23:43 -0400
Subject: [PATCH 1/4] [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 
Date: Sun, 10 Mar 2024 21:24:23 -0400
Subject: [PATCH 2/4] 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 {

>From 0d4adf0600c1a86b092fec52749bd781e0ecfd6d Mon Sep 17 00:00:00 2001
From: Sunglas 
Date: Tue, 12 Mar 2024 07:33:34 -0400
Subject: [PATCH 3/4] fix(NodeBuilderContext API): fixed accesses to
 NodeBuilderContext private member accesses.

The files CheckerManager.h, CoreEngine.h, ExprEngine.h and CoreEngine.cpp all 
had bad private member accesses.
---
 clang/include/clang/StaticAnalyzer/Core/CheckerManager.h| 2 +-
 .../clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h| 1 -
 .../clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h| 2 +-
 clang/lib/StaticAnalyzer/Core/CoreEngine.cpp| 6 +++---
 4 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/clang/include/clang/StaticAnalyzer/Core/CheckerManager.h 
b/clang/include/clang/StaticAnalyzer/Core/CheckerManager.h
index a45ba1bc573e1e..ad25d18f280700 100644
--- a/clang/include/clang/StaticAnalyzer/Core/CheckerManager.h
+++ b/clang/include/clang/StaticAnalyzer/Core/CheckerManager.h
@@ -49,7 +49,7 @@ class ExplodedNodeSet;
 class ExprEngine;
 struct EvalCallOptions;
 class MemRegion;
-struct NodeBuilderContext;
+class NodeBuilderContext;
 class ObjCMethodCall;
 class RegionAndSymbolInvalidationTraits;
 class SVal;
diff --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h 
b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h
index 0705affa4117d9..0ef353bf9731ca 100644
--- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h
+++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h
@@ -193,7 +193,6 @@ class CoreEngine {
   DataTag::Factory &getDataTags() { return DataTags; }
 };
 
-// TODO: Turn into a class.
 class NodeBuilderContext {
   const CoreEngine &Eng;
   const CFGBlock *Block;
diff --git a/clang/include/clang/StaticAnalyzer/Co