[cfe-dev] MSVC /Za considered harmful

Nikola Smiljanic popizdeh at gmail.com
Wed Jun 6 05:17:37 PDT 2012


I just removed a couple of lines from CMakeLists that mentioned /Za and
projects are now generated without this flag. I did a rebuild using Visual
Studio 2010 and everything went fine except for CFG.cpp which says:

clang\lib\Analysis\CFG.cpp(3203): error C2059: syntax error : '='
clang\lib\Analysis\CFG.cpp(3203): error C2143: syntax error : missing ';'
before '{'
clang\lib\Analysis\CFG.cpp(3204): error C2059: syntax error : '__cdecl'

Renaming cdecl variable to decl fixed this, funny.

P.S. I know very little about CMake, somebody who knows this stuff should
review the patch
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20120606/19b8cf9d/attachment.html>
-------------- next part --------------
Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt	(revision 158060)
+++ CMakeLists.txt	(working copy)
@@ -198,14 +198,6 @@
   link_system_libs( ${name} )
 
   add_dependencies(${name} ClangDiagnosticCommon)
-  if(MSVC)
-    get_target_property(cflag ${name} COMPILE_FLAGS)
-    if(NOT cflag)
-      set(cflag "")
-    endif(NOT cflag)
-    set(cflag "${cflag} /Za")
-    set_target_properties(${name} PROPERTIES COMPILE_FLAGS ${cflag})
-  endif(MSVC)
   install(TARGETS ${name}
     LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
     ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}
Index: lib/Analysis/CFG.cpp
===================================================================
--- lib/Analysis/CFG.cpp	(revision 158060)
+++ lib/Analysis/CFG.cpp	(working copy)
@@ -3200,8 +3200,8 @@
 }
 
 bool CFGImplicitDtor::isNoReturn(ASTContext &astContext) const {
-  if (const CXXDestructorDecl *cdecl = getDestructorDecl(astContext)) {
-    QualType ty = cdecl->getType();
+  if (const CXXDestructorDecl *decl = getDestructorDecl(astContext)) {
+    QualType ty = decl->getType();
     return cast<FunctionType>(ty)->getNoReturnAttr();
   }
   return false;
Index: lib/Driver/CMakeLists.txt
===================================================================
--- lib/Driver/CMakeLists.txt	(revision 158060)
+++ lib/Driver/CMakeLists.txt	(working copy)
@@ -20,13 +20,5 @@
   Types.cpp
   )
 
-IF(MSVC)
-  get_target_property(NON_ANSI_COMPILE_FLAGS clangDriver COMPILE_FLAGS)
-  string(REPLACE /Za
-    "" NON_ANSI_COMPILE_FLAGS
-    ${NON_ANSI_COMPILE_FLAGS})
-  set_target_properties(clangDriver PROPERTIES COMPILE_FLAGS ${NON_ANSI_COMPILE_FLAGS})
-ENDIF(MSVC)
-
 add_dependencies(clangDriver ClangAttrList ClangDiagnosticDriver
                  ClangDriverOptions ClangCC1AsOptions)
Index: lib/Frontend/CMakeLists.txt
===================================================================
--- lib/Frontend/CMakeLists.txt	(revision 158060)
+++ lib/Frontend/CMakeLists.txt	(working copy)
@@ -41,14 +41,6 @@
   Warnings.cpp
   )
 
-IF(MSVC)
-  get_target_property(NON_ANSI_COMPILE_FLAGS clangFrontend COMPILE_FLAGS)
-  string(REPLACE /Za
-    "" NON_ANSI_COMPILE_FLAGS
-    ${NON_ANSI_COMPILE_FLAGS})
-  set_target_properties(clangFrontend PROPERTIES COMPILE_FLAGS ${NON_ANSI_COMPILE_FLAGS})
-ENDIF(MSVC)
-
 add_dependencies(clangFrontend
   ClangAttrClasses
   ClangAttrList
Index: tools/libclang/CMakeLists.txt
===================================================================
--- tools/libclang/CMakeLists.txt	(revision 158060)
+++ tools/libclang/CMakeLists.txt	(working copy)
@@ -76,14 +76,6 @@
       INSTALL_NAME_DIR "@executable_path/../lib")
   endif()
 
-  if(MSVC)
-    # windows.h doesn't compile with /Za
-    get_target_property(NON_ANSI_COMPILE_FLAGS libclang COMPILE_FLAGS)
-    string(REPLACE "/Za" "" NON_ANSI_COMPILE_FLAGS ${NON_ANSI_COMPILE_FLAGS})
-    set_target_properties(libclang PROPERTIES
-      COMPILE_FLAGS ${NON_ANSI_COMPILE_FLAGS})
-  endif()
-
   set(LIBCLANG_STATIC_TARGET_NAME libclang_static)
 else()
   set(LIBCLANG_STATIC_TARGET_NAME libclang)


More information about the cfe-dev mailing list