]> granicus.if.org Git - llvm/commitdiff
Mark BumpPtrAllocator::Allocate as returning a noalias pointer.
authorBenjamin Kramer <benny.kra@googlemail.com>
Sun, 5 Apr 2015 17:02:25 +0000 (17:02 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Sun, 5 Apr 2015 17:02:25 +0000 (17:02 +0000)
The GCC attribute is curiously named 'malloc', but I think it's better
to use LLVM terminology for the wrapper macro.

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

include/llvm/Support/Allocator.h
include/llvm/Support/Compiler.h

index de317719714da0196261b5173b83a501687792d6..94cf3e85f3667f9054c69089fb575b2737b1661a 100644 (file)
@@ -203,7 +203,8 @@ public:
   }
 
   /// \brief Allocate space at the specified alignment.
-  LLVM_ATTRIBUTE_RETURNS_NONNULL void *Allocate(size_t Size, size_t Alignment) {
+  LLVM_ATTRIBUTE_RETURNS_NONNULL LLVM_ATTRIBUTE_RETURNS_NOALIAS void *
+  Allocate(size_t Size, size_t Alignment) {
     assert(Alignment > 0 && "0-byte alignnment is not allowed. Use 1 instead.");
 
     // Keep track of how many bytes we've allocated.
index 8534316600a166ae42ddf23d044f5f6d59968bbb..4684af5f34d2c69c4d8d8490d9999c1f64029f9e 100644 (file)
 #define LLVM_ATTRIBUTE_RETURNS_NONNULL
 #endif
 
+/// \macro LLVM_ATTRIBUTE_RETURNS_NOALIAS Used to mark a function as returning a
+/// pointer that does not alias any other valid pointer.
+#ifdef __GNUC__
+#define LLVM_ATTRIBUTE_RETURNS_NOALIAS __attribute__((__malloc__))
+#elif defined(_MSC_VER)
+#define LLVM_ATTRIBUTE_RETURNS_NOALIAS __declspec(restrict)
+#else
+#define LLVM_ATTRIBUTE_RETURNS_NOALIAS
+#endif
+
 /// LLVM_EXTENSION - Support compilers where we have a keyword to suppress
 /// pedantic diagnostics.
 #ifdef __GNUC__