Skip to content

Commit 5989164

Browse files
committed
fixed misc-const-correctness clang-tidy warnings
s fixed `misc-const-correctness` clang-tidy warnings
1 parent 3c1bdcc commit 5989164

3 files changed

Lines changed: 18 additions & 18 deletions

File tree

main.cpp

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

27-
int main(int argc, char **argv)
27+
int main(int argc, char *argv[])
2828
{
2929
bool error = false;
3030
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 == '(') &&
@@ -998,7 +998,7 @@ void simplecpp::TokenList::constFold()
998998
}
999999
}
10001000

1001-
static bool isFloatSuffix(const simplecpp::Token *tok)
1001+
static bool isFloatSuffix(const simplecpp::Token * const tok)
10021002
{
10031003
if (!tok || tok->str().size() != 1U)
10041004
return false;
@@ -1009,7 +1009,7 @@ static bool isFloatSuffix(const simplecpp::Token *tok)
10091009
static const std::string AND("and");
10101010
static const std::string BITAND("bitand");
10111011
static const std::string BITOR("bitor");
1012-
static bool isAlternativeAndBitandBitor(const simplecpp::Token* tok)
1012+
static bool isAlternativeAndBitandBitor(const simplecpp::Token * const tok)
10131013
{
10141014
return isAlternativeBinaryOp(tok, AND) || isAlternativeBinaryOp(tok, BITAND) || isAlternativeBinaryOp(tok, BITOR);
10151015
}
@@ -3305,14 +3305,14 @@ static void getLocaltime(struct tm &ltime)
33053305
#endif
33063306
}
33073307

3308-
static std::string getDateDefine(const struct tm *timep)
3308+
static std::string getDateDefine(const struct tm * const timep)
33093309
{
33103310
char buf[] = "??? ?? ????";
33113311
strftime(buf, sizeof(buf), "%b %d %Y", timep);
33123312
return std::string("\"").append(buf).append("\"");
33133313
}
33143314

3315-
static std::string getTimeDefine(const struct tm *timep)
3315+
static std::string getTimeDefine(const struct tm * const timep)
33163316
{
33173317
char buf[] = "??:??:??";
33183318
strftime(buf, sizeof(buf), "%H:%M:%S", timep);

test.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ static void assertThrowFailed(int line)
6666
std::cerr << "exception not thrown" << std::endl;
6767
}
6868

69-
static void testcase(const std::string &name, void (*f)(), int argc, char * const *argv)
69+
static void testcase(const std::string &name, void (*const f)(), int argc, char *argv[])
7070
{
7171
if (argc == 1) {
7272
f();
@@ -81,30 +81,30 @@ static void testcase(const std::string &name, void (*f)(), int argc, char * cons
8181

8282
#define TEST_CASE(F) (testcase(#F, F, argc, argv))
8383

84-
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)
84+
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)
8585
{
8686
std::istringstream istr(std::string(code, size));
8787
return {istr,filenames,filename,outputList};
8888
}
8989

90-
static simplecpp::TokenList makeTokenList(const char code[], std::vector<std::string> &filenames, const std::string &filename=std::string(), simplecpp::OutputList *outputList=nullptr)
90+
static simplecpp::TokenList makeTokenList(const char code[], std::vector<std::string> &filenames, const std::string &filename=std::string(), simplecpp::OutputList * const outputList=nullptr)
9191
{
9292
return makeTokenList(code, strlen(code), filenames, filename, outputList);
9393
}
9494

95-
static std::string readfile(const char code[], simplecpp::OutputList *outputList=nullptr)
95+
static std::string readfile(const char code[], simplecpp::OutputList * const outputList=nullptr)
9696
{
9797
std::vector<std::string> files;
9898
return makeTokenList(code,files,std::string(),outputList).stringify();
9999
}
100100

101-
static std::string readfile(const char code[], std::size_t size, simplecpp::OutputList *outputList=nullptr)
101+
static std::string readfile(const char code[], std::size_t size, simplecpp::OutputList * const outputList=nullptr)
102102
{
103103
std::vector<std::string> files;
104104
return makeTokenList(code,size,files,std::string(),outputList).stringify();
105105
}
106106

107-
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())
107+
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())
108108
{
109109
std::vector<std::string> files;
110110
simplecpp::FileDataCache cache;
@@ -132,17 +132,17 @@ static std::string preprocess(const char code[], const simplecpp::DUI &dui)
132132
return preprocess(code, dui, nullptr);
133133
}
134134

135-
static std::string preprocess(const char code[], simplecpp::OutputList *outputList)
135+
static std::string preprocess(const char code[], simplecpp::OutputList * const outputList)
136136
{
137137
return preprocess(code, simplecpp::DUI(), outputList);
138138
}
139139

140-
static std::string preprocess(const char code[], std::list<simplecpp::IfCond> *ifCond)
140+
static std::string preprocess(const char code[], std::list<simplecpp::IfCond> * const ifCond)
141141
{
142142
return preprocess(code, simplecpp::DUI(), nullptr, nullptr, ifCond);
143143
}
144144

145-
static std::string preprocess(const char code[], std::list<simplecpp::MacroUsage> *macroUsage)
145+
static std::string preprocess(const char code[], std::list<simplecpp::MacroUsage> * const macroUsage)
146146
{
147147
return preprocess(code, simplecpp::DUI(), nullptr, macroUsage);
148148
}
@@ -3600,7 +3600,7 @@ static void leak()
36003600
}
36013601
}
36023602

3603-
int main(int argc, char **argv)
3603+
int main(int argc, char *argv[])
36043604
{
36053605
TEST_CASE(backslash);
36063606

0 commit comments

Comments
 (0)