17 using namespace clang;
26 TypeLocs.push_back(CurTL);
30 for (
unsigned i = 0, e = TypeLocs.size(); i < e; ++i) {
31 TypeLoc CurTL = TypeLocs[e-i-1];
33 #define ABSTRACT_TYPELOC(CLASS, PARENT)
34 #define TYPELOC(CLASS, PARENT) \
35 case TypeLoc::CLASS: { \
36 CLASS##TypeLoc NewTL = push<class CLASS##TypeLoc>(CurTL.getType()); \
37 memcpy(NewTL.getOpaqueData(), CurTL.getOpaqueData(), NewTL.getLocalDataSize()); \
40 #include "clang/AST/TypeLocNodes.def"
45 void TypeLocBuilder::grow(
size_t NewCapacity) {
46 assert(NewCapacity > Capacity);
49 char *NewBuffer =
new char[NewCapacity];
50 unsigned NewIndex = Index + NewCapacity - Capacity;
51 memcpy(&NewBuffer[NewIndex],
55 if (Buffer != InlineBuffer.buffer)
59 Capacity = NewCapacity;
63 TypeLoc TypeLocBuilder::pushImpl(
QualType T,
size_t LocalSize,
unsigned LocalAlignment) {
66 assert(TLast == LastTy &&
67 "mismatch between last type and new type's inner type");
71 assert(LocalAlignment <= BufferMaxAlignment &&
"Unexpected alignment");
74 if (LocalSize > Index) {
75 size_t RequiredCapacity = Capacity + (LocalSize - Index);
76 size_t NewCapacity = Capacity * 2;
77 while (RequiredCapacity > NewCapacity)
88 if (LocalAlignment == 4) {
89 if (NumBytesAtAlign8 == 0) {
90 NumBytesAtAlign4 += LocalSize;
92 unsigned Padding = NumBytesAtAlign4 % 8;
94 if (LocalSize % 8 == 0) {
98 assert(LocalSize % 8 == 4);
100 memmove(&Buffer[Index - 4], &Buffer[Index], NumBytesAtAlign4);
104 assert(Padding == 4);
105 if (LocalSize % 8 == 0) {
109 assert(LocalSize % 8 == 4);
111 memmove(&Buffer[Index + 4], &Buffer[Index], NumBytesAtAlign4);
115 NumBytesAtAlign4 += LocalSize;
117 }
else if (LocalAlignment == 8) {
118 if (NumBytesAtAlign8 == 0) {
121 if ((Index - LocalSize) % 8 != 0) {
122 memmove(&Buffer[Index - 4], &Buffer[Index], NumBytesAtAlign4);
126 unsigned Padding = NumBytesAtAlign4 % 8;
128 if (LocalSize % 8 == 0) {
132 assert(LocalSize % 8 == 4);
134 memmove(&Buffer[Index - 4], &Buffer[Index], NumBytesAtAlign4);
138 assert(Padding == 4);
139 if (LocalSize % 8 == 0) {
143 assert(LocalSize % 8 == 4);
145 memmove(&Buffer[Index + 4], &Buffer[Index], NumBytesAtAlign4);
152 NumBytesAtAlign4 = 0;
153 NumBytesAtAlign8 += LocalSize;
155 assert(LocalSize == 0);
161 "incorrect data size provided to CreateTypeSourceInfo!");
163 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.
Base wrapper for a particular "section" of type source info.
TypeLoc getNextTypeLoc() const
Get the next TypeLoc pointed by this TypeLoc, e.g for "int*" the TypeLoc is a PointerLoc and next Typ...
QualType getType() const
Get the type for which this source info wrapper provides information.
void reserve(size_t Requested)
Ensures that this buffer has at least as much capacity as described.
TypeLocClass getTypeLocClass() const
unsigned getFullDataSize() const
Returns the size of the type source info data block.
void pushFullCopy(TypeLoc L)
Pushes a copy of the given TypeLoc onto this builder.