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
10 changes: 5 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ cmake_minimum_required (VERSION 3.5)
project (simplecpp LANGUAGES CXX)

if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
add_compile_options(-Wall -Wextra -pedantic -Wcast-qual -Wfloat-equal -Wmissing-declarations -Wmissing-format-attribute -Wredundant-decls -Wshadow -Wundef -Wold-style-cast)
endif()

if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -pedantic -Wcast-qual -Wfloat-equal -Wmissing-declarations -Wmissing-format-attribute -Wredundant-decls -Wshadow -Wundef -Wold-style-cast -Wno-multichar)
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Weverything)
# no need for c++98 compatibility
add_compile_options(-Wno-c++98-compat-pedantic)
# these are not really fixable
add_compile_options(-Wno-exit-time-destructors -Wno-global-constructors)
# we are not interested in these
add_compile_options(-Wno-multichar)
# TODO: fix these?
add_compile_options(-Wno-padded -Wno-sign-conversion -Wno-conversion)
add_compile_options(-Wno-padded -Wno-sign-conversion -Wno-implicit-int-conversion -Wno-shorten-64-to-32)
endif()

add_executable(simplecpp simplecpp.cpp main.cpp)
Expand Down
2 changes: 1 addition & 1 deletion main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

int main(int argc, char **argv)
{
const char *filename = NULL;
const char *filename = nullptr;

// Settings..
simplecpp::DUI dui;
Expand Down
12 changes: 6 additions & 6 deletions simplecpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1424,7 +1424,7 @@ namespace simplecpp {
};
private:
/** Create new token where Token::macro is set for replaced tokens */
Token *newMacroToken(const TokenString &str, const Location &loc, bool replaced, const Token *expandedFromToken=NULL) const {
Token *newMacroToken(const TokenString &str, const Location &loc, bool replaced, const Token *expandedFromToken=nullptr) const {
Token *tok = new Token(str,loc);
if (replaced)
tok->macro = nameTokDef->str();
Expand Down Expand Up @@ -2646,7 +2646,7 @@ static NonExistingFilesCache nonExistingFilesCache;

#endif

static std::string _openHeader(std::ifstream &f, const std::string &path)
static std::string openHeader(std::ifstream &f, const std::string &path)
{
#ifdef SIMPLECPP_WINDOWS
std::string simplePath = simplecpp::simplifyPath(path);
Expand Down Expand Up @@ -2675,7 +2675,7 @@ static std::string getRelativeFileName(const std::string &sourcefile, const std:

static std::string openHeaderRelative(std::ifstream &f, const std::string &sourcefile, const std::string &header)
{
return _openHeader(f, getRelativeFileName(sourcefile, header));
return openHeader(f, getRelativeFileName(sourcefile, header));
}

static std::string getIncludePathFileName(const std::string &includePath, const std::string &header)
Expand All @@ -2689,7 +2689,7 @@ static std::string getIncludePathFileName(const std::string &includePath, const
static std::string openHeaderIncludePath(std::ifstream &f, const simplecpp::DUI &dui, const std::string &header)
{
for (std::list<std::string>::const_iterator it = dui.includePaths.begin(); it != dui.includePaths.end(); ++it) {
std::string simplePath = _openHeader(f, getIncludePathFileName(*it, header));
std::string simplePath = openHeader(f, getIncludePathFileName(*it, header));
if (!simplePath.empty())
return simplePath;
}
Expand All @@ -2699,7 +2699,7 @@ static std::string openHeaderIncludePath(std::ifstream &f, const simplecpp::DUI
static std::string openHeader(std::ifstream &f, const simplecpp::DUI &dui, const std::string &sourcefile, const std::string &header, bool systemheader)
{
if (isAbsolutePath(header))
return _openHeader(f, header);
return openHeader(f, header);

std::string ret;

Expand Down Expand Up @@ -3132,7 +3132,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
expr.push_back(new Token(header2.empty() ? "0" : "1", tok->location));
}
if (par)
tok = tok ? tok->next : NULL;
tok = tok ? tok->next : nullptr;
if (!tok || !sameline(rawtok,tok) || (par && tok->op != ')')) {
if (outputList) {
Output out(rawtok->location.files);
Expand Down
6 changes: 3 additions & 3 deletions test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
static int numberOfFailedAssertions = 0;

#define ASSERT_EQUALS(expected, actual) (assertEquals((expected), (actual), __LINE__))
#define ASSERT_THROW(stmt, e) try { stmt; assertThrowFailed(__LINE__); } catch (const e&) {}
#define ASSERT_THROW(stmt, e) do { try { stmt; assertThrowFailed(__LINE__); } catch (const e&) {} } while(false)

static std::string pprint(const std::string &in)
{
Expand Down Expand Up @@ -86,7 +86,7 @@ static std::string readfile(const char code[], int sz=-1, simplecpp::OutputList
return simplecpp::TokenList(istr,files,std::string(),outputList).stringify();
}

static std::string preprocess(const char code[], const simplecpp::DUI &dui, simplecpp::OutputList *outputList = NULL)
static std::string preprocess(const char code[], const simplecpp::DUI &dui, simplecpp::OutputList *outputList = nullptr)
{
std::istringstream istr(code);
std::vector<std::string> files;
Expand Down Expand Up @@ -1459,7 +1459,7 @@ static void missingHeader2()
std::istringstream istr("#include \"foo.h\"\n"); // this file exists
std::vector<std::string> files;
std::map<std::string, simplecpp::TokenList*> filedata;
filedata["foo.h"] = NULL;
filedata["foo.h"] = nullptr;
simplecpp::OutputList outputList;
simplecpp::TokenList tokens2(files);
simplecpp::preprocess(tokens2, simplecpp::TokenList(istr,files), files, filedata, dui, &outputList);
Expand Down