[Tarantool-patches] [PATCH 2/2] cmake: split UB sanitations into separate flags.

Timur Safin tsafin at tarantool.org
Mon Jun 15 18:41:00 MSK 2020



: Sent: Sunday, June 14, 2020 7:25 PM
: Subject: [PATCH 2/2] cmake: split UB sanitations into separate flags.
: 


: diff --git a/cmake/compiler.cmake b/cmake/compiler.cmake
: index 6c0fa635c..6de8219a0 100644
: --- a/cmake/compiler.cmake
: +++ b/cmake/compiler.cmake
: @@ -269,19 +269,55 @@ macro(enable_tnt_compile_flags)
:          if (NOT CMAKE_COMPILER_IS_CLANG)
:              message(FATAL_ERROR "Undefined behaviour sanitizer only
: available for clang")
:          else()
: -            set(SANITIZE_FLAGS "-fsanitize=undefined -fno-sanitize-
: recover=undefined")
: +            string(JOIN "," SANITIZE_FLAGS
: +                "alignment"
: +                "bool"
: +                "bounds"
: +                "builtin"
: +                "enum"
: +                "float-cast-overflow"
: +                "float-divide-by-zero"
: +                "function"
: +                "integer-divide-by-zero"
: +                "return"
: +                "shift"
: +                "unreachable"
: +                "vla-bound"
: +            )
: +

You know, every time I see (unnecessary) quoted strings inside of cmake 
lists I want to run and fix it immediately. Because there is no actual
need to quote them - in cmake almost everything is string literal at the end

Thus I tried to make this construction compacter and less verbose, e.g.

diff --git a/cmake/compiler.cmake b/cmake/compiler.cmake                                              
index 6de8219a0..5a1141ebd 100644                                                                     
--- a/cmake/compiler.cmake                                                                            
+++ b/cmake/compiler.cmake                                                                            
@@ -270,19 +270,9 @@ macro(enable_tnt_compile_flags)                                                  
             message(FATAL_ERROR "Undefined behaviour sanitizer only available for clang")            
         else()                                                                                       
             string(JOIN "," SANITIZE_FLAGS                                                           
-                "alignment"                                                                          
-                "bool"                                                                               
-                "bounds"                                                                             
-                "builtin"                                                                            
-                "enum"                                                                               
-                "float-cast-overflow"                                                                
-                "float-divide-by-zero"                                                               
-                "function"                                                                           
-                "integer-divide-by-zero"                                                             
-                "return"                                                                             
-                "shift"                                                                              
-                "unreachable"                                                                        
-                "vla-bound"                                                                          
+                alignment bool bounds builtin enum float-cast-overflow                               
+                float-divide-by-zero function integer-divide-by-zero return                          
+                shift unreachable vla-bound                                                          
             )                                                                                        
                                                                                                      
             # Exclude "object-size".                                                                 
                                                                                                      

---
But it did not add any readability penny, so I'm not insisting on using it.


Hence, LGTM 




More information about the Tarantool-patches mailing list