Skip to content

Commit 34dad93

Browse files
committed
mitigated misc-const-correctness clang-tidy warnings
1 parent e8b7c81 commit 34dad93

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
@@ -150,12 +150,12 @@ static bool endsWith(const std::string &s, const std::string &e)
150150
return (s.size() >= e.size()) && std::equal(e.rbegin(), e.rend(), s.rbegin());
151151
}
152152

153-
static bool sameline(const simplecpp::Token *tok1, const simplecpp::Token *tok2)
153+
static bool sameline(const simplecpp::Token * const tok1, const simplecpp::Token * const tok2)
154154
{
155155
return tok1 && tok2 && tok1->location.sameline(tok2->location);
156156
}
157157

158-
static bool isAlternativeBinaryOp(const simplecpp::Token *tok, const std::string &alt)
158+
static bool isAlternativeBinaryOp(const simplecpp::Token * const tok, const std::string &alt)
159159
{
160160
return (tok->name &&
161161
tok->str() == alt &&
@@ -165,7 +165,7 @@ static bool isAlternativeBinaryOp(const simplecpp::Token *tok, const std::string
165165
(tok->next->number || tok->next->name || tok->next->op == '('));
166166
}
167167

168-
static bool isAlternativeUnaryOp(const simplecpp::Token *tok, const std::string &alt)
168+
static bool isAlternativeUnaryOp(const simplecpp::Token * const tok, const std::string &alt)
169169
{
170170
return ((tok->name && tok->str() == alt) &&
171171
(!tok->previous || tok->previous->op == '(') &&
@@ -619,7 +619,7 @@ static std::string escapeString(const std::string &str)
619619
return ostr.str();
620620
}
621621

622-
static void portabilityBackslash(simplecpp::OutputList *outputList, const simplecpp::Location &location)
622+
static void portabilityBackslash(simplecpp::OutputList * const outputList, const simplecpp::Location &location)
623623
{
624624
if (!outputList)
625625
return;
@@ -1013,7 +1013,7 @@ void simplecpp::TokenList::constFold()
10131013
}
10141014
}
10151015

1016-
static bool isFloatSuffix(const simplecpp::Token *tok)
1016+
static bool isFloatSuffix(const simplecpp::Token * const tok)
10171017
{
10181018
if (!tok || tok->str().size() != 1U)
10191019
return false;
@@ -1024,7 +1024,7 @@ static bool isFloatSuffix(const simplecpp::Token *tok)
10241024
static const std::string AND("and");
10251025
static const std::string BITAND("bitand");
10261026
static const std::string BITOR("bitor");
1027-
static bool isAlternativeAndBitandBitor(const simplecpp::Token* tok)
1027+
static bool isAlternativeAndBitandBitor(const simplecpp::Token * const tok)
10281028
{
10291029
return isAlternativeBinaryOp(tok, AND) || isAlternativeBinaryOp(tok, BITAND) || isAlternativeBinaryOp(tok, BITOR);
10301030
}
@@ -2306,7 +2306,7 @@ namespace simplecpp {
23062306
* @return token after B
23072307
*/
23082308
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 {
2309-
Token *A = output.back();
2309+
Token * const A = output.back();
23102310
if (!A)
23112311
throw invalidHashHash(tok->location, name(), "Missing first argument");
23122312
if (!sameline(tok, tok->next) || !sameline(tok, tok->next->next))
@@ -3090,7 +3090,7 @@ static std::string openHeader(std::ifstream &f, const simplecpp::DUI &dui, const
30903090
return "";
30913091
}
30923092

3093-
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)
3093+
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)
30943094
{
30953095
const std::string &path = name_it->first;
30963096
FileID fileId;
@@ -3202,7 +3202,7 @@ bool simplecpp::FileDataCache::getFileId(const std::string &path, FileID &id)
32023202
#endif
32033203
}
32043204

3205-
simplecpp::FileDataCache simplecpp::load(const simplecpp::TokenList &rawtokens, std::vector<std::string> &filenames, const simplecpp::DUI &dui, simplecpp::OutputList *outputList, FileDataCache cache)
3205+
simplecpp::FileDataCache simplecpp::load(const simplecpp::TokenList &rawtokens, std::vector<std::string> &filenames, const simplecpp::DUI &dui, simplecpp::OutputList * const outputList, FileDataCache cache)
32063206
{
32073207
#ifdef SIMPLECPP_WINDOWS
32083208
if (dui.clearIncludeCache)
@@ -3285,7 +3285,7 @@ simplecpp::FileDataCache simplecpp::load(const simplecpp::TokenList &rawtokens,
32853285
return cache;
32863286
}
32873287

3288-
static bool preprocessToken(simplecpp::TokenList &output, const simplecpp::Token *&tok1, simplecpp::MacroMap &macros, std::vector<std::string> &files, simplecpp::OutputList *outputList)
3288+
static bool preprocessToken(simplecpp::TokenList &output, const simplecpp::Token *&tok1, simplecpp::MacroMap &macros, std::vector<std::string> &files, simplecpp::OutputList * const outputList)
32893289
{
32903290
const simplecpp::Token * const tok = tok1;
32913291
const simplecpp::MacroMap::const_iterator it = tok->name ? macros.find(tok->str()) : macros.end();
@@ -3325,21 +3325,21 @@ static void getLocaltime(struct tm &ltime)
33253325
#endif
33263326
}
33273327

3328-
static std::string getDateDefine(const struct tm *timep)
3328+
static std::string getDateDefine(const struct tm * const timep)
33293329
{
33303330
char buf[] = "??? ?? ????";
33313331
strftime(buf, sizeof(buf), "%b %d %Y", timep);
33323332
return std::string("\"").append(buf).append("\"");
33333333
}
33343334

3335-
static std::string getTimeDefine(const struct tm *timep)
3335+
static std::string getTimeDefine(const struct tm * const timep)
33363336
{
33373337
char buf[] = "??:??:??";
33383338
strftime(buf, sizeof(buf), "%H:%M:%S", timep);
33393339
return std::string("\"").append(buf).append("\"");
33403340
}
33413341

3342-
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)
3342+
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)
33433343
{
33443344
#ifdef SIMPLECPP_WINDOWS
33453345
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
}
@@ -3868,7 +3868,7 @@ static void leak()
38683868
}
38693869
}
38703870

3871-
static void runTests(int argc, char **argv, Input input)
3871+
static void runTests(int argc, char *argv[], Input input)
38723872
{
38733873
USE_INPUT = input;
38743874

@@ -4159,7 +4159,7 @@ static void runTests(int argc, char **argv, Input input)
41594159
TEST_CASE(leak);
41604160
}
41614161

4162-
int main(int argc, char **argv)
4162+
int main(int argc, char *argv[])
41634163
{
41644164
runTests(argc, argv, Input::Stringstream);
41654165
runTests(argc, argv, Input::CharBuffer);

0 commit comments

Comments
 (0)