mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
229 lines
7.9 KiB
Diff
229 lines
7.9 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: PJ Reiniger <pj.reiniger@gmail.com>
|
|
Date: Sun, 8 May 2022 13:34:07 -0400
|
|
Subject: [PATCH 08/37] Add compiler warning pragmas
|
|
|
|
---
|
|
llvm/include/llvm/ADT/FunctionExtras.h | 11 +++++++++++
|
|
llvm/include/llvm/ADT/Hashing.h | 9 +++++++++
|
|
llvm/include/llvm/ADT/SmallVector.h | 8 ++++++++
|
|
llvm/include/llvm/Support/MathExtras.h | 9 +++++++++
|
|
llvm/include/llvm/Support/MemAlloc.h | 13 +++++++++++++
|
|
llvm/lib/Support/raw_ostream.cpp | 4 ++++
|
|
llvm/unittests/ADT/DenseMapTest.cpp | 4 ++++
|
|
llvm/unittests/ADT/MapVectorTest.cpp | 7 +++++++
|
|
llvm/unittests/ADT/SmallVectorTest.cpp | 4 ++++
|
|
llvm/unittests/Support/AlignOfTest.cpp | 7 +++----
|
|
10 files changed, 72 insertions(+), 4 deletions(-)
|
|
|
|
diff --git a/llvm/include/llvm/ADT/FunctionExtras.h b/llvm/include/llvm/ADT/FunctionExtras.h
|
|
index 3ce85530b718666afa1dafbf60699c1add423ea6..da61b606eb44bdbdeb4674c9c7eab9f691124f9c 100644
|
|
--- a/llvm/include/llvm/ADT/FunctionExtras.h
|
|
+++ b/llvm/include/llvm/ADT/FunctionExtras.h
|
|
@@ -56,6 +56,13 @@ namespace llvm {
|
|
/// It can hold functions with a non-const operator(), like mutable lambdas.
|
|
template <typename FunctionT> class unique_function;
|
|
|
|
+// GCC warns on OutOfLineStorage
|
|
+#if defined(__GNUC__) && !defined(__clang__)
|
|
+#pragma GCC diagnostic push
|
|
+#pragma GCC diagnostic ignored "-Warray-bounds"
|
|
+#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
|
|
+#endif
|
|
+
|
|
namespace detail {
|
|
|
|
template <typename T>
|
|
@@ -411,6 +418,10 @@ public:
|
|
}
|
|
};
|
|
|
|
+#if defined(__GNUC__) && !defined(__clang__)
|
|
+#pragma GCC diagnostic pop
|
|
+#endif
|
|
+
|
|
} // end namespace llvm
|
|
|
|
#endif // LLVM_ADT_FUNCTIONEXTRAS_H
|
|
diff --git a/llvm/include/llvm/ADT/Hashing.h b/llvm/include/llvm/ADT/Hashing.h
|
|
index 109966257b51c015754f6410aec5fa9b8de435ae..a33c6eec308c8722f88b09f73f954d39558c3d62 100644
|
|
--- a/llvm/include/llvm/ADT/Hashing.h
|
|
+++ b/llvm/include/llvm/ADT/Hashing.h
|
|
@@ -57,6 +57,11 @@
|
|
#include <tuple>
|
|
#include <utility>
|
|
|
|
+#ifdef _WIN32
|
|
+#pragma warning(push)
|
|
+#pragma warning(disable : 26495)
|
|
+#endif
|
|
+
|
|
namespace llvm {
|
|
template <typename T, typename Enable> struct DenseMapInfo;
|
|
|
|
@@ -677,4 +682,8 @@ struct hash<llvm::hash_code> {
|
|
|
|
} // namespace std;
|
|
|
|
+#ifdef _WIN32
|
|
+#pragma warning(pop)
|
|
+#endif
|
|
+
|
|
#endif
|
|
diff --git a/llvm/include/llvm/ADT/SmallVector.h b/llvm/include/llvm/ADT/SmallVector.h
|
|
index 85bf5172e419b1b58f53d3cf00d4aabb58877c33..ec340afd4519f4070389434006bf7f2afdbf2993 100644
|
|
--- a/llvm/include/llvm/ADT/SmallVector.h
|
|
+++ b/llvm/include/llvm/ADT/SmallVector.h
|
|
@@ -14,6 +14,14 @@
|
|
#ifndef LLVM_ADT_SMALLVECTOR_H
|
|
#define LLVM_ADT_SMALLVECTOR_H
|
|
|
|
+// This file uses std::memcpy() to copy std::pair<unsigned int, unsigned int>.
|
|
+// That type is POD, but the standard doesn't guarantee that. GCC doesn't treat
|
|
+// the type as POD so it throws a warning. We want to consider this a warning
|
|
+// instead of an error.
|
|
+#if __GNUC__ >= 8
|
|
+#pragma GCC diagnostic warning "-Wclass-memaccess"
|
|
+#endif
|
|
+
|
|
#include "llvm/Support/Compiler.h"
|
|
#include "llvm/Support/type_traits.h"
|
|
#include <algorithm>
|
|
diff --git a/llvm/include/llvm/Support/MathExtras.h b/llvm/include/llvm/Support/MathExtras.h
|
|
index d9de2e92d5b07bce1d02ffcfda614b9079d2df91..6028ba8ead7627b4821aa8642f5069b305605c5e 100644
|
|
--- a/llvm/include/llvm/Support/MathExtras.h
|
|
+++ b/llvm/include/llvm/Support/MathExtras.h
|
|
@@ -231,6 +231,11 @@ inline uint64_t maxUIntN(uint64_t N) {
|
|
return UINT64_MAX >> (64 - N);
|
|
}
|
|
|
|
+#ifdef _WIN32
|
|
+#pragma warning(push)
|
|
+#pragma warning(disable : 4146)
|
|
+#endif
|
|
+
|
|
/// Gets the minimum value for a N-bit signed integer.
|
|
inline int64_t minIntN(int64_t N) {
|
|
assert(N <= 64 && "integer width out of range");
|
|
@@ -240,6 +245,10 @@ inline int64_t minIntN(int64_t N) {
|
|
return UINT64_C(1) + ~(UINT64_C(1) << (N - 1));
|
|
}
|
|
|
|
+#ifdef _WIN32
|
|
+#pragma warning(pop)
|
|
+#endif
|
|
+
|
|
/// Gets the maximum value for a N-bit signed integer.
|
|
inline int64_t maxIntN(int64_t N) {
|
|
assert(N <= 64 && "integer width out of range");
|
|
diff --git a/llvm/include/llvm/Support/MemAlloc.h b/llvm/include/llvm/Support/MemAlloc.h
|
|
index f3f378b7697a18f57b189c5322b080fe23d45bec..0028e871f6a05baf6172c60c602b8b26e5f116c6 100644
|
|
--- a/llvm/include/llvm/Support/MemAlloc.h
|
|
+++ b/llvm/include/llvm/Support/MemAlloc.h
|
|
@@ -22,6 +22,14 @@
|
|
|
|
namespace llvm {
|
|
|
|
+#ifdef _WIN32
|
|
+#pragma warning(push)
|
|
+// Warning on NONNULL, report is not known to abort
|
|
+#pragma warning(disable : 6387)
|
|
+#pragma warning(disable : 28196)
|
|
+#pragma warning(disable : 28183)
|
|
+#endif
|
|
+
|
|
LLVM_ATTRIBUTE_RETURNS_NONNULL inline void *safe_malloc(size_t Sz) {
|
|
void *Result = std::malloc(Sz);
|
|
if (Result == nullptr) {
|
|
@@ -84,4 +92,9 @@ allocate_buffer(size_t Size, size_t Alignment);
|
|
void deallocate_buffer(void *Ptr, size_t Size, size_t Alignment);
|
|
|
|
} // namespace llvm
|
|
+
|
|
+#ifdef _WIN32
|
|
+#pragma warning(pop)
|
|
+#endif
|
|
+
|
|
#endif
|
|
diff --git a/llvm/lib/Support/raw_ostream.cpp b/llvm/lib/Support/raw_ostream.cpp
|
|
index 2dbb0674406e1860fdd0c266df64003e45b12fa3..e248eb67df9144bb4cf14e3d3acab161a95d1ce3 100644
|
|
--- a/llvm/lib/Support/raw_ostream.cpp
|
|
+++ b/llvm/lib/Support/raw_ostream.cpp
|
|
@@ -10,6 +10,10 @@
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
+#ifdef _WIN32
|
|
+#define _CRT_NONSTDC_NO_WARNINGS
|
|
+#endif
|
|
+
|
|
#include "llvm/Support/raw_ostream.h"
|
|
#include "llvm/ADT/StringExtras.h"
|
|
#include "llvm/Config/config.h"
|
|
diff --git a/llvm/unittests/ADT/DenseMapTest.cpp b/llvm/unittests/ADT/DenseMapTest.cpp
|
|
index e93e18423507655ce8275a0718d8e5d01915985f..b930a21f8b43b64835436fcd27f4802a7987827f 100644
|
|
--- a/llvm/unittests/ADT/DenseMapTest.cpp
|
|
+++ b/llvm/unittests/ADT/DenseMapTest.cpp
|
|
@@ -6,6 +6,10 @@
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
+#if defined(__GNUC__) && !defined(__clang__)
|
|
+#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
|
|
+#endif
|
|
+
|
|
#include "llvm/ADT/DenseMap.h"
|
|
#include "CountCopyAndMove.h"
|
|
#include "llvm/ADT/DenseMapInfo.h"
|
|
diff --git a/llvm/unittests/ADT/MapVectorTest.cpp b/llvm/unittests/ADT/MapVectorTest.cpp
|
|
index e0f11b60a0223da7c00a47c20b61136bd608bae6..9c802ab30721c9ce58ed65052a6ab467039226ff 100644
|
|
--- a/llvm/unittests/ADT/MapVectorTest.cpp
|
|
+++ b/llvm/unittests/ADT/MapVectorTest.cpp
|
|
@@ -6,6 +6,13 @@
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
+#if defined(__GNUC__)
|
|
+#pragma GCC diagnostic ignored "-Wpedantic"
|
|
+#if !defined(__clang__)
|
|
+#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
|
|
+#endif
|
|
+#endif
|
|
+
|
|
#include "llvm/ADT/MapVector.h"
|
|
#include "llvm/ADT/iterator_range.h"
|
|
#include "gtest/gtest.h"
|
|
diff --git a/llvm/unittests/ADT/SmallVectorTest.cpp b/llvm/unittests/ADT/SmallVectorTest.cpp
|
|
index 7029038d18d433cef987bedbfa4fda269b24fb8f..f8c37820ef9fdfe0af067f5aa8d2297ed15e73bc 100644
|
|
--- a/llvm/unittests/ADT/SmallVectorTest.cpp
|
|
+++ b/llvm/unittests/ADT/SmallVectorTest.cpp
|
|
@@ -17,6 +17,10 @@
|
|
#include <span>
|
|
#include <stdarg.h>
|
|
|
|
+#if defined(__GNUC__)
|
|
+#pragma GCC diagnostic ignored "-Wpedantic"
|
|
+#endif
|
|
+
|
|
using namespace llvm;
|
|
|
|
namespace {
|
|
diff --git a/llvm/unittests/Support/AlignOfTest.cpp b/llvm/unittests/Support/AlignOfTest.cpp
|
|
index f84895c18602d3936d623ed79c5d9689cd57cc91..6a50205b143b7ff553066f048a45bf4e1ecc475b 100644
|
|
--- a/llvm/unittests/Support/AlignOfTest.cpp
|
|
+++ b/llvm/unittests/Support/AlignOfTest.cpp
|
|
@@ -31,10 +31,9 @@ namespace {
|
|
#pragma clang diagnostic ignored "-Wunknown-pragmas"
|
|
#pragma clang diagnostic ignored "-Winaccessible-base"
|
|
#elif ((__GNUC__ * 100) + __GNUC_MINOR__) >= 402
|
|
-// Pragma based warning suppression was introduced in GGC 4.2. Additionally
|
|
-// this warning is "enabled by default". The warning still appears if -Wall is
|
|
-// suppressed. Apparently GCC suppresses it when -w is specifed, which is odd.
|
|
-#pragma GCC diagnostic warning "-w"
|
|
+#pragma GCC diagnostic warning "-Wunknown-pragmas"
|
|
+#pragma GCC diagnostic warning "-Winaccessible-base"
|
|
+#pragma GCC diagnostic warning "-Wunused-function"
|
|
#endif
|
|
|
|
// Define some fixed alignment types to use in these tests.
|