Suppress common warnings when building by clang (#69710)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/69710

Namely no range-loop-analysis (that detect when loop variable can not be const reference

Test Plan: Imported from OSS

Reviewed By: r-barnes

Differential Revision: D32997003

Pulled By: malfet

fbshipit-source-id: dba0e7875e5b667e2cc394c70dd75e2403265918
This commit is contained in:
Nikita Shulga 2021-12-10 16:43:41 -08:00 committed by Facebook GitHub Bot
parent 41c344d460
commit e305e4d4d8
3 changed files with 13 additions and 5 deletions

View File

@ -768,6 +768,10 @@ if(NOT MSVC)
string(APPEND CMAKE_CXX_FLAGS " -Wno-strict-overflow")
string(APPEND CMAKE_CXX_FLAGS " -Wno-strict-aliasing")
string(APPEND CMAKE_CXX_FLAGS " -Wno-error=deprecated-declarations")
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
string(APPEND CMAKE_CXX_FLAGS " -Wno-range-loop-analysis")
string(APPEND CMAKE_CXX_FLAGS " -Wno-pass-failed")
endif()
if(CMAKE_COMPILER_IS_GNUCXX AND NOT (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0.0))
string(APPEND CMAKE_CXX_FLAGS " -Wno-stringop-overflow")
string(APPEND CMAKE_CXX_FLAGS " -Wno-noexcept-type")

View File

@ -447,7 +447,10 @@ function(torch_compile_options libname)
# warnings, see https://bugs.llvm.org/show_bug.cgi?id=21629
-Wno-missing-braces
)
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
list(APPEND private_compile_options
-Wno-range-loop-analysis)
endif()
if(NOT APPLE)
list(APPEND private_compile_options
# Considered to be flaky. See the discussion at

View File

@ -105,10 +105,11 @@ else()
-fno-strict-aliasing
-Wno-write-strings
-Wno-strict-aliasing)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
list(APPEND TORCH_PYTHON_COMPILE_OPTIONS
-Wno-writable-strings)
endif()
endif()
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
list(APPEND TORCH_PYTHON_COMPILE_OPTIONS
-Wno-writable-strings)
endif()
if(USE_CUDA)