Skip to content

Commit ce94a16

Browse files
committed
[cmake] Enable -Werror=return-type
Turn `-Wreturn-type` into an error. This is currently used by libcxx, libcxxabi, and libunwind, and would be a good default for all of llvm. I'm not aware of any cases where this shouldn't be an error. This ensures different build configs, merges, and downstream branches catch issues sooner. Differential Revision: https://reviews.llvm.org/D98224
1 parent c92d2ea commit ce94a16

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

llvm/cmake/modules/HandleLLVMOptions.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -745,6 +745,10 @@ if (LLVM_ENABLE_WARNINGS AND (LLVM_COMPILER_IS_GCC_COMPATIBLE OR CLANG_CL))
745745

746746
# Enable -Wstring-conversion to catch misuse of string literals.
747747
add_flag_if_supported("-Wstring-conversion" STRING_CONVERSION_FLAG)
748+
749+
# Enable -Werror=return-type if available, to catch functions that contain
750+
# control paths that do not return a value.
751+
add_flag_if_supported("-Werror=return-type" WERROR_RETURN_TYPE)
748752
endif (LLVM_ENABLE_WARNINGS AND (LLVM_COMPILER_IS_GCC_COMPATIBLE OR CLANG_CL))
749753

750754
if (LLVM_COMPILER_IS_GCC_COMPATIBLE AND NOT LLVM_ENABLE_WARNINGS)

0 commit comments

Comments
 (0)