e38fc6de8a
This enables -Wshadow to warn about shadow variables on in tree code under arch/, boards/, drivers/, kernel/, lib/, soc/, and subsys/. Note that this does not enable it globally because out-of-tree modules will probably take some time to fix (or not at all depending on the project), and it would be great to avoid introduction of any new shadow variables in the meantime. Also note that this tries to be done in a minimally invasive way so it is easy to revert when we enable -Wshadow globally. Source files under modules/, samples/ and tests/ are currently excluded because there does not seem to be a trivial way to add -Wshadow there without going through all CMakeLists.txt to add the option (as there are 1000+ files to change). Signed-off-by: Daniel Leung <daniel.leung@intel.com>
37 lines
1.3 KiB
CMake
37 lines
1.3 KiB
CMake
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
include(${ZEPHYR_BASE}/cmake/compiler/clang/compiler_flags.cmake)
|
|
|
|
# nostdinc_include contains path to llvm headers and also relative
|
|
# path of "include-fixed".
|
|
# Clear "nostdinc" and nostdinc_include
|
|
set_compiler_property(PROPERTY nostdinc)
|
|
set_compiler_property(PROPERTY nostdinc_include)
|
|
|
|
# For C++ code, re-add the standard includes directory which was
|
|
# cleared up from nostdinc_inlcude in above lines with no
|
|
# "include-fixed" this time"
|
|
if(CONFIG_CPP)
|
|
execute_process(
|
|
COMMAND ${CMAKE_C_COMPILER} --print-file-name=include/stddef.h
|
|
OUTPUT_VARIABLE _OUTPUT
|
|
COMMAND_ERROR_IS_FATAL ANY
|
|
)
|
|
get_filename_component(_OUTPUT "${_OUTPUT}" DIRECTORY)
|
|
string(REGEX REPLACE "\n" "" _OUTPUT "${_OUTPUT}")
|
|
set_compiler_property(PROPERTY nostdinc_include "${_OUTPUT}")
|
|
endif()
|
|
|
|
if($ENV{XCC_NO_G_FLAG})
|
|
# Older xcc/clang cannot use "-g" due to this bug:
|
|
# https://bugs.llvm.org/show_bug.cgi?id=11740.
|
|
# Clear the related flag(s) here so it won't cause issues.
|
|
set_compiler_property(PROPERTY debug)
|
|
endif()
|
|
|
|
# Clang version used by Xtensa does not support -fno-pic and -fno-pie
|
|
set_compiler_property(PROPERTY no_position_independent "")
|
|
|
|
# Remove after testing that -Wshadow works
|
|
set_compiler_property(PROPERTY warning_shadow_variables)
|