Skip to content

Commit 62f69bc

Browse files
committed
enabled and fixed modernize-use-default-member-init clang-tidy warnings
1 parent ccde80d commit 62f69bc

File tree

3 files changed

+19
-22
lines changed

3 files changed

+19
-22
lines changed

.clang-tidy

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ Checks: >
3232
-modernize-return-braced-init-list,
3333
-modernize-use-auto,
3434
-modernize-use-equals-delete,
35-
-modernize-use-default-member-init,
3635
-modernize-use-nodiscard,
3736
-modernize-use-trailing-return-type,
3837
-readability-avoid-nested-conditional-operator,

simplecpp.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -386,8 +386,7 @@ class StdCharBufStream : public simplecpp::TokenList::Stream {
386386
StdCharBufStream(const unsigned char* str, std::size_t size)
387387
: str(str)
388388
, size(size)
389-
, pos(0)
390-
, lastStatus(0) {
389+
{
391390
init();
392391
}
393392

@@ -411,17 +410,16 @@ class StdCharBufStream : public simplecpp::TokenList::Stream {
411410
private:
412411
const unsigned char *str;
413412
const std::size_t size;
414-
std::size_t pos;
415-
int lastStatus;
413+
std::size_t pos{};
414+
int lastStatus{};
416415
};
417416

418417
class FileStream : public simplecpp::TokenList::Stream {
419418
public:
420419
// cppcheck-suppress uninitDerivedMemberVar - we call Stream::init() to initialize the private members
421420
explicit FileStream(const std::string &filename, std::vector<std::string> &files)
422421
: file(fopen(filename.c_str(), "rb"))
423-
, lastCh(0)
424-
, lastStatus(0) {
422+
{
425423
if (!file) {
426424
files.push_back(filename);
427425
throw simplecpp::Output(files, simplecpp::Output::FILE_NOT_FOUND, "File is missing: " + filename);
@@ -465,8 +463,8 @@ class FileStream : public simplecpp::TokenList::Stream {
465463
FileStream &operator=(const FileStream&);
466464

467465
FILE *file;
468-
int lastCh;
469-
int lastStatus;
466+
int lastCh{};
467+
int lastStatus{};
470468
};
471469

472470
simplecpp::TokenList::TokenList(std::vector<std::string> &filenames) : frontToken(nullptr), backToken(nullptr), files(filenames) {}
@@ -1487,7 +1485,7 @@ namespace simplecpp {
14871485

14881486
class Macro {
14891487
public:
1490-
explicit Macro(std::vector<std::string> &f) : nameTokDef(nullptr), valueToken(nullptr), endToken(nullptr), files(f), tokenListDefine(f), variadic(false), variadicOpt(false), optExpandValue(nullptr), optNoExpandValue(nullptr), valueDefinedInCode_(false) {}
1488+
explicit Macro(std::vector<std::string> &f) : nameTokDef(nullptr), valueToken(nullptr), endToken(nullptr), files(f), tokenListDefine(f), variadic(false), variadicOpt(false), valueDefinedInCode_(false) {}
14911489

14921490
Macro(const Token *tok, std::vector<std::string> &f) : nameTokDef(nullptr), files(f), tokenListDefine(f), valueDefinedInCode_(true) {
14931491
if (sameline(tok->previousSkipComments(), tok))

simplecpp.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ namespace simplecpp {
7676
*/
7777
class SIMPLECPP_LIB Location {
7878
public:
79-
explicit Location(const std::vector<std::string> &f) : files(f), fileIndex(0), line(1U), col(0U) {}
79+
explicit Location(const std::vector<std::string> &f) : files(f) {}
8080

8181
Location(const Location &loc) = default;
8282

@@ -109,9 +109,9 @@ namespace simplecpp {
109109
}
110110

111111
const std::vector<std::string> &files;
112-
unsigned int fileIndex;
113-
unsigned int line;
114-
unsigned int col;
112+
unsigned int fileIndex{};
113+
unsigned int line{1};
114+
unsigned int col{};
115115
private:
116116
static const std::string emptyFileName;
117117
};
@@ -123,12 +123,12 @@ namespace simplecpp {
123123
class SIMPLECPP_LIB Token {
124124
public:
125125
Token(const TokenString &s, const Location &loc, bool wsahead = false) :
126-
whitespaceahead(wsahead), location(loc), previous(nullptr), next(nullptr), nextcond(nullptr), string(s) {
126+
whitespaceahead(wsahead), location(loc), string(s) {
127127
flags();
128128
}
129129

130130
Token(const Token &tok) :
131-
macro(tok.macro), op(tok.op), comment(tok.comment), name(tok.name), number(tok.number), whitespaceahead(tok.whitespaceahead), location(tok.location), previous(nullptr), next(nullptr), nextcond(nullptr), string(tok.string), mExpandedFrom(tok.mExpandedFrom) {}
131+
macro(tok.macro), op(tok.op), comment(tok.comment), name(tok.name), number(tok.number), whitespaceahead(tok.whitespaceahead), location(tok.location), string(tok.string), mExpandedFrom(tok.mExpandedFrom) {}
132132

133133
const TokenString& str() const {
134134
return string;
@@ -153,9 +153,9 @@ namespace simplecpp {
153153
bool number;
154154
bool whitespaceahead;
155155
Location location;
156-
Token *previous;
157-
Token *next;
158-
mutable const Token *nextcond;
156+
Token *previous{};
157+
Token *next{};
158+
mutable const Token *nextcond{};
159159

160160
const Token *previousSkipComments() const {
161161
const Token *tok = this->previous;
@@ -393,14 +393,14 @@ namespace simplecpp {
393393
* On the command line these are configured by -D, -U, -I, --include, -std
394394
*/
395395
struct SIMPLECPP_LIB DUI {
396-
DUI() : clearIncludeCache(false), removeComments(false) {}
396+
DUI() = default;
397397
std::list<std::string> defines;
398398
std::set<std::string> undefined;
399399
std::list<std::string> includePaths;
400400
std::list<std::string> includes;
401401
std::string std;
402-
bool clearIncludeCache;
403-
bool removeComments; /** remove comment tokens from included files */
402+
bool clearIncludeCache{};
403+
bool removeComments{}; /** remove comment tokens from included files */
404404
};
405405

406406
struct SIMPLECPP_LIB FileData {

0 commit comments

Comments
 (0)