Skip to content
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

[analyzer][NFC] Turn NodeBuilderContext into a class #84638

Merged
merged 4 commits into from
Mar 12, 2024

Conversation

diego-est
Copy link
Contributor

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.

Copy link

github-actions bot commented Mar 9, 2024

Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be
notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this page.

If this is not working for you, it is probably because you do not have write
permissions for the repository. In which case you can instead tag reviewers by
name in a comment by using @ followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review
by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate
is once a week. Please remember that you are asking for valuable time from other developers.

If you have further questions, they may be answered by the LLVM GitHub User Guide.

You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums.

@llvmbot llvmbot added clang Clang issues not falling into any other category clang:static analyzer labels Mar 9, 2024
@llvmbot
Copy link
Collaborator

llvmbot commented Mar 9, 2024

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

@llvm/pr-subscribers-clang

Author: Diego A. Estrada Rivera (diego-est)

Changes

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.


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

1 Files Affected:

  • (modified) clang/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h (+3-2)
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;

@steakhal
Copy link
Contributor

Thanks for the PR.
I think it would make sense to not expose data members in a class' public api.
We might need some member functions along the way to make this possible.

@steakhal steakhal self-requested a review March 10, 2024 11:11
Copy link
Contributor

@steakhal steakhal left a comment

Choose a reason for hiding this comment

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

See my previous reply.

…ate 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.
@diego-est diego-est requested a review from steakhal March 11, 2024 01:46
@diego-est
Copy link
Contributor Author

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.

Copy link
Contributor

@steakhal steakhal left a comment

Choose a reason for hiding this comment

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

Alright. So we can simply mark all the members private. I was surprised a bit.
LGTM, but remove the TODO comment you fix.

…vate member accesses.

The files CheckerManager.h, CoreEngine.h, ExprEngine.h and CoreEngine.cpp all had bad private member accesses.
Fixed code formatting error in ternary expression.
Copy link

github-actions bot commented Mar 12, 2024

✅ With the latest revision this PR passed the C/C++ code formatter.

@diego-est
Copy link
Contributor Author

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.

@diego-est diego-est requested a review from steakhal March 12, 2024 14:31
@steakhal steakhal changed the title [analyzer] Turn NodeBuilderContext into a class [analyzer][NFC] Turn NodeBuilderContext into a class Mar 12, 2024
@steakhal steakhal merged commit 7bee91f into llvm:main Mar 12, 2024
3 of 4 checks passed
Copy link

@diego-est Congratulations on having your first Pull Request (PR) merged into the LLVM Project!

Your changes will be combined with recent changes from other authors, then tested
by our build bots. If there is a problem with a build, you may recieve a report in an email or a comment on this PR.

Please check whether problems have been caused by your change specifically, as
the builds can include changes from many authors. It is not uncommon for your
change to be included in a build that fails due to someone else's changes, or
infrastructure issues.

How to do this, and the rest of the post-merge process, is covered in detail here.

If your change does cause a problem, it may be reverted, or you can revert it yourself.
This is a normal part of LLVM development. You can fix your changes and open a new PR to merge them again.

If you don't get any reports, no action is required from you. Your changes are working as expected, well done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

None yet

3 participants