[llvm] ce94a16 - [cmake] Enable -Werror=return-type

Dave Lee via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 9 13:51:39 PST 2021


Author: Dave Lee
Date: 2021-03-09T13:51:09-08:00
New Revision: ce94a161651d0edd313d0fa65571eb53d3a34d13

URL: https://github.com/llvm/llvm-project/commit/ce94a161651d0edd313d0fa65571eb53d3a34d13
DIFF: https://github.com/llvm/llvm-project/commit/ce94a161651d0edd313d0fa65571eb53d3a34d13.diff

LOG: [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

Added: 
    

Modified: 
    llvm/cmake/modules/HandleLLVMOptions.cmake

Removed: 
    


################################################################################
diff  --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake
index 32fb4e10e31e..911275f21124 100644
--- a/llvm/cmake/modules/HandleLLVMOptions.cmake
+++ b/llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -745,6 +745,10 @@ if (LLVM_ENABLE_WARNINGS AND (LLVM_COMPILER_IS_GCC_COMPATIBLE OR CLANG_CL))
 
   # Enable -Wstring-conversion to catch misuse of string literals.
   add_flag_if_supported("-Wstring-conversion" STRING_CONVERSION_FLAG)
+
+  # Enable -Werror=return-type if available, to catch functions that contain
+  # control paths that do not return a value.
+  add_flag_if_supported("-Werror=return-type" WERROR_RETURN_TYPE)
 endif (LLVM_ENABLE_WARNINGS AND (LLVM_COMPILER_IS_GCC_COMPATIBLE OR CLANG_CL))
 
 if (LLVM_COMPILER_IS_GCC_COMPATIBLE AND NOT LLVM_ENABLE_WARNINGS)


        


More information about the llvm-commits mailing list