Skip to content

Commit cbdc3e1

Browse files
committed
[clang-tidy][NFC] Fix cppcoreguidelines-init-variables findings
Fix issues found by clang-tidy in clang-tidy source directory.
1 parent 9f82209 commit cbdc3e1

35 files changed

+59
-63
lines changed

clang-tools-extra/clang-tidy/ClangTidy.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ class ErrorReporter {
133133
for (const FileByteRange &FBR : Error.Message.Ranges)
134134
Diag << getRange(FBR);
135135
// FIXME: explore options to support interactive fix selection.
136-
const llvm::StringMap<Replacements> *ChosenFix;
136+
const llvm::StringMap<Replacements> *ChosenFix = nullptr;
137137
if (ApplyFixes != FB_NoFix &&
138138
(ChosenFix = getFixIt(Error, ApplyFixes == FB_FixNotes))) {
139139
for (const auto &FileAndReplacements : *ChosenFix) {

clang-tools-extra/clang-tidy/ClangTidyCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ static std::optional<bool> getAsBool(StringRef Value,
9797
return Parsed;
9898
// To maintain backwards compatability, we support parsing numbers as
9999
// booleans, even though its not supported in YAML.
100-
long long Number;
100+
long long Number = 0;
101101
if (!Value.getAsInteger(10, Number))
102102
return Number != 0;
103103
return std::nullopt;

clang-tools-extra/clang-tidy/abseil/DurationFactoryScaleCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ void DurationFactoryScaleCheck::check(const MatchFinder::MatchResult &Result) {
159159
return;
160160

161161
DurationScale Scale = *MaybeScale;
162-
const Expr *Remainder;
162+
const Expr *Remainder = nullptr;
163163
std::optional<DurationScale> NewScale;
164164

165165
// We next handle the cases of multiplication and division.

clang-tools-extra/clang-tidy/abseil/RedundantStrcatCallsCheck.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,9 @@ StrCatCheckResult processCall(const CallExpr *RootCall, bool IsAppend,
103103
} // namespace
104104

105105
void RedundantStrcatCallsCheck::check(const MatchFinder::MatchResult& Result) {
106-
bool IsAppend;
106+
bool IsAppend = false;
107107

108-
const CallExpr* RootCall;
108+
const CallExpr *RootCall = nullptr;
109109
if ((RootCall = Result.Nodes.getNodeAs<CallExpr>("StrCat")))
110110
IsAppend = false;
111111
else if ((RootCall = Result.Nodes.getNodeAs<CallExpr>("StrAppend")))

clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ bool UnrollLoopsCheck::hasLargeNumIterations(const Stmt *Statement,
203203
// If increment is binary and not one of +, -, *, /, we can't know the loop
204204
// bounds.
205205
if (const auto *Op = dyn_cast<BinaryOperator>(Increment)) {
206-
int ConstantValue;
206+
int ConstantValue = 0;
207207
if (!extractValue(ConstantValue, Op, Context))
208208
return true;
209209
switch (Op->getOpcode()) {

clang-tools-extra/clang-tidy/bugprone/ImplicitWideningOfMultiplicationResultCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ void ImplicitWideningOfMultiplicationResultCheck::handlePointerOffsetting(
151151

152152
// We are looking for a pointer offset operation,
153153
// with one hand being a pointer, and another one being an offset.
154-
const Expr *PointerExpr, *IndexExpr;
154+
const Expr *PointerExpr = nullptr, *IndexExpr = nullptr;
155155
if (const auto *BO = dyn_cast<BinaryOperator>(E)) {
156156
PointerExpr = BO->getLHS();
157157
IndexExpr = BO->getRHS();

clang-tools-extra/clang-tidy/bugprone/MisplacedWideningCastCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ static int relativeCharSizesW(BuiltinType::Kind Kind) {
163163
}
164164

165165
static bool isFirstWider(BuiltinType::Kind First, BuiltinType::Kind Second) {
166-
int FirstSize, SecondSize;
166+
int FirstSize = 0, SecondSize = 0;
167167
if ((FirstSize = relativeIntSizes(First)) != 0 &&
168168
(SecondSize = relativeIntSizes(Second)) != 0)
169169
return FirstSize > SecondSize;

clang-tools-extra/clang-tidy/bugprone/MultipleNewInOneExpressionCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ bool isExprValueStored(const Expr *E, ASTContext &C) {
2929
DynTypedNodeList P = PMap.getParents(*E);
3030
if (P.size() != 1)
3131
return false;
32-
const Expr *ParentE;
32+
const Expr *ParentE = nullptr;
3333
while ((ParentE = P[0].get<Expr>()) && ParentE->IgnoreParenCasts() == E) {
3434
P = PMap.getParents(P[0]);
3535
if (P.size() != 1)

clang-tools-extra/clang-tidy/bugprone/RedundantBranchConditionCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ void RedundantBranchConditionCheck::check(const MatchFinder::MatchResult &Result
7676
const auto *CondVar = Result.Nodes.getNodeAs<VarDecl>(CondVarStr);
7777
const auto *Func = Result.Nodes.getNodeAs<FunctionDecl>(FuncStr);
7878

79-
const DeclRefExpr *OuterIfVar, *InnerIfVar;
79+
const DeclRefExpr *OuterIfVar = nullptr, *InnerIfVar = nullptr;
8080
if (const auto *Inner = Result.Nodes.getNodeAs<DeclRefExpr>(InnerIfVar1Str))
8181
InnerIfVar = Inner;
8282
else

clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ bool SignalHandlerCheck::checkFunctionCPP14(
480480
return true;
481481
}
482482

483-
const FunctionDecl *FBody;
483+
const FunctionDecl *FBody = nullptr;
484484
const Stmt *BodyS = FD->getBody(FBody);
485485
if (!BodyS)
486486
return false;

0 commit comments

Comments
 (0)