[PATCH] D150744: [NFC][CLANG] Fix uninitialized scalar field issues found by Coverity
Soumi Manna via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed May 17 09:05:34 PDT 2023
Manna marked an inline comment as done.
Manna added inline comments.
================
Comment at: clang/lib/StaticAnalyzer/Checkers/MoveChecker.cpp:187
- AggressivenessKind Aggressiveness;
+ AggressivenessKind Aggressiveness = AK_Invalid;
----------------
steakhal wrote:
> 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.
```
void setAggressiveness(StringRef Str, CheckerManager &Mgr) {
Aggressiveness =
llvm::StringSwitch<AggressivenessKind>(Str)
.Case("KnownsOnly", AK_KnownsOnly)
.Case("KnownsAndLocals", AK_KnownsAndLocals)
.Case("All", AK_All)
.Default(AK_Invalid);
if (Aggressiveness == AK_Invalid)
Mgr.reportInvalidCheckerOptionValue(this, "WarnOn",
"either \"KnownsOnly\", \"KnownsAndLocals\" or \"All\" string value");
```
By looking at the codes above, my understanding was that default value is AK_Invalid. Thank you @steakhal for the pointer and the explanation.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D150744/new/
https://reviews.llvm.org/D150744
More information about the cfe-commits
mailing list