16 using namespace clang;
25 TypeLocs.push_back(CurTL);
29 for (
unsigned i = 0, e = TypeLocs.size(); i < e; ++i) {
30 TypeLoc CurTL = TypeLocs[e-i-1];
32 #define ABSTRACT_TYPELOC(CLASS, PARENT) 33 #define TYPELOC(CLASS, PARENT) \ 34 case TypeLoc::CLASS: { \ 35 CLASS##TypeLoc NewTL = push<class CLASS##TypeLoc>(CurTL.getType()); \ 36 memcpy(NewTL.getOpaqueData(), CurTL.getOpaqueData(), NewTL.getLocalDataSize()); \ 39 #include "clang/AST/TypeLocNodes.def" 44 void TypeLocBuilder::grow(
size_t NewCapacity) {
45 assert(NewCapacity > Capacity);
48 char *NewBuffer =
new char[NewCapacity];
49 unsigned NewIndex = Index + NewCapacity - Capacity;
50 memcpy(&NewBuffer[NewIndex],
54 if (Buffer != InlineBuffer)
58 Capacity = NewCapacity;
62 TypeLoc TypeLocBuilder::pushImpl(
QualType T,
size_t LocalSize,
unsigned LocalAlignment) {
65 assert(TLast == LastTy &&
66 "mismatch between last type and new type's inner type");
70 assert(LocalAlignment <= BufferMaxAlignment &&
"Unexpected alignment");
73 if (LocalSize > Index) {
74 size_t RequiredCapacity = Capacity + (LocalSize - Index);
75 size_t NewCapacity = Capacity * 2;
76 while (RequiredCapacity > NewCapacity)
87 if (LocalAlignment == 4) {
88 if (NumBytesAtAlign8 == 0) {
89 NumBytesAtAlign4 += LocalSize;
91 unsigned Padding = NumBytesAtAlign4 % 8;
93 if (LocalSize % 8 == 0) {
97 assert(LocalSize % 8 == 4);
99 memmove(&Buffer[Index - 4], &Buffer[Index], NumBytesAtAlign4);
103 assert(Padding == 4);
104 if (LocalSize % 8 == 0) {
108 assert(LocalSize % 8 == 4);
110 memmove(&Buffer[Index + 4], &Buffer[Index], NumBytesAtAlign4);
114 NumBytesAtAlign4 += LocalSize;
116 }
else if (LocalAlignment == 8) {
117 if (NumBytesAtAlign8 == 0) {
120 if ((Index - LocalSize) % 8 != 0) {
121 memmove(&Buffer[Index - 4], &Buffer[Index], NumBytesAtAlign4);
125 unsigned Padding = NumBytesAtAlign4 % 8;
127 if (LocalSize % 8 == 0) {
131 assert(LocalSize % 8 == 4);
133 memmove(&Buffer[Index - 4], &Buffer[Index], NumBytesAtAlign4);
137 assert(Padding == 4);
138 if (LocalSize % 8 == 0) {
142 assert(LocalSize % 8 == 4);
144 memmove(&Buffer[Index + 4], &Buffer[Index], NumBytesAtAlign4);
151 NumBytesAtAlign4 = 0;
152 NumBytesAtAlign8 += LocalSize;
154 assert(LocalSize == 0);
160 "incorrect data size provided to CreateTypeSourceInfo!");
162 return getTemporaryTypeLoc(T);
static unsigned getFullDataSizeForType(QualType Ty)
Returns the size of type source info data block for the given type.
A (possibly-)qualified type.
TypeLoc getNextTypeLoc() const
Get the next TypeLoc pointed by this TypeLoc, e.g for "int*" the TypeLoc is a PointerLoc and next Typ...
Base wrapper for a particular "section" of type source info.
void reserve(size_t Requested)
Ensures that this buffer has at least as much capacity as described.
__DEVICE__ void * memcpy(void *__a, const void *__b, size_t __c)
unsigned getFullDataSize() const
Returns the size of the type source info data block.
Dataflow Directional Tag Classes.
QualType getType() const
Get the type for which this source info wrapper provides information.
TypeLocClass getTypeLocClass() const
void pushFullCopy(TypeLoc L)
Pushes a copy of the given TypeLoc onto this builder.