Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ Checks: >
-modernize-return-braced-init-list,
-modernize-use-auto,
-modernize-use-equals-delete,
-modernize-use-default-member-init,
-modernize-use-nodiscard,
-modernize-use-trailing-return-type,
-readability-avoid-nested-conditional-operator,
Expand Down
16 changes: 7 additions & 9 deletions simplecpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -386,8 +386,7 @@ class StdCharBufStream : public simplecpp::TokenList::Stream {
StdCharBufStream(const unsigned char* str, std::size_t size)
: str(str)
, size(size)
, pos(0)
, lastStatus(0) {
{
init();
}

Expand All @@ -411,17 +410,16 @@ class StdCharBufStream : public simplecpp::TokenList::Stream {
private:
const unsigned char *str;
const std::size_t size;
std::size_t pos;
int lastStatus;
std::size_t pos{};
int lastStatus{};
};

class FileStream : public simplecpp::TokenList::Stream {
public:
// cppcheck-suppress uninitDerivedMemberVar - we call Stream::init() to initialize the private members
explicit FileStream(const std::string &filename, std::vector<std::string> &files)
: file(fopen(filename.c_str(), "rb"))
, lastCh(0)
, lastStatus(0) {
{
if (!file) {
files.push_back(filename);
throw simplecpp::Output(files, simplecpp::Output::FILE_NOT_FOUND, "File is missing: " + filename);
Expand Down Expand Up @@ -465,8 +463,8 @@ class FileStream : public simplecpp::TokenList::Stream {
FileStream &operator=(const FileStream&);

FILE *file;
int lastCh;
int lastStatus;
int lastCh{};
int lastStatus{};
};

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

class Macro {
public:
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) {}
explicit Macro(std::vector<std::string> &f) : nameTokDef(nullptr), valueToken(nullptr), endToken(nullptr), files(f), tokenListDefine(f), variadic(false), variadicOpt(false), valueDefinedInCode_(false) {}

Macro(const Token *tok, std::vector<std::string> &f) : nameTokDef(nullptr), files(f), tokenListDefine(f), valueDefinedInCode_(true) {
if (sameline(tok->previousSkipComments(), tok))
Expand Down
24 changes: 12 additions & 12 deletions simplecpp.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ namespace simplecpp {
*/
class SIMPLECPP_LIB Location {
public:
explicit Location(const std::vector<std::string> &f) : files(f), fileIndex(0), line(1U), col(0U) {}
explicit Location(const std::vector<std::string> &f) : files(f) {}

Location(const Location &loc) = default;

Expand Down Expand Up @@ -109,9 +109,9 @@ namespace simplecpp {
}

const std::vector<std::string> &files;
unsigned int fileIndex;
unsigned int line;
unsigned int col;
unsigned int fileIndex{};
unsigned int line{1};
unsigned int col{};
private:
static const std::string emptyFileName;
};
Expand All @@ -123,12 +123,12 @@ namespace simplecpp {
class SIMPLECPP_LIB Token {
public:
Token(const TokenString &s, const Location &loc, bool wsahead = false) :
whitespaceahead(wsahead), location(loc), previous(nullptr), next(nullptr), nextcond(nullptr), string(s) {
whitespaceahead(wsahead), location(loc), string(s) {
flags();
}

Token(const Token &tok) :
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) {}
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) {}

const TokenString& str() const {
return string;
Expand All @@ -153,9 +153,9 @@ namespace simplecpp {
bool number;
bool whitespaceahead;
Location location;
Token *previous;
Token *next;
mutable const Token *nextcond;
Token *previous{};
Token *next{};
mutable const Token *nextcond{};

const Token *previousSkipComments() const {
const Token *tok = this->previous;
Expand Down Expand Up @@ -393,14 +393,14 @@ namespace simplecpp {
* On the command line these are configured by -D, -U, -I, --include, -std
*/
struct SIMPLECPP_LIB DUI {
DUI() : clearIncludeCache(false), removeComments(false) {}
DUI() = default;
std::list<std::string> defines;
std::set<std::string> undefined;
std::list<std::string> includePaths;
std::list<std::string> includes;
std::string std;
bool clearIncludeCache;
bool removeComments; /** remove comment tokens from included files */
bool clearIncludeCache{};
bool removeComments{}; /** remove comment tokens from included files */
};

struct SIMPLECPP_LIB FileData {
Expand Down