Go to the documentation of this file.
13 #ifndef LLVM_CLANG_SEMA_OWNERSHIP_H
14 #define LLVM_CLANG_SEMA_OWNERSHIP_H
18 #include "llvm/ADT/ArrayRef.h"
19 #include "llvm/Support/PointerLikeTypeTraits.h"
20 #include "llvm/Support/type_traits.h"
31 class CXXBaseSpecifier;
32 class CXXCtorInitializer;
35 class ParsedTemplateArgument;
39 class TemplateParameterList;
49 template <
class PtrTy>
53 explicit OpaquePtr(
void *Ptr) : Ptr(Ptr) {}
66 template <
typename Po
inteeT> PointeeT*
getPtrTo()
const {
76 template <
typename PtrT> PtrT
getPtrAs()
const {
81 return Traits::getFromVoidPointer(Ptr);
85 Ptr = Traits::getAsVoidPointer(
P);
88 explicit operator bool()
const {
return Ptr !=
nullptr; }
108 Ptr =
P.getAsOpaquePtr();
119 static constexpr
int NumLowBitsAvailable = 0;
123 return P.getAsOpaquePtr();
136 class StreamingDiagnostic;
150 template<
class PtrTy,
167 bool isUnset()
const {
return !Invalid && !Val; }
169 PtrTy
get()
const {
return Val; }
170 template <
typename T> T *
getAs() {
return static_cast<T*
>(
get()); }
183 template<
typename PtrTy>
193 : PtrWithInvalid(static_cast<
uintptr_t>(Invalid)) {}
196 void *VP = PtrTraits::getAsVoidPointer(
V);
197 PtrWithInvalid =
reinterpret_cast<uintptr_t>(VP);
198 assert((PtrWithInvalid & 0x01) == 0 &&
"Badly aligned pointer");
207 bool isInvalid()
const {
return PtrWithInvalid & 0x01; }
208 bool isUsable()
const {
return PtrWithInvalid > 0x01; }
209 bool isUnset()
const {
return PtrWithInvalid == 0; }
212 void *VP =
reinterpret_cast<void *
>(PtrWithInvalid & ~0x01);
213 return PtrTraits::getFromVoidPointer(VP);
216 template <
typename T> T *
getAs() {
return static_cast<T*
>(
get()); }
219 void *VP = PtrTraits::getAsVoidPointer(
V);
220 PtrWithInvalid =
reinterpret_cast<uintptr_t>(VP);
221 assert((PtrWithInvalid & 0x01) == 0 &&
"Badly aligned pointer");
225 void *VP = PtrTraits::getAsVoidPointer(RHS);
226 PtrWithInvalid =
reinterpret_cast<uintptr_t>(VP);
227 assert((PtrWithInvalid & 0x01) == 0 &&
"Badly aligned pointer");
250 static const bool value =
true;
253 static const bool value =
true;
256 static const bool value =
true;
259 static const bool value =
true;
293 assert(!R.
isInvalid() &&
"operation was asserted to never fail!");
298 assert(!R.
isInvalid() &&
"operation was asserted to never fail!");
304 #endif // LLVM_CLANG_SEMA_OWNERSHIP_H
Expr * AssertSuccess(ExprResult R)
const ActionResult & operator=(PtrTy RHS)
YAML serialization mapping.
A little helper class used to produce diagnostics.
UnionOpaquePtr & operator=(OpaquePtr< T > P)
OpaquePtr< T > get() const
OpaquePtr(std::nullptr_t=nullptr)
@ Decl
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
ActionResult(const DiagnosticBuilder &)
void * getAsOpaquePointer() const
ActionResult< Expr * > ExprResult
The streaming interface shared between DiagnosticBuilder and PartialDiagnostic.
PointeeT * getPtrTo() const
Returns plain pointer to the entity pointed by this wrapper.
const ActionResult & operator=(PtrTy RHS)
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
ActionResult(bool Invalid=false)
ActionResult(bool Invalid=false)
Wrapper for void* pointer.
static ActionResult getFromOpaquePointer(void *P)
static void * getAsVoidPointer(clang::OpaquePtr< T > P)
static OpaquePtr make(PtrTy P)
ActionResult(const DiagnosticBuilder &)
ActionResult - This structure is used while parsing/acting on expressions, stmts, etc.
ActionResult< Stmt * > StmtResult
ActionResult< ParsedType > TypeResult
Stmt - This represents one statement.
Represents a base class of a C++ class.
PtrT getPtrAs() const
Returns pointer converted to the specified type.
void * getAsOpaquePtr() const
static UnionOpaquePtr make(OpaquePtr< T > P)
UnionOpaquePtr - A version of OpaquePtr suitable for membership in a union.
static clang::OpaquePtr< T > getFromVoidPointer(void *P)
This represents one expression.
static OpaquePtr getFromOpaquePtr(void *P)
Represents a C++ base or member initializer.