Skip to content

Commit cdc6591

Browse files
committed
Fix sanitizer issue
1 parent 98d252e commit cdc6591

File tree

3 files changed

+9
-14
lines changed

3 files changed

+9
-14
lines changed

clang-tools-extra/clang-tidy/modernize/MinMaxUseInitializerListCheck.cpp

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,12 @@ static FindArgsResult findArgs(const CallExpr *Call) {
6060

6161
return Result;
6262
}
63+
Result.Args = SmallVector<const Expr *>(Call->arguments());
6364
} else {
6465
// if it has 3 arguments then the last will be the comparison
6566
Result.Compare = *(std::next(Call->arguments().begin(), 2));
66-
}
67-
68-
if (Result.Compare)
6967
Result.Args = SmallVector<const Expr *>(llvm::drop_end(Call->arguments()));
70-
else
71-
Result.Args = SmallVector<const Expr *>(Call->arguments());
72-
68+
}
7369
Result.First = Result.Args.front();
7470
Result.Last = Result.Args.back();
7571

@@ -80,7 +76,7 @@ static SmallVector<FixItHint>
8076
generateReplacements(const MatchFinder::MatchResult &Match,
8177
const CallExpr *TopCall, const FindArgsResult &Result,
8278
const bool IgnoreNonTrivialTypes,
83-
const long IgnoreTrivialTypesOfSizeAbove) {
79+
const std::uint64_t IgnoreTrivialTypesOfSizeAbove) {
8480
SmallVector<FixItHint> FixItHints;
8581
const SourceManager &SourceMngr = *Match.SourceManager;
8682
const LangOptions &LanguageOpts = Match.Context->getLangOpts();
@@ -98,7 +94,6 @@ generateReplacements(const MatchFinder::MatchResult &Match,
9894
return FixItHints;
9995

10096
if (isResultTypeTrivial &&
101-
// size in bits divided by 8 to get bytes
10297
Match.Context->getTypeSizeInChars(ResultType).getQuantity() >
10398
IgnoreTrivialTypesOfSizeAbove)
10499
return FixItHints;
@@ -125,11 +120,11 @@ generateReplacements(const MatchFinder::MatchResult &Match,
125120
.concat(ResultType.getAsString(LanguageOpts))
126121
.concat(">(")
127122
.concat(ArgText)
128-
.concat(")");
129-
130-
FixItHints.push_back(FixItHint::CreateReplacement(Arg->getSourceRange(),
131-
Replacement.str()));
123+
.concat(")")
124+
.str();
132125

126+
FixItHints.push_back(
127+
FixItHint::CreateReplacement(Arg->getSourceRange(), Replacement));
133128
continue;
134129
}
135130

clang-tools-extra/clang-tidy/modernize/MinMaxUseInitializerListCheck.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class MinMaxUseInitializerListCheck : public ClangTidyCheck {
4747

4848
private:
4949
bool IgnoreNonTrivialTypes;
50-
long IgnoreTrivialTypesOfSizeAbove;
50+
std::uint64_t IgnoreTrivialTypesOfSizeAbove;
5151
utils::IncludeInserter Inserter;
5252
};
5353

clang-tools-extra/docs/clang-tidy/checks/modernize/min-max-use-initializer-list.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,4 @@ Options
4747
.. option:: IgnoreTrivialTypesOfSizeAbove
4848

4949
An integer specifying the size (in bytes) above which trivial types are
50-
ignored. Default is `32`.
50+
ignored. Default is `32`.

0 commit comments

Comments
 (0)