[llvm] 1f8f876 - [CMake] Disable GCC -Wnonnull

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Sun Jul 23 20:19:46 PDT 2023


Author: Farid Zakaria
Date: 2023-07-23T20:19:42-07:00
New Revision: 1f8f8760b586320be094daa872b298eeeedf582d

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

LOG: [CMake] Disable GCC -Wnonnull

I noticed during the build that GCC would emit a ton of nonnull
warnings.

Example:
```
/usr/local/google/home/fmzakari/code/github.com/llvm/llvm-project/clang/include/clang/AST/ExternalASTSource.h:378:54: warning: ‘this’ pointer is null [-Wnonnull]
  378 |       Ptr = reinterpret_cast<uint64_t>((Source->*Get)(Ptr >> 1));
      |                                        ~~~~~~~~~~~~~~^~~~~~~~~~
```

Reviewed By: MaskRay, rsmith

Differential Revision: https://reviews.llvm.org/D155857

Added: 
    

Modified: 
    llvm/cmake/modules/HandleLLVMOptions.cmake

Removed: 
    


################################################################################
diff  --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake
index 8692af9039ac52..19d6c58d991b7c 100644
--- a/llvm/cmake/modules/HandleLLVMOptions.cmake
+++ b/llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -770,6 +770,11 @@ if (LLVM_ENABLE_WARNINGS AND (LLVM_COMPILER_IS_GCC_COMPATIBLE OR CLANG_CL))
   append_if(USE_NO_UNINITIALIZED "-Wno-uninitialized" CMAKE_CXX_FLAGS)
   append_if(USE_NO_MAYBE_UNINITIALIZED "-Wno-maybe-uninitialized" CMAKE_CXX_FLAGS)
 
+  # Disable -Wnonnull for GCC warning as it is emitting a lot of false positives.
+  if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
+    append("-Wno-nonnull" CMAKE_CXX_FLAGS)
+  endif()
+
   # Disable -Wclass-memaccess, a C++-only warning from GCC 8 that fires on
   # LLVM's ADT classes.
   check_cxx_compiler_flag("-Wclass-memaccess" CXX_SUPPORTS_CLASS_MEMACCESS_FLAG)


        


More information about the llvm-commits mailing list