[yaml2obj/obj2yaml] - Add support for .stack_sizes sections.
[llvm-complete.git] / lib / Demangle / MicrosoftDemangleNodes.cpp
blob10363dc69cda437c19187b339ffa5768574b6408
1 //===- MicrosoftDemangle.cpp ----------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file defines a demangler for MSVC-style mangled symbols.
11 //===----------------------------------------------------------------------===//
13 #include "llvm/Demangle/MicrosoftDemangleNodes.h"
14 #include "llvm/Demangle/DemangleConfig.h"
15 #include "llvm/Demangle/Utility.h"
16 #include <cctype>
17 #include <string>
19 using namespace llvm;
20 using namespace ms_demangle;
22 #define OUTPUT_ENUM_CLASS_VALUE(Enum, Value, Desc) \
23 case Enum::Value: \
24 OS << Desc; \
25 break;
27 // Writes a space if the last token does not end with a punctuation.
28 static void outputSpaceIfNecessary(OutputStream &OS) {
29 if (OS.empty())
30 return;
32 char C = OS.back();
33 if (std::isalnum(C) || C == '>')
34 OS << " ";
37 static void outputSingleQualifier(OutputStream &OS, Qualifiers Q) {
38 switch (Q) {
39 case Q_Const:
40 OS << "const";
41 break;
42 case Q_Volatile:
43 OS << "volatile";
44 break;
45 case Q_Restrict:
46 OS << "__restrict";
47 break;
48 default:
49 break;
53 static bool outputQualifierIfPresent(OutputStream &OS, Qualifiers Q,
54 Qualifiers Mask, bool NeedSpace) {
55 if (!(Q & Mask))
56 return NeedSpace;
58 if (NeedSpace)
59 OS << " ";
61 outputSingleQualifier(OS, Mask);
62 return true;
65 static void outputQualifiers(OutputStream &OS, Qualifiers Q, bool SpaceBefore,
66 bool SpaceAfter) {
67 if (Q == Q_None)
68 return;
70 size_t Pos1 = OS.getCurrentPosition();
71 SpaceBefore = outputQualifierIfPresent(OS, Q, Q_Const, SpaceBefore);
72 SpaceBefore = outputQualifierIfPresent(OS, Q, Q_Volatile, SpaceBefore);
73 SpaceBefore = outputQualifierIfPresent(OS, Q, Q_Restrict, SpaceBefore);
74 size_t Pos2 = OS.getCurrentPosition();
75 if (SpaceAfter && Pos2 > Pos1)
76 OS << " ";
79 static void outputCallingConvention(OutputStream &OS, CallingConv CC) {
80 outputSpaceIfNecessary(OS);
82 switch (CC) {
83 case CallingConv::Cdecl:
84 OS << "__cdecl";
85 break;
86 case CallingConv::Fastcall:
87 OS << "__fastcall";
88 break;
89 case CallingConv::Pascal:
90 OS << "__pascal";
91 break;
92 case CallingConv::Regcall:
93 OS << "__regcall";
94 break;
95 case CallingConv::Stdcall:
96 OS << "__stdcall";
97 break;
98 case CallingConv::Thiscall:
99 OS << "__thiscall";
100 break;
101 case CallingConv::Eabi:
102 OS << "__eabi";
103 break;
104 case CallingConv::Vectorcall:
105 OS << "__vectorcall";
106 break;
107 case CallingConv::Clrcall:
108 OS << "__clrcall";
109 break;
110 default:
111 break;
115 std::string Node::toString(OutputFlags Flags) const {
116 OutputStream OS;
117 initializeOutputStream(nullptr, nullptr, OS, 1024);
118 this->output(OS, Flags);
119 OS << '\0';
120 return {OS.getBuffer()};
123 void PrimitiveTypeNode::outputPre(OutputStream &OS, OutputFlags Flags) const {
124 switch (PrimKind) {
125 OUTPUT_ENUM_CLASS_VALUE(PrimitiveKind, Void, "void");
126 OUTPUT_ENUM_CLASS_VALUE(PrimitiveKind, Bool, "bool");
127 OUTPUT_ENUM_CLASS_VALUE(PrimitiveKind, Char, "char");
128 OUTPUT_ENUM_CLASS_VALUE(PrimitiveKind, Schar, "signed char");
129 OUTPUT_ENUM_CLASS_VALUE(PrimitiveKind, Uchar, "unsigned char");
130 OUTPUT_ENUM_CLASS_VALUE(PrimitiveKind, Char8, "char8_t");
131 OUTPUT_ENUM_CLASS_VALUE(PrimitiveKind, Char16, "char16_t");
132 OUTPUT_ENUM_CLASS_VALUE(PrimitiveKind, Char32, "char32_t");
133 OUTPUT_ENUM_CLASS_VALUE(PrimitiveKind, Short, "short");
134 OUTPUT_ENUM_CLASS_VALUE(PrimitiveKind, Ushort, "unsigned short");
135 OUTPUT_ENUM_CLASS_VALUE(PrimitiveKind, Int, "int");
136 OUTPUT_ENUM_CLASS_VALUE(PrimitiveKind, Uint, "unsigned int");
137 OUTPUT_ENUM_CLASS_VALUE(PrimitiveKind, Long, "long");
138 OUTPUT_ENUM_CLASS_VALUE(PrimitiveKind, Ulong, "unsigned long");
139 OUTPUT_ENUM_CLASS_VALUE(PrimitiveKind, Int64, "__int64");
140 OUTPUT_ENUM_CLASS_VALUE(PrimitiveKind, Uint64, "unsigned __int64");
141 OUTPUT_ENUM_CLASS_VALUE(PrimitiveKind, Wchar, "wchar_t");
142 OUTPUT_ENUM_CLASS_VALUE(PrimitiveKind, Float, "float");
143 OUTPUT_ENUM_CLASS_VALUE(PrimitiveKind, Double, "double");
144 OUTPUT_ENUM_CLASS_VALUE(PrimitiveKind, Ldouble, "long double");
145 OUTPUT_ENUM_CLASS_VALUE(PrimitiveKind, Nullptr, "std::nullptr_t");
147 outputQualifiers(OS, Quals, true, false);
150 void NodeArrayNode::output(OutputStream &OS, OutputFlags Flags) const {
151 output(OS, Flags, ", ");
154 void NodeArrayNode::output(OutputStream &OS, OutputFlags Flags,
155 StringView Separator) const {
156 if (Count == 0)
157 return;
158 if (Nodes[0])
159 Nodes[0]->output(OS, Flags);
160 for (size_t I = 1; I < Count; ++I) {
161 OS << Separator;
162 Nodes[I]->output(OS, Flags);
166 void EncodedStringLiteralNode::output(OutputStream &OS,
167 OutputFlags Flags) const {
168 switch (Char) {
169 case CharKind::Wchar:
170 OS << "L\"";
171 break;
172 case CharKind::Char:
173 OS << "\"";
174 break;
175 case CharKind::Char16:
176 OS << "u\"";
177 break;
178 case CharKind::Char32:
179 OS << "U\"";
180 break;
182 OS << DecodedString << "\"";
183 if (IsTruncated)
184 OS << "...";
187 void IntegerLiteralNode::output(OutputStream &OS, OutputFlags Flags) const {
188 if (IsNegative)
189 OS << '-';
190 OS << Value;
193 void TemplateParameterReferenceNode::output(OutputStream &OS,
194 OutputFlags Flags) const {
195 if (ThunkOffsetCount > 0)
196 OS << "{";
197 else if (Affinity == PointerAffinity::Pointer)
198 OS << "&";
200 if (Symbol) {
201 Symbol->output(OS, Flags);
202 if (ThunkOffsetCount > 0)
203 OS << ", ";
206 if (ThunkOffsetCount > 0)
207 OS << ThunkOffsets[0];
208 for (int I = 1; I < ThunkOffsetCount; ++I) {
209 OS << ", " << ThunkOffsets[I];
211 if (ThunkOffsetCount > 0)
212 OS << "}";
215 void IdentifierNode::outputTemplateParameters(OutputStream &OS,
216 OutputFlags Flags) const {
217 if (!TemplateParams)
218 return;
219 OS << "<";
220 TemplateParams->output(OS, Flags);
221 OS << ">";
224 void DynamicStructorIdentifierNode::output(OutputStream &OS,
225 OutputFlags Flags) const {
226 if (IsDestructor)
227 OS << "`dynamic atexit destructor for ";
228 else
229 OS << "`dynamic initializer for ";
231 if (Variable) {
232 OS << "`";
233 Variable->output(OS, Flags);
234 OS << "''";
235 } else {
236 OS << "'";
237 Name->output(OS, Flags);
238 OS << "''";
242 void NamedIdentifierNode::output(OutputStream &OS, OutputFlags Flags) const {
243 OS << Name;
244 outputTemplateParameters(OS, Flags);
247 void IntrinsicFunctionIdentifierNode::output(OutputStream &OS,
248 OutputFlags Flags) const {
249 switch (Operator) {
250 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, New, "operator new");
251 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, Delete, "operator delete");
252 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, Assign, "operator=");
253 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, RightShift, "operator>>");
254 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, LeftShift, "operator<<");
255 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, LogicalNot, "operator!");
256 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, Equals, "operator==");
257 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, NotEquals, "operator!=");
258 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, ArraySubscript,
259 "operator[]");
260 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, Pointer, "operator->");
261 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, Increment, "operator++");
262 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, Decrement, "operator--");
263 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, Minus, "operator-");
264 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, Plus, "operator+");
265 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, Dereference, "operator*");
266 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, BitwiseAnd, "operator&");
267 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, MemberPointer,
268 "operator->*");
269 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, Divide, "operator/");
270 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, Modulus, "operator%");
271 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, LessThan, "operator<");
272 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, LessThanEqual, "operator<=");
273 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, GreaterThan, "operator>");
274 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, GreaterThanEqual,
275 "operator>=");
276 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, Comma, "operator,");
277 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, Parens, "operator()");
278 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, BitwiseNot, "operator~");
279 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, BitwiseXor, "operator^");
280 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, BitwiseOr, "operator|");
281 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, LogicalAnd, "operator&&");
282 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, LogicalOr, "operator||");
283 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, TimesEqual, "operator*=");
284 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, PlusEqual, "operator+=");
285 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, MinusEqual, "operator-=");
286 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, DivEqual, "operator/=");
287 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, ModEqual, "operator%=");
288 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, RshEqual, "operator>>=");
289 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, LshEqual, "operator<<=");
290 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, BitwiseAndEqual,
291 "operator&=");
292 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, BitwiseOrEqual,
293 "operator|=");
294 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, BitwiseXorEqual,
295 "operator^=");
296 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, VbaseDtor, "`vbase dtor'");
297 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, VecDelDtor,
298 "`vector deleting dtor'");
299 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, DefaultCtorClosure,
300 "`default ctor closure'");
301 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, ScalarDelDtor,
302 "`scalar deleting dtor'");
303 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, VecCtorIter,
304 "`vector ctor iterator'");
305 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, VecDtorIter,
306 "`vector dtor iterator'");
307 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, VecVbaseCtorIter,
308 "`vector vbase ctor iterator'");
309 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, VdispMap,
310 "`virtual displacement map'");
311 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, EHVecCtorIter,
312 "`eh vector ctor iterator'");
313 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, EHVecDtorIter,
314 "`eh vector dtor iterator'");
315 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, EHVecVbaseCtorIter,
316 "`eh vector vbase ctor iterator'");
317 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, CopyCtorClosure,
318 "`copy ctor closure'");
319 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, LocalVftableCtorClosure,
320 "`local vftable ctor closure'");
321 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, ArrayNew, "operator new[]");
322 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, ArrayDelete,
323 "operator delete[]");
324 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, ManVectorCtorIter,
325 "`managed vector ctor iterator'");
326 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, ManVectorDtorIter,
327 "`managed vector dtor iterator'");
328 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, EHVectorCopyCtorIter,
329 "`EH vector copy ctor iterator'");
330 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, EHVectorVbaseCopyCtorIter,
331 "`EH vector vbase copy ctor iterator'");
332 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, VectorCopyCtorIter,
333 "`vector copy ctor iterator'");
334 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, VectorVbaseCopyCtorIter,
335 "`vector vbase copy constructor iterator'");
336 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, ManVectorVbaseCopyCtorIter,
337 "`managed vector vbase copy constructor iterator'");
338 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, CoAwait,
339 "operator co_await");
340 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, Spaceship, "operator<=>");
341 case IntrinsicFunctionKind::MaxIntrinsic:
342 case IntrinsicFunctionKind::None:
343 break;
345 outputTemplateParameters(OS, Flags);
348 void LocalStaticGuardIdentifierNode::output(OutputStream &OS,
349 OutputFlags Flags) const {
350 if (IsThread)
351 OS << "`local static thread guard'";
352 else
353 OS << "`local static guard'";
354 if (ScopeIndex > 0)
355 OS << "{" << ScopeIndex << "}";
358 void ConversionOperatorIdentifierNode::output(OutputStream &OS,
359 OutputFlags Flags) const {
360 OS << "operator";
361 outputTemplateParameters(OS, Flags);
362 OS << " ";
363 TargetType->output(OS, Flags);
366 void StructorIdentifierNode::output(OutputStream &OS, OutputFlags Flags) const {
367 if (IsDestructor)
368 OS << "~";
369 Class->output(OS, Flags);
370 outputTemplateParameters(OS, Flags);
373 void LiteralOperatorIdentifierNode::output(OutputStream &OS,
374 OutputFlags Flags) const {
375 OS << "operator \"\"" << Name;
376 outputTemplateParameters(OS, Flags);
379 void FunctionSignatureNode::outputPre(OutputStream &OS,
380 OutputFlags Flags) const {
381 if (FunctionClass & FC_Public)
382 OS << "public: ";
383 if (FunctionClass & FC_Protected)
384 OS << "protected: ";
385 if (FunctionClass & FC_Private)
386 OS << "private: ";
388 if (!(FunctionClass & FC_Global)) {
389 if (FunctionClass & FC_Static)
390 OS << "static ";
392 if (FunctionClass & FC_Virtual)
393 OS << "virtual ";
395 if (FunctionClass & FC_ExternC)
396 OS << "extern \"C\" ";
398 if (ReturnType) {
399 ReturnType->outputPre(OS, Flags);
400 OS << " ";
403 if (!(Flags & OF_NoCallingConvention))
404 outputCallingConvention(OS, CallConvention);
407 void FunctionSignatureNode::outputPost(OutputStream &OS,
408 OutputFlags Flags) const {
409 if (!(FunctionClass & FC_NoParameterList)) {
410 OS << "(";
411 if (Params)
412 Params->output(OS, Flags);
413 else
414 OS << "void";
416 if (IsVariadic) {
417 if (OS.back() != '(')
418 OS << ", ";
419 OS << "...";
421 OS << ")";
424 if (Quals & Q_Const)
425 OS << " const";
426 if (Quals & Q_Volatile)
427 OS << " volatile";
428 if (Quals & Q_Restrict)
429 OS << " __restrict";
430 if (Quals & Q_Unaligned)
431 OS << " __unaligned";
433 if (IsNoexcept)
434 OS << " noexcept";
436 if (RefQualifier == FunctionRefQualifier::Reference)
437 OS << " &";
438 else if (RefQualifier == FunctionRefQualifier::RValueReference)
439 OS << " &&";
441 if (ReturnType)
442 ReturnType->outputPost(OS, Flags);
445 void ThunkSignatureNode::outputPre(OutputStream &OS, OutputFlags Flags) const {
446 OS << "[thunk]: ";
448 FunctionSignatureNode::outputPre(OS, Flags);
451 void ThunkSignatureNode::outputPost(OutputStream &OS, OutputFlags Flags) const {
452 if (FunctionClass & FC_StaticThisAdjust) {
453 OS << "`adjustor{" << ThisAdjust.StaticOffset << "}'";
454 } else if (FunctionClass & FC_VirtualThisAdjust) {
455 if (FunctionClass & FC_VirtualThisAdjustEx) {
456 OS << "`vtordispex{" << ThisAdjust.VBPtrOffset << ", "
457 << ThisAdjust.VBOffsetOffset << ", " << ThisAdjust.VtordispOffset
458 << ", " << ThisAdjust.StaticOffset << "}'";
459 } else {
460 OS << "`vtordisp{" << ThisAdjust.VtordispOffset << ", "
461 << ThisAdjust.StaticOffset << "}'";
465 FunctionSignatureNode::outputPost(OS, Flags);
468 void PointerTypeNode::outputPre(OutputStream &OS, OutputFlags Flags) const {
469 if (Pointee->kind() == NodeKind::FunctionSignature) {
470 // If this is a pointer to a function, don't output the calling convention.
471 // It needs to go inside the parentheses.
472 const FunctionSignatureNode *Sig =
473 static_cast<const FunctionSignatureNode *>(Pointee);
474 Sig->outputPre(OS, OF_NoCallingConvention);
475 } else
476 Pointee->outputPre(OS, Flags);
478 outputSpaceIfNecessary(OS);
480 if (Quals & Q_Unaligned)
481 OS << "__unaligned ";
483 if (Pointee->kind() == NodeKind::ArrayType) {
484 OS << "(";
485 } else if (Pointee->kind() == NodeKind::FunctionSignature) {
486 OS << "(";
487 const FunctionSignatureNode *Sig =
488 static_cast<const FunctionSignatureNode *>(Pointee);
489 outputCallingConvention(OS, Sig->CallConvention);
490 OS << " ";
493 if (ClassParent) {
494 ClassParent->output(OS, Flags);
495 OS << "::";
498 switch (Affinity) {
499 case PointerAffinity::Pointer:
500 OS << "*";
501 break;
502 case PointerAffinity::Reference:
503 OS << "&";
504 break;
505 case PointerAffinity::RValueReference:
506 OS << "&&";
507 break;
508 default:
509 assert(false);
511 outputQualifiers(OS, Quals, false, false);
514 void PointerTypeNode::outputPost(OutputStream &OS, OutputFlags Flags) const {
515 if (Pointee->kind() == NodeKind::ArrayType ||
516 Pointee->kind() == NodeKind::FunctionSignature)
517 OS << ")";
519 Pointee->outputPost(OS, Flags);
522 void TagTypeNode::outputPre(OutputStream &OS, OutputFlags Flags) const {
523 if (!(Flags & OF_NoTagSpecifier)) {
524 switch (Tag) {
525 OUTPUT_ENUM_CLASS_VALUE(TagKind, Class, "class");
526 OUTPUT_ENUM_CLASS_VALUE(TagKind, Struct, "struct");
527 OUTPUT_ENUM_CLASS_VALUE(TagKind, Union, "union");
528 OUTPUT_ENUM_CLASS_VALUE(TagKind, Enum, "enum");
530 OS << " ";
532 QualifiedName->output(OS, Flags);
533 outputQualifiers(OS, Quals, true, false);
536 void TagTypeNode::outputPost(OutputStream &OS, OutputFlags Flags) const {}
538 void ArrayTypeNode::outputPre(OutputStream &OS, OutputFlags Flags) const {
539 ElementType->outputPre(OS, Flags);
540 outputQualifiers(OS, Quals, true, false);
543 void ArrayTypeNode::outputOneDimension(OutputStream &OS, OutputFlags Flags,
544 Node *N) const {
545 assert(N->kind() == NodeKind::IntegerLiteral);
546 IntegerLiteralNode *ILN = static_cast<IntegerLiteralNode *>(N);
547 if (ILN->Value != 0)
548 ILN->output(OS, Flags);
551 void ArrayTypeNode::outputDimensionsImpl(OutputStream &OS,
552 OutputFlags Flags) const {
553 if (Dimensions->Count == 0)
554 return;
556 outputOneDimension(OS, Flags, Dimensions->Nodes[0]);
557 for (size_t I = 1; I < Dimensions->Count; ++I) {
558 OS << "][";
559 outputOneDimension(OS, Flags, Dimensions->Nodes[I]);
563 void ArrayTypeNode::outputPost(OutputStream &OS, OutputFlags Flags) const {
564 OS << "[";
565 outputDimensionsImpl(OS, Flags);
566 OS << "]";
568 ElementType->outputPost(OS, Flags);
571 void SymbolNode::output(OutputStream &OS, OutputFlags Flags) const {
572 Name->output(OS, Flags);
575 void FunctionSymbolNode::output(OutputStream &OS, OutputFlags Flags) const {
576 Signature->outputPre(OS, Flags);
577 outputSpaceIfNecessary(OS);
578 Name->output(OS, Flags);
579 Signature->outputPost(OS, Flags);
582 void VariableSymbolNode::output(OutputStream &OS, OutputFlags Flags) const {
583 switch (SC) {
584 case StorageClass::PrivateStatic:
585 OS << "private: static ";
586 break;
587 case StorageClass::PublicStatic:
588 OS << "public: static ";
589 break;
590 case StorageClass::ProtectedStatic:
591 OS << "protected: static ";
592 break;
593 default:
594 break;
597 if (Type) {
598 Type->outputPre(OS, Flags);
599 outputSpaceIfNecessary(OS);
601 Name->output(OS, Flags);
602 if (Type)
603 Type->outputPost(OS, Flags);
606 void CustomTypeNode::outputPre(OutputStream &OS, OutputFlags Flags) const {
607 Identifier->output(OS, Flags);
609 void CustomTypeNode::outputPost(OutputStream &OS, OutputFlags Flags) const {}
611 void QualifiedNameNode::output(OutputStream &OS, OutputFlags Flags) const {
612 Components->output(OS, Flags, "::");
615 void RttiBaseClassDescriptorNode::output(OutputStream &OS,
616 OutputFlags Flags) const {
617 OS << "`RTTI Base Class Descriptor at (";
618 OS << NVOffset << ", " << VBPtrOffset << ", " << VBTableOffset << ", "
619 << this->Flags;
620 OS << ")'";
623 void LocalStaticGuardVariableNode::output(OutputStream &OS,
624 OutputFlags Flags) const {
625 Name->output(OS, Flags);
628 void VcallThunkIdentifierNode::output(OutputStream &OS,
629 OutputFlags Flags) const {
630 OS << "`vcall'{" << OffsetInVTable << ", {flat}}";
633 void SpecialTableSymbolNode::output(OutputStream &OS, OutputFlags Flags) const {
634 outputQualifiers(OS, Quals, false, true);
635 Name->output(OS, Flags);
636 if (TargetName) {
637 OS << "{for `";
638 TargetName->output(OS, Flags);
639 OS << "'}";
641 return;