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();
135class StreamingDiagnostic;
152template <class PtrTy, bool Compress = IsResultPtrLowBitFree<PtrTy>::value>
155 bool Invalid =
false;
167 bool isUnset()
const {
return !Invalid && !Val; }
170 PtrTy
get()
const {
return Val; }
171 template <
typename T>
T *
getAs() {
return static_cast<T *
>(
get()); }
182 static constexpr uintptr_t UnsetValue = 0x0;
183 static constexpr uintptr_t InvalidValue = 0x1;
191 :
Value(Invalid ? InvalidValue : UnsetValue) {}
204 void *VP =
reinterpret_cast<void *
>(
Value & ~0x01);
205 return PtrTraits::getFromVoidPointer(VP);
207 template <
typename T>
T *
getAs() {
return static_cast<T *
>(
get()); }
210 void *VP = PtrTraits::getAsVoidPointer(RHS);
212 assert((
Value & 0x01) == 0 &&
"Badly aligned pointer");
221 assert(
Result.isInvalid() ||
222 PtrTraits::getAsVoidPointer(
Result.get()) ==
P);
236 static const bool value =
true;
239 static const bool value =
true;
242 static const bool value =
true;
245 static const bool value =
true;
275 assert(!R.
isInvalid() &&
"operation was asserted to never fail!");
280 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
ActionResult & operator=(PtrTy RHS)
ActionResult(volatile void *)=delete
ActionResult(const DiagnosticBuilder &)
The result of parsing/analyzing an expression, statement etc.
ActionResult(const void *)=delete
ActionResult & operator=(PtrTy RHS)
ActionResult(volatile void *)=delete
ActionResult(bool Invalid=false)
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 ...
The JSON file list parser is used to communicate input to InstallAPI.
Expr * AssertSuccess(ExprResult R)
@ Result
The result type of a method or function.
ActionResult< Expr * > ExprResult
ActionResult< Stmt * > StmtResult
ActionResult< ParsedType > TypeResult
const FunctionProtoType * T
Diagnostic wrappers for TextAPI types for error reporting.
__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)