Skip to content

Commit b8a194d

Browse files
committed
mitigated misc-const-correctness clang-tidy warnings
1 parent 746c5d6 commit b8a194d

3 files changed

Lines changed: 25 additions & 25 deletions

File tree

main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ static bool isDir(const std::string& path)
2626
return (file_stat.st_mode & S_IFMT) == S_IFDIR;
2727
}
2828

29-
int main(int argc, char **argv)
29+
int main(int argc, char *argv[])
3030
{
3131
bool error = false;
3232
const char *filename = nullptr;

simplecpp.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -153,12 +153,12 @@ static bool endsWith(const std::string &s, const std::string &e)
153153
return (s.size() >= e.size()) && std::equal(e.rbegin(), e.rend(), s.rbegin());
154154
}
155155

156-
static bool sameline(const simplecpp::Token *tok1, const simplecpp::Token *tok2)
156+
static bool sameline(const simplecpp::Token * const tok1, const simplecpp::Token * const tok2)
157157
{
158158
return tok1 && tok2 && tok1->location.sameline(tok2->location);
159159
}
160160

161-
static bool isAlternativeBinaryOp(const simplecpp::Token *tok, const std::string &alt)
161+
static bool isAlternativeBinaryOp(const simplecpp::Token * const tok, const std::string &alt)
162162
{
163163
return (tok->name &&
164164
tok->str() == alt &&
@@ -168,7 +168,7 @@ static bool isAlternativeBinaryOp(const simplecpp::Token *tok, const std::string
168168
(tok->next->number || tok->next->name || tok->next->op == '('));
169169
}
170170

171-
static bool isAlternativeUnaryOp(const simplecpp::Token *tok, const std::string &alt)
171+
static bool isAlternativeUnaryOp(const simplecpp::Token * const tok, const std::string &alt)
172172
{
173173
return ((tok->name && tok->str() == alt) &&
174174
(!tok->previous || tok->previous->op == '(') &&
@@ -622,7 +622,7 @@ static std::string escapeString(const std::string &str)
622622
return ostr.str();
623623
}
624624

625-
static void portabilityBackslash(simplecpp::OutputList *outputList, const simplecpp::Location &location)
625+
static void portabilityBackslash(simplecpp::OutputList * const outputList, const simplecpp::Location &location)
626626
{
627627
if (!outputList)
628628
return;
@@ -999,7 +999,7 @@ void simplecpp::TokenList::constFold()
999999
}
10001000
}
10011001

1002-
static bool isFloatSuffix(const simplecpp::Token *tok)
1002+
static bool isFloatSuffix(const simplecpp::Token * const tok)
10031003
{
10041004
if (!tok || tok->str().size() != 1U)
10051005
return false;
@@ -1010,7 +1010,7 @@ static bool isFloatSuffix(const simplecpp::Token *tok)
10101010
static const std::string AND("and");
10111011
static const std::string BITAND("bitand");
10121012
static const std::string BITOR("bitor");
1013-
static bool isAlternativeAndBitandBitor(const simplecpp::Token* tok)
1013+
static bool isAlternativeAndBitandBitor(const simplecpp::Token * const tok)
10141014
{
10151015
return isAlternativeBinaryOp(tok, AND) || isAlternativeBinaryOp(tok, BITAND) || isAlternativeBinaryOp(tok, BITOR);
10161016
}
@@ -2292,7 +2292,7 @@ namespace simplecpp {
22922292
* @return token after B
22932293
*/
22942294
const Token *expandHashHash(TokenList &output, const Location &loc, const Token *tok, const MacroMap &macros, const std::set<TokenString> &expandedmacros, const std::vector<const Token*> &parametertokens, bool expandResult=true) const {
2295-
Token *A = output.back();
2295+
Token * const A = output.back();
22962296
if (!A)
22972297
throw invalidHashHash(tok->location, name(), "Missing first argument");
22982298
if (!sameline(tok, tok->next) || !sameline(tok, tok->next->next))
@@ -3132,7 +3132,7 @@ simplecpp::FileDataCache &simplecpp::FileDataCache::operator=(simplecpp::FileDat
31323132

31333133
static bool getFileId(const std::string &path, FileID &id);
31343134

3135-
std::pair<simplecpp::FileData *, bool> simplecpp::FileDataCache::tryload(FileDataCache::name_map_type::iterator &name_it, const simplecpp::DUI &dui, std::vector<std::string> &filenames, simplecpp::OutputList *outputList)
3135+
std::pair<simplecpp::FileData *, bool> simplecpp::FileDataCache::tryload(FileDataCache::name_map_type::iterator &name_it, const simplecpp::DUI &dui, std::vector<std::string> &filenames, simplecpp::OutputList * const outputList)
31363136
{
31373137
const std::string &path = name_it->first;
31383138
FileID fileId;
@@ -3251,7 +3251,7 @@ static bool getFileId(const std::string &path, FileID &id)
32513251
#endif
32523252
}
32533253

3254-
simplecpp::FileDataCache simplecpp::load(const simplecpp::TokenList &rawtokens, std::vector<std::string> &filenames, const simplecpp::DUI &dui, simplecpp::OutputList *outputList, FileDataCache cache)
3254+
simplecpp::FileDataCache simplecpp::load(const simplecpp::TokenList &rawtokens, std::vector<std::string> &filenames, const simplecpp::DUI &dui, simplecpp::OutputList * const outputList, FileDataCache cache)
32553255
{
32563256
#ifdef SIMPLECPP_WINDOWS
32573257
if (dui.clearIncludeCache)
@@ -3334,7 +3334,7 @@ simplecpp::FileDataCache simplecpp::load(const simplecpp::TokenList &rawtokens,
33343334
return cache;
33353335
}
33363336

3337-
static bool preprocessToken(simplecpp::TokenList &output, const simplecpp::Token *&tok1, simplecpp::MacroMap &macros, std::vector<std::string> &files, simplecpp::OutputList *outputList)
3337+
static bool preprocessToken(simplecpp::TokenList &output, const simplecpp::Token *&tok1, simplecpp::MacroMap &macros, std::vector<std::string> &files, simplecpp::OutputList * const outputList)
33383338
{
33393339
const simplecpp::Token * const tok = tok1;
33403340
const simplecpp::MacroMap::const_iterator it = tok->name ? macros.find(tok->str()) : macros.end();
@@ -3374,21 +3374,21 @@ static void getLocaltime(struct tm &ltime)
33743374
#endif
33753375
}
33763376

3377-
static std::string getDateDefine(const struct tm *timep)
3377+
static std::string getDateDefine(const struct tm * const timep)
33783378
{
33793379
char buf[] = "??? ?? ????";
33803380
strftime(buf, sizeof(buf), "%b %d %Y", timep);
33813381
return std::string("\"").append(buf).append("\"");
33823382
}
33833383

3384-
static std::string getTimeDefine(const struct tm *timep)
3384+
static std::string getTimeDefine(const struct tm * const timep)
33853385
{
33863386
char buf[] = "??:??:??";
33873387
strftime(buf, sizeof(buf), "%H:%M:%S", timep);
33883388
return std::string("\"").append(buf).append("\"");
33893389
}
33903390

3391-
void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenList &rawtokens, std::vector<std::string> &files, simplecpp::FileDataCache &cache, const simplecpp::DUI &dui, simplecpp::OutputList *outputList, std::list<simplecpp::MacroUsage> *macroUsage, std::list<simplecpp::IfCond> *ifCond)
3391+
void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenList &rawtokens, std::vector<std::string> &files, simplecpp::FileDataCache &cache, const simplecpp::DUI &dui, simplecpp::OutputList * const outputList, std::list<simplecpp::MacroUsage> * const macroUsage, std::list<simplecpp::IfCond> * const ifCond)
33923392
{
33933393
#ifdef SIMPLECPP_WINDOWS
33943394
if (dui.clearIncludeCache)

test.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ static void assertThrowFailed(int line)
8686
std::cerr << "exception not thrown" << std::endl;
8787
}
8888

89-
static void testcase(const std::string &name, void (*f)(), int argc, char * const *argv)
89+
static void testcase(const std::string &name, void (*const f)(), int argc, char *argv[])
9090
{
9191
if (argc == 1) {
9292
f();
@@ -101,7 +101,7 @@ static void testcase(const std::string &name, void (*f)(), int argc, char * cons
101101

102102
#define TEST_CASE(F) (testcase(#F, F, argc, argv))
103103

104-
static simplecpp::TokenList makeTokenList(const char code[], std::size_t size, std::vector<std::string> &filenames, const std::string &filename=std::string(), simplecpp::OutputList *outputList=nullptr)
104+
static simplecpp::TokenList makeTokenList(const char code[], std::size_t size, std::vector<std::string> &filenames, const std::string &filename=std::string(), simplecpp::OutputList * const outputList=nullptr)
105105
{
106106
switch (USE_INPUT) {
107107
case Input::Stringstream: {
@@ -115,24 +115,24 @@ static simplecpp::TokenList makeTokenList(const char code[], std::size_t size, s
115115
return simplecpp::TokenList{filenames}; // unreachable - needed for GCC and Visual Studio
116116
}
117117

118-
static simplecpp::TokenList makeTokenList(const char code[], std::vector<std::string> &filenames, const std::string &filename=std::string(), simplecpp::OutputList *outputList=nullptr)
118+
static simplecpp::TokenList makeTokenList(const char code[], std::vector<std::string> &filenames, const std::string &filename=std::string(), simplecpp::OutputList * const outputList=nullptr)
119119
{
120120
return makeTokenList(code, strlen(code), filenames, filename, outputList);
121121
}
122122

123-
static std::string readfile(const char code[], simplecpp::OutputList *outputList=nullptr)
123+
static std::string readfile(const char code[], simplecpp::OutputList * const outputList=nullptr)
124124
{
125125
std::vector<std::string> files;
126126
return makeTokenList(code,files,std::string(),outputList).stringify();
127127
}
128128

129-
static std::string readfile(const char code[], std::size_t size, simplecpp::OutputList *outputList=nullptr)
129+
static std::string readfile(const char code[], std::size_t size, simplecpp::OutputList * const outputList=nullptr)
130130
{
131131
std::vector<std::string> files;
132132
return makeTokenList(code,size,files,std::string(),outputList).stringify();
133133
}
134134

135-
static std::string preprocess(const char code[], const simplecpp::DUI &dui, simplecpp::OutputList *outputList, std::list<simplecpp::MacroUsage> *macroUsage = nullptr, std::list<simplecpp::IfCond> *ifCond = nullptr, const std::string &file = std::string())
135+
static std::string preprocess(const char code[], const simplecpp::DUI &dui, simplecpp::OutputList * const outputList, std::list<simplecpp::MacroUsage> * const macroUsage = nullptr, std::list<simplecpp::IfCond> * const ifCond = nullptr, const std::string &file = std::string())
136136
{
137137
std::vector<std::string> files;
138138
simplecpp::FileDataCache cache;
@@ -160,17 +160,17 @@ static std::string preprocess(const char code[], const simplecpp::DUI &dui)
160160
return preprocess(code, dui, nullptr);
161161
}
162162

163-
static std::string preprocess(const char code[], simplecpp::OutputList *outputList)
163+
static std::string preprocess(const char code[], simplecpp::OutputList * const outputList)
164164
{
165165
return preprocess(code, simplecpp::DUI(), outputList);
166166
}
167167

168-
static std::string preprocess(const char code[], std::list<simplecpp::IfCond> *ifCond)
168+
static std::string preprocess(const char code[], std::list<simplecpp::IfCond> * const ifCond)
169169
{
170170
return preprocess(code, simplecpp::DUI(), nullptr, nullptr, ifCond);
171171
}
172172

173-
static std::string preprocess(const char code[], std::list<simplecpp::MacroUsage> *macroUsage)
173+
static std::string preprocess(const char code[], std::list<simplecpp::MacroUsage> * const macroUsage)
174174
{
175175
return preprocess(code, simplecpp::DUI(), nullptr, macroUsage);
176176
}
@@ -3879,7 +3879,7 @@ static void leak()
38793879
}
38803880
}
38813881

3882-
static void runTests(int argc, char **argv, Input input)
3882+
static void runTests(int argc, char *argv[], Input input)
38833883
{
38843884
USE_INPUT = input;
38853885

@@ -4171,7 +4171,7 @@ static void runTests(int argc, char **argv, Input input)
41714171
TEST_CASE(leak);
41724172
}
41734173

4174-
int main(int argc, char **argv)
4174+
int main(int argc, char *argv[])
41754175
{
41764176
runTests(argc, argv, Input::Stringstream);
41774177
runTests(argc, argv, Input::CharBuffer);

0 commit comments

Comments
 (0)