[llvm-commits] [llvm] r161975 - /llvm/trunk/include/llvm/Support/Compiler.h

Michael J. Spencer bigcheesegs at gmail.com
Wed Aug 15 11:54:36 PDT 2012


Author: mspencer
Date: Wed Aug 15 13:54:36 2012
New Revision: 161975

URL: http://llvm.org/viewvc/llvm-project?rev=161975&view=rev
Log:
Add LLVM_DELETED_FUNCTION compatibility macro.

This should replace uses of:

class A {
  A(const &A); // DO NOT IMPLEMENT
public:
  ...
};

Modified:
    llvm/trunk/include/llvm/Support/Compiler.h

Modified: llvm/trunk/include/llvm/Support/Compiler.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Compiler.h?rev=161975&r1=161974&r2=161975&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/Compiler.h (original)
+++ llvm/trunk/include/llvm/Support/Compiler.h Wed Aug 15 13:54:36 2012
@@ -38,6 +38,25 @@
 #define llvm_move(value) (value)
 #endif
 
+/// LLVM_DELETED_FUNCTION - Expands to = delete if the compiler supports it.
+/// Use to mark functions as uncallable. Member functions with this should
+/// be declared private so that some behaivor is kept in C++03 mode.
+///
+/// class DontCopy {
+/// private:
+///   DontCopy(const DontCopy&) LLVM_DELETED_FUNCTION;
+///   DontCopy &operator =(const DontCopy&) LLVM_DELETED_FUNCTION;
+/// public:
+///   ...
+/// };
+#if (__has_feature(cxx_deleted_functions) \
+     || defined(__GXX_EXPERIMENTAL_CXX0X__))
+     // No version of MSVC currently supports this.
+#define LLVM_DELETED_FUNCTION = delete
+#else
+#define LLVM_DELETED_FUNCTION
+#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





More information about the llvm-commits mailing list