[libc] Switch to using the generic `<gpuintrin.h>` implementations (#121810)
[llvm-project.git] / runtimes / cmake / Modules / WarningFlags.cmake
blobd17bf92389d0b007dfd5f01c90cb98e7cc2c4848
1 include(HandleFlags)
3 # Warning flags ===============================================================
4 function(cxx_add_warning_flags target enable_werror enable_pedantic)
5   target_compile_definitions(${target} PUBLIC -D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
6   if (MSVC)
7     # -W4 is the cl.exe/clang-cl equivalent of -Wall. (In cl.exe and clang-cl,
8     # -Wall is equivalent to -Weverything in GCC style compiler drivers.)
9     target_add_compile_flags_if_supported(${target} PRIVATE -W4)
10   else()
11     target_add_compile_flags_if_supported(${target} PRIVATE -Wall)
12   endif()
13   # TODO: Should -Wconversion be enabled?
14   target_add_compile_flags_if_supported(${target} PRIVATE
15       -Wextra
16       -Wnewline-eof
17       -Wshadow
18       -Wwrite-strings
19       -Wno-unused-parameter
20       -Wno-long-long
21       -Werror=return-type
22       -Wextra-semi
23       -Wundef
24       -Wunused-template
25       -Wformat-nonliteral
26       -Wzero-length-array
27       -Wdeprecated-redundant-constexpr-static-def
28       )
30   if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
31     target_add_compile_flags_if_supported(${target} PRIVATE
32       -Wno-user-defined-literals
33       -Wno-covered-switch-default
34       -Wno-suggest-override
35     )
36     if (LIBCXX_TARGETING_CLANG_CL)
37       target_add_compile_flags_if_supported(${target} PRIVATE
38         -Wno-c++98-compat
39         -Wno-c++98-compat-pedantic
40         -Wno-c++11-compat
41         -Wno-undef
42         -Wno-reserved-id-macro
43         -Wno-gnu-include-next
44         -Wno-gcc-compat # For ignoring "'diagnose_if' is a clang extension" warnings
45         -Wno-zero-as-null-pointer-constant # FIXME: Remove this and fix all occurrences.
46         -Wno-deprecated-dynamic-exception-spec # For auto_ptr
47         -Wno-sign-conversion
48         -Wno-old-style-cast
49         -Wno-deprecated # FIXME: Remove this and fix all occurrences.
50         -Wno-shift-sign-overflow # FIXME: Why do we need this with clang-cl but not clang?
51         -Wno-double-promotion # FIXME: remove me
52       )
53     endif()
55   elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
57     target_add_compile_flags_if_supported(${target} PRIVATE
58       -Wstrict-aliasing=2
59       -Wstrict-overflow=4
60       -Wno-attributes
61       -Wno-literal-suffix
62       -Wno-c++14-compat
63       -Wno-noexcept-type
64       -Wno-suggest-override
65       -Wno-alloc-size-larger-than
66       -Wno-deprecated-declarations
67       -Wno-dangling-reference
68       -Wno-strict-overflow
69       -Wno-maybe-uninitialized
70       -Wno-strict-aliasing
71       )
73   endif()
74   if (${enable_werror})
75     target_add_compile_flags_if_supported(${target} PRIVATE -Werror)
76     target_add_compile_flags_if_supported(${target} PRIVATE -WX)
77   else()
78     # TODO(EricWF) Remove this. We shouldn't be suppressing errors when -Werror is
79     # added elsewhere.
80     target_add_compile_flags_if_supported(${target} PRIVATE -Wno-error)
81   endif()
82   if (${enable_pedantic})
83     target_add_compile_flags_if_supported(${target} PRIVATE -pedantic)
84   endif()
85 endfunction()