[llvm] 12d8e7c - [cmake][msvc] Enable standards-conforming preprocessor

Jan Svoboda via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 2 09:36:01 PDT 2022


Author: Jan Svoboda
Date: 2022-11-02T09:35:55-07:00
New Revision: 12d8e7c6ade55bba241259312e3e4bdcf6aeab81

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

LOG: [cmake][msvc] Enable standards-conforming preprocessor

Since we now only support Visual Studio 2019 16.7 and newer, we're able to use the /Zc:preprocessor flag that turns on the standards-conforming preprocessor. Among other things, it correctly expands __VA_ARGS__. This enables removal of some boilerplate in D135128.

Reviewed By: Bigcheese, thieta

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

Added: 
    

Modified: 
    llvm/cmake/modules/HandleLLVMOptions.cmake

Removed: 
    


################################################################################
diff  --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake
index 7828e8a1627f2..8be51f74a9814 100644
--- a/llvm/cmake/modules/HandleLLVMOptions.cmake
+++ b/llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -481,6 +481,10 @@ if( MSVC )
 
   append("/Zc:inline" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
 
+  # Enable standards-conforming preprocessor.
+  # https://learn.microsoft.com/en-us/cpp/build/reference/zc-preprocessor
+  append("/Zc:preprocessor" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
+
   # Some projects use the __cplusplus preprocessor macro to check support for
   # a particular version of the C++ standard. When this option is not specified
   # explicitly, macro's value is "199711L" that implies C++98 Standard.


        


More information about the llvm-commits mailing list