Bug Summary

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