[clang] 6c4f999 - [analyzer] Fix StreamErrorState hash bug
Balazs Benics via cfe-commits
cfe-commits at lists.llvm.org
Wed Jun 15 07:50:34 PDT 2022
Author: Balazs Benics
Date: 2022-06-15T16:50:12+02:00
New Revision: 6c4f9998ae383d69e97a0d977585f2cb55ff92ed
URL: https://github.com/llvm/llvm-project/commit/6c4f9998ae383d69e97a0d977585f2cb55ff92ed
DIFF: https://github.com/llvm/llvm-project/commit/6c4f9998ae383d69e97a0d977585f2cb55ff92ed.diff
LOG: [analyzer] Fix StreamErrorState hash bug
The `Profile` function was incorrectly implemented.
The `StreamErrorState` has an implicit `bool` conversion operator, which
will result in a different hash than faithfully hashing the raw value of
the enum.
I don't have a test for it, since it seems difficult to find one.
Even if we would have one, any change in the hashing algorithm would
have a chance of breaking it, so I don't think it would justify the
effort.
Depends on D127836, which uncovered this issue by marking the related
`Profile` function dead.
Reviewed By: martong, balazske
Differential Revision: https://reviews.llvm.org/D127839
Added:
Modified:
clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
Removed:
################################################################################
diff --git a/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
index b16e1f012251..1aa665f0ef45 100644
--- a/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
@@ -146,7 +146,7 @@ struct StreamState {
void Profile(llvm::FoldingSetNodeID &ID) const {
ID.AddPointer(LastOperation);
ID.AddInteger(State);
- ID.AddInteger(ErrorState);
+ ErrorState.Profile(ID);
ID.AddBoolean(FilePositionIndeterminate);
}
};
More information about the cfe-commits
mailing list