Skip to content

Commit e546ec4

Browse files
committed
Treat all warnings as errors
1 parent 114b3ff commit e546ec4

File tree

8 files changed

+48
-33
lines changed

8 files changed

+48
-33
lines changed

.github/workflows/ci.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,10 @@ jobs:
758758
run: |
759759
brew update
760760
brew remove [email protected]
761+
export ARCHITECHURE=$(uname -m)
762+
if [[ "$ARCHITECHURE" == "x86_64" ]]; then
763+
brew remove swiftlint
764+
fi
761765
# workaround for https://github.com/actions/setup-python/issues/577
762766
for pkg in $(brew list | grep '^python@'); do
763767
brew unlink "$pkg"
@@ -815,6 +819,7 @@ jobs:
815819
-DBUILD_SHARED_LIBS=ON \
816820
-DCODE_COVERAGE=${{ env.CODE_COVERAGE }} \
817821
-DCMAKE_INSTALL_PREFIX=$CPPINTEROP_DIR \
822+
-DLLVM_ENABLE_WERROR=On \
818823
../
819824
else
820825
cmake -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \
@@ -825,6 +830,7 @@ jobs:
825830
-DBUILD_SHARED_LIBS=ON \
826831
-DCODE_COVERAGE=${{ env.CODE_COVERAGE }} \
827832
-DCMAKE_INSTALL_PREFIX=$CPPINTEROP_DIR \
833+
-DLLVM_ENABLE_WERROR=On \
828834
../
829835
fi
830836
os="${{ matrix.os }}"
@@ -840,7 +846,7 @@ jobs:
840846
echo "CPPINTEROP_DIR=$CPPINTEROP_DIR" >> $GITHUB_ENV
841847
echo "LLVM_BUILD_DIR=$LLVM_BUILD_DIR" >> $GITHUB_ENV
842848
echo "CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH" >> $GITHUB_ENV
843-
849+
844850
- name: Build and Test/Install CppInterOp on Windows systems
845851
continue-on-error: true
846852
if: ${{ runner.os == 'windows' }}
@@ -899,6 +905,7 @@ jobs:
899905
-DUSE_REPL=OFF `
900906
-DCling_DIR="$env:LLVM_BUILD_DIR\tools\cling" `
901907
-DLLVM_DIR="$env:LLVM_BUILD_DIR" `
908+
-DLLVM_ENABLE_WERROR=On `
902909
-DClang_DIR="$env:LLVM_BUILD_DIR" -DCODE_COVERAGE=${{ env.CODE_COVERAGE }} -DCMAKE_INSTALL_PREFIX="$env:CPPINTEROP_DIR" ..\
903910
}
904911
else
@@ -907,6 +914,7 @@ jobs:
907914
-DUSE_CLING=OFF `
908915
-DUSE_REPL=ON `
909916
-DLLVM_DIR="$env:LLVM_BUILD_DIR\lib\cmake\llvm" `
917+
-DLLVM_ENABLE_WERROR=On `
910918
-DClang_DIR="$env:LLVM_BUILD_DIR\lib\cmake\clang" -DCODE_COVERAGE=${{ env.CODE_COVERAGE }} -DCMAKE_INSTALL_PREFIX="$env:CPPINTEROP_DIR" ..\
911919
}
912920
cmake --build . --config ${{ env.BUILD_TYPE }} --target check-cppinterop --parallel ${{ env.ncpus }}

CMakeLists.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR )
211211

212212
endif()
213213

214-
##Replace \ with / in LLVM_DIR (attempt to fix path parsing issue Windows)
214+
#Replace \ with / in LLVM_DIR (attempt to fix path parsing issue Windows)
215215
string(REPLACE "\\" "/" LLVM_DIR "${LLVM_DIR}")
216216

217217
# When in debug mode the llvm package thinks it is built with -frtti.
@@ -302,6 +302,11 @@ if (LLVM_COMPILER_IS_GCC_COMPATIBLE)
302302
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-common -Woverloaded-virtual -Wcast-qual -fno-strict-aliasing -pedantic -Wno-long-long -Wall -W -Wno-unused-parameter -Wwrite-strings")
303303
endif ()
304304

305+
# Fixes "C++ exception handler used, but unwind semantics are not enabled" warning Windows
306+
if (WIN32)
307+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc")
308+
endif ()
309+
305310
if (APPLE)
306311
set(CMAKE_MODULE_LINKER_FLAGS "-Wl,-flat_namespace -Wl,-undefined -Wl,suppress")
307312
endif ()
@@ -319,6 +324,8 @@ include_directories(BEFORE SYSTEM
319324
${CMAKE_CURRENT_SOURCE_DIR}/include
320325
)
321326

327+
#Removes flag due to issue with Google test download when LLVM_ENABLE_WERROR=On
328+
string(REPLACE "-Wcovered-switch-default" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
322329

323330
file(STRINGS "VERSION" CPPINTEROP_VERSION)
324331
string(REGEX MATCH "([0-9]*)\.([0-9]*)\.([0-9]*)" CPPINTEROP_VERSION_ONLY "${CPPINTEROP_VERSION}")

lib/Interpreter/Compatibility.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#if LLVM_VERSION_MAJOR < 18
1414
#define starts_with startswith
1515
#define ends_with endswith
16+
#define starts_with_insensitive startswith_insensitive
1617
#endif
1718

1819
#if CLANG_VERSION_MAJOR >= 18

lib/Interpreter/CppInterOp.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,7 +1204,8 @@ namespace Cpp {
12041204
for (auto &GV : GeneratedPTU->TheModule->globals()) {
12051205
llvm::GlobalValue::LinkageTypes LT = GV.getLinkage();
12061206
if (GV.isDeclaration() || !GV.hasName() ||
1207-
GV.getName().startswith(".str") || !GV.isDiscardableIfUnused(LT) ||
1207+
GV.getName().starts_with(".str") ||
1208+
!GV.isDiscardableIfUnused(LT) ||
12081209
LT != llvm::GlobalValue::InternalLinkage)
12091210
continue; //nothing to do
12101211
GV.setLinkage(llvm::GlobalValue::WeakAnyLinkage);
@@ -1333,11 +1334,11 @@ namespace Cpp {
13331334
{
13341335
bool issigned = false;
13351336
bool isunsigned = false;
1336-
if (typeName.startswith("signed ")) {
1337+
if (typeName.starts_with("signed ")) {
13371338
issigned = true;
13381339
typeName = StringRef(typeName.data()+7, typeName.size()-7);
13391340
}
1340-
if (!issigned && typeName.startswith("unsigned ")) {
1341+
if (!issigned && typeName.starts_with("unsigned ")) {
13411342
isunsigned = true;
13421343
typeName = StringRef(typeName.data()+9, typeName.size()-9);
13431344
}
@@ -2813,7 +2814,6 @@ namespace Cpp {
28132814
}
28142815

28152816
// Let's inject it.
2816-
SymbolMap::iterator It;
28172817
llvm::orc::SymbolMap InjectedSymbols;
28182818
auto& DL = compat::getExecutionEngine(I)->getDataLayout();
28192819
char GlobalPrefix = DL.getGlobalPrefix();
@@ -3078,7 +3078,7 @@ namespace Cpp {
30783078
std::string GetFunctionArgDefault(TCppFunction_t func,
30793079
TCppIndex_t param_index) {
30803080
auto *D = (clang::Decl *)func;
3081-
clang::ParmVarDecl* PI;
3081+
clang::ParmVarDecl* PI = nullptr;
30823082

30833083
if (auto* FD = llvm::dyn_cast_or_null<clang::FunctionDecl>(D))
30843084
PI = FD->getParamDecl(param_index);
@@ -3125,7 +3125,7 @@ namespace Cpp {
31253125
std::string GetFunctionArgName(TCppFunction_t func, TCppIndex_t param_index)
31263126
{
31273127
auto *D = (clang::Decl *)func;
3128-
clang::ParmVarDecl* PI;
3128+
clang::ParmVarDecl* PI = nullptr;
31293129

31303130
if (auto* FD = llvm::dyn_cast_or_null<clang::FunctionDecl>(D))
31313131
PI = FD->getParamDecl(param_index);
@@ -3154,7 +3154,7 @@ namespace Cpp {
31543154
auto* const Ctor = GetDefaultConstructor(Class);
31553155
if (JitCall JC = MakeFunctionCallable(Ctor)) {
31563156
if (arena) {
3157-
JC.Invoke(&arena, {}, (void *)~0U); // Tell Invoke to use placement new.
3157+
JC.Invoke(&arena, {}, (void*)0); // Tell Invoke to use placement new.
31583158
return arena;
31593159
}
31603160

lib/Interpreter/DynamicLibraryManager.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,6 @@ namespace Cpp {
6969
for (const std::string& P : SysPaths)
7070
addSearchPath(P, /*IsUser*/ false);
7171
}
72-
#if LLVM_VERSION_MAJOR < 18
73-
#define starts_with_insensitive startswith_insensitive
74-
#endif
7572
///\returns substitution of pattern in the front of original with replacement
7673
/// Example: substFront("@rpath/abc", "@rpath/", "/tmp") -> "/tmp/abc"
7774
static std::string substFront(StringRef original, StringRef pattern,

lib/Interpreter/DynamicLibraryManagerSymbol.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ struct BloomFilter {
9393
// bloomSize = ceil((-1.44 * n * log2f(p)) / bits)
9494

9595
const int m_Bits = 8 * sizeof(uint64_t);
96-
const float m_P = 0.02;
96+
const float m_P = 0.02f;
9797

9898
bool m_IsInitialized = false;
9999
uint32_t m_SymbolsCount = 0;

unittests/CppInterOp/ScopeReflectionTest.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -663,15 +663,15 @@ TEST(ScopeReflectionTest, GetBaseClassOffset) {
663663
#define Stringify(s) Stringifyx(s)
664664
#define Stringifyx(...) #__VA_ARGS__
665665
#define CODE \
666-
class A { int m_a; }; \
667-
class B { int m_b; }; \
668-
class C : virtual A, virtual B { int m_c; }; \
669-
class D : virtual A, virtual B, public C { int m_d; }; \
670-
class E : public A, public B { int m_e; }; \
671-
class F : public A { int m_f; }; \
672-
class G : public F { int m_g; };
673-
674-
CODE;
666+
struct A { int m_a; }; \
667+
struct B { int m_b; }; \
668+
struct C : virtual A, virtual B { int m_c; }; \
669+
struct D : virtual A, virtual B, public C { int m_d; }; \
670+
struct E : public A, public B { int m_e; }; \
671+
struct F : public A { int m_f; }; \
672+
struct G : public F { int m_g; };
673+
674+
CODE;
675675

676676
GetAllTopLevelDecls(Stringify(CODE), Decls);
677677
#undef Stringifyx

unittests/CppInterOp/VariableReflectionTest.cpp

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ TEST(VariableReflectionTest, GetVariableType) {
9393

9494
#define CODE \
9595
int a; \
96-
const int N = 5; \
96+
int N = 5; \
9797
class C { \
9898
public: \
9999
int a; \
@@ -121,12 +121,13 @@ TEST(VariableReflectionTest, GetVariableOffset) {
121121
EXPECT_TRUE((bool) Cpp::GetVariableOffset(Decls[1])); // N
122122

123123
EXPECT_EQ(Cpp::GetVariableOffset(datamembers[0]), 0);
124+
124125
EXPECT_EQ(Cpp::GetVariableOffset(datamembers[1]),
125-
((unsigned long) &(c.b)) - ((unsigned long) &(c.a)));
126+
((intptr_t) &(c.b)) - ((intptr_t) &(c.a)));
126127
EXPECT_EQ(Cpp::GetVariableOffset(datamembers[2]),
127-
((unsigned long) &(c.c)) - ((unsigned long) &(c.a)));
128+
((intptr_t) &(c.c)) - ((intptr_t) &(c.a)));
128129
EXPECT_EQ(Cpp::GetVariableOffset(datamembers[3]),
129-
((unsigned long) &(c.d)) - ((unsigned long) &(c.a)));
130+
((intptr_t) &(c.d)) - ((intptr_t) &(c.a)));
130131

131132
auto *VD_C_s_a = Cpp::GetNamed("s_a", Decls[2]); // C::s_a
132133
EXPECT_TRUE((bool) Cpp::GetVariableOffset(VD_C_s_a));
@@ -240,13 +241,14 @@ TEST(VariableReflectionTest, DISABLED_GetArrayDimensions) {
240241

241242
GetAllTopLevelDecls(code, Decls);
242243

243-
auto is_vec_eq = [](const std::vector<size_t> &arr_dims,
244-
const std::vector<size_t> &truth_vals) {
245-
if (arr_dims.size() != truth_vals.size())
246-
return false;
247-
248-
return std::equal(arr_dims.begin(), arr_dims.end(), truth_vals.begin());
249-
};
244+
//FIXME: is_vec_eq is an unused variable until test does something
245+
//auto is_vec_eq = [](const std::vector<size_t> &arr_dims,
246+
// const std::vector<size_t> &truth_vals) {
247+
// if (arr_dims.size() != truth_vals.size())
248+
// return false;
249+
//
250+
// return std::equal(arr_dims.begin(), arr_dims.end(), truth_vals.begin());
251+
//};
250252

251253
// EXPECT_TRUE(is_vec_eq(Cpp::GetArrayDimensions(Decls[0]), {}));
252254
// EXPECT_TRUE(is_vec_eq(Cpp::GetArrayDimensions(Decls[1]), {1}));

0 commit comments

Comments
 (0)