Skip to content
This repository was archived by the owner on Nov 27, 2025. It is now read-only.

Commit 26236fc

Browse files
update a function to enable some warning for specified target
Signed-off-by: Zhu, Shaojie <[email protected]>
1 parent 899b076 commit 26236fc

File tree

45 files changed

+159
-186
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+159
-186
lines changed

llvm/cmake/modules/HandleLLVMOptions.cmake

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -769,6 +769,16 @@ if (MSVC)
769769
endforeach(flag)
770770
endif (MSVC)
771771

772+
function(enable_msvc_warnings_on_compiler_for_driver target_name enable_warning_level)
773+
if(MSVC AND BUILD_COMPILER_FOR_DRIVER)
774+
set(warnings ${ARGN})
775+
foreach(warning ${warnings})
776+
list(APPEND warning_flags "${enable_warning_level}${warning}")
777+
endforeach()
778+
target_compile_options(${target_name} PRIVATE ${warning_flags})
779+
endif()
780+
endfunction()
781+
772782
if (LLVM_ENABLE_WARNINGS AND (LLVM_COMPILER_IS_GCC_COMPATIBLE OR CLANG_CL))
773783

774784
# Don't add -Wall for clang-cl, because it maps -Wall to -Weverything for

llvm/lib/Analysis/CMakeLists.txt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,6 @@ add_llvm_component_library(LLVMAnalysis
162162
TargetParser
163163
)
164164

165-
if(MSVC AND BUILD_COMPILER_FOR_DRIVER)
166-
target_compile_options(LLVMAnalysis PRIVATE
167-
/w34146 /w34244 /w34267
168-
)
169-
endif()
165+
# Due to this target cannot pass the binskim scan after the compiler in the driver build,
166+
# it is necessary to remove the suppression of these three warnings(/wd4146 /wd4244 /wd4267).
167+
enable_msvc_warnings_on_compiler_for_driver(LLVMAnalysis /w3 4146 4244 4267)

llvm/lib/BinaryFormat/CMakeLists.txt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ add_llvm_component_library(LLVMBinaryFormat
2222
TargetParser
2323
)
2424

25-
if(MSVC AND BUILD_COMPILER_FOR_DRIVER)
26-
target_compile_options(LLVMBinaryFormat PRIVATE
27-
/w34146 /w34244 /w34267
28-
)
29-
endif()
25+
# Due to this target cannot pass the binskim scan after the compiler in the driver build,
26+
# it is necessary to remove the suppression of these three warnings(/wd4146 /wd4244 /wd4267).
27+
enable_msvc_warnings_on_compiler_for_driver(LLVMBinaryFormat /w3 4146 4244 4267)

llvm/lib/Bitcode/Reader/CMakeLists.txt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ add_llvm_component_library(LLVMBitReader
1818
TargetParser
1919
)
2020

21-
if(MSVC AND BUILD_COMPILER_FOR_DRIVER)
22-
target_compile_options(LLVMBitReader PRIVATE
23-
/w34146 /w34244 /w34267
24-
)
25-
endif()
21+
# Due to this target cannot pass the binskim scan after the compiler in the driver build,
22+
# it is necessary to remove the suppression of these three warnings(/wd4146 /wd4244 /wd4267).
23+
enable_msvc_warnings_on_compiler_for_driver(LLVMBitReader /w3 4146 4244 4267)

llvm/lib/Frontend/Offloading/CMakeLists.txt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ add_llvm_component_library(LLVMFrontendOffloading
1616
TargetParser
1717
)
1818

19-
if(MSVC AND BUILD_COMPILER_FOR_DRIVER)
20-
target_compile_options(LLVMFrontendOffloading PRIVATE
21-
/w34146 /w34244 /w34267
22-
)
23-
endif()
19+
# Due to this target cannot pass the binskim scan after the compiler in the driver build,
20+
# it is necessary to remove the suppression of these three warnings(/wd4146 /wd4244 /wd4267).
21+
enable_msvc_warnings_on_compiler_for_driver(LLVMFrontendOffloading /w3 4146 4244 4267)

llvm/lib/Frontend/OpenMP/CMakeLists.txt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ add_llvm_component_library(LLVMFrontendOpenMP
2323
FrontendOffloading
2424
)
2525

26-
if(MSVC AND BUILD_COMPILER_FOR_DRIVER)
27-
target_compile_options(LLVMFrontendOpenMP PRIVATE
28-
/w34146 /w34244 /w34267
29-
)
30-
endif()
26+
# Due to this target cannot pass the binskim scan after the compiler in the driver build,
27+
# it is necessary to remove the suppression of these three warnings(/wd4146 /wd4244 /wd4267).
28+
enable_msvc_warnings_on_compiler_for_driver(LLVMFrontendOpenMP /w3 4146 4244 4267)

llvm/lib/IR/CMakeLists.txt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,6 @@ add_llvm_component_library(LLVMCore
8888
TargetParser
8989
)
9090

91-
if(MSVC AND BUILD_COMPILER_FOR_DRIVER)
92-
target_compile_options(LLVMCore PRIVATE
93-
/w34146 /w34244 /w34267
94-
)
95-
endif()
91+
# Due to this target cannot pass the binskim scan after the compiler in the driver build,
92+
# it is necessary to remove the suppression of these three warnings(/wd4146 /wd4244 /wd4267).
93+
enable_msvc_warnings_on_compiler_for_driver(LLVMCore /w3 4146 4244 4267)

llvm/lib/ProfileData/CMakeLists.txt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,8 @@ add_llvm_component_library(LLVMProfileData
2929
TargetParser
3030
)
3131

32-
if(MSVC AND BUILD_COMPILER_FOR_DRIVER)
33-
target_compile_options(LLVMProfileData PRIVATE
34-
/w34146 /w34244 /w34267
35-
)
36-
endif()
32+
# Due to this target cannot pass the binskim scan after the compiler in the driver build,
33+
# it is necessary to remove the suppression of these three warnings(/wd4146 /wd4244 /wd4267).
34+
enable_msvc_warnings_on_compiler_for_driver(LLVMProfileData /w3 4146 4244 4267)
3735

3836
add_subdirectory(Coverage)

llvm/lib/Remarks/CMakeLists.txt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ add_llvm_component_library(LLVMRemarks
2222
intrinsics_gen
2323
)
2424

25-
if(MSVC AND BUILD_COMPILER_FOR_DRIVER)
26-
target_compile_options(LLVMRemarks PRIVATE
27-
/w34146 /w34244 /w34267
28-
)
29-
endif()
25+
# Due to this target cannot pass the binskim scan after the compiler in the driver build,
26+
# it is necessary to remove the suppression of these three warnings(/wd4146 /wd4244 /wd4267).
27+
enable_msvc_warnings_on_compiler_for_driver(LLVMRemarks /w3 4146 4244 4267)

llvm/lib/Support/CMakeLists.txt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -292,11 +292,9 @@ add_llvm_component_library(LLVMSupport
292292
Demangle
293293
)
294294

295-
if(MSVC AND BUILD_COMPILER_FOR_DRIVER)
296-
target_compile_options(LLVMSupport PRIVATE
297-
/w34146 /w34244 /w34267
298-
)
299-
endif()
295+
# Due to this target cannot pass the binskim scan after the compiler in the driver build,
296+
# it is necessary to remove the suppression of these three warnings(/wd4146 /wd4244 /wd4267).
297+
enable_msvc_warnings_on_compiler_for_driver(LLVMSupport /w3 4146 4244 4267)
300298

301299
set(llvm_system_libs ${system_libs})
302300

0 commit comments

Comments
 (0)