Skip to content

Commit d31f0fb

Browse files
committed
enabled and fixed modernize-use-auto clang-tidy warnings
1 parent cb9a9a2 commit d31f0fb

3 files changed

Lines changed: 13 additions & 14 deletions

File tree

.clang-tidy

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ Checks: >
3030
-modernize-loop-convert,
3131
-modernize-pass-by-value,
3232
-modernize-return-braced-init-list,
33-
-modernize-use-auto,
3433
-modernize-use-nodiscard,
3534
-modernize-use-trailing-return-type,
3635
-readability-avoid-nested-conditional-operator,

simplecpp.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -253,12 +253,12 @@ class simplecpp::TokenList::Stream {
253253
virtual bool good() = 0;
254254

255255
unsigned char readChar() {
256-
unsigned char ch = static_cast<unsigned char>(get());
256+
auto ch = static_cast<unsigned char>(get());
257257

258258
// For UTF-16 encoded files the BOM is 0xfeff/0xfffe. If the
259259
// character is non-ASCII character then replace it with 0xff
260260
if (isUtf16) {
261-
const unsigned char ch2 = static_cast<unsigned char>(get());
261+
const auto ch2 = static_cast<unsigned char>(get());
262262
const int ch16 = makeUtf16Char(ch, ch2);
263263
ch = static_cast<unsigned char>(((ch16 >= 0x80) ? 0xff : ch16));
264264
}
@@ -281,13 +281,13 @@ class simplecpp::TokenList::Stream {
281281
}
282282

283283
unsigned char peekChar() {
284-
unsigned char ch = static_cast<unsigned char>(peek());
284+
auto ch = static_cast<unsigned char>(peek());
285285

286286
// For UTF-16 encoded files the BOM is 0xfeff/0xfffe. If the
287287
// character is non-ASCII character then replace it with 0xff
288288
if (isUtf16) {
289289
(void)get();
290-
const unsigned char ch2 = static_cast<unsigned char>(peek());
290+
const auto ch2 = static_cast<unsigned char>(peek());
291291
unget();
292292
const int ch16 = makeUtf16Char(ch, ch2);
293293
ch = static_cast<unsigned char>(((ch16 >= 0x80) ? 0xff : ch16));
@@ -1706,7 +1706,7 @@ namespace simplecpp {
17061706
private:
17071707
/** Create new token where Token::macro is set for replaced tokens */
17081708
Token *newMacroToken(const TokenString &str, const Location &loc, bool replaced, const Token *expandedFromToken=nullptr) const {
1709-
Token *tok = new Token(str,loc);
1709+
auto *tok = new Token(str,loc);
17101710
if (replaced)
17111711
tok->macro = nameTokDef->str();
17121712
if (expandedFromToken)
@@ -2366,11 +2366,11 @@ namespace simplecpp {
23662366

23672367
static bool isReplaced(const std::set<std::string> &expandedmacros) {
23682368
// return true if size > 1
2369-
std::set<std::string>::const_iterator it = expandedmacros.begin();
2370-
if (it == expandedmacros.end())
2369+
auto it = expandedmacros.cbegin();
2370+
if (it == expandedmacros.cend())
23712371
return false;
23722372
++it;
2373-
return (it != expandedmacros.end());
2373+
return (it != expandedmacros.cend());
23742374
}
23752375

23762376
/** name token in definition */
@@ -3061,7 +3061,7 @@ std::pair<simplecpp::FileData *, bool> simplecpp::FileDataCache::tryload(FileDat
30613061
return {id_it->second, false};
30623062
}
30633063

3064-
FileData *const data = new FileData {path, TokenList(path, filenames, outputList)};
3064+
auto *const data = new FileData {path, TokenList(path, filenames, outputList)};
30653065

30663066
if (dui.removeComments)
30673067
data->tokens.removeComments();
@@ -3155,7 +3155,7 @@ simplecpp::FileDataCache simplecpp::load(const simplecpp::TokenList &rawtokens,
31553155
std::list<const Token *> filelist;
31563156

31573157
// -include files
3158-
for (std::list<std::string>::const_iterator it = dui.includes.begin(); it != dui.includes.end(); ++it) {
3158+
for (auto it = dui.includes.cbegin(); it != dui.includes.cend(); ++it) {
31593159
const std::string &filename = *it;
31603160

31613161
const auto loadResult = cache.get("", filename, dui, false, filenames, outputList);
@@ -3315,7 +3315,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
33153315
const bool hasInclude = isCpp17OrLater(dui) || isGnu(dui);
33163316
MacroMap macros;
33173317
bool strictAnsiDefined = false;
3318-
for (std::list<std::string>::const_iterator it = dui.defines.begin(); it != dui.defines.end(); ++it) {
3318+
for (auto it = dui.defines.cbegin(); it != dui.defines.cend(); ++it) {
33193319
const std::string &macrostr = *it;
33203320
const std::string::size_type eq = macrostr.find('=');
33213321
const std::string::size_type par = macrostr.find('(');
@@ -3379,7 +3379,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
33793379
std::set<std::string> pragmaOnce;
33803380

33813381
includetokenstack.push(rawtokens.cfront());
3382-
for (std::list<std::string>::const_iterator it = dui.includes.begin(); it != dui.includes.end(); ++it) {
3382+
for (auto it = dui.includes.cbegin(); it != dui.includes.cend(); ++it) {
33833383
const FileData *const filedata = cache.get("", *it, dui, false, files, outputList).first;
33843384
if (filedata != nullptr && filedata->tokens.cfront() != nullptr)
33853385
includetokenstack.push(filedata->tokens.cfront());

simplecpp.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ namespace simplecpp {
425425

426426
void insert(FileData data) {
427427
// NOLINTNEXTLINE(misc-const-correctness) - FP
428-
FileData *const newdata = new FileData(std::move(data));
428+
auto *const newdata = new FileData(std::move(data));
429429

430430
mData.emplace_back(newdata);
431431
mNameMap.emplace(newdata->filename, newdata);

0 commit comments

Comments
 (0)