Skip to content

Commit 6b2b1c2

Browse files
committed
mitigated misc-const-correctness clang-tidy warnings
1 parent e8b7c81 commit 6b2b1c2

3 files changed

Lines changed: 19 additions & 19 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: 7 additions & 7 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 == '(') &&
@@ -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
}
@@ -3325,14 +3325,14 @@ 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);

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)