Files
swift-mirror/include/swift/SIL/SILAllocated.h
Saleem Abdulrasool 01d5652999 remove VS2015 workaround (NFC)
VS2015 had an issue with the deletion of an operator.  Since VS2017 is
the minimum version that LLVM uses, we can assume that VS2017+ is in use
(_MSC_VER >= 1910).  Clean up the now defunct workaround.
2019-12-23 11:55:10 -08:00

50 lines
1.6 KiB
C++

//===--- SILAllocated.h - Defines the SILAllocated class --------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
#ifndef SWIFT_SIL_SILALLOCATED_H
#define SWIFT_SIL_SILALLOCATED_H
#include "swift/Basic/LLVM.h"
#include "swift/Basic/Compiler.h"
#include "llvm/Support/ErrorHandling.h"
#include <stddef.h>
namespace swift {
class SILModule;
/// SILAllocated - This class enforces that derived classes are allocated out of
/// the SILModule bump pointer allocator.
template <typename DERIVED>
class SILAllocated {
public:
/// Disable non-placement new.
void *operator new(size_t) = delete;
void *operator new[](size_t) = delete;
/// Disable non-placement delete.
void operator delete(void *) = delete;
void operator delete[](void *) = delete;
/// Custom version of 'new' that uses the SILModule's BumpPtrAllocator with
/// precise alignment knowledge. This is templated on the allocator type so
/// that this doesn't require including SILModule.h.
template <typename ContextTy>
void *operator new(size_t Bytes, const ContextTy &C,
size_t Alignment = alignof(DERIVED)) {
return C.allocate(Bytes, Alignment);
}
};
} // end swift namespace
#endif