[PATCH] D150744: [NFC][CLANG] Fix uninitialized scalar field issues found by Coverity
Balázs Benics via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed May 17 08:22:36 PDT 2023
steakhal added a comment.
Speaking of the `StaticAnalyzer`, I think setting some default value is a fair point, and I think it's a good practice.
In our case, we initialized that field from the registration function, like this:
void ento::registerMoveChecker(CheckerManager &mgr) {
MoveChecker *chk = mgr.registerChecker<MoveChecker>();
chk->setAggressiveness(
mgr.getAnalyzerOptions().getCheckerStringOption(chk, "WarnOn"), mgr); // <--- initialized here
}
================
Comment at: clang/lib/StaticAnalyzer/Checkers/MoveChecker.cpp:187
- AggressivenessKind Aggressiveness;
+ AggressivenessKind Aggressiveness = AK_Invalid;
----------------
By looking at the default value of the `Move.WarnOn` checker option [[ https://github.com/llvm/llvm-project/blob/main/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td#L668 | here ]], we should probably initialize this field to the default value matching the default value of the config.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D150744/new/
https://reviews.llvm.org/D150744
More information about the cfe-commits
mailing list