Skip to content

Commit 4aa4006

Browse files
authored
enabled and fixed modernize-use-auto clang-tidy warnings (#574)
1 parent e78af46 commit 4aa4006

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));
@@ -1705,7 +1705,7 @@ namespace simplecpp {
17051705
private:
17061706
/** Create new token where Token::macro is set for replaced tokens */
17071707
Token *newMacroToken(const TokenString &str, const Location &loc, bool replaced, const Token *expandedFromToken=nullptr) const {
1708-
Token *tok = new Token(str,loc);
1708+
auto *tok = new Token(str,loc);
17091709
if (replaced)
17101710
tok->macro = nameTokDef->str();
17111711
if (expandedFromToken)
@@ -2365,11 +2365,11 @@ namespace simplecpp {
23652365

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

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

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

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

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

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

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

simplecpp.h

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

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

428428
mData.emplace_back(newdata);
429429
mNameMap.emplace(newdata->filename, newdata);

0 commit comments

Comments
 (0)