Skip to content

[clang][analyzer]][NFC] Simplify method 'ensureStreamNonNull' of StreamChecker #70927

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

Merged
merged 1 commit into from
Nov 2, 2023
Merged

[clang][analyzer]][NFC] Simplify method 'ensureStreamNonNull' of StreamChecker #70927

merged 1 commit into from
Nov 2, 2023

Conversation

benshi001
Copy link
Member

The passed in parameter 'State' is always identical to 'C.getState()'.

…mChecker

The passed in parameter 'State' is always identical to 'C.getState()'.
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:static analyzer labels Nov 1, 2023
@llvmbot
Copy link
Member

llvmbot commented Nov 1, 2023

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

@llvm/pr-subscribers-clang

Author: Ben Shi (benshi001)

Changes

The passed in parameter 'State' is always identical to 'C.getState()'.


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

1 Files Affected:

  • (modified) clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp (+1-1)
diff --git a/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
index 4b7103c20557cc4..a5f8d855f8e06e1 100644
--- a/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
@@ -1037,7 +1037,7 @@ StreamChecker::ensureStreamNonNull(SVal StreamVal, const Expr *StreamE,
   ConstraintManager &CM = C.getConstraintManager();
 
   ProgramStateRef StateNotNull, StateNull;
-  std::tie(StateNotNull, StateNull) = CM.assumeDual(C.getState(), *Stream);
+  std::tie(StateNotNull, StateNull) = CM.assumeDual(State, *Stream);
 
   if (!StateNotNull && StateNull) {
     if (ExplodedNode *N = C.generateErrorNode(StateNull)) {

@benshi001 benshi001 changed the title [clang][analyzer] Simplify method 'ensureStreamNonNull' of StreamChecker [clang][analyzer]][NFC] Simplify method 'ensureStreamNonNull' of StreamChecker Nov 1, 2023
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.

You are right.
I'm not sure it improves the code too much, and I wonder if you have further ideas refactoring the checker; if so we could probably bundle up similar changes into this one.

@benshi001
Copy link
Member Author

much, and I wonder if you have further ideas refactoring the checker; if so we could probably bundle up similar changes into this one.

Thanks for your reply. Actually I have no plan about improving this checker. Currently I am just reading its code and trying to understand its details.

@benshi001 benshi001 merged commit e98f3bf into llvm:main Nov 2, 2023
@benshi001 benshi001 deleted the csa-delete branch November 2, 2023 06:41
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.

3 participants