Skip to content
Closed
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
20 changes: 14 additions & 6 deletions .github/workflows/CI-unixish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ jobs:
sudo apt-get update
sudo apt-get install libc++-18-dev

# coreutils contains "nproc"
- name: Install missing software on macos
if: contains(matrix.os, 'macos')
run: |
brew install coreutils

- name: Install missing software on macos
if: contains(matrix.os, 'macos')
run: |
Expand All @@ -41,9 +47,11 @@ jobs:
python3 -m pip config set global.break-system-packages true
python3 -m pip install pytest

# TODO: bail out on warnings
- name: make simplecpp
run: make -j$(nproc)

# TODO: bail out on warnings
- name: make test
run: make -j$(nproc) test

Expand All @@ -57,7 +65,7 @@ jobs:

- name: Run CMake
run: |
cmake -S . -B cmake.output
cmake -S . -B cmake.output -DCMAKE_COMPILE_WARNING_AS_ERROR=On

- name: CMake simplecpp
run: |
Expand All @@ -80,27 +88,27 @@ jobs:
if: matrix.os == 'ubuntu-24.04' && matrix.compiler == 'g++'
run: |
make clean
make -j$(nproc) test selfcheck CXXFLAGS="-g3 -D_GLIBCXX_DEBUG"
make -j$(nproc) test selfcheck CXXFLAGS="-Werror -Wno-multichar -g3 -D_GLIBCXX_DEBUG"

- name: Run with libc++ hardening mode
if: matrix.os == 'ubuntu-24.04' && matrix.compiler == 'clang++'
run: |
make clean
make -j$(nproc) test selfcheck CXXFLAGS="-stdlib=libc++ -g3 -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG" LDFLAGS="-lc++"
make -j$(nproc) test selfcheck CXXFLAGS="-Werror -Wno-multichar -stdlib=libc++ -g3 -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG" LDFLAGS="-lc++"

- name: Run AddressSanitizer
if: matrix.os == 'ubuntu-24.04'
run: |
make clean
make -j$(nproc) test selfcheck CXXFLAGS="-O2 -g3 -fsanitize=address" LDFLAGS="-fsanitize=address"
make -j$(nproc) test selfcheck CXXFLAGS="-Werror -Wno-multichar -O2 -g3 -fsanitize=address" LDFLAGS="-fsanitize=address"
env:
ASAN_OPTIONS: detect_stack_use_after_return=1

- name: Run UndefinedBehaviorSanitizer
if: matrix.os == 'ubuntu-24.04'
run: |
make clean
make -j$(nproc) test selfcheck CXXFLAGS="-O2 -g3 -fsanitize=undefined -fno-sanitize=signed-integer-overflow" LDFLAGS="-fsanitize=undefined -fno-sanitize=signed-integer-overflow"
make -j$(nproc) test selfcheck CXXFLAGS="-Werror -Wno-multichar -O2 -g3 -fsanitize=undefined -fno-sanitize=signed-integer-overflow" LDFLAGS="-fsanitize=undefined -fno-sanitize=signed-integer-overflow"
env:
UBSAN_OPTIONS: print_stacktrace=1:halt_on_error=1:report_error_type=1

Expand All @@ -109,4 +117,4 @@ jobs:
if: false && matrix.os == 'ubuntu-24.04' && matrix.compiler == 'clang++'
run: |
make clean
make -j$(nproc) test selfcheck CXXFLAGS="-O2 -g3 -stdlib=libc++ -fsanitize=memory" LDFLAGS="-lc++ -fsanitize=memory"
make -j$(nproc) test selfcheck CXXFLAGS="-Werror -Wno-multichar -O2 -g3 -stdlib=libc++ -fsanitize=memory" LDFLAGS="-lc++ -fsanitize=memory"
6 changes: 4 additions & 2 deletions .github/workflows/CI-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,14 @@ jobs:

- name: Run CMake
run: |
cmake -G "Visual Studio 17 2022" -A x64 . || exit /b !errorlevel!
cmake -G "Visual Studio 17 2022" -A x64 -DCMAKE_COMPILE_WARNING_AS_ERROR=On . || exit /b !errorlevel!

- name: Build
run: |
msbuild -m simplecpp.sln /p:Configuration=${{ matrix.config }} /p:Platform=x64 || exit /b !errorlevel!

env:
_CL_: /WX

- name: Test
run: |
.\${{ matrix.config }}\testrunner.exe || exit /b !errorlevel!
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/clang-tidy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:

- name: Prepare CMake
run: |
cmake -S . -B cmake.output -G "Unix Makefiles" -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
cmake -S . -B cmake.output -G "Unix Makefiles" -DCMAKE_COMPILE_WARNING_AS_ERROR=On -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
env:
CXX: clang-20

Expand Down
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")

add_compile_options(-Wsuggest-attribute=noreturn)
add_compile_options_safe(-Wuseless-cast)

add_compile_options(-Wno-shadow) # TODO: fix these
elseif (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
Expand All @@ -56,6 +58,10 @@ elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
# TODO: fix these?
add_compile_options(-Wno-padded -Wno-sign-conversion -Wno-implicit-int-conversion -Wno-shorten-64-to-32 -Wno-shadow-field-in-constructor)

if (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
add_compile_options(-Wno-c++11-long-long)
endif()

if (CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 14 OR CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 14)
# TODO: verify this regression still exists in clang-15
if (CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
Expand Down
6 changes: 3 additions & 3 deletions simplecpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,7 @@ void simplecpp::TokenList::readfile(Stream &stream, const std::string &filename,

// number or name
if (isNameChar(ch)) {
const bool num = std::isdigit(ch);
const bool num = !!std::isdigit(ch);
while (stream.good() && isNameChar(ch)) {
currentToken += ch;
ch = stream.readChar();
Expand Down Expand Up @@ -886,7 +886,7 @@ void simplecpp::TokenList::readfile(Stream &stream, const std::string &filename,
}

if (prefix.empty())
push_back(new Token(s, location, std::isspace(stream.peekChar()))); // push string without newlines
push_back(new Token(s, location, !!std::isspace(stream.peekChar()))); // push string without newlines
else
back()->setstr(prefix + s);

Expand Down Expand Up @@ -916,7 +916,7 @@ void simplecpp::TokenList::readfile(Stream &stream, const std::string &filename,
}
}

push_back(new Token(currentToken, location, std::isspace(stream.peekChar())));
push_back(new Token(currentToken, location, !!std::isspace(stream.peekChar())));

if (multiline)
location.col += currentToken.size();
Expand Down
Loading