Skip to content

Commit 269574f

Browse files
committed
[libclc] Fix CUDA build failure after 2e97236 Rename OutputStream to OutputBuffer
1 parent c9c12a2 commit 269574f

File tree

1 file changed

+94
-94
lines changed

1 file changed

+94
-94
lines changed

libclc/utils/libclc-remangler/LibclcRemangler.cpp

Lines changed: 94 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -158,15 +158,15 @@ class Remangler {
158158
SmallVector<std::string, 16> Subs;
159159
bool Failed = false;
160160

161-
OutputStream printNode(const Node *node) {
162-
OutputStream nodeOutStream;
163-
initializeOutputStream(nullptr, nullptr, nodeOutStream, 1024);
164-
node->print(nodeOutStream);
165-
return nodeOutStream;
161+
OutputBuffer printNode(const Node *node) {
162+
OutputBuffer nodeOutBuffer;
163+
initializeOutputBuffer(nullptr, nullptr, nodeOutBuffer, 1024);
164+
node->print(nodeOutBuffer);
165+
return nodeOutBuffer;
166166
}
167167

168168
void addSub(const Node *node) {
169-
OutputStream nodeOut = printNode(node);
169+
OutputBuffer nodeOut = printNode(node);
170170
char *nodeOutBuf = nodeOut.getBuffer();
171171
auto nodeOutStr =
172172
std::string(nodeOutBuf, nodeOutBuf + nodeOut.getCurrentPosition());
@@ -175,7 +175,7 @@ class Remangler {
175175
}
176176

177177
bool findSub(const Node *node, size_t *index) {
178-
OutputStream nodeOut = printNode(node);
178+
OutputBuffer nodeOut = printNode(node);
179179
char *nodeOutBuf = nodeOut.getBuffer();
180180
auto nodeOutStr =
181181
std::string(nodeOutBuf, nodeOutBuf + nodeOut.getCurrentPosition());
@@ -190,59 +190,59 @@ class Remangler {
190190
return false;
191191
}
192192

193-
bool remangleSub(const Node *node, OutputStream &S) {
193+
bool remangleSub(const Node *node, OutputBuffer &OB) {
194194
size_t index = 0;
195195
if (findSub(node, &index)) {
196-
S << 'S';
196+
OB << 'S';
197197
if (index != 0)
198-
S << index;
199-
S << '_';
198+
OB << index;
199+
OB << '_';
200200
return true;
201201
}
202202
return false;
203203
}
204204

205-
void remangleOpenCLCName(const Node *nameNode, OutputStream &S,
205+
void remangleOpenCLCName(const Node *nameNode, OutputBuffer &OB,
206206
bool Substitutable, bool isNameRoot = true) {
207-
if (Substitutable && remangleSub(nameNode, S))
207+
if (Substitutable && remangleSub(nameNode, OB))
208208
return;
209209
switch (nameNode->getKind()) {
210210
case Node::Kind::KNameType: {
211211
const NameType *name = static_cast<const NameType *>(nameNode);
212-
S << name->getName().size();
213-
S << name->getName();
212+
OB << name->getName().size();
213+
OB << name->getName();
214214
break;
215215
}
216216
case Node::Kind::KNestedName: {
217217
if (isNameRoot)
218-
S << 'N';
218+
OB << 'N';
219219
const NestedName *nestedName = static_cast<const NestedName *>(nameNode);
220-
remangleOpenCLCName(nestedName->Qual, S, Substitutable,
220+
remangleOpenCLCName(nestedName->Qual, OB, Substitutable,
221221
/* isNameRoot= */ false);
222-
remangleOpenCLCName(nestedName->Name, S, /* Substitutable= */ false,
222+
remangleOpenCLCName(nestedName->Name, OB, /* Substitutable= */ false,
223223
/* isNameRoot= */ false);
224224
if (isNameRoot)
225-
S << 'E';
225+
OB << 'E';
226226
break;
227227
}
228228
case Node::Kind::KNameWithTemplateArgs: {
229229
const NameWithTemplateArgs *templateName =
230230
static_cast<const NameWithTemplateArgs *>(nameNode);
231231
assert(templateName->TemplateArgs->getKind() ==
232232
Node::Kind::KTemplateArgs);
233-
remangleOpenCLCName(templateName->Name, S, /* Substitutable= */ false,
233+
remangleOpenCLCName(templateName->Name, OB, /* Substitutable= */ false,
234234
/* isNameRoot= */ false);
235-
S << 'I';
235+
OB << 'I';
236236
const TemplateArgs *templateArgs =
237237
static_cast<const TemplateArgs *>(templateName->TemplateArgs);
238238
for (auto templateArgType : templateArgs->getParams())
239-
remangleOpenCLCType(templateArgType, S);
240-
S << 'E';
239+
remangleOpenCLCType(templateArgType, OB);
240+
OB << 'E';
241241
break;
242242
}
243243
default: {
244-
OutputStream errorTypeOut;
245-
initializeOutputStream(nullptr, nullptr, errorTypeOut, 1024);
244+
OutputBuffer errorTypeOut;
245+
initializeOutputBuffer(nullptr, nullptr, errorTypeOut, 1024);
246246
errorTypeOut << "Unhandled name : ";
247247
nameNode->print(errorTypeOut);
248248
errorTypeOut << "\n";
@@ -255,165 +255,165 @@ class Remangler {
255255
addSub(nameNode);
256256
}
257257

258-
void remangleOpenCLCTypeName(const NameType *typeName, OutputStream &S) {
258+
void remangleOpenCLCTypeName(const NameType *typeName, OutputBuffer &OB) {
259259
StringView name = typeName->getName();
260260

261261
auto it = TypeReplacements.find(name.begin());
262262
if (it != TypeReplacements.end())
263263
name = StringView(it->second);
264264

265265
if (name == "void")
266-
S << 'v';
266+
OB << 'v';
267267
else if (name == "wchar_t")
268-
S << 'w';
268+
OB << 'w';
269269
else if (name == "bool")
270-
S << 'b';
270+
OB << 'b';
271271
else if (name == "char")
272-
S << 'c';
272+
OB << 'c';
273273
else if (name == "signed char")
274-
S << 'a';
274+
OB << 'a';
275275
else if (name == "unsigned char")
276-
S << 'h';
276+
OB << 'h';
277277
else if (name == "short")
278-
S << 's';
278+
OB << 's';
279279
else if (name == "unsigned short")
280-
S << 't';
280+
OB << 't';
281281
else if (name == "int")
282-
S << 'i';
282+
OB << 'i';
283283
else if (name == "unsigned int")
284-
S << 'j';
284+
OB << 'j';
285285
else if (name == "long")
286-
S << 'l';
286+
OB << 'l';
287287
else if (name == "unsigned long")
288-
S << 'm';
288+
OB << 'm';
289289
else if (name == "long long")
290-
S << 'x';
290+
OB << 'x';
291291
else if (name == "unsigned long long")
292-
S << 'y';
292+
OB << 'y';
293293
else if (name == "__int128")
294-
S << 'n';
294+
OB << 'n';
295295
else if (name == "unsigned __int128")
296-
S << 'o';
296+
OB << 'o';
297297
else if (name == "float")
298-
S << 'f';
298+
OB << 'f';
299299
else if (name == "double")
300-
S << 'd';
300+
OB << 'd';
301301
else if (name == "long double")
302-
S << 'e';
302+
OB << 'e';
303303
else if (name == "__float128")
304-
S << 'g';
304+
OB << 'g';
305305
else if (name == "...")
306-
S << 'z';
306+
OB << 'z';
307307
// TODO: u
308308
else if (name == "decimal64")
309-
S << "Dd";
309+
OB << "Dd";
310310
else if (name == "decimal128")
311-
S << "De";
311+
OB << "De";
312312
else if (name == "decimal32")
313-
S << "Df";
313+
OB << "Df";
314314
else if (name == "decimal16")
315-
S << "Dh";
315+
OB << "Dh";
316316
else if (name == "char32_t")
317-
S << "Di";
317+
OB << "Di";
318318
else if (name == "char16_t")
319-
S << "Ds";
319+
OB << "Ds";
320320
else if (name == "char8_t")
321-
S << "Du";
321+
OB << "Du";
322322
else if (name == "_Float16")
323-
S << "DF16_";
323+
OB << "DF16_";
324324
else if (name == "auto")
325-
S << 'a';
325+
OB << 'a';
326326
else if (name == "decltype(auto)")
327-
S << 'c';
327+
OB << 'c';
328328
else if (name == "std::nullptr_t")
329-
S << 'n';
329+
OB << 'n';
330330
// Enum
331331
else
332-
remangleOpenCLCName(typeName, S, /* Substitutable= */ true);
332+
remangleOpenCLCName(typeName, OB, /* Substitutable= */ true);
333333
}
334334

335335
void remangleOpenCLCQualifiers(const itanium_demangle::Qualifiers quals,
336-
OutputStream &S) {
336+
OutputBuffer &OB) {
337337
if (quals & QualConst)
338-
S << "K";
338+
OB << "K";
339339
if (quals & QualVolatile)
340-
S << "V";
340+
OB << "V";
341341
if (quals & QualRestrict)
342-
S << "r";
342+
OB << "r";
343343
}
344344

345-
void remangleOpenCLCType(const Node *typeNode, OutputStream &S) {
345+
void remangleOpenCLCType(const Node *typeNode, OutputBuffer &OB) {
346346
switch (typeNode->getKind()) {
347347
case Node::Kind::KPointerType: {
348348
const itanium_demangle::PointerType *ptype =
349349
static_cast<const itanium_demangle::PointerType *>(typeNode);
350-
S << 'P';
351-
remangleOpenCLCType(ptype->getPointee(), S);
350+
OB << 'P';
351+
remangleOpenCLCType(ptype->getPointee(), OB);
352352
break;
353353
}
354354
case Node::Kind::KVectorType: {
355-
if (remangleSub(typeNode, S))
355+
if (remangleSub(typeNode, OB))
356356
return;
357357

358358
const itanium_demangle::VectorType *vecType =
359359
static_cast<const itanium_demangle::VectorType *>(typeNode);
360360
assert(vecType->getDimension()->getKind() == Node::Kind::KNameType);
361361
const NameType *dims =
362362
static_cast<const NameType *>(vecType->getDimension());
363-
S << "Dv";
364-
S << dims->getName();
365-
S << '_';
366-
remangleOpenCLCType(vecType->getBaseType(), S);
363+
OB << "Dv";
364+
OB << dims->getName();
365+
OB << '_';
366+
remangleOpenCLCType(vecType->getBaseType(), OB);
367367
addSub(typeNode);
368368
break;
369369
}
370370
case Node::Kind::KBinaryFPType: {
371-
if (remangleSub(typeNode, S))
371+
if (remangleSub(typeNode, OB))
372372
return;
373373

374374
const BinaryFPType *BFPType = static_cast<const BinaryFPType *>(typeNode);
375375
assert(BFPType->getDimension()->getKind() == Node::Kind::KNameType);
376376
const NameType *dims =
377377
static_cast<const NameType *>(BFPType->getDimension());
378378

379-
S << "DF";
380-
S << dims->getName();
381-
S << '_';
379+
OB << "DF";
380+
OB << dims->getName();
381+
OB << '_';
382382
break;
383383
}
384384
case Node::Kind::KVendorExtQualType: {
385-
if (remangleSub(typeNode, S))
385+
if (remangleSub(typeNode, OB))
386386
return;
387387

388388
const VendorExtQualType *extQualType =
389389
static_cast<const VendorExtQualType *>(typeNode);
390-
S << 'U';
391-
S << extQualType->getExt().size();
392-
S << extQualType->getExt();
393-
remangleOpenCLCType(extQualType->getTy(), S);
390+
OB << 'U';
391+
OB << extQualType->getExt().size();
392+
OB << extQualType->getExt();
393+
remangleOpenCLCType(extQualType->getTy(), OB);
394394
addSub(typeNode);
395395
break;
396396
}
397397
case Node::Kind::KQualType: {
398398
const itanium_demangle::QualType *qtype =
399399
static_cast<const itanium_demangle::QualType *>(typeNode);
400-
remangleOpenCLCQualifiers(qtype->getQuals(), S);
401-
remangleOpenCLCType(qtype->getChild(), S);
400+
remangleOpenCLCQualifiers(qtype->getQuals(), OB);
401+
remangleOpenCLCType(qtype->getChild(), OB);
402402
break;
403403
}
404404
case Node::Kind::KNameType: {
405405
const NameType *typeName = static_cast<const NameType *>(typeNode);
406-
remangleOpenCLCTypeName(typeName, S);
406+
remangleOpenCLCTypeName(typeName, OB);
407407
break;
408408
}
409409
case Node::Kind::KNestedName: {
410410
// Enum type with nested name
411-
remangleOpenCLCName(typeNode, S, /* Substitutable= */ true);
411+
remangleOpenCLCName(typeNode, OB, /* Substitutable= */ true);
412412
break;
413413
}
414414
default: {
415-
OutputStream errorTypeOut;
416-
initializeOutputStream(nullptr, nullptr, errorTypeOut, 1024);
415+
OutputBuffer errorTypeOut;
416+
initializeOutputBuffer(nullptr, nullptr, errorTypeOut, 1024);
417417
errorTypeOut << "Unhandled type : ";
418418
typeNode->print(errorTypeOut);
419419
errorTypeOut << "\n";
@@ -424,23 +424,23 @@ class Remangler {
424424
}
425425
}
426426

427-
void remangleOpenCLCFunction(const Node *root, OutputStream &S) {
427+
void remangleOpenCLCFunction(const Node *root, OutputBuffer &OB) {
428428
assert(root->getKind() == Node::Kind::KFunctionEncoding);
429-
S << "_Z";
429+
OB << "_Z";
430430

431431
const FunctionEncoding *encoding =
432432
static_cast<const FunctionEncoding *>(root);
433433

434-
remangleOpenCLCName(encoding->getName(), S, /* Substitutable= */ false);
434+
remangleOpenCLCName(encoding->getName(), OB, /* Substitutable= */ false);
435435

436436
if (encoding->getReturnType())
437-
remangleOpenCLCType(encoding->getReturnType(), S);
437+
remangleOpenCLCType(encoding->getReturnType(), OB);
438438

439439
for (const Node *paramType : encoding->getParams())
440-
remangleOpenCLCType(paramType, S);
440+
remangleOpenCLCType(paramType, OB);
441441

442442
if (encoding->getParams().size() == 0)
443-
S << 'v';
443+
OB << 'v';
444444
}
445445

446446
public:
@@ -452,8 +452,8 @@ class Remangler {
452452

453453
std::string remangle() {
454454
Subs.clear();
455-
OutputStream remanglingStream;
456-
initializeOutputStream(nullptr, nullptr, remanglingStream, 1024);
455+
OutputBuffer remanglingStream;
456+
initializeOutputBuffer(nullptr, nullptr, remanglingStream, 1024);
457457
remangleOpenCLCFunction(Root, remanglingStream);
458458
std::string remangled = std::string(remanglingStream.getBuffer(),
459459
remanglingStream.getCurrentPosition());

0 commit comments

Comments
 (0)