LLVM 20.0.0git
|
This header defines support for implementing classes that have some trailing object (or arrays of objects) appended to them. More...
#include "llvm/Support/AlignOf.h"
#include "llvm/Support/Alignment.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/type_traits.h"
#include <new>
#include <type_traits>
Go to the source code of this file.
Namespaces | |
namespace | llvm |
This is an optimization pass for GlobalISel generic memory operations. | |
namespace | llvm::trailing_objects_internal |
This header defines support for implementing classes that have some trailing object (or arrays of objects) appended to them.
The main purpose is to make it obvious where this idiom is being used, and to make the usage more idiomatic and more difficult to get wrong.
The TrailingObject template abstracts away the reinterpret_cast, pointer arithmetic, and size calculations used for the allocation and access of appended arrays of objects, and takes care that they are all allocated at their required alignment. Additionally, it ensures that the base type is final – deriving from a class that expects data appended immediately after it is typically not safe.
Users are expected to derive from this template, and provide numTrailingObjects implementations for each trailing type except the last, e.g. like this sample:
You can access the appended arrays via 'getTrailingObjects', and determine the size needed for allocation via 'additionalSizeToAlloc' and 'totalSizeToAlloc'.
All the methods implemented by this class are intended for use by the implementation of the class, not as part of its interface (thus, private inheritance is suggested).
Definition in file TrailingObjects.h.