Make sure macros in the include subdirectory are not used without being defined.
authorBob Wilson <bob.wilson@apple.com>
Tue, 4 Sep 2012 17:42:53 +0000 (17:42 +0000)
committerBob Wilson <bob.wilson@apple.com>
Tue, 4 Sep 2012 17:42:53 +0000 (17:42 +0000)
Rationale: For each preprocessor macro, either the definedness is what's
meaningful, or the value is what's meaningful, or both. If definedness is
meaningful, we should use #ifdef. If the value is meaningful, we should use
and #ifdef interchangeably for the same macro, seems ugly to me, even if
undefined macros are zero if used.

This also has the benefit that including an LLVM header doesn't prevent
you from compiling with -Wundef -Werror.

Patch by John Garvin!
<rdar://problem/12189979>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@163148 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm-c/Core.h
include/llvm/Support/Compiler.h
include/llvm/Support/FileSystem.h

index 441fa4d13abe24dde6e02ffdc7d0614a8a193970..6587e77080078ae652eee5d1242d1edc44323725 100644 (file)
@@ -2688,7 +2688,7 @@ namespace llvm {
   
   template<typename T>
   inline T **unwrap(LLVMValueRef *Vals, unsigned Length) {
-    #if DEBUG
+    #ifdef DEBUG
     for (LLVMValueRef *I = Vals, *E = Vals + Length; I != E; ++I)
       cast<T>(*I);
     #endif
index 4f5b8f82392adb9aaa6a985cacbaac95affcd4d8..1136ff70c370fb85a40d07071382ee4f7517fdb6 100644 (file)
@@ -24,7 +24,7 @@
 /// does not imply the existence of any other C++ library features.
 #if (__has_feature(cxx_rvalue_references)   \
      || defined(__GXX_EXPERIMENTAL_CXX0X__) \
-     || _MSC_VER >= 1600)
+     || (defined(_MSC_VER) && _MSC_VER >= 1600))
 #define LLVM_USE_RVALUE_REFERENCES 1
 #else
 #define LLVM_USE_RVALUE_REFERENCES 0
index bffc234f93db423841589928128c8456f8e868d0..5d6020502dc68bc94ca90afdc17c41c3d7be7af3 100644 (file)
@@ -40,7 +40,7 @@
 #include <string>
 #include <vector>
 
-#if HAVE_SYS_STAT_H
+#ifdef HAVE_SYS_STAT_H
 #include <sys/stat.h>
 #endif
 
@@ -596,7 +596,7 @@ private:
   mapmode Mode;
   uint64_t Size;
   void *Mapping;
-#if LLVM_ON_WIN32
+#ifdef LLVM_ON_WIN32
   int FileDescriptor;
   void *FileHandle;
   void *FileMappingHandle;