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