[NFC] [clang-tidy] Fix potential SA issues. (#170289)
This patch addresses issues identified by the static analyzers, which appear to be legitimate problems. `FloatLoopCounterCheck.cpp`: "Dereferencing a pointer that might be `nullptr` FS when calling `getInc`". `ProBoundsAvoidUncheckedContainerAccessCheck.cpp`: "Dereferencing a pointer that might be `nullptr Callee` when calling `getBeginLoc`". `ExpandModularHeadersPPCallbacks.cpp`: Non-static class member `CurrentToken.Flags` is not initialized in this constructor nor in any functions that it calls. (line #101).
This commit is contained in:
parent
6984f942bc
commit
c6910201cc
@ -137,7 +137,7 @@ private:
|
||||
std::unique_ptr<Preprocessor> PP;
|
||||
bool EnteredMainFile = false;
|
||||
bool StartedLexing = false;
|
||||
Token CurrentToken;
|
||||
Token CurrentToken = Token();
|
||||
};
|
||||
|
||||
} // namespace tooling
|
||||
|
||||
@ -31,6 +31,7 @@ void FloatLoopCounterCheck::registerMatchers(MatchFinder *Finder) {
|
||||
|
||||
void FloatLoopCounterCheck::check(const MatchFinder::MatchResult &Result) {
|
||||
const auto *FS = Result.Nodes.getNodeAs<ForStmt>("for");
|
||||
assert(FS && "FS should not be null");
|
||||
|
||||
diag(FS->getInc()->getBeginLoc(), "loop induction expression should not have "
|
||||
"floating-point type")
|
||||
|
||||
@ -176,7 +176,7 @@ void ProBoundsAvoidUncheckedContainerAccessCheck::check(
|
||||
}
|
||||
} else if (const auto *MCE = dyn_cast<CXXMemberCallExpr>(MatchedExpr)) {
|
||||
// Case: a.operator[](i) or a->operator[](i)
|
||||
const auto *Callee = dyn_cast<MemberExpr>(MCE->getCallee());
|
||||
const auto *Callee = cast<MemberExpr>(MCE->getCallee());
|
||||
|
||||
if (FixMode == At) {
|
||||
// Cases: a.operator[](i) => a.at(i) and a->operator[](i) => a->at(i)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user