Reinstate r133513 (reverted in r133700) with an additional fix for a
[oota-llvm.git] / include / llvm / Support / Compiler.h
index 6682c84a7ade9060a3ef9ac6b21852e4b84f6f23..e0921572182bde9d17c3907990db725995540852 100644 (file)
 #ifndef LLVM_SUPPORT_COMPILER_H
 #define LLVM_SUPPORT_COMPILER_H
 
+#ifndef __has_feature
+# define __has_feature(x) 0
+#endif
+
 /// LLVM_LIBRARY_VISIBILITY - If a class marked with this attribute is linked
 /// into a shared library, then the class should be private to the library and
 /// not accessible from outside it.  Can also be used to mark variables and
 #define LLVM_ATTRIBUTE_NORETURN
 #endif
 
-// We provide definitions without the LLVM_ prefix briefly while transitioning
-// to always-prefixed names. These will go away as soon as the migration is
-// complete.
-#define ATTRIBUTE_USED LLVM_ATTRIBUTE_USED
-#define ATTRIBUTE_UNUSED LLVM_ATTRIBUTE_UNUSED
-#define ATTRIBUTE_READNONE LLVM_ATTRIBUTE_READNONE
-#define ATTRIBUTE_READONLY LLVM_ATTRIBUTE_READONLY
-#define NORETURN LLVM_ATTRIBUTE_NORETURN
-#define DISABLE_INLINE LLVM_ATTRIBUTE_NOINLINE
-#define ALWAYS_INLINE LLVM_ATTRIBUTE_ALWAYS_INLINE
+// LLVM_ATTRIBUTE_DEPRECATED(decl, "message")
+#if __has_feature(attribute_deprecated_with_message)
+# define LLVM_ATTRIBUTE_DEPRECATED(decl, message) \
+  decl __attribute__((deprecated(message)))
+#elif defined(__GNUC__)
+# define LLVM_ATTRIBUTE_DEPRECATED(decl, message) \
+  decl __attribute__((deprecated))
+#elif defined(_MSC_VER)
+# define LLVM_ATTRIBUTE_DEPRECATED(decl, message) \
+  __declspec(deprecated(message)) decl
+#else
+# define LLVM_ATTRIBUTE_DEPRECATED(decl, message) \
+  decl
+#endif
+
+// LLVM_BUILTIN_UNREACHABLE - On compilers which support it, expands
+// to an expression which states that it is undefined behavior for the
+// compiler to reach this point.  Otherwise is not defined.
+#if defined(__clang__) || (__GNUC__ > 4) \
+ || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
+# define LLVM_BUILTIN_UNREACHABLE __builtin_unreachable()
+#endif
 
 #endif