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"
31class CXXBaseSpecifier;
32class CXXCtorInitializer;
35class ParsedTemplateArgument;
39class 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();
136class 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!");
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
static ActionResult getFromOpaquePointer(void *P)
void * getAsOpaquePointer() const
ActionResult(bool Invalid=false)
ActionResult(const void *)=delete
const ActionResult & operator=(PtrTy RHS)
ActionResult(volatile void *)=delete
ActionResult(const DiagnosticBuilder &)
ActionResult - This structure is used while parsing/acting on expressions, stmts, etc.
ActionResult(const void *)=delete
ActionResult(bool Invalid=false)
const ActionResult & operator=(PtrTy RHS)
ActionResult(volatile void *)=delete
ActionResult(const DiagnosticBuilder &)
Represents a base class of a C++ class.
Represents a C++ base or member initializer.
A little helper class used to produce diagnostics.
This represents one expression.
Wrapper for void* pointer.
PointeeT * getPtrTo() const
Returns plain pointer to the entity pointed by this wrapper.
OpaquePtr(std::nullptr_t=nullptr)
PtrT getPtrAs() const
Returns pointer converted to the specified type.
void * getAsOpaquePtr() const
static OpaquePtr getFromOpaquePtr(void *P)
static OpaquePtr make(PtrTy P)
Stmt - This represents one statement.
The streaming interface shared between DiagnosticBuilder and PartialDiagnostic.
@ Decl
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
Expr * AssertSuccess(ExprResult R)
@ Result
The result type of a method or function.
ActionResult< Expr * > ExprResult
ActionResult< Stmt * > StmtResult
ActionResult< ParsedType > TypeResult
YAML serialization mapping.
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
UnionOpaquePtr - A version of OpaquePtr suitable for membership in a union.
OpaquePtr< T > get() const
static UnionOpaquePtr make(OpaquePtr< T > P)
UnionOpaquePtr & operator=(OpaquePtr< T > P)
static clang::OpaquePtr< T > getFromVoidPointer(void *P)
static void * getAsVoidPointer(clang::OpaquePtr< T > P)