8339156: Use more fine-granular clang unused warnings

Reviewed-by: erikj, kbarrett
This commit is contained in:
Magnus Ihse Bursie 2024-08-30 16:43:16 +00:00
parent 2fb830553f
commit a528c4b370
16 changed files with 59 additions and 18 deletions

View File

@ -242,6 +242,8 @@ AC_DEFUN([FLAGS_SETUP_WARNINGS],
WARNINGS_ENABLE_ALL_CFLAGS="-Wall -Wextra -Wformat=2 $WARNINGS_ENABLE_ADDITIONAL"
WARNINGS_ENABLE_ALL_CXXFLAGS="$WARNINGS_ENABLE_ALL_CFLAGS $WARNINGS_ENABLE_ADDITIONAL_CXX"
# These warnings will never be turned on, since they generate too many
# false positives.
DISABLED_WARNINGS="unused-parameter"
# gcc10/11 on ppc generate lots of abi warnings about layout of aggregates containing vectors
if test "x$OPENJDK_TARGET_CPU_ARCH" = "xppc"; then
@ -259,7 +261,9 @@ AC_DEFUN([FLAGS_SETUP_WARNINGS],
-Wunused-function -Wundef -Wunused-value -Woverloaded-virtual"
WARNINGS_ENABLE_ALL="-Wall -Wextra -Wformat=2 $WARNINGS_ENABLE_ADDITIONAL"
DISABLED_WARNINGS="unknown-warning-option unused-parameter unused"
# These warnings will never be turned on, since they generate too many
# false positives.
DISABLED_WARNINGS="unknown-warning-option unused-parameter"
;;
esac
AC_SUBST(DISABLE_WARNING_PREFIX)

View File

@ -115,8 +115,9 @@ define SetupTestFilesCompilationBody
DISABLED_WARNINGS_gcc := format undef unused-but-set-variable \
unused-const-variable unused-function unused-value \
unused-variable, \
DISABLED_WARNINGS_clang := undef format-nonliteral \
missing-field-initializers sometimes-uninitialized, \
DISABLED_WARNINGS_clang := format-nonliteral \
missing-field-initializers sometimes-uninitialized undef \
unused-but-set-variable unused-function unused-variable, \
DEFAULT_LIBCXX := false, \
JDK_LIBS := $$($1_JDK_LIBS_$$(name)), \
LIBS := $$($1_LIBS_$$(name)), \

View File

@ -136,6 +136,7 @@ define SetupBuildLauncherBody
CFLAGS_windows := $$($1_CFLAGS_windows), \
EXTRA_HEADER_DIRS := java.base:libjvm, \
DISABLED_WARNINGS_gcc := unused-function unused-variable, \
DISABLED_WARNINGS_clang := unused-function, \
LDFLAGS := $$($1_LDFLAGS), \
LDFLAGS_linux := $$(call SET_EXECUTABLE_ORIGIN,/../lib), \
LDFLAGS_macosx := $$(call SET_EXECUTABLE_ORIGIN,/../lib), \

View File

@ -95,8 +95,9 @@ DISABLED_WARNINGS_gcc := array-bounds comment delete-non-virtual-dtor \
shift-negative-value unknown-pragmas unused-but-set-variable \
unused-local-typedefs unused-variable
DISABLED_WARNINGS_clang := sometimes-uninitialized \
missing-braces delete-non-abstract-non-virtual-dtor unknown-pragmas
DISABLED_WARNINGS_clang := delete-non-abstract-non-virtual-dtor missing-braces \
sometimes-uninitialized unknown-pragmas unused-but-set-variable \
unused-function unused-local-typedef unused-private-field unused-variable
ifneq ($(DEBUG_LEVEL), release)
# Assert macro gives warning

View File

@ -46,7 +46,9 @@ $(eval $(call SetupJdkLibrary, BUILD_LIBNET, \
OPTIMIZATION := LOW, \
DISABLED_WARNINGS_gcc_net_util_md.c := format-nonliteral unused-variable, \
DISABLED_WARNINGS_gcc_NetworkInterface.c := unused-function, \
DISABLED_WARNINGS_clang_net_util_md.c := format-nonliteral, \
DISABLED_WARNINGS_clang_net_util_md.c := format-nonliteral \
unused-variable, \
DISABLED_WARNINGS_clang_NetworkInterface.c := unused-function, \
DISABLED_WARNINGS_clang_aix_DefaultProxySelector.c := \
deprecated-non-prototype, \
DISABLED_WARNINGS_clang_aix_NetworkInterface.c := gnu-pointer-arith, \
@ -77,6 +79,8 @@ $(eval $(call SetupJdkLibrary, BUILD_LIBNIO, \
libnio/ch \
libnio/fs \
libjvm, \
DISABLED_WARNINGS_clang_Net.c := unused-function unused-variable, \
DISABLED_WARNINGS_clang_UnixNativeDispatcher.c := unused-variable, \
JDK_LIBS := libjava libnet, \
LIBS_linux := $(LIBDL) -lpthread, \
LIBS_aix := $(LIBDL), \
@ -96,7 +100,8 @@ ifeq ($(call isTargetOs, macosx), true)
$(eval $(call SetupJdkLibrary, BUILD_LIBOSXSECURITY, \
NAME := osxsecurity, \
OPTIMIZATION := LOW, \
DISABLED_WARNINGS_clang_KeystoreImpl.m := deprecated-declarations, \
DISABLED_WARNINGS_clang_KeystoreImpl.m := deprecated-declarations \
unused-but-set-variable unused-variable, \
JDK_LIBS := libjava, \
LIBS_macosx := -lobjc \
-framework CoreServices \
@ -117,6 +122,7 @@ ifeq ($(call isTargetOsType, unix), true)
OPTIMIZATION := LOW, \
jsig.c_CFLAGS := -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"', \
DISABLED_WARNINGS_gcc_jsig.c := unused-but-set-variable, \
DISABLED_WARNINGS_clang_jsig.c := unused-but-set-variable, \
LIBS_linux := $(LIBDL), \
LIBS_aix := $(LIBDL), \
))

View File

@ -36,6 +36,7 @@ $(eval $(call SetupJdkLibrary, BUILD_LIBVERIFY, \
NAME := verify, \
OPTIMIZATION := $(LIBVERIFY_OPTIMIZATION), \
DISABLED_WARNINGS_gcc_check_code.c := unused-variable, \
DISABLED_WARNINGS_clang_check_code.c := unused-variable, \
EXTRA_HEADER_DIRS := libjava, \
JDK_LIBS := libjvm, \
))
@ -59,6 +60,7 @@ $(eval $(call SetupJdkLibrary, BUILD_LIBJAVA, \
java_props_md.c_CFLAGS := \
-DARCHPROPNAME='"$(OPENJDK_TARGET_CPU_OSARCH)"', \
DISABLED_WARNINGS_gcc_ProcessImpl_md.c := unused-result, \
DISABLED_WARNINGS_clang_TimeZone_md.c := unused-variable, \
JDK_LIBS := libjvm, \
LIBS_linux := $(LIBDL), \
LIBS_aix := $(LIBDL) $(LIBM),\
@ -93,6 +95,7 @@ $(eval $(call SetupJdkLibrary, BUILD_LIBZIP, \
DISABLED_WARNINGS_gcc_zip_util.c := unused-function, \
DISABLED_WARNINGS_clang := deprecated-non-prototype, \
DISABLED_WARNINGS_clang_gzwrite.c := format-nonliteral, \
DISABLED_WARNINGS_clang_zip_util.c := unused-function, \
JDK_LIBS := libjava libjvm, \
LIBS_unix := $(LIBZ_LIBS), \
))
@ -112,6 +115,9 @@ $(eval $(call SetupJdkLibrary, BUILD_LIBJIMAGE, \
DISABLED_WARNINGS_gcc_imageDecompressor.cpp := unused-variable, \
DISABLED_WARNINGS_gcc_imageFile.cpp := unused-const-variable \
unused-variable, \
DISABLED_WARNINGS_clang_imageDecompressor.cpp := unused-variable, \
DISABLED_WARNINGS_clang_imageFile.cpp := unused-private-field \
unused-variable, \
LDFLAGS := $(LDFLAGS_CXX_JDK), \
JDK_LIBS := libjvm, \
LIBS_unix := $(LIBDL), \
@ -172,7 +178,9 @@ $(eval $(call SetupJdkLibrary, BUILD_LIBJLI, \
OPTIMIZATION := HIGH, \
CFLAGS := $(LIBJLI_CFLAGS) $(LIBZ_CFLAGS), \
DISABLED_WARNINGS_gcc := unused-function unused-variable, \
DISABLED_WARNINGS_clang := format-nonliteral deprecated-non-prototype, \
DISABLED_WARNINGS_clang := deprecated-non-prototype format-nonliteral \
unused-function, \
DISABLED_WARNINGS_clang_java_md_macosx.m := unused-variable, \
LIBS_unix := $(LIBZ_LIBS), \
LIBS_linux := $(LIBDL) -lpthread, \
LIBS_macosx := \

View File

@ -65,7 +65,10 @@ ifeq ($(call isTargetOs, aix), false)
CFLAGS := $(LIBJSOUND_CFLAGS), \
CXXFLAGS := $(LIBJSOUND_CFLAGS), \
DISABLED_WARNINGS_gcc := undef unused-variable, \
DISABLED_WARNINGS_clang := undef, \
DISABLED_WARNINGS_clang := undef unused-variable, \
DISABLED_WARNINGS_clang_PLATFORM_API_MacOSX_MidiUtils.c := \
unused-but-set-variable, \
DISABLED_WARNINGS_clang_DirectAudioDevice.c := unused-function, \
LIBS_linux := $(ALSA_LIBS), \
LIBS_macosx := \
-framework AudioToolbox \

View File

@ -113,6 +113,7 @@ $(eval $(call SetupJdkLibrary, BUILD_LIBAWT, \
DISABLED_WARNINGS_gcc_Region.c := maybe-uninitialized, \
DISABLED_WARNINGS_gcc_SurfaceData.c := unused-value, \
DISABLED_WARNINGS_gcc_TransformHelper.c := sign-compare, \
DISABLED_WARNINGS_clang := unused-but-set-variable unused-variable, \
DISABLED_WARNINGS_clang_awt_ImagingLib.c := deprecated-non-prototype, \
DISABLED_WARNINGS_clang_debug_trace.c := format-nonliteral, \
DISABLED_WARNINGS_clang_Trace.c := format-nonliteral, \
@ -312,9 +313,10 @@ ifeq ($(call isTargetOs, macosx), true)
EXCLUDES := $(LIBAWT_LWAWT_EXCLUDES), \
OPTIMIZATION := LOW, \
EXTRA_HEADER_DIRS := $(LIBAWT_LWAWT_EXTRA_HEADER_DIRS), \
DISABLED_WARNINGS_clang := incomplete-implementation \
deprecated-declarations objc-method-access \
incompatible-pointer-types extra-tokens sign-compare undef, \
DISABLED_WARNINGS_clang := deprecated-declarations extra-tokens \
incompatible-pointer-types incomplete-implementation \
objc-method-access sign-compare undef unused-function \
unused-variable, \
DISABLED_WARNINGS_clang_AWTWindow.m := bitwise-op-parentheses, \
DISABLED_WARNINGS_clang_CFileDialog.m := semicolon-before-method-body, \
DISABLED_WARNINGS_clang_CGGlyphImages.m := pointer-arith, \

View File

@ -46,6 +46,7 @@ $(eval $(call SetupJdkLibrary, BUILD_LIBMLIB_IMAGE, \
CFLAGS := -D__USE_J2D_NAMES -D__MEDIALIB_OLD_NAMES -DMLIB_NO_LIBSUNMATH \
$(LIBMLIB_IMAGE_CFLAGS), \
DISABLED_WARNINGS_gcc := unused-function, \
DISABLED_WARNINGS_clang_mlib_ImageCreate.c := unused-function, \
LIBS_unix := $(LIBDL) $(LIBM), \
))
@ -122,6 +123,7 @@ $(eval $(call SetupJdkLibrary, BUILD_LIBJAVAJPEG, \
unused-but-set-variable, \
DISABLED_WARNINGS_gcc_jcmaster.c := implicit-fallthrough, \
DISABLED_WARNINGS_gcc_jdphuff.c := shift-negative-value, \
DISABLED_WARNINGS_clang_imageioJPEG.c := unused-but-set-variable, \
JDK_LIBS := java.base:libjava, \
LIBS := $(LIBJPEG_LIBS), \
))
@ -230,10 +232,12 @@ ifeq ($(ENABLE_HEADLESS_ONLY), false)
DISABLED_WARNINGS_clang := deprecated-non-prototype, \
DISABLED_WARNINGS_clang_dgif_lib.c := sign-compare, \
DISABLED_WARNINGS_clang_gzwrite.c := format-nonliteral, \
DISABLED_WARNINGS_clang_splashscreen_impl.c := sign-compare, \
DISABLED_WARNINGS_clang_splashscreen_impl.c := sign-compare \
unused-but-set-variable unused-function, \
DISABLED_WARNINGS_clang_splashscreen_png.c := \
incompatible-pointer-types, \
DISABLED_WARNINGS_clang_splashscreen_sys.m := deprecated-declarations, \
DISABLED_WARNINGS_clang_splashscreen_sys.m := deprecated-declarations \
unused-variable unused-but-set-variable, \
DISABLED_WARNINGS_microsoft_dgif_lib.c := 4018 4267, \
DISABLED_WARNINGS_microsoft_splashscreen_impl.c := 4018 4267 4244, \
DISABLED_WARNINGS_microsoft_splashscreen_png.c := 4267, \
@ -322,7 +326,7 @@ else
expansion-to-defined dangling-reference maybe-uninitialized \
calloc-transposed-args
HARFBUZZ_DISABLED_WARNINGS_clang := missing-field-initializers \
range-loop-analysis
range-loop-analysis unused-variable
HARFBUZZ_DISABLED_WARNINGS_microsoft := 4267 4244
LIBFONTMANAGER_CFLAGS += $(HARFBUZZ_CFLAGS)

View File

@ -38,6 +38,7 @@ $(eval $(call SetupJdkLibrary, BUILD_LIBMANAGEMENT, \
NAME := management, \
OPTIMIZATION := $(LIBMANAGEMENT_OPTIMIZATION), \
DISABLED_WARNINGS_gcc_VMManagementImpl.c := unused-variable, \
DISABLED_WARNINGS_clang_VMManagementImpl.c := unused-variable, \
JDK_LIBS := java.base:libjava java.base:libjvm, \
LIBS_aix := -lperfstat,\
LIBS_windows := advapi32.lib psapi.lib, \

View File

@ -34,7 +34,7 @@ $(eval $(call SetupJdkLibrary, BUILD_LIBJ2GSS, \
OPTIMIZATION := LOW, \
EXTRA_HEADER_DIRS := java.base:libjava, \
DISABLED_WARNINGS_gcc := undef unused-but-set-variable, \
DISABLED_WARNINGS_clang := undef, \
DISABLED_WARNINGS_clang := undef unused-but-set-variable, \
LIBS_unix := $(LIBDL), \
))

View File

@ -34,6 +34,7 @@ $(eval $(call SetupJdkLibrary, BUILD_LIBJ2PKCS11, \
OPTIMIZATION := LOW, \
EXTRA_HEADER_DIRS := java.base:libjava, \
DISABLED_WARNINGS_gcc_p11_md.c := unused-variable, \
DISABLED_WARNINGS_clang_p11_md.c := unused-variable, \
DISABLED_WARNINGS_clang_p11_util.c := format-nonliteral, \
LIBS_unix := $(LIBDL), \
))

View File

@ -64,6 +64,7 @@ $(eval $(call SetupJdkLibrary, BUILD_LIBSAPROC, \
DISABLED_WARNINGS_gcc_symtab.c := unused-but-set-variable, \
DISABLED_WARNINGS_clang := sign-compare, \
DISABLED_WARNINGS_clang_libproc_impl.c := format-nonliteral, \
DISABLED_WARNINGS_clang_MacosxDebuggerLocal.m := unused-variable, \
DISABLED_WARNINGS_clang_ps_core.c := pointer-arith, \
DISABLED_WARNINGS_clang_sadis.c := format-nonliteral, \
CFLAGS := $(LIBSAPROC_CFLAGS), \

View File

@ -54,12 +54,18 @@ $(eval $(call SetupJdkLibrary, BUILD_LIBJDWP, \
CFLAGS := -DJDWP_LOGGING, \
DISABLED_WARNINGS_gcc_eventFilter.c := unused-variable, \
DISABLED_WARNINGS_gcc_SDE.c := unused-function, \
DISABLED_WARNINGS_gcc_threadControl.c := unused-but-set-variable unused-variable, \
DISABLED_WARNINGS_gcc_threadControl.c := unused-but-set-variable \
unused-variable, \
DISABLED_WARNINGS_gcc_utf_util.c := unused-but-set-variable, \
DISABLED_WARNINGS_clang_error_messages.c := format-nonliteral, \
DISABLED_WARNINGS_clang_eventFilter.c := unused-variable, \
DISABLED_WARNINGS_clang_EventRequestImpl.c := self-assign, \
DISABLED_WARNINGS_clang_inStream.c := sometimes-uninitialized, \
DISABLED_WARNINGS_clang_log_messages.c := format-nonliteral, \
DISABLED_WARNINGS_clang_SDE.c := unused-function, \
DISABLED_WARNINGS_clang_threadControl.c := unused-but-set-variable \
unused-variable, \
DISABLED_WARNINGS_clang_utf_util.c := unused-but-set-variable, \
EXTRA_HEADER_DIRS := \
include \
libjdwp/export \

View File

@ -53,8 +53,9 @@ $(eval $(call SetupJdkExecutable, BUILD_JPACKAGEAPPLAUNCHER, \
EXTRA_SRC := common, \
INCLUDE_FILES := $(JPACKAGEAPPLAUNCHER_INCLUDE_FILES), \
OPTIMIZATION := LOW, \
DISABLED_WARNINGS_clang_LinuxPackage.c := format-nonliteral, \
DISABLED_WARNINGS_clang_JvmLauncherLib.c := format-nonliteral, \
DISABLED_WARNINGS_clang_LinuxPackage.c := format-nonliteral, \
DISABLED_WARNINGS_clang_Log.cpp := unused-const-variable, \
CFLAGS_FILTER_OUT := -MD, \
CXXFLAGS_FILTER_OUT := -MD, \
CFLAGS_macosx := -Wno-format-nonliteral, \

View File

@ -45,6 +45,7 @@ $(eval $(call SetupJdkLibrary, BUILD_LIBMANAGEMENT_EXT, \
NAME := management_ext, \
OPTIMIZATION := $(LIBMANAGEMENT_EXT_OPTIMIZATION), \
DISABLED_WARNINGS_gcc_DiagnosticCommandImpl.c := unused-variable, \
DISABLED_WARNINGS_clang_DiagnosticCommandImpl.c := unused-variable, \
DISABLED_WARNINGS_clang_UnixOperatingSystem.c := format-nonliteral, \
CFLAGS := $(LIBMANAGEMENT_EXT_CFLAGS), \
JDK_LIBS := java.base:libjava java.base:libjvm, \