blob: 47ec7ad5547997d3ac92335a1372abf32ab2a64d [file] [log] [blame]
//===--- SyntaxArena.h - Syntax Tree Memory Allocation ----------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2018 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
//
//===----------------------------------------------------------------------===//
//
// This file defines SyntaxArena that is Memory manager for Syntax nodes.
//
//===----------------------------------------------------------------------===//
#ifndef SWIFT_SYNTAX_SYNTAXARENA_H
#define SWIFT_SYNTAX_SYNTAXARENA_H
#include "llvm/ADT/IntrusiveRefCntPtr.h"
#include "llvm/Support/Allocator.h"
namespace swift {
namespace syntax {
/// Memory manager for Syntax nodes.
class SyntaxArena : public llvm::ThreadSafeRefCountedBase<SyntaxArena> {
SyntaxArena(const SyntaxArena &) = delete;
void operator=(const SyntaxArena &) = delete;
llvm::BumpPtrAllocator Allocator;
public:
SyntaxArena() {}
llvm::BumpPtrAllocator &getAllocator() { return Allocator; }
void *Allocate(size_t size, size_t alignment) {
return Allocator.Allocate(size, alignment);
}
};
} // namespace syntax
} // namespace swift
#endif