Bug Summary

File:lib/Demangle/MicrosoftDemangleNodes.cpp
Warning:line 74, column 3
Value stored to 'SpaceBefore' is never read

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name MicrosoftDemangleNodes.cpp -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -mrelocation-model pic -pic-level 2 -mthread-model posix -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info -debugger-tuning=gdb -momit-leaf-frame-pointer -ffunction-sections -fdata-sections -resource-dir /usr/lib/llvm-8/lib/clang/8.0.0 -D _DEBUG -D _GNU_SOURCE -D __STDC_CONSTANT_MACROS -D __STDC_FORMAT_MACROS -D __STDC_LIMIT_MACROS -I /build/llvm-toolchain-snapshot-8~svn345461/build-llvm/lib/Demangle -I /build/llvm-toolchain-snapshot-8~svn345461/lib/Demangle -I /build/llvm-toolchain-snapshot-8~svn345461/build-llvm/include -I /build/llvm-toolchain-snapshot-8~svn345461/include -U NDEBUG -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/c++/6.3.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/x86_64-linux-gnu/c++/6.3.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/x86_64-linux-gnu/c++/6.3.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/c++/6.3.0/backward -internal-isystem /usr/include/clang/8.0.0/include/ -internal-isystem /usr/local/include -internal-isystem /usr/lib/llvm-8/lib/clang/8.0.0/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -Wno-unused-parameter -Wwrite-strings -Wno-missing-field-initializers -Wno-long-long -Wno-maybe-uninitialized -Wno-comment -std=c++11 -fdeprecated-macro -fdebug-compilation-dir /build/llvm-toolchain-snapshot-8~svn345461/build-llvm/lib/Demangle -ferror-limit 19 -fmessage-length 0 -fvisibility-inlines-hidden -fobjc-runtime=gcc -fdiagnostics-show-option -vectorize-loops -vectorize-slp -analyzer-output=html -analyzer-config stable-report-filename=true -o /tmp/scan-build-2018-10-27-211344-32123-1 -x c++ /build/llvm-toolchain-snapshot-8~svn345461/lib/Demangle/MicrosoftDemangleNodes.cpp -faddrsig
1//===- MicrosoftDemangle.cpp ----------------------------------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file defines a demangler for MSVC-style mangled symbols.
11//
12//===----------------------------------------------------------------------===//
13
14#include "MicrosoftDemangleNodes.h"
15#include "llvm/Demangle/Compiler.h"
16#include "llvm/Demangle/Utility.h"
17#include <cctype>
18
19using namespace llvm;
20using namespace ms_demangle;
21
22#define OUTPUT_ENUM_CLASS_VALUE(Enum, Value, Desc)case Enum::Value: OS << Desc; break; \
23 case Enum::Value: \
24 OS << Desc; \
25 break;
26
27// Writes a space if the last token does not end with a punctuation.
28static void outputSpaceIfNecessary(OutputStream &OS) {
29 if (OS.empty())
30 return;
31
32 char C = OS.back();
33 if (std::isalnum(C) || C == '>')
34 OS << " ";
35}
36
37static bool outputSingleQualifier(OutputStream &OS, Qualifiers Q) {
38 switch (Q) {
39 case Q_Const:
40 OS << "const";
41 return true;
42 case Q_Volatile:
43 OS << "volatile";
44 return true;
45 case Q_Restrict:
46 OS << "__restrict";
47 return true;
48 default:
49 break;
50 }
51 return false;
52}
53
54static bool outputQualifierIfPresent(OutputStream &OS, Qualifiers Q,
55 Qualifiers Mask, bool NeedSpace) {
56 if (!(Q & Mask))
57 return NeedSpace;
58
59 if (NeedSpace)
60 OS << " ";
61
62 outputSingleQualifier(OS, Mask);
63 return true;
64}
65
66static void outputQualifiers(OutputStream &OS, Qualifiers Q, bool SpaceBefore,
67 bool SpaceAfter) {
68 if (Q == Q_None)
69 return;
70
71 size_t Pos1 = OS.getCurrentPosition();
72 SpaceBefore = outputQualifierIfPresent(OS, Q, Q_Const, SpaceBefore);
73 SpaceBefore = outputQualifierIfPresent(OS, Q, Q_Volatile, SpaceBefore);
74 SpaceBefore = outputQualifierIfPresent(OS, Q, Q_Restrict, SpaceBefore);
Value stored to 'SpaceBefore' is never read
75 size_t Pos2 = OS.getCurrentPosition();
76 if (SpaceAfter && Pos2 > Pos1)
77 OS << " ";
78}
79
80static void outputCallingConvention(OutputStream &OS, CallingConv CC) {
81 outputSpaceIfNecessary(OS);
82
83 switch (CC) {
84 case CallingConv::Cdecl:
85 OS << "__cdecl";
86 break;
87 case CallingConv::Fastcall:
88 OS << "__fastcall";
89 break;
90 case CallingConv::Pascal:
91 OS << "__pascal";
92 break;
93 case CallingConv::Regcall:
94 OS << "__regcall";
95 break;
96 case CallingConv::Stdcall:
97 OS << "__stdcall";
98 break;
99 case CallingConv::Thiscall:
100 OS << "__thiscall";
101 break;
102 case CallingConv::Eabi:
103 OS << "__eabi";
104 break;
105 case CallingConv::Vectorcall:
106 OS << "__vectorcall";
107 break;
108 case CallingConv::Clrcall:
109 OS << "__clrcall";
110 break;
111 default:
112 break;
113 }
114}
115
116void TypeNode::outputQuals(bool SpaceBefore, bool SpaceAfter) const {}
117
118void PrimitiveTypeNode::outputPre(OutputStream &OS, OutputFlags Flags) const {
119 switch (PrimKind) {
120 OUTPUT_ENUM_CLASS_VALUE(PrimitiveKind, Void, "void")case PrimitiveKind::Void: OS << "void"; break;;
121 OUTPUT_ENUM_CLASS_VALUE(PrimitiveKind, Bool, "bool")case PrimitiveKind::Bool: OS << "bool"; break;;
122 OUTPUT_ENUM_CLASS_VALUE(PrimitiveKind, Char, "char")case PrimitiveKind::Char: OS << "char"; break;;
123 OUTPUT_ENUM_CLASS_VALUE(PrimitiveKind, Schar, "signed char")case PrimitiveKind::Schar: OS << "signed char"; break;;
124 OUTPUT_ENUM_CLASS_VALUE(PrimitiveKind, Uchar, "unsigned char")case PrimitiveKind::Uchar: OS << "unsigned char"; break
;
;
125 OUTPUT_ENUM_CLASS_VALUE(PrimitiveKind, Char16, "char16_t")case PrimitiveKind::Char16: OS << "char16_t"; break;;
126 OUTPUT_ENUM_CLASS_VALUE(PrimitiveKind, Char32, "char32_t")case PrimitiveKind::Char32: OS << "char32_t"; break;;
127 OUTPUT_ENUM_CLASS_VALUE(PrimitiveKind, Short, "short")case PrimitiveKind::Short: OS << "short"; break;;
128 OUTPUT_ENUM_CLASS_VALUE(PrimitiveKind, Ushort, "unsigned short")case PrimitiveKind::Ushort: OS << "unsigned short"; break
;
;
129 OUTPUT_ENUM_CLASS_VALUE(PrimitiveKind, Int, "int")case PrimitiveKind::Int: OS << "int"; break;;
130 OUTPUT_ENUM_CLASS_VALUE(PrimitiveKind, Uint, "unsigned int")case PrimitiveKind::Uint: OS << "unsigned int"; break;;
131 OUTPUT_ENUM_CLASS_VALUE(PrimitiveKind, Long, "long")case PrimitiveKind::Long: OS << "long"; break;;
132 OUTPUT_ENUM_CLASS_VALUE(PrimitiveKind, Ulong, "unsigned long")case PrimitiveKind::Ulong: OS << "unsigned long"; break
;
;
133 OUTPUT_ENUM_CLASS_VALUE(PrimitiveKind, Int64, "__int64")case PrimitiveKind::Int64: OS << "__int64"; break;;
134 OUTPUT_ENUM_CLASS_VALUE(PrimitiveKind, Uint64, "unsigned __int64")case PrimitiveKind::Uint64: OS << "unsigned __int64"; break
;
;
135 OUTPUT_ENUM_CLASS_VALUE(PrimitiveKind, Wchar, "wchar_t")case PrimitiveKind::Wchar: OS << "wchar_t"; break;;
136 OUTPUT_ENUM_CLASS_VALUE(PrimitiveKind, Float, "float")case PrimitiveKind::Float: OS << "float"; break;;
137 OUTPUT_ENUM_CLASS_VALUE(PrimitiveKind, Double, "double")case PrimitiveKind::Double: OS << "double"; break;;
138 OUTPUT_ENUM_CLASS_VALUE(PrimitiveKind, Ldouble, "long double")case PrimitiveKind::Ldouble: OS << "long double"; break
;
;
139 OUTPUT_ENUM_CLASS_VALUE(PrimitiveKind, Nullptr, "std::nullptr_t")case PrimitiveKind::Nullptr: OS << "std::nullptr_t"; break
;
;
140 }
141 outputQualifiers(OS, Quals, true, false);
142}
143
144void NodeArrayNode::output(OutputStream &OS, OutputFlags Flags) const {
145 output(OS, Flags, ", ");
146}
147
148void NodeArrayNode::output(OutputStream &OS, OutputFlags Flags,
149 StringView Separator) const {
150 if (Count == 0)
151 return;
152 if (Nodes[0])
153 Nodes[0]->output(OS, Flags);
154 for (size_t I = 1; I < Count; ++I) {
155 OS << Separator;
156 Nodes[I]->output(OS, Flags);
157 }
158}
159
160void EncodedStringLiteralNode::output(OutputStream &OS,
161 OutputFlags Flags) const {
162 switch (Char) {
163 case CharKind::Wchar:
164 OS << "const wchar_t * {L\"";
165 break;
166 case CharKind::Char:
167 OS << "const char * {\"";
168 break;
169 case CharKind::Char16:
170 OS << "const char16_t * {u\"";
171 break;
172 case CharKind::Char32:
173 OS << "const char32_t * {U\"";
174 break;
175 }
176 OS << DecodedString << "\"";
177 if (IsTruncated)
178 OS << "...";
179 OS << "}";
180}
181
182void IntegerLiteralNode::output(OutputStream &OS, OutputFlags Flags) const {
183 if (IsNegative)
184 OS << '-';
185 OS << Value;
186}
187
188void TemplateParameterReferenceNode::output(OutputStream &OS,
189 OutputFlags Flags) const {
190 if (ThunkOffsetCount > 0)
191 OS << "{";
192 else if (Affinity == PointerAffinity::Pointer)
193 OS << "&";
194
195 if (Symbol) {
196 Symbol->output(OS, Flags);
197 if (ThunkOffsetCount > 0)
198 OS << ", ";
199 }
200
201 if (ThunkOffsetCount > 0)
202 OS << ThunkOffsets[0];
203 for (int I = 1; I < ThunkOffsetCount; ++I) {
204 OS << ", " << ThunkOffsets[I];
205 }
206 if (ThunkOffsetCount > 0)
207 OS << "}";
208}
209
210void IdentifierNode::outputTemplateParameters(OutputStream &OS,
211 OutputFlags Flags) const {
212 if (!TemplateParams)
213 return;
214 OS << "<";
215 TemplateParams->output(OS, Flags);
216 OS << ">";
217}
218
219void DynamicStructorIdentifierNode::output(OutputStream &OS,
220 OutputFlags Flags) const {
221 if (IsDestructor)
222 OS << "`dynamic atexit destructor for ";
223 else
224 OS << "`dynamic initializer for ";
225
226 if (Variable) {
227 OS << "`";
228 Variable->output(OS, Flags);
229 OS << "''";
230 } else {
231 OS << "'";
232 Name->output(OS, Flags);
233 OS << "''";
234 }
235}
236
237void NamedIdentifierNode::output(OutputStream &OS, OutputFlags Flags) const {
238 OS << Name;
239 outputTemplateParameters(OS, Flags);
240}
241
242void IntrinsicFunctionIdentifierNode::output(OutputStream &OS,
243 OutputFlags Flags) const {
244 switch (Operator) {
245 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, New, "operator new")case IntrinsicFunctionKind::New: OS << "operator new"; break
;
;
246 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, Delete, "operator delete")case IntrinsicFunctionKind::Delete: OS << "operator delete"
; break;
;
247 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, Assign, "operator=")case IntrinsicFunctionKind::Assign: OS << "operator="; break
;
;
248 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, RightShift, "operator>>")case IntrinsicFunctionKind::RightShift: OS << "operator>>"
; break;
;
249 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, LeftShift, "operator<<")case IntrinsicFunctionKind::LeftShift: OS << "operator<<"
; break;
;
250 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, LogicalNot, "operator!")case IntrinsicFunctionKind::LogicalNot: OS << "operator!"
; break;
;
251 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, Equals, "operator==")case IntrinsicFunctionKind::Equals: OS << "operator==";
break;
;
252 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, NotEquals, "operator!=")case IntrinsicFunctionKind::NotEquals: OS << "operator!="
; break;
;
253 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, ArraySubscript,case IntrinsicFunctionKind::ArraySubscript: OS << "operator[]"
; break;
254 "operator[]")case IntrinsicFunctionKind::ArraySubscript: OS << "operator[]"
; break;
;
255 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, Pointer, "operator->")case IntrinsicFunctionKind::Pointer: OS << "operator->"
; break;
;
256 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, Increment, "operator++")case IntrinsicFunctionKind::Increment: OS << "operator++"
; break;
;
257 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, Decrement, "operator--")case IntrinsicFunctionKind::Decrement: OS << "operator--"
; break;
;
258 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, Minus, "operator-")case IntrinsicFunctionKind::Minus: OS << "operator-"; break
;
;
259 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, Plus, "operator+")case IntrinsicFunctionKind::Plus: OS << "operator+"; break
;
;
260 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, Dereference, "operator*")case IntrinsicFunctionKind::Dereference: OS << "operator*"
; break;
;
261 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, BitwiseAnd, "operator&")case IntrinsicFunctionKind::BitwiseAnd: OS << "operator&"
; break;
;
262 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, MemberPointer,case IntrinsicFunctionKind::MemberPointer: OS << "operator->*"
; break;
263 "operator->*")case IntrinsicFunctionKind::MemberPointer: OS << "operator->*"
; break;
;
264 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, Divide, "operator/")case IntrinsicFunctionKind::Divide: OS << "operator/"; break
;
;
265 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, Modulus, "operator%")case IntrinsicFunctionKind::Modulus: OS << "operator%";
break;
;
266 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, LessThan, "operator<")case IntrinsicFunctionKind::LessThan: OS << "operator<"
; break;
;
267 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, LessThanEqual, "operator<=")case IntrinsicFunctionKind::LessThanEqual: OS << "operator<="
; break;
;
268 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, GreaterThan, "operator>")case IntrinsicFunctionKind::GreaterThan: OS << "operator>"
; break;
;
269 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, GreaterThanEqual,case IntrinsicFunctionKind::GreaterThanEqual: OS << "operator>="
; break;
270 "operator>=")case IntrinsicFunctionKind::GreaterThanEqual: OS << "operator>="
; break;
;
271 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, Comma, "operator,")case IntrinsicFunctionKind::Comma: OS << "operator,"; break
;
;
272 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, Parens, "operator()")case IntrinsicFunctionKind::Parens: OS << "operator()";
break;
;
273 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, BitwiseNot, "operator~")case IntrinsicFunctionKind::BitwiseNot: OS << "operator~"
; break;
;
274 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, BitwiseXor, "operator^")case IntrinsicFunctionKind::BitwiseXor: OS << "operator^"
; break;
;
275 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, BitwiseOr, "operator|")case IntrinsicFunctionKind::BitwiseOr: OS << "operator|"
; break;
;
276 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, LogicalAnd, "operator&&")case IntrinsicFunctionKind::LogicalAnd: OS << "operator&&"
; break;
;
277 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, LogicalOr, "operator||")case IntrinsicFunctionKind::LogicalOr: OS << "operator||"
; break;
;
278 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, TimesEqual, "operator*=")case IntrinsicFunctionKind::TimesEqual: OS << "operator*="
; break;
;
279 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, PlusEqual, "operator+=")case IntrinsicFunctionKind::PlusEqual: OS << "operator+="
; break;
;
280 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, MinusEqual, "operator-=")case IntrinsicFunctionKind::MinusEqual: OS << "operator-="
; break;
;
281 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, DivEqual, "operator/=")case IntrinsicFunctionKind::DivEqual: OS << "operator/="
; break;
;
282 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, ModEqual, "operator%=")case IntrinsicFunctionKind::ModEqual: OS << "operator%="
; break;
;
283 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, RshEqual, "operator>>=")case IntrinsicFunctionKind::RshEqual: OS << "operator>>="
; break;
;
284 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, LshEqual, "operator<<=")case IntrinsicFunctionKind::LshEqual: OS << "operator<<="
; break;
;
285 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, BitwiseAndEqual,case IntrinsicFunctionKind::BitwiseAndEqual: OS << "operator&="
; break;
286 "operator&=")case IntrinsicFunctionKind::BitwiseAndEqual: OS << "operator&="
; break;
;
287 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, BitwiseOrEqual,case IntrinsicFunctionKind::BitwiseOrEqual: OS << "operator|="
; break;
288 "operator|=")case IntrinsicFunctionKind::BitwiseOrEqual: OS << "operator|="
; break;
;
289 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, BitwiseXorEqual,case IntrinsicFunctionKind::BitwiseXorEqual: OS << "operator^="
; break;
290 "operator^=")case IntrinsicFunctionKind::BitwiseXorEqual: OS << "operator^="
; break;
;
291 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, VbaseDtor, "`vbase dtor'")case IntrinsicFunctionKind::VbaseDtor: OS << "`vbase dtor'"
; break;
;
292 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, VecDelDtor,case IntrinsicFunctionKind::VecDelDtor: OS << "`vector deleting dtor'"
; break;
293 "`vector deleting dtor'")case IntrinsicFunctionKind::VecDelDtor: OS << "`vector deleting dtor'"
; break;
;
294 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, DefaultCtorClosure,case IntrinsicFunctionKind::DefaultCtorClosure: OS << "`default ctor closure'"
; break;
295 "`default ctor closure'")case IntrinsicFunctionKind::DefaultCtorClosure: OS << "`default ctor closure'"
; break;
;
296 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, ScalarDelDtor,case IntrinsicFunctionKind::ScalarDelDtor: OS << "`scalar deleting dtor'"
; break;
297 "`scalar deleting dtor'")case IntrinsicFunctionKind::ScalarDelDtor: OS << "`scalar deleting dtor'"
; break;
;
298 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, VecCtorIter,case IntrinsicFunctionKind::VecCtorIter: OS << "`vector ctor iterator'"
; break;
299 "`vector ctor iterator'")case IntrinsicFunctionKind::VecCtorIter: OS << "`vector ctor iterator'"
; break;
;
300 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, VecDtorIter,case IntrinsicFunctionKind::VecDtorIter: OS << "`vector dtor iterator'"
; break;
301 "`vector dtor iterator'")case IntrinsicFunctionKind::VecDtorIter: OS << "`vector dtor iterator'"
; break;
;
302 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, VecVbaseCtorIter,case IntrinsicFunctionKind::VecVbaseCtorIter: OS << "`vector vbase ctor iterator'"
; break;
303 "`vector vbase ctor iterator'")case IntrinsicFunctionKind::VecVbaseCtorIter: OS << "`vector vbase ctor iterator'"
; break;
;
304 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, VdispMap,case IntrinsicFunctionKind::VdispMap: OS << "`virtual displacement map'"
; break;
305 "`virtual displacement map'")case IntrinsicFunctionKind::VdispMap: OS << "`virtual displacement map'"
; break;
;
306 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, EHVecCtorIter,case IntrinsicFunctionKind::EHVecCtorIter: OS << "`eh vector ctor iterator'"
; break;
307 "`eh vector ctor iterator'")case IntrinsicFunctionKind::EHVecCtorIter: OS << "`eh vector ctor iterator'"
; break;
;
308 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, EHVecDtorIter,case IntrinsicFunctionKind::EHVecDtorIter: OS << "`eh vector dtor iterator'"
; break;
309 "`eh vector dtor iterator'")case IntrinsicFunctionKind::EHVecDtorIter: OS << "`eh vector dtor iterator'"
; break;
;
310 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, EHVecVbaseCtorIter,case IntrinsicFunctionKind::EHVecVbaseCtorIter: OS << "`eh vector vbase ctor iterator'"
; break;
311 "`eh vector vbase ctor iterator'")case IntrinsicFunctionKind::EHVecVbaseCtorIter: OS << "`eh vector vbase ctor iterator'"
; break;
;
312 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, CopyCtorClosure,case IntrinsicFunctionKind::CopyCtorClosure: OS << "`copy ctor closure'"
; break;
313 "`copy ctor closure'")case IntrinsicFunctionKind::CopyCtorClosure: OS << "`copy ctor closure'"
; break;
;
314 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, LocalVftableCtorClosure,case IntrinsicFunctionKind::LocalVftableCtorClosure: OS <<
"`local vftable ctor closure'"; break;
315 "`local vftable ctor closure'")case IntrinsicFunctionKind::LocalVftableCtorClosure: OS <<
"`local vftable ctor closure'"; break;
;
316 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, ArrayNew, "operator new[]")case IntrinsicFunctionKind::ArrayNew: OS << "operator new[]"
; break;
;
317 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, ArrayDelete,case IntrinsicFunctionKind::ArrayDelete: OS << "operator delete[]"
; break;
318 "operator delete[]")case IntrinsicFunctionKind::ArrayDelete: OS << "operator delete[]"
; break;
;
319 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, ManVectorCtorIter,case IntrinsicFunctionKind::ManVectorCtorIter: OS << "`managed vector ctor iterator'"
; break;
320 "`managed vector ctor iterator'")case IntrinsicFunctionKind::ManVectorCtorIter: OS << "`managed vector ctor iterator'"
; break;
;
321 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, ManVectorDtorIter,case IntrinsicFunctionKind::ManVectorDtorIter: OS << "`managed vector dtor iterator'"
; break;
322 "`managed vector dtor iterator'")case IntrinsicFunctionKind::ManVectorDtorIter: OS << "`managed vector dtor iterator'"
; break;
;
323 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, EHVectorCopyCtorIter,case IntrinsicFunctionKind::EHVectorCopyCtorIter: OS <<
"`EH vector copy ctor iterator'"; break;
324 "`EH vector copy ctor iterator'")case IntrinsicFunctionKind::EHVectorCopyCtorIter: OS <<
"`EH vector copy ctor iterator'"; break;
;
325 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, EHVectorVbaseCopyCtorIter,case IntrinsicFunctionKind::EHVectorVbaseCopyCtorIter: OS <<
"`EH vector vbase copy ctor iterator'"; break;
326 "`EH vector vbase copy ctor iterator'")case IntrinsicFunctionKind::EHVectorVbaseCopyCtorIter: OS <<
"`EH vector vbase copy ctor iterator'"; break;
;
327 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, VectorCopyCtorIter,case IntrinsicFunctionKind::VectorCopyCtorIter: OS << "`vector copy ctor iterator'"
; break;
328 "`vector copy ctor iterator'")case IntrinsicFunctionKind::VectorCopyCtorIter: OS << "`vector copy ctor iterator'"
; break;
;
329 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, VectorVbaseCopyCtorIter,case IntrinsicFunctionKind::VectorVbaseCopyCtorIter: OS <<
"`vector vbase copy constructor iterator'"; break;
330 "`vector vbase copy constructor iterator'")case IntrinsicFunctionKind::VectorVbaseCopyCtorIter: OS <<
"`vector vbase copy constructor iterator'"; break;
;
331 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, ManVectorVbaseCopyCtorIter,case IntrinsicFunctionKind::ManVectorVbaseCopyCtorIter: OS <<
"`managed vector vbase copy constructor iterator'"; break;
332 "`managed vector vbase copy constructor iterator'")case IntrinsicFunctionKind::ManVectorVbaseCopyCtorIter: OS <<
"`managed vector vbase copy constructor iterator'"; break;
;
333 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, CoAwait, "co_await")case IntrinsicFunctionKind::CoAwait: OS << "co_await"; break
;
;
334 OUTPUT_ENUM_CLASS_VALUE(IntrinsicFunctionKind, Spaceship, "operator <=>")case IntrinsicFunctionKind::Spaceship: OS << "operator <=>"
; break;
;
335 case IntrinsicFunctionKind::MaxIntrinsic:
336 case IntrinsicFunctionKind::None:
337 break;
338 }
339 outputTemplateParameters(OS, Flags);
340}
341
342void LocalStaticGuardIdentifierNode::output(OutputStream &OS,
343 OutputFlags Flags) const {
344 OS << "`local static guard'";
345 if (ScopeIndex > 0)
346 OS << "{" << ScopeIndex << "}";
347}
348
349void ConversionOperatorIdentifierNode::output(OutputStream &OS,
350 OutputFlags Flags) const {
351 OS << "operator";
352 outputTemplateParameters(OS, Flags);
353 OS << " ";
354 TargetType->output(OS, Flags);
355}
356
357void StructorIdentifierNode::output(OutputStream &OS, OutputFlags Flags) const {
358 if (IsDestructor)
359 OS << "~";
360 Class->output(OS, Flags);
361 outputTemplateParameters(OS, Flags);
362}
363
364void LiteralOperatorIdentifierNode::output(OutputStream &OS,
365 OutputFlags Flags) const {
366 OS << "operator \"\"" << Name;
367 outputTemplateParameters(OS, Flags);
368}
369
370void FunctionSignatureNode::outputPre(OutputStream &OS,
371 OutputFlags Flags) const {
372 if (!(FunctionClass & FC_Global)) {
373 if (FunctionClass & FC_Static)
374 OS << "static ";
375 }
376 if (FunctionClass & FC_ExternC)
377 OS << "extern \"C\" ";
378
379 if (FunctionClass & FC_Virtual)
380 OS << "virtual ";
381
382 if (ReturnType) {
383 ReturnType->outputPre(OS, Flags);
384 OS << " ";
385 }
386
387 if (!(Flags & OF_NoCallingConvention))
388 outputCallingConvention(OS, CallConvention);
389}
390
391void FunctionSignatureNode::outputPost(OutputStream &OS,
392 OutputFlags Flags) const {
393 if (!(FunctionClass & FC_NoParameterList)) {
394 OS << "(";
395 if (Params)
396 Params->output(OS, Flags);
397 else
398 OS << "void";
399 OS << ")";
400 }
401
402 if (Quals & Q_Const)
403 OS << " const";
404 if (Quals & Q_Volatile)
405 OS << " volatile";
406 if (Quals & Q_Restrict)
407 OS << " __restrict";
408 if (Quals & Q_Unaligned)
409 OS << " __unaligned";
410
411 if (RefQualifier == FunctionRefQualifier::Reference)
412 OS << " &";
413 else if (RefQualifier == FunctionRefQualifier::RValueReference)
414 OS << " &&";
415
416 if (ReturnType)
417 ReturnType->outputPost(OS, Flags);
418}
419
420void ThunkSignatureNode::outputPre(OutputStream &OS, OutputFlags Flags) const {
421 OS << "[thunk]: ";
422
423 FunctionSignatureNode::outputPre(OS, Flags);
424}
425
426void ThunkSignatureNode::outputPost(OutputStream &OS, OutputFlags Flags) const {
427 if (FunctionClass & FC_StaticThisAdjust) {
428 OS << "`adjustor{" << ThisAdjust.StaticOffset << "}'";
429 } else if (FunctionClass & FC_VirtualThisAdjust) {
430 if (FunctionClass & FC_VirtualThisAdjustEx) {
431 OS << "`vtordispex{" << ThisAdjust.VBPtrOffset << ", "
432 << ThisAdjust.VBOffsetOffset << ", " << ThisAdjust.VtordispOffset
433 << ", " << ThisAdjust.StaticOffset << "}'";
434 } else {
435 OS << "`vtordisp{" << ThisAdjust.VtordispOffset << ", "
436 << ThisAdjust.StaticOffset << "}'";
437 }
438 }
439
440 FunctionSignatureNode::outputPost(OS, Flags);
441}
442
443void PointerTypeNode::outputPre(OutputStream &OS, OutputFlags Flags) const {
444 if (Pointee->kind() == NodeKind::FunctionSignature) {
445 // If this is a pointer to a function, don't output the calling convention.
446 // It needs to go inside the parentheses.
447 const FunctionSignatureNode *Sig =
448 static_cast<const FunctionSignatureNode *>(Pointee);
449 Sig->outputPre(OS, OF_NoCallingConvention);
450 } else
451 Pointee->outputPre(OS, Flags);
452
453 outputSpaceIfNecessary(OS);
454
455 if (Quals & Q_Unaligned)
456 OS << "__unaligned ";
457
458 if (Pointee->kind() == NodeKind::ArrayType) {
459 OS << "(";
460 } else if (Pointee->kind() == NodeKind::FunctionSignature) {
461 OS << "(";
462 const FunctionSignatureNode *Sig =
463 static_cast<const FunctionSignatureNode *>(Pointee);
464 outputCallingConvention(OS, Sig->CallConvention);
465 OS << " ";
466 }
467
468 if (ClassParent) {
469 ClassParent->output(OS, Flags);
470 OS << "::";
471 }
472
473 switch (Affinity) {
474 case PointerAffinity::Pointer:
475 OS << "*";
476 break;
477 case PointerAffinity::Reference:
478 OS << "&";
479 break;
480 case PointerAffinity::RValueReference:
481 OS << "&&";
482 break;
483 default:
484 assert(false)((false) ? static_cast<void> (0) : __assert_fail ("false"
, "/build/llvm-toolchain-snapshot-8~svn345461/lib/Demangle/MicrosoftDemangleNodes.cpp"
, 484, __PRETTY_FUNCTION__))
;
485 }
486 outputQualifiers(OS, Quals, false, false);
487}
488
489void PointerTypeNode::outputPost(OutputStream &OS, OutputFlags Flags) const {
490 if (Pointee->kind() == NodeKind::ArrayType ||
491 Pointee->kind() == NodeKind::FunctionSignature)
492 OS << ")";
493
494 Pointee->outputPost(OS, Flags);
495}
496
497void TagTypeNode::outputPre(OutputStream &OS, OutputFlags Flags) const {
498 switch (Tag) {
499 OUTPUT_ENUM_CLASS_VALUE(TagKind, Class, "class")case TagKind::Class: OS << "class"; break;;
500 OUTPUT_ENUM_CLASS_VALUE(TagKind, Struct, "struct")case TagKind::Struct: OS << "struct"; break;;
501 OUTPUT_ENUM_CLASS_VALUE(TagKind, Union, "union")case TagKind::Union: OS << "union"; break;;
502 OUTPUT_ENUM_CLASS_VALUE(TagKind, Enum, "enum")case TagKind::Enum: OS << "enum"; break;;
503 }
504 OS << " ";
505 QualifiedName->output(OS, Flags);
506 outputQualifiers(OS, Quals, true, false);
507}
508
509void TagTypeNode::outputPost(OutputStream &OS, OutputFlags Flags) const {}
510
511void ArrayTypeNode::outputPre(OutputStream &OS, OutputFlags Flags) const {
512 ElementType->outputPre(OS, Flags);
513 outputQualifiers(OS, Quals, true, false);
514}
515
516void ArrayTypeNode::outputOneDimension(OutputStream &OS, OutputFlags Flags,
517 Node *N) const {
518 assert(N->kind() == NodeKind::IntegerLiteral)((N->kind() == NodeKind::IntegerLiteral) ? static_cast<
void> (0) : __assert_fail ("N->kind() == NodeKind::IntegerLiteral"
, "/build/llvm-toolchain-snapshot-8~svn345461/lib/Demangle/MicrosoftDemangleNodes.cpp"
, 518, __PRETTY_FUNCTION__))
;
519 IntegerLiteralNode *ILN = static_cast<IntegerLiteralNode *>(N);
520 if (ILN->Value != 0)
521 ILN->output(OS, Flags);
522}
523
524void ArrayTypeNode::outputDimensionsImpl(OutputStream &OS,
525 OutputFlags Flags) const {
526 if (Dimensions->Count == 0)
527 return;
528
529 outputOneDimension(OS, Flags, Dimensions->Nodes[0]);
530 for (size_t I = 1; I < Dimensions->Count; ++I) {
531 OS << "][";
532 outputOneDimension(OS, Flags, Dimensions->Nodes[I]);
533 }
534}
535
536void ArrayTypeNode::outputPost(OutputStream &OS, OutputFlags Flags) const {
537 OS << "[";
538 outputDimensionsImpl(OS, Flags);
539 OS << "]";
540
541 ElementType->outputPost(OS, Flags);
542}
543
544void SymbolNode::output(OutputStream &OS, OutputFlags Flags) const {
545 Name->output(OS, Flags);
546}
547
548void FunctionSymbolNode::output(OutputStream &OS, OutputFlags Flags) const {
549 Signature->outputPre(OS, Flags);
550 outputSpaceIfNecessary(OS);
551 Name->output(OS, Flags);
552 Signature->outputPost(OS, Flags);
553}
554
555void VariableSymbolNode::output(OutputStream &OS, OutputFlags Flags) const {
556 switch (SC) {
557 case StorageClass::PrivateStatic:
558 case StorageClass::PublicStatic:
559 case StorageClass::ProtectedStatic:
560 OS << "static ";
561 default:
562 break;
563 }
564
565 if (Type) {
566 Type->outputPre(OS, Flags);
567 outputSpaceIfNecessary(OS);
568 }
569 Name->output(OS, Flags);
570 if (Type)
571 Type->outputPost(OS, Flags);
572}
573
574void CustomTypeNode::outputPre(OutputStream &OS, OutputFlags Flags) const {
575 Identifier->output(OS, Flags);
576}
577void CustomTypeNode::outputPost(OutputStream &OS, OutputFlags Flags) const {}
578
579void QualifiedNameNode::output(OutputStream &OS, OutputFlags Flags) const {
580 Components->output(OS, Flags, "::");
581}
582
583void RttiBaseClassDescriptorNode::output(OutputStream &OS,
584 OutputFlags Flags) const {
585 OS << "`RTTI Base Class Descriptor at (";
586 OS << NVOffset << ", " << VBPtrOffset << ", " << VBTableOffset << ", "
587 << this->Flags;
588 OS << ")'";
589}
590
591void LocalStaticGuardVariableNode::output(OutputStream &OS,
592 OutputFlags Flags) const {
593 Name->output(OS, Flags);
594}
595
596void VcallThunkIdentifierNode::output(OutputStream &OS,
597 OutputFlags Flags) const {
598 OS << "`vcall'{" << OffsetInVTable << ", {flat}}";
599}
600
601void SpecialTableSymbolNode::output(OutputStream &OS, OutputFlags Flags) const {
602 outputQualifiers(OS, Quals, false, true);
603 Name->output(OS, Flags);
604 if (TargetName) {
605 OS << "{for `";
606 TargetName->output(OS, Flags);
607 OS << "'}";
608 }
609 return;
610}