Skip to content

Commit

Permalink
Improve diagnostics and macros
Browse files Browse the repository at this point in the history
  • Loading branch information
bbrk24 committed Jul 29, 2023
1 parent bc9e5b5 commit 247fb01
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 9 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/lint-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ jobs:
- name: Invoke clang
shell: bash
run: >+
clang++ -DVERSION=0.0.0 -DNDEBUG -WCL4 -Wnon-gcc -Wno-nullability-completeness -Werror -std=c++14 -o
/dev/null src/*.cpp
clang++ -DVERSION=0.0.0 -DNDEBUG -WCL4 -Wnon-gcc -Wimplicit-fallthrough -Werror -std=c++14 -o /dev/null
src/*.cpp
lint-npm:
if: ${{ !contains(github.event.head_commit.message, '[skip ci]') }}
runs-on: ubuntu-latest
Expand Down
18 changes: 14 additions & 4 deletions src/compat.hh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <utility>

#ifdef __has_include
#if __has_include(<sal.h>)
#if __has_include(<sal.h>) && !defined(__clang__)
#include <sal.h>
#endif

Expand Down Expand Up @@ -35,6 +35,15 @@ constexpr int EX_NOINPUT = 66;
#endif


#if !defined(__GNUC__) && defined(_MSC_VER)
// 1 if the compiler is really MSVC, and not clang pretending to be MSVC. 0 for clang and GCC.
#define REALLY_MSVC 1
#else
// 1 if the compiler is really MSVC, and not clang pretending to be MSVC. 0 for clang and GCC.
#define REALLY_MSVC 0
#endif


#ifdef __cpp_constinit
// constinit, constexpr, or just const, depending on where lambdas are allowed
#define CONSTINIT_LAMBDA constinit const
Expand Down Expand Up @@ -108,7 +117,7 @@ constexpr int EX_NOINPUT = 66;
#define FALLTHROUGH [[fallthrough]];
#endif

#if !defined(__GNUC__) && defined(_MSC_VER)
#if REALLY_MSVC
#if _MSC_VER >= 1929
// mark that the padding of this member can be used for other members
#define NO_UNIQUE_ADDRESS [[msvc::no_unique_address]]
Expand Down Expand Up @@ -160,7 +169,7 @@ constexpr int EX_NOINPUT = 66;
#endif


#if !defined(__GNUC__) && defined(_MSC_VER)
#if REALLY_MSVC
#define __builtin_unreachable() __assume(0)
#endif

Expand All @@ -172,6 +181,7 @@ constexpr int EX_NOINPUT = 66;


#ifdef __clang__
#pragma clang diagnostic ignored "-Wnullability-completeness"
// A non-nullable pointer to the specified type.
#define NONNULL_PTR(...) __VA_ARGS__* _Nonnull
#elif defined(_Notnull_)
Expand All @@ -184,7 +194,7 @@ constexpr int EX_NOINPUT = 66;
#endif


#if (defined(__x86_64__) || defined(_M_X64)) && (defined(__GNUC__) || defined(__clang__))
#if (defined(__x86_64__) || defined(_M_X64)) && !REALLY_MSVC
// 1 on gcc or clang for x86-64, where asm blocks are used. 0 otherwise.
#define ASM_ALLOWED 1
#else
Expand Down
1 change: 1 addition & 0 deletions src/disassembler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ void disassembler::build_state() {
case PSI:
case PSC:
program_walker::advance(ip, m_program->side_length());
break;
default:
break;
}
Expand Down
4 changes: 2 additions & 2 deletions src/program_walker.hh
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public:
}
}

#ifdef _MSC_VER
#if REALLY_MSVC
#pragma warning(push)
#pragma warning(disable : 4702)
// C4702 is unreachable code, which it complains about when constant-folding the template instantiation
Expand Down Expand Up @@ -290,7 +290,7 @@ public:
}
}

#ifdef _MSC_VER
#if REALLY_MSVC
#pragma warning(pop)
#endif
protected:
Expand Down
2 changes: 1 addition & 1 deletion wasm/build_wasm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -e

common_emcc_args=(-WCL4 -Wnon-gcc -Wno-nullability-completeness
common_emcc_args=(-WCL4 -Wnon-gcc -Wimplicit-fallthrough
-fno-rtti -fno-exceptions
-sEXPORTED_RUNTIME_METHODS=ccall -sASYNCIFY -sASYNCIFY_IMPORTS='send_debug_info'
-o worker.js
Expand Down

0 comments on commit 247fb01

Please sign in to comment.