Bug Summary

File:build-llvm/tools/lldb/../clang/include/clang/AST/Attrs.inc
Warning:line 1151, column 5
Called C++ object pointer is null

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 ClangASTContext.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 HAVE_ROUND -D LLDB_CONFIGURATION_RELEASE -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/tools/lldb/source/Symbol -I /build/llvm-toolchain-snapshot-8~svn345461/tools/lldb/source/Symbol -I /build/llvm-toolchain-snapshot-8~svn345461/build-llvm/tools/lldb/include -I /build/llvm-toolchain-snapshot-8~svn345461/tools/lldb/include -I /build/llvm-toolchain-snapshot-8~svn345461/build-llvm/include -I /build/llvm-toolchain-snapshot-8~svn345461/include -I /usr/include/python2.7 -I /build/llvm-toolchain-snapshot-8~svn345461/tools/clang/include -I /build/llvm-toolchain-snapshot-8~svn345461/build-llvm/tools/lldb/../clang/include -I /build/llvm-toolchain-snapshot-8~svn345461/tools/lldb/source/. -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 -Wno-deprecated-declarations -Wno-unknown-pragmas -Wno-strict-aliasing -Wno-deprecated-register -Wno-vla-extension -std=c++11 -fdeprecated-macro -fdebug-compilation-dir /build/llvm-toolchain-snapshot-8~svn345461/build-llvm/tools/lldb/source/Symbol -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/tools/lldb/source/Symbol/ClangASTContext.cpp -faddrsig

/build/llvm-toolchain-snapshot-8~svn345461/tools/lldb/source/Symbol/ClangASTContext.cpp

1//===-- ClangASTContext.cpp -------------------------------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#include "lldb/Symbol/ClangASTContext.h"
11
12#include "llvm/Support/FormatAdapters.h"
13#include "llvm/Support/FormatVariadic.h"
14
15// C Includes
16// C++ Includes
17#include <mutex>
18#include <string>
19#include <vector>
20
21// Other libraries and framework includes
22
23// Clang headers like to use NDEBUG inside of them to enable/disable debug
24// related features using "#ifndef NDEBUG" preprocessor blocks to do one thing
25// or another. This is bad because it means that if clang was built in release
26// mode, it assumes that you are building in release mode which is not always
27// the case. You can end up with functions that are defined as empty in header
28// files when NDEBUG is not defined, and this can cause link errors with the
29// clang .a files that you have since you might be missing functions in the .a
30// file. So we have to define NDEBUG when including clang headers to avoid any
31// mismatches. This is covered by rdar://problem/8691220
32
33#if !defined(NDEBUG) && !defined(LLVM_NDEBUG_OFF)
34#define LLDB_DEFINED_NDEBUG_FOR_CLANG
35#define NDEBUG
36// Need to include assert.h so it is as clang would expect it to be (disabled)
37#include <assert.h>
38#endif
39
40#include "clang/AST/ASTContext.h"
41#include "clang/AST/ASTImporter.h"
42#include "clang/AST/Attr.h"
43#include "clang/AST/CXXInheritance.h"
44#include "clang/AST/DeclObjC.h"
45#include "clang/AST/DeclTemplate.h"
46#include "clang/AST/Mangle.h"
47#include "clang/AST/RecordLayout.h"
48#include "clang/AST/Type.h"
49#include "clang/AST/VTableBuilder.h"
50#include "clang/Basic/Builtins.h"
51#include "clang/Basic/Diagnostic.h"
52#include "clang/Basic/FileManager.h"
53#include "clang/Basic/FileSystemOptions.h"
54#include "clang/Basic/SourceManager.h"
55#include "clang/Basic/TargetInfo.h"
56#include "clang/Basic/TargetOptions.h"
57#include "clang/Frontend/FrontendOptions.h"
58#include "clang/Frontend/LangStandard.h"
59
60#ifdef LLDB_DEFINED_NDEBUG_FOR_CLANG
61#undef NDEBUG
62#undef LLDB_DEFINED_NDEBUG_FOR_CLANG
63// Need to re-include assert.h so it is as _we_ would expect it to be (enabled)
64#include <assert.h>
65#endif
66
67#include "llvm/Support/Signals.h"
68#include "llvm/Support/Threading.h"
69
70#include "Plugins/ExpressionParser/Clang/ClangFunctionCaller.h"
71#include "Plugins/ExpressionParser/Clang/ClangUserExpression.h"
72#include "Plugins/ExpressionParser/Clang/ClangUtilityFunction.h"
73#include "lldb/Utility/ArchSpec.h"
74#include "lldb/Utility/Flags.h"
75
76#include "lldb/Core/DumpDataExtractor.h"
77#include "lldb/Core/Module.h"
78#include "lldb/Core/PluginManager.h"
79#include "lldb/Core/StreamFile.h"
80#include "lldb/Core/ThreadSafeDenseMap.h"
81#include "lldb/Core/UniqueCStringMap.h"
82#include "lldb/Symbol/ClangASTContext.h"
83#include "lldb/Symbol/ClangASTImporter.h"
84#include "lldb/Symbol/ClangExternalASTSourceCallbacks.h"
85#include "lldb/Symbol/ClangExternalASTSourceCommon.h"
86#include "lldb/Symbol/ClangUtil.h"
87#include "lldb/Symbol/ObjectFile.h"
88#include "lldb/Symbol/SymbolFile.h"
89#include "lldb/Symbol/VerifyDecl.h"
90#include "lldb/Target/ExecutionContext.h"
91#include "lldb/Target/Language.h"
92#include "lldb/Target/ObjCLanguageRuntime.h"
93#include "lldb/Target/Process.h"
94#include "lldb/Target/Target.h"
95#include "lldb/Utility/DataExtractor.h"
96#include "lldb/Utility/LLDBAssert.h"
97#include "lldb/Utility/Log.h"
98#include "lldb/Utility/RegularExpression.h"
99#include "lldb/Utility/Scalar.h"
100
101#include "Plugins/SymbolFile/DWARF/DWARFASTParserClang.h"
102#include "Plugins/SymbolFile/PDB/PDBASTParser.h"
103
104#include <stdio.h>
105
106#include <mutex>
107
108using namespace lldb;
109using namespace lldb_private;
110using namespace llvm;
111using namespace clang;
112
113namespace {
114static inline bool
115ClangASTContextSupportsLanguage(lldb::LanguageType language) {
116 return language == eLanguageTypeUnknown || // Clang is the default type system
117 Language::LanguageIsC(language) ||
118 Language::LanguageIsCPlusPlus(language) ||
119 Language::LanguageIsObjC(language) ||
120 Language::LanguageIsPascal(language) ||
121 // Use Clang for Rust until there is a proper language plugin for it
122 language == eLanguageTypeRust ||
123 language == eLanguageTypeExtRenderScript ||
124 // Use Clang for D until there is a proper language plugin for it
125 language == eLanguageTypeD;
126}
127
128// Checks whether m1 is an overload of m2 (as opposed to an override). This is
129// called by addOverridesForMethod to distinguish overrides (which share a
130// vtable entry) from overloads (which require distinct entries).
131bool isOverload(clang::CXXMethodDecl *m1, clang::CXXMethodDecl *m2) {
132 // FIXME: This should detect covariant return types, but currently doesn't.
133 lldbassert(&m1->getASTContext() == &m2->getASTContext() &&lldb_private::lldb_assert(static_cast<bool>(&m1->
getASTContext() == &m2->getASTContext() && "Methods should have the same AST context"
), "&m1->getASTContext() == &m2->getASTContext() && \"Methods should have the same AST context\""
, __FUNCTION__, "/build/llvm-toolchain-snapshot-8~svn345461/tools/lldb/source/Symbol/ClangASTContext.cpp"
, 134)
134 "Methods should have the same AST context")lldb_private::lldb_assert(static_cast<bool>(&m1->
getASTContext() == &m2->getASTContext() && "Methods should have the same AST context"
), "&m1->getASTContext() == &m2->getASTContext() && \"Methods should have the same AST context\""
, __FUNCTION__, "/build/llvm-toolchain-snapshot-8~svn345461/tools/lldb/source/Symbol/ClangASTContext.cpp"
, 134)
;
135 clang::ASTContext &context = m1->getASTContext();
136
137 const auto *m1Type = llvm::cast<clang::FunctionProtoType>(
138 context.getCanonicalType(m1->getType()));
139
140 const auto *m2Type = llvm::cast<clang::FunctionProtoType>(
141 context.getCanonicalType(m2->getType()));
142
143 auto compareArgTypes = [&context](const clang::QualType &m1p,
144 const clang::QualType &m2p) {
145 return context.hasSameType(m1p.getUnqualifiedType(),
146 m2p.getUnqualifiedType());
147 };
148
149 // FIXME: In C++14 and later, we can just pass m2Type->param_type_end()
150 // as a fourth parameter to std::equal().
151 return (m1->getNumParams() != m2->getNumParams()) ||
152 !std::equal(m1Type->param_type_begin(), m1Type->param_type_end(),
153 m2Type->param_type_begin(), compareArgTypes);
154}
155
156// If decl is a virtual method, walk the base classes looking for methods that
157// decl overrides. This table of overridden methods is used by IRGen to
158// determine the vtable layout for decl's parent class.
159void addOverridesForMethod(clang::CXXMethodDecl *decl) {
160 if (!decl->isVirtual())
161 return;
162
163 clang::CXXBasePaths paths;
164
165 auto find_overridden_methods =
166 [decl](const clang::CXXBaseSpecifier *specifier,
167 clang::CXXBasePath &path) {
168 if (auto *base_record = llvm::dyn_cast<clang::CXXRecordDecl>(
169 specifier->getType()->getAs<clang::RecordType>()->getDecl())) {
170
171 clang::DeclarationName name = decl->getDeclName();
172
173 // If this is a destructor, check whether the base class destructor is
174 // virtual.
175 if (name.getNameKind() == clang::DeclarationName::CXXDestructorName)
176 if (auto *baseDtorDecl = base_record->getDestructor()) {
177 if (baseDtorDecl->isVirtual()) {
178 path.Decls = baseDtorDecl;
179 return true;
180 } else
181 return false;
182 }
183
184 // Otherwise, search for name in the base class.
185 for (path.Decls = base_record->lookup(name); !path.Decls.empty();
186 path.Decls = path.Decls.slice(1)) {
187 if (auto *method_decl =
188 llvm::dyn_cast<clang::CXXMethodDecl>(path.Decls.front()))
189 if (method_decl->isVirtual() && !isOverload(decl, method_decl)) {
190 path.Decls = method_decl;
191 return true;
192 }
193 }
194 }
195
196 return false;
197 };
198
199 if (decl->getParent()->lookupInBases(find_overridden_methods, paths)) {
200 for (auto *overridden_decl : paths.found_decls())
201 decl->addOverriddenMethod(
202 llvm::cast<clang::CXXMethodDecl>(overridden_decl));
203 }
204}
205}
206
207typedef lldb_private::ThreadSafeDenseMap<clang::ASTContext *, ClangASTContext *>
208 ClangASTMap;
209
210static ClangASTMap &GetASTMap() {
211 static ClangASTMap *g_map_ptr = nullptr;
212 static llvm::once_flag g_once_flag;
213 llvm::call_once(g_once_flag, []() {
214 g_map_ptr = new ClangASTMap(); // leaked on purpose to avoid spins
215 });
216 return *g_map_ptr;
217}
218
219bool ClangASTContext::IsOperator(const char *name,
220 clang::OverloadedOperatorKind &op_kind) {
221 if (name == nullptr || name[0] == '\0')
222 return false;
223
224#define OPERATOR_PREFIX "operator"
225#define OPERATOR_PREFIX_LENGTH (sizeof(OPERATOR_PREFIX) - 1)
226
227 const char *post_op_name = nullptr;
228
229 bool no_space = true;
230
231 if (::strncmp(name, OPERATOR_PREFIX, OPERATOR_PREFIX_LENGTH))
232 return false;
233
234 post_op_name = name + OPERATOR_PREFIX_LENGTH;
235
236 if (post_op_name[0] == ' ') {
237 post_op_name++;
238 no_space = false;
239 }
240
241#undef OPERATOR_PREFIX
242#undef OPERATOR_PREFIX_LENGTH
243
244 // This is an operator, set the overloaded operator kind to invalid in case
245 // this is a conversion operator...
246 op_kind = clang::NUM_OVERLOADED_OPERATORS;
247
248 switch (post_op_name[0]) {
249 default:
250 if (no_space)
251 return false;
252 break;
253 case 'n':
254 if (no_space)
255 return false;
256 if (strcmp(post_op_name, "new") == 0)
257 op_kind = clang::OO_New;
258 else if (strcmp(post_op_name, "new[]") == 0)
259 op_kind = clang::OO_Array_New;
260 break;
261
262 case 'd':
263 if (no_space)
264 return false;
265 if (strcmp(post_op_name, "delete") == 0)
266 op_kind = clang::OO_Delete;
267 else if (strcmp(post_op_name, "delete[]") == 0)
268 op_kind = clang::OO_Array_Delete;
269 break;
270
271 case '+':
272 if (post_op_name[1] == '\0')
273 op_kind = clang::OO_Plus;
274 else if (post_op_name[2] == '\0') {
275 if (post_op_name[1] == '=')
276 op_kind = clang::OO_PlusEqual;
277 else if (post_op_name[1] == '+')
278 op_kind = clang::OO_PlusPlus;
279 }
280 break;
281
282 case '-':
283 if (post_op_name[1] == '\0')
284 op_kind = clang::OO_Minus;
285 else if (post_op_name[2] == '\0') {
286 switch (post_op_name[1]) {
287 case '=':
288 op_kind = clang::OO_MinusEqual;
289 break;
290 case '-':
291 op_kind = clang::OO_MinusMinus;
292 break;
293 case '>':
294 op_kind = clang::OO_Arrow;
295 break;
296 }
297 } else if (post_op_name[3] == '\0') {
298 if (post_op_name[2] == '*')
299 op_kind = clang::OO_ArrowStar;
300 break;
301 }
302 break;
303
304 case '*':
305 if (post_op_name[1] == '\0')
306 op_kind = clang::OO_Star;
307 else if (post_op_name[1] == '=' && post_op_name[2] == '\0')
308 op_kind = clang::OO_StarEqual;
309 break;
310
311 case '/':
312 if (post_op_name[1] == '\0')
313 op_kind = clang::OO_Slash;
314 else if (post_op_name[1] == '=' && post_op_name[2] == '\0')
315 op_kind = clang::OO_SlashEqual;
316 break;
317
318 case '%':
319 if (post_op_name[1] == '\0')
320 op_kind = clang::OO_Percent;
321 else if (post_op_name[1] == '=' && post_op_name[2] == '\0')
322 op_kind = clang::OO_PercentEqual;
323 break;
324
325 case '^':
326 if (post_op_name[1] == '\0')
327 op_kind = clang::OO_Caret;
328 else if (post_op_name[1] == '=' && post_op_name[2] == '\0')
329 op_kind = clang::OO_CaretEqual;
330 break;
331
332 case '&':
333 if (post_op_name[1] == '\0')
334 op_kind = clang::OO_Amp;
335 else if (post_op_name[2] == '\0') {
336 switch (post_op_name[1]) {
337 case '=':
338 op_kind = clang::OO_AmpEqual;
339 break;
340 case '&':
341 op_kind = clang::OO_AmpAmp;
342 break;
343 }
344 }
345 break;
346
347 case '|':
348 if (post_op_name[1] == '\0')
349 op_kind = clang::OO_Pipe;
350 else if (post_op_name[2] == '\0') {
351 switch (post_op_name[1]) {
352 case '=':
353 op_kind = clang::OO_PipeEqual;
354 break;
355 case '|':
356 op_kind = clang::OO_PipePipe;
357 break;
358 }
359 }
360 break;
361
362 case '~':
363 if (post_op_name[1] == '\0')
364 op_kind = clang::OO_Tilde;
365 break;
366
367 case '!':
368 if (post_op_name[1] == '\0')
369 op_kind = clang::OO_Exclaim;
370 else if (post_op_name[1] == '=' && post_op_name[2] == '\0')
371 op_kind = clang::OO_ExclaimEqual;
372 break;
373
374 case '=':
375 if (post_op_name[1] == '\0')
376 op_kind = clang::OO_Equal;
377 else if (post_op_name[1] == '=' && post_op_name[2] == '\0')
378 op_kind = clang::OO_EqualEqual;
379 break;
380
381 case '<':
382 if (post_op_name[1] == '\0')
383 op_kind = clang::OO_Less;
384 else if (post_op_name[2] == '\0') {
385 switch (post_op_name[1]) {
386 case '<':
387 op_kind = clang::OO_LessLess;
388 break;
389 case '=':
390 op_kind = clang::OO_LessEqual;
391 break;
392 }
393 } else if (post_op_name[3] == '\0') {
394 if (post_op_name[2] == '=')
395 op_kind = clang::OO_LessLessEqual;
396 }
397 break;
398
399 case '>':
400 if (post_op_name[1] == '\0')
401 op_kind = clang::OO_Greater;
402 else if (post_op_name[2] == '\0') {
403 switch (post_op_name[1]) {
404 case '>':
405 op_kind = clang::OO_GreaterGreater;
406 break;
407 case '=':
408 op_kind = clang::OO_GreaterEqual;
409 break;
410 }
411 } else if (post_op_name[1] == '>' && post_op_name[2] == '=' &&
412 post_op_name[3] == '\0') {
413 op_kind = clang::OO_GreaterGreaterEqual;
414 }
415 break;
416
417 case ',':
418 if (post_op_name[1] == '\0')
419 op_kind = clang::OO_Comma;
420 break;
421
422 case '(':
423 if (post_op_name[1] == ')' && post_op_name[2] == '\0')
424 op_kind = clang::OO_Call;
425 break;
426
427 case '[':
428 if (post_op_name[1] == ']' && post_op_name[2] == '\0')
429 op_kind = clang::OO_Subscript;
430 break;
431 }
432
433 return true;
434}
435
436clang::AccessSpecifier
437ClangASTContext::ConvertAccessTypeToAccessSpecifier(AccessType access) {
438 switch (access) {
439 default:
440 break;
441 case eAccessNone:
442 return AS_none;
443 case eAccessPublic:
444 return AS_public;
445 case eAccessPrivate:
446 return AS_private;
447 case eAccessProtected:
448 return AS_protected;
449 }
450 return AS_none;
451}
452
453static void ParseLangArgs(LangOptions &Opts, InputKind IK, const char *triple) {
454 // FIXME: Cleanup per-file based stuff.
455
456 // Set some properties which depend solely on the input kind; it would be
457 // nice to move these to the language standard, and have the driver resolve
458 // the input kind + language standard.
459 if (IK.getLanguage() == InputKind::Asm) {
460 Opts.AsmPreprocessor = 1;
461 } else if (IK.isObjectiveC()) {
462 Opts.ObjC1 = Opts.ObjC2 = 1;
463 }
464
465 LangStandard::Kind LangStd = LangStandard::lang_unspecified;
466
467 if (LangStd == LangStandard::lang_unspecified) {
468 // Based on the base language, pick one.
469 switch (IK.getLanguage()) {
470 case InputKind::Unknown:
471 case InputKind::LLVM_IR:
472 case InputKind::RenderScript:
473 llvm_unreachable("Invalid input kind!")::llvm::llvm_unreachable_internal("Invalid input kind!", "/build/llvm-toolchain-snapshot-8~svn345461/tools/lldb/source/Symbol/ClangASTContext.cpp"
, 473)
;
474 case InputKind::OpenCL:
475 LangStd = LangStandard::lang_opencl10;
476 break;
477 case InputKind::CUDA:
478 LangStd = LangStandard::lang_cuda;
479 break;
480 case InputKind::Asm:
481 case InputKind::C:
482 case InputKind::ObjC:
483 LangStd = LangStandard::lang_gnu99;
484 break;
485 case InputKind::CXX:
486 case InputKind::ObjCXX:
487 LangStd = LangStandard::lang_gnucxx98;
488 break;
489 case InputKind::HIP:
490 LangStd = LangStandard::lang_hip;
491 break;
492 }
493 }
494
495 const LangStandard &Std = LangStandard::getLangStandardForKind(LangStd);
496 Opts.LineComment = Std.hasLineComments();
497 Opts.C99 = Std.isC99();
498 Opts.CPlusPlus = Std.isCPlusPlus();
499 Opts.CPlusPlus11 = Std.isCPlusPlus11();
500 Opts.Digraphs = Std.hasDigraphs();
501 Opts.GNUMode = Std.isGNUMode();
502 Opts.GNUInline = !Std.isC99();
503 Opts.HexFloats = Std.hasHexFloats();
504 Opts.ImplicitInt = Std.hasImplicitInt();
505
506 Opts.WChar = true;
507
508 // OpenCL has some additional defaults.
509 if (LangStd == LangStandard::lang_opencl10) {
510 Opts.OpenCL = 1;
511 Opts.AltiVec = 1;
512 Opts.CXXOperatorNames = 1;
513 Opts.LaxVectorConversions = 1;
514 }
515
516 // OpenCL and C++ both have bool, true, false keywords.
517 Opts.Bool = Opts.OpenCL || Opts.CPlusPlus;
518
519 Opts.setValueVisibilityMode(DefaultVisibility);
520
521 // Mimicing gcc's behavior, trigraphs are only enabled if -trigraphs is
522 // specified, or -std is set to a conforming mode.
523 Opts.Trigraphs = !Opts.GNUMode;
524 Opts.CharIsSigned = ArchSpec(triple).CharIsSignedByDefault();
525 Opts.OptimizeSize = 0;
526
527 // FIXME: Eliminate this dependency.
528 // unsigned Opt =
529 // Args.hasArg(OPT_Os) ? 2 : getLastArgIntValue(Args, OPT_O, 0, Diags);
530 // Opts.Optimize = Opt != 0;
531 unsigned Opt = 0;
532
533 // This is the __NO_INLINE__ define, which just depends on things like the
534 // optimization level and -fno-inline, not actually whether the backend has
535 // inlining enabled.
536 //
537 // FIXME: This is affected by other options (-fno-inline).
538 Opts.NoInlineDefine = !Opt;
539}
540
541ClangASTContext::ClangASTContext(const char *target_triple)
542 : TypeSystem(TypeSystem::eKindClang), m_target_triple(), m_ast_ap(),
543 m_language_options_ap(), m_source_manager_ap(), m_diagnostics_engine_ap(),
544 m_target_options_rp(), m_target_info_ap(), m_identifier_table_ap(),
545 m_selector_table_ap(), m_builtins_ap(), m_callback_tag_decl(nullptr),
546 m_callback_objc_decl(nullptr), m_callback_baton(nullptr),
547 m_pointer_byte_size(0), m_ast_owned(false) {
548 if (target_triple && target_triple[0])
549 SetTargetTriple(target_triple);
550}
551
552//----------------------------------------------------------------------
553// Destructor
554//----------------------------------------------------------------------
555ClangASTContext::~ClangASTContext() { Finalize(); }
556
557ConstString ClangASTContext::GetPluginNameStatic() {
558 return ConstString("clang");
559}
560
561ConstString ClangASTContext::GetPluginName() {
562 return ClangASTContext::GetPluginNameStatic();
563}
564
565uint32_t ClangASTContext::GetPluginVersion() { return 1; }
566
567lldb::TypeSystemSP ClangASTContext::CreateInstance(lldb::LanguageType language,
568 lldb_private::Module *module,
569 Target *target) {
570 if (ClangASTContextSupportsLanguage(language)) {
571 ArchSpec arch;
572 if (module)
573 arch = module->GetArchitecture();
574 else if (target)
575 arch = target->GetArchitecture();
576
577 if (arch.IsValid()) {
578 ArchSpec fixed_arch = arch;
579 // LLVM wants this to be set to iOS or MacOSX; if we're working on
580 // a bare-boards type image, change the triple for llvm's benefit.
581 if (fixed_arch.GetTriple().getVendor() == llvm::Triple::Apple &&
582 fixed_arch.GetTriple().getOS() == llvm::Triple::UnknownOS) {
583 if (fixed_arch.GetTriple().getArch() == llvm::Triple::arm ||
584 fixed_arch.GetTriple().getArch() == llvm::Triple::aarch64 ||
585 fixed_arch.GetTriple().getArch() == llvm::Triple::thumb) {
586 fixed_arch.GetTriple().setOS(llvm::Triple::IOS);
587 } else {
588 fixed_arch.GetTriple().setOS(llvm::Triple::MacOSX);
589 }
590 }
591
592 if (module) {
593 std::shared_ptr<ClangASTContext> ast_sp(new ClangASTContext);
594 if (ast_sp) {
595 ast_sp->SetArchitecture(fixed_arch);
596 }
597 return ast_sp;
598 } else if (target && target->IsValid()) {
599 std::shared_ptr<ClangASTContextForExpressions> ast_sp(
600 new ClangASTContextForExpressions(*target));
601 if (ast_sp) {
602 ast_sp->SetArchitecture(fixed_arch);
603 ast_sp->m_scratch_ast_source_ap.reset(
604 new ClangASTSource(target->shared_from_this()));
605 lldbassert(ast_sp->getFileManager())lldb_private::lldb_assert(static_cast<bool>(ast_sp->
getFileManager()), "ast_sp->getFileManager()", __FUNCTION__
, "/build/llvm-toolchain-snapshot-8~svn345461/tools/lldb/source/Symbol/ClangASTContext.cpp"
, 605)
;
606 ast_sp->m_scratch_ast_source_ap->InstallASTContext(
607 *ast_sp->getASTContext(), *ast_sp->getFileManager(), true);
608 llvm::IntrusiveRefCntPtr<clang::ExternalASTSource> proxy_ast_source(
609 ast_sp->m_scratch_ast_source_ap->CreateProxy());
610 ast_sp->SetExternalSource(proxy_ast_source);
611 return ast_sp;
612 }
613 }
614 }
615 }
616 return lldb::TypeSystemSP();
617}
618
619void ClangASTContext::EnumerateSupportedLanguages(
620 std::set<lldb::LanguageType> &languages_for_types,
621 std::set<lldb::LanguageType> &languages_for_expressions) {
622 static std::vector<lldb::LanguageType> s_supported_languages_for_types(
623 {lldb::eLanguageTypeC89, lldb::eLanguageTypeC, lldb::eLanguageTypeC11,
624 lldb::eLanguageTypeC_plus_plus, lldb::eLanguageTypeC99,
625 lldb::eLanguageTypeObjC, lldb::eLanguageTypeObjC_plus_plus,
626 lldb::eLanguageTypeC_plus_plus_03, lldb::eLanguageTypeC_plus_plus_11,
627 lldb::eLanguageTypeC11, lldb::eLanguageTypeC_plus_plus_14});
628
629 static std::vector<lldb::LanguageType> s_supported_languages_for_expressions(
630 {lldb::eLanguageTypeC_plus_plus, lldb::eLanguageTypeObjC_plus_plus,
631 lldb::eLanguageTypeC_plus_plus_03, lldb::eLanguageTypeC_plus_plus_11,
632 lldb::eLanguageTypeC_plus_plus_14});
633
634 languages_for_types.insert(s_supported_languages_for_types.begin(),
635 s_supported_languages_for_types.end());
636 languages_for_expressions.insert(
637 s_supported_languages_for_expressions.begin(),
638 s_supported_languages_for_expressions.end());
639}
640
641void ClangASTContext::Initialize() {
642 PluginManager::RegisterPlugin(GetPluginNameStatic(),
643 "clang base AST context plug-in",
644 CreateInstance, EnumerateSupportedLanguages);
645}
646
647void ClangASTContext::Terminate() {
648 PluginManager::UnregisterPlugin(CreateInstance);
649}
650
651void ClangASTContext::Finalize() {
652 if (m_ast_ap.get()) {
653 GetASTMap().Erase(m_ast_ap.get());
654 if (!m_ast_owned)
655 m_ast_ap.release();
656 }
657
658 m_builtins_ap.reset();
659 m_selector_table_ap.reset();
660 m_identifier_table_ap.reset();
661 m_target_info_ap.reset();
662 m_target_options_rp.reset();
663 m_diagnostics_engine_ap.reset();
664 m_source_manager_ap.reset();
665 m_language_options_ap.reset();
666 m_ast_ap.reset();
667 m_scratch_ast_source_ap.reset();
668}
669
670void ClangASTContext::Clear() {
671 m_ast_ap.reset();
672 m_language_options_ap.reset();
673 m_source_manager_ap.reset();
674 m_diagnostics_engine_ap.reset();
675 m_target_options_rp.reset();
676 m_target_info_ap.reset();
677 m_identifier_table_ap.reset();
678 m_selector_table_ap.reset();
679 m_builtins_ap.reset();
680 m_pointer_byte_size = 0;
681}
682
683const char *ClangASTContext::GetTargetTriple() {
684 return m_target_triple.c_str();
685}
686
687void ClangASTContext::SetTargetTriple(const char *target_triple) {
688 Clear();
689 m_target_triple.assign(target_triple);
690}
691
692void ClangASTContext::SetArchitecture(const ArchSpec &arch) {
693 SetTargetTriple(arch.GetTriple().str().c_str());
694}
695
696bool ClangASTContext::HasExternalSource() {
697 ASTContext *ast = getASTContext();
698 if (ast)
699 return ast->getExternalSource() != nullptr;
700 return false;
701}
702
703void ClangASTContext::SetExternalSource(
704 llvm::IntrusiveRefCntPtr<ExternalASTSource> &ast_source_ap) {
705 ASTContext *ast = getASTContext();
706 if (ast) {
707 ast->setExternalSource(ast_source_ap);
708 ast->getTranslationUnitDecl()->setHasExternalLexicalStorage(true);
709 }
710}
711
712void ClangASTContext::RemoveExternalSource() {
713 ASTContext *ast = getASTContext();
714
715 if (ast) {
716 llvm::IntrusiveRefCntPtr<ExternalASTSource> empty_ast_source_ap;
717 ast->setExternalSource(empty_ast_source_ap);
718 ast->getTranslationUnitDecl()->setHasExternalLexicalStorage(false);
719 }
720}
721
722void ClangASTContext::setASTContext(clang::ASTContext *ast_ctx) {
723 if (!m_ast_owned) {
724 m_ast_ap.release();
725 }
726 m_ast_owned = false;
727 m_ast_ap.reset(ast_ctx);
728 GetASTMap().Insert(ast_ctx, this);
729}
730
731ASTContext *ClangASTContext::getASTContext() {
732 if (m_ast_ap.get() == nullptr) {
733 m_ast_owned = true;
734 m_ast_ap.reset(new ASTContext(*getLanguageOptions(), *getSourceManager(),
735 *getIdentifierTable(), *getSelectorTable(),
736 *getBuiltinContext()));
737
738 m_ast_ap->getDiagnostics().setClient(getDiagnosticConsumer(), false);
739
740 // This can be NULL if we don't know anything about the architecture or if
741 // the target for an architecture isn't enabled in the llvm/clang that we
742 // built
743 TargetInfo *target_info = getTargetInfo();
744 if (target_info)
745 m_ast_ap->InitBuiltinTypes(*target_info);
746
747 if ((m_callback_tag_decl || m_callback_objc_decl) && m_callback_baton) {
748 m_ast_ap->getTranslationUnitDecl()->setHasExternalLexicalStorage();
749 // m_ast_ap->getTranslationUnitDecl()->setHasExternalVisibleStorage();
750 }
751
752 GetASTMap().Insert(m_ast_ap.get(), this);
753
754 llvm::IntrusiveRefCntPtr<clang::ExternalASTSource> ast_source_ap(
755 new ClangExternalASTSourceCallbacks(
756 ClangASTContext::CompleteTagDecl,
757 ClangASTContext::CompleteObjCInterfaceDecl, nullptr,
758 ClangASTContext::LayoutRecordType, this));
759 SetExternalSource(ast_source_ap);
760 }
761 return m_ast_ap.get();
762}
763
764ClangASTContext *ClangASTContext::GetASTContext(clang::ASTContext *ast) {
765 ClangASTContext *clang_ast = GetASTMap().Lookup(ast);
766 return clang_ast;
767}
768
769Builtin::Context *ClangASTContext::getBuiltinContext() {
770 if (m_builtins_ap.get() == nullptr)
771 m_builtins_ap.reset(new Builtin::Context());
772 return m_builtins_ap.get();
773}
774
775IdentifierTable *ClangASTContext::getIdentifierTable() {
776 if (m_identifier_table_ap.get() == nullptr)
777 m_identifier_table_ap.reset(
778 new IdentifierTable(*ClangASTContext::getLanguageOptions(), nullptr));
779 return m_identifier_table_ap.get();
780}
781
782LangOptions *ClangASTContext::getLanguageOptions() {
783 if (m_language_options_ap.get() == nullptr) {
784 m_language_options_ap.reset(new LangOptions());
785 ParseLangArgs(*m_language_options_ap, InputKind::ObjCXX, GetTargetTriple());
786 // InitializeLangOptions(*m_language_options_ap, InputKind::ObjCXX);
787 }
788 return m_language_options_ap.get();
789}
790
791SelectorTable *ClangASTContext::getSelectorTable() {
792 if (m_selector_table_ap.get() == nullptr)
793 m_selector_table_ap.reset(new SelectorTable());
794 return m_selector_table_ap.get();
795}
796
797clang::FileManager *ClangASTContext::getFileManager() {
798 if (m_file_manager_ap.get() == nullptr) {
799 clang::FileSystemOptions file_system_options;
800 m_file_manager_ap.reset(new clang::FileManager(file_system_options));
801 }
802 return m_file_manager_ap.get();
803}
804
805clang::SourceManager *ClangASTContext::getSourceManager() {
806 if (m_source_manager_ap.get() == nullptr)
807 m_source_manager_ap.reset(
808 new clang::SourceManager(*getDiagnosticsEngine(), *getFileManager()));
809 return m_source_manager_ap.get();
810}
811
812clang::DiagnosticsEngine *ClangASTContext::getDiagnosticsEngine() {
813 if (m_diagnostics_engine_ap.get() == nullptr) {
814 llvm::IntrusiveRefCntPtr<DiagnosticIDs> diag_id_sp(new DiagnosticIDs());
815 m_diagnostics_engine_ap.reset(
816 new DiagnosticsEngine(diag_id_sp, new DiagnosticOptions()));
817 }
818 return m_diagnostics_engine_ap.get();
819}
820
821clang::MangleContext *ClangASTContext::getMangleContext() {
822 if (m_mangle_ctx_ap.get() == nullptr)
823 m_mangle_ctx_ap.reset(getASTContext()->createMangleContext());
824 return m_mangle_ctx_ap.get();
825}
826
827class NullDiagnosticConsumer : public DiagnosticConsumer {
828public:
829 NullDiagnosticConsumer() {
830 m_log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS(1u << 8));
831 }
832
833 void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
834 const clang::Diagnostic &info) {
835 if (m_log) {
836 llvm::SmallVector<char, 32> diag_str(10);
837 info.FormatDiagnostic(diag_str);
838 diag_str.push_back('\0');
839 m_log->Printf("Compiler diagnostic: %s\n", diag_str.data());
840 }
841 }
842
843 DiagnosticConsumer *clone(DiagnosticsEngine &Diags) const {
844 return new NullDiagnosticConsumer();
845 }
846
847private:
848 Log *m_log;
849};
850
851DiagnosticConsumer *ClangASTContext::getDiagnosticConsumer() {
852 if (m_diagnostic_consumer_ap.get() == nullptr)
853 m_diagnostic_consumer_ap.reset(new NullDiagnosticConsumer);
854
855 return m_diagnostic_consumer_ap.get();
856}
857
858std::shared_ptr<clang::TargetOptions> &ClangASTContext::getTargetOptions() {
859 if (m_target_options_rp.get() == nullptr && !m_target_triple.empty()) {
860 m_target_options_rp = std::make_shared<clang::TargetOptions>();
861 if (m_target_options_rp.get() != nullptr)
862 m_target_options_rp->Triple = m_target_triple;
863 }
864 return m_target_options_rp;
865}
866
867TargetInfo *ClangASTContext::getTargetInfo() {
868 // target_triple should be something like "x86_64-apple-macosx"
869 if (m_target_info_ap.get() == nullptr && !m_target_triple.empty())
870 m_target_info_ap.reset(TargetInfo::CreateTargetInfo(*getDiagnosticsEngine(),
871 getTargetOptions()));
872 return m_target_info_ap.get();
873}
874
875#pragma mark Basic Types
876
877static inline bool QualTypeMatchesBitSize(const uint64_t bit_size,
878 ASTContext *ast, QualType qual_type) {
879 uint64_t qual_type_bit_size = ast->getTypeSize(qual_type);
880 if (qual_type_bit_size == bit_size)
881 return true;
882 return false;
883}
884
885CompilerType
886ClangASTContext::GetBuiltinTypeForEncodingAndBitSize(Encoding encoding,
887 size_t bit_size) {
888 return ClangASTContext::GetBuiltinTypeForEncodingAndBitSize(
889 getASTContext(), encoding, bit_size);
890}
891
892CompilerType ClangASTContext::GetBuiltinTypeForEncodingAndBitSize(
893 ASTContext *ast, Encoding encoding, uint32_t bit_size) {
894 if (!ast)
895 return CompilerType();
896 switch (encoding) {
897 case eEncodingInvalid:
898 if (QualTypeMatchesBitSize(bit_size, ast, ast->VoidPtrTy))
899 return CompilerType(ast, ast->VoidPtrTy);
900 break;
901
902 case eEncodingUint:
903 if (QualTypeMatchesBitSize(bit_size, ast, ast->UnsignedCharTy))
904 return CompilerType(ast, ast->UnsignedCharTy);
905 if (QualTypeMatchesBitSize(bit_size, ast, ast->UnsignedShortTy))
906 return CompilerType(ast, ast->UnsignedShortTy);
907 if (QualTypeMatchesBitSize(bit_size, ast, ast->UnsignedIntTy))
908 return CompilerType(ast, ast->UnsignedIntTy);
909 if (QualTypeMatchesBitSize(bit_size, ast, ast->UnsignedLongTy))
910 return CompilerType(ast, ast->UnsignedLongTy);
911 if (QualTypeMatchesBitSize(bit_size, ast, ast->UnsignedLongLongTy))
912 return CompilerType(ast, ast->UnsignedLongLongTy);
913 if (QualTypeMatchesBitSize(bit_size, ast, ast->UnsignedInt128Ty))
914 return CompilerType(ast, ast->UnsignedInt128Ty);
915 break;
916
917 case eEncodingSint:
918 if (QualTypeMatchesBitSize(bit_size, ast, ast->SignedCharTy))
919 return CompilerType(ast, ast->SignedCharTy);
920 if (QualTypeMatchesBitSize(bit_size, ast, ast->ShortTy))
921 return CompilerType(ast, ast->ShortTy);
922 if (QualTypeMatchesBitSize(bit_size, ast, ast->IntTy))
923 return CompilerType(ast, ast->IntTy);
924 if (QualTypeMatchesBitSize(bit_size, ast, ast->LongTy))
925 return CompilerType(ast, ast->LongTy);
926 if (QualTypeMatchesBitSize(bit_size, ast, ast->LongLongTy))
927 return CompilerType(ast, ast->LongLongTy);
928 if (QualTypeMatchesBitSize(bit_size, ast, ast->Int128Ty))
929 return CompilerType(ast, ast->Int128Ty);
930 break;
931
932 case eEncodingIEEE754:
933 if (QualTypeMatchesBitSize(bit_size, ast, ast->FloatTy))
934 return CompilerType(ast, ast->FloatTy);
935 if (QualTypeMatchesBitSize(bit_size, ast, ast->DoubleTy))
936 return CompilerType(ast, ast->DoubleTy);
937 if (QualTypeMatchesBitSize(bit_size, ast, ast->LongDoubleTy))
938 return CompilerType(ast, ast->LongDoubleTy);
939 if (QualTypeMatchesBitSize(bit_size, ast, ast->HalfTy))
940 return CompilerType(ast, ast->HalfTy);
941 break;
942
943 case eEncodingVector:
944 // Sanity check that bit_size is a multiple of 8's.
945 if (bit_size && !(bit_size & 0x7u))
946 return CompilerType(
947 ast, ast->getExtVectorType(ast->UnsignedCharTy, bit_size / 8));
948 break;
949 }
950
951 return CompilerType();
952}
953
954lldb::BasicType
955ClangASTContext::GetBasicTypeEnumeration(const ConstString &name) {
956 if (name) {
957 typedef UniqueCStringMap<lldb::BasicType> TypeNameToBasicTypeMap;
958 static TypeNameToBasicTypeMap g_type_map;
959 static llvm::once_flag g_once_flag;
960 llvm::call_once(g_once_flag, []() {
961 // "void"
962 g_type_map.Append(ConstString("void"), eBasicTypeVoid);
963
964 // "char"
965 g_type_map.Append(ConstString("char"), eBasicTypeChar);
966 g_type_map.Append(ConstString("signed char"), eBasicTypeSignedChar);
967 g_type_map.Append(ConstString("unsigned char"), eBasicTypeUnsignedChar);
968 g_type_map.Append(ConstString("wchar_t"), eBasicTypeWChar);
969 g_type_map.Append(ConstString("signed wchar_t"), eBasicTypeSignedWChar);
970 g_type_map.Append(ConstString("unsigned wchar_t"),
971 eBasicTypeUnsignedWChar);
972 // "short"
973 g_type_map.Append(ConstString("short"), eBasicTypeShort);
974 g_type_map.Append(ConstString("short int"), eBasicTypeShort);
975 g_type_map.Append(ConstString("unsigned short"), eBasicTypeUnsignedShort);
976 g_type_map.Append(ConstString("unsigned short int"),
977 eBasicTypeUnsignedShort);
978
979 // "int"
980 g_type_map.Append(ConstString("int"), eBasicTypeInt);
981 g_type_map.Append(ConstString("signed int"), eBasicTypeInt);
982 g_type_map.Append(ConstString("unsigned int"), eBasicTypeUnsignedInt);
983 g_type_map.Append(ConstString("unsigned"), eBasicTypeUnsignedInt);
984
985 // "long"
986 g_type_map.Append(ConstString("long"), eBasicTypeLong);
987 g_type_map.Append(ConstString("long int"), eBasicTypeLong);
988 g_type_map.Append(ConstString("unsigned long"), eBasicTypeUnsignedLong);
989 g_type_map.Append(ConstString("unsigned long int"),
990 eBasicTypeUnsignedLong);
991
992 // "long long"
993 g_type_map.Append(ConstString("long long"), eBasicTypeLongLong);
994 g_type_map.Append(ConstString("long long int"), eBasicTypeLongLong);
995 g_type_map.Append(ConstString("unsigned long long"),
996 eBasicTypeUnsignedLongLong);
997 g_type_map.Append(ConstString("unsigned long long int"),
998 eBasicTypeUnsignedLongLong);
999
1000 // "int128"
1001 g_type_map.Append(ConstString("__int128_t"), eBasicTypeInt128);
1002 g_type_map.Append(ConstString("__uint128_t"), eBasicTypeUnsignedInt128);
1003
1004 // Miscellaneous
1005 g_type_map.Append(ConstString("bool"), eBasicTypeBool);
1006 g_type_map.Append(ConstString("float"), eBasicTypeFloat);
1007 g_type_map.Append(ConstString("double"), eBasicTypeDouble);
1008 g_type_map.Append(ConstString("long double"), eBasicTypeLongDouble);
1009 g_type_map.Append(ConstString("id"), eBasicTypeObjCID);
1010 g_type_map.Append(ConstString("SEL"), eBasicTypeObjCSel);
1011 g_type_map.Append(ConstString("nullptr"), eBasicTypeNullPtr);
1012 g_type_map.Sort();
1013 });
1014
1015 return g_type_map.Find(name, eBasicTypeInvalid);
1016 }
1017 return eBasicTypeInvalid;
1018}
1019
1020CompilerType ClangASTContext::GetBasicType(ASTContext *ast,
1021 const ConstString &name) {
1022 if (ast) {
1023 lldb::BasicType basic_type = ClangASTContext::GetBasicTypeEnumeration(name);
1024 return ClangASTContext::GetBasicType(ast, basic_type);
1025 }
1026 return CompilerType();
1027}
1028
1029uint32_t ClangASTContext::GetPointerByteSize() {
1030 if (m_pointer_byte_size == 0)
1031 m_pointer_byte_size = GetBasicType(lldb::eBasicTypeVoid)
1032 .GetPointerType()
1033 .GetByteSize(nullptr);
1034 return m_pointer_byte_size;
1035}
1036
1037CompilerType ClangASTContext::GetBasicType(lldb::BasicType basic_type) {
1038 return GetBasicType(getASTContext(), basic_type);
1039}
1040
1041CompilerType ClangASTContext::GetBasicType(ASTContext *ast,
1042 lldb::BasicType basic_type) {
1043 if (!ast)
1044 return CompilerType();
1045 lldb::opaque_compiler_type_t clang_type =
1046 GetOpaqueCompilerType(ast, basic_type);
1047
1048 if (clang_type)
1049 return CompilerType(GetASTContext(ast), clang_type);
1050 return CompilerType();
1051}
1052
1053CompilerType ClangASTContext::GetBuiltinTypeForDWARFEncodingAndBitSize(
1054 const char *type_name, uint32_t dw_ate, uint32_t bit_size) {
1055 ASTContext *ast = getASTContext();
1056
1057#define streq(a, b)strcmp(a, b) == 0 strcmp(a, b) == 0
1058 assert(ast != nullptr)((ast != nullptr) ? static_cast<void> (0) : __assert_fail
("ast != nullptr", "/build/llvm-toolchain-snapshot-8~svn345461/tools/lldb/source/Symbol/ClangASTContext.cpp"
, 1058, __PRETTY_FUNCTION__))
;
1059 if (ast) {
1060 switch (dw_ate) {
1061 default:
1062 break;
1063
1064 case DW_ATE_address:
1065 if (QualTypeMatchesBitSize(bit_size, ast, ast->VoidPtrTy))
1066 return CompilerType(ast, ast->VoidPtrTy);
1067 break;
1068
1069 case DW_ATE_boolean:
1070 if (QualTypeMatchesBitSize(bit_size, ast, ast->BoolTy))
1071 return CompilerType(ast, ast->BoolTy);
1072 if (QualTypeMatchesBitSize(bit_size, ast, ast->UnsignedCharTy))
1073 return CompilerType(ast, ast->UnsignedCharTy);
1074 if (QualTypeMatchesBitSize(bit_size, ast, ast->UnsignedShortTy))
1075 return CompilerType(ast, ast->UnsignedShortTy);
1076 if (QualTypeMatchesBitSize(bit_size, ast, ast->UnsignedIntTy))
1077 return CompilerType(ast, ast->UnsignedIntTy);
1078 break;
1079
1080 case DW_ATE_lo_user:
1081 // This has been seen to mean DW_AT_complex_integer
1082 if (type_name) {
1083 if (::strstr(type_name, "complex")) {
1084 CompilerType complex_int_clang_type =
1085 GetBuiltinTypeForDWARFEncodingAndBitSize("int", DW_ATE_signed,
1086 bit_size / 2);
1087 return CompilerType(ast, ast->getComplexType(ClangUtil::GetQualType(
1088 complex_int_clang_type)));
1089 }
1090 }
1091 break;
1092
1093 case DW_ATE_complex_float:
1094 if (QualTypeMatchesBitSize(bit_size, ast, ast->FloatComplexTy))
1095 return CompilerType(ast, ast->FloatComplexTy);
1096 else if (QualTypeMatchesBitSize(bit_size, ast, ast->DoubleComplexTy))
1097 return CompilerType(ast, ast->DoubleComplexTy);
1098 else if (QualTypeMatchesBitSize(bit_size, ast, ast->LongDoubleComplexTy))
1099 return CompilerType(ast, ast->LongDoubleComplexTy);
1100 else {
1101 CompilerType complex_float_clang_type =
1102 GetBuiltinTypeForDWARFEncodingAndBitSize("float", DW_ATE_float,
1103 bit_size / 2);
1104 return CompilerType(ast, ast->getComplexType(ClangUtil::GetQualType(
1105 complex_float_clang_type)));
1106 }
1107 break;
1108
1109 case DW_ATE_float:
1110 if (streq(type_name, "float")strcmp(type_name, "float") == 0 &&
1111 QualTypeMatchesBitSize(bit_size, ast, ast->FloatTy))
1112 return CompilerType(ast, ast->FloatTy);
1113 if (streq(type_name, "double")strcmp(type_name, "double") == 0 &&
1114 QualTypeMatchesBitSize(bit_size, ast, ast->DoubleTy))
1115 return CompilerType(ast, ast->DoubleTy);
1116 if (streq(type_name, "long double")strcmp(type_name, "long double") == 0 &&
1117 QualTypeMatchesBitSize(bit_size, ast, ast->LongDoubleTy))
1118 return CompilerType(ast, ast->LongDoubleTy);
1119 // Fall back to not requiring a name match
1120 if (QualTypeMatchesBitSize(bit_size, ast, ast->FloatTy))
1121 return CompilerType(ast, ast->FloatTy);
1122 if (QualTypeMatchesBitSize(bit_size, ast, ast->DoubleTy))
1123 return CompilerType(ast, ast->DoubleTy);
1124 if (QualTypeMatchesBitSize(bit_size, ast, ast->LongDoubleTy))
1125 return CompilerType(ast, ast->LongDoubleTy);
1126 if (QualTypeMatchesBitSize(bit_size, ast, ast->HalfTy))
1127 return CompilerType(ast, ast->HalfTy);
1128 break;
1129
1130 case DW_ATE_signed:
1131 if (type_name) {
1132 if (streq(type_name, "wchar_t")strcmp(type_name, "wchar_t") == 0 &&
1133 QualTypeMatchesBitSize(bit_size, ast, ast->WCharTy) &&
1134 (getTargetInfo() &&
1135 TargetInfo::isTypeSigned(getTargetInfo()->getWCharType())))
1136 return CompilerType(ast, ast->WCharTy);
1137 if (streq(type_name, "void")strcmp(type_name, "void") == 0 &&
1138 QualTypeMatchesBitSize(bit_size, ast, ast->VoidTy))
1139 return CompilerType(ast, ast->VoidTy);
1140 if (strstr(type_name, "long long") &&
1141 QualTypeMatchesBitSize(bit_size, ast, ast->LongLongTy))
1142 return CompilerType(ast, ast->LongLongTy);
1143 if (strstr(type_name, "long") &&
1144 QualTypeMatchesBitSize(bit_size, ast, ast->LongTy))
1145 return CompilerType(ast, ast->LongTy);
1146 if (strstr(type_name, "short") &&
1147 QualTypeMatchesBitSize(bit_size, ast, ast->ShortTy))
1148 return CompilerType(ast, ast->ShortTy);
1149 if (strstr(type_name, "char")) {
1150 if (QualTypeMatchesBitSize(bit_size, ast, ast->CharTy))
1151 return CompilerType(ast, ast->CharTy);
1152 if (QualTypeMatchesBitSize(bit_size, ast, ast->SignedCharTy))
1153 return CompilerType(ast, ast->SignedCharTy);
1154 }
1155 if (strstr(type_name, "int")) {
1156 if (QualTypeMatchesBitSize(bit_size, ast, ast->IntTy))
1157 return CompilerType(ast, ast->IntTy);
1158 if (QualTypeMatchesBitSize(bit_size, ast, ast->Int128Ty))
1159 return CompilerType(ast, ast->Int128Ty);
1160 }
1161 }
1162 // We weren't able to match up a type name, just search by size
1163 if (QualTypeMatchesBitSize(bit_size, ast, ast->CharTy))
1164 return CompilerType(ast, ast->CharTy);
1165 if (QualTypeMatchesBitSize(bit_size, ast, ast->ShortTy))
1166 return CompilerType(ast, ast->ShortTy);
1167 if (QualTypeMatchesBitSize(bit_size, ast, ast->IntTy))
1168 return CompilerType(ast, ast->IntTy);
1169 if (QualTypeMatchesBitSize(bit_size, ast, ast->LongTy))
1170 return CompilerType(ast, ast->LongTy);
1171 if (QualTypeMatchesBitSize(bit_size, ast, ast->LongLongTy))
1172 return CompilerType(ast, ast->LongLongTy);
1173 if (QualTypeMatchesBitSize(bit_size, ast, ast->Int128Ty))
1174 return CompilerType(ast, ast->Int128Ty);
1175 break;
1176
1177 case DW_ATE_signed_char:
1178 if (ast->getLangOpts().CharIsSigned && type_name &&
1179 streq(type_name, "char")strcmp(type_name, "char") == 0) {
1180 if (QualTypeMatchesBitSize(bit_size, ast, ast->CharTy))
1181 return CompilerType(ast, ast->CharTy);
1182 }
1183 if (QualTypeMatchesBitSize(bit_size, ast, ast->SignedCharTy))
1184 return CompilerType(ast, ast->SignedCharTy);
1185 break;
1186
1187 case DW_ATE_unsigned:
1188 if (type_name) {
1189 if (streq(type_name, "wchar_t")strcmp(type_name, "wchar_t") == 0) {
1190 if (QualTypeMatchesBitSize(bit_size, ast, ast->WCharTy)) {
1191 if (!(getTargetInfo() &&
1192 TargetInfo::isTypeSigned(getTargetInfo()->getWCharType())))
1193 return CompilerType(ast, ast->WCharTy);
1194 }
1195 }
1196 if (strstr(type_name, "long long")) {
1197 if (QualTypeMatchesBitSize(bit_size, ast, ast->UnsignedLongLongTy))
1198 return CompilerType(ast, ast->UnsignedLongLongTy);
1199 } else if (strstr(type_name, "long")) {
1200 if (QualTypeMatchesBitSize(bit_size, ast, ast->UnsignedLongTy))
1201 return CompilerType(ast, ast->UnsignedLongTy);
1202 } else if (strstr(type_name, "short")) {
1203 if (QualTypeMatchesBitSize(bit_size, ast, ast->UnsignedShortTy))
1204 return CompilerType(ast, ast->UnsignedShortTy);
1205 } else if (strstr(type_name, "char")) {
1206 if (QualTypeMatchesBitSize(bit_size, ast, ast->UnsignedCharTy))
1207 return CompilerType(ast, ast->UnsignedCharTy);
1208 } else if (strstr(type_name, "int")) {
1209 if (QualTypeMatchesBitSize(bit_size, ast, ast->UnsignedIntTy))
1210 return CompilerType(ast, ast->UnsignedIntTy);
1211 if (QualTypeMatchesBitSize(bit_size, ast, ast->UnsignedInt128Ty))
1212 return CompilerType(ast, ast->UnsignedInt128Ty);
1213 }
1214 }
1215 // We weren't able to match up a type name, just search by size
1216 if (QualTypeMatchesBitSize(bit_size, ast, ast->UnsignedCharTy))
1217 return CompilerType(ast, ast->UnsignedCharTy);
1218 if (QualTypeMatchesBitSize(bit_size, ast, ast->UnsignedShortTy))
1219 return CompilerType(ast, ast->UnsignedShortTy);
1220 if (QualTypeMatchesBitSize(bit_size, ast, ast->UnsignedIntTy))
1221 return CompilerType(ast, ast->UnsignedIntTy);
1222 if (QualTypeMatchesBitSize(bit_size, ast, ast->UnsignedLongTy))
1223 return CompilerType(ast, ast->UnsignedLongTy);
1224 if (QualTypeMatchesBitSize(bit_size, ast, ast->UnsignedLongLongTy))
1225 return CompilerType(ast, ast->UnsignedLongLongTy);
1226 if (QualTypeMatchesBitSize(bit_size, ast, ast->UnsignedInt128Ty))
1227 return CompilerType(ast, ast->UnsignedInt128Ty);
1228 break;
1229
1230 case DW_ATE_unsigned_char:
1231 if (!ast->getLangOpts().CharIsSigned && type_name &&
1232 streq(type_name, "char")strcmp(type_name, "char") == 0) {
1233 if (QualTypeMatchesBitSize(bit_size, ast, ast->CharTy))
1234 return CompilerType(ast, ast->CharTy);
1235 }
1236 if (QualTypeMatchesBitSize(bit_size, ast, ast->UnsignedCharTy))
1237 return CompilerType(ast, ast->UnsignedCharTy);
1238 if (QualTypeMatchesBitSize(bit_size, ast, ast->UnsignedShortTy))
1239 return CompilerType(ast, ast->UnsignedShortTy);
1240 break;
1241
1242 case DW_ATE_imaginary_float:
1243 break;
1244
1245 case DW_ATE_UTF:
1246 if (type_name) {
1247 if (streq(type_name, "char16_t")strcmp(type_name, "char16_t") == 0) {
1248 return CompilerType(ast, ast->Char16Ty);
1249 } else if (streq(type_name, "char32_t")strcmp(type_name, "char32_t") == 0) {
1250 return CompilerType(ast, ast->Char32Ty);
1251 }
1252 }
1253 break;
1254 }
1255 }
1256 // This assert should fire for anything that we don't catch above so we know
1257 // to fix any issues we run into.
1258 if (type_name) {
1259 Host::SystemLog(Host::eSystemLogError, "error: need to add support for "
1260 "DW_TAG_base_type '%s' encoded with "
1261 "DW_ATE = 0x%x, bit_size = %u\n",
1262 type_name, dw_ate, bit_size);
1263 } else {
1264 Host::SystemLog(Host::eSystemLogError, "error: need to add support for "
1265 "DW_TAG_base_type encoded with "
1266 "DW_ATE = 0x%x, bit_size = %u\n",
1267 dw_ate, bit_size);
1268 }
1269 return CompilerType();
1270}
1271
1272CompilerType ClangASTContext::GetUnknownAnyType(clang::ASTContext *ast) {
1273 if (ast)
1274 return CompilerType(ast, ast->UnknownAnyTy);
1275 return CompilerType();
1276}
1277
1278CompilerType ClangASTContext::GetCStringType(bool is_const) {
1279 ASTContext *ast = getASTContext();
1280 QualType char_type(ast->CharTy);
1281
1282 if (is_const)
1283 char_type.addConst();
1284
1285 return CompilerType(ast, ast->getPointerType(char_type));
1286}
1287
1288clang::DeclContext *
1289ClangASTContext::GetTranslationUnitDecl(clang::ASTContext *ast) {
1290 return ast->getTranslationUnitDecl();
1291}
1292
1293clang::Decl *ClangASTContext::CopyDecl(ASTContext *dst_ast, ASTContext *src_ast,
1294 clang::Decl *source_decl) {
1295 FileSystemOptions file_system_options;
1296 FileManager file_manager(file_system_options);
1297 ASTImporter importer(*dst_ast, file_manager, *src_ast, file_manager, false);
1298
1299 return importer.Import(source_decl);
1300}
1301
1302bool ClangASTContext::AreTypesSame(CompilerType type1, CompilerType type2,
1303 bool ignore_qualifiers) {
1304 ClangASTContext *ast =
1305 llvm::dyn_cast_or_null<ClangASTContext>(type1.GetTypeSystem());
1306 if (!ast || ast != type2.GetTypeSystem())
1307 return false;
1308
1309 if (type1.GetOpaqueQualType() == type2.GetOpaqueQualType())
1310 return true;
1311
1312 QualType type1_qual = ClangUtil::GetQualType(type1);
1313 QualType type2_qual = ClangUtil::GetQualType(type2);
1314
1315 if (ignore_qualifiers) {
1316 type1_qual = type1_qual.getUnqualifiedType();
1317 type2_qual = type2_qual.getUnqualifiedType();
1318 }
1319
1320 return ast->getASTContext()->hasSameType(type1_qual, type2_qual);
1321}
1322
1323CompilerType ClangASTContext::GetTypeForDecl(clang::NamedDecl *decl) {
1324 if (clang::ObjCInterfaceDecl *interface_decl =
1325 llvm::dyn_cast<clang::ObjCInterfaceDecl>(decl))
1326 return GetTypeForDecl(interface_decl);
1327 if (clang::TagDecl *tag_decl = llvm::dyn_cast<clang::TagDecl>(decl))
1328 return GetTypeForDecl(tag_decl);
1329 return CompilerType();
1330}
1331
1332CompilerType ClangASTContext::GetTypeForDecl(TagDecl *decl) {
1333 // No need to call the getASTContext() accessor (which can create the AST if
1334 // it isn't created yet, because we can't have created a decl in this
1335 // AST if our AST didn't already exist...
1336 ASTContext *ast = &decl->getASTContext();
1337 if (ast)
1338 return CompilerType(ast, ast->getTagDeclType(decl));
1339 return CompilerType();
1340}
1341
1342CompilerType ClangASTContext::GetTypeForDecl(ObjCInterfaceDecl *decl) {
1343 // No need to call the getASTContext() accessor (which can create the AST if
1344 // it isn't created yet, because we can't have created a decl in this
1345 // AST if our AST didn't already exist...
1346 ASTContext *ast = &decl->getASTContext();
1347 if (ast)
1348 return CompilerType(ast, ast->getObjCInterfaceType(decl));
1349 return CompilerType();
1350}
1351
1352#pragma mark Structure, Unions, Classes
1353
1354CompilerType ClangASTContext::CreateRecordType(DeclContext *decl_ctx,
1355 AccessType access_type,
1356 const char *name, int kind,
1357 LanguageType language,
1358 ClangASTMetadata *metadata) {
1359 ASTContext *ast = getASTContext();
1360 assert(ast != nullptr)((ast != nullptr) ? static_cast<void> (0) : __assert_fail
("ast != nullptr", "/build/llvm-toolchain-snapshot-8~svn345461/tools/lldb/source/Symbol/ClangASTContext.cpp"
, 1360, __PRETTY_FUNCTION__))
;
1361
1362 if (decl_ctx == nullptr)
1363 decl_ctx = ast->getTranslationUnitDecl();
1364
1365 if (language == eLanguageTypeObjC ||
1366 language == eLanguageTypeObjC_plus_plus) {
1367 bool isForwardDecl = true;
1368 bool isInternal = false;
1369 return CreateObjCClass(name, decl_ctx, isForwardDecl, isInternal, metadata);
1370 }
1371
1372 // NOTE: Eventually CXXRecordDecl will be merged back into RecordDecl and
1373 // we will need to update this code. I was told to currently always use the
1374 // CXXRecordDecl class since we often don't know from debug information if
1375 // something is struct or a class, so we default to always use the more
1376 // complete definition just in case.
1377
1378 bool is_anonymous = (!name) || (!name[0]);
1379
1380 CXXRecordDecl *decl = CXXRecordDecl::Create(
1381 *ast, (TagDecl::TagKind)kind, decl_ctx, SourceLocation(),
1382 SourceLocation(), is_anonymous ? nullptr : &ast->Idents.get(name));
1383
1384 if (is_anonymous)
1385 decl->setAnonymousStructOrUnion(true);
1386
1387 if (decl) {
1388 if (metadata)
1389 SetMetadata(ast, decl, *metadata);
1390
1391 if (access_type != eAccessNone)
1392 decl->setAccess(ConvertAccessTypeToAccessSpecifier(access_type));
1393
1394 if (decl_ctx)
1395 decl_ctx->addDecl(decl);
1396
1397 return CompilerType(ast, ast->getTagDeclType(decl));
1398 }
1399 return CompilerType();
1400}
1401
1402namespace {
1403 bool IsValueParam(const clang::TemplateArgument &argument) {
1404 return argument.getKind() == TemplateArgument::Integral;
1405 }
1406}
1407
1408static TemplateParameterList *CreateTemplateParameterList(
1409 ASTContext *ast,
1410 const ClangASTContext::TemplateParameterInfos &template_param_infos,
1411 llvm::SmallVector<NamedDecl *, 8> &template_param_decls) {
1412 const bool parameter_pack = false;
1413 const bool is_typename = false;
1414 const unsigned depth = 0;
1415 const size_t num_template_params = template_param_infos.args.size();
1416 DeclContext *const decl_context =
1417 ast->getTranslationUnitDecl(); // Is this the right decl context?,
1418 for (size_t i = 0; i < num_template_params; ++i) {
1419 const char *name = template_param_infos.names[i];
1420
1421 IdentifierInfo *identifier_info = nullptr;
1422 if (name && name[0])
1423 identifier_info = &ast->Idents.get(name);
1424 if (IsValueParam(template_param_infos.args[i])) {
1425 template_param_decls.push_back(NonTypeTemplateParmDecl::Create(
1426 *ast, decl_context,
1427 SourceLocation(), SourceLocation(), depth, i, identifier_info,
1428 template_param_infos.args[i].getIntegralType(), parameter_pack,
1429 nullptr));
1430
1431 } else {
1432 template_param_decls.push_back(TemplateTypeParmDecl::Create(
1433 *ast, decl_context,
1434 SourceLocation(), SourceLocation(), depth, i, identifier_info,
1435 is_typename, parameter_pack));
1436 }
1437 }
1438
1439 if (template_param_infos.packed_args &&
1440 template_param_infos.packed_args->args.size()) {
1441 IdentifierInfo *identifier_info = nullptr;
1442 if (template_param_infos.pack_name && template_param_infos.pack_name[0])
1443 identifier_info = &ast->Idents.get(template_param_infos.pack_name);
1444 const bool parameter_pack_true = true;
1445 if (IsValueParam(template_param_infos.packed_args->args[0])) {
1446 template_param_decls.push_back(NonTypeTemplateParmDecl::Create(
1447 *ast, decl_context,
1448 SourceLocation(), SourceLocation(), depth, num_template_params,
1449 identifier_info,
1450 template_param_infos.packed_args->args[0].getIntegralType(),
1451 parameter_pack_true, nullptr));
1452 } else {
1453 template_param_decls.push_back(TemplateTypeParmDecl::Create(
1454 *ast, decl_context,
1455 SourceLocation(), SourceLocation(), depth, num_template_params,
1456 identifier_info,
1457 is_typename, parameter_pack_true));
1458 }
1459 }
1460 clang::Expr *const requires_clause = nullptr; // TODO: Concepts
1461 TemplateParameterList *template_param_list = TemplateParameterList::Create(
1462 *ast, SourceLocation(), SourceLocation(), template_param_decls,
1463 SourceLocation(), requires_clause);
1464 return template_param_list;
1465}
1466
1467clang::FunctionTemplateDecl *ClangASTContext::CreateFunctionTemplateDecl(
1468 clang::DeclContext *decl_ctx, clang::FunctionDecl *func_decl,
1469 const char *name, const TemplateParameterInfos &template_param_infos) {
1470 // /// Create a function template node.
1471 ASTContext *ast = getASTContext();
1472
1473 llvm::SmallVector<NamedDecl *, 8> template_param_decls;
1474
1475 TemplateParameterList *template_param_list = CreateTemplateParameterList(
1476 ast, template_param_infos, template_param_decls);
1477 FunctionTemplateDecl *func_tmpl_decl = FunctionTemplateDecl::Create(
1478 *ast, decl_ctx, func_decl->getLocation(), func_decl->getDeclName(),
1479 template_param_list, func_decl);
1480
1481 for (size_t i = 0, template_param_decl_count = template_param_decls.size();
1482 i < template_param_decl_count; ++i) {
1483 // TODO: verify which decl context we should put template_param_decls into..
1484 template_param_decls[i]->setDeclContext(func_decl);
1485 }
1486
1487 return func_tmpl_decl;
1488}
1489
1490void ClangASTContext::CreateFunctionTemplateSpecializationInfo(
1491 FunctionDecl *func_decl, clang::FunctionTemplateDecl *func_tmpl_decl,
1492 const TemplateParameterInfos &infos) {
1493 TemplateArgumentList template_args(TemplateArgumentList::OnStack, infos.args);
1494
1495 func_decl->setFunctionTemplateSpecialization(func_tmpl_decl, &template_args,
1496 nullptr);
1497}
1498
1499ClassTemplateDecl *ClangASTContext::CreateClassTemplateDecl(
1500 DeclContext *decl_ctx, lldb::AccessType access_type, const char *class_name,
1501 int kind, const TemplateParameterInfos &template_param_infos) {
1502 ASTContext *ast = getASTContext();
1503
1504 ClassTemplateDecl *class_template_decl = nullptr;
1505 if (decl_ctx == nullptr)
1506 decl_ctx = ast->getTranslationUnitDecl();
1507
1508 IdentifierInfo &identifier_info = ast->Idents.get(class_name);
1509 DeclarationName decl_name(&identifier_info);
1510
1511 clang::DeclContext::lookup_result result = decl_ctx->lookup(decl_name);
1512
1513 for (NamedDecl *decl : result) {
1514 class_template_decl = dyn_cast<clang::ClassTemplateDecl>(decl);
1515 if (class_template_decl)
1516 return class_template_decl;
1517 }
1518
1519 llvm::SmallVector<NamedDecl *, 8> template_param_decls;
1520
1521 TemplateParameterList *template_param_list = CreateTemplateParameterList(
1522 ast, template_param_infos, template_param_decls);
1523
1524 CXXRecordDecl *template_cxx_decl = CXXRecordDecl::Create(
1525 *ast, (TagDecl::TagKind)kind,
1526 decl_ctx, // What decl context do we use here? TU? The actual decl
1527 // context?
1528 SourceLocation(), SourceLocation(), &identifier_info);
1529
1530 for (size_t i = 0, template_param_decl_count = template_param_decls.size();
1531 i < template_param_decl_count; ++i) {
1532 template_param_decls[i]->setDeclContext(template_cxx_decl);
1533 }
1534
1535 // With templated classes, we say that a class is templated with
1536 // specializations, but that the bare class has no functions.
1537 // template_cxx_decl->startDefinition();
1538 // template_cxx_decl->completeDefinition();
1539
1540 class_template_decl = ClassTemplateDecl::Create(
1541 *ast,
1542 decl_ctx, // What decl context do we use here? TU? The actual decl
1543 // context?
1544 SourceLocation(), decl_name, template_param_list, template_cxx_decl);
1545
1546 if (class_template_decl) {
1547 if (access_type != eAccessNone)
1548 class_template_decl->setAccess(
1549 ConvertAccessTypeToAccessSpecifier(access_type));
1550
1551 // if (TagDecl *ctx_tag_decl = dyn_cast<TagDecl>(decl_ctx))
1552 // CompleteTagDeclarationDefinition(GetTypeForDecl(ctx_tag_decl));
1553
1554 decl_ctx->addDecl(class_template_decl);
1555
1556#ifdef LLDB_CONFIGURATION_DEBUG
1557 VerifyDecl(class_template_decl);
1558#endif
1559 }
1560
1561 return class_template_decl;
1562}
1563
1564TemplateTemplateParmDecl *
1565ClangASTContext::CreateTemplateTemplateParmDecl(const char *template_name) {
1566 ASTContext *ast = getASTContext();
1567
1568 auto *decl_ctx = ast->getTranslationUnitDecl();
1569
1570 IdentifierInfo &identifier_info = ast->Idents.get(template_name);
1571 llvm::SmallVector<NamedDecl *, 8> template_param_decls;
1572
1573 ClangASTContext::TemplateParameterInfos template_param_infos;
1574 TemplateParameterList *template_param_list = CreateTemplateParameterList(
1575 ast, template_param_infos, template_param_decls);
1576
1577 // LLDB needs to create those decls only to be able to display a
1578 // type that includes a template template argument. Only the name matters for
1579 // this purpose, so we use dummy values for the other characterisitcs of the
1580 // type.
1581 return TemplateTemplateParmDecl::Create(
1582 *ast, decl_ctx, SourceLocation(),
1583 /*Depth*/ 0, /*Position*/ 0,
1584 /*IsParameterPack*/ false, &identifier_info, template_param_list);
1585}
1586
1587ClassTemplateSpecializationDecl *
1588ClangASTContext::CreateClassTemplateSpecializationDecl(
1589 DeclContext *decl_ctx, ClassTemplateDecl *class_template_decl, int kind,
1590 const TemplateParameterInfos &template_param_infos) {
1591 ASTContext *ast = getASTContext();
1592 llvm::SmallVector<clang::TemplateArgument, 2> args(
1593 template_param_infos.args.size() +
1594 (template_param_infos.packed_args ? 1 : 0));
1595 std::copy(template_param_infos.args.begin(), template_param_infos.args.end(),
1596 args.begin());
1597 if (template_param_infos.packed_args) {
1598 args[args.size() - 1] = TemplateArgument::CreatePackCopy(
1599 *ast, template_param_infos.packed_args->args);
1600 }
1601 ClassTemplateSpecializationDecl *class_template_specialization_decl =
1602 ClassTemplateSpecializationDecl::Create(
1603 *ast, (TagDecl::TagKind)kind, decl_ctx, SourceLocation(),
1604 SourceLocation(), class_template_decl, args,
1605 nullptr);
1606
1607 class_template_specialization_decl->setSpecializationKind(
1608 TSK_ExplicitSpecialization);
1609
1610 return class_template_specialization_decl;
1611}
1612
1613CompilerType ClangASTContext::CreateClassTemplateSpecializationType(
1614 ClassTemplateSpecializationDecl *class_template_specialization_decl) {
1615 if (class_template_specialization_decl) {
1616 ASTContext *ast = getASTContext();
1617 if (ast)
1618 return CompilerType(
1619 ast, ast->getTagDeclType(class_template_specialization_decl));
1620 }
1621 return CompilerType();
1622}
1623
1624static inline bool check_op_param(bool is_method,
1625 clang::OverloadedOperatorKind op_kind,
1626 bool unary, bool binary,
1627 uint32_t num_params) {
1628 // Special-case call since it can take any number of operands
1629 if (op_kind == OO_Call)
1630 return true;
1631
1632 // The parameter count doesn't include "this"
1633 if (is_method)
1634 ++num_params;
1635 if (num_params == 1)
1636 return unary;
1637 if (num_params == 2)
1638 return binary;
1639 else
1640 return false;
1641}
1642
1643bool ClangASTContext::CheckOverloadedOperatorKindParameterCount(
1644 bool is_method, clang::OverloadedOperatorKind op_kind,
1645 uint32_t num_params) {
1646 switch (op_kind) {
1647 default:
1648 break;
1649 // C++ standard allows any number of arguments to new/delete
1650 case OO_New:
1651 case OO_Array_New:
1652 case OO_Delete:
1653 case OO_Array_Delete:
1654 return true;
1655 }
1656
1657#define OVERLOADED_OPERATOR(Name, Spelling, Token, Unary, Binary, MemberOnly) \
1658 case OO_##Name: \
1659 return check_op_param(is_method, op_kind, Unary, Binary, num_params);
1660 switch (op_kind) {
1661#include "clang/Basic/OperatorKinds.def"
1662 default:
1663 break;
1664 }
1665 return false;
1666}
1667
1668clang::AccessSpecifier
1669ClangASTContext::UnifyAccessSpecifiers(clang::AccessSpecifier lhs,
1670 clang::AccessSpecifier rhs) {
1671 // Make the access equal to the stricter of the field and the nested field's
1672 // access
1673 if (lhs == AS_none || rhs == AS_none)
1674 return AS_none;
1675 if (lhs == AS_private || rhs == AS_private)
1676 return AS_private;
1677 if (lhs == AS_protected || rhs == AS_protected)
1678 return AS_protected;
1679 return AS_public;
1680}
1681
1682bool ClangASTContext::FieldIsBitfield(FieldDecl *field,
1683 uint32_t &bitfield_bit_size) {
1684 return FieldIsBitfield(getASTContext(), field, bitfield_bit_size);
1685}
1686
1687bool ClangASTContext::FieldIsBitfield(ASTContext *ast, FieldDecl *field,
1688 uint32_t &bitfield_bit_size) {
1689 if (ast == nullptr || field == nullptr)
1690 return false;
1691
1692 if (field->isBitField()) {
1693 Expr *bit_width_expr = field->getBitWidth();
1694 if (bit_width_expr) {
1695 llvm::APSInt bit_width_apsint;
1696 if (bit_width_expr->isIntegerConstantExpr(bit_width_apsint, *ast)) {
1697 bitfield_bit_size = bit_width_apsint.getLimitedValue(UINT32_MAX(4294967295U));
1698 return true;
1699 }
1700 }
1701 }
1702 return false;
1703}
1704
1705bool ClangASTContext::RecordHasFields(const RecordDecl *record_decl) {
1706 if (record_decl == nullptr)
1707 return false;
1708
1709 if (!record_decl->field_empty())
1710 return true;
1711
1712 // No fields, lets check this is a CXX record and check the base classes
1713 const CXXRecordDecl *cxx_record_decl = dyn_cast<CXXRecordDecl>(record_decl);
1714 if (cxx_record_decl) {
1715 CXXRecordDecl::base_class_const_iterator base_class, base_class_end;
1716 for (base_class = cxx_record_decl->bases_begin(),
1717 base_class_end = cxx_record_decl->bases_end();
1718 base_class != base_class_end; ++base_class) {
1719 const CXXRecordDecl *base_class_decl = cast<CXXRecordDecl>(
1720 base_class->getType()->getAs<RecordType>()->getDecl());
1721 if (RecordHasFields(base_class_decl))
1722 return true;
1723 }
1724 }
1725 return false;
1726}
1727
1728#pragma mark Objective-C Classes
1729
1730CompilerType ClangASTContext::CreateObjCClass(const char *name,
1731 DeclContext *decl_ctx,
1732 bool isForwardDecl,
1733 bool isInternal,
1734 ClangASTMetadata *metadata) {
1735 ASTContext *ast = getASTContext();
1736 assert(ast != nullptr)((ast != nullptr) ? static_cast<void> (0) : __assert_fail
("ast != nullptr", "/build/llvm-toolchain-snapshot-8~svn345461/tools/lldb/source/Symbol/ClangASTContext.cpp"
, 1736, __PRETTY_FUNCTION__))
;
1737 assert(name && name[0])((name && name[0]) ? static_cast<void> (0) : __assert_fail
("name && name[0]", "/build/llvm-toolchain-snapshot-8~svn345461/tools/lldb/source/Symbol/ClangASTContext.cpp"
, 1737, __PRETTY_FUNCTION__))
;
1738 if (decl_ctx == nullptr)
1739 decl_ctx = ast->getTranslationUnitDecl();
1740
1741 ObjCInterfaceDecl *decl = ObjCInterfaceDecl::Create(
1742 *ast, decl_ctx, SourceLocation(), &ast->Idents.get(name), nullptr,
1743 nullptr, SourceLocation(),
1744 /*isForwardDecl,*/
1745 isInternal);
1746
1747 if (decl && metadata)
1748 SetMetadata(ast, decl, *metadata);
1749
1750 return CompilerType(ast, ast->getObjCInterfaceType(decl));
1751}
1752
1753static inline bool BaseSpecifierIsEmpty(const CXXBaseSpecifier *b) {
1754 return ClangASTContext::RecordHasFields(b->getType()->getAsCXXRecordDecl()) ==
1755 false;
1756}
1757
1758uint32_t
1759ClangASTContext::GetNumBaseClasses(const CXXRecordDecl *cxx_record_decl,
1760 bool omit_empty_base_classes) {
1761 uint32_t num_bases = 0;
1762 if (cxx_record_decl) {
1763 if (omit_empty_base_classes) {
1764 CXXRecordDecl::base_class_const_iterator base_class, base_class_end;
1765 for (base_class = cxx_record_decl->bases_begin(),
1766 base_class_end = cxx_record_decl->bases_end();
1767 base_class != base_class_end; ++base_class) {
1768 // Skip empty base classes
1769 if (omit_empty_base_classes) {
1770 if (BaseSpecifierIsEmpty(base_class))
1771 continue;
1772 }
1773 ++num_bases;
1774 }
1775 } else
1776 num_bases = cxx_record_decl->getNumBases();
1777 }
1778 return num_bases;
1779}
1780
1781#pragma mark Namespace Declarations
1782
1783NamespaceDecl *
1784ClangASTContext::GetUniqueNamespaceDeclaration(const char *name,
1785 DeclContext *decl_ctx) {
1786 NamespaceDecl *namespace_decl = nullptr;
1787 ASTContext *ast = getASTContext();
1788 TranslationUnitDecl *translation_unit_decl = ast->getTranslationUnitDecl();
1789 if (decl_ctx == nullptr)
1790 decl_ctx = translation_unit_decl;
1791
1792 if (name) {
1793 IdentifierInfo &identifier_info = ast->Idents.get(name);
1794 DeclarationName decl_name(&identifier_info);
1795 clang::DeclContext::lookup_result result = decl_ctx->lookup(decl_name);
1796 for (NamedDecl *decl : result) {
1797 namespace_decl = dyn_cast<clang::NamespaceDecl>(decl);
1798 if (namespace_decl)
1799 return namespace_decl;
1800 }
1801
1802 namespace_decl =
1803 NamespaceDecl::Create(*ast, decl_ctx, false, SourceLocation(),
1804 SourceLocation(), &identifier_info, nullptr);
1805
1806 decl_ctx->addDecl(namespace_decl);
1807 } else {
1808 if (decl_ctx == translation_unit_decl) {
1809 namespace_decl = translation_unit_decl->getAnonymousNamespace();
1810 if (namespace_decl)
1811 return namespace_decl;
1812
1813 namespace_decl =
1814 NamespaceDecl::Create(*ast, decl_ctx, false, SourceLocation(),
1815 SourceLocation(), nullptr, nullptr);
1816 translation_unit_decl->setAnonymousNamespace(namespace_decl);
1817 translation_unit_decl->addDecl(namespace_decl);
1818 assert(namespace_decl == translation_unit_decl->getAnonymousNamespace())((namespace_decl == translation_unit_decl->getAnonymousNamespace
()) ? static_cast<void> (0) : __assert_fail ("namespace_decl == translation_unit_decl->getAnonymousNamespace()"
, "/build/llvm-toolchain-snapshot-8~svn345461/tools/lldb/source/Symbol/ClangASTContext.cpp"
, 1818, __PRETTY_FUNCTION__))
;
1819 } else {
1820 NamespaceDecl *parent_namespace_decl = cast<NamespaceDecl>(decl_ctx);
1821 if (parent_namespace_decl) {
1822 namespace_decl = parent_namespace_decl->getAnonymousNamespace();
1823 if (namespace_decl)
1824 return namespace_decl;
1825 namespace_decl =
1826 NamespaceDecl::Create(*ast, decl_ctx, false, SourceLocation(),
1827 SourceLocation(), nullptr, nullptr);
1828 parent_namespace_decl->setAnonymousNamespace(namespace_decl);
1829 parent_namespace_decl->addDecl(namespace_decl);
1830 assert(namespace_decl ==((namespace_decl == parent_namespace_decl->getAnonymousNamespace
()) ? static_cast<void> (0) : __assert_fail ("namespace_decl == parent_namespace_decl->getAnonymousNamespace()"
, "/build/llvm-toolchain-snapshot-8~svn345461/tools/lldb/source/Symbol/ClangASTContext.cpp"
, 1831, __PRETTY_FUNCTION__))
1831 parent_namespace_decl->getAnonymousNamespace())((namespace_decl == parent_namespace_decl->getAnonymousNamespace
()) ? static_cast<void> (0) : __assert_fail ("namespace_decl == parent_namespace_decl->getAnonymousNamespace()"
, "/build/llvm-toolchain-snapshot-8~svn345461/tools/lldb/source/Symbol/ClangASTContext.cpp"
, 1831, __PRETTY_FUNCTION__))
;
1832 } else {
1833 // BAD!!!
1834 }
1835 }
1836 }
1837#ifdef LLDB_CONFIGURATION_DEBUG
1838 VerifyDecl(namespace_decl);
1839#endif
1840 return namespace_decl;
1841}
1842
1843NamespaceDecl *ClangASTContext::GetUniqueNamespaceDeclaration(
1844 clang::ASTContext *ast, const char *name, clang::DeclContext *decl_ctx) {
1845 ClangASTContext *ast_ctx = ClangASTContext::GetASTContext(ast);
1846 if (ast_ctx == nullptr)
1847 return nullptr;
1848
1849 return ast_ctx->GetUniqueNamespaceDeclaration(name, decl_ctx);
1850}
1851
1852clang::BlockDecl *
1853ClangASTContext::CreateBlockDeclaration(clang::DeclContext *ctx) {
1854 if (ctx != nullptr) {
1855 clang::BlockDecl *decl = clang::BlockDecl::Create(*getASTContext(), ctx,
1856 clang::SourceLocation());
1857 ctx->addDecl(decl);
1858 return decl;
1859 }
1860 return nullptr;
1861}
1862
1863clang::DeclContext *FindLCABetweenDecls(clang::DeclContext *left,
1864 clang::DeclContext *right,
1865 clang::DeclContext *root) {
1866 if (root == nullptr)
1867 return nullptr;
1868
1869 std::set<clang::DeclContext *> path_left;
1870 for (clang::DeclContext *d = left; d != nullptr; d = d->getParent())
1871 path_left.insert(d);
1872
1873 for (clang::DeclContext *d = right; d != nullptr; d = d->getParent())
1874 if (path_left.find(d) != path_left.end())
1875 return d;
1876
1877 return nullptr;
1878}
1879
1880clang::UsingDirectiveDecl *ClangASTContext::CreateUsingDirectiveDeclaration(
1881 clang::DeclContext *decl_ctx, clang::NamespaceDecl *ns_decl) {
1882 if (decl_ctx != nullptr && ns_decl != nullptr) {
1883 clang::TranslationUnitDecl *translation_unit =
1884 (clang::TranslationUnitDecl *)GetTranslationUnitDecl(getASTContext());
1885 clang::UsingDirectiveDecl *using_decl = clang::UsingDirectiveDecl::Create(
1886 *getASTContext(), decl_ctx, clang::SourceLocation(),
1887 clang::SourceLocation(), clang::NestedNameSpecifierLoc(),
1888 clang::SourceLocation(), ns_decl,
1889 FindLCABetweenDecls(decl_ctx, ns_decl, translation_unit));
1890 decl_ctx->addDecl(using_decl);
1891 return using_decl;
1892 }
1893 return nullptr;
1894}
1895
1896clang::UsingDecl *
1897ClangASTContext::CreateUsingDeclaration(clang::DeclContext *current_decl_ctx,
1898 clang::NamedDecl *target) {
1899 if (current_decl_ctx != nullptr && target != nullptr) {
1900 clang::UsingDecl *using_decl = clang::UsingDecl::Create(
1901 *getASTContext(), current_decl_ctx, clang::SourceLocation(),
1902 clang::NestedNameSpecifierLoc(), clang::DeclarationNameInfo(), false);
1903 clang::UsingShadowDecl *shadow_decl = clang::UsingShadowDecl::Create(
1904 *getASTContext(), current_decl_ctx, clang::SourceLocation(), using_decl,
1905 target);
1906 using_decl->addShadowDecl(shadow_decl);
1907 current_decl_ctx->addDecl(using_decl);
1908 return using_decl;
1909 }
1910 return nullptr;
1911}
1912
1913clang::VarDecl *ClangASTContext::CreateVariableDeclaration(
1914 clang::DeclContext *decl_context, const char *name, clang::QualType type) {
1915 if (decl_context != nullptr) {
1916 clang::VarDecl *var_decl = clang::VarDecl::Create(
1917 *getASTContext(), decl_context, clang::SourceLocation(),
1918 clang::SourceLocation(),
1919 name && name[0] ? &getASTContext()->Idents.getOwn(name) : nullptr, type,
1920 nullptr, clang::SC_None);
1921 var_decl->setAccess(clang::AS_public);
1922 decl_context->addDecl(var_decl);
1923 return var_decl;
1924 }
1925 return nullptr;
1926}
1927
1928lldb::opaque_compiler_type_t
1929ClangASTContext::GetOpaqueCompilerType(clang::ASTContext *ast,
1930 lldb::BasicType basic_type) {
1931 switch (basic_type) {
1932 case eBasicTypeVoid:
1933 return ast->VoidTy.getAsOpaquePtr();
1934 case eBasicTypeChar:
1935 return ast->CharTy.getAsOpaquePtr();
1936 case eBasicTypeSignedChar:
1937 return ast->SignedCharTy.getAsOpaquePtr();
1938 case eBasicTypeUnsignedChar:
1939 return ast->UnsignedCharTy.getAsOpaquePtr();
1940 case eBasicTypeWChar:
1941 return ast->getWCharType().getAsOpaquePtr();
1942 case eBasicTypeSignedWChar:
1943 return ast->getSignedWCharType().getAsOpaquePtr();
1944 case eBasicTypeUnsignedWChar:
1945 return ast->getUnsignedWCharType().getAsOpaquePtr();
1946 case eBasicTypeChar16:
1947 return ast->Char16Ty.getAsOpaquePtr();
1948 case eBasicTypeChar32:
1949 return ast->Char32Ty.getAsOpaquePtr();
1950 case eBasicTypeShort:
1951 return ast->ShortTy.getAsOpaquePtr();
1952 case eBasicTypeUnsignedShort:
1953 return ast->UnsignedShortTy.getAsOpaquePtr();
1954 case eBasicTypeInt:
1955 return ast->IntTy.getAsOpaquePtr();
1956 case eBasicTypeUnsignedInt:
1957 return ast->UnsignedIntTy.getAsOpaquePtr();
1958 case eBasicTypeLong:
1959 return ast->LongTy.getAsOpaquePtr();
1960 case eBasicTypeUnsignedLong:
1961 return ast->UnsignedLongTy.getAsOpaquePtr();
1962 case eBasicTypeLongLong:
1963 return ast->LongLongTy.getAsOpaquePtr();
1964 case eBasicTypeUnsignedLongLong:
1965 return ast->UnsignedLongLongTy.getAsOpaquePtr();
1966 case eBasicTypeInt128:
1967 return ast->Int128Ty.getAsOpaquePtr();
1968 case eBasicTypeUnsignedInt128:
1969 return ast->UnsignedInt128Ty.getAsOpaquePtr();
1970 case eBasicTypeBool:
1971 return ast->BoolTy.getAsOpaquePtr();
1972 case eBasicTypeHalf:
1973 return ast->HalfTy.getAsOpaquePtr();
1974 case eBasicTypeFloat:
1975 return ast->FloatTy.getAsOpaquePtr();
1976 case eBasicTypeDouble:
1977 return ast->DoubleTy.getAsOpaquePtr();
1978 case eBasicTypeLongDouble:
1979 return ast->LongDoubleTy.getAsOpaquePtr();
1980 case eBasicTypeFloatComplex:
1981 return ast->FloatComplexTy.getAsOpaquePtr();
1982 case eBasicTypeDoubleComplex:
1983 return ast->DoubleComplexTy.getAsOpaquePtr();
1984 case eBasicTypeLongDoubleComplex:
1985 return ast->LongDoubleComplexTy.getAsOpaquePtr();
1986 case eBasicTypeObjCID:
1987 return ast->getObjCIdType().getAsOpaquePtr();
1988 case eBasicTypeObjCClass:
1989 return ast->getObjCClassType().getAsOpaquePtr();
1990 case eBasicTypeObjCSel:
1991 return ast->getObjCSelType().getAsOpaquePtr();
1992 case eBasicTypeNullPtr:
1993 return ast->NullPtrTy.getAsOpaquePtr();
1994 default:
1995 return nullptr;
1996 }
1997}
1998
1999#pragma mark Function Types
2000
2001clang::DeclarationName
2002ClangASTContext::GetDeclarationName(const char *name,
2003 const CompilerType &function_clang_type) {
2004 if (!name || !name[0])
2005 return clang::DeclarationName();
2006
2007 clang::OverloadedOperatorKind op_kind = clang::NUM_OVERLOADED_OPERATORS;
2008 if (!IsOperator(name, op_kind) || op_kind == clang::NUM_OVERLOADED_OPERATORS)
2009 return DeclarationName(&getASTContext()->Idents.get(
2010 name)); // Not operator, but a regular function.
2011
2012 // Check the number of operator parameters. Sometimes we have seen bad DWARF
2013 // that doesn't correctly describe operators and if we try to create a method
2014 // and add it to the class, clang will assert and crash, so we need to make
2015 // sure things are acceptable.
2016 clang::QualType method_qual_type(ClangUtil::GetQualType(function_clang_type));
2017 const clang::FunctionProtoType *function_type =
2018 llvm::dyn_cast<clang::FunctionProtoType>(method_qual_type.getTypePtr());
2019 if (function_type == nullptr)
2020 return clang::DeclarationName();
2021
2022 const bool is_method = false;
2023 const unsigned int num_params = function_type->getNumParams();
2024 if (!ClangASTContext::CheckOverloadedOperatorKindParameterCount(
2025 is_method, op_kind, num_params))
2026 return clang::DeclarationName();
2027
2028 return getASTContext()->DeclarationNames.getCXXOperatorName(op_kind);
2029}
2030
2031FunctionDecl *ClangASTContext::CreateFunctionDeclaration(
2032 DeclContext *decl_ctx, const char *name,
2033 const CompilerType &function_clang_type, int storage, bool is_inline) {
2034 FunctionDecl *func_decl = nullptr;
2035 ASTContext *ast = getASTContext();
2036 if (decl_ctx == nullptr)
2037 decl_ctx = ast->getTranslationUnitDecl();
2038
2039 const bool hasWrittenPrototype = true;
2040 const bool isConstexprSpecified = false;
2041
2042 clang::DeclarationName declarationName =
2043 GetDeclarationName(name, function_clang_type);
2044 func_decl = FunctionDecl::Create(
2045 *ast, decl_ctx, SourceLocation(), SourceLocation(), declarationName,
2046 ClangUtil::GetQualType(function_clang_type), nullptr,
2047 (clang::StorageClass)storage, is_inline, hasWrittenPrototype,
2048 isConstexprSpecified);
2049 if (func_decl)
2050 decl_ctx->addDecl(func_decl);
2051
2052#ifdef LLDB_CONFIGURATION_DEBUG
2053 VerifyDecl(func_decl);
2054#endif
2055
2056 return func_decl;
2057}
2058
2059CompilerType ClangASTContext::CreateFunctionType(
2060 ASTContext *ast, const CompilerType &result_type, const CompilerType *args,
2061 unsigned num_args, bool is_variadic, unsigned type_quals,
2062 clang::CallingConv cc) {
2063 if (ast == nullptr)
2064 return CompilerType(); // invalid AST
2065
2066 if (!result_type || !ClangUtil::IsClangType(result_type))
2067 return CompilerType(); // invalid return type
2068
2069 std::vector<QualType> qual_type_args;
2070 if (num_args > 0 && args == nullptr)
2071 return CompilerType(); // invalid argument array passed in
2072
2073 // Verify that all arguments are valid and the right type
2074 for (unsigned i = 0; i < num_args; ++i) {
2075 if (args[i]) {
2076 // Make sure we have a clang type in args[i] and not a type from another
2077 // language whose name might match
2078 const bool is_clang_type = ClangUtil::IsClangType(args[i]);
2079 lldbassert(is_clang_type)lldb_private::lldb_assert(static_cast<bool>(is_clang_type
), "is_clang_type", __FUNCTION__, "/build/llvm-toolchain-snapshot-8~svn345461/tools/lldb/source/Symbol/ClangASTContext.cpp"
, 2079)
;
2080 if (is_clang_type)
2081 qual_type_args.push_back(ClangUtil::GetQualType(args[i]));
2082 else
2083 return CompilerType(); // invalid argument type (must be a clang type)
2084 } else
2085 return CompilerType(); // invalid argument type (empty)
2086 }
2087
2088 // TODO: Detect calling convention in DWARF?
2089 FunctionProtoType::ExtProtoInfo proto_info;
2090 proto_info.ExtInfo = cc;
2091 proto_info.Variadic = is_variadic;
2092 proto_info.ExceptionSpec = EST_None;
2093 proto_info.TypeQuals = type_quals;
2094 proto_info.RefQualifier = RQ_None;
2095
2096 return CompilerType(ast,
2097 ast->getFunctionType(ClangUtil::GetQualType(result_type),
2098 qual_type_args, proto_info));
2099}
2100
2101ParmVarDecl *ClangASTContext::CreateParameterDeclaration(
2102 const char *name, const CompilerType &param_type, int storage) {
2103 ASTContext *ast = getASTContext();
2104 assert(ast != nullptr)((ast != nullptr) ? static_cast<void> (0) : __assert_fail
("ast != nullptr", "/build/llvm-toolchain-snapshot-8~svn345461/tools/lldb/source/Symbol/ClangASTContext.cpp"
, 2104, __PRETTY_FUNCTION__))
;
2105 return ParmVarDecl::Create(*ast, ast->getTranslationUnitDecl(),
2106 SourceLocation(), SourceLocation(),
2107 name && name[0] ? &ast->Idents.get(name) : nullptr,
2108 ClangUtil::GetQualType(param_type), nullptr,
2109 (clang::StorageClass)storage, nullptr);
2110}
2111
2112void ClangASTContext::SetFunctionParameters(FunctionDecl *function_decl,
2113 ParmVarDecl **params,
2114 unsigned num_params) {
2115 if (function_decl)
2116 function_decl->setParams(ArrayRef<ParmVarDecl *>(params, num_params));
2117}
2118
2119CompilerType
2120ClangASTContext::CreateBlockPointerType(const CompilerType &function_type) {
2121 QualType block_type = m_ast_ap->getBlockPointerType(
2122 clang::QualType::getFromOpaquePtr(function_type.GetOpaqueQualType()));
2123
2124 return CompilerType(this, block_type.getAsOpaquePtr());
2125}
2126
2127#pragma mark Array Types
2128
2129CompilerType ClangASTContext::CreateArrayType(const CompilerType &element_type,
2130 size_t element_count,
2131 bool is_vector) {
2132 if (element_type.IsValid()) {
2133 ASTContext *ast = getASTContext();
2134 assert(ast != nullptr)((ast != nullptr) ? static_cast<void> (0) : __assert_fail
("ast != nullptr", "/build/llvm-toolchain-snapshot-8~svn345461/tools/lldb/source/Symbol/ClangASTContext.cpp"
, 2134, __PRETTY_FUNCTION__))
;
2135
2136 if (is_vector) {
2137 return CompilerType(
2138 ast, ast->getExtVectorType(ClangUtil::GetQualType(element_type),
2139 element_count));
2140 } else {
2141
2142 llvm::APInt ap_element_count(64, element_count);
2143 if (element_count == 0) {
2144 return CompilerType(ast, ast->getIncompleteArrayType(
2145 ClangUtil::GetQualType(element_type),
2146 clang::ArrayType::Normal, 0));
2147 } else {
2148 return CompilerType(
2149 ast, ast->getConstantArrayType(ClangUtil::GetQualType(element_type),
2150 ap_element_count,
2151 clang::ArrayType::Normal, 0));
2152 }
2153 }
2154 }
2155 return CompilerType();
2156}
2157
2158CompilerType ClangASTContext::CreateStructForIdentifier(
2159 const ConstString &type_name,
2160 const std::initializer_list<std::pair<const char *, CompilerType>>
2161 &type_fields,
2162 bool packed) {
2163 CompilerType type;
2164 if (!type_name.IsEmpty() &&
2165 (type = GetTypeForIdentifier<clang::CXXRecordDecl>(type_name))
2166 .IsValid()) {
2167 lldbassert(0 && "Trying to create a type for an existing name")lldb_private::lldb_assert(static_cast<bool>(0 &&
"Trying to create a type for an existing name"), "0 && \"Trying to create a type for an existing name\""
, __FUNCTION__, "/build/llvm-toolchain-snapshot-8~svn345461/tools/lldb/source/Symbol/ClangASTContext.cpp"
, 2167)
;
2168 return type;
2169 }
2170
2171 type = CreateRecordType(nullptr, lldb::eAccessPublic, type_name.GetCString(),
2172 clang::TTK_Struct, lldb::eLanguageTypeC);
2173 StartTagDeclarationDefinition(type);
2174 for (const auto &field : type_fields)
2175 AddFieldToRecordType(type, field.first, field.second, lldb::eAccessPublic,
2176 0);
2177 if (packed)
2178 SetIsPacked(type);
2179 CompleteTagDeclarationDefinition(type);
2180 return type;
2181}
2182
2183CompilerType ClangASTContext::GetOrCreateStructForIdentifier(
2184 const ConstString &type_name,
2185 const std::initializer_list<std::pair<const char *, CompilerType>>
2186 &type_fields,
2187 bool packed) {
2188 CompilerType type;
2189 if ((type = GetTypeForIdentifier<clang::CXXRecordDecl>(type_name)).IsValid())
2190 return type;
2191
2192 return CreateStructForIdentifier(type_name, type_fields, packed);
2193}
2194
2195#pragma mark Enumeration Types
2196
2197CompilerType
2198ClangASTContext::CreateEnumerationType(const char *name, DeclContext *decl_ctx,
2199 const Declaration &decl,
2200 const CompilerType &integer_clang_type,
2201 bool is_scoped) {
2202 // TODO: Do something intelligent with the Declaration object passed in
2203 // like maybe filling in the SourceLocation with it...
2204 ASTContext *ast = getASTContext();
2205
2206 // TODO: ask about these...
2207 // const bool IsFixed = false;
2208
2209 EnumDecl *enum_decl = EnumDecl::Create(
2210 *ast, decl_ctx, SourceLocation(), SourceLocation(),
2211 name && name[0] ? &ast->Idents.get(name) : nullptr, nullptr,
2212 is_scoped, // IsScoped
2213 is_scoped, // IsScopedUsingClassTag
2214 false); // IsFixed
2215
2216 if (enum_decl) {
2217 if (decl_ctx)
2218 decl_ctx->addDecl(enum_decl);
2219
2220 // TODO: check if we should be setting the promotion type too?
2221 enum_decl->setIntegerType(ClangUtil::GetQualType(integer_clang_type));
2222
2223 enum_decl->setAccess(AS_public); // TODO respect what's in the debug info
2224
2225 return CompilerType(ast, ast->getTagDeclType(enum_decl));
2226 }
2227 return CompilerType();
2228}
2229
2230CompilerType ClangASTContext::GetIntTypeFromBitSize(clang::ASTContext *ast,
2231 size_t bit_size,
2232 bool is_signed) {
2233 if (ast) {
2234 if (is_signed) {
2235 if (bit_size == ast->getTypeSize(ast->SignedCharTy))
2236 return CompilerType(ast, ast->SignedCharTy);
2237
2238 if (bit_size == ast->getTypeSize(ast->ShortTy))
2239 return CompilerType(ast, ast->ShortTy);
2240
2241 if (bit_size == ast->getTypeSize(ast->IntTy))
2242 return CompilerType(ast, ast->IntTy);
2243
2244 if (bit_size == ast->getTypeSize(ast->LongTy))
2245 return CompilerType(ast, ast->LongTy);
2246
2247 if (bit_size == ast->getTypeSize(ast->LongLongTy))
2248 return CompilerType(ast, ast->LongLongTy);
2249
2250 if (bit_size == ast->getTypeSize(ast->Int128Ty))
2251 return CompilerType(ast, ast->Int128Ty);
2252 } else {
2253 if (bit_size == ast->getTypeSize(ast->UnsignedCharTy))
2254 return CompilerType(ast, ast->UnsignedCharTy);
2255
2256 if (bit_size == ast->getTypeSize(ast->UnsignedShortTy))
2257 return CompilerType(ast, ast->UnsignedShortTy);
2258
2259 if (bit_size == ast->getTypeSize(ast->UnsignedIntTy))
2260 return CompilerType(ast, ast->UnsignedIntTy);
2261
2262 if (bit_size == ast->getTypeSize(ast->UnsignedLongTy))
2263 return CompilerType(ast, ast->UnsignedLongTy);
2264
2265 if (bit_size == ast->getTypeSize(ast->UnsignedLongLongTy))
2266 return CompilerType(ast, ast->UnsignedLongLongTy);
2267
2268 if (bit_size == ast->getTypeSize(ast->UnsignedInt128Ty))
2269 return CompilerType(ast, ast->UnsignedInt128Ty);
2270 }
2271 }
2272 return CompilerType();
2273}
2274
2275CompilerType ClangASTContext::GetPointerSizedIntType(clang::ASTContext *ast,
2276 bool is_signed) {
2277 if (ast)
2278 return GetIntTypeFromBitSize(ast, ast->getTypeSize(ast->VoidPtrTy),
2279 is_signed);
2280 return CompilerType();
2281}
2282
2283void ClangASTContext::DumpDeclContextHiearchy(clang::DeclContext *decl_ctx) {
2284 if (decl_ctx) {
2285 DumpDeclContextHiearchy(decl_ctx->getParent());
2286
2287 clang::NamedDecl *named_decl = llvm::dyn_cast<clang::NamedDecl>(decl_ctx);
2288 if (named_decl) {
2289 printf("%20s: %s\n", decl_ctx->getDeclKindName(),
2290 named_decl->getDeclName().getAsString().c_str());
2291 } else {
2292 printf("%20s\n", decl_ctx->getDeclKindName());
2293 }
2294 }
2295}
2296
2297void ClangASTContext::DumpDeclHiearchy(clang::Decl *decl) {
2298 if (decl == nullptr)
2299 return;
2300 DumpDeclContextHiearchy(decl->getDeclContext());
2301
2302 clang::RecordDecl *record_decl = llvm::dyn_cast<clang::RecordDecl>(decl);
2303 if (record_decl) {
2304 printf("%20s: %s%s\n", decl->getDeclKindName(),
2305 record_decl->getDeclName().getAsString().c_str(),
2306 record_decl->isInjectedClassName() ? " (injected class name)" : "");
2307
2308 } else {
2309 clang::NamedDecl *named_decl = llvm::dyn_cast<clang::NamedDecl>(decl);
2310 if (named_decl) {
2311 printf("%20s: %s\n", decl->getDeclKindName(),
2312 named_decl->getDeclName().getAsString().c_str());
2313 } else {
2314 printf("%20s\n", decl->getDeclKindName());
2315 }
2316 }
2317}
2318
2319bool ClangASTContext::DeclsAreEquivalent(clang::Decl *lhs_decl,
2320 clang::Decl *rhs_decl) {
2321 if (lhs_decl && rhs_decl) {
2322 //----------------------------------------------------------------------
2323 // Make sure the decl kinds match first
2324 //----------------------------------------------------------------------
2325 const clang::Decl::Kind lhs_decl_kind = lhs_decl->getKind();
2326 const clang::Decl::Kind rhs_decl_kind = rhs_decl->getKind();
2327
2328 if (lhs_decl_kind == rhs_decl_kind) {
2329 //------------------------------------------------------------------
2330 // Now check that the decl contexts kinds are all equivalent before we
2331 // have to check any names of the decl contexts...
2332 //------------------------------------------------------------------
2333 clang::DeclContext *lhs_decl_ctx = lhs_decl->getDeclContext();
2334 clang::DeclContext *rhs_decl_ctx = rhs_decl->getDeclContext();
2335 if (lhs_decl_ctx && rhs_decl_ctx) {
2336 while (1) {
2337 if (lhs_decl_ctx && rhs_decl_ctx) {
2338 const clang::Decl::Kind lhs_decl_ctx_kind =
2339 lhs_decl_ctx->getDeclKind();
2340 const clang::Decl::Kind rhs_decl_ctx_kind =
2341 rhs_decl_ctx->getDeclKind();
2342 if (lhs_decl_ctx_kind == rhs_decl_ctx_kind) {
2343 lhs_decl_ctx = lhs_decl_ctx->getParent();
2344 rhs_decl_ctx = rhs_decl_ctx->getParent();
2345
2346 if (lhs_decl_ctx == nullptr && rhs_decl_ctx == nullptr)
2347 break;
2348 } else
2349 return false;
2350 } else
2351 return false;
2352 }
2353
2354 //--------------------------------------------------------------
2355 // Now make sure the name of the decls match
2356 //--------------------------------------------------------------
2357 clang::NamedDecl *lhs_named_decl =
2358 llvm::dyn_cast<clang::NamedDecl>(lhs_decl);
2359 clang::NamedDecl *rhs_named_decl =
2360 llvm::dyn_cast<clang::NamedDecl>(rhs_decl);
2361 if (lhs_named_decl && rhs_named_decl) {
2362 clang::DeclarationName lhs_decl_name = lhs_named_decl->getDeclName();
2363 clang::DeclarationName rhs_decl_name = rhs_named_decl->getDeclName();
2364 if (lhs_decl_name.getNameKind() == rhs_decl_name.getNameKind()) {
2365 if (lhs_decl_name.getAsString() != rhs_decl_name.getAsString())
2366 return false;
2367 } else
2368 return false;
2369 } else
2370 return false;
2371
2372 //--------------------------------------------------------------
2373 // We know that the decl context kinds all match, so now we need to
2374 // make sure the names match as well
2375 //--------------------------------------------------------------
2376 lhs_decl_ctx = lhs_decl->getDeclContext();
2377 rhs_decl_ctx = rhs_decl->getDeclContext();
2378 while (1) {
2379 switch (lhs_decl_ctx->getDeclKind()) {
2380 case clang::Decl::TranslationUnit:
2381 // We don't care about the translation unit names
2382 return true;
2383 default: {
2384 clang::NamedDecl *lhs_named_decl =
2385 llvm::dyn_cast<clang::NamedDecl>(lhs_decl_ctx);
2386 clang::NamedDecl *rhs_named_decl =
2387 llvm::dyn_cast<clang::NamedDecl>(rhs_decl_ctx);
2388 if (lhs_named_decl && rhs_named_decl) {
2389 clang::DeclarationName lhs_decl_name =
2390 lhs_named_decl->getDeclName();
2391 clang::DeclarationName rhs_decl_name =
2392 rhs_named_decl->getDeclName();
2393 if (lhs_decl_name.getNameKind() == rhs_decl_name.getNameKind()) {
2394 if (lhs_decl_name.getAsString() != rhs_decl_name.getAsString())
2395 return false;
2396 } else
2397 return false;
2398 } else
2399 return false;
2400 } break;
2401 }
2402 lhs_decl_ctx = lhs_decl_ctx->getParent();
2403 rhs_decl_ctx = rhs_decl_ctx->getParent();
2404 }
2405 }
2406 }
2407 }
2408 return false;
2409}
2410bool ClangASTContext::GetCompleteDecl(clang::ASTContext *ast,
2411 clang::Decl *decl) {
2412 if (!decl)
2413 return false;
2414
2415 ExternalASTSource *ast_source = ast->getExternalSource();
2416
2417 if (!ast_source)
2418 return false;
2419
2420 if (clang::TagDecl *tag_decl = llvm::dyn_cast<clang::TagDecl>(decl)) {
2421 if (tag_decl->isCompleteDefinition())
2422 return true;
2423
2424 if (!tag_decl->hasExternalLexicalStorage())
2425 return false;
2426
2427 ast_source->CompleteType(tag_decl);
2428
2429 return !tag_decl->getTypeForDecl()->isIncompleteType();
2430 } else if (clang::ObjCInterfaceDecl *objc_interface_decl =
2431 llvm::dyn_cast<clang::ObjCInterfaceDecl>(decl)) {
2432 if (objc_interface_decl->getDefinition())
2433 return true;
2434
2435 if (!objc_interface_decl->hasExternalLexicalStorage())
2436 return false;
2437
2438 ast_source->CompleteType(objc_interface_decl);
2439
2440 return !objc_interface_decl->getTypeForDecl()->isIncompleteType();
2441 } else {
2442 return false;
2443 }
2444}
2445
2446void ClangASTContext::SetMetadataAsUserID(const void *object,
2447 user_id_t user_id) {
2448 ClangASTMetadata meta_data;
2449 meta_data.SetUserID(user_id);
2450 SetMetadata(object, meta_data);
2451}
2452
2453void ClangASTContext::SetMetadata(clang::ASTContext *ast, const void *object,
2454 ClangASTMetadata &metadata) {
2455 ClangExternalASTSourceCommon *external_source =
2456 ClangExternalASTSourceCommon::Lookup(ast->getExternalSource());
2457
2458 if (external_source)
2459 external_source->SetMetadata(object, metadata);
2460}
2461
2462ClangASTMetadata *ClangASTContext::GetMetadata(clang::ASTContext *ast,
2463 const void *object) {
2464 ClangExternalASTSourceCommon *external_source =
2465 ClangExternalASTSourceCommon::Lookup(ast->getExternalSource());
2466
2467 if (external_source && external_source->HasMetadata(object))
2468 return external_source->GetMetadata(object);
2469 else
2470 return nullptr;
2471}
2472
2473clang::DeclContext *
2474ClangASTContext::GetAsDeclContext(clang::CXXMethodDecl *cxx_method_decl) {
2475 return llvm::dyn_cast<clang::DeclContext>(cxx_method_decl);
2476}
2477
2478clang::DeclContext *
2479ClangASTContext::GetAsDeclContext(clang::ObjCMethodDecl *objc_method_decl) {
2480 return llvm::dyn_cast<clang::DeclContext>(objc_method_decl);
2481}
2482
2483bool ClangASTContext::SetTagTypeKind(clang::QualType tag_qual_type,
2484 int kind) const {
2485 const clang::Type *clang_type = tag_qual_type.getTypePtr();
2486 if (clang_type) {
2487 const clang::TagType *tag_type = llvm::dyn_cast<clang::TagType>(clang_type);
2488 if (tag_type) {
2489 clang::TagDecl *tag_decl =
2490 llvm::dyn_cast<clang::TagDecl>(tag_type->getDecl());
2491 if (tag_decl) {
2492 tag_decl->setTagKind((clang::TagDecl::TagKind)kind);
2493 return true;
2494 }
2495 }
2496 }
2497 return false;
2498}
2499
2500bool ClangASTContext::SetDefaultAccessForRecordFields(
2501 clang::RecordDecl *record_decl, int default_accessibility,
2502 int *assigned_accessibilities, size_t num_assigned_accessibilities) {
2503 if (record_decl) {
2504 uint32_t field_idx;
2505 clang::RecordDecl::field_iterator field, field_end;
2506 for (field = record_decl->field_begin(),
2507 field_end = record_decl->field_end(), field_idx = 0;
2508 field != field_end; ++field, ++field_idx) {
2509 // If no accessibility was assigned, assign the correct one
2510 if (field_idx < num_assigned_accessibilities &&
2511 assigned_accessibilities[field_idx] == clang::AS_none)
2512 field->setAccess((clang::AccessSpecifier)default_accessibility);
2513 }
2514 return true;
2515 }
2516 return false;
2517}
2518
2519clang::DeclContext *
2520ClangASTContext::GetDeclContextForType(const CompilerType &type) {
2521 return GetDeclContextForType(ClangUtil::GetQualType(type));
2522}
2523
2524clang::DeclContext *
2525ClangASTContext::GetDeclContextForType(clang::QualType type) {
2526 if (type.isNull())
2527 return nullptr;
2528
2529 clang::QualType qual_type = type.getCanonicalType();
2530 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
2531 switch (type_class) {
2532 case clang::Type::ObjCInterface:
2533 return llvm::cast<clang::ObjCObjectType>(qual_type.getTypePtr())
2534 ->getInterface();
2535 case clang::Type::ObjCObjectPointer:
2536 return GetDeclContextForType(
2537 llvm::cast<clang::ObjCObjectPointerType>(qual_type.getTypePtr())
2538 ->getPointeeType());
2539 case clang::Type::Record:
2540 return llvm::cast<clang::RecordType>(qual_type)->getDecl();
2541 case clang::Type::Enum:
2542 return llvm::cast<clang::EnumType>(qual_type)->getDecl();
2543 case clang::Type::Typedef:
2544 return GetDeclContextForType(llvm::cast<clang::TypedefType>(qual_type)
2545 ->getDecl()
2546 ->getUnderlyingType());
2547 case clang::Type::Auto:
2548 return GetDeclContextForType(
2549 llvm::cast<clang::AutoType>(qual_type)->getDeducedType());
2550 case clang::Type::Elaborated:
2551 return GetDeclContextForType(
2552 llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType());
2553 case clang::Type::Paren:
2554 return GetDeclContextForType(
2555 llvm::cast<clang::ParenType>(qual_type)->desugar());
2556 default:
2557 break;
2558 }
2559 // No DeclContext in this type...
2560 return nullptr;
2561}
2562
2563static bool GetCompleteQualType(clang::ASTContext *ast,
2564 clang::QualType qual_type,
2565 bool allow_completion = true) {
2566 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
2567 switch (type_class) {
2568 case clang::Type::ConstantArray:
2569 case clang::Type::IncompleteArray:
2570 case clang::Type::VariableArray: {
2571 const clang::ArrayType *array_type =
2572 llvm::dyn_cast<clang::ArrayType>(qual_type.getTypePtr());
2573
2574 if (array_type)
2575 return GetCompleteQualType(ast, array_type->getElementType(),
2576 allow_completion);
2577 } break;
2578 case clang::Type::Record: {
2579 clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl();
2580 if (cxx_record_decl) {
2581 if (cxx_record_decl->hasExternalLexicalStorage()) {
2582 const bool is_complete = cxx_record_decl->isCompleteDefinition();
2583 const bool fields_loaded =
2584 cxx_record_decl->hasLoadedFieldsFromExternalStorage();
2585 if (is_complete && fields_loaded)
2586 return true;
2587
2588 if (!allow_completion)
2589 return false;
2590
2591 // Call the field_begin() accessor to for it to use the external source
2592 // to load the fields...
2593 clang::ExternalASTSource *external_ast_source =
2594 ast->getExternalSource();
2595 if (external_ast_source) {
2596 external_ast_source->CompleteType(cxx_record_decl);
2597 if (cxx_record_decl->isCompleteDefinition()) {
2598 cxx_record_decl->field_begin();
2599 cxx_record_decl->setHasLoadedFieldsFromExternalStorage(true);
2600 }
2601 }
2602 }
2603 }
2604 const clang::TagType *tag_type =
2605 llvm::cast<clang::TagType>(qual_type.getTypePtr());
2606 return !tag_type->isIncompleteType();
2607 } break;
2608
2609 case clang::Type::Enum: {
2610 const clang::TagType *tag_type =
2611 llvm::dyn_cast<clang::TagType>(qual_type.getTypePtr());
2612 if (tag_type) {
2613 clang::TagDecl *tag_decl = tag_type->getDecl();
2614 if (tag_decl) {
2615 if (tag_decl->getDefinition())
2616 return true;
2617
2618 if (!allow_completion)
2619 return false;
2620
2621 if (tag_decl->hasExternalLexicalStorage()) {
2622 if (ast) {
2623 clang::ExternalASTSource *external_ast_source =
2624 ast->getExternalSource();
2625 if (external_ast_source) {
2626 external_ast_source->CompleteType(tag_decl);
2627 return !tag_type->isIncompleteType();
2628 }
2629 }
2630 }
2631 return false;
2632 }
2633 }
2634
2635 } break;
2636 case clang::Type::ObjCObject:
2637 case clang::Type::ObjCInterface: {
2638 const clang::ObjCObjectType *objc_class_type =
2639 llvm::dyn_cast<clang::ObjCObjectType>(qual_type);
2640 if (objc_class_type) {
2641 clang::ObjCInterfaceDecl *class_interface_decl =
2642 objc_class_type->getInterface();
2643 // We currently can't complete objective C types through the newly added
2644 // ASTContext because it only supports TagDecl objects right now...
2645 if (class_interface_decl) {
2646 if (class_interface_decl->getDefinition())
2647 return true;
2648
2649 if (!allow_completion)
2650 return false;
2651
2652 if (class_interface_decl->hasExternalLexicalStorage()) {
2653 if (ast) {
2654 clang::ExternalASTSource *external_ast_source =
2655 ast->getExternalSource();
2656 if (external_ast_source) {
2657 external_ast_source->CompleteType(class_interface_decl);
2658 return !objc_class_type->isIncompleteType();
2659 }
2660 }
2661 }
2662 return false;
2663 }
2664 }
2665 } break;
2666
2667 case clang::Type::Typedef:
2668 return GetCompleteQualType(ast, llvm::cast<clang::TypedefType>(qual_type)
2669 ->getDecl()
2670 ->getUnderlyingType(),
2671 allow_completion);
2672
2673 case clang::Type::Auto:
2674 return GetCompleteQualType(
2675 ast, llvm::cast<clang::AutoType>(qual_type)->getDeducedType(),
2676 allow_completion);
2677
2678 case clang::Type::Elaborated:
2679 return GetCompleteQualType(
2680 ast, llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType(),
2681 allow_completion);
2682
2683 case clang::Type::Paren:
2684 return GetCompleteQualType(
2685 ast, llvm::cast<clang::ParenType>(qual_type)->desugar(),
2686 allow_completion);
2687
2688 case clang::Type::Attributed:
2689 return GetCompleteQualType(
2690 ast, llvm::cast<clang::AttributedType>(qual_type)->getModifiedType(),
2691 allow_completion);
2692
2693 default:
2694 break;
2695 }
2696
2697 return true;
2698}
2699
2700static clang::ObjCIvarDecl::AccessControl
2701ConvertAccessTypeToObjCIvarAccessControl(AccessType access) {
2702 switch (access) {
2703 case eAccessNone:
2704 return clang::ObjCIvarDecl::None;
2705 case eAccessPublic:
2706 return clang::ObjCIvarDecl::Public;
2707 case eAccessPrivate:
2708 return clang::ObjCIvarDecl::Private;
2709 case eAccessProtected:
2710 return clang::ObjCIvarDecl::Protected;
2711 case eAccessPackage:
2712 return clang::ObjCIvarDecl::Package;
2713 }
2714 return clang::ObjCIvarDecl::None;
2715}
2716
2717//----------------------------------------------------------------------
2718// Tests
2719//----------------------------------------------------------------------
2720
2721bool ClangASTContext::IsAggregateType(lldb::opaque_compiler_type_t type) {
2722 clang::QualType qual_type(GetCanonicalQualType(type));
2723
2724 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
2725 switch (type_class) {
2726 case clang::Type::IncompleteArray:
2727 case clang::Type::VariableArray:
2728 case clang::Type::ConstantArray:
2729 case clang::Type::ExtVector:
2730 case clang::Type::Vector:
2731 case clang::Type::Record:
2732 case clang::Type::ObjCObject:
2733 case clang::Type::ObjCInterface:
2734 return true;
2735 case clang::Type::Auto:
2736 return IsAggregateType(llvm::cast<clang::AutoType>(qual_type)
2737 ->getDeducedType()
2738 .getAsOpaquePtr());
2739 case clang::Type::Elaborated:
2740 return IsAggregateType(llvm::cast<clang::ElaboratedType>(qual_type)
2741 ->getNamedType()
2742 .getAsOpaquePtr());
2743 case clang::Type::Typedef:
2744 return IsAggregateType(llvm::cast<clang::TypedefType>(qual_type)
2745 ->getDecl()
2746 ->getUnderlyingType()
2747 .getAsOpaquePtr());
2748 case clang::Type::Paren:
2749 return IsAggregateType(
2750 llvm::cast<clang::ParenType>(qual_type)->desugar().getAsOpaquePtr());
2751 default:
2752 break;
2753 }
2754 // The clang type does have a value
2755 return false;
2756}
2757
2758bool ClangASTContext::IsAnonymousType(lldb::opaque_compiler_type_t type) {
2759 clang::QualType qual_type(GetCanonicalQualType(type));
2760
2761 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
2762 switch (type_class) {
2763 case clang::Type::Record: {
2764 if (const clang::RecordType *record_type =
2765 llvm::dyn_cast_or_null<clang::RecordType>(
2766 qual_type.getTypePtrOrNull())) {
2767 if (const clang::RecordDecl *record_decl = record_type->getDecl()) {
2768 return record_decl->isAnonymousStructOrUnion();
2769 }
2770 }
2771 break;
2772 }
2773 case clang::Type::Auto:
2774 return IsAnonymousType(llvm::cast<clang::AutoType>(qual_type)
2775 ->getDeducedType()
2776 .getAsOpaquePtr());
2777 case clang::Type::Elaborated:
2778 return IsAnonymousType(llvm::cast<clang::ElaboratedType>(qual_type)
2779 ->getNamedType()
2780 .getAsOpaquePtr());
2781 case clang::Type::Typedef:
2782 return IsAnonymousType(llvm::cast<clang::TypedefType>(qual_type)
2783 ->getDecl()
2784 ->getUnderlyingType()
2785 .getAsOpaquePtr());
2786 case clang::Type::Paren:
2787 return IsAnonymousType(
2788 llvm::cast<clang::ParenType>(qual_type)->desugar().getAsOpaquePtr());
2789 default:
2790 break;
2791 }
2792 // The clang type does have a value
2793 return false;
2794}
2795
2796bool ClangASTContext::IsArrayType(lldb::opaque_compiler_type_t type,
2797 CompilerType *element_type_ptr,
2798 uint64_t *size, bool *is_incomplete) {
2799 clang::QualType qual_type(GetCanonicalQualType(type));
2800
2801 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
2802 switch (type_class) {
2803 default:
2804 break;
2805
2806 case clang::Type::ConstantArray:
2807 if (element_type_ptr)
2808 element_type_ptr->SetCompilerType(
2809 getASTContext(),
2810 llvm::cast<clang::ConstantArrayType>(qual_type)->getElementType());
2811 if (size)
2812 *size = llvm::cast<clang::ConstantArrayType>(qual_type)
2813 ->getSize()
2814 .getLimitedValue(ULLONG_MAX(9223372036854775807LL*2ULL+1ULL));
2815 if (is_incomplete)
2816 *is_incomplete = false;
2817 return true;
2818
2819 case clang::Type::IncompleteArray:
2820 if (element_type_ptr)
2821 element_type_ptr->SetCompilerType(
2822 getASTContext(),
2823 llvm::cast<clang::IncompleteArrayType>(qual_type)->getElementType());
2824 if (size)
2825 *size = 0;
2826 if (is_incomplete)
2827 *is_incomplete = true;
2828 return true;
2829
2830 case clang::Type::VariableArray:
2831 if (element_type_ptr)
2832 element_type_ptr->SetCompilerType(
2833 getASTContext(),
2834 llvm::cast<clang::VariableArrayType>(qual_type)->getElementType());
2835 if (size)
2836 *size = 0;
2837 if (is_incomplete)
2838 *is_incomplete = false;
2839 return true;
2840
2841 case clang::Type::DependentSizedArray:
2842 if (element_type_ptr)
2843 element_type_ptr->SetCompilerType(
2844 getASTContext(), llvm::cast<clang::DependentSizedArrayType>(qual_type)
2845 ->getElementType());
2846 if (size)
2847 *size = 0;
2848 if (is_incomplete)
2849 *is_incomplete = false;
2850 return true;
2851
2852 case clang::Type::Typedef:
2853 return IsArrayType(llvm::cast<clang::TypedefType>(qual_type)
2854 ->getDecl()
2855 ->getUnderlyingType()
2856 .getAsOpaquePtr(),
2857 element_type_ptr, size, is_incomplete);
2858 case clang::Type::Auto:
2859 return IsArrayType(llvm::cast<clang::AutoType>(qual_type)
2860 ->getDeducedType()
2861 .getAsOpaquePtr(),
2862 element_type_ptr, size, is_incomplete);
2863 case clang::Type::Elaborated:
2864 return IsArrayType(llvm::cast<clang::ElaboratedType>(qual_type)
2865 ->getNamedType()
2866 .getAsOpaquePtr(),
2867 element_type_ptr, size, is_incomplete);
2868 case clang::Type::Paren:
2869 return IsArrayType(
2870 llvm::cast<clang::ParenType>(qual_type)->desugar().getAsOpaquePtr(),
2871 element_type_ptr, size, is_incomplete);
2872 }
2873 if (element_type_ptr)
2874 element_type_ptr->Clear();
2875 if (size)
2876 *size = 0;
2877 if (is_incomplete)
2878 *is_incomplete = false;
2879 return false;
2880}
2881
2882bool ClangASTContext::IsVectorType(lldb::opaque_compiler_type_t type,
2883 CompilerType *element_type, uint64_t *size) {
2884 clang::QualType qual_type(GetCanonicalQualType(type));
2885
2886 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
2887 switch (type_class) {
2888 case clang::Type::Vector: {
2889 const clang::VectorType *vector_type =
2890 qual_type->getAs<clang::VectorType>();
2891 if (vector_type) {
2892 if (size)
2893 *size = vector_type->getNumElements();
2894 if (element_type)
2895 *element_type =
2896 CompilerType(getASTContext(), vector_type->getElementType());
2897 }
2898 return true;
2899 } break;
2900 case clang::Type::ExtVector: {
2901 const clang::ExtVectorType *ext_vector_type =
2902 qual_type->getAs<clang::ExtVectorType>();
2903 if (ext_vector_type) {
2904 if (size)
2905 *size = ext_vector_type->getNumElements();
2906 if (element_type)
2907 *element_type =
2908 CompilerType(getASTContext(), ext_vector_type->getElementType());
2909 }
2910 return true;
2911 }
2912 default:
2913 break;
2914 }
2915 return false;
2916}
2917
2918bool ClangASTContext::IsRuntimeGeneratedType(
2919 lldb::opaque_compiler_type_t type) {
2920 clang::DeclContext *decl_ctx = ClangASTContext::GetASTContext(getASTContext())
2921 ->GetDeclContextForType(GetQualType(type));
2922 if (!decl_ctx)
2923 return false;
2924
2925 if (!llvm::isa<clang::ObjCInterfaceDecl>(decl_ctx))
2926 return false;
2927
2928 clang::ObjCInterfaceDecl *result_iface_decl =
2929 llvm::dyn_cast<clang::ObjCInterfaceDecl>(decl_ctx);
2930
2931 ClangASTMetadata *ast_metadata =
2932 ClangASTContext::GetMetadata(getASTContext(), result_iface_decl);
2933 if (!ast_metadata)
2934 return false;
2935 return (ast_metadata->GetISAPtr() != 0);
2936}
2937
2938bool ClangASTContext::IsCharType(lldb::opaque_compiler_type_t type) {
2939 return GetQualType(type).getUnqualifiedType()->isCharType();
2940}
2941
2942bool ClangASTContext::IsCompleteType(lldb::opaque_compiler_type_t type) {
2943 const bool allow_completion = false;
2944 return GetCompleteQualType(getASTContext(), GetQualType(type),
2945 allow_completion);
2946}
2947
2948bool ClangASTContext::IsConst(lldb::opaque_compiler_type_t type) {
2949 return GetQualType(type).isConstQualified();
2950}
2951
2952bool ClangASTContext::IsCStringType(lldb::opaque_compiler_type_t type,
2953 uint32_t &length) {
2954 CompilerType pointee_or_element_clang_type;
2955 length = 0;
2956 Flags type_flags(GetTypeInfo(type, &pointee_or_element_clang_type));
2957
2958 if (!pointee_or_element_clang_type.IsValid())
2959 return false;
2960
2961 if (type_flags.AnySet(eTypeIsArray | eTypeIsPointer)) {
2962 if (pointee_or_element_clang_type.IsCharType()) {
2963 if (type_flags.Test(eTypeIsArray)) {
2964 // We know the size of the array and it could be a C string since it is
2965 // an array of characters
2966 length = llvm::cast<clang::ConstantArrayType>(
2967 GetCanonicalQualType(type).getTypePtr())
2968 ->getSize()
2969 .getLimitedValue();
2970 }
2971 return true;
2972 }
2973 }
2974 return false;
2975}
2976
2977bool ClangASTContext::IsFunctionType(lldb::opaque_compiler_type_t type,
2978 bool *is_variadic_ptr) {
2979 if (type) {
2980 clang::QualType qual_type(GetCanonicalQualType(type));
2981
2982 if (qual_type->isFunctionType()) {
2983 if (is_variadic_ptr) {
2984 const clang::FunctionProtoType *function_proto_type =
2985 llvm::dyn_cast<clang::FunctionProtoType>(qual_type.getTypePtr());
2986 if (function_proto_type)
2987 *is_variadic_ptr = function_proto_type->isVariadic();
2988 else
2989 *is_variadic_ptr = false;
2990 }
2991 return true;
2992 }
2993
2994 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
2995 switch (type_class) {
2996 default:
2997 break;
2998 case clang::Type::Typedef:
2999 return IsFunctionType(llvm::cast<clang::TypedefType>(qual_type)
3000 ->getDecl()
3001 ->getUnderlyingType()
3002 .getAsOpaquePtr(),
3003 nullptr);
3004 case clang::Type::Auto:
3005 return IsFunctionType(llvm::cast<clang::AutoType>(qual_type)
3006 ->getDeducedType()
3007 .getAsOpaquePtr(),
3008 nullptr);
3009 case clang::Type::Elaborated:
3010 return IsFunctionType(llvm::cast<clang::ElaboratedType>(qual_type)
3011 ->getNamedType()
3012 .getAsOpaquePtr(),
3013 nullptr);
3014 case clang::Type::Paren:
3015 return IsFunctionType(
3016 llvm::cast<clang::ParenType>(qual_type)->desugar().getAsOpaquePtr(),
3017 nullptr);
3018 case clang::Type::LValueReference:
3019 case clang::Type::RValueReference: {
3020 const clang::ReferenceType *reference_type =
3021 llvm::cast<clang::ReferenceType>(qual_type.getTypePtr());
3022 if (reference_type)
3023 return IsFunctionType(reference_type->getPointeeType().getAsOpaquePtr(),
3024 nullptr);
3025 } break;
3026 }
3027 }
3028 return false;
3029}
3030
3031// Used to detect "Homogeneous Floating-point Aggregates"
3032uint32_t
3033ClangASTContext::IsHomogeneousAggregate(lldb::opaque_compiler_type_t type,
3034 CompilerType *base_type_ptr) {
3035 if (!type)
3036 return 0;
3037
3038 clang::QualType qual_type(GetCanonicalQualType(type));
3039 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3040 switch (type_class) {
3041 case clang::Type::Record:
3042 if (GetCompleteType(type)) {
3043 const clang::CXXRecordDecl *cxx_record_decl =
3044 qual_type->getAsCXXRecordDecl();
3045 if (cxx_record_decl) {
3046 if (cxx_record_decl->getNumBases() || cxx_record_decl->isDynamicClass())
3047 return 0;
3048 }
3049 const clang::RecordType *record_type =
3050 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
3051 if (record_type) {
3052 const clang::RecordDecl *record_decl = record_type->getDecl();
3053 if (record_decl) {
3054 // We are looking for a structure that contains only floating point
3055 // types
3056 clang::RecordDecl::field_iterator field_pos,
3057 field_end = record_decl->field_end();
3058 uint32_t num_fields = 0;
3059 bool is_hva = false;
3060 bool is_hfa = false;
3061 clang::QualType base_qual_type;
3062 uint64_t base_bitwidth = 0;
3063 for (field_pos = record_decl->field_begin(); field_pos != field_end;
3064 ++field_pos) {
3065 clang::QualType field_qual_type = field_pos->getType();
3066 uint64_t field_bitwidth = getASTContext()->getTypeSize(qual_type);
3067 if (field_qual_type->isFloatingType()) {
3068 if (field_qual_type->isComplexType())
3069 return 0;
3070 else {
3071 if (num_fields == 0)
3072 base_qual_type = field_qual_type;
3073 else {
3074 if (is_hva)
3075 return 0;
3076 is_hfa = true;
3077 if (field_qual_type.getTypePtr() !=
3078 base_qual_type.getTypePtr())
3079 return 0;
3080 }
3081 }
3082 } else if (field_qual_type->isVectorType() ||
3083 field_qual_type->isExtVectorType()) {
3084 if (num_fields == 0) {
3085 base_qual_type = field_qual_type;
3086 base_bitwidth = field_bitwidth;
3087 } else {
3088 if (is_hfa)
3089 return 0;
3090 is_hva = true;
3091 if (base_bitwidth != field_bitwidth)
3092 return 0;
3093 if (field_qual_type.getTypePtr() != base_qual_type.getTypePtr())
3094 return 0;
3095 }
3096 } else
3097 return 0;
3098 ++num_fields;
3099 }
3100 if (base_type_ptr)
3101 *base_type_ptr = CompilerType(getASTContext(), base_qual_type);
3102 return num_fields;
3103 }
3104 }
3105 }
3106 break;
3107
3108 case clang::Type::Typedef:
3109 return IsHomogeneousAggregate(llvm::cast<clang::TypedefType>(qual_type)
3110 ->getDecl()
3111 ->getUnderlyingType()
3112 .getAsOpaquePtr(),
3113 base_type_ptr);
3114
3115 case clang::Type::Auto:
3116 return IsHomogeneousAggregate(llvm::cast<clang::AutoType>(qual_type)
3117 ->getDeducedType()
3118 .getAsOpaquePtr(),
3119 base_type_ptr);
3120
3121 case clang::Type::Elaborated:
3122 return IsHomogeneousAggregate(llvm::cast<clang::ElaboratedType>(qual_type)
3123 ->getNamedType()
3124 .getAsOpaquePtr(),
3125 base_type_ptr);
3126 default:
3127 break;
3128 }
3129 return 0;
3130}
3131
3132size_t ClangASTContext::GetNumberOfFunctionArguments(
3133 lldb::opaque_compiler_type_t type) {
3134 if (type) {
3135 clang::QualType qual_type(GetCanonicalQualType(type));
3136 const clang::FunctionProtoType *func =
3137 llvm::dyn_cast<clang::FunctionProtoType>(qual_type.getTypePtr());
3138 if (func)
3139 return func->getNumParams();
3140 }
3141 return 0;
3142}
3143
3144CompilerType
3145ClangASTContext::GetFunctionArgumentAtIndex(lldb::opaque_compiler_type_t type,
3146 const size_t index) {
3147 if (type) {
3148 clang::QualType qual_type(GetQualType(type));
3149 const clang::FunctionProtoType *func =
3150 llvm::dyn_cast<clang::FunctionProtoType>(qual_type.getTypePtr());
3151 if (func) {
3152 if (index < func->getNumParams())
3153 return CompilerType(getASTContext(), func->getParamType(index));
3154 }
3155 }
3156 return CompilerType();
3157}
3158
3159bool ClangASTContext::IsFunctionPointerType(lldb::opaque_compiler_type_t type) {
3160 if (type) {
3161 clang::QualType qual_type(GetCanonicalQualType(type));
3162
3163 if (qual_type->isFunctionPointerType())
3164 return true;
3165
3166 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3167 switch (type_class) {
3168 default:
3169 break;
3170 case clang::Type::Typedef:
3171 return IsFunctionPointerType(llvm::cast<clang::TypedefType>(qual_type)
3172 ->getDecl()
3173 ->getUnderlyingType()
3174 .getAsOpaquePtr());
3175 case clang::Type::Auto:
3176 return IsFunctionPointerType(llvm::cast<clang::AutoType>(qual_type)
3177 ->getDeducedType()
3178 .getAsOpaquePtr());
3179 case clang::Type::Elaborated:
3180 return IsFunctionPointerType(llvm::cast<clang::ElaboratedType>(qual_type)
3181 ->getNamedType()
3182 .getAsOpaquePtr());
3183 case clang::Type::Paren:
3184 return IsFunctionPointerType(
3185 llvm::cast<clang::ParenType>(qual_type)->desugar().getAsOpaquePtr());
3186
3187 case clang::Type::LValueReference:
3188 case clang::Type::RValueReference: {
3189 const clang::ReferenceType *reference_type =
3190 llvm::cast<clang::ReferenceType>(qual_type.getTypePtr());
3191 if (reference_type)
3192 return IsFunctionPointerType(
3193 reference_type->getPointeeType().getAsOpaquePtr());
3194 } break;
3195 }
3196 }
3197 return false;
3198}
3199
3200bool ClangASTContext::IsBlockPointerType(
3201 lldb::opaque_compiler_type_t type,
3202 CompilerType *function_pointer_type_ptr) {
3203 if (type) {
3204 clang::QualType qual_type(GetCanonicalQualType(type));
3205
3206 if (qual_type->isBlockPointerType()) {
3207 if (function_pointer_type_ptr) {
3208 const clang::BlockPointerType *block_pointer_type =
3209 qual_type->getAs<clang::BlockPointerType>();
3210 QualType pointee_type = block_pointer_type->getPointeeType();
3211 QualType function_pointer_type = m_ast_ap->getPointerType(pointee_type);
3212 *function_pointer_type_ptr =
3213 CompilerType(getASTContext(), function_pointer_type);
3214 }
3215 return true;
3216 }
3217
3218 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3219 switch (type_class) {
3220 default:
3221 break;
3222 case clang::Type::Typedef:
3223 return IsBlockPointerType(llvm::cast<clang::TypedefType>(qual_type)
3224 ->getDecl()
3225 ->getUnderlyingType()
3226 .getAsOpaquePtr(),
3227 function_pointer_type_ptr);
3228 case clang::Type::Auto:
3229 return IsBlockPointerType(llvm::cast<clang::AutoType>(qual_type)
3230 ->getDeducedType()
3231 .getAsOpaquePtr(),
3232 function_pointer_type_ptr);
3233 case clang::Type::Elaborated:
3234 return IsBlockPointerType(llvm::cast<clang::ElaboratedType>(qual_type)
3235 ->getNamedType()
3236 .getAsOpaquePtr(),
3237 function_pointer_type_ptr);
3238 case clang::Type::Paren:
3239 return IsBlockPointerType(
3240 llvm::cast<clang::ParenType>(qual_type)->desugar().getAsOpaquePtr(),
3241 function_pointer_type_ptr);
3242
3243 case clang::Type::LValueReference:
3244 case clang::Type::RValueReference: {
3245 const clang::ReferenceType *reference_type =
3246 llvm::cast<clang::ReferenceType>(qual_type.getTypePtr());
3247 if (reference_type)
3248 return IsBlockPointerType(
3249 reference_type->getPointeeType().getAsOpaquePtr(),
3250 function_pointer_type_ptr);
3251 } break;
3252 }
3253 }
3254 return false;
3255}
3256
3257bool ClangASTContext::IsIntegerType(lldb::opaque_compiler_type_t type,
3258 bool &is_signed) {
3259 if (!type)
3260 return false;
3261
3262 clang::QualType qual_type(GetCanonicalQualType(type));
3263 const clang::BuiltinType *builtin_type =
3264 llvm::dyn_cast<clang::BuiltinType>(qual_type->getCanonicalTypeInternal());
3265
3266 if (builtin_type) {
3267 if (builtin_type->isInteger()) {
3268 is_signed = builtin_type->isSignedInteger();
3269 return true;
3270 }
3271 }
3272
3273 return false;
3274}
3275
3276bool ClangASTContext::IsEnumerationType(lldb::opaque_compiler_type_t type,
3277 bool &is_signed) {
3278 if (type) {
3279 const clang::EnumType *enum_type = llvm::dyn_cast<clang::EnumType>(
3280 GetCanonicalQualType(type)->getCanonicalTypeInternal());
3281
3282 if (enum_type) {
3283 IsIntegerType(enum_type->getDecl()->getIntegerType().getAsOpaquePtr(),
3284 is_signed);
3285 return true;
3286 }
3287 }
3288
3289 return false;
3290}
3291
3292bool ClangASTContext::IsPointerType(lldb::opaque_compiler_type_t type,
3293 CompilerType *pointee_type) {
3294 if (type) {
3295 clang::QualType qual_type(GetCanonicalQualType(type));
3296 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3297 switch (type_class) {
3298 case clang::Type::Builtin:
3299 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
3300 default:
3301 break;
3302 case clang::BuiltinType::ObjCId:
3303 case clang::BuiltinType::ObjCClass:
3304 return true;
3305 }
3306 return false;
3307 case clang::Type::ObjCObjectPointer:
3308 if (pointee_type)
3309 pointee_type->SetCompilerType(
3310 getASTContext(), llvm::cast<clang::ObjCObjectPointerType>(qual_type)
3311 ->getPointeeType());
3312 return true;
3313 case clang::Type::BlockPointer:
3314 if (pointee_type)
3315 pointee_type->SetCompilerType(
3316 getASTContext(),
3317 llvm::cast<clang::BlockPointerType>(qual_type)->getPointeeType());
3318 return true;
3319 case clang::Type::Pointer:
3320 if (pointee_type)
3321 pointee_type->SetCompilerType(
3322 getASTContext(),
3323 llvm::cast<clang::PointerType>(qual_type)->getPointeeType());
3324 return true;
3325 case clang::Type::MemberPointer:
3326 if (pointee_type)
3327 pointee_type->SetCompilerType(
3328 getASTContext(),
3329 llvm::cast<clang::MemberPointerType>(qual_type)->getPointeeType());
3330 return true;
3331 case clang::Type::Typedef:
3332 return IsPointerType(llvm::cast<clang::TypedefType>(qual_type)
3333 ->getDecl()
3334 ->getUnderlyingType()
3335 .getAsOpaquePtr(),
3336 pointee_type);
3337 case clang::Type::Auto:
3338 return IsPointerType(llvm::cast<clang::AutoType>(qual_type)
3339 ->getDeducedType()
3340 .getAsOpaquePtr(),
3341 pointee_type);
3342 case clang::Type::Elaborated:
3343 return IsPointerType(llvm::cast<clang::ElaboratedType>(qual_type)
3344 ->getNamedType()
3345 .getAsOpaquePtr(),
3346 pointee_type);
3347 case clang::Type::Paren:
3348 return IsPointerType(
3349 llvm::cast<clang::ParenType>(qual_type)->desugar().getAsOpaquePtr(),
3350 pointee_type);
3351 default:
3352 break;
3353 }
3354 }
3355 if (pointee_type)
3356 pointee_type->Clear();
3357 return false;
3358}
3359
3360bool ClangASTContext::IsPointerOrReferenceType(
3361 lldb::opaque_compiler_type_t type, CompilerType *pointee_type) {
3362 if (type) {
3363 clang::QualType qual_type(GetCanonicalQualType(type));
3364 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3365 switch (type_class) {
3366 case clang::Type::Builtin:
3367 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
3368 default:
3369 break;
3370 case clang::BuiltinType::ObjCId:
3371 case clang::BuiltinType::ObjCClass:
3372 return true;
3373 }
3374 return false;
3375 case clang::Type::ObjCObjectPointer:
3376 if (pointee_type)
3377 pointee_type->SetCompilerType(
3378 getASTContext(), llvm::cast<clang::ObjCObjectPointerType>(qual_type)
3379 ->getPointeeType());
3380 return true;
3381 case clang::Type::BlockPointer:
3382 if (pointee_type)
3383 pointee_type->SetCompilerType(
3384 getASTContext(),
3385 llvm::cast<clang::BlockPointerType>(qual_type)->getPointeeType());
3386 return true;
3387 case clang::Type::Pointer:
3388 if (pointee_type)
3389 pointee_type->SetCompilerType(
3390 getASTContext(),
3391 llvm::cast<clang::PointerType>(qual_type)->getPointeeType());
3392 return true;
3393 case clang::Type::MemberPointer:
3394 if (pointee_type)
3395 pointee_type->SetCompilerType(
3396 getASTContext(),
3397 llvm::cast<clang::MemberPointerType>(qual_type)->getPointeeType());
3398 return true;
3399 case clang::Type::LValueReference:
3400 if (pointee_type)
3401 pointee_type->SetCompilerType(
3402 getASTContext(),
3403 llvm::cast<clang::LValueReferenceType>(qual_type)->desugar());
3404 return true;
3405 case clang::Type::RValueReference:
3406 if (pointee_type)
3407 pointee_type->SetCompilerType(
3408 getASTContext(),
3409 llvm::cast<clang::RValueReferenceType>(qual_type)->desugar());
3410 return true;
3411 case clang::Type::Typedef:
3412 return IsPointerOrReferenceType(llvm::cast<clang::TypedefType>(qual_type)
3413 ->getDecl()
3414 ->getUnderlyingType()
3415 .getAsOpaquePtr(),
3416 pointee_type);
3417 case clang::Type::Auto:
3418 return IsPointerOrReferenceType(llvm::cast<clang::AutoType>(qual_type)
3419 ->getDeducedType()
3420 .getAsOpaquePtr(),
3421 pointee_type);
3422 case clang::Type::Elaborated:
3423 return IsPointerOrReferenceType(
3424 llvm::cast<clang::ElaboratedType>(qual_type)
3425 ->getNamedType()
3426 .getAsOpaquePtr(),
3427 pointee_type);
3428 case clang::Type::Paren:
3429 return IsPointerOrReferenceType(
3430 llvm::cast<clang::ParenType>(qual_type)->desugar().getAsOpaquePtr(),
3431 pointee_type);
3432 default:
3433 break;
3434 }
3435 }
3436 if (pointee_type)
3437 pointee_type->Clear();
3438 return false;
3439}
3440
3441bool ClangASTContext::IsReferenceType(lldb::opaque_compiler_type_t type,
3442 CompilerType *pointee_type,
3443 bool *is_rvalue) {
3444 if (type) {
3445 clang::QualType qual_type(GetCanonicalQualType(type));
3446 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3447
3448 switch (type_class) {
3449 case clang::Type::LValueReference:
3450 if (pointee_type)
3451 pointee_type->SetCompilerType(
3452 getASTContext(),
3453 llvm::cast<clang::LValueReferenceType>(qual_type)->desugar());
3454 if (is_rvalue)
3455 *is_rvalue = false;
3456 return true;
3457 case clang::Type::RValueReference:
3458 if (pointee_type)
3459 pointee_type->SetCompilerType(
3460 getASTContext(),
3461 llvm::cast<clang::RValueReferenceType>(qual_type)->desugar());
3462 if (is_rvalue)
3463 *is_rvalue = true;
3464 return true;
3465 case clang::Type::Typedef:
3466 return IsReferenceType(llvm::cast<clang::TypedefType>(qual_type)
3467 ->getDecl()
3468 ->getUnderlyingType()
3469 .getAsOpaquePtr(),
3470 pointee_type, is_rvalue);
3471 case clang::Type::Auto:
3472 return IsReferenceType(llvm::cast<clang::AutoType>(qual_type)
3473 ->getDeducedType()
3474 .getAsOpaquePtr(),
3475 pointee_type, is_rvalue);
3476 case clang::Type::Elaborated:
3477 return IsReferenceType(llvm::cast<clang::ElaboratedType>(qual_type)
3478 ->getNamedType()
3479 .getAsOpaquePtr(),
3480 pointee_type, is_rvalue);
3481 case clang::Type::Paren:
3482 return IsReferenceType(
3483 llvm::cast<clang::ParenType>(qual_type)->desugar().getAsOpaquePtr(),
3484 pointee_type, is_rvalue);
3485
3486 default:
3487 break;
3488 }
3489 }
3490 if (pointee_type)
3491 pointee_type->Clear();
3492 return false;
3493}
3494
3495bool ClangASTContext::IsFloatingPointType(lldb::opaque_compiler_type_t type,
3496 uint32_t &count, bool &is_complex) {
3497 if (type) {
3498 clang::QualType qual_type(GetCanonicalQualType(type));
3499
3500 if (const clang::BuiltinType *BT = llvm::dyn_cast<clang::BuiltinType>(
3501 qual_type->getCanonicalTypeInternal())) {
3502 clang::BuiltinType::Kind kind = BT->getKind();
3503 if (kind >= clang::BuiltinType::Float &&
3504 kind <= clang::BuiltinType::LongDouble) {
3505 count = 1;
3506 is_complex = false;
3507 return true;
3508 }
3509 } else if (const clang::ComplexType *CT =
3510 llvm::dyn_cast<clang::ComplexType>(
3511 qual_type->getCanonicalTypeInternal())) {
3512 if (IsFloatingPointType(CT->getElementType().getAsOpaquePtr(), count,
3513 is_complex)) {
3514 count = 2;
3515 is_complex = true;
3516 return true;
3517 }
3518 } else if (const clang::VectorType *VT = llvm::dyn_cast<clang::VectorType>(
3519 qual_type->getCanonicalTypeInternal())) {
3520 if (IsFloatingPointType(VT->getElementType().getAsOpaquePtr(), count,
3521 is_complex)) {
3522 count = VT->getNumElements();
3523 is_complex = false;
3524 return true;
3525 }
3526 }
3527 }
3528 count = 0;
3529 is_complex = false;
3530 return false;
3531}
3532
3533bool ClangASTContext::IsDefined(lldb::opaque_compiler_type_t type) {
3534 if (!type)
3535 return false;
3536
3537 clang::QualType qual_type(GetQualType(type));
3538 const clang::TagType *tag_type =
3539 llvm::dyn_cast<clang::TagType>(qual_type.getTypePtr());
3540 if (tag_type) {
3541 clang::TagDecl *tag_decl = tag_type->getDecl();
3542 if (tag_decl)
3543 return tag_decl->isCompleteDefinition();
3544 return false;
3545 } else {
3546 const clang::ObjCObjectType *objc_class_type =
3547 llvm::dyn_cast<clang::ObjCObjectType>(qual_type);
3548 if (objc_class_type) {
3549 clang::ObjCInterfaceDecl *class_interface_decl =
3550 objc_class_type->getInterface();
3551 if (class_interface_decl)
3552 return class_interface_decl->getDefinition() != nullptr;
3553 return false;
3554 }
3555 }
3556 return true;
3557}
3558
3559bool ClangASTContext::IsObjCClassType(const CompilerType &type) {
3560 if (type) {
3561 clang::QualType qual_type(ClangUtil::GetCanonicalQualType(type));
3562
3563 const clang::ObjCObjectPointerType *obj_pointer_type =
3564 llvm::dyn_cast<clang::ObjCObjectPointerType>(qual_type);
3565
3566 if (obj_pointer_type)
3567 return obj_pointer_type->isObjCClassType();
3568 }
3569 return false;
3570}
3571
3572bool ClangASTContext::IsObjCObjectOrInterfaceType(const CompilerType &type) {
3573 if (ClangUtil::IsClangType(type))
3574 return ClangUtil::GetCanonicalQualType(type)->isObjCObjectOrInterfaceType();
3575 return false;
3576}
3577
3578bool ClangASTContext::IsClassType(lldb::opaque_compiler_type_t type) {
3579 if (!type)
3580 return false;
3581 clang::QualType qual_type(GetCanonicalQualType(type));
3582 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3583 return (type_class == clang::Type::Record);
3584}
3585
3586bool ClangASTContext::IsEnumType(lldb::opaque_compiler_type_t type) {
3587 if (!type)
3588 return false;
3589 clang::QualType qual_type(GetCanonicalQualType(type));
3590 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3591 return (type_class == clang::Type::Enum);
3592}
3593
3594bool ClangASTContext::IsPolymorphicClass(lldb::opaque_compiler_type_t type) {
3595 if (type) {
3596 clang::QualType qual_type(GetCanonicalQualType(type));
3597 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3598 switch (type_class) {
3599 case clang::Type::Record:
3600 if (GetCompleteType(type)) {
3601 const clang::RecordType *record_type =
3602 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
3603 const clang::RecordDecl *record_decl = record_type->getDecl();
3604 if (record_decl) {
3605 const clang::CXXRecordDecl *cxx_record_decl =
3606 llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
3607 if (cxx_record_decl)
3608 return cxx_record_decl->isPolymorphic();
3609 }
3610 }
3611 break;
3612
3613 default:
3614 break;
3615 }
3616 }
3617 return false;
3618}
3619
3620bool ClangASTContext::IsPossibleDynamicType(lldb::opaque_compiler_type_t type,
3621 CompilerType *dynamic_pointee_type,
3622 bool check_cplusplus,
3623 bool check_objc) {
3624 clang::QualType pointee_qual_type;
3625 if (type) {
3626 clang::QualType qual_type(GetCanonicalQualType(type));
3627 bool success = false;
3628 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3629 switch (type_class) {
3630 case clang::Type::Builtin:
3631 if (check_objc &&
3632 llvm::cast<clang::BuiltinType>(qual_type)->getKind() ==
3633 clang::BuiltinType::ObjCId) {
3634 if (dynamic_pointee_type)
3635 dynamic_pointee_type->SetCompilerType(this, type);
3636 return true;
3637 }
3638 break;
3639
3640 case clang::Type::ObjCObjectPointer:
3641 if (check_objc) {
3642 if (auto objc_pointee_type =
3643 qual_type->getPointeeType().getTypePtrOrNull()) {
3644 if (auto objc_object_type =
3645 llvm::dyn_cast_or_null<clang::ObjCObjectType>(
3646 objc_pointee_type)) {
3647 if (objc_object_type->isObjCClass())
3648 return false;
3649 }
3650 }
3651 if (dynamic_pointee_type)
3652 dynamic_pointee_type->SetCompilerType(
3653 getASTContext(),
3654 llvm::cast<clang::ObjCObjectPointerType>(qual_type)
3655 ->getPointeeType());
3656 return true;
3657 }
3658 break;
3659
3660 case clang::Type::Pointer:
3661 pointee_qual_type =
3662 llvm::cast<clang::PointerType>(qual_type)->getPointeeType();
3663 success = true;
3664 break;
3665
3666 case clang::Type::LValueReference:
3667 case clang::Type::RValueReference:
3668 pointee_qual_type =
3669 llvm::cast<clang::ReferenceType>(qual_type)->getPointeeType();
3670 success = true;
3671 break;
3672
3673 case clang::Type::Typedef:
3674 return IsPossibleDynamicType(llvm::cast<clang::TypedefType>(qual_type)
3675 ->getDecl()
3676 ->getUnderlyingType()
3677 .getAsOpaquePtr(),
3678 dynamic_pointee_type, check_cplusplus,
3679 check_objc);
3680
3681 case clang::Type::Auto:
3682 return IsPossibleDynamicType(llvm::cast<clang::AutoType>(qual_type)
3683 ->getDeducedType()
3684 .getAsOpaquePtr(),
3685 dynamic_pointee_type, check_cplusplus,
3686 check_objc);
3687
3688 case clang::Type::Elaborated:
3689 return IsPossibleDynamicType(llvm::cast<clang::ElaboratedType>(qual_type)
3690 ->getNamedType()
3691 .getAsOpaquePtr(),
3692 dynamic_pointee_type, check_cplusplus,
3693 check_objc);
3694
3695 case clang::Type::Paren:
3696 return IsPossibleDynamicType(
3697 llvm::cast<clang::ParenType>(qual_type)->desugar().getAsOpaquePtr(),
3698 dynamic_pointee_type, check_cplusplus, check_objc);
3699 default:
3700 break;
3701 }
3702
3703 if (success) {
3704 // Check to make sure what we are pointing too is a possible dynamic C++
3705 // type We currently accept any "void *" (in case we have a class that
3706 // has been watered down to an opaque pointer) and virtual C++ classes.
3707 const clang::Type::TypeClass pointee_type_class =
3708 pointee_qual_type.getCanonicalType()->getTypeClass();
3709 switch (pointee_type_class) {
3710 case clang::Type::Builtin:
3711 switch (llvm::cast<clang::BuiltinType>(pointee_qual_type)->getKind()) {
3712 case clang::BuiltinType::UnknownAny:
3713 case clang::BuiltinType::Void:
3714 if (dynamic_pointee_type)
3715 dynamic_pointee_type->SetCompilerType(getASTContext(),
3716 pointee_qual_type);
3717 return true;
3718 default:
3719 break;
3720 }
3721 break;
3722
3723 case clang::Type::Record:
3724 if (check_cplusplus) {
3725 clang::CXXRecordDecl *cxx_record_decl =
3726 pointee_qual_type->getAsCXXRecordDecl();
3727 if (cxx_record_decl) {
3728 bool is_complete = cxx_record_decl->isCompleteDefinition();
3729
3730 if (is_complete)
3731 success = cxx_record_decl->isDynamicClass();
3732 else {
3733 ClangASTMetadata *metadata = ClangASTContext::GetMetadata(
3734 getASTContext(), cxx_record_decl);
3735 if (metadata)
3736 success = metadata->GetIsDynamicCXXType();
3737 else {
3738 is_complete = CompilerType(getASTContext(), pointee_qual_type)
3739 .GetCompleteType();
3740 if (is_complete)
3741 success = cxx_record_decl->isDynamicClass();
3742 else
3743 success = false;
3744 }
3745 }
3746
3747 if (success) {
3748 if (dynamic_pointee_type)
3749 dynamic_pointee_type->SetCompilerType(getASTContext(),
3750 pointee_qual_type);
3751 return true;
3752 }
3753 }
3754 }
3755 break;
3756
3757 case clang::Type::ObjCObject:
3758 case clang::Type::ObjCInterface:
3759 if (check_objc) {
3760 if (dynamic_pointee_type)
3761 dynamic_pointee_type->SetCompilerType(getASTContext(),
3762 pointee_qual_type);
3763 return true;
3764 }
3765 break;
3766
3767 default:
3768 break;
3769 }
3770 }
3771 }
3772 if (dynamic_pointee_type)
3773 dynamic_pointee_type->Clear();
3774 return false;
3775}
3776
3777bool ClangASTContext::IsScalarType(lldb::opaque_compiler_type_t type) {
3778 if (!type)
3779 return false;
3780
3781 return (GetTypeInfo(type, nullptr) & eTypeIsScalar) != 0;
3782}
3783
3784bool ClangASTContext::IsTypedefType(lldb::opaque_compiler_type_t type) {
3785 if (!type)
3786 return false;
3787 return GetQualType(type)->getTypeClass() == clang::Type::Typedef;
3788}
3789
3790bool ClangASTContext::IsVoidType(lldb::opaque_compiler_type_t type) {
3791 if (!type)
3792 return false;
3793 return GetCanonicalQualType(type)->isVoidType();
3794}
3795
3796bool ClangASTContext::SupportsLanguage(lldb::LanguageType language) {
3797 return ClangASTContextSupportsLanguage(language);
3798}
3799
3800bool ClangASTContext::GetCXXClassName(const CompilerType &type,
3801 std::string &class_name) {
3802 if (type) {
3803 clang::QualType qual_type(ClangUtil::GetCanonicalQualType(type));
3804 if (!qual_type.isNull()) {
3805 clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl();
3806 if (cxx_record_decl) {
3807 class_name.assign(cxx_record_decl->getIdentifier()->getNameStart());
3808 return true;
3809 }
3810 }
3811 }
3812 class_name.clear();
3813 return false;
3814}
3815
3816bool ClangASTContext::IsCXXClassType(const CompilerType &type) {
3817 if (!type)
3818 return false;
3819
3820 clang::QualType qual_type(ClangUtil::GetCanonicalQualType(type));
3821 if (!qual_type.isNull() && qual_type->getAsCXXRecordDecl() != nullptr)
3822 return true;
3823 return false;
3824}
3825
3826bool ClangASTContext::IsBeingDefined(lldb::opaque_compiler_type_t type) {
3827 if (!type)
3828 return false;
3829 clang::QualType qual_type(GetCanonicalQualType(type));
3830 const clang::TagType *tag_type = llvm::dyn_cast<clang::TagType>(qual_type);
3831 if (tag_type)
3832 return tag_type->isBeingDefined();
3833 return false;
3834}
3835
3836bool ClangASTContext::IsObjCObjectPointerType(const CompilerType &type,
3837 CompilerType *class_type_ptr) {
3838 if (!type)
3839 return false;
3840
3841 clang::QualType qual_type(ClangUtil::GetCanonicalQualType(type));
3842
3843 if (!qual_type.isNull() && qual_type->isObjCObjectPointerType()) {
3844 if (class_type_ptr) {
3845 if (!qual_type->isObjCClassType() && !qual_type->isObjCIdType()) {
3846 const clang::ObjCObjectPointerType *obj_pointer_type =
3847 llvm::dyn_cast<clang::ObjCObjectPointerType>(qual_type);
3848 if (obj_pointer_type == nullptr)
3849 class_type_ptr->Clear();
3850 else
3851 class_type_ptr->SetCompilerType(
3852 type.GetTypeSystem(),
3853 clang::QualType(obj_pointer_type->getInterfaceType(), 0)
3854 .getAsOpaquePtr());
3855 }
3856 }
3857 return true;
3858 }
3859 if (class_type_ptr)
3860 class_type_ptr->Clear();
3861 return false;
3862}
3863
3864bool ClangASTContext::GetObjCClassName(const CompilerType &type,
3865 std::string &class_name) {
3866 if (!type)
3867 return false;
3868
3869 clang::QualType qual_type(ClangUtil::GetCanonicalQualType(type));
3870
3871 const clang::ObjCObjectType *object_type =
3872 llvm::dyn_cast<clang::ObjCObjectType>(qual_type);
3873 if (object_type) {
3874 const clang::ObjCInterfaceDecl *interface = object_type->getInterface();
3875 if (interface) {
3876 class_name = interface->getNameAsString();
3877 return true;
3878 }
3879 }
3880 return false;
3881}
3882
3883//----------------------------------------------------------------------
3884// Type Completion
3885//----------------------------------------------------------------------
3886
3887bool ClangASTContext::GetCompleteType(lldb::opaque_compiler_type_t type) {
3888 if (!type)
3889 return false;
3890 const bool allow_completion = true;
3891 return GetCompleteQualType(getASTContext(), GetQualType(type),
3892 allow_completion);
3893}
3894
3895ConstString ClangASTContext::GetTypeName(lldb::opaque_compiler_type_t type) {
3896 std::string type_name;
3897 if (type) {
3898 clang::PrintingPolicy printing_policy(getASTContext()->getPrintingPolicy());
3899 clang::QualType qual_type(GetQualType(type));
3900 printing_policy.SuppressTagKeyword = true;
3901 const clang::TypedefType *typedef_type =
3902 qual_type->getAs<clang::TypedefType>();
3903 if (typedef_type) {
3904 const clang::TypedefNameDecl *typedef_decl = typedef_type->getDecl();
3905 type_name = typedef_decl->getQualifiedNameAsString();
3906 } else {
3907 type_name = qual_type.getAsString(printing_policy);
3908 }
3909 }
3910 return ConstString(type_name);
3911}
3912
3913uint32_t
3914ClangASTContext::GetTypeInfo(lldb::opaque_compiler_type_t type,
3915 CompilerType *pointee_or_element_clang_type) {
3916 if (!type)
3917 return 0;
3918
3919 if (pointee_or_element_clang_type)
3920 pointee_or_element_clang_type->Clear();
3921
3922 clang::QualType qual_type(GetQualType(type));
3923
3924 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3925 switch (type_class) {
3926 case clang::Type::Attributed:
3927 return GetTypeInfo(
3928 qual_type->getAs<clang::AttributedType>()
3929 ->getModifiedType().getAsOpaquePtr(),
3930 pointee_or_element_clang_type);
3931 case clang::Type::Builtin: {
3932 const clang::BuiltinType *builtin_type = llvm::dyn_cast<clang::BuiltinType>(
3933 qual_type->getCanonicalTypeInternal());
3934
3935 uint32_t builtin_type_flags = eTypeIsBuiltIn | eTypeHasValue;
3936 switch (builtin_type->getKind()) {
3937 case clang::BuiltinType::ObjCId:
3938 case clang::BuiltinType::ObjCClass:
3939 if (pointee_or_element_clang_type)
3940 pointee_or_element_clang_type->SetCompilerType(
3941 getASTContext(), getASTContext()->ObjCBuiltinClassTy);
3942 builtin_type_flags |= eTypeIsPointer | eTypeIsObjC;
3943 break;
3944
3945 case clang::BuiltinType::ObjCSel:
3946 if (pointee_or_element_clang_type)
3947 pointee_or_element_clang_type->SetCompilerType(getASTContext(),
3948 getASTContext()->CharTy);
3949 builtin_type_flags |= eTypeIsPointer | eTypeIsObjC;
3950 break;
3951
3952 case clang::BuiltinType::Bool:
3953 case clang::BuiltinType::Char_U:
3954 case clang::BuiltinType::UChar:
3955 case clang::BuiltinType::WChar_U:
3956 case clang::BuiltinType::Char16:
3957 case clang::BuiltinType::Char32:
3958 case clang::BuiltinType::UShort:
3959 case clang::BuiltinType::UInt:
3960 case clang::BuiltinType::ULong:
3961 case clang::BuiltinType::ULongLong:
3962 case clang::BuiltinType::UInt128:
3963 case clang::BuiltinType::Char_S:
3964 case clang::BuiltinType::SChar:
3965 case clang::BuiltinType::WChar_S:
3966 case clang::BuiltinType::Short:
3967 case clang::BuiltinType::Int:
3968 case clang::BuiltinType::Long:
3969 case clang::BuiltinType::LongLong:
3970 case clang::BuiltinType::Int128:
3971 case clang::BuiltinType::Float:
3972 case clang::BuiltinType::Double:
3973 case clang::BuiltinType::LongDouble:
3974 builtin_type_flags |= eTypeIsScalar;
3975 if (builtin_type->isInteger()) {
3976 builtin_type_flags |= eTypeIsInteger;
3977 if (builtin_type->isSignedInteger())
3978 builtin_type_flags |= eTypeIsSigned;
3979 } else if (builtin_type->isFloatingPoint())
3980 builtin_type_flags |= eTypeIsFloat;
3981 break;
3982 default:
3983 break;
3984 }
3985 return builtin_type_flags;
3986 }
3987
3988 case clang::Type::BlockPointer:
3989 if (pointee_or_element_clang_type)
3990 pointee_or_element_clang_type->SetCompilerType(
3991 getASTContext(), qual_type->getPointeeType());
3992 return eTypeIsPointer | eTypeHasChildren | eTypeIsBlock;
3993
3994 case clang::Type::Complex: {
3995 uint32_t complex_type_flags =
3996 eTypeIsBuiltIn | eTypeHasValue | eTypeIsComplex;
3997 const clang::ComplexType *complex_type = llvm::dyn_cast<clang::ComplexType>(
3998 qual_type->getCanonicalTypeInternal());
3999 if (complex_type) {
4000 clang::QualType complex_element_type(complex_type->getElementType());
4001 if (complex_element_type->isIntegerType())
4002 complex_type_flags |= eTypeIsFloat;
4003 else if (complex_element_type->isFloatingType())
4004 complex_type_flags |= eTypeIsInteger;
4005 }
4006 return complex_type_flags;
4007 } break;
4008
4009 case clang::Type::ConstantArray:
4010 case clang::Type::DependentSizedArray:
4011 case clang::Type::IncompleteArray:
4012 case clang::Type::VariableArray:
4013 if (pointee_or_element_clang_type)
4014 pointee_or_element_clang_type->SetCompilerType(
4015 getASTContext(), llvm::cast<clang::ArrayType>(qual_type.getTypePtr())
4016 ->getElementType());
4017 return eTypeHasChildren | eTypeIsArray;
4018
4019 case clang::Type::DependentName:
4020 return 0;
4021 case clang::Type::DependentSizedExtVector:
4022 return eTypeHasChildren | eTypeIsVector;
4023 case clang::Type::DependentTemplateSpecialization:
4024 return eTypeIsTemplate;
4025 case clang::Type::Decltype:
4026 return CompilerType(
4027 getASTContext(),
4028 llvm::cast<clang::DecltypeType>(qual_type)->getUnderlyingType())
4029 .GetTypeInfo(pointee_or_element_clang_type);
4030
4031 case clang::Type::Enum:
4032 if (pointee_or_element_clang_type)
4033 pointee_or_element_clang_type->SetCompilerType(
4034 getASTContext(),
4035 llvm::cast<clang::EnumType>(qual_type)->getDecl()->getIntegerType());
4036 return eTypeIsEnumeration | eTypeHasValue;
4037
4038 case clang::Type::Auto:
4039 return CompilerType(
4040 getASTContext(),
4041 llvm::cast<clang::AutoType>(qual_type)->getDeducedType())
4042 .GetTypeInfo(pointee_or_element_clang_type);
4043 case clang::Type::Elaborated:
4044 return CompilerType(
4045 getASTContext(),
4046 llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType())
4047 .GetTypeInfo(pointee_or_element_clang_type);
4048 case clang::Type::Paren:
4049 return CompilerType(getASTContext(),
4050 llvm::cast<clang::ParenType>(qual_type)->desugar())
4051 .GetTypeInfo(pointee_or_element_clang_type);
4052
4053 case clang::Type::FunctionProto:
4054 return eTypeIsFuncPrototype | eTypeHasValue;
4055 case clang::Type::FunctionNoProto:
4056 return eTypeIsFuncPrototype | eTypeHasValue;
4057 case clang::Type::InjectedClassName:
4058 return 0;
4059
4060 case clang::Type::LValueReference:
4061 case clang::Type::RValueReference:
4062 if (pointee_or_element_clang_type)
4063 pointee_or_element_clang_type->SetCompilerType(
4064 getASTContext(),
4065 llvm::cast<clang::ReferenceType>(qual_type.getTypePtr())
4066 ->getPointeeType());
4067 return eTypeHasChildren | eTypeIsReference | eTypeHasValue;
4068
4069 case clang::Type::MemberPointer:
4070 return eTypeIsPointer | eTypeIsMember | eTypeHasValue;
4071
4072 case clang::Type::ObjCObjectPointer:
4073 if (pointee_or_element_clang_type)
4074 pointee_or_element_clang_type->SetCompilerType(
4075 getASTContext(), qual_type->getPointeeType());
4076 return eTypeHasChildren | eTypeIsObjC | eTypeIsClass | eTypeIsPointer |
4077 eTypeHasValue;
4078
4079 case clang::Type::ObjCObject:
4080 return eTypeHasChildren | eTypeIsObjC | eTypeIsClass;
4081 case clang::Type::ObjCInterface:
4082 return eTypeHasChildren | eTypeIsObjC | eTypeIsClass;
4083
4084 case clang::Type::Pointer:
4085 if (pointee_or_element_clang_type)
4086 pointee_or_element_clang_type->SetCompilerType(
4087 getASTContext(), qual_type->getPointeeType());
4088 return eTypeHasChildren | eTypeIsPointer | eTypeHasValue;
4089
4090 case clang::Type::Record:
4091 if (qual_type->getAsCXXRecordDecl())
4092 return eTypeHasChildren | eTypeIsClass | eTypeIsCPlusPlus;
4093 else
4094 return eTypeHasChildren | eTypeIsStructUnion;
4095 break;
4096 case clang::Type::SubstTemplateTypeParm:
4097 return eTypeIsTemplate;
4098 case clang::Type::TemplateTypeParm:
4099 return eTypeIsTemplate;
4100 case clang::Type::TemplateSpecialization:
4101 return eTypeIsTemplate;
4102
4103 case clang::Type::Typedef:
4104 return eTypeIsTypedef |
4105 CompilerType(getASTContext(),
4106 llvm::cast<clang::TypedefType>(qual_type)
4107 ->getDecl()
4108 ->getUnderlyingType())
4109 .GetTypeInfo(pointee_or_element_clang_type);
4110 case clang::Type::TypeOfExpr:
4111 return CompilerType(getASTContext(),
4112 llvm::cast<clang::TypeOfExprType>(qual_type)
4113 ->getUnderlyingExpr()
4114 ->getType())
4115 .GetTypeInfo(pointee_or_element_clang_type);
4116 case clang::Type::TypeOf:
4117 return CompilerType(
4118 getASTContext(),
4119 llvm::cast<clang::TypeOfType>(qual_type)->getUnderlyingType())
4120 .GetTypeInfo(pointee_or_element_clang_type);
4121 case clang::Type::UnresolvedUsing:
4122 return 0;
4123
4124 case clang::Type::ExtVector:
4125 case clang::Type::Vector: {
4126 uint32_t vector_type_flags = eTypeHasChildren | eTypeIsVector;
4127 const clang::VectorType *vector_type = llvm::dyn_cast<clang::VectorType>(
4128 qual_type->getCanonicalTypeInternal());
4129 if (vector_type) {
4130 if (vector_type->isIntegerType())
4131 vector_type_flags |= eTypeIsFloat;
4132 else if (vector_type->isFloatingType())
4133 vector_type_flags |= eTypeIsInteger;
4134 }
4135 return vector_type_flags;
4136 }
4137 default:
4138 return 0;
4139 }
4140 return 0;
4141}
4142
4143lldb::LanguageType
4144ClangASTContext::GetMinimumLanguage(lldb::opaque_compiler_type_t type) {
4145 if (!type)
4146 return lldb::eLanguageTypeC;
4147
4148 // If the type is a reference, then resolve it to what it refers to first:
4149 clang::QualType qual_type(GetCanonicalQualType(type).getNonReferenceType());
4150 if (qual_type->isAnyPointerType()) {
4151 if (qual_type->isObjCObjectPointerType())
4152 return lldb::eLanguageTypeObjC;
4153
4154 clang::QualType pointee_type(qual_type->getPointeeType());
4155 if (pointee_type->getPointeeCXXRecordDecl() != nullptr)
4156 return lldb::eLanguageTypeC_plus_plus;
4157 if (pointee_type->isObjCObjectOrInterfaceType())
4158 return lldb::eLanguageTypeObjC;
4159 if (pointee_type->isObjCClassType())
4160 return lldb::eLanguageTypeObjC;
4161 if (pointee_type.getTypePtr() ==
4162 getASTContext()->ObjCBuiltinIdTy.getTypePtr())
4163 return lldb::eLanguageTypeObjC;
4164 } else {
4165 if (qual_type->isObjCObjectOrInterfaceType())
4166 return lldb::eLanguageTypeObjC;
4167 if (qual_type->getAsCXXRecordDecl())
4168 return lldb::eLanguageTypeC_plus_plus;
4169 switch (qual_type->getTypeClass()) {
4170 default:
4171 break;
4172 case clang::Type::Builtin:
4173 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
4174 default:
4175 case clang::BuiltinType::Void:
4176 case clang::BuiltinType::Bool:
4177 case clang::BuiltinType::Char_U:
4178 case clang::BuiltinType::UChar:
4179 case clang::BuiltinType::WChar_U:
4180 case clang::BuiltinType::Char16:
4181 case clang::BuiltinType::Char32:
4182 case clang::BuiltinType::UShort:
4183 case clang::BuiltinType::UInt:
4184 case clang::BuiltinType::ULong:
4185 case clang::BuiltinType::ULongLong:
4186 case clang::BuiltinType::UInt128:
4187 case clang::BuiltinType::Char_S:
4188 case clang::BuiltinType::SChar:
4189 case clang::BuiltinType::WChar_S:
4190 case clang::BuiltinType::Short:
4191 case clang::BuiltinType::Int:
4192 case clang::BuiltinType::Long:
4193 case clang::BuiltinType::LongLong:
4194 case clang::BuiltinType::Int128:
4195 case clang::BuiltinType::Float:
4196 case clang::BuiltinType::Double:
4197 case clang::BuiltinType::LongDouble:
4198 break;
4199
4200 case clang::BuiltinType::NullPtr:
4201 return eLanguageTypeC_plus_plus;
4202
4203 case clang::BuiltinType::ObjCId:
4204 case clang::BuiltinType::ObjCClass:
4205 case clang::BuiltinType::ObjCSel:
4206 return eLanguageTypeObjC;
4207
4208 case clang::BuiltinType::Dependent:
4209 case clang::BuiltinType::Overload:
4210 case clang::BuiltinType::BoundMember:
4211 case clang::BuiltinType::UnknownAny:
4212 break;
4213 }
4214 break;
4215 case clang::Type::Typedef:
4216 return CompilerType(getASTContext(),
4217 llvm::cast<clang::TypedefType>(qual_type)
4218 ->getDecl()
4219 ->getUnderlyingType())
4220 .GetMinimumLanguage();
4221 }
4222 }
4223 return lldb::eLanguageTypeC;
4224}
4225
4226lldb::TypeClass
4227ClangASTContext::GetTypeClass(lldb::opaque_compiler_type_t type) {
4228 if (!type)
4229 return lldb::eTypeClassInvalid;
4230
4231 clang::QualType qual_type(GetQualType(type));
4232
4233 switch (qual_type->getTypeClass()) {
4234 case clang::Type::UnaryTransform:
4235 break;
4236 case clang::Type::FunctionNoProto:
4237 return lldb::eTypeClassFunction;
4238 case clang::Type::FunctionProto:
4239 return lldb::eTypeClassFunction;
4240 case clang::Type::IncompleteArray:
4241 return lldb::eTypeClassArray;
4242 case clang::Type::VariableArray:
4243 return lldb::eTypeClassArray;
4244 case clang::Type::ConstantArray:
4245 return lldb::eTypeClassArray;
4246 case clang::Type::DependentSizedArray:
4247 return lldb::eTypeClassArray;
4248 case clang::Type::DependentSizedExtVector:
4249 return lldb::eTypeClassVector;
4250 case clang::Type::DependentVector:
4251 return lldb::eTypeClassVector;
4252 case clang::Type::ExtVector:
4253 return lldb::eTypeClassVector;
4254 case clang::Type::Vector:
4255 return lldb::eTypeClassVector;
4256 case clang::Type::Builtin:
4257 return lldb::eTypeClassBuiltin;
4258 case clang::Type::ObjCObjectPointer:
4259 return lldb::eTypeClassObjCObjectPointer;
4260 case clang::Type::BlockPointer:
4261 return lldb::eTypeClassBlockPointer;
4262 case clang::Type::Pointer:
4263 return lldb::eTypeClassPointer;
4264 case clang::Type::LValueReference:
4265 return lldb::eTypeClassReference;
4266 case clang::Type::RValueReference:
4267 return lldb::eTypeClassReference;
4268 case clang::Type::MemberPointer:
4269 return lldb::eTypeClassMemberPointer;
4270 case clang::Type::Complex:
4271 if (qual_type->isComplexType())
4272 return lldb::eTypeClassComplexFloat;
4273 else
4274 return lldb::eTypeClassComplexInteger;
4275 case clang::Type::ObjCObject:
4276 return lldb::eTypeClassObjCObject;
4277 case clang::Type::ObjCInterface:
4278 return lldb::eTypeClassObjCInterface;
4279 case clang::Type::Record: {
4280 const clang::RecordType *record_type =
4281 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
4282 const clang::RecordDecl *record_decl = record_type->getDecl();
4283 if (record_decl->isUnion())
4284 return lldb::eTypeClassUnion;
4285 else if (record_decl->isStruct())
4286 return lldb::eTypeClassStruct;
4287 else
4288 return lldb::eTypeClassClass;
4289 } break;
4290 case clang::Type::Enum:
4291 return lldb::eTypeClassEnumeration;
4292 case clang::Type::Typedef:
4293 return lldb::eTypeClassTypedef;
4294 case clang::Type::UnresolvedUsing:
4295 break;
4296 case clang::Type::Paren:
4297 return CompilerType(getASTContext(),
4298 llvm::cast<clang::ParenType>(qual_type)->desugar())
4299 .GetTypeClass();
4300 case clang::Type::Auto:
4301 return CompilerType(
4302 getASTContext(),
4303 llvm::cast<clang::AutoType>(qual_type)->getDeducedType())
4304 .GetTypeClass();
4305 case clang::Type::Elaborated:
4306 return CompilerType(
4307 getASTContext(),
4308 llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType())
4309 .GetTypeClass();
4310
4311 case clang::Type::Attributed:
4312 break;
4313 case clang::Type::TemplateTypeParm:
4314 break;
4315 case clang::Type::SubstTemplateTypeParm:
4316 break;
4317 case clang::Type::SubstTemplateTypeParmPack:
4318 break;
4319 case clang::Type::InjectedClassName:
4320 break;
4321 case clang::Type::DependentName:
4322 break;
4323 case clang::Type::DependentTemplateSpecialization:
4324 break;
4325 case clang::Type::PackExpansion:
4326 break;
4327
4328 case clang::Type::TypeOfExpr:
4329 return CompilerType(getASTContext(),
4330 llvm::cast<clang::TypeOfExprType>(qual_type)
4331 ->getUnderlyingExpr()
4332 ->getType())
4333 .GetTypeClass();
4334 case clang::Type::TypeOf:
4335 return CompilerType(
4336 getASTContext(),
4337 llvm::cast<clang::TypeOfType>(qual_type)->getUnderlyingType())
4338 .GetTypeClass();
4339 case clang::Type::Decltype:
4340 return CompilerType(
4341 getASTContext(),
4342 llvm::cast<clang::TypeOfType>(qual_type)->getUnderlyingType())
4343 .GetTypeClass();
4344 case clang::Type::TemplateSpecialization:
4345 break;
4346 case clang::Type::DeducedTemplateSpecialization:
4347 break;
4348 case clang::Type::Atomic:
4349 break;
4350 case clang::Type::Pipe:
4351 break;
4352
4353 // pointer type decayed from an array or function type.
4354 case clang::Type::Decayed:
4355 break;
4356 case clang::Type::Adjusted:
4357 break;
4358 case clang::Type::ObjCTypeParam:
4359 break;
4360
4361 case clang::Type::DependentAddressSpace:
4362 break;
4363 }
4364 // We don't know hot to display this type...
4365 return lldb::eTypeClassOther;
4366}
4367
4368unsigned ClangASTContext::GetTypeQualifiers(lldb::opaque_compiler_type_t type) {
4369 if (type)
4370 return GetQualType(type).getQualifiers().getCVRQualifiers();
4371 return 0;
4372}
4373
4374//----------------------------------------------------------------------
4375// Creating related types
4376//----------------------------------------------------------------------
4377
4378CompilerType
4379ClangASTContext::GetArrayElementType(lldb::opaque_compiler_type_t type,
4380 uint64_t *stride) {
4381 if (type) {
4382 clang::QualType qual_type(GetCanonicalQualType(type));
4383
4384 const clang::Type *array_eletype =
4385 qual_type.getTypePtr()->getArrayElementTypeNoTypeQual();
4386
4387 if (!array_eletype)
4388 return CompilerType();
4389
4390 CompilerType element_type(getASTContext(),
4391 array_eletype->getCanonicalTypeUnqualified());
4392
4393 // TODO: the real stride will be >= this value.. find the real one!
4394 if (stride)
4395 *stride = element_type.GetByteSize(nullptr);
4396
4397 return element_type;
4398 }
4399 return CompilerType();
4400}
4401
4402CompilerType ClangASTContext::GetArrayType(lldb::opaque_compiler_type_t type,
4403 uint64_t size) {
4404 if (type) {
4405 clang::QualType qual_type(GetCanonicalQualType(type));
4406 if (clang::ASTContext *ast_ctx = getASTContext()) {
4407 if (size != 0)
4408 return CompilerType(
4409 ast_ctx, ast_ctx->getConstantArrayType(
4410 qual_type, llvm::APInt(64, size),
4411 clang::ArrayType::ArraySizeModifier::Normal, 0));
4412 else
4413 return CompilerType(
4414 ast_ctx,
4415 ast_ctx->getIncompleteArrayType(
4416 qual_type, clang::ArrayType::ArraySizeModifier::Normal, 0));
4417 }
4418 }
4419
4420 return CompilerType();
4421}
4422
4423CompilerType
4424ClangASTContext::GetCanonicalType(lldb::opaque_compiler_type_t type) {
4425 if (type)
4426 return CompilerType(getASTContext(), GetCanonicalQualType(type));
4427 return CompilerType();
4428}
4429
4430static clang::QualType GetFullyUnqualifiedType_Impl(clang::ASTContext *ast,
4431 clang::QualType qual_type) {
4432 if (qual_type->isPointerType())
4433 qual_type = ast->getPointerType(
4434 GetFullyUnqualifiedType_Impl(ast, qual_type->getPointeeType()));
4435 else
4436 qual_type = qual_type.getUnqualifiedType();
4437 qual_type.removeLocalConst();
4438 qual_type.removeLocalRestrict();
4439 qual_type.removeLocalVolatile();
4440 return qual_type;
4441}
4442
4443CompilerType
4444ClangASTContext::GetFullyUnqualifiedType(lldb::opaque_compiler_type_t type) {
4445 if (type)
4446 return CompilerType(
4447 getASTContext(),
4448 GetFullyUnqualifiedType_Impl(getASTContext(), GetQualType(type)));
4449 return CompilerType();
4450}
4451
4452int ClangASTContext::GetFunctionArgumentCount(
4453 lldb::opaque_compiler_type_t type) {
4454 if (type) {
4455 const clang::FunctionProtoType *func =
4456 llvm::dyn_cast<clang::FunctionProtoType>(GetCanonicalQualType(type));
4457 if (func)
4458 return func->getNumParams();
4459 }
4460 return -1;
4461}
4462
4463CompilerType ClangASTContext::GetFunctionArgumentTypeAtIndex(
4464 lldb::opaque_compiler_type_t type, size_t idx) {
4465 if (type) {
4466 const clang::FunctionProtoType *func =
4467 llvm::dyn_cast<clang::FunctionProtoType>(GetQualType(type));
4468 if (func) {
4469 const uint32_t num_args = func->getNumParams();
4470 if (idx < num_args)
4471 return CompilerType(getASTContext(), func->getParamType(idx));
4472 }
4473 }
4474 return CompilerType();
4475}
4476
4477CompilerType
4478ClangASTContext::GetFunctionReturnType(lldb::opaque_compiler_type_t type) {
4479 if (type) {
4480 clang::QualType qual_type(GetQualType(type));
4481 const clang::FunctionProtoType *func =
4482 llvm::dyn_cast<clang::FunctionProtoType>(qual_type.getTypePtr());
4483 if (func)
4484 return CompilerType(getASTContext(), func->getReturnType());
4485 }
4486 return CompilerType();
4487}
4488
4489size_t
4490ClangASTContext::GetNumMemberFunctions(lldb::opaque_compiler_type_t type) {
4491 size_t num_functions = 0;
4492 if (type) {
4493 clang::QualType qual_type(GetCanonicalQualType(type));
4494 switch (qual_type->getTypeClass()) {
4495 case clang::Type::Record:
4496 if (GetCompleteQualType(getASTContext(), qual_type)) {
4497 const clang::RecordType *record_type =
4498 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
4499 const clang::RecordDecl *record_decl = record_type->getDecl();
4500 assert(record_decl)((record_decl) ? static_cast<void> (0) : __assert_fail (
"record_decl", "/build/llvm-toolchain-snapshot-8~svn345461/tools/lldb/source/Symbol/ClangASTContext.cpp"
, 4500, __PRETTY_FUNCTION__))
;
4501 const clang::CXXRecordDecl *cxx_record_decl =
4502 llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
4503 if (cxx_record_decl)
4504 num_functions = std::distance(cxx_record_decl->method_begin(),
4505 cxx_record_decl->method_end());
4506 }
4507 break;
4508
4509 case clang::Type::ObjCObjectPointer: {
4510 const clang::ObjCObjectPointerType *objc_class_type =
4511 qual_type->getAs<clang::ObjCObjectPointerType>();
4512 const clang::ObjCInterfaceType *objc_interface_type =
4513 objc_class_type->getInterfaceType();
4514 if (objc_interface_type &&
4515 GetCompleteType(static_cast<lldb::opaque_compiler_type_t>(
4516 const_cast<clang::ObjCInterfaceType *>(objc_interface_type)))) {
4517 clang::ObjCInterfaceDecl *class_interface_decl =
4518 objc_interface_type->getDecl();
4519 if (class_interface_decl) {
4520 num_functions = std::distance(class_interface_decl->meth_begin(),
4521 class_interface_decl->meth_end());
4522 }
4523 }
4524 break;
4525 }
4526
4527 case clang::Type::ObjCObject:
4528 case clang::Type::ObjCInterface:
4529 if (GetCompleteType(type)) {
4530 const clang::ObjCObjectType *objc_class_type =
4531 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
4532 if (objc_class_type) {
4533 clang::ObjCInterfaceDecl *class_interface_decl =
4534 objc_class_type->getInterface();
4535 if (class_interface_decl)
4536 num_functions = std::distance(class_interface_decl->meth_begin(),
4537 class_interface_decl->meth_end());
4538 }
4539 }
4540 break;
4541
4542 case clang::Type::Typedef:
4543 return CompilerType(getASTContext(),
4544 llvm::cast<clang::TypedefType>(qual_type)
4545 ->getDecl()
4546 ->getUnderlyingType())
4547 .GetNumMemberFunctions();
4548
4549 case clang::Type::Auto:
4550 return CompilerType(
4551 getASTContext(),
4552 llvm::cast<clang::AutoType>(qual_type)->getDeducedType())
4553 .GetNumMemberFunctions();
4554
4555 case clang::Type::Elaborated:
4556 return CompilerType(
4557 getASTContext(),
4558 llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType())
4559 .GetNumMemberFunctions();
4560
4561 case clang::Type::Paren:
4562 return CompilerType(getASTContext(),
4563 llvm::cast<clang::ParenType>(qual_type)->desugar())
4564 .GetNumMemberFunctions();
4565
4566 default:
4567 break;
4568 }
4569 }
4570 return num_functions;
4571}
4572
4573TypeMemberFunctionImpl
4574ClangASTContext::GetMemberFunctionAtIndex(lldb::opaque_compiler_type_t type,
4575 size_t idx) {
4576 std::string name;
4577 MemberFunctionKind kind(MemberFunctionKind::eMemberFunctionKindUnknown);
4578 CompilerType clang_type;
4579 CompilerDecl clang_decl;
4580 if (type) {
4581 clang::QualType qual_type(GetCanonicalQualType(type));
4582 switch (qual_type->getTypeClass()) {
4583 case clang::Type::Record:
4584 if (GetCompleteQualType(getASTContext(), qual_type)) {
4585 const clang::RecordType *record_type =
4586 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
4587 const clang::RecordDecl *record_decl = record_type->getDecl();
4588 assert(record_decl)((record_decl) ? static_cast<void> (0) : __assert_fail (
"record_decl", "/build/llvm-toolchain-snapshot-8~svn345461/tools/lldb/source/Symbol/ClangASTContext.cpp"
, 4588, __PRETTY_FUNCTION__))
;
4589 const clang::CXXRecordDecl *cxx_record_decl =
4590 llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
4591 if (cxx_record_decl) {
4592 auto method_iter = cxx_record_decl->method_begin();
4593 auto method_end = cxx_record_decl->method_end();
4594 if (idx <
4595 static_cast<size_t>(std::distance(method_iter, method_end))) {
4596 std::advance(method_iter, idx);
4597 clang::CXXMethodDecl *cxx_method_decl =
4598 method_iter->getCanonicalDecl();
4599 if (cxx_method_decl) {
4600 name = cxx_method_decl->getDeclName().getAsString();
4601 if (cxx_method_decl->isStatic())
4602 kind = lldb::eMemberFunctionKindStaticMethod;
4603 else if (llvm::isa<clang::CXXConstructorDecl>(cxx_method_decl))
4604 kind = lldb::eMemberFunctionKindConstructor;
4605 else if (llvm::isa<clang::CXXDestructorDecl>(cxx_method_decl))
4606 kind = lldb::eMemberFunctionKindDestructor;
4607 else
4608 kind = lldb::eMemberFunctionKindInstanceMethod;
4609 clang_type = CompilerType(
4610 this, cxx_method_decl->getType().getAsOpaquePtr());
4611 clang_decl = CompilerDecl(this, cxx_method_decl);
4612 }
4613 }
4614 }
4615 }
4616 break;
4617
4618 case clang::Type::ObjCObjectPointer: {
4619 const clang::ObjCObjectPointerType *objc_class_type =
4620 qual_type->getAs<clang::ObjCObjectPointerType>();
4621 const clang::ObjCInterfaceType *objc_interface_type =
4622 objc_class_type->getInterfaceType();
4623 if (objc_interface_type &&
4624 GetCompleteType(static_cast<lldb::opaque_compiler_type_t>(
4625 const_cast<clang::ObjCInterfaceType *>(objc_interface_type)))) {
4626 clang::ObjCInterfaceDecl *class_interface_decl =
4627 objc_interface_type->getDecl();
4628 if (class_interface_decl) {
4629 auto method_iter = class_interface_decl->meth_begin();
4630 auto method_end = class_interface_decl->meth_end();
4631 if (idx <
4632 static_cast<size_t>(std::distance(method_iter, method_end))) {
4633 std::advance(method_iter, idx);
4634 clang::ObjCMethodDecl *objc_method_decl =
4635 method_iter->getCanonicalDecl();
4636 if (objc_method_decl) {
4637 clang_decl = CompilerDecl(this, objc_method_decl);
4638 name = objc_method_decl->getSelector().getAsString();
4639 if (objc_method_decl->isClassMethod())
4640 kind = lldb::eMemberFunctionKindStaticMethod;
4641 else
4642 kind = lldb::eMemberFunctionKindInstanceMethod;
4643 }
4644 }
4645 }
4646 }
4647 break;
4648 }
4649
4650 case clang::Type::ObjCObject:
4651 case clang::Type::ObjCInterface:
4652 if (GetCompleteType(type)) {
4653 const clang::ObjCObjectType *objc_class_type =
4654 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
4655 if (objc_class_type) {
4656 clang::ObjCInterfaceDecl *class_interface_decl =
4657 objc_class_type->getInterface();
4658 if (class_interface_decl) {
4659 auto method_iter = class_interface_decl->meth_begin();
4660 auto method_end = class_interface_decl->meth_end();
4661 if (idx <
4662 static_cast<size_t>(std::distance(method_iter, method_end))) {
4663 std::advance(method_iter, idx);
4664 clang::ObjCMethodDecl *objc_method_decl =
4665 method_iter->getCanonicalDecl();
4666 if (objc_method_decl) {
4667 clang_decl = CompilerDecl(this, objc_method_decl);
4668 name = objc_method_decl->getSelector().getAsString();
4669 if (objc_method_decl->isClassMethod())
4670 kind = lldb::eMemberFunctionKindStaticMethod;
4671 else
4672 kind = lldb::eMemberFunctionKindInstanceMethod;
4673 }
4674 }
4675 }
4676 }
4677 }
4678 break;
4679
4680 case clang::Type::Typedef:
4681 return GetMemberFunctionAtIndex(llvm::cast<clang::TypedefType>(qual_type)
4682 ->getDecl()
4683 ->getUnderlyingType()
4684 .getAsOpaquePtr(),
4685 idx);
4686
4687 case clang::Type::Auto:
4688 return GetMemberFunctionAtIndex(llvm::cast<clang::AutoType>(qual_type)
4689 ->getDeducedType()
4690 .getAsOpaquePtr(),
4691 idx);
4692
4693 case clang::Type::Elaborated:
4694 return GetMemberFunctionAtIndex(
4695 llvm::cast<clang::ElaboratedType>(qual_type)
4696 ->getNamedType()
4697 .getAsOpaquePtr(),
4698 idx);
4699
4700 case clang::Type::Paren:
4701 return GetMemberFunctionAtIndex(
4702 llvm::cast<clang::ParenType>(qual_type)->desugar().getAsOpaquePtr(),
4703 idx);
4704
4705 default:
4706 break;
4707 }
4708 }
4709
4710 if (kind == eMemberFunctionKindUnknown)
4711 return TypeMemberFunctionImpl();
4712 else
4713 return TypeMemberFunctionImpl(clang_type, clang_decl, name, kind);
4714}
4715
4716CompilerType
4717ClangASTContext::GetNonReferenceType(lldb::opaque_compiler_type_t type) {
4718 if (type)
4719 return CompilerType(getASTContext(),
4720 GetQualType(type).getNonReferenceType());
4721 return CompilerType();
4722}
4723
4724CompilerType ClangASTContext::CreateTypedefType(
4725 const CompilerType &type, const char *typedef_name,
4726 const CompilerDeclContext &compiler_decl_ctx) {
4727 if (type && typedef_name && typedef_name[0]) {
4728 ClangASTContext *ast =
4729 llvm::dyn_cast<ClangASTContext>(type.GetTypeSystem());
4730 if (!ast)
4731 return CompilerType();
4732 clang::ASTContext *clang_ast = ast->getASTContext();
4733 clang::QualType qual_type(ClangUtil::GetQualType(type));
4734
4735 clang::DeclContext *decl_ctx =
4736 ClangASTContext::DeclContextGetAsDeclContext(compiler_decl_ctx);
4737 if (decl_ctx == nullptr)
4738 decl_ctx = ast->getASTContext()->getTranslationUnitDecl();
4739
4740 clang::TypedefDecl *decl = clang::TypedefDecl::Create(
4741 *clang_ast, decl_ctx, clang::SourceLocation(), clang::SourceLocation(),
4742 &clang_ast->Idents.get(typedef_name),
4743 clang_ast->getTrivialTypeSourceInfo(qual_type));
4744
4745 decl->setAccess(clang::AS_public); // TODO respect proper access specifier
4746
4747 decl_ctx->addDecl(decl);
4748
4749 // Get a uniqued clang::QualType for the typedef decl type
4750 return CompilerType(clang_ast, clang_ast->getTypedefType(decl));
4751 }
4752 return CompilerType();
4753}
4754
4755CompilerType
4756ClangASTContext::GetPointeeType(lldb::opaque_compiler_type_t type) {
4757 if (type) {
4758 clang::QualType qual_type(GetQualType(type));
4759 return CompilerType(getASTContext(),
4760 qual_type.getTypePtr()->getPointeeType());
4761 }
4762 return CompilerType();
4763}
4764
4765CompilerType
4766ClangASTContext::GetPointerType(lldb::opaque_compiler_type_t type) {
4767 if (type) {
4768 clang::QualType qual_type(GetQualType(type));
4769
4770 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
4771 switch (type_class) {
4772 case clang::Type::ObjCObject:
4773 case clang::Type::ObjCInterface:
4774 return CompilerType(getASTContext(),
4775 getASTContext()->getObjCObjectPointerType(qual_type));
4776
4777 default:
4778 return CompilerType(getASTContext(),
4779 getASTContext()->getPointerType(qual_type));
4780 }
4781 }
4782 return CompilerType();
4783}
4784
4785CompilerType
4786ClangASTContext::GetLValueReferenceType(lldb::opaque_compiler_type_t type) {
4787 if (type)
4788 return CompilerType(this, getASTContext()
4789 ->getLValueReferenceType(GetQualType(type))
4790 .getAsOpaquePtr());
4791 else
4792 return CompilerType();
4793}
4794
4795CompilerType
4796ClangASTContext::GetRValueReferenceType(lldb::opaque_compiler_type_t type) {
4797 if (type)
4798 return CompilerType(this, getASTContext()
4799 ->getRValueReferenceType(GetQualType(type))
4800 .getAsOpaquePtr());
4801 else
4802 return CompilerType();
4803}
4804
4805CompilerType
4806ClangASTContext::AddConstModifier(lldb::opaque_compiler_type_t type) {
4807 if (type) {
4808 clang::QualType result(GetQualType(type));
4809 result.addConst();
4810 return CompilerType(this, result.getAsOpaquePtr());
4811 }
4812 return CompilerType();
4813}
4814
4815CompilerType
4816ClangASTContext::AddVolatileModifier(lldb::opaque_compiler_type_t type) {
4817 if (type) {
4818 clang::QualType result(GetQualType(type));
4819 result.addVolatile();
4820 return CompilerType(this, result.getAsOpaquePtr());
4821 }
4822 return CompilerType();
4823}
4824
4825CompilerType
4826ClangASTContext::AddRestrictModifier(lldb::opaque_compiler_type_t type) {
4827 if (type) {
4828 clang::QualType result(GetQualType(type));
4829 result.addRestrict();
4830 return CompilerType(this, result.getAsOpaquePtr());
4831 }
4832 return CompilerType();
4833}
4834
4835CompilerType
4836ClangASTContext::CreateTypedef(lldb::opaque_compiler_type_t type,
4837 const char *typedef_name,
4838 const CompilerDeclContext &compiler_decl_ctx) {
4839 if (type) {
4840 clang::ASTContext *clang_ast = getASTContext();
4841 clang::QualType qual_type(GetQualType(type));
4842
4843 clang::DeclContext *decl_ctx =
4844 ClangASTContext::DeclContextGetAsDeclContext(compiler_decl_ctx);
4845 if (decl_ctx == nullptr)
4846 decl_ctx = getASTContext()->getTranslationUnitDecl();
4847
4848 clang::TypedefDecl *decl = clang::TypedefDecl::Create(
4849 *clang_ast, decl_ctx, clang::SourceLocation(), clang::SourceLocation(),
4850 &clang_ast->Idents.get(typedef_name),
4851 clang_ast->getTrivialTypeSourceInfo(qual_type));
4852
4853 clang::TagDecl *tdecl = nullptr;
4854 if (!qual_type.isNull()) {
4855 if (const clang::RecordType *rt = qual_type->getAs<clang::RecordType>())
4856 tdecl = rt->getDecl();
4857 if (const clang::EnumType *et = qual_type->getAs<clang::EnumType>())
4858 tdecl = et->getDecl();
4859 }
4860
4861 // Check whether this declaration is an anonymous struct, union, or enum,
4862 // hidden behind a typedef. If so, we try to check whether we have a
4863 // typedef tag to attach to the original record declaration
4864 if (tdecl && !tdecl->getIdentifier() && !tdecl->getTypedefNameForAnonDecl())
4865 tdecl->setTypedefNameForAnonDecl(decl);
4866
4867 decl->setAccess(clang::AS_public); // TODO respect proper access specifier
4868
4869 // Get a uniqued clang::QualType for the typedef decl type
4870 return CompilerType(this, clang_ast->getTypedefType(decl).getAsOpaquePtr());
4871 }
4872 return CompilerType();
4873}
4874
4875CompilerType
4876ClangASTContext::GetTypedefedType(lldb::opaque_compiler_type_t type) {
4877 if (type) {
4878 const clang::TypedefType *typedef_type =
4879 llvm::dyn_cast<clang::TypedefType>(GetQualType(type));
4880 if (typedef_type)
4881 return CompilerType(getASTContext(),
4882 typedef_type->getDecl()->getUnderlyingType());
4883 }
4884 return CompilerType();
4885}
4886
4887//----------------------------------------------------------------------
4888// Create related types using the current type's AST
4889//----------------------------------------------------------------------
4890
4891CompilerType ClangASTContext::GetBasicTypeFromAST(lldb::BasicType basic_type) {
4892 return ClangASTContext::GetBasicType(getASTContext(), basic_type);
4893}
4894//----------------------------------------------------------------------
4895// Exploring the type
4896//----------------------------------------------------------------------
4897
4898uint64_t ClangASTContext::GetBitSize(lldb::opaque_compiler_type_t type,
4899 ExecutionContextScope *exe_scope) {
4900 if (GetCompleteType(type)) {
4901 clang::QualType qual_type(GetCanonicalQualType(type));
4902 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
4903 switch (type_class) {
4904 case clang::Type::Record:
4905 if (GetCompleteType(type))
4906 return getASTContext()->getTypeSize(qual_type);
4907 else
4908 return 0;
4909 break;
4910
4911 case clang::Type::ObjCInterface:
4912 case clang::Type::ObjCObject: {
4913 ExecutionContext exe_ctx(exe_scope);
4914 Process *process = exe_ctx.GetProcessPtr();
4915 if (process) {
4916 ObjCLanguageRuntime *objc_runtime = process->GetObjCLanguageRuntime();
4917 if (objc_runtime) {
4918 uint64_t bit_size = 0;
4919 if (objc_runtime->GetTypeBitSize(
4920 CompilerType(getASTContext(), qual_type), bit_size))
4921 return bit_size;
4922 }
4923 } else {
4924 static bool g_printed = false;
4925 if (!g_printed) {
4926 StreamString s;
4927 DumpTypeDescription(type, &s);
4928
4929 llvm::outs() << "warning: trying to determine the size of type ";
4930 llvm::outs() << s.GetString() << "\n";
4931 llvm::outs() << "without a valid ExecutionContext. this is not "
4932 "reliable. please file a bug against LLDB.\n";
4933 llvm::outs() << "backtrace:\n";
4934 llvm::sys::PrintStackTrace(llvm::outs());
4935 llvm::outs() << "\n";
4936 g_printed = true;
4937 }
4938 }
4939 }
4940 LLVM_FALLTHROUGH[[clang::fallthrough]];
4941 default:
4942 const uint32_t bit_size = getASTContext()->getTypeSize(qual_type);
4943 if (bit_size == 0) {
4944 if (qual_type->isIncompleteArrayType())
4945 return getASTContext()->getTypeSize(
4946 qual_type->getArrayElementTypeNoTypeQual()
4947 ->getCanonicalTypeUnqualified());
4948 }
4949 if (qual_type->isObjCObjectOrInterfaceType())
4950 return bit_size +
4951 getASTContext()->getTypeSize(
4952 getASTContext()->ObjCBuiltinClassTy);
4953 return bit_size;
4954 }
4955 }
4956 return 0;
4957}
4958
4959size_t ClangASTContext::GetTypeBitAlign(lldb::opaque_compiler_type_t type) {
4960 if (GetCompleteType(type))
4961 return getASTContext()->getTypeAlign(GetQualType(type));
4962 return 0;
4963}
4964
4965lldb::Encoding ClangASTContext::GetEncoding(lldb::opaque_compiler_type_t type,
4966 uint64_t &count) {
4967 if (!type)
4968 return lldb::eEncodingInvalid;
4969
4970 count = 1;
4971 clang::QualType qual_type(GetCanonicalQualType(type));
4972
4973 switch (qual_type->getTypeClass()) {
4974 case clang::Type::UnaryTransform:
4975 break;
4976
4977 case clang::Type::FunctionNoProto:
4978 case clang::Type::FunctionProto:
4979 break;
4980
4981 case clang::Type::IncompleteArray:
4982 case clang::Type::VariableArray:
4983 break;
4984
4985 case clang::Type::ConstantArray:
4986 break;
4987
4988 case clang::Type::DependentVector:
4989 case clang::Type::ExtVector:
4990 case clang::Type::Vector:
4991 // TODO: Set this to more than one???
4992 break;
4993
4994 case clang::Type::Builtin:
4995 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
4996 case clang::BuiltinType::Void:
4997 break;
4998
4999 case clang::BuiltinType::Bool:
5000 case clang::BuiltinType::Char_S:
5001 case clang::BuiltinType::SChar:
5002 case clang::BuiltinType::WChar_S:
5003 case clang::BuiltinType::Short:
5004 case clang::BuiltinType::Int:
5005 case clang::BuiltinType::Long:
5006 case clang::BuiltinType::LongLong:
5007 case clang::BuiltinType::Int128:
5008 return lldb::eEncodingSint;
5009
5010 case clang::BuiltinType::Char_U:
5011 case clang::BuiltinType::UChar:
5012 case clang::BuiltinType::WChar_U:
5013 case clang::BuiltinType::Char8:
5014 case clang::BuiltinType::Char16:
5015 case clang::BuiltinType::Char32:
5016 case clang::BuiltinType::UShort:
5017 case clang::BuiltinType::UInt:
5018 case clang::BuiltinType::ULong:
5019 case clang::BuiltinType::ULongLong:
5020 case clang::BuiltinType::UInt128:
5021 return lldb::eEncodingUint;
5022
5023 // Fixed point types. Note that they are currently ignored.
5024 case clang::BuiltinType::ShortAccum:
5025 case clang::BuiltinType::Accum:
5026 case clang::BuiltinType::LongAccum:
5027 case clang::BuiltinType::UShortAccum:
5028 case clang::BuiltinType::UAccum:
5029 case clang::BuiltinType::ULongAccum:
5030 case clang::BuiltinType::ShortFract:
5031 case clang::BuiltinType::Fract:
5032 case clang::BuiltinType::LongFract:
5033 case clang::BuiltinType::UShortFract:
5034 case clang::BuiltinType::UFract:
5035 case clang::BuiltinType::ULongFract:
5036 case clang::BuiltinType::SatShortAccum:
5037 case clang::BuiltinType::SatAccum:
5038 case clang::BuiltinType::SatLongAccum:
5039 case clang::BuiltinType::SatUShortAccum:
5040 case clang::BuiltinType::SatUAccum:
5041 case clang::BuiltinType::SatULongAccum:
5042 case clang::BuiltinType::SatShortFract:
5043 case clang::BuiltinType::SatFract:
5044 case clang::BuiltinType::SatLongFract:
5045 case clang::BuiltinType::SatUShortFract:
5046 case clang::BuiltinType::SatUFract:
5047 case clang::BuiltinType::SatULongFract:
5048 break;
5049
5050 case clang::BuiltinType::Half:
5051 case clang::BuiltinType::Float:
5052 case clang::BuiltinType::Float16:
5053 case clang::BuiltinType::Float128:
5054 case clang::BuiltinType::Double:
5055 case clang::BuiltinType::LongDouble:
5056 return lldb::eEncodingIEEE754;
5057
5058 case clang::BuiltinType::ObjCClass:
5059 case clang::BuiltinType::ObjCId:
5060 case clang::BuiltinType::ObjCSel:
5061 return lldb::eEncodingUint;
5062
5063 case clang::BuiltinType::NullPtr:
5064 return lldb::eEncodingUint;
5065
5066 case clang::BuiltinType::Kind::ARCUnbridgedCast:
5067 case clang::BuiltinType::Kind::BoundMember:
5068 case clang::BuiltinType::Kind::BuiltinFn:
5069 case clang::BuiltinType::Kind::Dependent:
5070 case clang::BuiltinType::Kind::OCLClkEvent:
5071 case clang::BuiltinType::Kind::OCLEvent:
5072 case clang::BuiltinType::Kind::OCLImage1dRO:
5073 case clang::BuiltinType::Kind::OCLImage1dWO:
5074 case clang::BuiltinType::Kind::OCLImage1dRW:
5075 case clang::BuiltinType::Kind::OCLImage1dArrayRO:
5076 case clang::BuiltinType::Kind::OCLImage1dArrayWO:
5077 case clang::BuiltinType::Kind::OCLImage1dArrayRW:
5078 case clang::BuiltinType::Kind::OCLImage1dBufferRO:
5079 case clang::BuiltinType::Kind::OCLImage1dBufferWO:
5080 case clang::BuiltinType::Kind::OCLImage1dBufferRW:
5081 case clang::BuiltinType::Kind::OCLImage2dRO:
5082 case clang::BuiltinType::Kind::OCLImage2dWO:
5083 case clang::BuiltinType::Kind::OCLImage2dRW:
5084 case clang::BuiltinType::Kind::OCLImage2dArrayRO:
5085 case clang::BuiltinType::Kind::OCLImage2dArrayWO:
5086 case clang::BuiltinType::Kind::OCLImage2dArrayRW:
5087 case clang::BuiltinType::Kind::OCLImage2dArrayDepthRO:
5088 case clang::BuiltinType::Kind::OCLImage2dArrayDepthWO:
5089 case clang::BuiltinType::Kind::OCLImage2dArrayDepthRW:
5090 case clang::BuiltinType::Kind::OCLImage2dArrayMSAARO:
5091 case clang::BuiltinType::Kind::OCLImage2dArrayMSAAWO:
5092 case clang::BuiltinType::Kind::OCLImage2dArrayMSAARW:
5093 case clang::BuiltinType::Kind::OCLImage2dArrayMSAADepthRO:
5094 case clang::BuiltinType::Kind::OCLImage2dArrayMSAADepthWO:
5095 case clang::BuiltinType::Kind::OCLImage2dArrayMSAADepthRW:
5096 case clang::BuiltinType::Kind::OCLImage2dDepthRO:
5097 case clang::BuiltinType::Kind::OCLImage2dDepthWO:
5098 case clang::BuiltinType::Kind::OCLImage2dDepthRW:
5099 case clang::BuiltinType::Kind::OCLImage2dMSAARO:
5100 case clang::BuiltinType::Kind::OCLImage2dMSAAWO:
5101 case clang::BuiltinType::Kind::OCLImage2dMSAARW:
5102 case clang::BuiltinType::Kind::OCLImage2dMSAADepthRO:
5103 case clang::BuiltinType::Kind::OCLImage2dMSAADepthWO:
5104 case clang::BuiltinType::Kind::OCLImage2dMSAADepthRW:
5105 case clang::BuiltinType::Kind::OCLImage3dRO:
5106 case clang::BuiltinType::Kind::OCLImage3dWO:
5107 case clang::BuiltinType::Kind::OCLImage3dRW:
5108 case clang::BuiltinType::Kind::OCLQueue:
5109 case clang::BuiltinType::Kind::OCLReserveID:
5110 case clang::BuiltinType::Kind::OCLSampler:
5111 case clang::BuiltinType::Kind::OMPArraySection:
5112 case clang::BuiltinType::Kind::Overload:
5113 case clang::BuiltinType::Kind::PseudoObject:
5114 case clang::BuiltinType::Kind::UnknownAny:
5115 break;
5116 }
5117 break;
5118 // All pointer types are represented as unsigned integer encodings. We may
5119 // nee to add a eEncodingPointer if we ever need to know the difference
5120 case clang::Type::ObjCObjectPointer:
5121 case clang::Type::BlockPointer:
5122 case clang::Type::Pointer:
5123 case clang::Type::LValueReference:
5124 case clang::Type::RValueReference:
5125 case clang::Type::MemberPointer:
5126 return lldb::eEncodingUint;
5127 case clang::Type::Complex: {
5128 lldb::Encoding encoding = lldb::eEncodingIEEE754;
5129 if (qual_type->isComplexType())
5130 encoding = lldb::eEncodingIEEE754;
5131 else {
5132 const clang::ComplexType *complex_type =
5133 qual_type->getAsComplexIntegerType();
5134 if (complex_type)
5135 encoding = CompilerType(getASTContext(), complex_type->getElementType())
5136 .GetEncoding(count);
5137 else
5138 encoding = lldb::eEncodingSint;
5139 }
5140 count = 2;
5141 return encoding;
5142 }
5143
5144 case clang::Type::ObjCInterface:
5145 break;
5146 case clang::Type::Record:
5147 break;
5148 case clang::Type::Enum:
5149 return lldb::eEncodingSint;
5150 case clang::Type::Typedef:
5151 return CompilerType(getASTContext(),
5152 llvm::cast<clang::TypedefType>(qual_type)
5153 ->getDecl()
5154 ->getUnderlyingType())
5155 .GetEncoding(count);
5156
5157 case clang::Type::Auto:
5158 return CompilerType(
5159 getASTContext(),
5160 llvm::cast<clang::AutoType>(qual_type)->getDeducedType())
5161 .GetEncoding(count);
5162
5163 case clang::Type::Elaborated:
5164 return CompilerType(
5165 getASTContext(),
5166 llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType())
5167 .GetEncoding(count);
5168
5169 case clang::Type::Paren:
5170 return CompilerType(getASTContext(),
5171 llvm::cast<clang::ParenType>(qual_type)->desugar())
5172 .GetEncoding(count);
5173 case clang::Type::TypeOfExpr:
5174 return CompilerType(getASTContext(),
5175 llvm::cast<clang::TypeOfExprType>(qual_type)
5176 ->getUnderlyingExpr()
5177 ->getType())
5178 .GetEncoding(count);
5179 case clang::Type::TypeOf:
5180 return CompilerType(
5181 getASTContext(),
5182 llvm::cast<clang::TypeOfType>(qual_type)->getUnderlyingType())
5183 .GetEncoding(count);
5184 case clang::Type::Decltype:
5185 return CompilerType(
5186 getASTContext(),
5187 llvm::cast<clang::DecltypeType>(qual_type)->getUnderlyingType())
5188 .GetEncoding(count);
5189 case clang::Type::DependentSizedArray:
5190 case clang::Type::DependentSizedExtVector:
5191 case clang::Type::UnresolvedUsing:
5192 case clang::Type::Attributed:
5193 case clang::Type::TemplateTypeParm:
5194 case clang::Type::SubstTemplateTypeParm:
5195 case clang::Type::SubstTemplateTypeParmPack:
5196 case clang::Type::InjectedClassName:
5197 case clang::Type::DependentName:
5198 case clang::Type::DependentTemplateSpecialization:
5199 case clang::Type::PackExpansion:
5200 case clang::Type::ObjCObject:
5201
5202 case clang::Type::TemplateSpecialization:
5203 case clang::Type::DeducedTemplateSpecialization:
5204 case clang::Type::Atomic:
5205 case clang::Type::Adjusted:
5206 case clang::Type::Pipe:
5207 break;
5208
5209 // pointer type decayed from an array or function type.
5210 case clang::Type::Decayed:
5211 break;
5212 case clang::Type::ObjCTypeParam:
5213 break;
5214
5215 case clang::Type::DependentAddressSpace:
5216 break;
5217 }
5218 count = 0;
5219 return lldb::eEncodingInvalid;
5220}
5221
5222lldb::Format ClangASTContext::GetFormat(lldb::opaque_compiler_type_t type) {
5223 if (!type)
5224 return lldb::eFormatDefault;
5225
5226 clang::QualType qual_type(GetCanonicalQualType(type));
5227
5228 switch (qual_type->getTypeClass()) {
5229 case clang::Type::UnaryTransform:
5230 break;
5231
5232 case clang::Type::FunctionNoProto:
5233 case clang::Type::FunctionProto:
5234 break;
5235
5236 case clang::Type::IncompleteArray:
5237 case clang::Type::VariableArray:
5238 break;
5239
5240 case clang::Type::ConstantArray:
5241 return lldb::eFormatVoid; // no value
5242
5243 case clang::Type::DependentVector:
5244 case clang::Type::ExtVector:
5245 case clang::Type::Vector:
5246 break;
5247
5248 case clang::Type::Builtin:
5249 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
5250 // default: assert(0 && "Unknown builtin type!");
5251 case clang::BuiltinType::UnknownAny:
5252 case clang::BuiltinType::Void:
5253 case clang::BuiltinType::BoundMember:
5254 break;
5255
5256 case clang::BuiltinType::Bool:
5257 return lldb::eFormatBoolean;
5258 case clang::BuiltinType::Char_S:
5259 case clang::BuiltinType::SChar:
5260 case clang::BuiltinType::WChar_S:
5261 case clang::BuiltinType::Char_U:
5262 case clang::BuiltinType::UChar:
5263 case clang::BuiltinType::WChar_U:
5264 return lldb::eFormatChar;
5265 case clang::BuiltinType::Char16:
5266 return lldb::eFormatUnicode16;
5267 case clang::BuiltinType::Char32:
5268 return lldb::eFormatUnicode32;
5269 case clang::BuiltinType::UShort:
5270 return lldb::eFormatUnsigned;
5271 case clang::BuiltinType::Short:
5272 return lldb::eFormatDecimal;
5273 case clang::BuiltinType::UInt:
5274 return lldb::eFormatUnsigned;
5275 case clang::BuiltinType::Int:
5276 return lldb::eFormatDecimal;
5277 case clang::BuiltinType::ULong:
5278 return lldb::eFormatUnsigned;
5279 case clang::BuiltinType::Long:
5280 return lldb::eFormatDecimal;
5281 case clang::BuiltinType::ULongLong:
5282 return lldb::eFormatUnsigned;
5283 case clang::BuiltinType::LongLong:
5284 return lldb::eFormatDecimal;
5285 case clang::BuiltinType::UInt128:
5286 return lldb::eFormatUnsigned;
5287 case clang::BuiltinType::Int128:
5288 return lldb::eFormatDecimal;
5289 case clang::BuiltinType::Half:
5290 case clang::BuiltinType::Float:
5291 case clang::BuiltinType::Double:
5292 case clang::BuiltinType::LongDouble:
5293 return lldb::eFormatFloat;
5294 default:
5295 return lldb::eFormatHex;
5296 }
5297 break;
5298 case clang::Type::ObjCObjectPointer:
5299 return lldb::eFormatHex;
5300 case clang::Type::BlockPointer:
5301 return lldb::eFormatHex;
5302 case clang::Type::Pointer:
5303 return lldb::eFormatHex;
5304 case clang::Type::LValueReference:
5305 case clang::Type::RValueReference:
5306 return lldb::eFormatHex;
5307 case clang::Type::MemberPointer:
5308 break;
5309 case clang::Type::Complex: {
5310 if (qual_type->isComplexType())
5311 return lldb::eFormatComplex;
5312 else
5313 return lldb::eFormatComplexInteger;
5314 }
5315 case clang::Type::ObjCInterface:
5316 break;
5317 case clang::Type::Record:
5318 break;
5319 case clang::Type::Enum:
5320 return lldb::eFormatEnum;
5321 case clang::Type::Typedef:
5322 return CompilerType(getASTContext(),
5323 llvm::cast<clang::TypedefType>(qual_type)
5324 ->getDecl()
5325 ->getUnderlyingType())
5326 .GetFormat();
5327 case clang::Type::Auto:
5328 return CompilerType(getASTContext(),
5329 llvm::cast<clang::AutoType>(qual_type)->desugar())
5330 .GetFormat();
5331 case clang::Type::Paren:
5332 return CompilerType(getASTContext(),
5333 llvm::cast<clang::ParenType>(qual_type)->desugar())
5334 .GetFormat();
5335 case clang::Type::Elaborated:
5336 return CompilerType(
5337 getASTContext(),
5338 llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType())
5339 .GetFormat();
5340 case clang::Type::TypeOfExpr:
5341 return CompilerType(getASTContext(),
5342 llvm::cast<clang::TypeOfExprType>(qual_type)
5343 ->getUnderlyingExpr()
5344 ->getType())
5345 .GetFormat();
5346 case clang::Type::TypeOf:
5347 return CompilerType(
5348 getASTContext(),
5349 llvm::cast<clang::TypeOfType>(qual_type)->getUnderlyingType())
5350 .GetFormat();
5351 case clang::Type::Decltype:
5352 return CompilerType(
5353 getASTContext(),
5354 llvm::cast<clang::DecltypeType>(qual_type)->getUnderlyingType())
5355 .GetFormat();
5356 case clang::Type::DependentSizedArray:
5357 case clang::Type::DependentSizedExtVector:
5358 case clang::Type::UnresolvedUsing:
5359 case clang::Type::Attributed:
5360 case clang::Type::TemplateTypeParm:
5361 case clang::Type::SubstTemplateTypeParm:
5362 case clang::Type::SubstTemplateTypeParmPack:
5363 case clang::Type::InjectedClassName:
5364 case clang::Type::DependentName:
5365 case clang::Type::DependentTemplateSpecialization:
5366 case clang::Type::PackExpansion:
5367 case clang::Type::ObjCObject:
5368
5369 case clang::Type::TemplateSpecialization:
5370 case clang::Type::DeducedTemplateSpecialization:
5371 case clang::Type::Atomic:
5372 case clang::Type::Adjusted:
5373 case clang::Type::Pipe:
5374 break;
5375
5376 // pointer type decayed from an array or function type.
5377 case clang::Type::Decayed:
5378 break;
5379 case clang::Type::ObjCTypeParam:
5380 break;
5381
5382 case clang::Type::DependentAddressSpace:
5383 break;
5384 }
5385 // We don't know hot to display this type...
5386 return lldb::eFormatBytes;
5387}
5388
5389static bool ObjCDeclHasIVars(clang::ObjCInterfaceDecl *class_interface_decl,
5390 bool check_superclass) {
5391 while (class_interface_decl) {
5392 if (class_interface_decl->ivar_size() > 0)
5393 return true;
5394
5395 if (check_superclass)
5396 class_interface_decl = class_interface_decl->getSuperClass();
5397 else
5398 break;
5399 }
5400 return false;
5401}
5402
5403uint32_t ClangASTContext::GetNumChildren(lldb::opaque_compiler_type_t type,
5404 bool omit_empty_base_classes) {
5405 if (!type)
5406 return 0;
5407
5408 uint32_t num_children = 0;
5409 clang::QualType qual_type(GetQualType(type));
5410 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5411 switch (type_class) {
5412 case clang::Type::Builtin:
5413 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
5414 case clang::BuiltinType::ObjCId: // child is Class
5415 case clang::BuiltinType::ObjCClass: // child is Class
5416 num_children = 1;
5417 break;
5418
5419 default:
5420 break;
5421 }
5422 break;
5423
5424 case clang::Type::Complex:
5425 return 0;
5426
5427 case clang::Type::Record:
5428 if (GetCompleteQualType(getASTContext(), qual_type)) {
5429 const clang::RecordType *record_type =
5430 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
5431 const clang::RecordDecl *record_decl = record_type->getDecl();
5432 assert(record_decl)((record_decl) ? static_cast<void> (0) : __assert_fail (
"record_decl", "/build/llvm-toolchain-snapshot-8~svn345461/tools/lldb/source/Symbol/ClangASTContext.cpp"
, 5432, __PRETTY_FUNCTION__))
;
5433 const clang::CXXRecordDecl *cxx_record_decl =
5434 llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
5435 if (cxx_record_decl) {
5436 if (omit_empty_base_classes) {
5437 // Check each base classes to see if it or any of its base classes
5438 // contain any fields. This can help limit the noise in variable
5439 // views by not having to show base classes that contain no members.
5440 clang::CXXRecordDecl::base_class_const_iterator base_class,
5441 base_class_end;
5442 for (base_class = cxx_record_decl->bases_begin(),
5443 base_class_end = cxx_record_decl->bases_end();
5444 base_class != base_class_end; ++base_class) {
5445 const clang::CXXRecordDecl *base_class_decl =
5446 llvm::cast<clang::CXXRecordDecl>(
5447 base_class->getType()
5448 ->getAs<clang::RecordType>()
5449 ->getDecl());
5450
5451 // Skip empty base classes
5452 if (ClangASTContext::RecordHasFields(base_class_decl) == false)
5453 continue;
5454
5455 num_children++;
5456 }
5457 } else {
5458 // Include all base classes
5459 num_children += cxx_record_decl->getNumBases();
5460 }
5461 }
5462 clang::RecordDecl::field_iterator field, field_end;
5463 for (field = record_decl->field_begin(),
5464 field_end = record_decl->field_end();
5465 field != field_end; ++field)
5466 ++num_children;
5467 }
5468 break;
5469
5470 case clang::Type::ObjCObject:
5471 case clang::Type::ObjCInterface:
5472 if (GetCompleteQualType(getASTContext(), qual_type)) {
5473 const clang::ObjCObjectType *objc_class_type =
5474 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
5475 assert(objc_class_type)((objc_class_type) ? static_cast<void> (0) : __assert_fail
("objc_class_type", "/build/llvm-toolchain-snapshot-8~svn345461/tools/lldb/source/Symbol/ClangASTContext.cpp"
, 5475, __PRETTY_FUNCTION__))
;
5476 if (objc_class_type) {
5477 clang::ObjCInterfaceDecl *class_interface_decl =
5478 objc_class_type->getInterface();
5479
5480 if (class_interface_decl) {
5481
5482 clang::ObjCInterfaceDecl *superclass_interface_decl =
5483 class_interface_decl->getSuperClass();
5484 if (superclass_interface_decl) {
5485 if (omit_empty_base_classes) {
5486 if (ObjCDeclHasIVars(superclass_interface_decl, true))
5487 ++num_children;
5488 } else
5489 ++num_children;
5490 }
5491
5492 num_children += class_interface_decl->ivar_size();
5493 }
5494 }
5495 }
5496 break;
5497
5498 case clang::Type::ObjCObjectPointer: {
5499 const clang::ObjCObjectPointerType *pointer_type =
5500 llvm::cast<clang::ObjCObjectPointerType>(qual_type.getTypePtr());
5501 clang::QualType pointee_type = pointer_type->getPointeeType();
5502 uint32_t num_pointee_children =
5503 CompilerType(getASTContext(), pointee_type)
5504 .GetNumChildren(omit_empty_base_classes);
5505 // If this type points to a simple type, then it has 1 child
5506 if (num_pointee_children == 0)
5507 num_children = 1;
5508 else
5509 num_children = num_pointee_children;
5510 } break;
5511
5512 case clang::Type::Vector:
5513 case clang::Type::ExtVector:
5514 num_children =
5515 llvm::cast<clang::VectorType>(qual_type.getTypePtr())->getNumElements();
5516 break;
5517
5518 case clang::Type::ConstantArray:
5519 num_children = llvm::cast<clang::ConstantArrayType>(qual_type.getTypePtr())
5520 ->getSize()
5521 .getLimitedValue();
5522 break;
5523
5524 case clang::Type::Pointer: {
5525 const clang::PointerType *pointer_type =
5526 llvm::cast<clang::PointerType>(qual_type.getTypePtr());
5527 clang::QualType pointee_type(pointer_type->getPointeeType());
5528 uint32_t num_pointee_children =
5529 CompilerType(getASTContext(), pointee_type)
5530 .GetNumChildren(omit_empty_base_classes);
5531 if (num_pointee_children == 0) {
5532 // We have a pointer to a pointee type that claims it has no children. We
5533 // will want to look at
5534 num_children = GetNumPointeeChildren(pointee_type);
5535 } else
5536 num_children = num_pointee_children;
5537 } break;
5538
5539 case clang::Type::LValueReference:
5540 case clang::Type::RValueReference: {
5541 const clang::ReferenceType *reference_type =
5542 llvm::cast<clang::ReferenceType>(qual_type.getTypePtr());
5543 clang::QualType pointee_type = reference_type->getPointeeType();
5544 uint32_t num_pointee_children =
5545 CompilerType(getASTContext(), pointee_type)
5546 .GetNumChildren(omit_empty_base_classes);
5547 // If this type points to a simple type, then it has 1 child
5548 if (num_pointee_children == 0)
5549 num_children = 1;
5550 else
5551 num_children = num_pointee_children;
5552 } break;
5553
5554 case clang::Type::Typedef:
5555 num_children =
5556 CompilerType(getASTContext(), llvm::cast<clang::TypedefType>(qual_type)
5557 ->getDecl()
5558 ->getUnderlyingType())
5559 .GetNumChildren(omit_empty_base_classes);
5560 break;
5561
5562 case clang::Type::Auto:
5563 num_children =
5564 CompilerType(getASTContext(),
5565 llvm::cast<clang::AutoType>(qual_type)->getDeducedType())
5566 .GetNumChildren(omit_empty_base_classes);
5567 break;
5568
5569 case clang::Type::Elaborated:
5570 num_children =
5571 CompilerType(
5572 getASTContext(),
5573 llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType())
5574 .GetNumChildren(omit_empty_base_classes);
5575 break;
5576
5577 case clang::Type::Paren:
5578 num_children =
5579 CompilerType(getASTContext(),
5580 llvm::cast<clang::ParenType>(qual_type)->desugar())
5581 .GetNumChildren(omit_empty_base_classes);
5582 break;
5583 default:
5584 break;
5585 }
5586 return num_children;
5587}
5588
5589CompilerType ClangASTContext::GetBuiltinTypeByName(const ConstString &name) {
5590 return GetBasicType(GetBasicTypeEnumeration(name));
5591}
5592
5593lldb::BasicType
5594ClangASTContext::GetBasicTypeEnumeration(lldb::opaque_compiler_type_t type) {
5595 if (type) {
5596 clang::QualType qual_type(GetQualType(type));
5597 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5598 if (type_class == clang::Type::Builtin) {
5599 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
5600 case clang::BuiltinType::Void:
5601 return eBasicTypeVoid;
5602 case clang::BuiltinType::Bool:
5603 return eBasicTypeBool;
5604 case clang::BuiltinType::Char_S:
5605 return eBasicTypeSignedChar;
5606 case clang::BuiltinType::Char_U:
5607 return eBasicTypeUnsignedChar;
5608 case clang::BuiltinType::Char16:
5609 return eBasicTypeChar16;
5610 case clang::BuiltinType::Char32:
5611 return eBasicTypeChar32;
5612 case clang::BuiltinType::UChar:
5613 return eBasicTypeUnsignedChar;
5614 case clang::BuiltinType::SChar:
5615 return eBasicTypeSignedChar;
5616 case clang::BuiltinType::WChar_S:
5617 return eBasicTypeSignedWChar;
5618 case clang::BuiltinType::WChar_U:
5619 return eBasicTypeUnsignedWChar;
5620 case clang::BuiltinType::Short:
5621 return eBasicTypeShort;
5622 case clang::BuiltinType::UShort:
5623 return eBasicTypeUnsignedShort;
5624 case clang::BuiltinType::Int:
5625 return eBasicTypeInt;
5626 case clang::BuiltinType::UInt:
5627 return eBasicTypeUnsignedInt;
5628 case clang::BuiltinType::Long:
5629 return eBasicTypeLong;
5630 case clang::BuiltinType::ULong:
5631 return eBasicTypeUnsignedLong;
5632 case clang::BuiltinType::LongLong:
5633 return eBasicTypeLongLong;
5634 case clang::BuiltinType::ULongLong:
5635 return eBasicTypeUnsignedLongLong;
5636 case clang::BuiltinType::Int128:
5637 return eBasicTypeInt128;
5638 case clang::BuiltinType::UInt128:
5639 return eBasicTypeUnsignedInt128;
5640
5641 case clang::BuiltinType::Half:
5642 return eBasicTypeHalf;
5643 case clang::BuiltinType::Float:
5644 return eBasicTypeFloat;
5645 case clang::BuiltinType::Double:
5646 return eBasicTypeDouble;
5647 case clang::BuiltinType::LongDouble:
5648 return eBasicTypeLongDouble;
5649
5650 case clang::BuiltinType::NullPtr:
5651 return eBasicTypeNullPtr;
5652 case clang::BuiltinType::ObjCId:
5653 return eBasicTypeObjCID;
5654 case clang::BuiltinType::ObjCClass:
5655 return eBasicTypeObjCClass;
5656 case clang::BuiltinType::ObjCSel:
5657 return eBasicTypeObjCSel;
5658 default:
5659 return eBasicTypeOther;
5660 }
5661 }
5662 }
5663 return eBasicTypeInvalid;
5664}
5665
5666void ClangASTContext::ForEachEnumerator(
5667 lldb::opaque_compiler_type_t type,
5668 std::function<bool(const CompilerType &integer_type,
5669 const ConstString &name,
5670 const llvm::APSInt &value)> const &callback) {
5671 const clang::EnumType *enum_type =
5672 llvm::dyn_cast<clang::EnumType>(GetCanonicalQualType(type));
5673 if (enum_type) {
5674 const clang::EnumDecl *enum_decl = enum_type->getDecl();
5675 if (enum_decl) {
5676 CompilerType integer_type(this,
5677 enum_decl->getIntegerType().getAsOpaquePtr());
5678
5679 clang::EnumDecl::enumerator_iterator enum_pos, enum_end_pos;
5680 for (enum_pos = enum_decl->enumerator_begin(),
5681 enum_end_pos = enum_decl->enumerator_end();
5682 enum_pos != enum_end_pos; ++enum_pos) {
5683 ConstString name(enum_pos->getNameAsString().c_str());
5684 if (!callback(integer_type, name, enum_pos->getInitVal()))
5685 break;
5686 }
5687 }
5688 }
5689}
5690
5691#pragma mark Aggregate Types
5692
5693uint32_t ClangASTContext::GetNumFields(lldb::opaque_compiler_type_t type) {
5694 if (!type)
5695 return 0;
5696
5697 uint32_t count = 0;
5698 clang::QualType qual_type(GetCanonicalQualType(type));
5699 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5700 switch (type_class) {
5701 case clang::Type::Record:
5702 if (GetCompleteType(type)) {
5703 const clang::RecordType *record_type =
5704 llvm::dyn_cast<clang::RecordType>(qual_type.getTypePtr());
5705 if (record_type) {
5706 clang::RecordDecl *record_decl = record_type->getDecl();
5707 if (record_decl) {
5708 uint32_t field_idx = 0;
5709 clang::RecordDecl::field_iterator field, field_end;
5710 for (field = record_decl->field_begin(),
5711 field_end = record_decl->field_end();
5712 field != field_end; ++field)
5713 ++field_idx;
5714 count = field_idx;
5715 }
5716 }
5717 }
5718 break;
5719
5720 case clang::Type::Typedef:
5721 count =
5722 CompilerType(getASTContext(), llvm::cast<clang::TypedefType>(qual_type)
5723 ->getDecl()
5724 ->getUnderlyingType())
5725 .GetNumFields();
5726 break;
5727
5728 case clang::Type::Auto:
5729 count =
5730 CompilerType(getASTContext(),
5731 llvm::cast<clang::AutoType>(qual_type)->getDeducedType())
5732 .GetNumFields();
5733 break;
5734
5735 case clang::Type::Elaborated:
5736 count = CompilerType(
5737 getASTContext(),
5738 llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType())
5739 .GetNumFields();
5740 break;
5741
5742 case clang::Type::Paren:
5743 count = CompilerType(getASTContext(),
5744 llvm::cast<clang::ParenType>(qual_type)->desugar())
5745 .GetNumFields();
5746 break;
5747
5748 case clang::Type::ObjCObjectPointer: {
5749 const clang::ObjCObjectPointerType *objc_class_type =
5750 qual_type->getAs<clang::ObjCObjectPointerType>();
5751 const clang::ObjCInterfaceType *objc_interface_type =
5752 objc_class_type->getInterfaceType();
5753 if (objc_interface_type &&
5754 GetCompleteType(static_cast<lldb::opaque_compiler_type_t>(
5755 const_cast<clang::ObjCInterfaceType *>(objc_interface_type)))) {
5756 clang::ObjCInterfaceDecl *class_interface_decl =
5757 objc_interface_type->getDecl();
5758 if (class_interface_decl) {
5759 count = class_interface_decl->ivar_size();
5760 }
5761 }
5762 break;
5763 }
5764
5765 case clang::Type::ObjCObject:
5766 case clang::Type::ObjCInterface:
5767 if (GetCompleteType(type)) {
5768 const clang::ObjCObjectType *objc_class_type =
5769 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
5770 if (objc_class_type) {
5771 clang::ObjCInterfaceDecl *class_interface_decl =
5772 objc_class_type->getInterface();
5773
5774 if (class_interface_decl)
5775 count = class_interface_decl->ivar_size();
5776 }
5777 }
5778 break;
5779
5780 default:
5781 break;
5782 }
5783 return count;
5784}
5785
5786static lldb::opaque_compiler_type_t
5787GetObjCFieldAtIndex(clang::ASTContext *ast,
5788 clang::ObjCInterfaceDecl *class_interface_decl, size_t idx,
5789 std::string &name, uint64_t *bit_offset_ptr,
5790 uint32_t *bitfield_bit_size_ptr, bool *is_bitfield_ptr) {
5791 if (class_interface_decl) {
5792 if (idx < (class_interface_decl->ivar_size())) {
5793 clang::ObjCInterfaceDecl::ivar_iterator ivar_pos,
5794 ivar_end = class_interface_decl->ivar_end();
5795 uint32_t ivar_idx = 0;
5796
5797 for (ivar_pos = class_interface_decl->ivar_begin(); ivar_pos != ivar_end;
5798 ++ivar_pos, ++ivar_idx) {
5799 if (ivar_idx == idx) {
5800 const clang::ObjCIvarDecl *ivar_decl = *ivar_pos;
5801
5802 clang::QualType ivar_qual_type(ivar_decl->getType());
5803
5804 name.assign(ivar_decl->getNameAsString());
5805
5806 if (bit_offset_ptr) {
5807 const clang::ASTRecordLayout &interface_layout =
5808 ast->getASTObjCInterfaceLayout(class_interface_decl);
5809 *bit_offset_ptr = interface_layout.getFieldOffset(ivar_idx);
5810 }
5811
5812 const bool is_bitfield = ivar_pos->isBitField();
5813
5814 if (bitfield_bit_size_ptr) {
5815 *bitfield_bit_size_ptr = 0;
5816
5817 if (is_bitfield && ast) {
5818 clang::Expr *bitfield_bit_size_expr = ivar_pos->getBitWidth();
5819 llvm::APSInt bitfield_apsint;
5820 if (bitfield_bit_size_expr &&
5821 bitfield_bit_size_expr->EvaluateAsInt(bitfield_apsint,
5822 *ast)) {
5823 *bitfield_bit_size_ptr = bitfield_apsint.getLimitedValue();
5824 }
5825 }
5826 }
5827 if (is_bitfield_ptr)
5828 *is_bitfield_ptr = is_bitfield;
5829
5830 return ivar_qual_type.getAsOpaquePtr();
5831 }
5832 }
5833 }
5834 }
5835 return nullptr;
5836}
5837
5838CompilerType ClangASTContext::GetFieldAtIndex(lldb::opaque_compiler_type_t type,
5839 size_t idx, std::string &name,
5840 uint64_t *bit_offset_ptr,
5841 uint32_t *bitfield_bit_size_ptr,
5842 bool *is_bitfield_ptr) {
5843 if (!type)
5844 return CompilerType();
5845
5846 clang::QualType qual_type(GetCanonicalQualType(type));
5847 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5848 switch (type_class) {
5849 case clang::Type::Record:
5850 if (GetCompleteType(type)) {
5851 const clang::RecordType *record_type =
5852 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
5853 const clang::RecordDecl *record_decl = record_type->getDecl();
5854 uint32_t field_idx = 0;
5855 clang::RecordDecl::field_iterator field, field_end;
5856 for (field = record_decl->field_begin(),
5857 field_end = record_decl->field_end();
5858 field != field_end; ++field, ++field_idx) {
5859 if (idx == field_idx) {
5860 // Print the member type if requested
5861 // Print the member name and equal sign
5862 name.assign(field->getNameAsString());
5863
5864 // Figure out the type byte size (field_type_info.first) and
5865 // alignment (field_type_info.second) from the AST context.
5866 if (bit_offset_ptr) {
5867 const clang::ASTRecordLayout &record_layout =
5868 getASTContext()->getASTRecordLayout(record_decl);
5869 *bit_offset_ptr = record_layout.getFieldOffset(field_idx);
5870 }
5871
5872 const bool is_bitfield = field->isBitField();
5873
5874 if (bitfield_bit_size_ptr) {
5875 *bitfield_bit_size_ptr = 0;
5876
5877 if (is_bitfield) {
5878 clang::Expr *bitfield_bit_size_expr = field->getBitWidth();
5879 llvm::APSInt bitfield_apsint;
5880 if (bitfield_bit_size_expr &&
5881 bitfield_bit_size_expr->EvaluateAsInt(bitfield_apsint,
5882 *getASTContext())) {
5883 *bitfield_bit_size_ptr = bitfield_apsint.getLimitedValue();
5884 }
5885 }
5886 }
5887 if (is_bitfield_ptr)
5888 *is_bitfield_ptr = is_bitfield;
5889
5890 return CompilerType(getASTContext(), field->getType());
5891 }
5892 }
5893 }
5894 break;
5895
5896 case clang::Type::ObjCObjectPointer: {
5897 const clang::ObjCObjectPointerType *objc_class_type =
5898 qual_type->getAs<clang::ObjCObjectPointerType>();
5899 const clang::ObjCInterfaceType *objc_interface_type =
5900 objc_class_type->getInterfaceType();
5901 if (objc_interface_type &&
5902 GetCompleteType(static_cast<lldb::opaque_compiler_type_t>(
5903 const_cast<clang::ObjCInterfaceType *>(objc_interface_type)))) {
5904 clang::ObjCInterfaceDecl *class_interface_decl =
5905 objc_interface_type->getDecl();
5906 if (class_interface_decl) {
5907 return CompilerType(
5908 this, GetObjCFieldAtIndex(getASTContext(), class_interface_decl,
5909 idx, name, bit_offset_ptr,
5910 bitfield_bit_size_ptr, is_bitfield_ptr));
5911 }
5912 }
5913 break;
5914 }
5915
5916 case clang::Type::ObjCObject:
5917 case clang::Type::ObjCInterface:
5918 if (GetCompleteType(type)) {
5919 const clang::ObjCObjectType *objc_class_type =
5920 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
5921 assert(objc_class_type)((objc_class_type) ? static_cast<void> (0) : __assert_fail
("objc_class_type", "/build/llvm-toolchain-snapshot-8~svn345461/tools/lldb/source/Symbol/ClangASTContext.cpp"
, 5921, __PRETTY_FUNCTION__))
;
5922 if (objc_class_type) {
5923 clang::ObjCInterfaceDecl *class_interface_decl =
5924 objc_class_type->getInterface();
5925 return CompilerType(
5926 this, GetObjCFieldAtIndex(getASTContext(), class_interface_decl,
5927 idx, name, bit_offset_ptr,
5928 bitfield_bit_size_ptr, is_bitfield_ptr));
5929 }
5930 }
5931 break;
5932
5933 case clang::Type::Typedef:
5934 return CompilerType(getASTContext(),
5935 llvm::cast<clang::TypedefType>(qual_type)
5936 ->getDecl()
5937 ->getUnderlyingType())
5938 .GetFieldAtIndex(idx, name, bit_offset_ptr, bitfield_bit_size_ptr,
5939 is_bitfield_ptr);
5940
5941 case clang::Type::Auto:
5942 return CompilerType(
5943 getASTContext(),
5944 llvm::cast<clang::AutoType>(qual_type)->getDeducedType())
5945 .GetFieldAtIndex(idx, name, bit_offset_ptr, bitfield_bit_size_ptr,
5946 is_bitfield_ptr);
5947
5948 case clang::Type::Elaborated:
5949 return CompilerType(
5950 getASTContext(),
5951 llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType())
5952 .GetFieldAtIndex(idx, name, bit_offset_ptr, bitfield_bit_size_ptr,
5953 is_bitfield_ptr);
5954
5955 case clang::Type::Paren:
5956 return CompilerType(getASTContext(),
5957 llvm::cast<clang::ParenType>(qual_type)->desugar())
5958 .GetFieldAtIndex(idx, name, bit_offset_ptr, bitfield_bit_size_ptr,
5959 is_bitfield_ptr);
5960
5961 default:
5962 break;
5963 }
5964 return CompilerType();
5965}
5966
5967uint32_t
5968ClangASTContext::GetNumDirectBaseClasses(lldb::opaque_compiler_type_t type) {
5969 uint32_t count = 0;
5970 clang::QualType qual_type(GetCanonicalQualType(type));
5971 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5972 switch (type_class) {
5973 case clang::Type::Record:
5974 if (GetCompleteType(type)) {
5975 const clang::CXXRecordDecl *cxx_record_decl =
5976 qual_type->getAsCXXRecordDecl();
5977 if (cxx_record_decl)
5978 count = cxx_record_decl->getNumBases();
5979 }
5980 break;
5981
5982 case clang::Type::ObjCObjectPointer:
5983 count = GetPointeeType(type).GetNumDirectBaseClasses();
5984 break;
5985
5986 case clang::Type::ObjCObject:
5987 if (GetCompleteType(type)) {
5988 const clang::ObjCObjectType *objc_class_type =
5989 qual_type->getAsObjCQualifiedInterfaceType();
5990 if (objc_class_type) {
5991 clang::ObjCInterfaceDecl *class_interface_decl =
5992 objc_class_type->getInterface();
5993
5994 if (class_interface_decl && class_interface_decl->getSuperClass())
5995 count = 1;
5996 }
5997 }
5998 break;
5999 case clang::Type::ObjCInterface:
6000 if (GetCompleteType(type)) {
6001 const clang::ObjCInterfaceType *objc_interface_type =
6002 qual_type->getAs<clang::ObjCInterfaceType>();
6003 if (objc_interface_type) {
6004 clang::ObjCInterfaceDecl *class_interface_decl =
6005 objc_interface_type->getInterface();
6006
6007 if (class_interface_decl && class_interface_decl->getSuperClass())
6008 count = 1;
6009 }
6010 }
6011 break;
6012
6013 case clang::Type::Typedef:
6014 count = GetNumDirectBaseClasses(llvm::cast<clang::TypedefType>(qual_type)
6015 ->getDecl()
6016 ->getUnderlyingType()
6017 .getAsOpaquePtr());
6018 break;
6019
6020 case clang::Type::Auto:
6021 count = GetNumDirectBaseClasses(llvm::cast<clang::AutoType>(qual_type)
6022 ->getDeducedType()
6023 .getAsOpaquePtr());
6024 break;
6025
6026 case clang::Type::Elaborated:
6027 count = GetNumDirectBaseClasses(llvm::cast<clang::ElaboratedType>(qual_type)
6028 ->getNamedType()
6029 .getAsOpaquePtr());
6030 break;
6031
6032 case clang::Type::Paren:
6033 return GetNumDirectBaseClasses(
6034 llvm::cast<clang::ParenType>(qual_type)->desugar().getAsOpaquePtr());
6035
6036 default:
6037 break;
6038 }
6039 return count;
6040}
6041
6042uint32_t
6043ClangASTContext::GetNumVirtualBaseClasses(lldb::opaque_compiler_type_t type) {
6044 uint32_t count = 0;
6045 clang::QualType qual_type(GetCanonicalQualType(type));
6046 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
6047 switch (type_class) {
6048 case clang::Type::Record:
6049 if (GetCompleteType(type)) {
6050 const clang::CXXRecordDecl *cxx_record_decl =
6051 qual_type->getAsCXXRecordDecl();
6052 if (cxx_record_decl)
6053 count = cxx_record_decl->getNumVBases();
6054 }
6055 break;
6056
6057 case clang::Type::Typedef:
6058 count = GetNumVirtualBaseClasses(llvm::cast<clang::TypedefType>(qual_type)
6059 ->getDecl()
6060 ->getUnderlyingType()
6061 .getAsOpaquePtr());
6062 break;
6063
6064 case clang::Type::Auto:
6065 count = GetNumVirtualBaseClasses(llvm::cast<clang::AutoType>(qual_type)
6066 ->getDeducedType()
6067 .getAsOpaquePtr());
6068 break;
6069
6070 case clang::Type::Elaborated:
6071 count =
6072 GetNumVirtualBaseClasses(llvm::cast<clang::ElaboratedType>(qual_type)
6073 ->getNamedType()
6074 .getAsOpaquePtr());
6075 break;
6076
6077 case clang::Type::Paren:
6078 count = GetNumVirtualBaseClasses(
6079 llvm::cast<clang::ParenType>(qual_type)->desugar().getAsOpaquePtr());
6080 break;
6081
6082 default:
6083 break;
6084 }
6085 return count;
6086}
6087
6088CompilerType ClangASTContext::GetDirectBaseClassAtIndex(
6089 lldb::opaque_compiler_type_t type, size_t idx, uint32_t *bit_offset_ptr) {
6090 clang::QualType qual_type(GetCanonicalQualType(type));
6091 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
6092 switch (type_class) {
6093 case clang::Type::Record:
6094 if (GetCompleteType(type)) {
6095 const clang::CXXRecordDecl *cxx_record_decl =
6096 qual_type->getAsCXXRecordDecl();
6097 if (cxx_record_decl) {
6098 uint32_t curr_idx = 0;
6099 clang::CXXRecordDecl::base_class_const_iterator base_class,
6100 base_class_end;
6101 for (base_class = cxx_record_decl->bases_begin(),
6102 base_class_end = cxx_record_decl->bases_end();
6103 base_class != base_class_end; ++base_class, ++curr_idx) {
6104 if (curr_idx == idx) {
6105 if (bit_offset_ptr) {
6106 const clang::ASTRecordLayout &record_layout =
6107 getASTContext()->getASTRecordLayout(cxx_record_decl);
6108 const clang::CXXRecordDecl *base_class_decl =
6109 llvm::cast<clang::CXXRecordDecl>(
6110 base_class->getType()
6111 ->getAs<clang::RecordType>()
6112 ->getDecl());
6113 if (base_class->isVirtual())
6114 *bit_offset_ptr =
6115 record_layout.getVBaseClassOffset(base_class_decl)
6116 .getQuantity() *
6117 8;
6118 else
6119 *bit_offset_ptr =
6120 record_layout.getBaseClassOffset(base_class_decl)
6121 .getQuantity() *
6122 8;
6123 }
6124 return CompilerType(this, base_class->getType().getAsOpaquePtr());
6125 }
6126 }
6127 }
6128 }
6129 break;
6130
6131 case clang::Type::ObjCObjectPointer:
6132 return GetPointeeType(type).GetDirectBaseClassAtIndex(idx, bit_offset_ptr);
6133
6134 case clang::Type::ObjCObject:
6135 if (idx == 0 && GetCompleteType(type)) {
6136 const clang::ObjCObjectType *objc_class_type =
6137 qual_type->getAsObjCQualifiedInterfaceType();
6138 if (objc_class_type) {
6139 clang::ObjCInterfaceDecl *class_interface_decl =
6140 objc_class_type->getInterface();
6141
6142 if (class_interface_decl) {
6143 clang::ObjCInterfaceDecl *superclass_interface_decl =
6144 class_interface_decl->getSuperClass();
6145 if (superclass_interface_decl) {
6146 if (bit_offset_ptr)
6147 *bit_offset_ptr = 0;
6148 return CompilerType(getASTContext(),
6149 getASTContext()->getObjCInterfaceType(
6150 superclass_interface_decl));
6151 }
6152 }
6153 }
6154 }
6155 break;
6156 case clang::Type::ObjCInterface:
6157 if (idx == 0 && GetCompleteType(type)) {
6158 const clang::ObjCObjectType *objc_interface_type =
6159 qual_type->getAs<clang::ObjCInterfaceType>();
6160 if (objc_interface_type) {
6161 clang::ObjCInterfaceDecl *class_interface_decl =
6162 objc_interface_type->getInterface();
6163
6164 if (class_interface_decl) {
6165 clang::ObjCInterfaceDecl *superclass_interface_decl =
6166 class_interface_decl->getSuperClass();
6167 if (superclass_interface_decl) {
6168 if (bit_offset_ptr)
6169 *bit_offset_ptr = 0;
6170 return CompilerType(getASTContext(),
6171 getASTContext()->getObjCInterfaceType(
6172 superclass_interface_decl));
6173 }
6174 }
6175 }
6176 }
6177 break;
6178
6179 case clang::Type::Typedef:
6180 return GetDirectBaseClassAtIndex(llvm::cast<clang::TypedefType>(qual_type)
6181 ->getDecl()
6182 ->getUnderlyingType()
6183 .getAsOpaquePtr(),
6184 idx, bit_offset_ptr);
6185
6186 case clang::Type::Auto:
6187 return GetDirectBaseClassAtIndex(llvm::cast<clang::AutoType>(qual_type)
6188 ->getDeducedType()
6189 .getAsOpaquePtr(),
6190 idx, bit_offset_ptr);
6191
6192 case clang::Type::Elaborated:
6193 return GetDirectBaseClassAtIndex(
6194 llvm::cast<clang::ElaboratedType>(qual_type)
6195 ->getNamedType()
6196 .getAsOpaquePtr(),
6197 idx, bit_offset_ptr);
6198
6199 case clang::Type::Paren:
6200 return GetDirectBaseClassAtIndex(
6201 llvm::cast<clang::ParenType>(qual_type)->desugar().getAsOpaquePtr(),
6202 idx, bit_offset_ptr);
6203
6204 default:
6205 break;
6206 }
6207 return CompilerType();
6208}
6209
6210CompilerType ClangASTContext::GetVirtualBaseClassAtIndex(
6211 lldb::opaque_compiler_type_t type, size_t idx, uint32_t *bit_offset_ptr) {
6212 clang::QualType qual_type(GetCanonicalQualType(type));
6213 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
6214 switch (type_class) {
6215 case clang::Type::Record:
6216 if (GetCompleteType(type)) {
6217 const clang::CXXRecordDecl *cxx_record_decl =
6218 qual_type->getAsCXXRecordDecl();
6219 if (cxx_record_decl) {
6220 uint32_t curr_idx = 0;
6221 clang::CXXRecordDecl::base_class_const_iterator base_class,
6222 base_class_end;
6223 for (base_class = cxx_record_decl->vbases_begin(),
6224 base_class_end = cxx_record_decl->vbases_end();
6225 base_class != base_class_end; ++base_class, ++curr_idx) {
6226 if (curr_idx == idx) {
6227 if (bit_offset_ptr) {
6228 const clang::ASTRecordLayout &record_layout =
6229 getASTContext()->getASTRecordLayout(cxx_record_decl);
6230 const clang::CXXRecordDecl *base_class_decl =
6231 llvm::cast<clang::CXXRecordDecl>(
6232 base_class->getType()
6233 ->getAs<clang::RecordType>()
6234 ->getDecl());
6235 *bit_offset_ptr =
6236 record_layout.getVBaseClassOffset(base_class_decl)
6237 .getQuantity() *
6238 8;
6239 }
6240 return CompilerType(this, base_class->getType().getAsOpaquePtr());
6241 }
6242 }
6243 }
6244 }
6245 break;
6246
6247 case clang::Type::Typedef:
6248 return GetVirtualBaseClassAtIndex(llvm::cast<clang::TypedefType>(qual_type)
6249 ->getDecl()
6250 ->getUnderlyingType()
6251 .getAsOpaquePtr(),
6252 idx, bit_offset_ptr);
6253
6254 case clang::Type::Auto:
6255 return GetVirtualBaseClassAtIndex(llvm::cast<clang::AutoType>(qual_type)
6256 ->getDeducedType()
6257 .getAsOpaquePtr(),
6258 idx, bit_offset_ptr);
6259
6260 case clang::Type::Elaborated:
6261 return GetVirtualBaseClassAtIndex(
6262 llvm::cast<clang::ElaboratedType>(qual_type)
6263 ->getNamedType()
6264 .getAsOpaquePtr(),
6265 idx, bit_offset_ptr);
6266
6267 case clang::Type::Paren:
6268 return GetVirtualBaseClassAtIndex(
6269 llvm::cast<clang::ParenType>(qual_type)->desugar().getAsOpaquePtr(),
6270 idx, bit_offset_ptr);
6271
6272 default:
6273 break;
6274 }
6275 return CompilerType();
6276}
6277
6278// If a pointer to a pointee type (the clang_type arg) says that it has no
6279// children, then we either need to trust it, or override it and return a
6280// different result. For example, an "int *" has one child that is an integer,
6281// but a function pointer doesn't have any children. Likewise if a Record type
6282// claims it has no children, then there really is nothing to show.
6283uint32_t ClangASTContext::GetNumPointeeChildren(clang::QualType type) {
6284 if (type.isNull())
6285 return 0;
6286
6287 clang::QualType qual_type(type.getCanonicalType());
6288 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
6289 switch (type_class) {
6290 case clang::Type::Builtin:
6291 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
6292 case clang::BuiltinType::UnknownAny:
6293 case clang::BuiltinType::Void:
6294 case clang::BuiltinType::NullPtr:
6295 case clang::BuiltinType::OCLEvent:
6296 case clang::BuiltinType::OCLImage1dRO:
6297 case clang::BuiltinType::OCLImage1dWO:
6298 case clang::BuiltinType::OCLImage1dRW:
6299 case clang::BuiltinType::OCLImage1dArrayRO:
6300 case clang::BuiltinType::OCLImage1dArrayWO:
6301 case clang::BuiltinType::OCLImage1dArrayRW:
6302 case clang::BuiltinType::OCLImage1dBufferRO:
6303 case clang::BuiltinType::OCLImage1dBufferWO:
6304 case clang::BuiltinType::OCLImage1dBufferRW:
6305 case clang::BuiltinType::OCLImage2dRO:
6306 case clang::BuiltinType::OCLImage2dWO:
6307 case clang::BuiltinType::OCLImage2dRW:
6308 case clang::BuiltinType::OCLImage2dArrayRO:
6309 case clang::BuiltinType::OCLImage2dArrayWO:
6310 case clang::BuiltinType::OCLImage2dArrayRW:
6311 case clang::BuiltinType::OCLImage3dRO:
6312 case clang::BuiltinType::OCLImage3dWO:
6313 case clang::BuiltinType::OCLImage3dRW:
6314 case clang::BuiltinType::OCLSampler:
6315 return 0;
6316 case clang::BuiltinType::Bool:
6317 case clang::BuiltinType::Char_U:
6318 case clang::BuiltinType::UChar:
6319 case clang::BuiltinType::WChar_U:
6320 case clang::BuiltinType::Char16:
6321 case clang::BuiltinType::Char32:
6322 case clang::BuiltinType::UShort:
6323 case clang::BuiltinType::UInt:
6324 case clang::BuiltinType::ULong:
6325 case clang::BuiltinType::ULongLong:
6326 case clang::BuiltinType::UInt128:
6327 case clang::BuiltinType::Char_S:
6328 case clang::BuiltinType::SChar:
6329 case clang::BuiltinType::WChar_S:
6330 case clang::BuiltinType::Short:
6331 case clang::BuiltinType::Int:
6332 case clang::BuiltinType::Long:
6333 case clang::BuiltinType::LongLong:
6334 case clang::BuiltinType::Int128:
6335 case clang::BuiltinType::Float:
6336 case clang::BuiltinType::Double:
6337 case clang::BuiltinType::LongDouble:
6338 case clang::BuiltinType::Dependent:
6339 case clang::BuiltinType::Overload:
6340 case clang::BuiltinType::ObjCId:
6341 case clang::BuiltinType::ObjCClass:
6342 case clang::BuiltinType::ObjCSel:
6343 case clang::BuiltinType::BoundMember:
6344 case clang::BuiltinType::Half:
6345 case clang::BuiltinType::ARCUnbridgedCast:
6346 case clang::BuiltinType::PseudoObject:
6347 case clang::BuiltinType::BuiltinFn:
6348 case clang::BuiltinType::OMPArraySection:
6349 return 1;
6350 default:
6351 return 0;
6352 }
6353 break;
6354
6355 case clang::Type::Complex:
6356 return 1;
6357 case clang::Type::Pointer:
6358 return 1;
6359 case clang::Type::BlockPointer:
6360 return 0; // If block pointers don't have debug info, then no children for
6361 // them
6362 case clang::Type::LValueReference:
6363 return 1;
6364 case clang::Type::RValueReference:
6365 return 1;
6366 case clang::Type::MemberPointer:
6367 return 0;
6368 case clang::Type::ConstantArray:
6369 return 0;
6370 case clang::Type::IncompleteArray:
6371 return 0;
6372 case clang::Type::VariableArray:
6373 return 0;
6374 case clang::Type::DependentSizedArray:
6375 return 0;
6376 case clang::Type::DependentSizedExtVector:
6377 return 0;
6378 case clang::Type::Vector:
6379 return 0;
6380 case clang::Type::ExtVector:
6381 return 0;
6382 case clang::Type::FunctionProto:
6383 return 0; // When we function pointers, they have no children...
6384 case clang::Type::FunctionNoProto:
6385 return 0; // When we function pointers, they have no children...
6386 case clang::Type::UnresolvedUsing:
6387 return 0;
6388 case clang::Type::Paren:
6389 return GetNumPointeeChildren(
6390 llvm::cast<clang::ParenType>(qual_type)->desugar());
6391 case clang::Type::Typedef:
6392 return GetNumPointeeChildren(llvm::cast<clang::TypedefType>(qual_type)
6393 ->getDecl()
6394 ->getUnderlyingType());
6395 case clang::Type::Auto:
6396 return GetNumPointeeChildren(
6397 llvm::cast<clang::AutoType>(qual_type)->getDeducedType());
6398 case clang::Type::Elaborated:
6399 return GetNumPointeeChildren(
6400 llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType());
6401 case clang::Type::TypeOfExpr:
6402 return GetNumPointeeChildren(llvm::cast<clang::TypeOfExprType>(qual_type)
6403 ->getUnderlyingExpr()
6404 ->getType());
6405 case clang::Type::TypeOf:
6406 return GetNumPointeeChildren(
6407 llvm::cast<clang::TypeOfType>(qual_type)->getUnderlyingType());
6408 case clang::Type::Decltype:
6409 return GetNumPointeeChildren(
6410 llvm::cast<clang::DecltypeType>(qual_type)->getUnderlyingType());
6411 case clang::Type::Record:
6412 return 0;
6413 case clang::Type::Enum:
6414 return 1;
6415 case clang::Type::TemplateTypeParm:
6416 return 1;
6417 case clang::Type::SubstTemplateTypeParm:
6418 return 1;
6419 case clang::Type::TemplateSpecialization:
6420 return 1;
6421 case clang::Type::InjectedClassName:
6422 return 0;
6423 case clang::Type::DependentName:
6424 return 1;
6425 case clang::Type::DependentTemplateSpecialization:
6426 return 1;
6427 case clang::Type::ObjCObject:
6428 return 0;
6429 case clang::Type::ObjCInterface:
6430 return 0;
6431 case clang::Type::ObjCObjectPointer:
6432 return 1;
6433 default:
6434 break;
6435 }
6436 return 0;
6437}
6438
6439CompilerType ClangASTContext::GetChildCompilerTypeAtIndex(
6440 lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, size_t idx,
6441 bool transparent_pointers, bool omit_empty_base_classes,
6442 bool ignore_array_bounds, std::string &child_name,
6443 uint32_t &child_byte_size, int32_t &child_byte_offset,
6444 uint32_t &child_bitfield_bit_size, uint32_t &child_bitfield_bit_offset,
6445 bool &child_is_base_class, bool &child_is_deref_of_parent,
6446 ValueObject *valobj, uint64_t &language_flags) {
6447 if (!type)
6448 return CompilerType();
6449
6450 clang::QualType parent_qual_type(GetCanonicalQualType(type));
6451 const clang::Type::TypeClass parent_type_class =
6452 parent_qual_type->getTypeClass();
6453 child_bitfield_bit_size = 0;
6454 child_bitfield_bit_offset = 0;
6455 child_is_base_class = false;
6456 language_flags = 0;
6457
6458 const bool idx_is_valid = idx < GetNumChildren(type, omit_empty_base_classes);
6459 int32_t bit_offset;
6460 switch (parent_type_class) {
6461 case clang::Type::Builtin:
6462 if (idx_is_valid) {
6463 switch (llvm::cast<clang::BuiltinType>(parent_qual_type)->getKind()) {
6464 case clang::BuiltinType::ObjCId:
6465 case clang::BuiltinType::ObjCClass:
6466 child_name = "isa";
6467 child_byte_size =
6468 getASTContext()->getTypeSize(getASTContext()->ObjCBuiltinClassTy) /
6469 CHAR_BIT8;
6470 return CompilerType(getASTContext(),
6471 getASTContext()->ObjCBuiltinClassTy);
6472
6473 default:
6474 break;
6475 }
6476 }
6477 break;
6478
6479 case clang::Type::Record:
6480 if (idx_is_valid && GetCompleteType(type)) {
6481 const clang::RecordType *record_type =
6482 llvm::cast<clang::RecordType>(parent_qual_type.getTypePtr());
6483 const clang::RecordDecl *record_decl = record_type->getDecl();
6484 assert(record_decl)((record_decl) ? static_cast<void> (0) : __assert_fail (
"record_decl", "/build/llvm-toolchain-snapshot-8~svn345461/tools/lldb/source/Symbol/ClangASTContext.cpp"
, 6484, __PRETTY_FUNCTION__))
;
6485 const clang::ASTRecordLayout &record_layout =
6486 getASTContext()->getASTRecordLayout(record_decl);
6487 uint32_t child_idx = 0;
6488
6489 const clang::CXXRecordDecl *cxx_record_decl =
6490 llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
6491 if (cxx_record_decl) {
6492 // We might have base classes to print out first
6493 clang::CXXRecordDecl::base_class_const_iterator base_class,
6494 base_class_end;
6495 for (base_class = cxx_record_decl->bases_begin(),
6496 base_class_end = cxx_record_decl->bases_end();
6497 base_class != base_class_end; ++base_class) {
6498 const clang::CXXRecordDecl *base_class_decl = nullptr;
6499
6500 // Skip empty base classes
6501 if (omit_empty_base_classes) {
6502 base_class_decl = llvm::cast<clang::CXXRecordDecl>(
6503 base_class->getType()->getAs<clang::RecordType>()->getDecl());
6504 if (ClangASTContext::RecordHasFields(base_class_decl) == false)
6505 continue;
6506 }
6507
6508 if (idx == child_idx) {
6509 if (base_class_decl == nullptr)
6510 base_class_decl = llvm::cast<clang::CXXRecordDecl>(
6511 base_class->getType()->getAs<clang::RecordType>()->getDecl());
6512
6513 if (base_class->isVirtual()) {
6514 bool handled = false;
6515 if (valobj) {
6516 Status err;
6517 AddressType addr_type = eAddressTypeInvalid;
6518 lldb::addr_t vtable_ptr_addr =
6519 valobj->GetCPPVTableAddress(addr_type);
6520
6521 if (vtable_ptr_addr != LLDB_INVALID_ADDRESS(18446744073709551615UL) &&
6522 addr_type == eAddressTypeLoad) {
6523
6524 ExecutionContext exe_ctx(valobj->GetExecutionContextRef());
6525 Process *process = exe_ctx.GetProcessPtr();
6526 if (process) {
6527 clang::VTableContextBase *vtable_ctx =
6528 getASTContext()->getVTableContext();
6529 if (vtable_ctx) {
6530 if (vtable_ctx->isMicrosoft()) {
6531 clang::MicrosoftVTableContext *msoft_vtable_ctx =
6532 static_cast<clang::MicrosoftVTableContext *>(
6533 vtable_ctx);
6534
6535 if (vtable_ptr_addr) {
6536 const lldb::addr_t vbtable_ptr_addr =
6537 vtable_ptr_addr +
6538 record_layout.getVBPtrOffset().getQuantity();
6539
6540 const lldb::addr_t vbtable_ptr =
6541 process->ReadPointerFromMemory(vbtable_ptr_addr,
6542 err);
6543 if (vbtable_ptr != LLDB_INVALID_ADDRESS(18446744073709551615UL)) {
6544 // Get the index into the virtual base table. The
6545 // index is the index in uint32_t from vbtable_ptr
6546 const unsigned vbtable_index =
6547 msoft_vtable_ctx->getVBTableIndex(
6548 cxx_record_decl, base_class_decl);
6549 const lldb::addr_t base_offset_addr =
6550 vbtable_ptr + vbtable_index * 4;
6551 const int32_t base_offset =
6552 process->ReadSignedIntegerFromMemory(
6553 base_offset_addr, 4, INT32_MAX(2147483647), err);
6554 if (base_offset != INT32_MAX(2147483647)) {
6555 handled = true;
6556 bit_offset = base_offset * 8;
6557 }
6558 }
6559 }
6560 } else {
6561 clang::ItaniumVTableContext *itanium_vtable_ctx =
6562 static_cast<clang::ItaniumVTableContext *>(
6563 vtable_ctx);
6564 if (vtable_ptr_addr) {
6565 const lldb::addr_t vtable_ptr =
6566 process->ReadPointerFromMemory(vtable_ptr_addr,
6567 err);
6568 if (vtable_ptr != LLDB_INVALID_ADDRESS(18446744073709551615UL)) {
6569 clang::CharUnits base_offset_offset =
6570 itanium_vtable_ctx->getVirtualBaseOffsetOffset(
6571 cxx_record_decl, base_class_decl);
6572 const lldb::addr_t base_offset_addr =
6573 vtable_ptr + base_offset_offset.getQuantity();
6574 const uint32_t base_offset_size =
6575 process->GetAddressByteSize();
6576 const int64_t base_offset =
6577 process->ReadSignedIntegerFromMemory(
6578 base_offset_addr, base_offset_size,
6579 UINT32_MAX(4294967295U), err);
6580 if (base_offset < UINT32_MAX(4294967295U)) {
6581 handled = true;
6582 bit_offset = base_offset * 8;
6583 }
6584 }
6585 }
6586 }
6587 }
6588 }
6589 }
6590 }
6591 if (!handled)
6592 bit_offset = record_layout.getVBaseClassOffset(base_class_decl)
6593 .getQuantity() *
6594 8;
6595 } else
6596 bit_offset = record_layout.getBaseClassOffset(base_class_decl)
6597 .getQuantity() *
6598 8;
6599
6600 // Base classes should be a multiple of 8 bits in size
6601 child_byte_offset = bit_offset / 8;
6602 CompilerType base_class_clang_type(getASTContext(),
6603 base_class->getType());
6604 child_name = base_class_clang_type.GetTypeName().AsCString("");
6605 uint64_t base_class_clang_type_bit_size =
6606 base_class_clang_type.GetBitSize(
6607 exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL__null);
6608
6609 // Base classes bit sizes should be a multiple of 8 bits in size
6610 assert(base_class_clang_type_bit_size % 8 == 0)((base_class_clang_type_bit_size % 8 == 0) ? static_cast<void
> (0) : __assert_fail ("base_class_clang_type_bit_size % 8 == 0"
, "/build/llvm-toolchain-snapshot-8~svn345461/tools/lldb/source/Symbol/ClangASTContext.cpp"
, 6610, __PRETTY_FUNCTION__))
;
6611 child_byte_size = base_class_clang_type_bit_size / 8;
6612 child_is_base_class = true;
6613 return base_class_clang_type;
6614 }
6615 // We don't increment the child index in the for loop since we might
6616 // be skipping empty base classes
6617 ++child_idx;
6618 }
6619 }
6620 // Make sure index is in range...
6621 uint32_t field_idx = 0;
6622 clang::RecordDecl::field_iterator field, field_end;
6623 for (field = record_decl->field_begin(),
6624 field_end = record_decl->field_end();
6625 field != field_end; ++field, ++field_idx, ++child_idx) {
6626 if (idx == child_idx) {
6627 // Print the member type if requested
6628 // Print the member name and equal sign
6629 child_name.assign(field->getNameAsString());
6630
6631 // Figure out the type byte size (field_type_info.first) and
6632 // alignment (field_type_info.second) from the AST context.
6633 CompilerType field_clang_type(getASTContext(), field->getType());
6634 assert(field_idx < record_layout.getFieldCount())((field_idx < record_layout.getFieldCount()) ? static_cast
<void> (0) : __assert_fail ("field_idx < record_layout.getFieldCount()"
, "/build/llvm-toolchain-snapshot-8~svn345461/tools/lldb/source/Symbol/ClangASTContext.cpp"
, 6634, __PRETTY_FUNCTION__))
;
6635 child_byte_size = field_clang_type.GetByteSize(
6636 exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL__null);
6637 const uint32_t child_bit_size = child_byte_size * 8;
6638
6639 // Figure out the field offset within the current struct/union/class
6640 // type
6641 bit_offset = record_layout.getFieldOffset(field_idx);
6642 if (ClangASTContext::FieldIsBitfield(getASTContext(), *field,
6643 child_bitfield_bit_size)) {
6644 child_bitfield_bit_offset = bit_offset % child_bit_size;
6645 const uint32_t child_bit_offset =
6646 bit_offset - child_bitfield_bit_offset;
6647 child_byte_offset = child_bit_offset / 8;
6648 } else {
6649 child_byte_offset = bit_offset / 8;
6650 }
6651
6652 return field_clang_type;
6653 }
6654 }
6655 }
6656 break;
6657
6658 case clang::Type::ObjCObject:
6659 case clang::Type::ObjCInterface:
6660 if (idx_is_valid && GetCompleteType(type)) {
6661 const clang::ObjCObjectType *objc_class_type =
6662 llvm::dyn_cast<clang::ObjCObjectType>(parent_qual_type.getTypePtr());
6663 assert(objc_class_type)((objc_class_type) ? static_cast<void> (0) : __assert_fail
("objc_class_type", "/build/llvm-toolchain-snapshot-8~svn345461/tools/lldb/source/Symbol/ClangASTContext.cpp"
, 6663, __PRETTY_FUNCTION__))
;
6664 if (objc_class_type) {
6665 uint32_t child_idx = 0;
6666 clang::ObjCInterfaceDecl *class_interface_decl =
6667 objc_class_type->getInterface();
6668
6669 if (class_interface_decl) {
6670
6671 const clang::ASTRecordLayout &interface_layout =
6672 getASTContext()->getASTObjCInterfaceLayout(class_interface_decl);
6673 clang::ObjCInterfaceDecl *superclass_interface_decl =
6674 class_interface_decl->getSuperClass();
6675 if (superclass_interface_decl) {
6676 if (omit_empty_base_classes) {
6677 CompilerType base_class_clang_type(
6678 getASTContext(), getASTContext()->getObjCInterfaceType(
6679 superclass_interface_decl));
6680 if (base_class_clang_type.GetNumChildren(
6681 omit_empty_base_classes) > 0) {
6682 if (idx == 0) {
6683 clang::QualType ivar_qual_type(
6684 getASTContext()->getObjCInterfaceType(
6685 superclass_interface_decl));
6686
6687 child_name.assign(
6688 superclass_interface_decl->getNameAsString());
6689
6690 clang::TypeInfo ivar_type_info =
6691 getASTContext()->getTypeInfo(ivar_qual_type.getTypePtr());
6692
6693 child_byte_size = ivar_type_info.Width / 8;
6694 child_byte_offset = 0;
6695 child_is_base_class = true;
6696
6697 return CompilerType(getASTContext(), ivar_qual_type);
6698 }
6699
6700 ++child_idx;
6701 }
6702 } else
6703 ++child_idx;
6704 }
6705
6706 const uint32_t superclass_idx = child_idx;
6707
6708 if (idx < (child_idx + class_interface_decl->ivar_size())) {
6709 clang::ObjCInterfaceDecl::ivar_iterator ivar_pos,
6710 ivar_end = class_interface_decl->ivar_end();
6711
6712 for (ivar_pos = class_interface_decl->ivar_begin();
6713 ivar_pos != ivar_end; ++ivar_pos) {
6714 if (child_idx == idx) {
6715 clang::ObjCIvarDecl *ivar_decl = *ivar_pos;
6716
6717 clang::QualType ivar_qual_type(ivar_decl->getType());
6718
6719 child_name.assign(ivar_decl->getNameAsString());
6720
6721 clang::TypeInfo ivar_type_info =
6722 getASTContext()->getTypeInfo(ivar_qual_type.getTypePtr());
6723
6724 child_byte_size = ivar_type_info.Width / 8;
6725
6726 // Figure out the field offset within the current
6727 // struct/union/class type For ObjC objects, we can't trust the
6728 // bit offset we get from the Clang AST, since that doesn't
6729 // account for the space taken up by unbacked properties, or
6730 // from the changing size of base classes that are newer than
6731 // this class. So if we have a process around that we can ask
6732 // about this object, do so.
6733 child_byte_offset = LLDB_INVALID_IVAR_OFFSET(4294967295U);
6734 Process *process = nullptr;
6735 if (exe_ctx)
6736 process = exe_ctx->GetProcessPtr();
6737 if (process) {
6738 ObjCLanguageRuntime *objc_runtime =
6739 process->GetObjCLanguageRuntime();
6740 if (objc_runtime != nullptr) {
6741 CompilerType parent_ast_type(getASTContext(),
6742 parent_qual_type);
6743 child_byte_offset = objc_runtime->GetByteOffsetForIvar(
6744 parent_ast_type, ivar_decl->getNameAsString().c_str());
6745 }
6746 }
6747
6748 // Setting this to INT32_MAX to make sure we don't compute it
6749 // twice...
6750 bit_offset = INT32_MAX(2147483647);
6751
6752 if (child_byte_offset ==
6753 static_cast<int32_t>(LLDB_INVALID_IVAR_OFFSET(4294967295U))) {
6754 bit_offset = interface_layout.getFieldOffset(child_idx -
6755 superclass_idx);
6756 child_byte_offset = bit_offset / 8;
6757 }
6758
6759 // Note, the ObjC Ivar Byte offset is just that, it doesn't
6760 // account for the bit offset of a bitfield within its
6761 // containing object. So regardless of where we get the byte
6762 // offset from, we still need to get the bit offset for
6763 // bitfields from the layout.
6764
6765 if (ClangASTContext::FieldIsBitfield(getASTContext(), ivar_decl,
6766 child_bitfield_bit_size)) {
6767 if (bit_offset == INT32_MAX(2147483647))
6768 bit_offset = interface_layout.getFieldOffset(
6769 child_idx - superclass_idx);
6770
6771 child_bitfield_bit_offset = bit_offset % 8;
6772 }
6773 return CompilerType(getASTContext(), ivar_qual_type);
6774 }
6775 ++child_idx;
6776 }
6777 }
6778 }
6779 }
6780 }
6781 break;
6782
6783 case clang::Type::ObjCObjectPointer:
6784 if (idx_is_valid) {
6785 CompilerType pointee_clang_type(GetPointeeType(type));
6786
6787 if (transparent_pointers && pointee_clang_type.IsAggregateType()) {
6788 child_is_deref_of_parent = false;
6789 bool tmp_child_is_deref_of_parent = false;
6790 return pointee_clang_type.GetChildCompilerTypeAtIndex(
6791 exe_ctx, idx, transparent_pointers, omit_empty_base_classes,
6792 ignore_array_bounds, child_name, child_byte_size, child_byte_offset,
6793 child_bitfield_bit_size, child_bitfield_bit_offset,
6794 child_is_base_class, tmp_child_is_deref_of_parent, valobj,
6795 language_flags);
6796 } else {
6797 child_is_deref_of_parent = true;
6798 const char *parent_name =
6799 valobj ? valobj->GetName().GetCString() : NULL__null;
6800 if (parent_name) {
6801 child_name.assign(1, '*');
6802 child_name += parent_name;
6803 }
6804
6805 // We have a pointer to an simple type
6806 if (idx == 0 && pointee_clang_type.GetCompleteType()) {
6807 child_byte_size = pointee_clang_type.GetByteSize(
6808 exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL__null);
6809 child_byte_offset = 0;
6810 return pointee_clang_type;
6811 }
6812 }
6813 }
6814 break;
6815
6816 case clang::Type::Vector:
6817 case clang::Type::ExtVector:
6818 if (idx_is_valid) {
6819 const clang::VectorType *array =
6820 llvm::cast<clang::VectorType>(parent_qual_type.getTypePtr());
6821 if (array) {
6822 CompilerType element_type(getASTContext(), array->getElementType());
6823 if (element_type.GetCompleteType()) {
6824 char element_name[64];
6825 ::snprintf(element_name, sizeof(element_name), "[%" PRIu64"l" "u" "]",
6826 static_cast<uint64_t>(idx));
6827 child_name.assign(element_name);
6828 child_byte_size = element_type.GetByteSize(
6829 exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL__null);
6830 child_byte_offset = (int32_t)idx * (int32_t)child_byte_size;
6831 return element_type;
6832 }
6833 }
6834 }
6835 break;
6836
6837 case clang::Type::ConstantArray:
6838 case clang::Type::IncompleteArray:
6839 if (ignore_array_bounds || idx_is_valid) {
6840 const clang::ArrayType *array = GetQualType(type)->getAsArrayTypeUnsafe();
6841 if (array) {
6842 CompilerType element_type(getASTContext(), array->getElementType());
6843 if (element_type.GetCompleteType()) {
6844 child_name = llvm::formatv("[{0}]", idx);
6845 child_byte_size = element_type.GetByteSize(
6846 exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL__null);
6847 child_byte_offset = (int32_t)idx * (int32_t)child_byte_size;
6848 return element_type;
6849 }
6850 }
6851 }
6852 break;
6853
6854 case clang::Type::Pointer: {
6855 CompilerType pointee_clang_type(GetPointeeType(type));
6856
6857 // Don't dereference "void *" pointers
6858 if (pointee_clang_type.IsVoidType())
6859 return CompilerType();
6860
6861 if (transparent_pointers && pointee_clang_type.IsAggregateType()) {
6862 child_is_deref_of_parent = false;
6863 bool tmp_child_is_deref_of_parent = false;
6864 return pointee_clang_type.GetChildCompilerTypeAtIndex(
6865 exe_ctx, idx, transparent_pointers, omit_empty_base_classes,
6866 ignore_array_bounds, child_name, child_byte_size, child_byte_offset,
6867 child_bitfield_bit_size, child_bitfield_bit_offset,
6868 child_is_base_class, tmp_child_is_deref_of_parent, valobj,
6869 language_flags);
6870 } else {
6871 child_is_deref_of_parent = true;
6872
6873 const char *parent_name =
6874 valobj ? valobj->GetName().GetCString() : NULL__null;
6875 if (parent_name) {
6876 child_name.assign(1, '*');
6877 child_name += parent_name;
6878 }
6879
6880 // We have a pointer to an simple type
6881 if (idx == 0) {
6882 child_byte_size = pointee_clang_type.GetByteSize(
6883 exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL__null);
6884 child_byte_offset = 0;
6885 return pointee_clang_type;
6886 }
6887 }
6888 break;
6889 }
6890
6891 case clang::Type::LValueReference:
6892 case clang::Type::RValueReference:
6893 if (idx_is_valid) {
6894 const clang::ReferenceType *reference_type =
6895 llvm::cast<clang::ReferenceType>(parent_qual_type.getTypePtr());
6896 CompilerType pointee_clang_type(getASTContext(),
6897 reference_type->getPointeeType());
6898 if (transparent_pointers && pointee_clang_type.IsAggregateType()) {
6899 child_is_deref_of_parent = false;
6900 bool tmp_child_is_deref_of_parent = false;
6901 return pointee_clang_type.GetChildCompilerTypeAtIndex(
6902 exe_ctx, idx, transparent_pointers, omit_empty_base_classes,
6903 ignore_array_bounds, child_name, child_byte_size, child_byte_offset,
6904 child_bitfield_bit_size, child_bitfield_bit_offset,
6905 child_is_base_class, tmp_child_is_deref_of_parent, valobj,
6906 language_flags);
6907 } else {
6908 const char *parent_name =
6909 valobj ? valobj->GetName().GetCString() : NULL__null;
6910 if (parent_name) {
6911 child_name.assign(1, '&');
6912 child_name += parent_name;
6913 }
6914
6915 // We have a pointer to an simple type
6916 if (idx == 0) {
6917 child_byte_size = pointee_clang_type.GetByteSize(
6918 exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL__null);
6919 child_byte_offset = 0;
6920 return pointee_clang_type;
6921 }
6922 }
6923 }
6924 break;
6925
6926 case clang::Type::Typedef: {
6927 CompilerType typedefed_clang_type(
6928 getASTContext(), llvm::cast<clang::TypedefType>(parent_qual_type)
6929 ->getDecl()
6930 ->getUnderlyingType());
6931 return typedefed_clang_type.GetChildCompilerTypeAtIndex(
6932 exe_ctx, idx, transparent_pointers, omit_empty_base_classes,
6933 ignore_array_bounds, child_name, child_byte_size, child_byte_offset,
6934 child_bitfield_bit_size, child_bitfield_bit_offset, child_is_base_class,
6935 child_is_deref_of_parent, valobj, language_flags);
6936 } break;
6937
6938 case clang::Type::Auto: {
6939 CompilerType elaborated_clang_type(
6940 getASTContext(),
6941 llvm::cast<clang::AutoType>(parent_qual_type)->getDeducedType());
6942 return elaborated_clang_type.GetChildCompilerTypeAtIndex(
6943 exe_ctx, idx, transparent_pointers, omit_empty_base_classes,
6944 ignore_array_bounds, child_name, child_byte_size, child_byte_offset,
6945 child_bitfield_bit_size, child_bitfield_bit_offset, child_is_base_class,
6946 child_is_deref_of_parent, valobj, language_flags);
6947 }
6948
6949 case clang::Type::Elaborated: {
6950 CompilerType elaborated_clang_type(
6951 getASTContext(),
6952 llvm::cast<clang::ElaboratedType>(parent_qual_type)->getNamedType());
6953 return elaborated_clang_type.GetChildCompilerTypeAtIndex(
6954 exe_ctx, idx, transparent_pointers, omit_empty_base_classes,
6955 ignore_array_bounds, child_name, child_byte_size, child_byte_offset,
6956 child_bitfield_bit_size, child_bitfield_bit_offset, child_is_base_class,
6957 child_is_deref_of_parent, valobj, language_flags);
6958 }
6959
6960 case clang::Type::Paren: {
6961 CompilerType paren_clang_type(
6962 getASTContext(),
6963 llvm::cast<clang::ParenType>(parent_qual_type)->desugar());
6964 return paren_clang_type.GetChildCompilerTypeAtIndex(
6965 exe_ctx, idx, transparent_pointers, omit_empty_base_classes,
6966 ignore_array_bounds, child_name, child_byte_size, child_byte_offset,
6967 child_bitfield_bit_size, child_bitfield_bit_offset, child_is_base_class,
6968 child_is_deref_of_parent, valobj, language_flags);
6969 }
6970
6971 default:
6972 break;
6973 }
6974 return CompilerType();
6975}
6976
6977static uint32_t GetIndexForRecordBase(const clang::RecordDecl *record_decl,
6978 const clang::CXXBaseSpecifier *base_spec,
6979 bool omit_empty_base_classes) {
6980 uint32_t child_idx = 0;
6981
6982 const clang::CXXRecordDecl *cxx_record_decl =
6983 llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
6984
6985 // const char *super_name = record_decl->getNameAsCString();
6986 // const char *base_name =
6987 // base_spec->getType()->getAs<clang::RecordType>()->getDecl()->getNameAsCString();
6988 // printf ("GetIndexForRecordChild (%s, %s)\n", super_name, base_name);
6989 //
6990 if (cxx_record_decl) {
6991 clang::CXXRecordDecl::base_class_const_iterator base_class, base_class_end;
6992 for (base_class = cxx_record_decl->bases_begin(),
6993 base_class_end = cxx_record_decl->bases_end();
6994 base_class != base_class_end; ++base_class) {
6995 if (omit_empty_base_classes) {
6996 if (BaseSpecifierIsEmpty(base_class))
6997 continue;
6998 }
6999
7000 // printf ("GetIndexForRecordChild (%s, %s) base[%u] = %s\n",
7001 // super_name, base_name,
7002 // child_idx,
7003 // base_class->getType()->getAs<clang::RecordType>()->getDecl()->getNameAsCString());
7004 //
7005 //
7006 if (base_class == base_spec)
7007 return child_idx;
7008 ++child_idx;
7009 }
7010 }
7011
7012 return UINT32_MAX(4294967295U);
7013}
7014
7015static uint32_t GetIndexForRecordChild(const clang::RecordDecl *record_decl,
7016 clang::NamedDecl *canonical_decl,
7017 bool omit_empty_base_classes) {
7018 uint32_t child_idx = ClangASTContext::GetNumBaseClasses(
7019 llvm::dyn_cast<clang::CXXRecordDecl>(record_decl),
7020 omit_empty_base_classes);
7021
7022 clang::RecordDecl::field_iterator field, field_end;
7023 for (field = record_decl->field_begin(), field_end = record_decl->field_end();
7024 field != field_end; ++field, ++child_idx) {
7025 if (field->getCanonicalDecl() == canonical_decl)
7026 return child_idx;
7027 }
7028
7029 return UINT32_MAX(4294967295U);
7030}
7031
7032// Look for a child member (doesn't include base classes, but it does include
7033// their members) in the type hierarchy. Returns an index path into
7034// "clang_type" on how to reach the appropriate member.
7035//
7036// class A
7037// {
7038// public:
7039// int m_a;
7040// int m_b;
7041// };
7042//
7043// class B
7044// {
7045// };
7046//
7047// class C :
7048// public B,
7049// public A
7050// {
7051// };
7052//
7053// If we have a clang type that describes "class C", and we wanted to looked
7054// "m_b" in it:
7055//
7056// With omit_empty_base_classes == false we would get an integer array back
7057// with: { 1, 1 } The first index 1 is the child index for "class A" within
7058// class C The second index 1 is the child index for "m_b" within class A
7059//
7060// With omit_empty_base_classes == true we would get an integer array back
7061// with: { 0, 1 } The first index 0 is the child index for "class A" within
7062// class C (since class B doesn't have any members it doesn't count) The second
7063// index 1 is the child index for "m_b" within class A
7064
7065size_t ClangASTContext::GetIndexOfChildMemberWithName(
7066 lldb::opaque_compiler_type_t type, const char *name,
7067 bool omit_empty_base_classes, std::vector<uint32_t> &child_indexes) {
7068 if (type && name && name[0]) {
7069 clang::QualType qual_type(GetCanonicalQualType(type));
7070 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
7071 switch (type_class) {
7072 case clang::Type::Record:
7073 if (GetCompleteType(type)) {
7074 const clang::RecordType *record_type =
7075 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
7076 const clang::RecordDecl *record_decl = record_type->getDecl();
7077
7078 assert(record_decl)((record_decl) ? static_cast<void> (0) : __assert_fail (
"record_decl", "/build/llvm-toolchain-snapshot-8~svn345461/tools/lldb/source/Symbol/ClangASTContext.cpp"
, 7078, __PRETTY_FUNCTION__))
;
7079 uint32_t child_idx = 0;
7080
7081 const clang::CXXRecordDecl *cxx_record_decl =
7082 llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
7083
7084 // Try and find a field that matches NAME
7085 clang::RecordDecl::field_iterator field, field_end;
7086 llvm::StringRef name_sref(name);
7087 for (field = record_decl->field_begin(),
7088 field_end = record_decl->field_end();
7089 field != field_end; ++field, ++child_idx) {
7090 llvm::StringRef field_name = field->getName();
7091 if (field_name.empty()) {
7092 CompilerType field_type(getASTContext(), field->getType());
7093 child_indexes.push_back(child_idx);
7094 if (field_type.GetIndexOfChildMemberWithName(
7095 name, omit_empty_base_classes, child_indexes))
7096 return child_indexes.size();
7097 child_indexes.pop_back();
7098
7099 } else if (field_name.equals(name_sref)) {
7100 // We have to add on the number of base classes to this index!
7101 child_indexes.push_back(
7102 child_idx + ClangASTContext::GetNumBaseClasses(
7103 cxx_record_decl, omit_empty_base_classes));
7104 return child_indexes.size();
7105 }
7106 }
7107
7108 if (cxx_record_decl) {
7109 const clang::RecordDecl *parent_record_decl = cxx_record_decl;
7110
7111 // printf ("parent = %s\n", parent_record_decl->getNameAsCString());
7112
7113 // const Decl *root_cdecl = cxx_record_decl->getCanonicalDecl();
7114 // Didn't find things easily, lets let clang do its thang...
7115 clang::IdentifierInfo &ident_ref =
7116 getASTContext()->Idents.get(name_sref);
7117 clang::DeclarationName decl_name(&ident_ref);
7118
7119 clang::CXXBasePaths paths;
7120 if (cxx_record_decl->lookupInBases(
7121 [decl_name](const clang::CXXBaseSpecifier *specifier,
7122 clang::CXXBasePath &path) {
7123 return clang::CXXRecordDecl::FindOrdinaryMember(
7124 specifier, path, decl_name);
7125 },
7126 paths)) {
7127 clang::CXXBasePaths::const_paths_iterator path,
7128 path_end = paths.end();
7129 for (path = paths.begin(); path != path_end; ++path) {
7130 const size_t num_path_elements = path->size();
7131 for (size_t e = 0; e < num_path_elements; ++e) {
7132 clang::CXXBasePathElement elem = (*path)[e];
7133
7134 child_idx = GetIndexForRecordBase(parent_record_decl, elem.Base,
7135 omit_empty_base_classes);
7136 if (child_idx == UINT32_MAX(4294967295U)) {
7137 child_indexes.clear();
7138 return 0;
7139 } else {
7140 child_indexes.push_back(child_idx);
7141 parent_record_decl = llvm::cast<clang::RecordDecl>(
7142 elem.Base->getType()
7143 ->getAs<clang::RecordType>()
7144 ->getDecl());
7145 }
7146 }
7147 for (clang::NamedDecl *path_decl : path->Decls) {
7148 child_idx = GetIndexForRecordChild(
7149 parent_record_decl, path_decl, omit_empty_base_classes);
7150 if (child_idx == UINT32_MAX(4294967295U)) {
7151 child_indexes.clear();
7152 return 0;
7153 } else {
7154 child_indexes.push_back(child_idx);
7155 }
7156 }
7157 }
7158 return child_indexes.size();
7159 }
7160 }
7161 }
7162 break;
7163
7164 case clang::Type::ObjCObject:
7165 case clang::Type::ObjCInterface:
7166 if (GetCompleteType(type)) {
7167 llvm::StringRef name_sref(name);
7168 const clang::ObjCObjectType *objc_class_type =
7169 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
7170 assert(objc_class_type)((objc_class_type) ? static_cast<void> (0) : __assert_fail
("objc_class_type", "/build/llvm-toolchain-snapshot-8~svn345461/tools/lldb/source/Symbol/ClangASTContext.cpp"
, 7170, __PRETTY_FUNCTION__))
;
7171 if (objc_class_type) {
7172 uint32_t child_idx = 0;
7173 clang::ObjCInterfaceDecl *class_interface_decl =
7174 objc_class_type->getInterface();
7175
7176 if (class_interface_decl) {
7177 clang::ObjCInterfaceDecl::ivar_iterator ivar_pos,
7178 ivar_end = class_interface_decl->ivar_end();
7179 clang::ObjCInterfaceDecl *superclass_interface_decl =
7180 class_interface_decl->getSuperClass();
7181
7182 for (ivar_pos = class_interface_decl->ivar_begin();
7183 ivar_pos != ivar_end; ++ivar_pos, ++child_idx) {
7184 const clang::ObjCIvarDecl *ivar_decl = *ivar_pos;
7185
7186 if (ivar_decl->getName().equals(name_sref)) {
7187 if ((!omit_empty_base_classes && superclass_interface_decl) ||
7188 (omit_empty_base_classes &&
7189 ObjCDeclHasIVars(superclass_interface_decl, true)))
7190 ++child_idx;
7191
7192 child_indexes.push_back(child_idx);
7193 return child_indexes.size();
7194 }
7195 }
7196
7197 if (superclass_interface_decl) {
7198 // The super class index is always zero for ObjC classes, so we
7199 // push it onto the child indexes in case we find an ivar in our
7200 // superclass...
7201 child_indexes.push_back(0);
7202
7203 CompilerType superclass_clang_type(
7204 getASTContext(), getASTContext()->getObjCInterfaceType(
7205 superclass_interface_decl));
7206 if (superclass_clang_type.GetIndexOfChildMemberWithName(
7207 name, omit_empty_base_classes, child_indexes)) {
7208 // We did find an ivar in a superclass so just return the
7209 // results!
7210 return child_indexes.size();
7211 }
7212
7213 // We didn't find an ivar matching "name" in our superclass, pop
7214 // the superclass zero index that we pushed on above.
7215 child_indexes.pop_back();
7216 }
7217 }
7218 }
7219 }
7220 break;
7221
7222 case clang::Type::ObjCObjectPointer: {
7223 CompilerType objc_object_clang_type(
7224 getASTContext(),
7225 llvm::cast<clang::ObjCObjectPointerType>(qual_type.getTypePtr())
7226 ->getPointeeType());
7227 return objc_object_clang_type.GetIndexOfChildMemberWithName(
7228 name, omit_empty_base_classes, child_indexes);
7229 } break;
7230
7231 case clang::Type::ConstantArray: {
7232 // const clang::ConstantArrayType *array =
7233 // llvm::cast<clang::ConstantArrayType>(parent_qual_type.getTypePtr());
7234 // const uint64_t element_count =
7235 // array->getSize().getLimitedValue();
7236 //
7237 // if (idx < element_count)
7238 // {
7239 // std::pair<uint64_t, unsigned> field_type_info =
7240 // ast->getTypeInfo(array->getElementType());
7241 //
7242 // char element_name[32];
7243 // ::snprintf (element_name, sizeof (element_name),
7244 // "%s[%u]", parent_name ? parent_name : "", idx);
7245 //
7246 // child_name.assign(element_name);
7247 // assert(field_type_info.first % 8 == 0);
7248 // child_byte_size = field_type_info.first / 8;
7249 // child_byte_offset = idx * child_byte_size;
7250 // return array->getElementType().getAsOpaquePtr();
7251 // }
7252 } break;
7253
7254 // case clang::Type::MemberPointerType:
7255 // {
7256 // MemberPointerType *mem_ptr_type =
7257 // llvm::cast<MemberPointerType>(qual_type.getTypePtr());
7258 // clang::QualType pointee_type =
7259 // mem_ptr_type->getPointeeType();
7260 //
7261 // if (ClangASTContext::IsAggregateType
7262 // (pointee_type.getAsOpaquePtr()))
7263 // {
7264 // return GetIndexOfChildWithName (ast,
7265 // mem_ptr_type->getPointeeType().getAsOpaquePtr(),
7266 // name);
7267 // }
7268 // }
7269 // break;
7270 //
7271 case clang::Type::LValueReference:
7272 case clang::Type::RValueReference: {
7273 const clang::ReferenceType *reference_type =
7274 llvm::cast<clang::ReferenceType>(qual_type.getTypePtr());
7275 clang::QualType pointee_type(reference_type->getPointeeType());
7276 CompilerType pointee_clang_type(getASTContext(), pointee_type);
7277
7278 if (pointee_clang_type.IsAggregateType()) {
7279 return pointee_clang_type.GetIndexOfChildMemberWithName(
7280 name, omit_empty_base_classes, child_indexes);
7281 }
7282 } break;
7283
7284 case clang::Type::Pointer: {
7285 CompilerType pointee_clang_type(GetPointeeType(type));
7286
7287 if (pointee_clang_type.IsAggregateType()) {
7288 return pointee_clang_type.GetIndexOfChildMemberWithName(
7289 name, omit_empty_base_classes, child_indexes);
7290 }
7291 } break;
7292
7293 case clang::Type::Typedef:
7294 return CompilerType(getASTContext(),
7295 llvm::cast<clang::TypedefType>(qual_type)
7296 ->getDecl()
7297 ->getUnderlyingType())
7298 .GetIndexOfChildMemberWithName(name, omit_empty_base_classes,
7299 child_indexes);
7300
7301 case clang::Type::Auto:
7302 return CompilerType(
7303 getASTContext(),
7304 llvm::cast<clang::AutoType>(qual_type)->getDeducedType())
7305 .GetIndexOfChildMemberWithName(name, omit_empty_base_classes,
7306 child_indexes);
7307
7308 case clang::Type::Elaborated:
7309 return CompilerType(
7310 getASTContext(),
7311 llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType())
7312 .GetIndexOfChildMemberWithName(name, omit_empty_base_classes,
7313 child_indexes);
7314
7315 case clang::Type::Paren:
7316 return CompilerType(getASTContext(),
7317 llvm::cast<clang::ParenType>(qual_type)->desugar())
7318 .GetIndexOfChildMemberWithName(name, omit_empty_base_classes,
7319 child_indexes);
7320
7321 default:
7322 break;
7323 }
7324 }
7325 return 0;
7326}
7327
7328// Get the index of the child of "clang_type" whose name matches. This function
7329// doesn't descend into the children, but only looks one level deep and name
7330// matches can include base class names.
7331
7332uint32_t
7333ClangASTContext::GetIndexOfChildWithName(lldb::opaque_compiler_type_t type,
7334 const char *name,
7335 bool omit_empty_base_classes) {
7336 if (type && name && name[0]) {
7337 clang::QualType qual_type(GetCanonicalQualType(type));
7338
7339 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
7340
7341 switch (type_class) {
7342 case clang::Type::Record:
7343 if (GetCompleteType(type)) {
7344 const clang::RecordType *record_type =
7345 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
7346 const clang::RecordDecl *record_decl = record_type->getDecl();
7347
7348 assert(record_decl)((record_decl) ? static_cast<void> (0) : __assert_fail (
"record_decl", "/build/llvm-toolchain-snapshot-8~svn345461/tools/lldb/source/Symbol/ClangASTContext.cpp"
, 7348, __PRETTY_FUNCTION__))
;
7349 uint32_t child_idx = 0;
7350
7351 const clang::CXXRecordDecl *cxx_record_decl =
7352 llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
7353
7354 if (cxx_record_decl) {
7355 clang::CXXRecordDecl::base_class_const_iterator base_class,
7356 base_class_end;
7357 for (base_class = cxx_record_decl->bases_begin(),
7358 base_class_end = cxx_record_decl->bases_end();
7359 base_class != base_class_end; ++base_class) {
7360 // Skip empty base classes
7361 clang::CXXRecordDecl *base_class_decl =
7362 llvm::cast<clang::CXXRecordDecl>(
7363 base_class->getType()
7364 ->getAs<clang::RecordType>()
7365 ->getDecl());
7366 if (omit_empty_base_classes &&
7367 ClangASTContext::RecordHasFields(base_class_decl) == false)
7368 continue;
7369
7370 CompilerType base_class_clang_type(getASTContext(),
7371 base_class->getType());
7372 std::string base_class_type_name(
7373 base_class_clang_type.GetTypeName().AsCString(""));
7374 if (base_class_type_name.compare(name) == 0)
7375 return child_idx;
7376 ++child_idx;
7377 }
7378 }
7379
7380 // Try and find a field that matches NAME
7381 clang::RecordDecl::field_iterator field, field_end;
7382 llvm::StringRef name_sref(name);
7383 for (field = record_decl->field_begin(),
7384 field_end = record_decl->field_end();
7385 field != field_end; ++field, ++child_idx) {
7386 if (field->getName().equals(name_sref))
7387 return child_idx;
7388 }
7389 }
7390 break;
7391
7392 case clang::Type::ObjCObject:
7393 case clang::Type::ObjCInterface:
7394 if (GetCompleteType(type)) {
7395 llvm::StringRef name_sref(name);
7396 const clang::ObjCObjectType *objc_class_type =
7397 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
7398 assert(objc_class_type)((objc_class_type) ? static_cast<void> (0) : __assert_fail
("objc_class_type", "/build/llvm-toolchain-snapshot-8~svn345461/tools/lldb/source/Symbol/ClangASTContext.cpp"
, 7398, __PRETTY_FUNCTION__))
;
7399 if (objc_class_type) {
7400 uint32_t child_idx = 0;
7401 clang::ObjCInterfaceDecl *class_interface_decl =
7402 objc_class_type->getInterface();
7403
7404 if (class_interface_decl) {
7405 clang::ObjCInterfaceDecl::ivar_iterator ivar_pos,
7406 ivar_end = class_interface_decl->ivar_end();
7407 clang::ObjCInterfaceDecl *superclass_interface_decl =
7408 class_interface_decl->getSuperClass();
7409
7410 for (ivar_pos = class_interface_decl->ivar_begin();
7411 ivar_pos != ivar_end; ++ivar_pos, ++child_idx) {
7412 const clang::ObjCIvarDecl *ivar_decl = *ivar_pos;
7413
7414 if (ivar_decl->getName().equals(name_sref)) {
7415 if ((!omit_empty_base_classes && superclass_interface_decl) ||
7416 (omit_empty_base_classes &&
7417 ObjCDeclHasIVars(superclass_interface_decl, true)))
7418 ++child_idx;
7419
7420 return child_idx;
7421 }
7422 }
7423
7424 if (superclass_interface_decl) {
7425 if (superclass_interface_decl->getName().equals(name_sref))
7426 return 0;
7427 }
7428 }
7429 }
7430 }
7431 break;
7432
7433 case clang::Type::ObjCObjectPointer: {
7434 CompilerType pointee_clang_type(
7435 getASTContext(),
7436 llvm::cast<clang::ObjCObjectPointerType>(qual_type.getTypePtr())
7437 ->getPointeeType());
7438 return pointee_clang_type.GetIndexOfChildWithName(
7439 name, omit_empty_base_classes);
7440 } break;
7441
7442 case clang::Type::ConstantArray: {
7443 // const clang::ConstantArrayType *array =
7444 // llvm::cast<clang::ConstantArrayType>(parent_qual_type.getTypePtr());
7445 // const uint64_t element_count =
7446 // array->getSize().getLimitedValue();
7447 //
7448 // if (idx < element_count)
7449 // {
7450 // std::pair<uint64_t, unsigned> field_type_info =
7451 // ast->getTypeInfo(array->getElementType());
7452 //
7453 // char element_name[32];
7454 // ::snprintf (element_name, sizeof (element_name),
7455 // "%s[%u]", parent_name ? parent_name : "", idx);
7456 //
7457 // child_name.assign(element_name);
7458 // assert(field_type_info.first % 8 == 0);
7459 // child_byte_size = field_type_info.first / 8;
7460 // child_byte_offset = idx * child_byte_size;
7461 // return array->getElementType().getAsOpaquePtr();
7462 // }
7463 } break;
7464
7465 // case clang::Type::MemberPointerType:
7466 // {
7467 // MemberPointerType *mem_ptr_type =
7468 // llvm::cast<MemberPointerType>(qual_type.getTypePtr());
7469 // clang::QualType pointee_type =
7470 // mem_ptr_type->getPointeeType();
7471 //
7472 // if (ClangASTContext::IsAggregateType
7473 // (pointee_type.getAsOpaquePtr()))
7474 // {
7475 // return GetIndexOfChildWithName (ast,
7476 // mem_ptr_type->getPointeeType().getAsOpaquePtr(),
7477 // name);
7478 // }
7479 // }
7480 // break;
7481 //
7482 case clang::Type::LValueReference:
7483 case clang::Type::RValueReference: {
7484 const clang::ReferenceType *reference_type =
7485 llvm::cast<clang::ReferenceType>(qual_type.getTypePtr());
7486 CompilerType pointee_type(getASTContext(),
7487 reference_type->getPointeeType());
7488
7489 if (pointee_type.IsAggregateType()) {
7490 return pointee_type.GetIndexOfChildWithName(name,
7491 omit_empty_base_classes);
7492 }
7493 } break;
7494
7495 case clang::Type::Pointer: {
7496 const clang::PointerType *pointer_type =
7497 llvm::cast<clang::PointerType>(qual_type.getTypePtr());
7498 CompilerType pointee_type(getASTContext(),
7499 pointer_type->getPointeeType());
7500
7501 if (pointee_type.IsAggregateType()) {
7502 return pointee_type.GetIndexOfChildWithName(name,
7503 omit_empty_base_classes);
7504 } else {
7505 // if (parent_name)
7506 // {
7507 // child_name.assign(1, '*');
7508 // child_name += parent_name;
7509 // }
7510 //
7511 // // We have a pointer to an simple type
7512 // if (idx == 0)
7513 // {
7514 // std::pair<uint64_t, unsigned> clang_type_info
7515 // = ast->getTypeInfo(pointee_type);
7516 // assert(clang_type_info.first % 8 == 0);
7517 // child_byte_size = clang_type_info.first / 8;
7518 // child_byte_offset = 0;
7519 // return pointee_type.getAsOpaquePtr();
7520 // }
7521 }
7522 } break;
7523
7524 case clang::Type::Auto:
7525 return CompilerType(
7526 getASTContext(),
7527 llvm::cast<clang::AutoType>(qual_type)->getDeducedType())
7528 .GetIndexOfChildWithName(name, omit_empty_base_classes);
7529
7530 case clang::Type::Elaborated:
7531 return CompilerType(
7532 getASTContext(),
7533 llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType())
7534 .GetIndexOfChildWithName(name, omit_empty_base_classes);
7535
7536 case clang::Type::Paren:
7537 return CompilerType(getASTContext(),
7538 llvm::cast<clang::ParenType>(qual_type)->desugar())
7539 .GetIndexOfChildWithName(name, omit_empty_base_classes);
7540
7541 case clang::Type::Typedef:
7542 return CompilerType(getASTContext(),
7543 llvm::cast<clang::TypedefType>(qual_type)
7544 ->getDecl()
7545 ->getUnderlyingType())
7546 .GetIndexOfChildWithName(name, omit_empty_base_classes);
7547
7548 default:
7549 break;
7550 }
7551 }
7552 return UINT32_MAX(4294967295U);
7553}
7554
7555size_t
7556ClangASTContext::GetNumTemplateArguments(lldb::opaque_compiler_type_t type) {
7557 if (!type)
7558 return 0;
7559
7560 clang::QualType qual_type(GetCanonicalQualType(type));
7561 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
7562 switch (type_class) {
7563 case clang::Type::Record:
7564 if (GetCompleteType(type)) {
7565 const clang::CXXRecordDecl *cxx_record_decl =
7566 qual_type->getAsCXXRecordDecl();
7567 if (cxx_record_decl) {
7568 const clang::ClassTemplateSpecializationDecl *template_decl =
7569 llvm::dyn_cast<clang::ClassTemplateSpecializationDecl>(
7570 cxx_record_decl);
7571 if (template_decl)
7572 return template_decl->getTemplateArgs().size();
7573 }
7574 }
7575 break;
7576
7577 case clang::Type::Typedef:
7578 return (CompilerType(getASTContext(),
7579 llvm::cast<clang::TypedefType>(qual_type)
7580 ->getDecl()
7581 ->getUnderlyingType()))
7582 .GetNumTemplateArguments();
7583
7584 case clang::Type::Auto:
7585 return (CompilerType(
7586 getASTContext(),
7587 llvm::cast<clang::AutoType>(qual_type)->getDeducedType()))
7588 .GetNumTemplateArguments();
7589
7590 case clang::Type::Elaborated:
7591 return (CompilerType(
7592 getASTContext(),
7593 llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType()))
7594 .GetNumTemplateArguments();
7595
7596 case clang::Type::Paren:
7597 return (CompilerType(getASTContext(),
7598 llvm::cast<clang::ParenType>(qual_type)->desugar()))
7599 .GetNumTemplateArguments();
7600
7601 default:
7602 break;
7603 }
7604
7605 return 0;
7606}
7607
7608const clang::ClassTemplateSpecializationDecl *
7609ClangASTContext::GetAsTemplateSpecialization(
7610 lldb::opaque_compiler_type_t type) {
7611 if (!type)
7612 return nullptr;
7613
7614 clang::QualType qual_type(GetCanonicalQualType(type));
7615 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
7616 switch (type_class) {
7617 case clang::Type::Record: {
7618 if (! GetCompleteType(type))
7619 return nullptr;
7620 const clang::CXXRecordDecl *cxx_record_decl =
7621 qual_type->getAsCXXRecordDecl();
7622 if (!cxx_record_decl)
7623 return nullptr;
7624 return llvm::dyn_cast<clang::ClassTemplateSpecializationDecl>(
7625 cxx_record_decl);
7626 }
7627
7628 case clang::Type::Typedef:
7629 return GetAsTemplateSpecialization(llvm::cast<clang::TypedefType>(qual_type)
7630 ->getDecl()
7631 ->getUnderlyingType()
7632 .getAsOpaquePtr());
7633
7634 case clang::Type::Auto:
7635 return GetAsTemplateSpecialization(llvm::cast<clang::AutoType>(qual_type)
7636 ->getDeducedType()
7637 .getAsOpaquePtr());
7638
7639 case clang::Type::Elaborated:
7640 return GetAsTemplateSpecialization(
7641 llvm::cast<clang::ElaboratedType>(qual_type)
7642 ->getNamedType()
7643 .getAsOpaquePtr());
7644
7645 case clang::Type::Paren:
7646 return GetAsTemplateSpecialization(
7647 llvm::cast<clang::ParenType>(qual_type)->desugar().getAsOpaquePtr());
7648
7649 default:
7650 return nullptr;
7651 }
7652}
7653
7654lldb::TemplateArgumentKind
7655ClangASTContext::GetTemplateArgumentKind(lldb::opaque_compiler_type_t type,
7656 size_t arg_idx) {
7657 const clang::ClassTemplateSpecializationDecl *template_decl =
7658 GetAsTemplateSpecialization(type);
7659 if (! template_decl || arg_idx >= template_decl->getTemplateArgs().size())
7660 return eTemplateArgumentKindNull;
7661
7662 switch (template_decl->getTemplateArgs()[arg_idx].getKind()) {
7663 case clang::TemplateArgument::Null:
7664 return eTemplateArgumentKindNull;
7665
7666 case clang::TemplateArgument::NullPtr:
7667 return eTemplateArgumentKindNullPtr;
7668
7669 case clang::TemplateArgument::Type:
7670 return eTemplateArgumentKindType;
7671
7672 case clang::TemplateArgument::Declaration:
7673 return eTemplateArgumentKindDeclaration;
7674
7675 case clang::TemplateArgument::Integral:
7676 return eTemplateArgumentKindIntegral;
7677
7678 case clang::TemplateArgument::Template:
7679 return eTemplateArgumentKindTemplate;
7680
7681 case clang::TemplateArgument::TemplateExpansion:
7682 return eTemplateArgumentKindTemplateExpansion;
7683
7684 case clang::TemplateArgument::Expression:
7685 return eTemplateArgumentKindExpression;
7686
7687 case clang::TemplateArgument::Pack:
7688 return eTemplateArgumentKindPack;
7689 }
7690 llvm_unreachable("Unhandled clang::TemplateArgument::ArgKind")::llvm::llvm_unreachable_internal("Unhandled clang::TemplateArgument::ArgKind"
, "/build/llvm-toolchain-snapshot-8~svn345461/tools/lldb/source/Symbol/ClangASTContext.cpp"
, 7690)
;
7691}
7692
7693CompilerType
7694ClangASTContext::GetTypeTemplateArgument(lldb::opaque_compiler_type_t type,
7695 size_t idx) {
7696 const clang::ClassTemplateSpecializationDecl *template_decl =
7697 GetAsTemplateSpecialization(type);
7698 if (!template_decl || idx >= template_decl->getTemplateArgs().size())
7699 return CompilerType();
7700
7701 const clang::TemplateArgument &template_arg =
7702 template_decl->getTemplateArgs()[idx];
7703 if (template_arg.getKind() != clang::TemplateArgument::Type)
7704 return CompilerType();
7705
7706 return CompilerType(getASTContext(), template_arg.getAsType());
7707}
7708
7709llvm::Optional<CompilerType::IntegralTemplateArgument>
7710ClangASTContext::GetIntegralTemplateArgument(lldb::opaque_compiler_type_t type,
7711 size_t idx) {
7712 const clang::ClassTemplateSpecializationDecl *template_decl =
7713 GetAsTemplateSpecialization(type);
7714 if (! template_decl || idx >= template_decl->getTemplateArgs().size())
7715 return llvm::None;
7716
7717 const clang::TemplateArgument &template_arg =
7718 template_decl->getTemplateArgs()[idx];
7719 if (template_arg.getKind() != clang::TemplateArgument::Integral)
7720 return llvm::None;
7721
7722 return {{template_arg.getAsIntegral(),
7723 CompilerType(getASTContext(), template_arg.getIntegralType())}};
7724}
7725
7726CompilerType ClangASTContext::GetTypeForFormatters(void *type) {
7727 if (type)
7728 return ClangUtil::RemoveFastQualifiers(CompilerType(this, type));
7729 return CompilerType();
7730}
7731
7732clang::EnumDecl *ClangASTContext::GetAsEnumDecl(const CompilerType &type) {
7733 const clang::EnumType *enutype =
7734 llvm::dyn_cast<clang::EnumType>(ClangUtil::GetCanonicalQualType(type));
7735 if (enutype)
7736 return enutype->getDecl();
7737 return NULL__null;
7738}
7739
7740clang::RecordDecl *ClangASTContext::GetAsRecordDecl(const CompilerType &type) {
7741 const clang::RecordType *record_type =
7742 llvm::dyn_cast<clang::RecordType>(ClangUtil::GetCanonicalQualType(type));
7743 if (record_type)
7744 return record_type->getDecl();
7745 return nullptr;
7746}
7747
7748clang::TagDecl *ClangASTContext::GetAsTagDecl(const CompilerType &type) {
7749 clang::QualType qual_type = ClangUtil::GetCanonicalQualType(type);
7750 if (qual_type.isNull())
7751 return nullptr;
7752 else
7753 return qual_type->getAsTagDecl();
7754}
7755
7756clang::TypedefNameDecl *
7757ClangASTContext::GetAsTypedefDecl(const CompilerType &type) {
7758 const clang::TypedefType *typedef_type =
7759 llvm::dyn_cast<clang::TypedefType>(ClangUtil::GetQualType(type));
7760 if (typedef_type)
7761 return typedef_type->getDecl();
7762 return nullptr;
7763}
7764
7765clang::CXXRecordDecl *
7766ClangASTContext::GetAsCXXRecordDecl(lldb::opaque_compiler_type_t type) {
7767 return GetCanonicalQualType(type)->getAsCXXRecordDecl();
7768}
7769
7770clang::ObjCInterfaceDecl *
7771ClangASTContext::GetAsObjCInterfaceDecl(const CompilerType &type) {
7772 const clang::ObjCObjectType *objc_class_type =
7773 llvm::dyn_cast<clang::ObjCObjectType>(
7774 ClangUtil::GetCanonicalQualType(type));
7775 if (objc_class_type)
7776 return objc_class_type->getInterface();
7777 return nullptr;
7778}
7779
7780clang::FieldDecl *ClangASTContext::AddFieldToRecordType(
7781 const CompilerType &type, llvm::StringRef name,
7782 const CompilerType &field_clang_type, AccessType access,
7783 uint32_t bitfield_bit_size) {
7784 if (!type.IsValid() || !field_clang_type.IsValid())
7785 return nullptr;
7786 ClangASTContext *ast =
7787 llvm::dyn_cast_or_null<ClangASTContext>(type.GetTypeSystem());
7788 if (!ast)
7789 return nullptr;
7790 clang::ASTContext *clang_ast = ast->getASTContext();
7791 clang::IdentifierInfo *ident = nullptr;
7792 if (!name.empty())
7793 ident = &clang_ast->Idents.get(name);
7794
7795 clang::FieldDecl *field = nullptr;
7796
7797 clang::Expr *bit_width = nullptr;
7798 if (bitfield_bit_size != 0) {
7799 llvm::APInt bitfield_bit_size_apint(
7800 clang_ast->getTypeSize(clang_ast->IntTy), bitfield_bit_size);
7801 bit_width = new (*clang_ast)
7802 clang::IntegerLiteral(*clang_ast, bitfield_bit_size_apint,
7803 clang_ast->IntTy, clang::SourceLocation());
7804 }
7805
7806 clang::RecordDecl *record_decl = ast->GetAsRecordDecl(type);
7807 if (record_decl) {
7808 field = clang::FieldDecl::Create(
7809 *clang_ast, record_decl, clang::SourceLocation(),
7810 clang::SourceLocation(),
7811 ident, // Identifier
7812 ClangUtil::GetQualType(field_clang_type), // Field type
7813 nullptr, // TInfo *
7814 bit_width, // BitWidth
7815 false, // Mutable
7816 clang::ICIS_NoInit); // HasInit
7817
7818 if (name.empty()) {
7819 // Determine whether this field corresponds to an anonymous struct or
7820 // union.
7821 if (const clang::TagType *TagT =
7822 field->getType()->getAs<clang::TagType>()) {
7823 if (clang::RecordDecl *Rec =
7824 llvm::dyn_cast<clang::RecordDecl>(TagT->getDecl()))
7825 if (!Rec->getDeclName()) {
7826 Rec->setAnonymousStructOrUnion(true);
7827 field->setImplicit();
7828 }
7829 }
7830 }
7831
7832 if (field) {
7833 field->setAccess(
7834 ClangASTContext::ConvertAccessTypeToAccessSpecifier(access));
7835
7836 record_decl->addDecl(field);
7837
7838#ifdef LLDB_CONFIGURATION_DEBUG
7839 VerifyDecl(field);
7840#endif
7841 }
7842 } else {
7843 clang::ObjCInterfaceDecl *class_interface_decl =
7844 ast->GetAsObjCInterfaceDecl(type);
7845
7846 if (class_interface_decl) {
7847 const bool is_synthesized = false;
7848
7849 field_clang_type.GetCompleteType();
7850
7851 field = clang::ObjCIvarDecl::Create(
7852 *clang_ast, class_interface_decl, clang::SourceLocation(),
7853 clang::SourceLocation(),
7854 ident, // Identifier
7855 ClangUtil::GetQualType(field_clang_type), // Field type
7856 nullptr, // TypeSourceInfo *
7857 ConvertAccessTypeToObjCIvarAccessControl(access), bit_width,
7858 is_synthesized);
7859
7860 if (field) {
7861 class_interface_decl->addDecl(field);
7862
7863#ifdef LLDB_CONFIGURATION_DEBUG
7864 VerifyDecl(field);
7865#endif
7866 }
7867 }
7868 }
7869 return field;
7870}
7871
7872void ClangASTContext::BuildIndirectFields(const CompilerType &type) {
7873 if (!type)
7874 return;
7875
7876 ClangASTContext *ast = llvm::dyn_cast<ClangASTContext>(type.GetTypeSystem());
7877 if (!ast)
7878 return;
7879
7880 clang::RecordDecl *record_decl = ast->GetAsRecordDecl(type);
7881
7882 if (!record_decl)
7883 return;
7884
7885 typedef llvm::SmallVector<clang::IndirectFieldDecl *, 1> IndirectFieldVector;
7886
7887 IndirectFieldVector indirect_fields;
7888 clang::RecordDecl::field_iterator field_pos;
7889 clang::RecordDecl::field_iterator field_end_pos = record_decl->field_end();
7890 clang::RecordDecl::field_iterator last_field_pos = field_end_pos;
7891 for (field_pos = record_decl->field_begin(); field_pos != field_end_pos;
7892 last_field_pos = field_pos++) {
7893 if (field_pos->isAnonymousStructOrUnion()) {
7894 clang::QualType field_qual_type = field_pos->getType();
7895
7896 const clang::RecordType *field_record_type =
7897 field_qual_type->getAs<clang::RecordType>();
7898
7899 if (!field_record_type)
7900 continue;
7901
7902 clang::RecordDecl *field_record_decl = field_record_type->getDecl();
7903
7904 if (!field_record_decl)
7905 continue;
7906
7907 for (clang::RecordDecl::decl_iterator
7908 di = field_record_decl->decls_begin(),
7909 de = field_record_decl->decls_end();
7910 di != de; ++di) {
7911 if (clang::FieldDecl *nested_field_decl =
7912 llvm::dyn_cast<clang::FieldDecl>(*di)) {
7913 clang::NamedDecl **chain =
7914 new (*ast->getASTContext()) clang::NamedDecl *[2];
7915 chain[0] = *field_pos;
7916 chain[1] = nested_field_decl;
7917 clang::IndirectFieldDecl *indirect_field =
7918 clang::IndirectFieldDecl::Create(
7919 *ast->getASTContext(), record_decl, clang::SourceLocation(),
7920 nested_field_decl->getIdentifier(),
7921 nested_field_decl->getType(), {chain, 2});
7922
7923 indirect_field->setImplicit();
7924
7925 indirect_field->setAccess(ClangASTContext::UnifyAccessSpecifiers(
7926 field_pos->getAccess(), nested_field_decl->getAccess()));
7927
7928 indirect_fields.push_back(indirect_field);
7929 } else if (clang::IndirectFieldDecl *nested_indirect_field_decl =
7930 llvm::dyn_cast<clang::IndirectFieldDecl>(*di)) {
7931 size_t nested_chain_size =
7932 nested_indirect_field_decl->getChainingSize();
7933 clang::NamedDecl **chain = new (*ast->getASTContext())
7934 clang::NamedDecl *[nested_chain_size + 1];
7935 chain[0] = *field_pos;
7936
7937 int chain_index = 1;
7938 for (clang::IndirectFieldDecl::chain_iterator
7939 nci = nested_indirect_field_decl->chain_begin(),
7940 nce = nested_indirect_field_decl->chain_end();
7941 nci < nce; ++nci) {
7942 chain[chain_index] = *nci;
7943 chain_index++;
7944 }
7945
7946 clang::IndirectFieldDecl *indirect_field =
7947 clang::IndirectFieldDecl::Create(
7948 *ast->getASTContext(), record_decl, clang::SourceLocation(),
7949 nested_indirect_field_decl->getIdentifier(),
7950 nested_indirect_field_decl->getType(),
7951 {chain, nested_chain_size + 1});
7952
7953 indirect_field->setImplicit();
7954
7955 indirect_field->setAccess(ClangASTContext::UnifyAccessSpecifiers(
7956 field_pos->getAccess(), nested_indirect_field_decl->getAccess()));
7957
7958 indirect_fields.push_back(indirect_field);
7959 }
7960 }
7961 }
7962 }
7963
7964 // Check the last field to see if it has an incomplete array type as its last
7965 // member and if it does, the tell the record decl about it
7966 if (last_field_pos != field_end_pos) {
7967 if (last_field_pos->getType()->isIncompleteArrayType())
7968 record_decl->hasFlexibleArrayMember();
7969 }
7970
7971 for (IndirectFieldVector::iterator ifi = indirect_fields.begin(),
7972 ife = indirect_fields.end();
7973 ifi < ife; ++ifi) {
7974 record_decl->addDecl(*ifi);
7975 }
7976}
7977
7978void ClangASTContext::SetIsPacked(const CompilerType &type) {
7979 if (type) {
7980 ClangASTContext *ast =
7981 llvm::dyn_cast<ClangASTContext>(type.GetTypeSystem());
7982 if (ast) {
7983 clang::RecordDecl *record_decl = GetAsRecordDecl(type);
7984
7985 if (!record_decl)
7986 return;
7987
7988 record_decl->addAttr(
7989 clang::PackedAttr::CreateImplicit(*ast->getASTContext()));
7990 }
7991 }
7992}
7993
7994clang::VarDecl *ClangASTContext::AddVariableToRecordType(
7995 const CompilerType &type, llvm::StringRef name,
7996 const CompilerType &var_type, AccessType access) {
7997 if (!type.IsValid() || !var_type.IsValid())
7998 return nullptr;
7999
8000 ClangASTContext *ast = llvm::dyn_cast<ClangASTContext>(type.GetTypeSystem());
8001 if (!ast)
8002 return nullptr;
8003
8004 clang::RecordDecl *record_decl = ast->GetAsRecordDecl(type);
8005 if (!record_decl)
8006 return nullptr;
8007
8008 clang::VarDecl *var_decl = nullptr;
8009 clang::IdentifierInfo *ident = nullptr;
8010 if (!name.empty())
8011 ident = &ast->getASTContext()->Idents.get(name);
8012
8013 var_decl = clang::VarDecl::Create(
8014 *ast->getASTContext(), // ASTContext &
8015 record_decl, // DeclContext *
8016 clang::SourceLocation(), // clang::SourceLocation StartLoc
8017 clang::SourceLocation(), // clang::SourceLocation IdLoc
8018 ident, // clang::IdentifierInfo *
8019 ClangUtil::GetQualType(var_type), // Variable clang::QualType
8020 nullptr, // TypeSourceInfo *
8021 clang::SC_Static); // StorageClass
8022 if (!var_decl)
8023 return nullptr;
8024
8025 var_decl->setAccess(
8026 ClangASTContext::ConvertAccessTypeToAccessSpecifier(access));
8027 record_decl->addDecl(var_decl);
8028
8029#ifdef LLDB_CONFIGURATION_DEBUG
8030 VerifyDecl(var_decl);
8031#endif
8032
8033 return var_decl;
8034}
8035
8036clang::CXXMethodDecl *ClangASTContext::AddMethodToCXXRecordType(
8037 lldb::opaque_compiler_type_t type, const char *name, const char *mangled_name,
8038 const CompilerType &method_clang_type, lldb::AccessType access,
8039 bool is_virtual, bool is_static, bool is_inline, bool is_explicit,
8040 bool is_attr_used, bool is_artificial) {
8041 if (!type || !method_clang_type.IsValid() || name == nullptr ||
1
Assuming 'type' is non-null
2
Assuming the condition is false
4
Taking false branch
8042 name[0] == '\0')
3
Assuming the condition is false
8043 return nullptr;
8044
8045 clang::QualType record_qual_type(GetCanonicalQualType(type));
8046
8047 clang::CXXRecordDecl *cxx_record_decl =
8048 record_qual_type->getAsCXXRecordDecl();
8049
8050 if (cxx_record_decl == nullptr)
5
Assuming the condition is false
6
Taking false branch
8051 return nullptr;
8052
8053 clang::QualType method_qual_type(ClangUtil::GetQualType(method_clang_type));
8054
8055 clang::CXXMethodDecl *cxx_method_decl = nullptr;
8056
8057 clang::DeclarationName decl_name(&getASTContext()->Idents.get(name));
8058
8059 const clang::FunctionType *function_type =
8060 llvm::dyn_cast<clang::FunctionType>(method_qual_type.getTypePtr());
8061
8062 if (function_type == nullptr)
7
Taking false branch
8063 return nullptr;
8064
8065 const clang::FunctionProtoType *method_function_prototype(
8066 llvm::dyn_cast<clang::FunctionProtoType>(function_type));
8067
8068 if (!method_function_prototype)
8
Assuming 'method_function_prototype' is non-null
9
Taking false branch
8069 return nullptr;
8070
8071 unsigned int num_params = method_function_prototype->getNumParams();
8072
8073 clang::CXXDestructorDecl *cxx_dtor_decl(nullptr);
8074 clang::CXXConstructorDecl *cxx_ctor_decl(nullptr);
8075
8076 if (is_artificial)
10
Assuming 'is_artificial' is 0
11
Taking false branch
8077 return nullptr; // skip everything artificial
8078
8079 if (name[0] == '~') {
12
Assuming the condition is false
13
Taking false branch
8080 cxx_dtor_decl = clang::CXXDestructorDecl::Create(
8081 *getASTContext(), cxx_record_decl, clang::SourceLocation(),
8082 clang::DeclarationNameInfo(
8083 getASTContext()->DeclarationNames.getCXXDestructorName(
8084 getASTContext()->getCanonicalType(record_qual_type)),
8085 clang::SourceLocation()),
8086 method_qual_type, nullptr, is_inline, is_artificial);
8087 cxx_method_decl = cxx_dtor_decl;
8088 } else if (decl_name == cxx_record_decl->getDeclName()) {
14
Taking false branch
8089 cxx_ctor_decl = clang::CXXConstructorDecl::Create(
8090 *getASTContext(), cxx_record_decl, clang::SourceLocation(),
8091 clang::DeclarationNameInfo(
8092 getASTContext()->DeclarationNames.getCXXConstructorName(
8093 getASTContext()->getCanonicalType(record_qual_type)),
8094 clang::SourceLocation()),
8095 method_qual_type,
8096 nullptr, // TypeSourceInfo *
8097 is_explicit, is_inline, is_artificial, false /*is_constexpr*/);
8098 cxx_method_decl = cxx_ctor_decl;
8099 } else {
8100 clang::StorageClass SC = is_static ? clang::SC_Static : clang::SC_None;
15
Assuming 'is_static' is 0
16
'?' condition is false
8101 clang::OverloadedOperatorKind op_kind = clang::NUM_OVERLOADED_OPERATORS;
8102
8103 if (IsOperator(name, op_kind)) {
17
Assuming the condition is false
18
Taking false branch
8104 if (op_kind != clang::NUM_OVERLOADED_OPERATORS) {
8105 // Check the number of operator parameters. Sometimes we have seen bad
8106 // DWARF that doesn't correctly describe operators and if we try to
8107 // create a method and add it to the class, clang will assert and
8108 // crash, so we need to make sure things are acceptable.
8109 const bool is_method = true;
8110 if (!ClangASTContext::CheckOverloadedOperatorKindParameterCount(
8111 is_method, op_kind, num_params))
8112 return nullptr;
8113 cxx_method_decl = clang::CXXMethodDecl::Create(
8114 *getASTContext(), cxx_record_decl, clang::SourceLocation(),
8115 clang::DeclarationNameInfo(
8116 getASTContext()->DeclarationNames.getCXXOperatorName(op_kind),
8117 clang::SourceLocation()),
8118 method_qual_type,
8119 nullptr, // TypeSourceInfo *
8120 SC, is_inline, false /*is_constexpr*/, clang::SourceLocation());
8121 } else if (num_params == 0) {
8122 // Conversion operators don't take params...
8123 cxx_method_decl = clang::CXXConversionDecl::Create(
8124 *getASTContext(), cxx_record_decl, clang::SourceLocation(),
8125 clang::DeclarationNameInfo(
8126 getASTContext()->DeclarationNames.getCXXConversionFunctionName(
8127 getASTContext()->getCanonicalType(
8128 function_type->getReturnType())),
8129 clang::SourceLocation()),
8130 method_qual_type,
8131 nullptr, // TypeSourceInfo *
8132 is_inline, is_explicit, false /*is_constexpr*/,
8133 clang::SourceLocation());
8134 }
8135 }
8136
8137 if (cxx_method_decl == nullptr) {
19
Taking true branch
8138 cxx_method_decl = clang::CXXMethodDecl::Create(
8139 *getASTContext(), cxx_record_decl, clang::SourceLocation(),
8140 clang::DeclarationNameInfo(decl_name, clang::SourceLocation()),
8141 method_qual_type,
8142 nullptr, // TypeSourceInfo *
8143 SC, is_inline, false /*is_constexpr*/, clang::SourceLocation());
8144 }
8145 }
8146
8147 clang::AccessSpecifier access_specifier =
8148 ClangASTContext::ConvertAccessTypeToAccessSpecifier(access);
8149
8150 cxx_method_decl->setAccess(access_specifier);
8151 cxx_method_decl->setVirtualAsWritten(is_virtual);
8152
8153 if (is_attr_used)
20
Assuming 'is_attr_used' is 0
21
Taking false branch
8154 cxx_method_decl->addAttr(clang::UsedAttr::CreateImplicit(*getASTContext()));
8155
8156 if (mangled_name != NULL__null) {
22
Assuming 'mangled_name' is not equal to NULL
23
Taking true branch
8157 cxx_method_decl->addAttr(
8158 clang::AsmLabelAttr::CreateImplicit(*getASTContext(), mangled_name));
24
Calling 'AsmLabelAttr::CreateImplicit'
8159 }
8160
8161 // Populate the method decl with parameter decls
8162
8163 llvm::SmallVector<clang::ParmVarDecl *, 12> params;
8164
8165 for (unsigned param_index = 0; param_index < num_params; ++param_index) {
8166 params.push_back(clang::ParmVarDecl::Create(
8167 *getASTContext(), cxx_method_decl, clang::SourceLocation(),
8168 clang::SourceLocation(),
8169 nullptr, // anonymous
8170 method_function_prototype->getParamType(param_index), nullptr,
8171 clang::SC_None, nullptr));
8172 }
8173
8174 cxx_method_decl->setParams(llvm::ArrayRef<clang::ParmVarDecl *>(params));
8175
8176 cxx_record_decl->addDecl(cxx_method_decl);
8177
8178 // Sometimes the debug info will mention a constructor (default/copy/move),
8179 // destructor, or assignment operator (copy/move) but there won't be any
8180 // version of this in the code. So we check if the function was artificially
8181 // generated and if it is trivial and this lets the compiler/backend know
8182 // that it can inline the IR for these when it needs to and we can avoid a
8183 // "missing function" error when running expressions.
8184
8185 if (is_artificial) {
8186 if (cxx_ctor_decl && ((cxx_ctor_decl->isDefaultConstructor() &&
8187 cxx_record_decl->hasTrivialDefaultConstructor()) ||
8188 (cxx_ctor_decl->isCopyConstructor() &&
8189 cxx_record_decl->hasTrivialCopyConstructor()) ||
8190 (cxx_ctor_decl->isMoveConstructor() &&
8191 cxx_record_decl->hasTrivialMoveConstructor()))) {
8192 cxx_ctor_decl->setDefaulted();
8193 cxx_ctor_decl->setTrivial(true);
8194 } else if (cxx_dtor_decl) {
8195 if (cxx_record_decl->hasTrivialDestructor()) {
8196 cxx_dtor_decl->setDefaulted();
8197 cxx_dtor_decl->setTrivial(true);
8198 }
8199 } else if ((cxx_method_decl->isCopyAssignmentOperator() &&
8200 cxx_record_decl->hasTrivialCopyAssignment()) ||
8201 (cxx_method_decl->isMoveAssignmentOperator() &&
8202 cxx_record_decl->hasTrivialMoveAssignment())) {
8203 cxx_method_decl->setDefaulted();
8204 cxx_method_decl->setTrivial(true);
8205 }
8206 }
8207
8208#ifdef LLDB_CONFIGURATION_DEBUG
8209 VerifyDecl(cxx_method_decl);
8210#endif
8211
8212 // printf ("decl->isPolymorphic() = %i\n",
8213 // cxx_record_decl->isPolymorphic());
8214 // printf ("decl->isAggregate() = %i\n",
8215 // cxx_record_decl->isAggregate());
8216 // printf ("decl->isPOD() = %i\n",
8217 // cxx_record_decl->isPOD());
8218 // printf ("decl->isEmpty() = %i\n",
8219 // cxx_record_decl->isEmpty());
8220 // printf ("decl->isAbstract() = %i\n",
8221 // cxx_record_decl->isAbstract());
8222 // printf ("decl->hasTrivialConstructor() = %i\n",
8223 // cxx_record_decl->hasTrivialConstructor());
8224 // printf ("decl->hasTrivialCopyConstructor() = %i\n",
8225 // cxx_record_decl->hasTrivialCopyConstructor());
8226 // printf ("decl->hasTrivialCopyAssignment() = %i\n",
8227 // cxx_record_decl->hasTrivialCopyAssignment());
8228 // printf ("decl->hasTrivialDestructor() = %i\n",
8229 // cxx_record_decl->hasTrivialDestructor());
8230 return cxx_method_decl;
8231}
8232
8233void ClangASTContext::AddMethodOverridesForCXXRecordType(
8234 lldb::opaque_compiler_type_t type) {
8235 if (auto *record = GetAsCXXRecordDecl(type))
8236 for (auto *method : record->methods())
8237 addOverridesForMethod(method);
8238}
8239
8240#pragma mark C++ Base Classes
8241
8242std::unique_ptr<clang::CXXBaseSpecifier>
8243ClangASTContext::CreateBaseClassSpecifier(lldb::opaque_compiler_type_t type,
8244 AccessType access, bool is_virtual,
8245 bool base_of_class) {
8246 if (!type)
8247 return nullptr;
8248
8249 return llvm::make_unique<clang::CXXBaseSpecifier>(
8250 clang::SourceRange(), is_virtual, base_of_class,
8251 ClangASTContext::ConvertAccessTypeToAccessSpecifier(access),
8252 getASTContext()->getTrivialTypeSourceInfo(GetQualType(type)),
8253 clang::SourceLocation());
8254}
8255
8256bool ClangASTContext::TransferBaseClasses(
8257 lldb::opaque_compiler_type_t type,
8258 std::vector<std::unique_ptr<clang::CXXBaseSpecifier>> bases) {
8259 if (!type)
8260 return false;
8261 clang::CXXRecordDecl *cxx_record_decl = GetAsCXXRecordDecl(type);
8262 if (!cxx_record_decl)
8263 return false;
8264 std::vector<clang::CXXBaseSpecifier *> raw_bases;
8265 raw_bases.reserve(bases.size());
8266
8267 // Clang will make a copy of them, so it's ok that we pass pointers that we're
8268 // about to destroy.
8269 for (auto &b : bases)
8270 raw_bases.push_back(b.get());
8271 cxx_record_decl->setBases(raw_bases.data(), raw_bases.size());
8272 return true;
8273}
8274
8275bool ClangASTContext::SetObjCSuperClass(
8276 const CompilerType &type, const CompilerType &superclass_clang_type) {
8277 ClangASTContext *ast =
8278 llvm::dyn_cast_or_null<ClangASTContext>(type.GetTypeSystem());
8279 if (!ast)
8280 return false;
8281 clang::ASTContext *clang_ast = ast->getASTContext();
8282
8283 if (type && superclass_clang_type.IsValid() &&
8284 superclass_clang_type.GetTypeSystem() == type.GetTypeSystem()) {
8285 clang::ObjCInterfaceDecl *class_interface_decl =
8286 GetAsObjCInterfaceDecl(type);
8287 clang::ObjCInterfaceDecl *super_interface_decl =
8288 GetAsObjCInterfaceDecl(superclass_clang_type);
8289 if (class_interface_decl && super_interface_decl) {
8290 class_interface_decl->setSuperClass(clang_ast->getTrivialTypeSourceInfo(
8291 clang_ast->getObjCInterfaceType(super_interface_decl)));
8292 return true;
8293 }
8294 }
8295 return false;
8296}
8297
8298bool ClangASTContext::AddObjCClassProperty(
8299 const CompilerType &type, const char *property_name,
8300 const CompilerType &property_clang_type, clang::ObjCIvarDecl *ivar_decl,
8301 const char *property_setter_name, const char *property_getter_name,
8302 uint32_t property_attributes, ClangASTMetadata *metadata) {
8303 if (!type || !property_clang_type.IsValid() || property_name == nullptr ||
8304 property_name[0] == '\0')
8305 return false;
8306 ClangASTContext *ast = llvm::dyn_cast<ClangASTContext>(type.GetTypeSystem());
8307 if (!ast)
8308 return false;
8309 clang::ASTContext *clang_ast = ast->getASTContext();
8310
8311 clang::ObjCInterfaceDecl *class_interface_decl = GetAsObjCInterfaceDecl(type);
8312
8313 if (class_interface_decl) {
8314 CompilerType property_clang_type_to_access;
8315
8316 if (property_clang_type.IsValid())
8317 property_clang_type_to_access = property_clang_type;
8318 else if (ivar_decl)
8319 property_clang_type_to_access =
8320 CompilerType(clang_ast, ivar_decl->getType());
8321
8322 if (class_interface_decl && property_clang_type_to_access.IsValid()) {
8323 clang::TypeSourceInfo *prop_type_source;
8324 if (ivar_decl)
8325 prop_type_source =
8326 clang_ast->getTrivialTypeSourceInfo(ivar_decl->getType());
8327 else
8328 prop_type_source = clang_ast->getTrivialTypeSourceInfo(
8329 ClangUtil::GetQualType(property_clang_type));
8330
8331 clang::ObjCPropertyDecl *property_decl = clang::ObjCPropertyDecl::Create(
8332 *clang_ast, class_interface_decl,
8333 clang::SourceLocation(), // Source Location
8334 &clang_ast->Idents.get(property_name),
8335 clang::SourceLocation(), // Source Location for AT
8336 clang::SourceLocation(), // Source location for (
8337 ivar_decl ? ivar_decl->getType()
8338 : ClangUtil::GetQualType(property_clang_type),
8339 prop_type_source);
8340
8341 if (property_decl) {
8342 if (metadata)
8343 ClangASTContext::SetMetadata(clang_ast, property_decl, *metadata);
8344
8345 class_interface_decl->addDecl(property_decl);
8346
8347 clang::Selector setter_sel, getter_sel;
8348
8349 if (property_setter_name != nullptr) {
8350 std::string property_setter_no_colon(
8351 property_setter_name, strlen(property_setter_name) - 1);
8352 clang::IdentifierInfo *setter_ident =
8353 &clang_ast->Idents.get(property_setter_no_colon);
8354 setter_sel = clang_ast->Selectors.getSelector(1, &setter_ident);
8355 } else if (!(property_attributes & DW_APPLE_PROPERTY_readonly)) {
8356 std::string setter_sel_string("set");
8357 setter_sel_string.push_back(::toupper(property_name[0]));
8358 setter_sel_string.append(&property_name[1]);
8359 clang::IdentifierInfo *setter_ident =
8360 &clang_ast->Idents.get(setter_sel_string);
8361 setter_sel = clang_ast->Selectors.getSelector(1, &setter_ident);
8362 }
8363 property_decl->setSetterName(setter_sel);
8364 property_decl->setPropertyAttributes(
8365 clang::ObjCPropertyDecl::OBJC_PR_setter);
8366
8367 if (property_getter_name != nullptr) {
8368 clang::IdentifierInfo *getter_ident =
8369 &clang_ast->Idents.get(property_getter_name);
8370 getter_sel = clang_ast->Selectors.getSelector(0, &getter_ident);
8371 } else {
8372 clang::IdentifierInfo *getter_ident =
8373 &clang_ast->Idents.get(property_name);
8374 getter_sel = clang_ast->Selectors.getSelector(0, &getter_ident);
8375 }
8376 property_decl->setGetterName(getter_sel);
8377 property_decl->setPropertyAttributes(
8378 clang::ObjCPropertyDecl::OBJC_PR_getter);
8379
8380 if (ivar_decl)
8381 property_decl->setPropertyIvarDecl(ivar_decl);
8382
8383 if (property_attributes & DW_APPLE_PROPERTY_readonly)
8384 property_decl->setPropertyAttributes(
8385 clang::ObjCPropertyDecl::OBJC_PR_readonly);
8386 if (property_attributes & DW_APPLE_PROPERTY_readwrite)
8387 property_decl->setPropertyAttributes(
8388 clang::ObjCPropertyDecl::OBJC_PR_readwrite);
8389 if (property_attributes & DW_APPLE_PROPERTY_assign)
8390 property_decl->setPropertyAttributes(
8391 clang::ObjCPropertyDecl::OBJC_PR_assign);
8392 if (property_attributes & DW_APPLE_PROPERTY_retain)
8393 property_decl->setPropertyAttributes(
8394 clang::ObjCPropertyDecl::OBJC_PR_retain);
8395 if (property_attributes & DW_APPLE_PROPERTY_copy)
8396 property_decl->setPropertyAttributes(
8397 clang::ObjCPropertyDecl::OBJC_PR_copy);
8398 if (property_attributes & DW_APPLE_PROPERTY_nonatomic)
8399 property_decl->setPropertyAttributes(
8400 clang::ObjCPropertyDecl::OBJC_PR_nonatomic);
8401 if (property_attributes & clang::ObjCPropertyDecl::OBJC_PR_nullability)
8402 property_decl->setPropertyAttributes(
8403 clang::ObjCPropertyDecl::OBJC_PR_nullability);
8404 if (property_attributes &
8405 clang::ObjCPropertyDecl::OBJC_PR_null_resettable)
8406 property_decl->setPropertyAttributes(
8407 clang::ObjCPropertyDecl::OBJC_PR_null_resettable);
8408 if (property_attributes & clang::ObjCPropertyDecl::OBJC_PR_class)
8409 property_decl->setPropertyAttributes(
8410 clang::ObjCPropertyDecl::OBJC_PR_class);
8411
8412 const bool isInstance =
8413 (property_attributes & clang::ObjCPropertyDecl::OBJC_PR_class) == 0;
8414
8415 if (!getter_sel.isNull() &&
8416 !(isInstance
8417 ? class_interface_decl->lookupInstanceMethod(getter_sel)
8418 : class_interface_decl->lookupClassMethod(getter_sel))) {
8419 const bool isVariadic = false;
8420 const bool isSynthesized = false;
8421 const bool isImplicitlyDeclared = true;
8422 const bool isDefined = false;
8423 const clang::ObjCMethodDecl::ImplementationControl impControl =
8424 clang::ObjCMethodDecl::None;
8425 const bool HasRelatedResultType = false;
8426
8427 clang::ObjCMethodDecl *getter = clang::ObjCMethodDecl::Create(
8428 *clang_ast, clang::SourceLocation(), clang::SourceLocation(),
8429 getter_sel, ClangUtil::GetQualType(property_clang_type_to_access),
8430 nullptr, class_interface_decl, isInstance, isVariadic,
8431 isSynthesized, isImplicitlyDeclared, isDefined, impControl,
8432 HasRelatedResultType);
8433
8434 if (getter && metadata)
8435 ClangASTContext::SetMetadata(clang_ast, getter, *metadata);
8436
8437 if (getter) {
8438 getter->setMethodParams(*clang_ast,
8439 llvm::ArrayRef<clang::ParmVarDecl *>(),
8440 llvm::ArrayRef<clang::SourceLocation>());
8441
8442 class_interface_decl->addDecl(getter);
8443 }
8444 }
8445
8446 if (!setter_sel.isNull() &&
8447 !(isInstance
8448 ? class_interface_decl->lookupInstanceMethod(setter_sel)
8449 : class_interface_decl->lookupClassMethod(setter_sel))) {
8450 clang::QualType result_type = clang_ast->VoidTy;
8451 const bool isVariadic = false;
8452 const bool isSynthesized = false;
8453 const bool isImplicitlyDeclared = true;
8454 const bool isDefined = false;
8455 const clang::ObjCMethodDecl::ImplementationControl impControl =
8456 clang::ObjCMethodDecl::None;
8457 const bool HasRelatedResultType = false;
8458
8459 clang::ObjCMethodDecl *setter = clang::ObjCMethodDecl::Create(
8460 *clang_ast, clang::SourceLocation(), clang::SourceLocation(),
8461 setter_sel, result_type, nullptr, class_interface_decl,
8462 isInstance, isVariadic, isSynthesized, isImplicitlyDeclared,
8463 isDefined, impControl, HasRelatedResultType);
8464
8465 if (setter && metadata)
8466 ClangASTContext::SetMetadata(clang_ast, setter, *metadata);
8467
8468 llvm::SmallVector<clang::ParmVarDecl *, 1> params;
8469
8470 params.push_back(clang::ParmVarDecl::Create(
8471 *clang_ast, setter, clang::SourceLocation(),
8472 clang::SourceLocation(),
8473 nullptr, // anonymous
8474 ClangUtil::GetQualType(property_clang_type_to_access), nullptr,
8475 clang::SC_Auto, nullptr));
8476
8477 if (setter) {
8478 setter->setMethodParams(
8479 *clang_ast, llvm::ArrayRef<clang::ParmVarDecl *>(params),
8480 llvm::ArrayRef<clang::SourceLocation>());
8481
8482 class_interface_decl->addDecl(setter);
8483 }
8484 }
8485
8486 return true;
8487 }
8488 }
8489 }
8490 return false;
8491}
8492
8493bool ClangASTContext::IsObjCClassTypeAndHasIVars(const CompilerType &type,
8494 bool check_superclass) {
8495 clang::ObjCInterfaceDecl *class_interface_decl = GetAsObjCInterfaceDecl(type);
8496 if (class_interface_decl)
8497 return ObjCDeclHasIVars(class_interface_decl, check_superclass);
8498 return false;
8499}
8500
8501clang::ObjCMethodDecl *ClangASTContext::AddMethodToObjCObjectType(
8502 const CompilerType &type,
8503 const char *name, // the full symbol name as seen in the symbol table
8504 // (lldb::opaque_compiler_type_t type, "-[NString
8505 // stringWithCString:]")
8506 const CompilerType &method_clang_type, lldb::AccessType access,
8507 bool is_artificial, bool is_variadic) {
8508 if (!type || !method_clang_type.IsValid())
8509 return nullptr;
8510
8511 clang::ObjCInterfaceDecl *class_interface_decl = GetAsObjCInterfaceDecl(type);
8512
8513 if (class_interface_decl == nullptr)
8514 return nullptr;
8515 ClangASTContext *lldb_ast =
8516 llvm::dyn_cast<ClangASTContext>(type.GetTypeSystem());
8517 if (lldb_ast == nullptr)
8518 return nullptr;
8519 clang::ASTContext *ast = lldb_ast->getASTContext();
8520
8521 const char *selector_start = ::strchr(name, ' ');
8522 if (selector_start == nullptr)
8523 return nullptr;
8524
8525 selector_start++;
8526 llvm::SmallVector<clang::IdentifierInfo *, 12> selector_idents;
8527
8528 size_t len = 0;
8529 const char *start;
8530 // printf ("name = '%s'\n", name);
8531
8532 unsigned num_selectors_with_args = 0;
8533 for (start = selector_start; start && *start != '\0' && *start != ']';
8534 start += len) {
8535 len = ::strcspn(start, ":]");
8536 bool has_arg = (start[len] == ':');
8537 if (has_arg)
8538 ++num_selectors_with_args;
8539 selector_idents.push_back(&ast->Idents.get(llvm::StringRef(start, len)));
8540 if (has_arg)
8541 len += 1;
8542 }
8543
8544 if (selector_idents.size() == 0)
8545 return nullptr;
8546
8547 clang::Selector method_selector = ast->Selectors.getSelector(
8548 num_selectors_with_args ? selector_idents.size() : 0,
8549 selector_idents.data());
8550
8551 clang::QualType method_qual_type(ClangUtil::GetQualType(method_clang_type));
8552
8553 // Populate the method decl with parameter decls
8554 const clang::Type *method_type(method_qual_type.getTypePtr());
8555
8556 if (method_type == nullptr)
8557 return nullptr;
8558
8559 const clang::FunctionProtoType *method_function_prototype(
8560 llvm::dyn_cast<clang::FunctionProtoType>(method_type));
8561
8562 if (!method_function_prototype)
8563 return nullptr;
8564
8565 bool is_synthesized = false;
8566 bool is_defined = false;
8567 clang::ObjCMethodDecl::ImplementationControl imp_control =
8568 clang::ObjCMethodDecl::None;
8569
8570 const unsigned num_args = method_function_prototype->getNumParams();
8571
8572 if (num_args != num_selectors_with_args)
8573 return nullptr; // some debug information is corrupt. We are not going to
8574 // deal with it.
8575
8576 clang::ObjCMethodDecl *objc_method_decl = clang::ObjCMethodDecl::Create(
8577 *ast,
8578 clang::SourceLocation(), // beginLoc,
8579 clang::SourceLocation(), // endLoc,
8580 method_selector, method_function_prototype->getReturnType(),
8581 nullptr, // TypeSourceInfo *ResultTInfo,
8582 ClangASTContext::GetASTContext(ast)->GetDeclContextForType(
8583 ClangUtil::GetQualType(type)),
8584 name[0] == '-', is_variadic, is_synthesized,
8585 true, // is_implicitly_declared; we force this to true because we don't
8586 // have source locations
8587 is_defined, imp_control, false /*has_related_result_type*/);
8588
8589 if (objc_method_decl == nullptr)
8590 return nullptr;
8591
8592 if (num_args > 0) {
8593 llvm::SmallVector<clang::ParmVarDecl *, 12> params;
8594
8595 for (unsigned param_index = 0; param_index < num_args; ++param_index) {
8596 params.push_back(clang::ParmVarDecl::Create(
8597 *ast, objc_method_decl, clang::SourceLocation(),
8598 clang::SourceLocation(),
8599 nullptr, // anonymous
8600 method_function_prototype->getParamType(param_index), nullptr,
8601 clang::SC_Auto, nullptr));
8602 }
8603
8604 objc_method_decl->setMethodParams(
8605 *ast, llvm::ArrayRef<clang::ParmVarDecl *>(params),
8606 llvm::ArrayRef<clang::SourceLocation>());
8607 }
8608
8609 class_interface_decl->addDecl(objc_method_decl);
8610
8611#ifdef LLDB_CONFIGURATION_DEBUG
8612 VerifyDecl(objc_method_decl);
8613#endif
8614
8615 return objc_method_decl;
8616}
8617
8618bool ClangASTContext::GetHasExternalStorage(const CompilerType &type) {
8619 if (ClangUtil::IsClangType(type))
8620 return false;
8621
8622 clang::QualType qual_type(ClangUtil::GetCanonicalQualType(type));
8623
8624 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
8625 switch (type_class) {
8626 case clang::Type::Record: {
8627 clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl();
8628 if (cxx_record_decl)
8629 return cxx_record_decl->hasExternalLexicalStorage() ||
8630 cxx_record_decl->hasExternalVisibleStorage();
8631 } break;
8632
8633 case clang::Type::Enum: {
8634 clang::EnumDecl *enum_decl =
8635 llvm::cast<clang::EnumType>(qual_type)->getDecl();
8636 if (enum_decl)
8637 return enum_decl->hasExternalLexicalStorage() ||
8638 enum_decl->hasExternalVisibleStorage();
8639 } break;
8640
8641 case clang::Type::ObjCObject:
8642 case clang::Type::ObjCInterface: {
8643 const clang::ObjCObjectType *objc_class_type =
8644 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
8645 assert(objc_class_type)((objc_class_type) ? static_cast<void> (0) : __assert_fail
("objc_class_type", "/build/llvm-toolchain-snapshot-8~svn345461/tools/lldb/source/Symbol/ClangASTContext.cpp"
, 8645, __PRETTY_FUNCTION__))
;
8646 if (objc_class_type) {
8647 clang::ObjCInterfaceDecl *class_interface_decl =
8648 objc_class_type->getInterface();
8649
8650 if (class_interface_decl)
8651 return class_interface_decl->hasExternalLexicalStorage() ||
8652 class_interface_decl->hasExternalVisibleStorage();
8653 }
8654 } break;
8655
8656 case clang::Type::Typedef:
8657 return GetHasExternalStorage(CompilerType(
8658 type.GetTypeSystem(), llvm::cast<clang::TypedefType>(qual_type)
8659 ->getDecl()
8660 ->getUnderlyingType()
8661 .getAsOpaquePtr()));
8662
8663 case clang::Type::Auto:
8664 return GetHasExternalStorage(CompilerType(
8665 type.GetTypeSystem(), llvm::cast<clang::AutoType>(qual_type)
8666 ->getDeducedType()
8667 .getAsOpaquePtr()));
8668
8669 case clang::Type::Elaborated:
8670 return GetHasExternalStorage(CompilerType(
8671 type.GetTypeSystem(), llvm::cast<clang::ElaboratedType>(qual_type)
8672 ->getNamedType()
8673 .getAsOpaquePtr()));
8674
8675 case clang::Type::Paren:
8676 return GetHasExternalStorage(CompilerType(
8677 type.GetTypeSystem(),
8678 llvm::cast<clang::ParenType>(qual_type)->desugar().getAsOpaquePtr()));
8679
8680 default:
8681 break;
8682 }
8683 return false;
8684}
8685
8686bool ClangASTContext::SetHasExternalStorage(lldb::opaque_compiler_type_t type,
8687 bool has_extern) {
8688 if (!type)
8689 return false;
8690
8691 clang::QualType qual_type(GetCanonicalQualType(type));
8692
8693 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
8694 switch (type_class) {
8695 case clang::Type::Record: {
8696 clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl();
8697 if (cxx_record_decl) {
8698 cxx_record_decl->setHasExternalLexicalStorage(has_extern);
8699 cxx_record_decl->setHasExternalVisibleStorage(has_extern);
8700 return true;
8701 }
8702 } break;
8703
8704 case clang::Type::Enum: {
8705 clang::EnumDecl *enum_decl =
8706 llvm::cast<clang::EnumType>(qual_type)->getDecl();
8707 if (enum_decl) {
8708 enum_decl->setHasExternalLexicalStorage(has_extern);
8709 enum_decl->setHasExternalVisibleStorage(has_extern);
8710 return true;
8711 }
8712 } break;
8713
8714 case clang::Type::ObjCObject:
8715 case clang::Type::ObjCInterface: {
8716 const clang::ObjCObjectType *objc_class_type =
8717 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
8718 assert(objc_class_type)((objc_class_type) ? static_cast<void> (0) : __assert_fail
("objc_class_type", "/build/llvm-toolchain-snapshot-8~svn345461/tools/lldb/source/Symbol/ClangASTContext.cpp"
, 8718, __PRETTY_FUNCTION__))
;
8719 if (objc_class_type) {
8720 clang::ObjCInterfaceDecl *class_interface_decl =
8721 objc_class_type->getInterface();
8722
8723 if (class_interface_decl) {
8724 class_interface_decl->setHasExternalLexicalStorage(has_extern);
8725 class_interface_decl->setHasExternalVisibleStorage(has_extern);
8726 return true;
8727 }
8728 }
8729 } break;
8730
8731 case clang::Type::Typedef:
8732 return SetHasExternalStorage(llvm::cast<clang::TypedefType>(qual_type)
8733 ->getDecl()
8734 ->getUnderlyingType()
8735 .getAsOpaquePtr(),
8736 has_extern);
8737
8738 case clang::Type::Auto:
8739 return SetHasExternalStorage(llvm::cast<clang::AutoType>(qual_type)
8740 ->getDeducedType()
8741 .getAsOpaquePtr(),
8742 has_extern);
8743
8744 case clang::Type::Elaborated:
8745 return SetHasExternalStorage(llvm::cast<clang::ElaboratedType>(qual_type)
8746 ->getNamedType()
8747 .getAsOpaquePtr(),
8748 has_extern);
8749
8750 case clang::Type::Paren:
8751 return SetHasExternalStorage(
8752 llvm::cast<clang::ParenType>(qual_type)->desugar().getAsOpaquePtr(),
8753 has_extern);
8754
8755 default:
8756 break;
8757 }
8758 return false;
8759}
8760
8761#pragma mark TagDecl
8762
8763bool ClangASTContext::StartTagDeclarationDefinition(const CompilerType &type) {
8764 clang::QualType qual_type(ClangUtil::GetQualType(type));
8765 if (!qual_type.isNull()) {
8766 const clang::TagType *tag_type = qual_type->getAs<clang::TagType>();
8767 if (tag_type) {
8768 clang::TagDecl *tag_decl = tag_type->getDecl();
8769 if (tag_decl) {
8770 tag_decl->startDefinition();
8771 return true;
8772 }
8773 }
8774
8775 const clang::ObjCObjectType *object_type =
8776 qual_type->getAs<clang::ObjCObjectType>();
8777 if (object_type) {
8778 clang::ObjCInterfaceDecl *interface_decl = object_type->getInterface();
8779 if (interface_decl) {
8780 interface_decl->startDefinition();
8781 return true;
8782 }
8783 }
8784 }
8785 return false;
8786}
8787
8788bool ClangASTContext::CompleteTagDeclarationDefinition(
8789 const CompilerType &type) {
8790 clang::QualType qual_type(ClangUtil::GetQualType(type));
8791 if (!qual_type.isNull()) {
8792 // Make sure we use the same methodology as
8793 // ClangASTContext::StartTagDeclarationDefinition() as to how we start/end
8794 // the definition. Previously we were calling
8795 const clang::TagType *tag_type = qual_type->getAs<clang::TagType>();
8796 if (tag_type) {
8797 clang::TagDecl *tag_decl = tag_type->getDecl();
8798 if (tag_decl) {
8799 clang::CXXRecordDecl *cxx_record_decl =
8800 llvm::dyn_cast_or_null<clang::CXXRecordDecl>(tag_decl);
8801
8802 if (cxx_record_decl) {
8803 if (!cxx_record_decl->isCompleteDefinition())
8804 cxx_record_decl->completeDefinition();
8805 cxx_record_decl->setHasLoadedFieldsFromExternalStorage(true);
8806 cxx_record_decl->setHasExternalLexicalStorage(false);
8807 cxx_record_decl->setHasExternalVisibleStorage(false);
8808 return true;
8809 }
8810 }
8811 }
8812
8813 const clang::EnumType *enutype = qual_type->getAs<clang::EnumType>();
8814
8815 if (enutype) {
8816 clang::EnumDecl *enum_decl = enutype->getDecl();
8817
8818 if (enum_decl) {
8819 if (!enum_decl->isCompleteDefinition()) {
8820 ClangASTContext *lldb_ast =
8821 llvm::dyn_cast<ClangASTContext>(type.GetTypeSystem());
8822 if (lldb_ast == nullptr)
8823 return false;
8824 clang::ASTContext *ast = lldb_ast->getASTContext();
8825
8826 /// TODO This really needs to be fixed.
8827
8828 QualType integer_type(enum_decl->getIntegerType());
8829 if (!integer_type.isNull()) {
8830 unsigned NumPositiveBits = 1;
8831 unsigned NumNegativeBits = 0;
8832
8833 clang::QualType promotion_qual_type;
8834 // If the enum integer type is less than an integer in bit width,
8835 // then we must promote it to an integer size.
8836 if (ast->getTypeSize(enum_decl->getIntegerType()) <
8837 ast->getTypeSize(ast->IntTy)) {
8838 if (enum_decl->getIntegerType()->isSignedIntegerType())
8839 promotion_qual_type = ast->IntTy;
8840 else
8841 promotion_qual_type = ast->UnsignedIntTy;
8842 } else
8843 promotion_qual_type = enum_decl->getIntegerType();
8844
8845 enum_decl->completeDefinition(enum_decl->getIntegerType(),
8846 promotion_qual_type, NumPositiveBits,
8847 NumNegativeBits);
8848 }
8849 }
8850 return true;
8851 }
8852 }
8853 }
8854 return false;
8855}
8856
8857clang::EnumConstantDecl *ClangASTContext::AddEnumerationValueToEnumerationType(
8858 lldb::opaque_compiler_type_t type,
8859 const CompilerType &enumerator_clang_type, const Declaration &decl,
8860 const char *name, int64_t enum_value, uint32_t enum_value_bit_size) {
8861 if (type && enumerator_clang_type.IsValid() && name && name[0]) {
8862 clang::QualType enum_qual_type(GetCanonicalQualType(type));
8863
8864 bool is_signed = false;
8865 enumerator_clang_type.IsIntegerType(is_signed);
8866 const clang::Type *clang_type = enum_qual_type.getTypePtr();
8867 if (clang_type) {
8868 const clang::EnumType *enutype =
8869 llvm::dyn_cast<clang::EnumType>(clang_type);
8870
8871 if (enutype) {
8872 llvm::APSInt enum_llvm_apsint(enum_value_bit_size, is_signed);
8873 enum_llvm_apsint = enum_value;
8874 clang::EnumConstantDecl *enumerator_decl =
8875 clang::EnumConstantDecl::Create(
8876 *getASTContext(), enutype->getDecl(), clang::SourceLocation(),
8877 name ? &getASTContext()->Idents.get(name)
8878 : nullptr, // Identifier
8879 ClangUtil::GetQualType(enumerator_clang_type),
8880 nullptr, enum_llvm_apsint);
8881
8882 if (enumerator_decl) {
8883 enutype->getDecl()->addDecl(enumerator_decl);
8884
8885#ifdef LLDB_CONFIGURATION_DEBUG
8886 VerifyDecl(enumerator_decl);
8887#endif
8888
8889 return enumerator_decl;
8890 }
8891 }
8892 }
8893 }
8894 return nullptr;
8895}
8896
8897CompilerType
8898ClangASTContext::GetEnumerationIntegerType(lldb::opaque_compiler_type_t type) {
8899 clang::QualType enum_qual_type(GetCanonicalQualType(type));
8900 const clang::Type *clang_type = enum_qual_type.getTypePtr();
8901 if (clang_type) {
8902 const clang::EnumType *enutype =
8903 llvm::dyn_cast<clang::EnumType>(clang_type);
8904 if (enutype) {
8905 clang::EnumDecl *enum_decl = enutype->getDecl();
8906 if (enum_decl)
8907 return CompilerType(getASTContext(), enum_decl->getIntegerType());
8908 }
8909 }
8910 return CompilerType();
8911}
8912
8913CompilerType
8914ClangASTContext::CreateMemberPointerType(const CompilerType &type,
8915 const CompilerType &pointee_type) {
8916 if (type && pointee_type.IsValid() &&
8917 type.GetTypeSystem() == pointee_type.GetTypeSystem()) {
8918 ClangASTContext *ast =
8919 llvm::dyn_cast<ClangASTContext>(type.GetTypeSystem());
8920 if (!ast)
8921 return CompilerType();
8922 return CompilerType(ast->getASTContext(),
8923 ast->getASTContext()->getMemberPointerType(
8924 ClangUtil::GetQualType(pointee_type),
8925 ClangUtil::GetQualType(type).getTypePtr()));
8926 }
8927 return CompilerType();
8928}
8929
8930size_t
8931ClangASTContext::ConvertStringToFloatValue(lldb::opaque_compiler_type_t type,
8932 const char *s, uint8_t *dst,
8933 size_t dst_size) {
8934 if (type) {
8935 clang::QualType qual_type(GetCanonicalQualType(type));
8936 uint32_t count = 0;
8937 bool is_complex = false;
8938 if (IsFloatingPointType(type, count, is_complex)) {
8939 // TODO: handle complex and vector types
8940 if (count != 1)
8941 return false;
8942
8943 llvm::StringRef s_sref(s);
8944 llvm::APFloat ap_float(getASTContext()->getFloatTypeSemantics(qual_type),
8945 s_sref);
8946
8947 const uint64_t bit_size = getASTContext()->getTypeSize(qual_type);
8948 const uint64_t byte_size = bit_size / 8;
8949 if (dst_size >= byte_size) {
8950 Scalar scalar = ap_float.bitcastToAPInt().zextOrTrunc(
8951 llvm::NextPowerOf2(byte_size) * 8);
8952 lldb_private::Status get_data_error;
8953 if (scalar.GetAsMemoryData(dst, byte_size,
8954 lldb_private::endian::InlHostByteOrder(),
8955 get_data_error))
8956 return byte_size;
8957 }
8958 }
8959 }
8960 return 0;
8961}
8962
8963//----------------------------------------------------------------------
8964// Dumping types
8965//----------------------------------------------------------------------
8966#define DEPTH_INCREMENT2 2
8967
8968void ClangASTContext::DumpValue(
8969 lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, Stream *s,
8970 lldb::Format format, const DataExtractor &data,
8971 lldb::offset_t data_byte_offset, size_t data_byte_size,
8972 uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset, bool show_types,
8973 bool show_summary, bool verbose, uint32_t depth) {
8974 if (!type)
8975 return;
8976
8977 clang::QualType qual_type(GetQualType(type));
8978 switch (qual_type->getTypeClass()) {
8979 case clang::Type::Record:
8980 if (GetCompleteType(type)) {
8981 const clang::RecordType *record_type =
8982 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
8983 const clang::RecordDecl *record_decl = record_type->getDecl();
8984 assert(record_decl)((record_decl) ? static_cast<void> (0) : __assert_fail (
"record_decl", "/build/llvm-toolchain-snapshot-8~svn345461/tools/lldb/source/Symbol/ClangASTContext.cpp"
, 8984, __PRETTY_FUNCTION__))
;
8985 uint32_t field_bit_offset = 0;
8986 uint32_t field_byte_offset = 0;
8987 const clang::ASTRecordLayout &record_layout =
8988 getASTContext()->getASTRecordLayout(record_decl);
8989 uint32_t child_idx = 0;
8990
8991 const clang::CXXRecordDecl *cxx_record_decl =
8992 llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
8993 if (cxx_record_decl) {
8994 // We might have base classes to print out first
8995 clang::CXXRecordDecl::base_class_const_iterator base_class,
8996 base_class_end;
8997 for (base_class = cxx_record_decl->bases_begin(),
8998 base_class_end = cxx_record_decl->bases_end();
8999 base_class != base_class_end; ++base_class) {
9000 const clang::CXXRecordDecl *base_class_decl =
9001 llvm::cast<clang::CXXRecordDecl>(
9002 base_class->getType()->getAs<clang::RecordType>()->getDecl());
9003
9004 // Skip empty base classes
9005 if (verbose == false &&
9006 ClangASTContext::RecordHasFields(base_class_decl) == false)
9007 continue;
9008
9009 if (base_class->isVirtual())
9010 field_bit_offset =
9011 record_layout.getVBaseClassOffset(base_class_decl)
9012 .getQuantity() *
9013 8;
9014 else
9015 field_bit_offset = record_layout.getBaseClassOffset(base_class_decl)
9016 .getQuantity() *
9017 8;
9018 field_byte_offset = field_bit_offset / 8;
9019 assert(field_bit_offset % 8 == 0)((field_bit_offset % 8 == 0) ? static_cast<void> (0) : __assert_fail
("field_bit_offset % 8 == 0", "/build/llvm-toolchain-snapshot-8~svn345461/tools/lldb/source/Symbol/ClangASTContext.cpp"
, 9019, __PRETTY_FUNCTION__))
;
9020 if (child_idx == 0)
9021 s->PutChar('{');
9022 else
9023 s->PutChar(',');
9024
9025 clang::QualType base_class_qual_type = base_class->getType();
9026 std::string base_class_type_name(base_class_qual_type.getAsString());
9027
9028 // Indent and print the base class type name
9029 s->Format("\n{0}{1}", llvm::fmt_repeat(" ", depth + DEPTH_INCREMENT2),
9030 base_class_type_name);
9031
9032 clang::TypeInfo base_class_type_info =
9033 getASTContext()->getTypeInfo(base_class_qual_type);
9034
9035 // Dump the value of the member
9036 CompilerType base_clang_type(getASTContext(), base_class_qual_type);
9037 base_clang_type.DumpValue(
9038 exe_ctx,
9039 s, // Stream to dump to
9040 base_clang_type
9041 .GetFormat(), // The format with which to display the member
9042 data, // Data buffer containing all bytes for this type
9043 data_byte_offset + field_byte_offset, // Offset into "data" where
9044 // to grab value from
9045 base_class_type_info.Width / 8, // Size of this type in bytes
9046 0, // Bitfield bit size
9047 0, // Bitfield bit offset
9048 show_types, // Boolean indicating if we should show the variable
9049 // types
9050 show_summary, // Boolean indicating if we should show a summary
9051 // for the current type
9052 verbose, // Verbose output?
9053 depth + DEPTH_INCREMENT2); // Scope depth for any types that have
9054 // children
9055
9056 ++child_idx;
9057 }
9058 }
9059 uint32_t field_idx = 0;
9060 clang::RecordDecl::field_iterator field, field_end;
9061 for (field = record_decl->field_begin(),
9062 field_end = record_decl->field_end();
9063 field != field_end; ++field, ++field_idx, ++child_idx) {
9064 // Print the starting squiggly bracket (if this is the first member) or
9065 // comma (for member 2 and beyond) for the struct/union/class member.
9066 if (child_idx == 0)
9067 s->PutChar('{');
9068 else
9069 s->PutChar(',');
9070
9071 // Indent
9072 s->Printf("\n%*s", depth + DEPTH_INCREMENT2, "");
9073
9074 clang::QualType field_type = field->getType();
9075 // Print the member type if requested
9076 // Figure out the type byte size (field_type_info.first) and alignment
9077 // (field_type_info.second) from the AST context.
9078 clang::TypeInfo field_type_info =
9079 getASTContext()->getTypeInfo(field_type);
9080 assert(field_idx < record_layout.getFieldCount())((field_idx < record_layout.getFieldCount()) ? static_cast
<void> (0) : __assert_fail ("field_idx < record_layout.getFieldCount()"
, "/build/llvm-toolchain-snapshot-8~svn345461/tools/lldb/source/Symbol/ClangASTContext.cpp"
, 9080, __PRETTY_FUNCTION__))
;
9081 // Figure out the field offset within the current struct/union/class
9082 // type
9083 field_bit_offset = record_layout.getFieldOffset(field_idx);
9084 field_byte_offset = field_bit_offset / 8;
9085 uint32_t field_bitfield_bit_size = 0;
9086 uint32_t field_bitfield_bit_offset = 0;
9087 if (ClangASTContext::FieldIsBitfield(getASTContext(), *field,
9088 field_bitfield_bit_size))
9089 field_bitfield_bit_offset = field_bit_offset % 8;
9090
9091 if (show_types) {
9092 std::string field_type_name(field_type.getAsString());
9093 if (field_bitfield_bit_size > 0)
9094 s->Printf("(%s:%u) ", field_type_name.c_str(),
9095 field_bitfield_bit_size);
9096 else
9097 s->Printf("(%s) ", field_type_name.c_str());
9098 }
9099 // Print the member name and equal sign
9100 s->Printf("%s = ", field->getNameAsString().c_str());
9101
9102 // Dump the value of the member
9103 CompilerType field_clang_type(getASTContext(), field_type);
9104 field_clang_type.DumpValue(
9105 exe_ctx,
9106 s, // Stream to dump to
9107 field_clang_type
9108 .GetFormat(), // The format with which to display the member
9109 data, // Data buffer containing all bytes for this type
9110 data_byte_offset + field_byte_offset, // Offset into "data" where to
9111 // grab value from
9112 field_type_info.Width / 8, // Size of this type in bytes
9113 field_bitfield_bit_size, // Bitfield bit size
9114 field_bitfield_bit_offset, // Bitfield bit offset
9115 show_types, // Boolean indicating if we should show the variable
9116 // types
9117 show_summary, // Boolean indicating if we should show a summary for
9118 // the current type
9119 verbose, // Verbose output?
9120 depth + DEPTH_INCREMENT2); // Scope depth for any types that have
9121 // children
9122 }
9123
9124 // Indent the trailing squiggly bracket
9125 if (child_idx > 0)
9126 s->Printf("\n%*s}", depth, "");
9127 }
9128 return;
9129
9130 case clang::Type::Enum:
9131 if (GetCompleteType(type)) {
9132 const clang::EnumType *enutype =
9133 llvm::cast<clang::EnumType>(qual_type.getTypePtr());
9134 const clang::EnumDecl *enum_decl = enutype->getDecl();
9135 assert(enum_decl)((enum_decl) ? static_cast<void> (0) : __assert_fail ("enum_decl"
, "/build/llvm-toolchain-snapshot-8~svn345461/tools/lldb/source/Symbol/ClangASTContext.cpp"
, 9135, __PRETTY_FUNCTION__))
;
9136 clang::EnumDecl::enumerator_iterator enum_pos, enum_end_pos;
9137 lldb::offset_t offset = data_byte_offset;
9138 const int64_t enum_value = data.GetMaxU64Bitfield(
9139 &offset, data_byte_size, bitfield_bit_size, bitfield_bit_offset);
9140 for (enum_pos = enum_decl->enumerator_begin(),
9141 enum_end_pos = enum_decl->enumerator_end();
9142 enum_pos != enum_end_pos; ++enum_pos) {
9143 if (enum_pos->getInitVal() == enum_value) {
9144 s->Printf("%s", enum_pos->getNameAsString().c_str());
9145 return;
9146 }
9147 }
9148 // If we have gotten here we didn't get find the enumerator in the enum
9149 // decl, so just print the integer.
9150 s->Printf("%" PRIi64"l" "i", enum_value);
9151 }
9152 return;
9153
9154 case clang::Type::ConstantArray: {
9155 const clang::ConstantArrayType *array =
9156 llvm::cast<clang::ConstantArrayType>(qual_type.getTypePtr());
9157 bool is_array_of_characters = false;
9158 clang::QualType element_qual_type = array->getElementType();
9159
9160 const clang::Type *canonical_type =
9161 element_qual_type->getCanonicalTypeInternal().getTypePtr();
9162 if (canonical_type)
9163 is_array_of_characters = canonical_type->isCharType();
9164
9165 const uint64_t element_count = array->getSize().getLimitedValue();
9166
9167 clang::TypeInfo field_type_info =
9168 getASTContext()->getTypeInfo(element_qual_type);
9169
9170 uint32_t element_idx = 0;
9171 uint32_t element_offset = 0;
9172 uint64_t element_byte_size = field_type_info.Width / 8;
9173 uint32_t element_stride = element_byte_size;
9174
9175 if (is_array_of_characters) {
9176 s->PutChar('"');
9177 DumpDataExtractor(data, s, data_byte_offset, lldb::eFormatChar,
9178 element_byte_size, element_count, UINT32_MAX(4294967295U),
9179 LLDB_INVALID_ADDRESS(18446744073709551615UL), 0, 0);
9180 s->PutChar('"');
9181 return;
9182 } else {
9183 CompilerType element_clang_type(getASTContext(), element_qual_type);
9184 lldb::Format element_format = element_clang_type.GetFormat();
9185
9186 for (element_idx = 0; element_idx < element_count; ++element_idx) {
9187 // Print the starting squiggly bracket (if this is the first member) or
9188 // comman (for member 2 and beyong) for the struct/union/class member.
9189 if (element_idx == 0)
9190 s->PutChar('{');
9191 else
9192 s->PutChar(',');
9193
9194 // Indent and print the index
9195 s->Printf("\n%*s[%u] ", depth + DEPTH_INCREMENT2, "", element_idx);
9196
9197 // Figure out the field offset within the current struct/union/class
9198 // type
9199 element_offset = element_idx * element_stride;
9200
9201 // Dump the value of the member
9202 element_clang_type.DumpValue(
9203 exe_ctx,
9204 s, // Stream to dump to
9205 element_format, // The format with which to display the element
9206 data, // Data buffer containing all bytes for this type
9207 data_byte_offset +
9208 element_offset, // Offset into "data" where to grab value from
9209 element_byte_size, // Size of this type in bytes
9210 0, // Bitfield bit size
9211 0, // Bitfield bit offset
9212 show_types, // Boolean indicating if we should show the variable
9213 // types
9214 show_summary, // Boolean indicating if we should show a summary for
9215 // the current type
9216 verbose, // Verbose output?
9217 depth + DEPTH_INCREMENT2); // Scope depth for any types that have
9218 // children
9219 }
9220
9221 // Indent the trailing squiggly bracket
9222 if (element_idx > 0)
9223 s->Printf("\n%*s}", depth, "");
9224 }
9225 }
9226 return;
9227
9228 case clang::Type::Typedef: {
9229 clang::QualType typedef_qual_type =
9230 llvm::cast<clang::TypedefType>(qual_type)
9231 ->getDecl()
9232 ->getUnderlyingType();
9233
9234 CompilerType typedef_clang_type(getASTContext(), typedef_qual_type);
9235 lldb::Format typedef_format = typedef_clang_type.GetFormat();
9236 clang::TypeInfo typedef_type_info =
9237 getASTContext()->getTypeInfo(typedef_qual_type);
9238 uint64_t typedef_byte_size = typedef_type_info.Width / 8;
9239
9240 return typedef_clang_type.DumpValue(
9241 exe_ctx,
9242 s, // Stream to dump to
9243 typedef_format, // The format with which to display the element
9244 data, // Data buffer containing all bytes for this type
9245 data_byte_offset, // Offset into "data" where to grab value from
9246 typedef_byte_size, // Size of this type in bytes
9247 bitfield_bit_size, // Bitfield bit size
9248 bitfield_bit_offset, // Bitfield bit offset
9249 show_types, // Boolean indicating if we should show the variable types
9250 show_summary, // Boolean indicating if we should show a summary for the
9251 // current type
9252 verbose, // Verbose output?
9253 depth); // Scope depth for any types that have children
9254 } break;
9255
9256 case clang::Type::Auto: {
9257 clang::QualType elaborated_qual_type =
9258 llvm::cast<clang::AutoType>(qual_type)->getDeducedType();
9259 CompilerType elaborated_clang_type(getASTContext(), elaborated_qual_type);
9260 lldb::Format elaborated_format = elaborated_clang_type.GetFormat();
9261 clang::TypeInfo elaborated_type_info =
9262 getASTContext()->getTypeInfo(elaborated_qual_type);
9263 uint64_t elaborated_byte_size = elaborated_type_info.Width / 8;
9264
9265 return elaborated_clang_type.DumpValue(
9266 exe_ctx,
9267 s, // Stream to dump to
9268 elaborated_format, // The format with which to display the element
9269 data, // Data buffer containing all bytes for this type
9270 data_byte_offset, // Offset into "data" where to grab value from
9271 elaborated_byte_size, // Size of this type in bytes
9272 bitfield_bit_size, // Bitfield bit size
9273 bitfield_bit_offset, // Bitfield bit offset
9274 show_types, // Boolean indicating if we should show the variable types
9275 show_summary, // Boolean indicating if we should show a summary for the
9276 // current type
9277 verbose, // Verbose output?
9278 depth); // Scope depth for any types that have children
9279 } break;
9280
9281 case clang::Type::Elaborated: {
9282 clang::QualType elaborated_qual_type =
9283 llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType();
9284 CompilerType elaborated_clang_type(getASTContext(), elaborated_qual_type);
9285 lldb::Format elaborated_format = elaborated_clang_type.GetFormat();
9286 clang::TypeInfo elaborated_type_info =
9287 getASTContext()->getTypeInfo(elaborated_qual_type);
9288 uint64_t elaborated_byte_size = elaborated_type_info.Width / 8;
9289
9290 return elaborated_clang_type.DumpValue(
9291 exe_ctx,
9292 s, // Stream to dump to
9293 elaborated_format, // The format with which to display the element
9294 data, // Data buffer containing all bytes for this type
9295 data_byte_offset, // Offset into "data" where to grab value from
9296 elaborated_byte_size, // Size of this type in bytes
9297 bitfield_bit_size, // Bitfield bit size
9298 bitfield_bit_offset, // Bitfield bit offset
9299 show_types, // Boolean indicating if we should show the variable types
9300 show_summary, // Boolean indicating if we should show a summary for the
9301 // current type
9302 verbose, // Verbose output?
9303 depth); // Scope depth for any types that have children
9304 } break;
9305
9306 case clang::Type::Paren: {
9307 clang::QualType desugar_qual_type =
9308 llvm::cast<clang::ParenType>(qual_type)->desugar();
9309 CompilerType desugar_clang_type(getASTContext(), desugar_qual_type);
9310
9311 lldb::Format desugar_format = desugar_clang_type.GetFormat();
9312 clang::TypeInfo desugar_type_info =
9313 getASTContext()->getTypeInfo(desugar_qual_type);
9314 uint64_t desugar_byte_size = desugar_type_info.Width / 8;
9315
9316 return desugar_clang_type.DumpValue(
9317 exe_ctx,
9318 s, // Stream to dump to
9319 desugar_format, // The format with which to display the element
9320 data, // Data buffer containing all bytes for this type
9321 data_byte_offset, // Offset into "data" where to grab value from
9322 desugar_byte_size, // Size of this type in bytes
9323 bitfield_bit_size, // Bitfield bit size
9324 bitfield_bit_offset, // Bitfield bit offset
9325 show_types, // Boolean indicating if we should show the variable types
9326 show_summary, // Boolean indicating if we should show a summary for the
9327 // current type
9328 verbose, // Verbose output?
9329 depth); // Scope depth for any types that have children
9330 } break;
9331
9332 default:
9333 // We are down to a scalar type that we just need to display.
9334 DumpDataExtractor(data, s, data_byte_offset, format, data_byte_size, 1,
9335 UINT32_MAX(4294967295U), LLDB_INVALID_ADDRESS(18446744073709551615UL), bitfield_bit_size,
9336 bitfield_bit_offset);
9337
9338 if (show_summary)
9339 DumpSummary(type, exe_ctx, s, data, data_byte_offset, data_byte_size);
9340 break;
9341 }
9342}
9343
9344bool ClangASTContext::DumpTypeValue(
9345 lldb::opaque_compiler_type_t type, Stream *s, lldb::Format format,
9346 const DataExtractor &data, lldb::offset_t byte_offset, size_t byte_size,
9347 uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset,
9348 ExecutionContextScope *exe_scope) {
9349 if (!type)
9350 return false;
9351 if (IsAggregateType(type)) {
9352 return false;
9353 } else {
9354 clang::QualType qual_type(GetQualType(type));
9355
9356 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
9357 switch (type_class) {
9358 case clang::Type::Typedef: {
9359 clang::QualType typedef_qual_type =
9360 llvm::cast<clang::TypedefType>(qual_type)
9361 ->getDecl()
9362 ->getUnderlyingType();
9363 CompilerType typedef_clang_type(getASTContext(), typedef_qual_type);
9364 if (format == eFormatDefault)
9365 format = typedef_clang_type.GetFormat();
9366 clang::TypeInfo typedef_type_info =
9367 getASTContext()->getTypeInfo(typedef_qual_type);
9368 uint64_t typedef_byte_size = typedef_type_info.Width / 8;
9369
9370 return typedef_clang_type.DumpTypeValue(
9371 s,
9372 format, // The format with which to display the element
9373 data, // Data buffer containing all bytes for this type
9374 byte_offset, // Offset into "data" where to grab value from
9375 typedef_byte_size, // Size of this type in bytes
9376 bitfield_bit_size, // Size in bits of a bitfield value, if zero don't
9377 // treat as a bitfield
9378 bitfield_bit_offset, // Offset in bits of a bitfield value if
9379 // bitfield_bit_size != 0
9380 exe_scope);
9381 } break;
9382
9383 case clang::Type::Enum:
9384 // If our format is enum or default, show the enumeration value as its
9385 // enumeration string value, else just display it as requested.
9386 if ((format == eFormatEnum || format == eFormatDefault) &&
9387 GetCompleteType(type)) {
9388 const clang::EnumType *enutype =
9389 llvm::cast<clang::EnumType>(qual_type.getTypePtr());
9390 const clang::EnumDecl *enum_decl = enutype->getDecl();
9391 assert(enum_decl)((enum_decl) ? static_cast<void> (0) : __assert_fail ("enum_decl"
, "/build/llvm-toolchain-snapshot-8~svn345461/tools/lldb/source/Symbol/ClangASTContext.cpp"
, 9391, __PRETTY_FUNCTION__))
;
9392 clang::EnumDecl::enumerator_iterator enum_pos, enum_end_pos;
9393 const bool is_signed = qual_type->isSignedIntegerOrEnumerationType();
9394 lldb::offset_t offset = byte_offset;
9395 if (is_signed) {
9396 const int64_t enum_svalue = data.GetMaxS64Bitfield(
9397 &offset, byte_size, bitfield_bit_size, bitfield_bit_offset);
9398 for (enum_pos = enum_decl->enumerator_begin(),
9399 enum_end_pos = enum_decl->enumerator_end();
9400 enum_pos != enum_end_pos; ++enum_pos) {
9401 if (enum_pos->getInitVal().getSExtValue() == enum_svalue) {
9402 s->PutCString(enum_pos->getNameAsString());
9403 return true;
9404 }
9405 }
9406 // If we have gotten here we didn't get find the enumerator in the
9407 // enum decl, so just print the integer.
9408 s->Printf("%" PRIi64"l" "i", enum_svalue);
9409 } else {
9410 const uint64_t enum_uvalue = data.GetMaxU64Bitfield(
9411 &offset, byte_size, bitfield_bit_size, bitfield_bit_offset);
9412 for (enum_pos = enum_decl->enumerator_begin(),
9413 enum_end_pos = enum_decl->enumerator_end();
9414 enum_pos != enum_end_pos; ++enum_pos) {
9415 if (enum_pos->getInitVal().getZExtValue() == enum_uvalue) {
9416 s->PutCString(enum_pos->getNameAsString());
9417 return true;
9418 }
9419 }
9420 // If we have gotten here we didn't get find the enumerator in the
9421 // enum decl, so just print the integer.
9422 s->Printf("%" PRIu64"l" "u", enum_uvalue);
9423 }
9424 return true;
9425 }
9426 // format was not enum, just fall through and dump the value as
9427 // requested....
9428 LLVM_FALLTHROUGH[[clang::fallthrough]];
9429
9430 default:
9431 // We are down to a scalar type that we just need to display.
9432 {
9433 uint32_t item_count = 1;
9434 // A few formats, we might need to modify our size and count for
9435 // depending
9436 // on how we are trying to display the value...
9437 switch (format) {
9438 default:
9439 case eFormatBoolean:
9440 case eFormatBinary:
9441 case eFormatComplex:
9442 case eFormatCString: // NULL terminated C strings
9443 case eFormatDecimal:
9444 case eFormatEnum:
9445 case eFormatHex:
9446 case eFormatHexUppercase:
9447 case eFormatFloat:
9448 case eFormatOctal:
9449 case eFormatOSType:
9450 case eFormatUnsigned:
9451 case eFormatPointer:
9452 case eFormatVectorOfChar:
9453 case eFormatVectorOfSInt8:
9454 case eFormatVectorOfUInt8:
9455 case eFormatVectorOfSInt16:
9456 case eFormatVectorOfUInt16:
9457 case eFormatVectorOfSInt32:
9458 case eFormatVectorOfUInt32:
9459 case eFormatVectorOfSInt64:
9460 case eFormatVectorOfUInt64:
9461 case eFormatVectorOfFloat32:
9462 case eFormatVectorOfFloat64:
9463 case eFormatVectorOfUInt128:
9464 break;
9465
9466 case eFormatChar:
9467 case eFormatCharPrintable:
9468 case eFormatCharArray:
9469 case eFormatBytes:
9470 case eFormatBytesWithASCII:
9471 item_count = byte_size;
9472 byte_size = 1;
9473 break;
9474
9475 case eFormatUnicode16:
9476 item_count = byte_size / 2;
9477 byte_size = 2;
9478 break;
9479
9480 case eFormatUnicode32:
9481 item_count = byte_size / 4;
9482 byte_size = 4;
9483 break;
9484 }
9485 return DumpDataExtractor(data, s, byte_offset, format, byte_size,
9486 item_count, UINT32_MAX(4294967295U), LLDB_INVALID_ADDRESS(18446744073709551615UL),
9487 bitfield_bit_size, bitfield_bit_offset,
9488 exe_scope);
9489 }
9490 break;
9491 }
9492 }
9493 return 0;
9494}
9495
9496void ClangASTContext::DumpSummary(lldb::opaque_compiler_type_t type,
9497 ExecutionContext *exe_ctx, Stream *s,
9498 const lldb_private::DataExtractor &data,
9499 lldb::offset_t data_byte_offset,
9500 size_t data_byte_size) {
9501 uint32_t length = 0;
9502 if (IsCStringType(type, length)) {
9503 if (exe_ctx) {
9504 Process *process = exe_ctx->GetProcessPtr();
9505 if (process) {
9506 lldb::offset_t offset = data_byte_offset;
9507 lldb::addr_t pointer_address = data.GetMaxU64(&offset, data_byte_size);
9508 std::vector<uint8_t> buf;
9509 if (length > 0)
9510 buf.resize(length);
9511 else
9512 buf.resize(256);
9513
9514 DataExtractor cstr_data(&buf.front(), buf.size(),
9515 process->GetByteOrder(), 4);
9516 buf.back() = '\0';
9517 size_t bytes_read;
9518 size_t total_cstr_len = 0;
9519 Status error;
9520 while ((bytes_read = process->ReadMemory(pointer_address, &buf.front(),
9521 buf.size(), error)) > 0) {
9522 const size_t len = strlen((const char *)&buf.front());
9523 if (len == 0)
9524 break;
9525 if (total_cstr_len == 0)
9526 s->PutCString(" \"");
9527 DumpDataExtractor(cstr_data, s, 0, lldb::eFormatChar, 1, len,
9528 UINT32_MAX(4294967295U), LLDB_INVALID_ADDRESS(18446744073709551615UL), 0, 0);
9529 total_cstr_len += len;
9530 if (len < buf.size())
9531 break;
9532 pointer_address += total_cstr_len;
9533 }
9534 if (total_cstr_len > 0)
9535 s->PutChar('"');
9536 }
9537 }
9538 }
9539}
9540
9541void ClangASTContext::DumpTypeDescription(lldb::opaque_compiler_type_t type) {
9542 StreamFile s(stdoutstdout, false);
9543 DumpTypeDescription(type, &s);
9544 ClangASTMetadata *metadata =
9545 ClangASTContext::GetMetadata(getASTContext(), type);
9546 if (metadata) {
9547 metadata->Dump(&s);
9548 }
9549}
9550
9551void ClangASTContext::DumpTypeDescription(lldb::opaque_compiler_type_t type,
9552 Stream *s) {
9553 if (type) {
9554 clang::QualType qual_type(GetQualType(type));
9555
9556 llvm::SmallVector<char, 1024> buf;
9557 llvm::raw_svector_ostream llvm_ostrm(buf);
9558
9559 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
9560 switch (type_class) {
9561 case clang::Type::ObjCObject:
9562 case clang::Type::ObjCInterface: {
9563 GetCompleteType(type);
9564
9565 const clang::ObjCObjectType *objc_class_type =
9566 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
9567 assert(objc_class_type)((objc_class_type) ? static_cast<void> (0) : __assert_fail
("objc_class_type", "/build/llvm-toolchain-snapshot-8~svn345461/tools/lldb/source/Symbol/ClangASTContext.cpp"
, 9567, __PRETTY_FUNCTION__))
;
9568 if (objc_class_type) {
9569 clang::ObjCInterfaceDecl *class_interface_decl =
9570 objc_class_type->getInterface();
9571 if (class_interface_decl) {
9572 clang::PrintingPolicy policy = getASTContext()->getPrintingPolicy();
9573 class_interface_decl->print(llvm_ostrm, policy, s->GetIndentLevel());
9574 }
9575 }
9576 } break;
9577
9578 case clang::Type::Typedef: {
9579 const clang::TypedefType *typedef_type =
9580 qual_type->getAs<clang::TypedefType>();
9581 if (typedef_type) {
9582 const clang::TypedefNameDecl *typedef_decl = typedef_type->getDecl();
9583 std::string clang_typedef_name(
9584 typedef_decl->getQualifiedNameAsString());
9585 if (!clang_typedef_name.empty()) {
9586 s->PutCString("typedef ");
9587 s->PutCString(clang_typedef_name);
9588 }
9589 }
9590 } break;
9591
9592 case clang::Type::Auto:
9593 CompilerType(getASTContext(),
9594 llvm::cast<clang::AutoType>(qual_type)->getDeducedType())
9595 .DumpTypeDescription(s);
9596 return;
9597
9598 case clang::Type::Elaborated:
9599 CompilerType(getASTContext(),
9600 llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType())
9601 .DumpTypeDescription(s);
9602 return;
9603
9604 case clang::Type::Paren:
9605 CompilerType(getASTContext(),
9606 llvm::cast<clang::ParenType>(qual_type)->desugar())
9607 .DumpTypeDescription(s);
9608 return;
9609
9610 case clang::Type::Record: {
9611 GetCompleteType(type);
9612
9613 const clang::RecordType *record_type =
9614 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
9615 const clang::RecordDecl *record_decl = record_type->getDecl();
9616 const clang::CXXRecordDecl *cxx_record_decl =
9617 llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
9618
9619 if (cxx_record_decl)
9620 cxx_record_decl->print(llvm_ostrm, getASTContext()->getPrintingPolicy(),
9621 s->GetIndentLevel());
9622 else
9623 record_decl->print(llvm_ostrm, getASTContext()->getPrintingPolicy(),
9624 s->GetIndentLevel());
9625 } break;
9626
9627 default: {
9628 const clang::TagType *tag_type =
9629 llvm::dyn_cast<clang::TagType>(qual_type.getTypePtr());
9630 if (tag_type) {
9631 clang::TagDecl *tag_decl = tag_type->getDecl();
9632 if (tag_decl)
9633 tag_decl->print(llvm_ostrm, 0);
9634 } else {
9635 std::string clang_type_name(qual_type.getAsString());
9636 if (!clang_type_name.empty())
9637 s->PutCString(clang_type_name);
9638 }
9639 }
9640 }
9641
9642 if (buf.size() > 0) {
9643 s->Write(buf.data(), buf.size());
9644 }
9645 }
9646}
9647
9648void ClangASTContext::DumpTypeName(const CompilerType &type) {
9649 if (ClangUtil::IsClangType(type)) {
9650 clang::QualType qual_type(
9651 ClangUtil::GetCanonicalQualType(ClangUtil::RemoveFastQualifiers(type)));
9652
9653 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
9654 switch (type_class) {
9655 case clang::Type::Record: {
9656 const clang::CXXRecordDecl *cxx_record_decl =
9657 qual_type->getAsCXXRecordDecl();
9658 if (cxx_record_decl)
9659 printf("class %s", cxx_record_decl->getName().str().c_str());
9660 } break;
9661
9662 case clang::Type::Enum: {
9663 clang::EnumDecl *enum_decl =
9664 llvm::cast<clang::EnumType>(qual_type)->getDecl();
9665 if (enum_decl) {
9666 printf("enum %s", enum_decl->getName().str().c_str());
9667 }
9668 } break;
9669
9670 case clang::Type::ObjCObject:
9671 case clang::Type::ObjCInterface: {
9672 const clang::ObjCObjectType *objc_class_type =
9673 llvm::dyn_cast<clang::ObjCObjectType>(qual_type);
9674 if (objc_class_type) {
9675 clang::ObjCInterfaceDecl *class_interface_decl =
9676 objc_class_type->getInterface();
9677 // We currently can't complete objective C types through the newly
9678 // added ASTContext because it only supports TagDecl objects right
9679 // now...
9680 if (class_interface_decl)
9681 printf("@class %s", class_interface_decl->getName().str().c_str());
9682 }
9683 } break;
9684
9685 case clang::Type::Typedef:
9686 printf("typedef %s", llvm::cast<clang::TypedefType>(qual_type)
9687 ->getDecl()
9688 ->getName()
9689 .str()
9690 .c_str());
9691 break;
9692
9693 case clang::Type::Auto:
9694 printf("auto ");
9695 return DumpTypeName(CompilerType(type.GetTypeSystem(),
9696 llvm::cast<clang::AutoType>(qual_type)
9697 ->getDeducedType()
9698 .getAsOpaquePtr()));
9699
9700 case clang::Type::Elaborated:
9701 printf("elaborated ");
9702 return DumpTypeName(CompilerType(
9703 type.GetTypeSystem(), llvm::cast<clang::ElaboratedType>(qual_type)
9704 ->getNamedType()
9705 .getAsOpaquePtr()));
9706
9707 case clang::Type::Paren:
9708 printf("paren ");
9709 return DumpTypeName(CompilerType(
9710 type.GetTypeSystem(),
9711 llvm::cast<clang::ParenType>(qual_type)->desugar().getAsOpaquePtr()));
9712
9713 default:
9714 printf("ClangASTContext::DumpTypeName() type_class = %u", type_class);
9715 break;
9716 }
9717 }
9718}
9719
9720clang::ClassTemplateDecl *ClangASTContext::ParseClassTemplateDecl(
9721 clang::DeclContext *decl_ctx, lldb::AccessType access_type,
9722 const char *parent_name, int tag_decl_kind,
9723 const ClangASTContext::TemplateParameterInfos &template_param_infos) {
9724 if (template_param_infos.IsValid()) {
9725 std::string template_basename(parent_name);
9726 template_basename.erase(template_basename.find('<'));
9727
9728 return CreateClassTemplateDecl(decl_ctx, access_type,
9729 template_basename.c_str(), tag_decl_kind,
9730 template_param_infos);
9731 }
9732 return NULL__null;
9733}
9734
9735void ClangASTContext::CompleteTagDecl(void *baton, clang::TagDecl *decl) {
9736 ClangASTContext *ast = (ClangASTContext *)baton;
9737 SymbolFile *sym_file = ast->GetSymbolFile();
9738 if (sym_file) {
9739 CompilerType clang_type = GetTypeForDecl(decl);
9740 if (clang_type)
9741 sym_file->CompleteType(clang_type);
9742 }
9743}
9744
9745void ClangASTContext::CompleteObjCInterfaceDecl(
9746 void *baton, clang::ObjCInterfaceDecl *decl) {
9747 ClangASTContext *ast = (ClangASTContext *)baton;
9748 SymbolFile *sym_file = ast->GetSymbolFile();
9749 if (sym_file) {
9750 CompilerType clang_type = GetTypeForDecl(decl);
9751 if (clang_type)
9752 sym_file->CompleteType(clang_type);
9753 }
9754}
9755
9756DWARFASTParser *ClangASTContext::GetDWARFParser() {
9757 if (!m_dwarf_ast_parser_ap)
9758 m_dwarf_ast_parser_ap.reset(new DWARFASTParserClang(*this));
9759 return m_dwarf_ast_parser_ap.get();
9760}
9761
9762PDBASTParser *ClangASTContext::GetPDBParser() {
9763 if (!m_pdb_ast_parser_ap)
9764 m_pdb_ast_parser_ap.reset(new PDBASTParser(*this));
9765 return m_pdb_ast_parser_ap.get();
9766}
9767
9768bool ClangASTContext::LayoutRecordType(
9769 void *baton, const clang::RecordDecl *record_decl, uint64_t &bit_size,
9770 uint64_t &alignment,
9771 llvm::DenseMap<const clang::FieldDecl *, uint64_t> &field_offsets,
9772 llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits>
9773 &base_offsets,
9774 llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits>
9775 &vbase_offsets) {
9776 ClangASTContext *ast = (ClangASTContext *)baton;
9777 lldb_private::ClangASTImporter *importer = nullptr;
9778 if (ast->m_dwarf_ast_parser_ap)
9779 importer = &ast->m_dwarf_ast_parser_ap->GetClangASTImporter();
9780 if (!importer && ast->m_pdb_ast_parser_ap)
9781 importer = &ast->m_pdb_ast_parser_ap->GetClangASTImporter();
9782 if (!importer)
9783 return false;
9784
9785 return importer->LayoutRecordType(record_decl, bit_size, alignment,
9786 field_offsets, base_offsets, vbase_offsets);
9787}
9788
9789//----------------------------------------------------------------------
9790// CompilerDecl override functions
9791//----------------------------------------------------------------------
9792
9793ConstString ClangASTContext::DeclGetName(void *opaque_decl) {
9794 if (opaque_decl) {
9795 clang::NamedDecl *nd =
9796 llvm::dyn_cast<NamedDecl>((clang::Decl *)opaque_decl);
9797 if (nd != nullptr)
9798 return ConstString(nd->getDeclName().getAsString());
9799 }
9800 return ConstString();
9801}
9802
9803ConstString ClangASTContext::DeclGetMangledName(void *opaque_decl) {
9804 if (opaque_decl) {
9805 clang::NamedDecl *nd =
9806 llvm::dyn_cast<clang::NamedDecl>((clang::Decl *)opaque_decl);
9807 if (nd != nullptr && !llvm::isa<clang::ObjCMethodDecl>(nd)) {
9808 clang::MangleContext *mc = getMangleContext();
9809 if (mc && mc->shouldMangleCXXName(nd)) {
9810 llvm::SmallVector<char, 1024> buf;
9811 llvm::raw_svector_ostream llvm_ostrm(buf);
9812 if (llvm::isa<clang::CXXConstructorDecl>(nd)) {
9813 mc->mangleCXXCtor(llvm::dyn_cast<clang::CXXConstructorDecl>(nd),
9814 Ctor_Complete, llvm_ostrm);
9815 } else if (llvm::isa<clang::CXXDestructorDecl>(nd)) {
9816 mc->mangleCXXDtor(llvm::dyn_cast<clang::CXXDestructorDecl>(nd),
9817 Dtor_Complete, llvm_ostrm);
9818 } else {
9819 mc->mangleName(nd, llvm_ostrm);
9820 }
9821 if (buf.size() > 0)
9822 return ConstString(buf.data(), buf.size());
9823 }
9824 }
9825 }
9826 return ConstString();
9827}
9828
9829CompilerDeclContext ClangASTContext::DeclGetDeclContext(void *opaque_decl) {
9830 if (opaque_decl)
9831 return CompilerDeclContext(this,
9832 ((clang::Decl *)opaque_decl)->getDeclContext());
9833 else
9834 return CompilerDeclContext();
9835}
9836
9837CompilerType ClangASTContext::DeclGetFunctionReturnType(void *opaque_decl) {
9838 if (clang::FunctionDecl *func_decl =
9839 llvm::dyn_cast<clang::FunctionDecl>((clang::Decl *)opaque_decl))
9840 return CompilerType(this, func_decl->getReturnType().getAsOpaquePtr());
9841 if (clang::ObjCMethodDecl *objc_method =
9842 llvm::dyn_cast<clang::ObjCMethodDecl>((clang::Decl *)opaque_decl))
9843 return CompilerType(this, objc_method->getReturnType().getAsOpaquePtr());
9844 else
9845 return CompilerType();
9846}
9847
9848size_t ClangASTContext::DeclGetFunctionNumArguments(void *opaque_decl) {
9849 if (clang::FunctionDecl *func_decl =
9850 llvm::dyn_cast<clang::FunctionDecl>((clang::Decl *)opaque_decl))
9851 return func_decl->param_size();
9852 if (clang::ObjCMethodDecl *objc_method =
9853 llvm::dyn_cast<clang::ObjCMethodDecl>((clang::Decl *)opaque_decl))
9854 return objc_method->param_size();
9855 else
9856 return 0;
9857}
9858
9859CompilerType ClangASTContext::DeclGetFunctionArgumentType(void *opaque_decl,
9860 size_t idx) {
9861 if (clang::FunctionDecl *func_decl =
9862 llvm::dyn_cast<clang::FunctionDecl>((clang::Decl *)opaque_decl)) {
9863 if (idx < func_decl->param_size()) {
9864 ParmVarDecl *var_decl = func_decl->getParamDecl(idx);
9865 if (var_decl)
9866 return CompilerType(this, var_decl->getOriginalType().getAsOpaquePtr());
9867 }
9868 } else if (clang::ObjCMethodDecl *objc_method =
9869 llvm::dyn_cast<clang::ObjCMethodDecl>(
9870 (clang::Decl *)opaque_decl)) {
9871 if (idx < objc_method->param_size())
9872 return CompilerType(
9873 this,
9874 objc_method->parameters()[idx]->getOriginalType().getAsOpaquePtr());
9875 }
9876 return CompilerType();
9877}
9878
9879//----------------------------------------------------------------------
9880// CompilerDeclContext functions
9881//----------------------------------------------------------------------
9882
9883std::vector<CompilerDecl> ClangASTContext::DeclContextFindDeclByName(
9884 void *opaque_decl_ctx, ConstString name, const bool ignore_using_decls) {
9885 std::vector<CompilerDecl> found_decls;
9886 if (opaque_decl_ctx) {
9887 DeclContext *root_decl_ctx = (DeclContext *)opaque_decl_ctx;
9888 std::set<DeclContext *> searched;
9889 std::multimap<DeclContext *, DeclContext *> search_queue;
9890 SymbolFile *symbol_file = GetSymbolFile();
9891
9892 for (clang::DeclContext *decl_context = root_decl_ctx;
9893 decl_context != nullptr && found_decls.empty();
9894 decl_context = decl_context->getParent()) {
9895 search_queue.insert(std::make_pair(decl_context, decl_context));
9896
9897 for (auto it = search_queue.find(decl_context); it != search_queue.end();
9898 it++) {
9899 if (!searched.insert(it->second).second)
9900 continue;
9901 symbol_file->ParseDeclsForContext(
9902 CompilerDeclContext(this, it->second));
9903
9904 for (clang::Decl *child : it->second->decls()) {
9905 if (clang::UsingDirectiveDecl *ud =
9906 llvm::dyn_cast<clang::UsingDirectiveDecl>(child)) {
9907 if (ignore_using_decls)
9908 continue;
9909 clang::DeclContext *from = ud->getCommonAncestor();
9910 if (searched.find(ud->getNominatedNamespace()) == searched.end())
9911 search_queue.insert(
9912 std::make_pair(from, ud->getNominatedNamespace()));
9913 } else if (clang::UsingDecl *ud =
9914 llvm::dyn_cast<clang::UsingDecl>(child)) {
9915 if (ignore_using_decls)
9916 continue;
9917 for (clang::UsingShadowDecl *usd : ud->shadows()) {
9918 clang::Decl *target = usd->getTargetDecl();
9919 if (clang::NamedDecl *nd =
9920 llvm::dyn_cast<clang::NamedDecl>(target)) {
9921 IdentifierInfo *ii = nd->getIdentifier();
9922 if (ii != nullptr &&
9923 ii->getName().equals(name.AsCString(nullptr)))
9924 found_decls.push_back(CompilerDecl(this, nd));
9925 }
9926 }
9927 } else if (clang::NamedDecl *nd =
9928 llvm::dyn_cast<clang::NamedDecl>(child)) {
9929 IdentifierInfo *ii = nd->getIdentifier();
9930 if (ii != nullptr && ii->getName().equals(name.AsCString(nullptr)))
9931 found_decls.push_back(CompilerDecl(this, nd));
9932 }
9933 }
9934 }
9935 }
9936 }
9937 return found_decls;
9938}
9939
9940// Look for child_decl_ctx's lookup scope in frame_decl_ctx and its parents,
9941// and return the number of levels it took to find it, or
9942// LLDB_INVALID_DECL_LEVEL if not found. If the decl was imported via a using
9943// declaration, its name and/or type, if set, will be used to check that the
9944// decl found in the scope is a match.
9945//
9946// The optional name is required by languages (like C++) to handle using
9947// declarations like:
9948//
9949// void poo();
9950// namespace ns {
9951// void foo();
9952// void goo();
9953// }
9954// void bar() {
9955// using ns::foo;
9956// // CountDeclLevels returns 0 for 'foo', 1 for 'poo', and
9957// // LLDB_INVALID_DECL_LEVEL for 'goo'.
9958// }
9959//
9960// The optional type is useful in the case that there's a specific overload
9961// that we're looking for that might otherwise be shadowed, like:
9962//
9963// void foo(int);
9964// namespace ns {
9965// void foo();
9966// }
9967// void bar() {
9968// using ns::foo;
9969// // CountDeclLevels returns 0 for { 'foo', void() },
9970// // 1 for { 'foo', void(int) }, and
9971// // LLDB_INVALID_DECL_LEVEL for { 'foo', void(int, int) }.
9972// }
9973//
9974// NOTE: Because file statics are at the TranslationUnit along with globals, a
9975// function at file scope will return the same level as a function at global
9976// scope. Ideally we'd like to treat the file scope as an additional scope just
9977// below the global scope. More work needs to be done to recognise that, if
9978// the decl we're trying to look up is static, we should compare its source
9979// file with that of the current scope and return a lower number for it.
9980uint32_t ClangASTContext::CountDeclLevels(clang::DeclContext *frame_decl_ctx,
9981 clang::DeclContext *child_decl_ctx,
9982 ConstString *child_name,
9983 CompilerType *child_type) {
9984 if (frame_decl_ctx) {
9985 std::set<DeclContext *> searched;
9986 std::multimap<DeclContext *, DeclContext *> search_queue;
9987 SymbolFile *symbol_file = GetSymbolFile();
9988
9989 // Get the lookup scope for the decl we're trying to find.
9990 clang::DeclContext *parent_decl_ctx = child_decl_ctx->getParent();
9991
9992 // Look for it in our scope's decl context and its parents.
9993 uint32_t level = 0;
9994 for (clang::DeclContext *decl_ctx = frame_decl_ctx; decl_ctx != nullptr;
9995 decl_ctx = decl_ctx->getParent()) {
9996 if (!decl_ctx->isLookupContext())
9997 continue;
9998 if (decl_ctx == parent_decl_ctx)
9999 // Found it!
10000 return level;
10001 search_queue.insert(std::make_pair(decl_ctx, decl_ctx));
10002 for (auto it = search_queue.find(decl_ctx); it != search_queue.end();
10003 it++) {
10004 if (searched.find(it->second) != searched.end())
10005 continue;
10006
10007 // Currently DWARF has one shared translation unit for all Decls at top
10008 // level, so this would erroneously find using statements anywhere. So
10009 // don't look at the top-level translation unit.
10010 // TODO fix this and add a testcase that depends on it.
10011
10012 if (llvm::isa<clang::TranslationUnitDecl>(it->second))
10013 continue;
10014
10015 searched.insert(it->second);
10016 symbol_file->ParseDeclsForContext(
10017 CompilerDeclContext(this, it->second));
10018
10019 for (clang::Decl *child : it->second->decls()) {
10020 if (clang::UsingDirectiveDecl *ud =
10021 llvm::dyn_cast<clang::UsingDirectiveDecl>(child)) {
10022 clang::DeclContext *ns = ud->getNominatedNamespace();
10023 if (ns == parent_decl_ctx)
10024 // Found it!
10025 return level;
10026 clang::DeclContext *from = ud->getCommonAncestor();
10027 if (searched.find(ns) == searched.end())
10028 search_queue.insert(std::make_pair(from, ns));
10029 } else if (child_name) {
10030 if (clang::UsingDecl *ud =
10031 llvm::dyn_cast<clang::UsingDecl>(child)) {
10032 for (clang::UsingShadowDecl *usd : ud->shadows()) {
10033 clang::Decl *target = usd->getTargetDecl();
10034 clang::NamedDecl *nd = llvm::dyn_cast<clang::NamedDecl>(target);
10035 if (!nd)
10036 continue;
10037 // Check names.
10038 IdentifierInfo *ii = nd->getIdentifier();
10039 if (ii == nullptr ||
10040 !ii->getName().equals(child_name->AsCString(nullptr)))
10041 continue;
10042 // Check types, if one was provided.
10043 if (child_type) {
10044 CompilerType clang_type = ClangASTContext::GetTypeForDecl(nd);
10045 if (!AreTypesSame(clang_type, *child_type,
10046 /*ignore_qualifiers=*/true))
10047 continue;
10048 }
10049 // Found it!
10050 return level;
10051 }
10052 }
10053 }
10054 }
10055 }
10056 ++level;
10057 }
10058 }
10059 return LLDB_INVALID_DECL_LEVEL(4294967295U);
10060}
10061
10062bool ClangASTContext::DeclContextIsStructUnionOrClass(void *opaque_decl_ctx) {
10063 if (opaque_decl_ctx)
10064 return ((clang::DeclContext *)opaque_decl_ctx)->isRecord();
10065 else
10066 return false;
10067}
10068
10069ConstString ClangASTContext::DeclContextGetName(void *opaque_decl_ctx) {
10070 if (opaque_decl_ctx) {
10071 clang::NamedDecl *named_decl =
10072 llvm::dyn_cast<clang::NamedDecl>((clang::DeclContext *)opaque_decl_ctx);
10073 if (named_decl)
10074 return ConstString(named_decl->getName());
10075 }
10076 return ConstString();
10077}
10078
10079ConstString
10080ClangASTContext::DeclContextGetScopeQualifiedName(void *opaque_decl_ctx) {
10081 if (opaque_decl_ctx) {
10082 clang::NamedDecl *named_decl =
10083 llvm::dyn_cast<clang::NamedDecl>((clang::DeclContext *)opaque_decl_ctx);
10084 if (named_decl)
10085 return ConstString(
10086 llvm::StringRef(named_decl->getQualifiedNameAsString()));
10087 }
10088 return ConstString();
10089}
10090
10091bool ClangASTContext::DeclContextIsClassMethod(
10092 void *opaque_decl_ctx, lldb::LanguageType *language_ptr,
10093 bool *is_instance_method_ptr, ConstString *language_object_name_ptr) {
10094 if (opaque_decl_ctx) {
10095 clang::DeclContext *decl_ctx = (clang::DeclContext *)opaque_decl_ctx;
10096 if (ObjCMethodDecl *objc_method =
10097 llvm::dyn_cast<clang::ObjCMethodDecl>(decl_ctx)) {
10098 if (is_instance_method_ptr)
10099 *is_instance_method_ptr = objc_method->isInstanceMethod();
10100 if (language_ptr)
10101 *language_ptr = eLanguageTypeObjC;
10102 if (language_object_name_ptr)
10103 language_object_name_ptr->SetCString("self");
10104 return true;
10105 } else if (CXXMethodDecl *cxx_method =
10106 llvm::dyn_cast<clang::CXXMethodDecl>(decl_ctx)) {
10107 if (is_instance_method_ptr)
10108 *is_instance_method_ptr = cxx_method->isInstance();
10109 if (language_ptr)
10110 *language_ptr = eLanguageTypeC_plus_plus;
10111 if (language_object_name_ptr)
10112 language_object_name_ptr->SetCString("this");
10113 return true;
10114 } else if (clang::FunctionDecl *function_decl =
10115 llvm::dyn_cast<clang::FunctionDecl>(decl_ctx)) {
10116 ClangASTMetadata *metadata =
10117 GetMetadata(&decl_ctx->getParentASTContext(), function_decl);
10118 if (metadata && metadata->HasObjectPtr()) {
10119 if (is_instance_method_ptr)
10120 *is_instance_method_ptr = true;
10121 if (language_ptr)
10122 *language_ptr = eLanguageTypeObjC;
10123 if (language_object_name_ptr)
10124 language_object_name_ptr->SetCString(metadata->GetObjectPtrName());
10125 return true;
10126 }
10127 }
10128 }
10129 return false;
10130}
10131
10132clang::DeclContext *
10133ClangASTContext::DeclContextGetAsDeclContext(const CompilerDeclContext &dc) {
10134 if (dc.IsClang())
10135 return (clang::DeclContext *)dc.GetOpaqueDeclContext();
10136 return nullptr;
10137}
10138
10139ObjCMethodDecl *
10140ClangASTContext::DeclContextGetAsObjCMethodDecl(const CompilerDeclContext &dc) {
10141 if (dc.IsClang())
10142 return llvm::dyn_cast<clang::ObjCMethodDecl>(
10143 (clang::DeclContext *)dc.GetOpaqueDeclContext());
10144 return nullptr;
10145}
10146
10147CXXMethodDecl *
10148ClangASTContext::DeclContextGetAsCXXMethodDecl(const CompilerDeclContext &dc) {
10149 if (dc.IsClang())
10150 return llvm::dyn_cast<clang::CXXMethodDecl>(
10151 (clang::DeclContext *)dc.GetOpaqueDeclContext());
10152 return nullptr;
10153}
10154
10155clang::FunctionDecl *
10156ClangASTContext::DeclContextGetAsFunctionDecl(const CompilerDeclContext &dc) {
10157 if (dc.IsClang())
10158 return llvm::dyn_cast<clang::FunctionDecl>(
10159 (clang::DeclContext *)dc.GetOpaqueDeclContext());
10160 return nullptr;
10161}
10162
10163clang::NamespaceDecl *
10164ClangASTContext::DeclContextGetAsNamespaceDecl(const CompilerDeclContext &dc) {
10165 if (dc.IsClang())
10166 return llvm::dyn_cast<clang::NamespaceDecl>(
10167 (clang::DeclContext *)dc.GetOpaqueDeclContext());
10168 return nullptr;
10169}
10170
10171ClangASTMetadata *
10172ClangASTContext::DeclContextGetMetaData(const CompilerDeclContext &dc,
10173 const void *object) {
10174 clang::ASTContext *ast = DeclContextGetClangASTContext(dc);
10175 if (ast)
10176 return ClangASTContext::GetMetadata(ast, object);
10177 return nullptr;
10178}
10179
10180clang::ASTContext *
10181ClangASTContext::DeclContextGetClangASTContext(const CompilerDeclContext &dc) {
10182 ClangASTContext *ast =
10183 llvm::dyn_cast_or_null<ClangASTContext>(dc.GetTypeSystem());
10184 if (ast)
10185 return ast->getASTContext();
10186 return nullptr;
10187}
10188
10189ClangASTContextForExpressions::ClangASTContextForExpressions(Target &target)
10190 : ClangASTContext(target.GetArchitecture().GetTriple().getTriple().c_str()),
10191 m_target_wp(target.shared_from_this()),
10192 m_persistent_variables(new ClangPersistentVariables) {}
10193
10194UserExpression *ClangASTContextForExpressions::GetUserExpression(
10195 llvm::StringRef expr, llvm::StringRef prefix, lldb::LanguageType language,
10196 Expression::ResultType desired_type,
10197 const EvaluateExpressionOptions &options) {
10198 TargetSP target_sp = m_target_wp.lock();
10199 if (!target_sp)
10200 return nullptr;
10201
10202 return new ClangUserExpression(*target_sp.get(), expr, prefix, language,
10203 desired_type, options);
10204}
10205
10206FunctionCaller *ClangASTContextForExpressions::GetFunctionCaller(
10207 const CompilerType &return_type, const Address &function_address,
10208 const ValueList &arg_value_list, const char *name) {
10209 TargetSP target_sp = m_target_wp.lock();
10210 if (!target_sp)
10211 return nullptr;
10212
10213 Process *process = target_sp->GetProcessSP().get();
10214 if (!process)
10215 return nullptr;
10216
10217 return new ClangFunctionCaller(*process, return_type, function_address,
10218 arg_value_list, name);
10219}
10220
10221UtilityFunction *
10222ClangASTContextForExpressions::GetUtilityFunction(const char *text,
10223 const char *name) {
10224 TargetSP target_sp = m_target_wp.lock();
10225 if (!target_sp)
10226 return nullptr;
10227
10228 return new ClangUtilityFunction(*target_sp.get(), text, name);
10229}
10230
10231PersistentExpressionState *
10232ClangASTContextForExpressions::GetPersistentExpressionState() {
10233 return m_persistent_variables.get();
10234}
10235
10236clang::ExternalASTMerger &
10237ClangASTContextForExpressions::GetMergerUnchecked() {
10238 lldbassert(m_scratch_ast_source_ap != nullptr)lldb_private::lldb_assert(static_cast<bool>(m_scratch_ast_source_ap
!= nullptr), "m_scratch_ast_source_ap != nullptr", __FUNCTION__
, "/build/llvm-toolchain-snapshot-8~svn345461/tools/lldb/source/Symbol/ClangASTContext.cpp"
, 10238)
;
10239 return m_scratch_ast_source_ap->GetMergerUnchecked();
10240}

/build/llvm-toolchain-snapshot-8~svn345461/build-llvm/tools/lldb/../clang/include/clang/AST/Attrs.inc

1/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\
2|* *|
3|* Attribute classes' definitions *|
4|* *|
5|* Automatically generated file, do not edit! *|
6|* *|
7\*===----------------------------------------------------------------------===*/
8
9#ifndef LLVM_CLANG_ATTR_CLASSES_INC
10#define LLVM_CLANG_ATTR_CLASSES_INC
11
12class AMDGPUFlatWorkGroupSizeAttr : public InheritableAttr {
13unsigned min;
14
15unsigned max;
16
17public:
18 static AMDGPUFlatWorkGroupSizeAttr *CreateImplicit(ASTContext &Ctx, unsigned Min, unsigned Max, SourceRange Loc = SourceRange()) {
19 auto *A = new (Ctx) AMDGPUFlatWorkGroupSizeAttr(Loc, Ctx, Min, Max, 0);
20 A->setImplicit(true);
21 return A;
22 }
23
24 AMDGPUFlatWorkGroupSizeAttr(SourceRange R, ASTContext &Ctx
25 , unsigned Min
26 , unsigned Max
27 , unsigned SI
28 )
29 : InheritableAttr(attr::AMDGPUFlatWorkGroupSize, R, SI, false, false)
30 , min(Min)
31 , max(Max)
32 {
33 }
34
35 AMDGPUFlatWorkGroupSizeAttr *clone(ASTContext &C) const;
36 void printPretty(raw_ostream &OS,
37 const PrintingPolicy &Policy) const;
38 const char *getSpelling() const;
39 unsigned getMin() const {
40 return min;
41 }
42
43 unsigned getMax() const {
44 return max;
45 }
46
47
48
49 static bool classof(const Attr *A) { return A->getKind() == attr::AMDGPUFlatWorkGroupSize; }
50};
51
52class AMDGPUNumSGPRAttr : public InheritableAttr {
53unsigned numSGPR;
54
55public:
56 static AMDGPUNumSGPRAttr *CreateImplicit(ASTContext &Ctx, unsigned NumSGPR, SourceRange Loc = SourceRange()) {
57 auto *A = new (Ctx) AMDGPUNumSGPRAttr(Loc, Ctx, NumSGPR, 0);
58 A->setImplicit(true);
59 return A;
60 }
61
62 AMDGPUNumSGPRAttr(SourceRange R, ASTContext &Ctx
63 , unsigned NumSGPR
64 , unsigned SI
65 )
66 : InheritableAttr(attr::AMDGPUNumSGPR, R, SI, false, false)
67 , numSGPR(NumSGPR)
68 {
69 }
70
71 AMDGPUNumSGPRAttr *clone(ASTContext &C) const;
72 void printPretty(raw_ostream &OS,
73 const PrintingPolicy &Policy) const;
74 const char *getSpelling() const;
75 unsigned getNumSGPR() const {
76 return numSGPR;
77 }
78
79
80
81 static bool classof(const Attr *A) { return A->getKind() == attr::AMDGPUNumSGPR; }
82};
83
84class AMDGPUNumVGPRAttr : public InheritableAttr {
85unsigned numVGPR;
86
87public:
88 static AMDGPUNumVGPRAttr *CreateImplicit(ASTContext &Ctx, unsigned NumVGPR, SourceRange Loc = SourceRange()) {
89 auto *A = new (Ctx) AMDGPUNumVGPRAttr(Loc, Ctx, NumVGPR, 0);
90 A->setImplicit(true);
91 return A;
92 }
93
94 AMDGPUNumVGPRAttr(SourceRange R, ASTContext &Ctx
95 , unsigned NumVGPR
96 , unsigned SI
97 )
98 : InheritableAttr(attr::AMDGPUNumVGPR, R, SI, false, false)
99 , numVGPR(NumVGPR)
100 {
101 }
102
103 AMDGPUNumVGPRAttr *clone(ASTContext &C) const;
104 void printPretty(raw_ostream &OS,
105 const PrintingPolicy &Policy) const;
106 const char *getSpelling() const;
107 unsigned getNumVGPR() const {
108 return numVGPR;
109 }
110
111
112
113 static bool classof(const Attr *A) { return A->getKind() == attr::AMDGPUNumVGPR; }
114};
115
116class AMDGPUWavesPerEUAttr : public InheritableAttr {
117unsigned min;
118
119unsigned max;
120
121public:
122 static AMDGPUWavesPerEUAttr *CreateImplicit(ASTContext &Ctx, unsigned Min, unsigned Max, SourceRange Loc = SourceRange()) {
123 auto *A = new (Ctx) AMDGPUWavesPerEUAttr(Loc, Ctx, Min, Max, 0);
124 A->setImplicit(true);
125 return A;
126 }
127
128 AMDGPUWavesPerEUAttr(SourceRange R, ASTContext &Ctx
129 , unsigned Min
130 , unsigned Max
131 , unsigned SI
132 )
133 : InheritableAttr(attr::AMDGPUWavesPerEU, R, SI, false, false)
134 , min(Min)
135 , max(Max)
136 {
137 }
138
139 AMDGPUWavesPerEUAttr(SourceRange R, ASTContext &Ctx
140 , unsigned Min
141 , unsigned SI
142 )
143 : InheritableAttr(attr::AMDGPUWavesPerEU, R, SI, false, false)
144 , min(Min)
145 , max()
146 {
147 }
148
149 AMDGPUWavesPerEUAttr *clone(ASTContext &C) const;
150 void printPretty(raw_ostream &OS,
151 const PrintingPolicy &Policy) const;
152 const char *getSpelling() const;
153 unsigned getMin() const {
154 return min;
155 }
156
157 unsigned getMax() const {
158 return max;
159 }
160
161
162
163 static bool classof(const Attr *A) { return A->getKind() == attr::AMDGPUWavesPerEU; }
164};
165
166class ARMInterruptAttr : public InheritableAttr {
167public:
168 enum InterruptType {
169 IRQ,
170 FIQ,
171 SWI,
172 ABORT,
173 UNDEF,
174 Generic
175 };
176private:
177 InterruptType interrupt;
178
179public:
180 static ARMInterruptAttr *CreateImplicit(ASTContext &Ctx, InterruptType Interrupt, SourceRange Loc = SourceRange()) {
181 auto *A = new (Ctx) ARMInterruptAttr(Loc, Ctx, Interrupt, 0);
182 A->setImplicit(true);
183 return A;
184 }
185
186 ARMInterruptAttr(SourceRange R, ASTContext &Ctx
187 , InterruptType Interrupt
188 , unsigned SI
189 )
190 : InheritableAttr(attr::ARMInterrupt, R, SI, false, false)
191 , interrupt(Interrupt)
192 {
193 }
194
195 ARMInterruptAttr(SourceRange R, ASTContext &Ctx
196 , unsigned SI
197 )
198 : InheritableAttr(attr::ARMInterrupt, R, SI, false, false)
199 , interrupt(InterruptType(0))
200 {
201 }
202
203 ARMInterruptAttr *clone(ASTContext &C) const;
204 void printPretty(raw_ostream &OS,
205 const PrintingPolicy &Policy) const;
206 const char *getSpelling() const;
207 InterruptType getInterrupt() const {
208 return interrupt;
209 }
210
211 static bool ConvertStrToInterruptType(StringRef Val, InterruptType &Out) {
212 Optional<InterruptType> R = llvm::StringSwitch<Optional<InterruptType>>(Val)
213 .Case("IRQ", ARMInterruptAttr::IRQ)
214 .Case("FIQ", ARMInterruptAttr::FIQ)
215 .Case("SWI", ARMInterruptAttr::SWI)
216 .Case("ABORT", ARMInterruptAttr::ABORT)
217 .Case("UNDEF", ARMInterruptAttr::UNDEF)
218 .Case("", ARMInterruptAttr::Generic)
219 .Default(Optional<InterruptType>());
220 if (R) {
221 Out = *R;
222 return true;
223 }
224 return false;
225 }
226
227 static const char *ConvertInterruptTypeToStr(InterruptType Val) {
228 switch(Val) {
229 case ARMInterruptAttr::IRQ: return "IRQ";
230 case ARMInterruptAttr::FIQ: return "FIQ";
231 case ARMInterruptAttr::SWI: return "SWI";
232 case ARMInterruptAttr::ABORT: return "ABORT";
233 case ARMInterruptAttr::UNDEF: return "UNDEF";
234 case ARMInterruptAttr::Generic: return "";
235 }
236 llvm_unreachable("No enumerator with that value")::llvm::llvm_unreachable_internal("No enumerator with that value"
, "/build/llvm-toolchain-snapshot-8~svn345461/build-llvm/tools/lldb/../clang/include/clang/AST/Attrs.inc"
, 236)
;
237 }
238
239
240 static bool classof(const Attr *A) { return A->getKind() == attr::ARMInterrupt; }
241};
242
243class AVRInterruptAttr : public InheritableAttr {
244public:
245 static AVRInterruptAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
246 auto *A = new (Ctx) AVRInterruptAttr(Loc, Ctx, 0);
247 A->setImplicit(true);
248 return A;
249 }
250
251 AVRInterruptAttr(SourceRange R, ASTContext &Ctx
252 , unsigned SI
253 )
254 : InheritableAttr(attr::AVRInterrupt, R, SI, false, false)
255 {
256 }
257
258 AVRInterruptAttr *clone(ASTContext &C) const;
259 void printPretty(raw_ostream &OS,
260 const PrintingPolicy &Policy) const;
261 const char *getSpelling() const;
262
263
264 static bool classof(const Attr *A) { return A->getKind() == attr::AVRInterrupt; }
265};
266
267class AVRSignalAttr : public InheritableAttr {
268public:
269 static AVRSignalAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
270 auto *A = new (Ctx) AVRSignalAttr(Loc, Ctx, 0);
271 A->setImplicit(true);
272 return A;
273 }
274
275 AVRSignalAttr(SourceRange R, ASTContext &Ctx
276 , unsigned SI
277 )
278 : InheritableAttr(attr::AVRSignal, R, SI, false, false)
279 {
280 }
281
282 AVRSignalAttr *clone(ASTContext &C) const;
283 void printPretty(raw_ostream &OS,
284 const PrintingPolicy &Policy) const;
285 const char *getSpelling() const;
286
287
288 static bool classof(const Attr *A) { return A->getKind() == attr::AVRSignal; }
289};
290
291class AbiTagAttr : public Attr {
292 unsigned tags_Size;
293 StringRef *tags_;
294
295public:
296 static AbiTagAttr *CreateImplicit(ASTContext &Ctx, StringRef *Tags, unsigned TagsSize, SourceRange Loc = SourceRange()) {
297 auto *A = new (Ctx) AbiTagAttr(Loc, Ctx, Tags, TagsSize, 0);
298 A->setImplicit(true);
299 return A;
300 }
301
302 AbiTagAttr(SourceRange R, ASTContext &Ctx
303 , StringRef *Tags, unsigned TagsSize
304 , unsigned SI
305 )
306 : Attr(attr::AbiTag, R, SI, false)
307 , tags_Size(TagsSize), tags_(new (Ctx, 16) StringRef[tags_Size])
308 {
309 for (size_t I = 0, E = tags_Size; I != E;
310 ++I) {
311 StringRef Ref = Tags[I];
312 if (!Ref.empty()) {
313 char *Mem = new (Ctx, 1) char[Ref.size()];
314 std::memcpy(Mem, Ref.data(), Ref.size());
315 tags_[I] = StringRef(Mem, Ref.size());
316 }
317 }
318 }
319
320 AbiTagAttr(SourceRange R, ASTContext &Ctx
321 , unsigned SI
322 )
323 : Attr(attr::AbiTag, R, SI, false)
324 , tags_Size(0), tags_(nullptr)
325 {
326 }
327
328 AbiTagAttr *clone(ASTContext &C) const;
329 void printPretty(raw_ostream &OS,
330 const PrintingPolicy &Policy) const;
331 const char *getSpelling() const;
332 typedef StringRef* tags_iterator;
333 tags_iterator tags_begin() const { return tags_; }
334 tags_iterator tags_end() const { return tags_ + tags_Size; }
335 unsigned tags_size() const { return tags_Size; }
336 llvm::iterator_range<tags_iterator> tags() const { return llvm::make_range(tags_begin(), tags_end()); }
337
338
339
340
341 static bool classof(const Attr *A) { return A->getKind() == attr::AbiTag; }
342};
343
344class AcquireCapabilityAttr : public InheritableAttr {
345 unsigned args_Size;
346 Expr * *args_;
347
348public:
349 enum Spelling {
350 GNU_acquire_capability = 0,
351 CXX11_clang_acquire_capability = 1,
352 GNU_acquire_shared_capability = 2,
353 CXX11_clang_acquire_shared_capability = 3,
354 GNU_exclusive_lock_function = 4,
355 GNU_shared_lock_function = 5
356 };
357
358 static AcquireCapabilityAttr *CreateImplicit(ASTContext &Ctx, Spelling S, Expr * *Args, unsigned ArgsSize, SourceRange Loc = SourceRange()) {
359 auto *A = new (Ctx) AcquireCapabilityAttr(Loc, Ctx, Args, ArgsSize, S);
360 A->setImplicit(true);
361 return A;
362 }
363
364 AcquireCapabilityAttr(SourceRange R, ASTContext &Ctx
365 , Expr * *Args, unsigned ArgsSize
366 , unsigned SI
367 )
368 : InheritableAttr(attr::AcquireCapability, R, SI, true, true)
369 , args_Size(ArgsSize), args_(new (Ctx, 16) Expr *[args_Size])
370 {
371 std::copy(Args, Args + args_Size, args_);
372 }
373
374 AcquireCapabilityAttr(SourceRange R, ASTContext &Ctx
375 , unsigned SI
376 )
377 : InheritableAttr(attr::AcquireCapability, R, SI, true, true)
378 , args_Size(0), args_(nullptr)
379 {
380 }
381
382 AcquireCapabilityAttr *clone(ASTContext &C) const;
383 void printPretty(raw_ostream &OS,
384 const PrintingPolicy &Policy) const;
385 const char *getSpelling() const;
386 Spelling getSemanticSpelling() const {
387 switch (SpellingListIndex) {
388 default: llvm_unreachable("Unknown spelling list index")::llvm::llvm_unreachable_internal("Unknown spelling list index"
, "/build/llvm-toolchain-snapshot-8~svn345461/build-llvm/tools/lldb/../clang/include/clang/AST/Attrs.inc"
, 388)
;
389 case 0: return GNU_acquire_capability;
390 case 1: return CXX11_clang_acquire_capability;
391 case 2: return GNU_acquire_shared_capability;
392 case 3: return CXX11_clang_acquire_shared_capability;
393 case 4: return GNU_exclusive_lock_function;
394 case 5: return GNU_shared_lock_function;
395 }
396 }
397 bool isShared() const { return SpellingListIndex == 2 ||
398 SpellingListIndex == 3 ||
399 SpellingListIndex == 5; }
400 typedef Expr ** args_iterator;
401 args_iterator args_begin() const { return args_; }
402 args_iterator args_end() const { return args_ + args_Size; }
403 unsigned args_size() const { return args_Size; }
404 llvm::iterator_range<args_iterator> args() const { return llvm::make_range(args_begin(), args_end()); }
405
406
407
408
409 static bool classof(const Attr *A) { return A->getKind() == attr::AcquireCapability; }
410};
411
412class AcquiredAfterAttr : public InheritableAttr {
413 unsigned args_Size;
414 Expr * *args_;
415
416public:
417 static AcquiredAfterAttr *CreateImplicit(ASTContext &Ctx, Expr * *Args, unsigned ArgsSize, SourceRange Loc = SourceRange()) {
418 auto *A = new (Ctx) AcquiredAfterAttr(Loc, Ctx, Args, ArgsSize, 0);
419 A->setImplicit(true);
420 return A;
421 }
422
423 AcquiredAfterAttr(SourceRange R, ASTContext &Ctx
424 , Expr * *Args, unsigned ArgsSize
425 , unsigned SI
426 )
427 : InheritableAttr(attr::AcquiredAfter, R, SI, true, true)
428 , args_Size(ArgsSize), args_(new (Ctx, 16) Expr *[args_Size])
429 {
430 std::copy(Args, Args + args_Size, args_);
431 }
432
433 AcquiredAfterAttr(SourceRange R, ASTContext &Ctx
434 , unsigned SI
435 )
436 : InheritableAttr(attr::AcquiredAfter, R, SI, true, true)
437 , args_Size(0), args_(nullptr)
438 {
439 }
440
441 AcquiredAfterAttr *clone(ASTContext &C) const;
442 void printPretty(raw_ostream &OS,
443 const PrintingPolicy &Policy) const;
444 const char *getSpelling() const;
445 typedef Expr ** args_iterator;
446 args_iterator args_begin() const { return args_; }
447 args_iterator args_end() const { return args_ + args_Size; }
448 unsigned args_size() const { return args_Size; }
449 llvm::iterator_range<args_iterator> args() const { return llvm::make_range(args_begin(), args_end()); }
450
451
452
453
454 static bool classof(const Attr *A) { return A->getKind() == attr::AcquiredAfter; }
455};
456
457class AcquiredBeforeAttr : public InheritableAttr {
458 unsigned args_Size;
459 Expr * *args_;
460
461public:
462 static AcquiredBeforeAttr *CreateImplicit(ASTContext &Ctx, Expr * *Args, unsigned ArgsSize, SourceRange Loc = SourceRange()) {
463 auto *A = new (Ctx) AcquiredBeforeAttr(Loc, Ctx, Args, ArgsSize, 0);
464 A->setImplicit(true);
465 return A;
466 }
467
468 AcquiredBeforeAttr(SourceRange R, ASTContext &Ctx
469 , Expr * *Args, unsigned ArgsSize
470 , unsigned SI
471 )
472 : InheritableAttr(attr::AcquiredBefore, R, SI, true, true)
473 , args_Size(ArgsSize), args_(new (Ctx, 16) Expr *[args_Size])
474 {
475 std::copy(Args, Args + args_Size, args_);
476 }
477
478 AcquiredBeforeAttr(SourceRange R, ASTContext &Ctx
479 , unsigned SI
480 )
481 : InheritableAttr(attr::AcquiredBefore, R, SI, true, true)
482 , args_Size(0), args_(nullptr)
483 {
484 }
485
486 AcquiredBeforeAttr *clone(ASTContext &C) const;
487 void printPretty(raw_ostream &OS,
488 const PrintingPolicy &Policy) const;
489 const char *getSpelling() const;
490 typedef Expr ** args_iterator;
491 args_iterator args_begin() const { return args_; }
492 args_iterator args_end() const { return args_ + args_Size; }
493 unsigned args_size() const { return args_Size; }
494 llvm::iterator_range<args_iterator> args() const { return llvm::make_range(args_begin(), args_end()); }
495
496
497
498
499 static bool classof(const Attr *A) { return A->getKind() == attr::AcquiredBefore; }
500};
501
502class AddressSpaceAttr : public TypeAttr {
503int addressSpace;
504
505public:
506 static AddressSpaceAttr *CreateImplicit(ASTContext &Ctx, int AddressSpace, SourceRange Loc = SourceRange()) {
507 auto *A = new (Ctx) AddressSpaceAttr(Loc, Ctx, AddressSpace, 0);
508 A->setImplicit(true);
509 return A;
510 }
511
512 AddressSpaceAttr(SourceRange R, ASTContext &Ctx
513 , int AddressSpace
514 , unsigned SI
515 )
516 : TypeAttr(attr::AddressSpace, R, SI, false)
517 , addressSpace(AddressSpace)
518 {
519 }
520
521 AddressSpaceAttr *clone(ASTContext &C) const;
522 void printPretty(raw_ostream &OS,
523 const PrintingPolicy &Policy) const;
524 const char *getSpelling() const;
525 int getAddressSpace() const {
526 return addressSpace;
527 }
528
529
530
531 static bool classof(const Attr *A) { return A->getKind() == attr::AddressSpace; }
532};
533
534class AliasAttr : public Attr {
535unsigned aliaseeLength;
536char *aliasee;
537
538public:
539 static AliasAttr *CreateImplicit(ASTContext &Ctx, llvm::StringRef Aliasee, SourceRange Loc = SourceRange()) {
540 auto *A = new (Ctx) AliasAttr(Loc, Ctx, Aliasee, 0);
541 A->setImplicit(true);
542 return A;
543 }
544
545 AliasAttr(SourceRange R, ASTContext &Ctx
546 , llvm::StringRef Aliasee
547 , unsigned SI
548 )
549 : Attr(attr::Alias, R, SI, false)
550 , aliaseeLength(Aliasee.size()),aliasee(new (Ctx, 1) char[aliaseeLength])
551 {
552 if (!Aliasee.empty())
553 std::memcpy(aliasee, Aliasee.data(), aliaseeLength);
554 }
555
556 AliasAttr *clone(ASTContext &C) const;
557 void printPretty(raw_ostream &OS,
558 const PrintingPolicy &Policy) const;
559 const char *getSpelling() const;
560 llvm::StringRef getAliasee() const {
561 return llvm::StringRef(aliasee, aliaseeLength);
562 }
563 unsigned getAliaseeLength() const {
564 return aliaseeLength;
565 }
566 void setAliasee(ASTContext &C, llvm::StringRef S) {
567 aliaseeLength = S.size();
568 this->aliasee = new (C, 1) char [aliaseeLength];
569 if (!S.empty())
570 std::memcpy(this->aliasee, S.data(), aliaseeLength);
571 }
572
573
574
575 static bool classof(const Attr *A) { return A->getKind() == attr::Alias; }
576};
577
578class AlignMac68kAttr : public InheritableAttr {
579public:
580 static AlignMac68kAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
581 auto *A = new (Ctx) AlignMac68kAttr(Loc, Ctx, 0);
582 A->setImplicit(true);
583 return A;
584 }
585
586 AlignMac68kAttr(SourceRange R, ASTContext &Ctx
587 , unsigned SI
588 )
589 : InheritableAttr(attr::AlignMac68k, R, SI, false, false)
590 {
591 }
592
593 AlignMac68kAttr *clone(ASTContext &C) const;
594 void printPretty(raw_ostream &OS,
595 const PrintingPolicy &Policy) const;
596 const char *getSpelling() const;
597
598
599 static bool classof(const Attr *A) { return A->getKind() == attr::AlignMac68k; }
600};
601
602class AlignValueAttr : public Attr {
603Expr * alignment;
604
605public:
606 static AlignValueAttr *CreateImplicit(ASTContext &Ctx, Expr * Alignment, SourceRange Loc = SourceRange()) {
607 auto *A = new (Ctx) AlignValueAttr(Loc, Ctx, Alignment, 0);
608 A->setImplicit(true);
609 return A;
610 }
611
612 AlignValueAttr(SourceRange R, ASTContext &Ctx
613 , Expr * Alignment
614 , unsigned SI
615 )
616 : Attr(attr::AlignValue, R, SI, false)
617 , alignment(Alignment)
618 {
619 }
620
621 AlignValueAttr *clone(ASTContext &C) const;
622 void printPretty(raw_ostream &OS,
623 const PrintingPolicy &Policy) const;
624 const char *getSpelling() const;
625 Expr * getAlignment() const {
626 return alignment;
627 }
628
629
630
631 static bool classof(const Attr *A) { return A->getKind() == attr::AlignValue; }
632};
633
634class AlignedAttr : public InheritableAttr {
635bool isalignmentExpr;
636union {
637Expr *alignmentExpr;
638TypeSourceInfo *alignmentType;
639};
640
641public:
642 enum Spelling {
643 GNU_aligned = 0,
644 CXX11_gnu_aligned = 1,
645 Declspec_align = 2,
646 Keyword_alignas = 3,
647 Keyword_Alignas = 4
648 };
649
650 static AlignedAttr *CreateImplicit(ASTContext &Ctx, Spelling S, bool IsAlignmentExpr, void *Alignment, SourceRange Loc = SourceRange()) {
651 auto *A = new (Ctx) AlignedAttr(Loc, Ctx, IsAlignmentExpr, Alignment, S);
652 A->setImplicit(true);
653 return A;
654 }
655
656 AlignedAttr(SourceRange R, ASTContext &Ctx
657 , bool IsAlignmentExpr, void *Alignment
658 , unsigned SI
659 )
660 : InheritableAttr(attr::Aligned, R, SI, false, false)
661 , isalignmentExpr(IsAlignmentExpr)
662 {
663 if (isalignmentExpr)
664 alignmentExpr = reinterpret_cast<Expr *>(Alignment);
665 else
666 alignmentType = reinterpret_cast<TypeSourceInfo *>(Alignment);
667 }
668
669 AlignedAttr(SourceRange R, ASTContext &Ctx
670 , unsigned SI
671 )
672 : InheritableAttr(attr::Aligned, R, SI, false, false)
673 , isalignmentExpr(false)
674 {
675 }
676
677 AlignedAttr *clone(ASTContext &C) const;
678 void printPretty(raw_ostream &OS,
679 const PrintingPolicy &Policy) const;
680 const char *getSpelling() const;
681 Spelling getSemanticSpelling() const {
682 switch (SpellingListIndex) {
683 default: llvm_unreachable("Unknown spelling list index")::llvm::llvm_unreachable_internal("Unknown spelling list index"
, "/build/llvm-toolchain-snapshot-8~svn345461/build-llvm/tools/lldb/../clang/include/clang/AST/Attrs.inc"
, 683)
;
684 case 0: return GNU_aligned;
685 case 1: return CXX11_gnu_aligned;
686 case 2: return Declspec_align;
687 case 3: return Keyword_alignas;
688 case 4: return Keyword_Alignas;
689 }
690 }
691 bool isGNU() const { return SpellingListIndex == 0 ||
692 SpellingListIndex == 1; }
693 bool isC11() const { return SpellingListIndex == 4; }
694 bool isAlignas() const { return SpellingListIndex == 3 ||
695 SpellingListIndex == 4; }
696 bool isDeclspec() const { return SpellingListIndex == 2; }
697 bool isAlignmentDependent() const;
698 unsigned getAlignment(ASTContext &Ctx) const;
699 bool isAlignmentExpr() const {
700 return isalignmentExpr;
701 }
702 Expr *getAlignmentExpr() const {
703 assert(isalignmentExpr)((isalignmentExpr) ? static_cast<void> (0) : __assert_fail
("isalignmentExpr", "/build/llvm-toolchain-snapshot-8~svn345461/build-llvm/tools/lldb/../clang/include/clang/AST/Attrs.inc"
, 703, __PRETTY_FUNCTION__))
;
704 return alignmentExpr;
705 }
706 TypeSourceInfo *getAlignmentType() const {
707 assert(!isalignmentExpr)((!isalignmentExpr) ? static_cast<void> (0) : __assert_fail
("!isalignmentExpr", "/build/llvm-toolchain-snapshot-8~svn345461/build-llvm/tools/lldb/../clang/include/clang/AST/Attrs.inc"
, 707, __PRETTY_FUNCTION__))
;
708 return alignmentType;
709 }
710
711
712
713 static bool classof(const Attr *A) { return A->getKind() == attr::Aligned; }
714};
715
716class AllocAlignAttr : public InheritableAttr {
717ParamIdx paramIndex;
718
719public:
720 static AllocAlignAttr *CreateImplicit(ASTContext &Ctx, ParamIdx ParamIndex, SourceRange Loc = SourceRange()) {
721 auto *A = new (Ctx) AllocAlignAttr(Loc, Ctx, ParamIndex, 0);
722 A->setImplicit(true);
723 return A;
724 }
725
726 AllocAlignAttr(SourceRange R, ASTContext &Ctx
727 , ParamIdx ParamIndex
728 , unsigned SI
729 )
730 : InheritableAttr(attr::AllocAlign, R, SI, false, false)
731 , paramIndex(ParamIndex)
732 {
733 }
734
735 AllocAlignAttr *clone(ASTContext &C) const;
736 void printPretty(raw_ostream &OS,
737 const PrintingPolicy &Policy) const;
738 const char *getSpelling() const;
739 ParamIdx getParamIndex() const {
740 return paramIndex;
741 }
742
743
744
745 static bool classof(const Attr *A) { return A->getKind() == attr::AllocAlign; }
746};
747
748class AllocSizeAttr : public InheritableAttr {
749ParamIdx elemSizeParam;
750
751ParamIdx numElemsParam;
752
753public:
754 static AllocSizeAttr *CreateImplicit(ASTContext &Ctx, ParamIdx ElemSizeParam, ParamIdx NumElemsParam, SourceRange Loc = SourceRange()) {
755 auto *A = new (Ctx) AllocSizeAttr(Loc, Ctx, ElemSizeParam, NumElemsParam, 0);
756 A->setImplicit(true);
757 return A;
758 }
759
760 AllocSizeAttr(SourceRange R, ASTContext &Ctx
761 , ParamIdx ElemSizeParam
762 , ParamIdx NumElemsParam
763 , unsigned SI
764 )
765 : InheritableAttr(attr::AllocSize, R, SI, false, false)
766 , elemSizeParam(ElemSizeParam)
767 , numElemsParam(NumElemsParam)
768 {
769 }
770
771 AllocSizeAttr(SourceRange R, ASTContext &Ctx
772 , ParamIdx ElemSizeParam
773 , unsigned SI
774 )
775 : InheritableAttr(attr::AllocSize, R, SI, false, false)
776 , elemSizeParam(ElemSizeParam)
777 , numElemsParam()
778 {
779 }
780
781 AllocSizeAttr *clone(ASTContext &C) const;
782 void printPretty(raw_ostream &OS,
783 const PrintingPolicy &Policy) const;
784 const char *getSpelling() const;
785 ParamIdx getElemSizeParam() const {
786 return elemSizeParam;
787 }
788
789 ParamIdx getNumElemsParam() const {
790 return numElemsParam;
791 }
792
793
794
795 static bool classof(const Attr *A) { return A->getKind() == attr::AllocSize; }
796};
797
798class AlwaysDestroyAttr : public InheritableAttr {
799public:
800 static AlwaysDestroyAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
801 auto *A = new (Ctx) AlwaysDestroyAttr(Loc, Ctx, 0);
802 A->setImplicit(true);
803 return A;
804 }
805
806 AlwaysDestroyAttr(SourceRange R, ASTContext &Ctx
807 , unsigned SI
808 )
809 : InheritableAttr(attr::AlwaysDestroy, R, SI, false, false)
810 {
811 }
812
813 AlwaysDestroyAttr *clone(ASTContext &C) const;
814 void printPretty(raw_ostream &OS,
815 const PrintingPolicy &Policy) const;
816 const char *getSpelling() const;
817
818
819 static bool classof(const Attr *A) { return A->getKind() == attr::AlwaysDestroy; }
820};
821
822class AlwaysInlineAttr : public InheritableAttr {
823public:
824 enum Spelling {
825 GNU_always_inline = 0,
826 CXX11_gnu_always_inline = 1,
827 Keyword_forceinline = 2
828 };
829
830 static AlwaysInlineAttr *CreateImplicit(ASTContext &Ctx, Spelling S, SourceRange Loc = SourceRange()) {
831 auto *A = new (Ctx) AlwaysInlineAttr(Loc, Ctx, S);
832 A->setImplicit(true);
833 return A;
834 }
835
836 AlwaysInlineAttr(SourceRange R, ASTContext &Ctx
837 , unsigned SI
838 )
839 : InheritableAttr(attr::AlwaysInline, R, SI, false, false)
840 {
841 }
842
843 AlwaysInlineAttr *clone(ASTContext &C) const;
844 void printPretty(raw_ostream &OS,
845 const PrintingPolicy &Policy) const;
846 const char *getSpelling() const;
847 Spelling getSemanticSpelling() const {
848 switch (SpellingListIndex) {
849 default: llvm_unreachable("Unknown spelling list index")::llvm::llvm_unreachable_internal("Unknown spelling list index"
, "/build/llvm-toolchain-snapshot-8~svn345461/build-llvm/tools/lldb/../clang/include/clang/AST/Attrs.inc"
, 849)
;
850 case 0: return GNU_always_inline;
851 case 1: return CXX11_gnu_always_inline;
852 case 2: return Keyword_forceinline;
853 }
854 }
855
856
857 static bool classof(const Attr *A) { return A->getKind() == attr::AlwaysInline; }
858};
859
860class AnalyzerNoReturnAttr : public InheritableAttr {
861public:
862 static AnalyzerNoReturnAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
863 auto *A = new (Ctx) AnalyzerNoReturnAttr(Loc, Ctx, 0);
864 A->setImplicit(true);
865 return A;
866 }
867
868 AnalyzerNoReturnAttr(SourceRange R, ASTContext &Ctx
869 , unsigned SI
870 )
871 : InheritableAttr(attr::AnalyzerNoReturn, R, SI, false, false)
872 {
873 }
874
875 AnalyzerNoReturnAttr *clone(ASTContext &C) const;
876 void printPretty(raw_ostream &OS,
877 const PrintingPolicy &Policy) const;
878 const char *getSpelling() const;
879
880
881 static bool classof(const Attr *A) { return A->getKind() == attr::AnalyzerNoReturn; }
882};
883
884class AnnotateAttr : public InheritableParamAttr {
885unsigned annotationLength;
886char *annotation;
887
888public:
889 static AnnotateAttr *CreateImplicit(ASTContext &Ctx, llvm::StringRef Annotation, SourceRange Loc = SourceRange()) {
890 auto *A = new (Ctx) AnnotateAttr(Loc, Ctx, Annotation, 0);
891 A->setImplicit(true);
892 return A;
893 }
894
895 AnnotateAttr(SourceRange R, ASTContext &Ctx
896 , llvm::StringRef Annotation
897 , unsigned SI
898 )
899 : InheritableParamAttr(attr::Annotate, R, SI, false, false)
900 , annotationLength(Annotation.size()),annotation(new (Ctx, 1) char[annotationLength])
901 {
902 if (!Annotation.empty())
903 std::memcpy(annotation, Annotation.data(), annotationLength);
904 }
905
906 AnnotateAttr *clone(ASTContext &C) const;
907 void printPretty(raw_ostream &OS,
908 const PrintingPolicy &Policy) const;
909 const char *getSpelling() const;
910 llvm::StringRef getAnnotation() const {
911 return llvm::StringRef(annotation, annotationLength);
912 }
913 unsigned getAnnotationLength() const {
914 return annotationLength;
915 }
916 void setAnnotation(ASTContext &C, llvm::StringRef S) {
917 annotationLength = S.size();
918 this->annotation = new (C, 1) char [annotationLength];
919 if (!S.empty())
920 std::memcpy(this->annotation, S.data(), annotationLength);
921 }
922
923
924
925 static bool classof(const Attr *A) { return A->getKind() == attr::Annotate; }
926};
927
928class AnyX86InterruptAttr : public InheritableAttr {
929public:
930 static AnyX86InterruptAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
931 auto *A = new (Ctx) AnyX86InterruptAttr(Loc, Ctx, 0);
932 A->setImplicit(true);
933 return A;
934 }
935
936 AnyX86InterruptAttr(SourceRange R, ASTContext &Ctx
937 , unsigned SI
938 )
939 : InheritableAttr(attr::AnyX86Interrupt, R, SI, false, false)
940 {
941 }
942
943 AnyX86InterruptAttr *clone(ASTContext &C) const;
944 void printPretty(raw_ostream &OS,
945 const PrintingPolicy &Policy) const;
946 const char *getSpelling() const;
947
948
949 static bool classof(const Attr *A) { return A->getKind() == attr::AnyX86Interrupt; }
950};
951
952class AnyX86NoCallerSavedRegistersAttr : public InheritableAttr {
953public:
954 static AnyX86NoCallerSavedRegistersAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
955 auto *A = new (Ctx) AnyX86NoCallerSavedRegistersAttr(Loc, Ctx, 0);
956 A->setImplicit(true);
957 return A;
958 }
959
960 AnyX86NoCallerSavedRegistersAttr(SourceRange R, ASTContext &Ctx
961 , unsigned SI
962 )
963 : InheritableAttr(attr::AnyX86NoCallerSavedRegisters, R, SI, false, false)
964 {
965 }
966
967 AnyX86NoCallerSavedRegistersAttr *clone(ASTContext &C) const;
968 void printPretty(raw_ostream &OS,
969 const PrintingPolicy &Policy) const;
970 const char *getSpelling() const;
971
972
973 static bool classof(const Attr *A) { return A->getKind() == attr::AnyX86NoCallerSavedRegisters; }
974};
975
976class AnyX86NoCfCheckAttr : public InheritableAttr {
977public:
978 static AnyX86NoCfCheckAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
979 auto *A = new (Ctx) AnyX86NoCfCheckAttr(Loc, Ctx, 0);
980 A->setImplicit(true);
981 return A;
982 }
983
984 AnyX86NoCfCheckAttr(SourceRange R, ASTContext &Ctx
985 , unsigned SI
986 )
987 : InheritableAttr(attr::AnyX86NoCfCheck, R, SI, false, false)
988 {
989 }
990
991 AnyX86NoCfCheckAttr *clone(ASTContext &C) const;
992 void printPretty(raw_ostream &OS,
993 const PrintingPolicy &Policy) const;
994 const char *getSpelling() const;
995
996
997 static bool classof(const Attr *A) { return A->getKind() == attr::AnyX86NoCfCheck; }
998};
999
1000class ArcWeakrefUnavailableAttr : public InheritableAttr {
1001public:
1002 static ArcWeakrefUnavailableAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
1003 auto *A = new (Ctx) ArcWeakrefUnavailableAttr(Loc, Ctx, 0);
1004 A->setImplicit(true);
1005 return A;
1006 }
1007
1008 ArcWeakrefUnavailableAttr(SourceRange R, ASTContext &Ctx
1009 , unsigned SI
1010 )
1011 : InheritableAttr(attr::ArcWeakrefUnavailable, R, SI, false, false)
1012 {
1013 }
1014
1015 ArcWeakrefUnavailableAttr *clone(ASTContext &C) const;
1016 void printPretty(raw_ostream &OS,
1017 const PrintingPolicy &Policy) const;
1018 const char *getSpelling() const;
1019
1020
1021 static bool classof(const Attr *A) { return A->getKind() == attr::ArcWeakrefUnavailable; }
1022};
1023
1024class ArgumentWithTypeTagAttr : public InheritableAttr {
1025IdentifierInfo * argumentKind;
1026
1027ParamIdx argumentIdx;
1028
1029ParamIdx typeTagIdx;
1030
1031bool isPointer;
1032
1033public:
1034 enum Spelling {
1035 GNU_argument_with_type_tag = 0,
1036 CXX11_clang_argument_with_type_tag = 1,
1037 C2x_clang_argument_with_type_tag = 2,
1038 GNU_pointer_with_type_tag = 3,
1039 CXX11_clang_pointer_with_type_tag = 4,
1040 C2x_clang_pointer_with_type_tag = 5
1041 };
1042
1043 static ArgumentWithTypeTagAttr *CreateImplicit(ASTContext &Ctx, Spelling S, IdentifierInfo * ArgumentKind, ParamIdx ArgumentIdx, ParamIdx TypeTagIdx, bool IsPointer, SourceRange Loc = SourceRange()) {
1044 auto *A = new (Ctx) ArgumentWithTypeTagAttr(Loc, Ctx, ArgumentKind, ArgumentIdx, TypeTagIdx, IsPointer, S);
1045 A->setImplicit(true);
1046 return A;
1047 }
1048
1049 static ArgumentWithTypeTagAttr *CreateImplicit(ASTContext &Ctx, Spelling S, IdentifierInfo * ArgumentKind, ParamIdx ArgumentIdx, ParamIdx TypeTagIdx, SourceRange Loc = SourceRange()) {
1050 auto *A = new (Ctx) ArgumentWithTypeTagAttr(Loc, Ctx, ArgumentKind, ArgumentIdx, TypeTagIdx, S);
1051 A->setImplicit(true);
1052 return A;
1053 }
1054
1055 ArgumentWithTypeTagAttr(SourceRange R, ASTContext &Ctx
1056 , IdentifierInfo * ArgumentKind
1057 , ParamIdx ArgumentIdx
1058 , ParamIdx TypeTagIdx
1059 , bool IsPointer
1060 , unsigned SI
1061 )
1062 : InheritableAttr(attr::ArgumentWithTypeTag, R, SI, false, false)
1063 , argumentKind(ArgumentKind)
1064 , argumentIdx(ArgumentIdx)
1065 , typeTagIdx(TypeTagIdx)
1066 , isPointer(IsPointer)
1067 {
1068 }
1069
1070 ArgumentWithTypeTagAttr(SourceRange R, ASTContext &Ctx
1071 , IdentifierInfo * ArgumentKind
1072 , ParamIdx ArgumentIdx
1073 , ParamIdx TypeTagIdx
1074 , unsigned SI
1075 )
1076 : InheritableAttr(attr::ArgumentWithTypeTag, R, SI, false, false)
1077 , argumentKind(ArgumentKind)
1078 , argumentIdx(ArgumentIdx)
1079 , typeTagIdx(TypeTagIdx)
1080 , isPointer()
1081 {
1082 }
1083
1084 ArgumentWithTypeTagAttr *clone(ASTContext &C) const;
1085 void printPretty(raw_ostream &OS,
1086 const PrintingPolicy &Policy) const;
1087 const char *getSpelling() const;
1088 Spelling getSemanticSpelling() const {
1089 switch (SpellingListIndex) {
1090 default: llvm_unreachable("Unknown spelling list index")::llvm::llvm_unreachable_internal("Unknown spelling list index"
, "/build/llvm-toolchain-snapshot-8~svn345461/build-llvm/tools/lldb/../clang/include/clang/AST/Attrs.inc"
, 1090)
;
1091 case 0: return GNU_argument_with_type_tag;
1092 case 1: return CXX11_clang_argument_with_type_tag;
1093 case 2: return C2x_clang_argument_with_type_tag;
1094 case 3: return GNU_pointer_with_type_tag;
1095 case 4: return CXX11_clang_pointer_with_type_tag;
1096 case 5: return C2x_clang_pointer_with_type_tag;
1097 }
1098 }
1099 IdentifierInfo * getArgumentKind() const {
1100 return argumentKind;
1101 }
1102
1103 ParamIdx getArgumentIdx() const {
1104 return argumentIdx;
1105 }
1106
1107 ParamIdx getTypeTagIdx() const {
1108 return typeTagIdx;
1109 }
1110
1111 bool getIsPointer() const {
1112 return isPointer;
1113 }
1114
1115
1116
1117 static bool classof(const Attr *A) { return A->getKind() == attr::ArgumentWithTypeTag; }
1118};
1119
1120class ArtificialAttr : public InheritableAttr {
1121public:
1122 static ArtificialAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
1123 auto *A = new (Ctx) ArtificialAttr(Loc, Ctx, 0);
1124 A->setImplicit(true);
1125 return A;
1126 }
1127
1128 ArtificialAttr(SourceRange R, ASTContext &Ctx
1129 , unsigned SI
1130 )
1131 : InheritableAttr(attr::Artificial, R, SI, false, false)
1132 {
1133 }
1134
1135 ArtificialAttr *clone(ASTContext &C) const;
1136 void printPretty(raw_ostream &OS,
1137 const PrintingPolicy &Policy) const;
1138 const char *getSpelling() const;
1139
1140
1141 static bool classof(const Attr *A) { return A->getKind() == attr::Artificial; }
1142};
1143
1144class AsmLabelAttr : public InheritableAttr {
1145unsigned labelLength;
1146char *label;
1147
1148public:
1149 static AsmLabelAttr *CreateImplicit(ASTContext &Ctx, llvm::StringRef Label, SourceRange Loc = SourceRange()) {
1150 auto *A = new (Ctx) AsmLabelAttr(Loc, Ctx, Label, 0);
25
'A' initialized to a null pointer value
1151 A->setImplicit(true);
26
Called C++ object pointer is null
1152 return A;
1153 }
1154
1155 AsmLabelAttr(SourceRange R, ASTContext &Ctx
1156 , llvm::StringRef Label
1157 , unsigned SI
1158 )
1159 : InheritableAttr(attr::AsmLabel, R, SI, false, false)
1160 , labelLength(Label.size()),label(new (Ctx, 1) char[labelLength])
1161 {
1162 if (!Label.empty())
1163 std::memcpy(label, Label.data(), labelLength);
1164 }
1165
1166 AsmLabelAttr *clone(ASTContext &C) const;
1167 void printPretty(raw_ostream &OS,
1168 const PrintingPolicy &Policy) const;
1169 const char *getSpelling() const;
1170 llvm::StringRef getLabel() const {
1171 return llvm::StringRef(label, labelLength);
1172 }
1173 unsigned getLabelLength() const {
1174 return labelLength;
1175 }
1176 void setLabel(ASTContext &C, llvm::StringRef S) {
1177 labelLength = S.size();
1178 this->label = new (C, 1) char [labelLength];
1179 if (!S.empty())
1180 std::memcpy(this->label, S.data(), labelLength);
1181 }
1182
1183
1184
1185 static bool classof(const Attr *A) { return A->getKind() == attr::AsmLabel; }
1186};
1187
1188class AssertCapabilityAttr : public InheritableAttr {
1189 unsigned args_Size;
1190 Expr * *args_;
1191
1192public:
1193 enum Spelling {
1194 GNU_assert_capability = 0,
1195 CXX11_clang_assert_capability = 1,
1196 GNU_assert_shared_capability = 2,
1197 CXX11_clang_assert_shared_capability = 3
1198 };
1199
1200 static AssertCapabilityAttr *CreateImplicit(ASTContext &Ctx, Spelling S, Expr * *Args, unsigned ArgsSize, SourceRange Loc = SourceRange()) {
1201 auto *A = new (Ctx) AssertCapabilityAttr(Loc, Ctx, Args, ArgsSize, S);
1202 A->setImplicit(true);
1203 return A;
1204 }
1205
1206 AssertCapabilityAttr(SourceRange R, ASTContext &Ctx
1207 , Expr * *Args, unsigned ArgsSize
1208 , unsigned SI
1209 )
1210 : InheritableAttr(attr::AssertCapability, R, SI, true, true)
1211 , args_Size(ArgsSize), args_(new (Ctx, 16) Expr *[args_Size])
1212 {
1213 std::copy(Args, Args + args_Size, args_);
1214 }
1215
1216 AssertCapabilityAttr(SourceRange R, ASTContext &Ctx
1217 , unsigned SI
1218 )
1219 : InheritableAttr(attr::AssertCapability, R, SI, true, true)
1220 , args_Size(0), args_(nullptr)
1221 {
1222 }
1223
1224 AssertCapabilityAttr *clone(ASTContext &C) const;
1225 void printPretty(raw_ostream &OS,
1226 const PrintingPolicy &Policy) const;
1227 const char *getSpelling() const;
1228 Spelling getSemanticSpelling() const {
1229 switch (SpellingListIndex) {
1230 default: llvm_unreachable("Unknown spelling list index")::llvm::llvm_unreachable_internal("Unknown spelling list index"
, "/build/llvm-toolchain-snapshot-8~svn345461/build-llvm/tools/lldb/../clang/include/clang/AST/Attrs.inc"
, 1230)
;
1231 case 0: return GNU_assert_capability;
1232 case 1: return CXX11_clang_assert_capability;
1233 case 2: return GNU_assert_shared_capability;
1234 case 3: return CXX11_clang_assert_shared_capability;
1235 }
1236 }
1237 bool isShared() const { return SpellingListIndex == 2 ||
1238 SpellingListIndex == 3; }
1239 typedef Expr ** args_iterator;
1240 args_iterator args_begin() const { return args_; }
1241 args_iterator args_end() const { return args_ + args_Size; }
1242 unsigned args_size() const { return args_Size; }
1243 llvm::iterator_range<args_iterator> args() const { return llvm::make_range(args_begin(), args_end()); }
1244
1245
1246
1247
1248 static bool classof(const Attr *A) { return A->getKind() == attr::AssertCapability; }
1249};
1250
1251class AssertExclusiveLockAttr : public InheritableAttr {
1252 unsigned args_Size;
1253 Expr * *args_;
1254
1255public:
1256 static AssertExclusiveLockAttr *CreateImplicit(ASTContext &Ctx, Expr * *Args, unsigned ArgsSize, SourceRange Loc = SourceRange()) {
1257 auto *A = new (Ctx) AssertExclusiveLockAttr(Loc, Ctx, Args, ArgsSize, 0);
1258 A->setImplicit(true);
1259 return A;
1260 }
1261
1262 AssertExclusiveLockAttr(SourceRange R, ASTContext &Ctx
1263 , Expr * *Args, unsigned ArgsSize
1264 , unsigned SI
1265 )
1266 : InheritableAttr(attr::AssertExclusiveLock, R, SI, true, true)
1267 , args_Size(ArgsSize), args_(new (Ctx, 16) Expr *[args_Size])
1268 {
1269 std::copy(Args, Args + args_Size, args_);
1270 }
1271
1272 AssertExclusiveLockAttr(SourceRange R, ASTContext &Ctx
1273 , unsigned SI
1274 )
1275 : InheritableAttr(attr::AssertExclusiveLock, R, SI, true, true)
1276 , args_Size(0), args_(nullptr)
1277 {
1278 }
1279
1280 AssertExclusiveLockAttr *clone(ASTContext &C) const;
1281 void printPretty(raw_ostream &OS,
1282 const PrintingPolicy &Policy) const;
1283 const char *getSpelling() const;
1284 typedef Expr ** args_iterator;
1285 args_iterator args_begin() const { return args_; }
1286 args_iterator args_end() const { return args_ + args_Size; }
1287 unsigned args_size() const { return args_Size; }
1288 llvm::iterator_range<args_iterator> args() const { return llvm::make_range(args_begin(), args_end()); }
1289
1290
1291
1292
1293 static bool classof(const Attr *A) { return A->getKind() == attr::AssertExclusiveLock; }
1294};
1295
1296class AssertSharedLockAttr : public InheritableAttr {
1297 unsigned args_Size;
1298 Expr * *args_;
1299
1300public:
1301 static AssertSharedLockAttr *CreateImplicit(ASTContext &Ctx, Expr * *Args, unsigned ArgsSize, SourceRange Loc = SourceRange()) {
1302 auto *A = new (Ctx) AssertSharedLockAttr(Loc, Ctx, Args, ArgsSize, 0);
1303 A->setImplicit(true);
1304 return A;
1305 }
1306
1307 AssertSharedLockAttr(SourceRange R, ASTContext &Ctx
1308 , Expr * *Args, unsigned ArgsSize
1309 , unsigned SI
1310 )
1311 : InheritableAttr(attr::AssertSharedLock, R, SI, true, true)
1312 , args_Size(ArgsSize), args_(new (Ctx, 16) Expr *[args_Size])
1313 {
1314 std::copy(Args, Args + args_Size, args_);
1315 }
1316
1317 AssertSharedLockAttr(SourceRange R, ASTContext &Ctx
1318 , unsigned SI
1319 )
1320 : InheritableAttr(attr::AssertSharedLock, R, SI, true, true)
1321 , args_Size(0), args_(nullptr)
1322 {
1323 }
1324
1325 AssertSharedLockAttr *clone(ASTContext &C) const;
1326 void printPretty(raw_ostream &OS,
1327 const PrintingPolicy &Policy) const;
1328 const char *getSpelling() const;
1329 typedef Expr ** args_iterator;
1330 args_iterator args_begin() const { return args_; }
1331 args_iterator args_end() const { return args_ + args_Size; }
1332 unsigned args_size() const { return args_Size; }
1333 llvm::iterator_range<args_iterator> args() const { return llvm::make_range(args_begin(), args_end()); }
1334
1335
1336
1337
1338 static bool classof(const Attr *A) { return A->getKind() == attr::AssertSharedLock; }
1339};
1340
1341class AssumeAlignedAttr : public InheritableAttr {
1342Expr * alignment;
1343
1344Expr * offset;
1345
1346public:
1347 static AssumeAlignedAttr *CreateImplicit(ASTContext &Ctx, Expr * Alignment, Expr * Offset, SourceRange Loc = SourceRange()) {
1348 auto *A = new (Ctx) AssumeAlignedAttr(Loc, Ctx, Alignment, Offset, 0);
1349 A->setImplicit(true);
1350 return A;
1351 }
1352
1353 AssumeAlignedAttr(SourceRange R, ASTContext &Ctx
1354 , Expr * Alignment
1355 , Expr * Offset
1356 , unsigned SI
1357 )
1358 : InheritableAttr(attr::AssumeAligned, R, SI, false, false)
1359 , alignment(Alignment)
1360 , offset(Offset)
1361 {
1362 }
1363
1364 AssumeAlignedAttr(SourceRange R, ASTContext &Ctx
1365 , Expr * Alignment
1366 , unsigned SI
1367 )
1368 : InheritableAttr(attr::AssumeAligned, R, SI, false, false)
1369 , alignment(Alignment)
1370 , offset()
1371 {
1372 }
1373
1374 AssumeAlignedAttr *clone(ASTContext &C) const;
1375 void printPretty(raw_ostream &OS,
1376 const PrintingPolicy &Policy) const;
1377 const char *getSpelling() const;
1378 Expr * getAlignment() const {
1379 return alignment;
1380 }
1381
1382 Expr * getOffset() const {
1383 return offset;
1384 }
1385
1386
1387
1388 static bool classof(const Attr *A) { return A->getKind() == attr::AssumeAligned; }
1389};
1390
1391class AvailabilityAttr : public InheritableAttr {
1392IdentifierInfo * platform;
1393
1394VersionTuple introduced;
1395
1396
1397VersionTuple deprecated;
1398
1399
1400VersionTuple obsoleted;
1401
1402
1403bool unavailable;
1404
1405unsigned messageLength;
1406char *message;
1407
1408bool strict;
1409
1410unsigned replacementLength;
1411char *replacement;
1412
1413public:
1414 static AvailabilityAttr *CreateImplicit(ASTContext &Ctx, IdentifierInfo * Platform, VersionTuple Introduced, VersionTuple Deprecated, VersionTuple Obsoleted, bool Unavailable, llvm::StringRef Message, bool Strict, llvm::StringRef Replacement, SourceRange Loc = SourceRange()) {
1415 auto *A = new (Ctx) AvailabilityAttr(Loc, Ctx, Platform, Introduced, Deprecated, Obsoleted, Unavailable, Message, Strict, Replacement, 0);
1416 A->setImplicit(true);
1417 return A;
1418 }
1419
1420 AvailabilityAttr(SourceRange R, ASTContext &Ctx
1421 , IdentifierInfo * Platform
1422 , VersionTuple Introduced
1423 , VersionTuple Deprecated
1424 , VersionTuple Obsoleted
1425 , bool Unavailable
1426 , llvm::StringRef Message
1427 , bool Strict
1428 , llvm::StringRef Replacement
1429 , unsigned SI
1430 )
1431 : InheritableAttr(attr::Availability, R, SI, false, true)
1432 , platform(Platform)
1433 , introduced(Introduced)
1434 , deprecated(Deprecated)
1435 , obsoleted(Obsoleted)
1436 , unavailable(Unavailable)
1437 , messageLength(Message.size()),message(new (Ctx, 1) char[messageLength])
1438 , strict(Strict)
1439 , replacementLength(Replacement.size()),replacement(new (Ctx, 1) char[replacementLength])
1440 {
1441 if (!Message.empty())
1442 std::memcpy(message, Message.data(), messageLength);
1443 if (!Replacement.empty())
1444 std::memcpy(replacement, Replacement.data(), replacementLength);
1445 }
1446
1447 AvailabilityAttr *clone(ASTContext &C) const;
1448 void printPretty(raw_ostream &OS,
1449 const PrintingPolicy &Policy) const;
1450 const char *getSpelling() const;
1451 IdentifierInfo * getPlatform() const {
1452 return platform;
1453 }
1454
1455 VersionTuple getIntroduced() const {
1456 return introduced;
1457 }
1458 void setIntroduced(ASTContext &C, VersionTuple V) {
1459 introduced = V;
1460 }
1461
1462 VersionTuple getDeprecated() const {
1463 return deprecated;
1464 }
1465 void setDeprecated(ASTContext &C, VersionTuple V) {
1466 deprecated = V;
1467 }
1468
1469 VersionTuple getObsoleted() const {
1470 return obsoleted;
1471 }
1472 void setObsoleted(ASTContext &C, VersionTuple V) {
1473 obsoleted = V;
1474 }
1475
1476 bool getUnavailable() const {
1477 return unavailable;
1478 }
1479
1480 llvm::StringRef getMessage() const {
1481 return llvm::StringRef(message, messageLength);
1482 }
1483 unsigned getMessageLength() const {
1484 return messageLength;
1485 }
1486 void setMessage(ASTContext &C, llvm::StringRef S) {
1487 messageLength = S.size();
1488 this->message = new (C, 1) char [messageLength];
1489 if (!S.empty())
1490 std::memcpy(this->message, S.data(), messageLength);
1491 }
1492
1493 bool getStrict() const {
1494 return strict;
1495 }
1496
1497 llvm::StringRef getReplacement() const {
1498 return llvm::StringRef(replacement, replacementLength);
1499 }
1500 unsigned getReplacementLength() const {
1501 return replacementLength;
1502 }
1503 void setReplacement(ASTContext &C, llvm::StringRef S) {
1504 replacementLength = S.size();
1505 this->replacement = new (C, 1) char [replacementLength];
1506 if (!S.empty())
1507 std::memcpy(this->replacement, S.data(), replacementLength);
1508 }
1509
1510static llvm::StringRef getPrettyPlatformName(llvm::StringRef Platform) {
1511 return llvm::StringSwitch<llvm::StringRef>(Platform)
1512 .Case("android", "Android")
1513 .Case("ios", "iOS")
1514 .Case("macos", "macOS")
1515 .Case("tvos", "tvOS")
1516 .Case("watchos", "watchOS")
1517 .Case("ios_app_extension", "iOS (App Extension)")
1518 .Case("macos_app_extension", "macOS (App Extension)")
1519 .Case("tvos_app_extension", "tvOS (App Extension)")
1520 .Case("watchos_app_extension", "watchOS (App Extension)")
1521 .Default(llvm::StringRef());
1522}
1523static llvm::StringRef getPlatformNameSourceSpelling(llvm::StringRef Platform) {
1524 return llvm::StringSwitch<llvm::StringRef>(Platform)
1525 .Case("ios", "iOS")
1526 .Case("macos", "macOS")
1527 .Case("tvos", "tvOS")
1528 .Case("watchos", "watchOS")
1529 .Case("ios_app_extension", "iOSApplicationExtension")
1530 .Case("macos_app_extension", "macOSApplicationExtension")
1531 .Case("tvos_app_extension", "tvOSApplicationExtension")
1532 .Case("watchos_app_extension", "watchOSApplicationExtension")
1533 .Default(Platform);
1534}
1535static llvm::StringRef canonicalizePlatformName(llvm::StringRef Platform) {
1536 return llvm::StringSwitch<llvm::StringRef>(Platform)
1537 .Case("iOS", "ios")
1538 .Case("macOS", "macos")
1539 .Case("tvOS", "tvos")
1540 .Case("watchOS", "watchos")
1541 .Case("iOSApplicationExtension", "ios_app_extension")
1542 .Case("macOSApplicationExtension", "macos_app_extension")
1543 .Case("tvOSApplicationExtension", "tvos_app_extension")
1544 .Case("watchOSApplicationExtension", "watchos_app_extension")
1545 .Default(Platform);
1546}
1547
1548 static bool classof(const Attr *A) { return A->getKind() == attr::Availability; }
1549};
1550
1551class BlocksAttr : public InheritableAttr {
1552public:
1553 enum BlockType {
1554 ByRef
1555 };
1556private:
1557 BlockType type;
1558
1559public:
1560 static BlocksAttr *CreateImplicit(ASTContext &Ctx, BlockType Type, SourceRange Loc = SourceRange()) {
1561 auto *A = new (Ctx) BlocksAttr(Loc, Ctx, Type, 0);
1562 A->setImplicit(true);
1563 return A;
1564 }
1565
1566 BlocksAttr(SourceRange R, ASTContext &Ctx
1567 , BlockType Type
1568 , unsigned SI
1569 )
1570 : InheritableAttr(attr::Blocks, R, SI, false, false)
1571 , type(Type)
1572 {
1573 }
1574
1575 BlocksAttr *clone(ASTContext &C) const;
1576 void printPretty(raw_ostream &OS,
1577 const PrintingPolicy &Policy) const;
1578 const char *getSpelling() const;
1579 BlockType getType() const {
1580 return type;
1581 }
1582
1583 static bool ConvertStrToBlockType(StringRef Val, BlockType &Out) {
1584 Optional<BlockType> R = llvm::StringSwitch<Optional<BlockType>>(Val)
1585 .Case("byref", BlocksAttr::ByRef)
1586 .Default(Optional<BlockType>());
1587 if (R) {
1588 Out = *R;
1589 return true;
1590 }
1591 return false;
1592 }
1593
1594 static const char *ConvertBlockTypeToStr(BlockType Val) {
1595 switch(Val) {
1596 case BlocksAttr::ByRef: return "byref";
1597 }
1598 llvm_unreachable("No enumerator with that value")::llvm::llvm_unreachable_internal("No enumerator with that value"
, "/build/llvm-toolchain-snapshot-8~svn345461/build-llvm/tools/lldb/../clang/include/clang/AST/Attrs.inc"
, 1598)
;
1599 }
1600
1601
1602 static bool classof(const Attr *A) { return A->getKind() == attr::Blocks; }
1603};
1604
1605class C11NoReturnAttr : public InheritableAttr {
1606public:
1607 static C11NoReturnAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
1608 auto *A = new (Ctx) C11NoReturnAttr(Loc, Ctx, 0);
1609 A->setImplicit(true);
1610 return A;
1611 }
1612
1613 C11NoReturnAttr(SourceRange R, ASTContext &Ctx
1614 , unsigned SI
1615 )
1616 : InheritableAttr(attr::C11NoReturn, R, SI, false, false)
1617 {
1618 }
1619
1620 C11NoReturnAttr *clone(ASTContext &C) const;
1621 void printPretty(raw_ostream &OS,
1622 const PrintingPolicy &Policy) const;
1623 const char *getSpelling() const;
1624
1625
1626 static bool classof(const Attr *A) { return A->getKind() == attr::C11NoReturn; }
1627};
1628
1629class CDeclAttr : public InheritableAttr {
1630public:
1631 static CDeclAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
1632 auto *A = new (Ctx) CDeclAttr(Loc, Ctx, 0);
1633 A->setImplicit(true);
1634 return A;
1635 }
1636
1637 CDeclAttr(SourceRange R, ASTContext &Ctx
1638 , unsigned SI
1639 )
1640 : InheritableAttr(attr::CDecl, R, SI, false, false)
1641 {
1642 }
1643
1644 CDeclAttr *clone(ASTContext &C) const;
1645 void printPretty(raw_ostream &OS,
1646 const PrintingPolicy &Policy) const;
1647 const char *getSpelling() const;
1648
1649
1650 static bool classof(const Attr *A) { return A->getKind() == attr::CDecl; }
1651};
1652
1653class CFAuditedTransferAttr : public InheritableAttr {
1654public:
1655 static CFAuditedTransferAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
1656 auto *A = new (Ctx) CFAuditedTransferAttr(Loc, Ctx, 0);
1657 A->setImplicit(true);
1658 return A;
1659 }
1660
1661 CFAuditedTransferAttr(SourceRange R, ASTContext &Ctx
1662 , unsigned SI
1663 )
1664 : InheritableAttr(attr::CFAuditedTransfer, R, SI, false, false)
1665 {
1666 }
1667
1668 CFAuditedTransferAttr *clone(ASTContext &C) const;
1669 void printPretty(raw_ostream &OS,
1670 const PrintingPolicy &Policy) const;
1671 const char *getSpelling() const;
1672
1673
1674 static bool classof(const Attr *A) { return A->getKind() == attr::CFAuditedTransfer; }
1675};
1676
1677class CFConsumedAttr : public InheritableParamAttr {
1678public:
1679 static CFConsumedAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
1680 auto *A = new (Ctx) CFConsumedAttr(Loc, Ctx, 0);
1681 A->setImplicit(true);
1682 return A;
1683 }
1684
1685 CFConsumedAttr(SourceRange R, ASTContext &Ctx
1686 , unsigned SI
1687 )
1688 : InheritableParamAttr(attr::CFConsumed, R, SI, false, false)
1689 {
1690 }
1691
1692 CFConsumedAttr *clone(ASTContext &C) const;
1693 void printPretty(raw_ostream &OS,
1694 const PrintingPolicy &Policy) const;
1695 const char *getSpelling() const;
1696
1697
1698 static bool classof(const Attr *A) { return A->getKind() == attr::CFConsumed; }
1699};
1700
1701class CFReturnsNotRetainedAttr : public InheritableAttr {
1702public:
1703 static CFReturnsNotRetainedAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
1704 auto *A = new (Ctx) CFReturnsNotRetainedAttr(Loc, Ctx, 0);
1705 A->setImplicit(true);
1706 return A;
1707 }
1708
1709 CFReturnsNotRetainedAttr(SourceRange R, ASTContext &Ctx
1710 , unsigned SI
1711 )
1712 : InheritableAttr(attr::CFReturnsNotRetained, R, SI, false, false)
1713 {
1714 }
1715
1716 CFReturnsNotRetainedAttr *clone(ASTContext &C) const;
1717 void printPretty(raw_ostream &OS,
1718 const PrintingPolicy &Policy) const;
1719 const char *getSpelling() const;
1720
1721
1722 static bool classof(const Attr *A) { return A->getKind() == attr::CFReturnsNotRetained; }
1723};
1724
1725class CFReturnsRetainedAttr : public InheritableAttr {
1726public:
1727 static CFReturnsRetainedAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
1728 auto *A = new (Ctx) CFReturnsRetainedAttr(Loc, Ctx, 0);
1729 A->setImplicit(true);
1730 return A;
1731 }
1732
1733 CFReturnsRetainedAttr(SourceRange R, ASTContext &Ctx
1734 , unsigned SI
1735 )
1736 : InheritableAttr(attr::CFReturnsRetained, R, SI, false, false)
1737 {
1738 }
1739
1740 CFReturnsRetainedAttr *clone(ASTContext &C) const;
1741 void printPretty(raw_ostream &OS,
1742 const PrintingPolicy &Policy) const;
1743 const char *getSpelling() const;
1744
1745
1746 static bool classof(const Attr *A) { return A->getKind() == attr::CFReturnsRetained; }
1747};
1748
1749class CFUnknownTransferAttr : public InheritableAttr {
1750public:
1751 static CFUnknownTransferAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
1752 auto *A = new (Ctx) CFUnknownTransferAttr(Loc, Ctx, 0);
1753 A->setImplicit(true);
1754 return A;
1755 }
1756
1757 CFUnknownTransferAttr(SourceRange R, ASTContext &Ctx
1758 , unsigned SI
1759 )
1760 : InheritableAttr(attr::CFUnknownTransfer, R, SI, false, false)
1761 {
1762 }
1763
1764 CFUnknownTransferAttr *clone(ASTContext &C) const;
1765 void printPretty(raw_ostream &OS,
1766 const PrintingPolicy &Policy) const;
1767 const char *getSpelling() const;
1768
1769
1770 static bool classof(const Attr *A) { return A->getKind() == attr::CFUnknownTransfer; }
1771};
1772
1773class CPUDispatchAttr : public InheritableAttr {
1774 unsigned cpus_Size;
1775 IdentifierInfo * *cpus_;
1776
1777public:
1778 static CPUDispatchAttr *CreateImplicit(ASTContext &Ctx, IdentifierInfo * *Cpus, unsigned CpusSize, SourceRange Loc = SourceRange()) {
1779 auto *A = new (Ctx) CPUDispatchAttr(Loc, Ctx, Cpus, CpusSize, 0);
1780 A->setImplicit(true);
1781 return A;
1782 }
1783
1784 CPUDispatchAttr(SourceRange R, ASTContext &Ctx
1785 , IdentifierInfo * *Cpus, unsigned CpusSize
1786 , unsigned SI
1787 )
1788 : InheritableAttr(attr::CPUDispatch, R, SI, false, false)
1789 , cpus_Size(CpusSize), cpus_(new (Ctx, 16) IdentifierInfo *[cpus_Size])
1790 {
1791 std::copy(Cpus, Cpus + cpus_Size, cpus_);
1792 }
1793
1794 CPUDispatchAttr(SourceRange R, ASTContext &Ctx
1795 , unsigned SI
1796 )
1797 : InheritableAttr(attr::CPUDispatch, R, SI, false, false)
1798 , cpus_Size(0), cpus_(nullptr)
1799 {
1800 }
1801
1802 CPUDispatchAttr *clone(ASTContext &C) const;
1803 void printPretty(raw_ostream &OS,
1804 const PrintingPolicy &Policy) const;
1805 const char *getSpelling() const;
1806 typedef IdentifierInfo ** cpus_iterator;
1807 cpus_iterator cpus_begin() const { return cpus_; }
1808 cpus_iterator cpus_end() const { return cpus_ + cpus_Size; }
1809 unsigned cpus_size() const { return cpus_Size; }
1810 llvm::iterator_range<cpus_iterator> cpus() const { return llvm::make_range(cpus_begin(), cpus_end()); }
1811
1812
1813
1814
1815 static bool classof(const Attr *A) { return A->getKind() == attr::CPUDispatch; }
1816};
1817
1818class CPUSpecificAttr : public InheritableAttr {
1819 unsigned cpus_Size;
1820 IdentifierInfo * *cpus_;
1821
1822public:
1823 static CPUSpecificAttr *CreateImplicit(ASTContext &Ctx, IdentifierInfo * *Cpus, unsigned CpusSize, SourceRange Loc = SourceRange()) {
1824 auto *A = new (Ctx) CPUSpecificAttr(Loc, Ctx, Cpus, CpusSize, 0);
1825 A->setImplicit(true);
1826 return A;
1827 }
1828
1829 CPUSpecificAttr(SourceRange R, ASTContext &Ctx
1830 , IdentifierInfo * *Cpus, unsigned CpusSize
1831 , unsigned SI
1832 )
1833 : InheritableAttr(attr::CPUSpecific, R, SI, false, false)
1834 , cpus_Size(CpusSize), cpus_(new (Ctx, 16) IdentifierInfo *[cpus_Size])
1835 {
1836 std::copy(Cpus, Cpus + cpus_Size, cpus_);
1837 }
1838
1839 CPUSpecificAttr(SourceRange R, ASTContext &Ctx
1840 , unsigned SI
1841 )
1842 : InheritableAttr(attr::CPUSpecific, R, SI, false, false)
1843 , cpus_Size(0), cpus_(nullptr)
1844 {
1845 }
1846
1847 CPUSpecificAttr *clone(ASTContext &C) const;
1848 void printPretty(raw_ostream &OS,
1849 const PrintingPolicy &Policy) const;
1850 const char *getSpelling() const;
1851 typedef IdentifierInfo ** cpus_iterator;
1852 cpus_iterator cpus_begin() const { return cpus_; }
1853 cpus_iterator cpus_end() const { return cpus_ + cpus_Size; }
1854 unsigned cpus_size() const { return cpus_Size; }
1855 llvm::iterator_range<cpus_iterator> cpus() const { return llvm::make_range(cpus_begin(), cpus_end()); }
1856
1857
1858
1859 unsigned ActiveArgIndex = 0;
1860
1861 IdentifierInfo *getCurCPUName() const {
1862 return *(cpus_begin() + ActiveArgIndex);
1863 }
1864
1865
1866 static bool classof(const Attr *A) { return A->getKind() == attr::CPUSpecific; }
1867};
1868
1869class CUDAConstantAttr : public InheritableAttr {
1870public:
1871 static CUDAConstantAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
1872 auto *A = new (Ctx) CUDAConstantAttr(Loc, Ctx, 0);
1873 A->setImplicit(true);
1874 return A;
1875 }
1876
1877 CUDAConstantAttr(SourceRange R, ASTContext &Ctx
1878 , unsigned SI
1879 )
1880 : InheritableAttr(attr::CUDAConstant, R, SI, false, false)
1881 {
1882 }
1883
1884 CUDAConstantAttr *clone(ASTContext &C) const;
1885 void printPretty(raw_ostream &OS,
1886 const PrintingPolicy &Policy) const;
1887 const char *getSpelling() const;
1888
1889
1890 static bool classof(const Attr *A) { return A->getKind() == attr::CUDAConstant; }
1891};
1892
1893class CUDADeviceAttr : public InheritableAttr {
1894public:
1895 static CUDADeviceAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
1896 auto *A = new (Ctx) CUDADeviceAttr(Loc, Ctx, 0);
1897 A->setImplicit(true);
1898 return A;
1899 }
1900
1901 CUDADeviceAttr(SourceRange R, ASTContext &Ctx
1902 , unsigned SI
1903 )
1904 : InheritableAttr(attr::CUDADevice, R, SI, false, false)
1905 {
1906 }
1907
1908 CUDADeviceAttr *clone(ASTContext &C) const;
1909 void printPretty(raw_ostream &OS,
1910 const PrintingPolicy &Policy) const;
1911 const char *getSpelling() const;
1912
1913
1914 static bool classof(const Attr *A) { return A->getKind() == attr::CUDADevice; }
1915};
1916
1917class CUDAGlobalAttr : public InheritableAttr {
1918public:
1919 static CUDAGlobalAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
1920 auto *A = new (Ctx) CUDAGlobalAttr(Loc, Ctx, 0);
1921 A->setImplicit(true);
1922 return A;
1923 }
1924
1925 CUDAGlobalAttr(SourceRange R, ASTContext &Ctx
1926 , unsigned SI
1927 )
1928 : InheritableAttr(attr::CUDAGlobal, R, SI, false, false)
1929 {
1930 }
1931
1932 CUDAGlobalAttr *clone(ASTContext &C) const;
1933 void printPretty(raw_ostream &OS,
1934 const PrintingPolicy &Policy) const;
1935 const char *getSpelling() const;
1936
1937
1938 static bool classof(const Attr *A) { return A->getKind() == attr::CUDAGlobal; }
1939};
1940
1941class CUDAHostAttr : public InheritableAttr {
1942public:
1943 static CUDAHostAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
1944 auto *A = new (Ctx) CUDAHostAttr(Loc, Ctx, 0);
1945 A->setImplicit(true);
1946 return A;
1947 }
1948
1949 CUDAHostAttr(SourceRange R, ASTContext &Ctx
1950 , unsigned SI
1951 )
1952 : InheritableAttr(attr::CUDAHost, R, SI, false, false)
1953 {
1954 }
1955
1956 CUDAHostAttr *clone(ASTContext &C) const;
1957 void printPretty(raw_ostream &OS,
1958 const PrintingPolicy &Policy) const;
1959 const char *getSpelling() const;
1960
1961
1962 static bool classof(const Attr *A) { return A->getKind() == attr::CUDAHost; }
1963};
1964
1965class CUDAInvalidTargetAttr : public InheritableAttr {
1966public:
1967 static CUDAInvalidTargetAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
1968 auto *A = new (Ctx) CUDAInvalidTargetAttr(Loc, Ctx, 0);
1969 A->setImplicit(true);
1970 return A;
1971 }
1972
1973 CUDAInvalidTargetAttr(SourceRange R, ASTContext &Ctx
1974 , unsigned SI
1975 )
1976 : InheritableAttr(attr::CUDAInvalidTarget, R, SI, false, false)
1977 {
1978 }
1979
1980 CUDAInvalidTargetAttr *clone(ASTContext &C) const;
1981 void printPretty(raw_ostream &OS,
1982 const PrintingPolicy &Policy) const;
1983 const char *getSpelling() const;
1984
1985
1986 static bool classof(const Attr *A) { return A->getKind() == attr::CUDAInvalidTarget; }
1987};
1988
1989class CUDALaunchBoundsAttr : public InheritableAttr {
1990Expr * maxThreads;
1991
1992Expr * minBlocks;
1993
1994public:
1995 static CUDALaunchBoundsAttr *CreateImplicit(ASTContext &Ctx, Expr * MaxThreads, Expr * MinBlocks, SourceRange Loc = SourceRange()) {
1996 auto *A = new (Ctx) CUDALaunchBoundsAttr(Loc, Ctx, MaxThreads, MinBlocks, 0);
1997 A->setImplicit(true);
1998 return A;
1999 }
2000
2001 CUDALaunchBoundsAttr(SourceRange R, ASTContext &Ctx
2002 , Expr * MaxThreads
2003 , Expr * MinBlocks
2004 , unsigned SI
2005 )
2006 : InheritableAttr(attr::CUDALaunchBounds, R, SI, false, false)
2007 , maxThreads(MaxThreads)
2008 , minBlocks(MinBlocks)
2009 {
2010 }
2011
2012 CUDALaunchBoundsAttr(SourceRange R, ASTContext &Ctx
2013 , Expr * MaxThreads
2014 , unsigned SI
2015 )
2016 : InheritableAttr(attr::CUDALaunchBounds, R, SI, false, false)
2017 , maxThreads(MaxThreads)
2018 , minBlocks()
2019 {
2020 }
2021
2022 CUDALaunchBoundsAttr *clone(ASTContext &C) const;
2023 void printPretty(raw_ostream &OS,
2024 const PrintingPolicy &Policy) const;
2025 const char *getSpelling() const;
2026 Expr * getMaxThreads() const {
2027 return maxThreads;
2028 }
2029
2030 Expr * getMinBlocks() const {
2031 return minBlocks;
2032 }
2033
2034
2035
2036 static bool classof(const Attr *A) { return A->getKind() == attr::CUDALaunchBounds; }
2037};
2038
2039class CUDASharedAttr : public InheritableAttr {
2040public:
2041 static CUDASharedAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
2042 auto *A = new (Ctx) CUDASharedAttr(Loc, Ctx, 0);
2043 A->setImplicit(true);
2044 return A;
2045 }
2046
2047 CUDASharedAttr(SourceRange R, ASTContext &Ctx
2048 , unsigned SI
2049 )
2050 : InheritableAttr(attr::CUDAShared, R, SI, false, false)
2051 {
2052 }
2053
2054 CUDASharedAttr *clone(ASTContext &C) const;
2055 void printPretty(raw_ostream &OS,
2056 const PrintingPolicy &Policy) const;
2057 const char *getSpelling() const;
2058
2059
2060 static bool classof(const Attr *A) { return A->getKind() == attr::CUDAShared; }
2061};
2062
2063class CXX11NoReturnAttr : public InheritableAttr {
2064public:
2065 static CXX11NoReturnAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
2066 auto *A = new (Ctx) CXX11NoReturnAttr(Loc, Ctx, 0);
2067 A->setImplicit(true);
2068 return A;
2069 }
2070
2071 CXX11NoReturnAttr(SourceRange R, ASTContext &Ctx
2072 , unsigned SI
2073 )
2074 : InheritableAttr(attr::CXX11NoReturn, R, SI, false, false)
2075 {
2076 }
2077
2078 CXX11NoReturnAttr *clone(ASTContext &C) const;
2079 void printPretty(raw_ostream &OS,
2080 const PrintingPolicy &Policy) const;
2081 const char *getSpelling() const;
2082
2083
2084 static bool classof(const Attr *A) { return A->getKind() == attr::CXX11NoReturn; }
2085};
2086
2087class CallableWhenAttr : public InheritableAttr {
2088public:
2089 enum ConsumedState {
2090 Unknown,
2091 Consumed,
2092 Unconsumed
2093 };
2094private:
2095 unsigned callableStates_Size;
2096 ConsumedState *callableStates_;
2097
2098public:
2099 static CallableWhenAttr *CreateImplicit(ASTContext &Ctx, ConsumedState *CallableStates, unsigned CallableStatesSize, SourceRange Loc = SourceRange()) {
2100 auto *A = new (Ctx) CallableWhenAttr(Loc, Ctx, CallableStates, CallableStatesSize, 0);
2101 A->setImplicit(true);
2102 return A;
2103 }
2104
2105 CallableWhenAttr(SourceRange R, ASTContext &Ctx
2106 , ConsumedState *CallableStates, unsigned CallableStatesSize
2107 , unsigned SI
2108 )
2109 : InheritableAttr(attr::CallableWhen, R, SI, false, false)
2110 , callableStates_Size(CallableStatesSize), callableStates_(new (Ctx, 16) ConsumedState[callableStates_Size])
2111 {
2112 std::copy(CallableStates, CallableStates + callableStates_Size, callableStates_);
2113 }
2114
2115 CallableWhenAttr(SourceRange R, ASTContext &Ctx
2116 , unsigned SI
2117 )
2118 : InheritableAttr(attr::CallableWhen, R, SI, false, false)
2119 , callableStates_Size(0), callableStates_(nullptr)
2120 {
2121 }
2122
2123 CallableWhenAttr *clone(ASTContext &C) const;
2124 void printPretty(raw_ostream &OS,
2125 const PrintingPolicy &Policy) const;
2126 const char *getSpelling() const;
2127 typedef ConsumedState* callableStates_iterator;
2128 callableStates_iterator callableStates_begin() const { return callableStates_; }
2129 callableStates_iterator callableStates_end() const { return callableStates_ + callableStates_Size; }
2130 unsigned callableStates_size() const { return callableStates_Size; }
2131 llvm::iterator_range<callableStates_iterator> callableStates() const { return llvm::make_range(callableStates_begin(), callableStates_end()); }
2132
2133
2134 static bool ConvertStrToConsumedState(StringRef Val, ConsumedState &Out) {
2135 Optional<ConsumedState> R = llvm::StringSwitch<Optional<ConsumedState>>(Val)
2136 .Case("unknown", CallableWhenAttr::Unknown)
2137 .Case("consumed", CallableWhenAttr::Consumed)
2138 .Case("unconsumed", CallableWhenAttr::Unconsumed)
2139 .Default(Optional<ConsumedState>());
2140 if (R) {
2141 Out = *R;
2142 return true;
2143 }
2144 return false;
2145 }
2146
2147 static const char *ConvertConsumedStateToStr(ConsumedState Val) {
2148 switch(Val) {
2149 case CallableWhenAttr::Unknown: return "unknown";
2150 case CallableWhenAttr::Consumed: return "consumed";
2151 case CallableWhenAttr::Unconsumed: return "unconsumed";
2152 }
2153 llvm_unreachable("No enumerator with that value")::llvm::llvm_unreachable_internal("No enumerator with that value"
, "/build/llvm-toolchain-snapshot-8~svn345461/build-llvm/tools/lldb/../clang/include/clang/AST/Attrs.inc"
, 2153)
;
2154 }
2155
2156
2157 static bool classof(const Attr *A) { return A->getKind() == attr::CallableWhen; }
2158};
2159
2160class CapabilityAttr : public InheritableAttr {
2161unsigned nameLength;
2162char *name;
2163
2164public:
2165 enum Spelling {
2166 GNU_capability = 0,
2167 CXX11_clang_capability = 1,
2168 GNU_shared_capability = 2,
2169 CXX11_clang_shared_capability = 3
2170 };
2171
2172 static CapabilityAttr *CreateImplicit(ASTContext &Ctx, Spelling S, llvm::StringRef Name, SourceRange Loc = SourceRange()) {
2173 auto *A = new (Ctx) CapabilityAttr(Loc, Ctx, Name, S);
2174 A->setImplicit(true);
2175 return A;
2176 }
2177
2178 CapabilityAttr(SourceRange R, ASTContext &Ctx
2179 , llvm::StringRef Name
2180 , unsigned SI
2181 )
2182 : InheritableAttr(attr::Capability, R, SI, false, false)
2183 , nameLength(Name.size()),name(new (Ctx, 1) char[nameLength])
2184 {
2185 if (!Name.empty())
2186 std::memcpy(name, Name.data(), nameLength);
2187 }
2188
2189 CapabilityAttr *clone(ASTContext &C) const;
2190 void printPretty(raw_ostream &OS,
2191 const PrintingPolicy &Policy) const;
2192 const char *getSpelling() const;
2193 Spelling getSemanticSpelling() const {
2194 switch (SpellingListIndex) {
2195 default: llvm_unreachable("Unknown spelling list index")::llvm::llvm_unreachable_internal("Unknown spelling list index"
, "/build/llvm-toolchain-snapshot-8~svn345461/build-llvm/tools/lldb/../clang/include/clang/AST/Attrs.inc"
, 2195)
;
2196 case 0: return GNU_capability;
2197 case 1: return CXX11_clang_capability;
2198 case 2: return GNU_shared_capability;
2199 case 3: return CXX11_clang_shared_capability;
2200 }
2201 }
2202 bool isShared() const { return SpellingListIndex == 2 ||
2203 SpellingListIndex == 3; }
2204 llvm::StringRef getName() const {
2205 return llvm::StringRef(name, nameLength);
2206 }
2207 unsigned getNameLength() const {
2208 return nameLength;
2209 }
2210 void setName(ASTContext &C, llvm::StringRef S) {
2211 nameLength = S.size();
2212 this->name = new (C, 1) char [nameLength];
2213 if (!S.empty())
2214 std::memcpy(this->name, S.data(), nameLength);
2215 }
2216
2217
2218 bool isMutex() const { return getName().equals_lower("mutex"); }
2219 bool isRole() const { return getName().equals_lower("role"); }
2220
2221
2222 static bool classof(const Attr *A) { return A->getKind() == attr::Capability; }
2223};
2224
2225class CapturedRecordAttr : public InheritableAttr {
2226public:
2227 static CapturedRecordAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
2228 auto *A = new (Ctx) CapturedRecordAttr(Loc, Ctx, 0);
2229 A->setImplicit(true);
2230 return A;
2231 }
2232
2233 CapturedRecordAttr(SourceRange R, ASTContext &Ctx
2234 , unsigned SI
2235 )
2236 : InheritableAttr(attr::CapturedRecord, R, SI, false, false)
2237 {
2238 }
2239
2240 CapturedRecordAttr *clone(ASTContext &C) const;
2241 void printPretty(raw_ostream &OS,
2242 const PrintingPolicy &Policy) const;
2243 const char *getSpelling() const;
2244
2245
2246 static bool classof(const Attr *A) { return A->getKind() == attr::CapturedRecord; }
2247};
2248
2249class CarriesDependencyAttr : public InheritableParamAttr {
2250public:
2251 static CarriesDependencyAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
2252 auto *A = new (Ctx) CarriesDependencyAttr(Loc, Ctx, 0);
2253 A->setImplicit(true);
2254 return A;
2255 }
2256
2257 CarriesDependencyAttr(SourceRange R, ASTContext &Ctx
2258 , unsigned SI
2259 )
2260 : InheritableParamAttr(attr::CarriesDependency, R, SI, false, false)
2261 {
2262 }
2263
2264 CarriesDependencyAttr *clone(ASTContext &C) const;
2265 void printPretty(raw_ostream &OS,
2266 const PrintingPolicy &Policy) const;
2267 const char *getSpelling() const;
2268
2269
2270 static bool classof(const Attr *A) { return A->getKind() == attr::CarriesDependency; }
2271};
2272
2273class CleanupAttr : public InheritableAttr {
2274FunctionDecl * functionDecl;
2275
2276public:
2277 static CleanupAttr *CreateImplicit(ASTContext &Ctx, FunctionDecl * FunctionDecl, SourceRange Loc = SourceRange()) {
2278 auto *A = new (Ctx) CleanupAttr(Loc, Ctx, FunctionDecl, 0);
2279 A->setImplicit(true);
2280 return A;
2281 }
2282
2283 CleanupAttr(SourceRange R, ASTContext &Ctx
2284 , FunctionDecl * FunctionDecl
2285 , unsigned SI
2286 )
2287 : InheritableAttr(attr::Cleanup, R, SI, false, false)
2288 , functionDecl(FunctionDecl)
2289 {
2290 }
2291
2292 CleanupAttr *clone(ASTContext &C) const;
2293 void printPretty(raw_ostream &OS,
2294 const PrintingPolicy &Policy) const;
2295 const char *getSpelling() const;
2296 FunctionDecl * getFunctionDecl() const {
2297 return functionDecl;
2298 }
2299
2300
2301
2302 static bool classof(const Attr *A) { return A->getKind() == attr::Cleanup; }
2303};
2304
2305class CodeSegAttr : public InheritableAttr {
2306unsigned nameLength;
2307char *name;
2308
2309public:
2310 static CodeSegAttr *CreateImplicit(ASTContext &Ctx, llvm::StringRef Name, SourceRange Loc = SourceRange()) {
2311 auto *A = new (Ctx) CodeSegAttr(Loc, Ctx, Name, 0);
2312 A->setImplicit(true);
2313 return A;
2314 }
2315
2316 CodeSegAttr(SourceRange R, ASTContext &Ctx
2317 , llvm::StringRef Name
2318 , unsigned SI
2319 )
2320 : InheritableAttr(attr::CodeSeg, R, SI, false, false)
2321 , nameLength(Name.size()),name(new (Ctx, 1) char[nameLength])
2322 {
2323 if (!Name.empty())
2324 std::memcpy(name, Name.data(), nameLength);
2325 }
2326
2327 CodeSegAttr *clone(ASTContext &C) const;
2328 void printPretty(raw_ostream &OS,
2329 const PrintingPolicy &Policy) const;
2330 const char *getSpelling() const;
2331 llvm::StringRef getName() const {
2332 return llvm::StringRef(name, nameLength);
2333 }
2334 unsigned getNameLength() const {
2335 return nameLength;
2336 }
2337 void setName(ASTContext &C, llvm::StringRef S) {
2338 nameLength = S.size();
2339 this->name = new (C, 1) char [nameLength];
2340 if (!S.empty())
2341 std::memcpy(this->name, S.data(), nameLength);
2342 }
2343
2344
2345
2346 static bool classof(const Attr *A) { return A->getKind() == attr::CodeSeg; }
2347};
2348
2349class ColdAttr : public InheritableAttr {
2350public:
2351 static ColdAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
2352 auto *A = new (Ctx) ColdAttr(Loc, Ctx, 0);
2353 A->setImplicit(true);
2354 return A;
2355 }
2356
2357 ColdAttr(SourceRange R, ASTContext &Ctx
2358 , unsigned SI
2359 )
2360 : InheritableAttr(attr::Cold, R, SI, false, false)
2361 {
2362 }
2363
2364 ColdAttr *clone(ASTContext &C) const;
2365 void printPretty(raw_ostream &OS,
2366 const PrintingPolicy &Policy) const;
2367 const char *getSpelling() const;
2368
2369
2370 static bool classof(const Attr *A) { return A->getKind() == attr::Cold; }
2371};
2372
2373class CommonAttr : public InheritableAttr {
2374public:
2375 static CommonAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
2376 auto *A = new (Ctx) CommonAttr(Loc, Ctx, 0);
2377 A->setImplicit(true);
2378 return A;
2379 }
2380
2381 CommonAttr(SourceRange R, ASTContext &Ctx
2382 , unsigned SI
2383 )
2384 : InheritableAttr(attr::Common, R, SI, false, false)
2385 {
2386 }
2387
2388 CommonAttr *clone(ASTContext &C) const;
2389 void printPretty(raw_ostream &OS,
2390 const PrintingPolicy &Policy) const;
2391 const char *getSpelling() const;
2392
2393
2394 static bool classof(const Attr *A) { return A->getKind() == attr::Common; }
2395};
2396
2397class ConstAttr : public InheritableAttr {
2398public:
2399 static ConstAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
2400 auto *A = new (Ctx) ConstAttr(Loc, Ctx, 0);
2401 A->setImplicit(true);
2402 return A;
2403 }
2404
2405 ConstAttr(SourceRange R, ASTContext &Ctx
2406 , unsigned SI
2407 )
2408 : InheritableAttr(attr::Const, R, SI, false, false)
2409 {
2410 }
2411
2412 ConstAttr *clone(ASTContext &C) const;
2413 void printPretty(raw_ostream &OS,
2414 const PrintingPolicy &Policy) const;
2415 const char *getSpelling() const;
2416
2417
2418 static bool classof(const Attr *A) { return A->getKind() == attr::Const; }
2419};
2420
2421class ConstructorAttr : public InheritableAttr {
2422int priority;
2423
2424public:
2425 static ConstructorAttr *CreateImplicit(ASTContext &Ctx, int Priority, SourceRange Loc = SourceRange()) {
2426 auto *A = new (Ctx) ConstructorAttr(Loc, Ctx, Priority, 0);
2427 A->setImplicit(true);
2428 return A;
2429 }
2430
2431 ConstructorAttr(SourceRange R, ASTContext &Ctx
2432 , int Priority
2433 , unsigned SI
2434 )
2435 : InheritableAttr(attr::Constructor, R, SI, false, false)
2436 , priority(Priority)
2437 {
2438 }
2439
2440 ConstructorAttr(SourceRange R, ASTContext &Ctx
2441 , unsigned SI
2442 )
2443 : InheritableAttr(attr::Constructor, R, SI, false, false)
2444 , priority()
2445 {
2446 }
2447
2448 ConstructorAttr *clone(ASTContext &C) const;
2449 void printPretty(raw_ostream &OS,
2450 const PrintingPolicy &Policy) const;
2451 const char *getSpelling() const;
2452 int getPriority() const {
2453 return priority;
2454 }
2455
2456 static const int DefaultPriority = 65535;
2457
2458
2459
2460 static bool classof(const Attr *A) { return A->getKind() == attr::Constructor; }
2461};
2462
2463class ConsumableAttr : public InheritableAttr {
2464public:
2465 enum ConsumedState {
2466 Unknown,
2467 Consumed,
2468 Unconsumed
2469 };
2470private:
2471 ConsumedState defaultState;
2472
2473public:
2474 static ConsumableAttr *CreateImplicit(ASTContext &Ctx, ConsumedState DefaultState, SourceRange Loc = SourceRange()) {
2475 auto *A = new (Ctx) ConsumableAttr(Loc, Ctx, DefaultState, 0);
2476 A->setImplicit(true);
2477 return A;
2478 }
2479
2480 ConsumableAttr(SourceRange R, ASTContext &Ctx
2481 , ConsumedState DefaultState
2482 , unsigned SI
2483 )
2484 : InheritableAttr(attr::Consumable, R, SI, false, false)
2485 , defaultState(DefaultState)
2486 {
2487 }
2488
2489 ConsumableAttr *clone(ASTContext &C) const;
2490 void printPretty(raw_ostream &OS,
2491 const PrintingPolicy &Policy) const;
2492 const char *getSpelling() const;
2493 ConsumedState getDefaultState() const {
2494 return defaultState;
2495 }
2496
2497 static bool ConvertStrToConsumedState(StringRef Val, ConsumedState &Out) {
2498 Optional<ConsumedState> R = llvm::StringSwitch<Optional<ConsumedState>>(Val)
2499 .Case("unknown", ConsumableAttr::Unknown)
2500 .Case("consumed", ConsumableAttr::Consumed)
2501 .Case("unconsumed", ConsumableAttr::Unconsumed)
2502 .Default(Optional<ConsumedState>());
2503 if (R) {
2504 Out = *R;
2505 return true;
2506 }
2507 return false;
2508 }
2509
2510 static const char *ConvertConsumedStateToStr(ConsumedState Val) {
2511 switch(Val) {
2512 case ConsumableAttr::Unknown: return "unknown";
2513 case ConsumableAttr::Consumed: return "consumed";
2514 case ConsumableAttr::Unconsumed: return "unconsumed";
2515 }
2516 llvm_unreachable("No enumerator with that value")::llvm::llvm_unreachable_internal("No enumerator with that value"
, "/build/llvm-toolchain-snapshot-8~svn345461/build-llvm/tools/lldb/../clang/include/clang/AST/Attrs.inc"
, 2516)
;
2517 }
2518
2519
2520 static bool classof(const Attr *A) { return A->getKind() == attr::Consumable; }
2521};
2522
2523class ConsumableAutoCastAttr : public InheritableAttr {
2524public:
2525 static ConsumableAutoCastAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
2526 auto *A = new (Ctx) ConsumableAutoCastAttr(Loc, Ctx, 0);
2527 A->setImplicit(true);
2528 return A;
2529 }
2530
2531 ConsumableAutoCastAttr(SourceRange R, ASTContext &Ctx
2532 , unsigned SI
2533 )
2534 : InheritableAttr(attr::ConsumableAutoCast, R, SI, false, false)
2535 {
2536 }
2537
2538 ConsumableAutoCastAttr *clone(ASTContext &C) const;
2539 void printPretty(raw_ostream &OS,
2540 const PrintingPolicy &Policy) const;
2541 const char *getSpelling() const;
2542
2543
2544 static bool classof(const Attr *A) { return A->getKind() == attr::ConsumableAutoCast; }
2545};
2546
2547class ConsumableSetOnReadAttr : public InheritableAttr {
2548public:
2549 static ConsumableSetOnReadAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
2550 auto *A = new (Ctx) ConsumableSetOnReadAttr(Loc, Ctx, 0);
2551 A->setImplicit(true);
2552 return A;
2553 }
2554
2555 ConsumableSetOnReadAttr(SourceRange R, ASTContext &Ctx
2556 , unsigned SI
2557 )
2558 : InheritableAttr(attr::ConsumableSetOnRead, R, SI, false, false)
2559 {
2560 }
2561
2562 ConsumableSetOnReadAttr *clone(ASTContext &C) const;
2563 void printPretty(raw_ostream &OS,
2564 const PrintingPolicy &Policy) const;
2565 const char *getSpelling() const;
2566
2567
2568 static bool classof(const Attr *A) { return A->getKind() == attr::ConsumableSetOnRead; }
2569};
2570
2571class ConvergentAttr : public InheritableAttr {
2572public:
2573 static ConvergentAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
2574 auto *A = new (Ctx) ConvergentAttr(Loc, Ctx, 0);
2575 A->setImplicit(true);
2576 return A;
2577 }
2578
2579 ConvergentAttr(SourceRange R, ASTContext &Ctx
2580 , unsigned SI
2581 )
2582 : InheritableAttr(attr::Convergent, R, SI, false, false)
2583 {
2584 }
2585
2586 ConvergentAttr *clone(ASTContext &C) const;
2587 void printPretty(raw_ostream &OS,
2588 const PrintingPolicy &Policy) const;
2589 const char *getSpelling() const;
2590
2591
2592 static bool classof(const Attr *A) { return A->getKind() == attr::Convergent; }
2593};
2594
2595class DLLExportAttr : public InheritableAttr {
2596public:
2597 static DLLExportAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
2598 auto *A = new (Ctx) DLLExportAttr(Loc, Ctx, 0);
2599 A->setImplicit(true);
2600 return A;
2601 }
2602
2603 DLLExportAttr(SourceRange R, ASTContext &Ctx
2604 , unsigned SI
2605 )
2606 : InheritableAttr(attr::DLLExport, R, SI, false, false)
2607 {
2608 }
2609
2610 DLLExportAttr *clone(ASTContext &C) const;
2611 void printPretty(raw_ostream &OS,
2612 const PrintingPolicy &Policy) const;
2613 const char *getSpelling() const;
2614
2615
2616 static bool classof(const Attr *A) { return A->getKind() == attr::DLLExport; }
2617};
2618
2619class DLLImportAttr : public InheritableAttr {
2620public:
2621 static DLLImportAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
2622 auto *A = new (Ctx) DLLImportAttr(Loc, Ctx, 0);
2623 A->setImplicit(true);
2624 return A;
2625 }
2626
2627 DLLImportAttr(SourceRange R, ASTContext &Ctx
2628 , unsigned SI
2629 )
2630 : InheritableAttr(attr::DLLImport, R, SI, false, false)
2631 {
2632 }
2633
2634 DLLImportAttr *clone(ASTContext &C) const;
2635 void printPretty(raw_ostream &OS,
2636 const PrintingPolicy &Policy) const;
2637 const char *getSpelling() const;
2638
2639private:
2640 bool PropagatedToBaseTemplate = false;
2641
2642public:
2643 void setPropagatedToBaseTemplate() { PropagatedToBaseTemplate = true; }
2644 bool wasPropagatedToBaseTemplate() { return PropagatedToBaseTemplate; }
2645
2646
2647 static bool classof(const Attr *A) { return A->getKind() == attr::DLLImport; }
2648};
2649
2650class DeprecatedAttr : public InheritableAttr {
2651unsigned messageLength;
2652char *message;
2653
2654unsigned replacementLength;
2655char *replacement;
2656
2657public:
2658 static DeprecatedAttr *CreateImplicit(ASTContext &Ctx, llvm::StringRef Message, llvm::StringRef Replacement, SourceRange Loc = SourceRange()) {
2659 auto *A = new (Ctx) DeprecatedAttr(Loc, Ctx, Message, Replacement, 0);
2660 A->setImplicit(true);
2661 return A;
2662 }
2663
2664 DeprecatedAttr(SourceRange R, ASTContext &Ctx
2665 , llvm::StringRef Message
2666 , llvm::StringRef Replacement
2667 , unsigned SI
2668 )
2669 : InheritableAttr(attr::Deprecated, R, SI, false, false)
2670 , messageLength(Message.size()),message(new (Ctx, 1) char[messageLength])
2671 , replacementLength(Replacement.size()),replacement(new (Ctx, 1) char[replacementLength])
2672 {
2673 if (!Message.empty())
2674 std::memcpy(message, Message.data(), messageLength);
2675 if (!Replacement.empty())
2676 std::memcpy(replacement, Replacement.data(), replacementLength);
2677 }
2678
2679 DeprecatedAttr(SourceRange R, ASTContext &Ctx
2680 , unsigned SI
2681 )
2682 : InheritableAttr(attr::Deprecated, R, SI, false, false)
2683 , messageLength(0),message(nullptr)
2684 , replacementLength(0),replacement(nullptr)
2685 {
2686 }
2687
2688 DeprecatedAttr *clone(ASTContext &C) const;
2689 void printPretty(raw_ostream &OS,
2690 const PrintingPolicy &Policy) const;
2691 const char *getSpelling() const;
2692 llvm::StringRef getMessage() const {
2693 return llvm::StringRef(message, messageLength);
2694 }
2695 unsigned getMessageLength() const {
2696 return messageLength;
2697 }
2698 void setMessage(ASTContext &C, llvm::StringRef S) {
2699 messageLength = S.size();
2700 this->message = new (C, 1) char [messageLength];
2701 if (!S.empty())
2702 std::memcpy(this->message, S.data(), messageLength);
2703 }
2704
2705 llvm::StringRef getReplacement() const {
2706 return llvm::StringRef(replacement, replacementLength);
2707 }
2708 unsigned getReplacementLength() const {
2709 return replacementLength;
2710 }
2711 void setReplacement(ASTContext &C, llvm::StringRef S) {
2712 replacementLength = S.size();
2713 this->replacement = new (C, 1) char [replacementLength];
2714 if (!S.empty())
2715 std::memcpy(this->replacement, S.data(), replacementLength);
2716 }
2717
2718
2719
2720 static bool classof(const Attr *A) { return A->getKind() == attr::Deprecated; }
2721};
2722
2723class DestructorAttr : public InheritableAttr {
2724int priority;
2725
2726public:
2727 static DestructorAttr *CreateImplicit(ASTContext &Ctx, int Priority, SourceRange Loc = SourceRange()) {
2728 auto *A = new (Ctx) DestructorAttr(Loc, Ctx, Priority, 0);
2729 A->setImplicit(true);
2730 return A;
2731 }
2732
2733 DestructorAttr(SourceRange R, ASTContext &Ctx
2734 , int Priority
2735 , unsigned SI
2736 )
2737 : InheritableAttr(attr::Destructor, R, SI, false, false)
2738 , priority(Priority)
2739 {
2740 }
2741
2742 DestructorAttr(SourceRange R, ASTContext &Ctx
2743 , unsigned SI
2744 )
2745 : InheritableAttr(attr::Destructor, R, SI, false, false)
2746 , priority()
2747 {
2748 }
2749
2750 DestructorAttr *clone(ASTContext &C) const;
2751 void printPretty(raw_ostream &OS,
2752 const PrintingPolicy &Policy) const;
2753 const char *getSpelling() const;
2754 int getPriority() const {
2755 return priority;
2756 }
2757
2758 static const int DefaultPriority = 65535;
2759
2760
2761
2762 static bool classof(const Attr *A) { return A->getKind() == attr::Destructor; }
2763};
2764
2765class DiagnoseIfAttr : public InheritableAttr {
2766Expr * cond;
2767
2768unsigned messageLength;
2769char *message;
2770
2771public:
2772 enum DiagnosticType {
2773 DT_Error,
2774 DT_Warning
2775 };
2776private:
2777 DiagnosticType diagnosticType;
2778
2779bool argDependent;
2780
2781NamedDecl * parent;
2782
2783public:
2784 static DiagnoseIfAttr *CreateImplicit(ASTContext &Ctx, Expr * Cond, llvm::StringRef Message, DiagnosticType DiagnosticType, bool ArgDependent, NamedDecl * Parent, SourceRange Loc = SourceRange()) {
2785 auto *A = new (Ctx) DiagnoseIfAttr(Loc, Ctx, Cond, Message, DiagnosticType, ArgDependent, Parent, 0);
2786 A->setImplicit(true);
2787 return A;
2788 }
2789
2790 static DiagnoseIfAttr *CreateImplicit(ASTContext &Ctx, Expr * Cond, llvm::StringRef Message, DiagnosticType DiagnosticType, SourceRange Loc = SourceRange()) {
2791 auto *A = new (Ctx) DiagnoseIfAttr(Loc, Ctx, Cond, Message, DiagnosticType, 0);
2792 A->setImplicit(true);
2793 return A;
2794 }
2795
2796 DiagnoseIfAttr(SourceRange R, ASTContext &Ctx
2797 , Expr * Cond
2798 , llvm::StringRef Message
2799 , DiagnosticType DiagnosticType
2800 , bool ArgDependent
2801 , NamedDecl * Parent
2802 , unsigned SI
2803 )
2804 : InheritableAttr(attr::DiagnoseIf, R, SI, true, true)
2805 , cond(Cond)
2806 , messageLength(Message.size()),message(new (Ctx, 1) char[messageLength])
2807 , diagnosticType(DiagnosticType)
2808 , argDependent(ArgDependent)
2809 , parent(Parent)
2810 {
2811 if (!Message.empty())
2812 std::memcpy(message, Message.data(), messageLength);
2813 }
2814
2815 DiagnoseIfAttr(SourceRange R, ASTContext &Ctx
2816 , Expr * Cond
2817 , llvm::StringRef Message
2818 , DiagnosticType DiagnosticType
2819 , unsigned SI
2820 )
2821 : InheritableAttr(attr::DiagnoseIf, R, SI, true, true)
2822 , cond(Cond)
2823 , messageLength(Message.size()),message(new (Ctx, 1) char[messageLength])
2824 , diagnosticType(DiagnosticType)
2825 , argDependent()
2826 , parent()
2827 {
2828 if (!Message.empty())
2829 std::memcpy(message, Message.data(), messageLength);
2830 }
2831
2832 DiagnoseIfAttr *clone(ASTContext &C) const;
2833 void printPretty(raw_ostream &OS,
2834 const PrintingPolicy &Policy) const;
2835 const char *getSpelling() const;
2836 Expr * getCond() const {
2837 return cond;
2838 }
2839
2840 llvm::StringRef getMessage() const {
2841 return llvm::StringRef(message, messageLength);
2842 }
2843 unsigned getMessageLength() const {
2844 return messageLength;
2845 }
2846 void setMessage(ASTContext &C, llvm::StringRef S) {
2847 messageLength = S.size();
2848 this->message = new (C, 1) char [messageLength];
2849 if (!S.empty())
2850 std::memcpy(this->message, S.data(), messageLength);
2851 }
2852
2853 DiagnosticType getDiagnosticType() const {
2854 return diagnosticType;
2855 }
2856
2857 static bool ConvertStrToDiagnosticType(StringRef Val, DiagnosticType &Out) {
2858 Optional<DiagnosticType> R = llvm::StringSwitch<Optional<DiagnosticType>>(Val)
2859 .Case("error", DiagnoseIfAttr::DT_Error)
2860 .Case("warning", DiagnoseIfAttr::DT_Warning)
2861 .Default(Optional<DiagnosticType>());
2862 if (R) {
2863 Out = *R;
2864 return true;
2865 }
2866 return false;
2867 }
2868
2869 static const char *ConvertDiagnosticTypeToStr(DiagnosticType Val) {
2870 switch(Val) {
2871 case DiagnoseIfAttr::DT_Error: return "error";
2872 case DiagnoseIfAttr::DT_Warning: return "warning";
2873 }
2874 llvm_unreachable("No enumerator with that value")::llvm::llvm_unreachable_internal("No enumerator with that value"
, "/build/llvm-toolchain-snapshot-8~svn345461/build-llvm/tools/lldb/../clang/include/clang/AST/Attrs.inc"
, 2874)
;
2875 }
2876 bool getArgDependent() const {
2877 return argDependent;
2878 }
2879
2880 NamedDecl * getParent() const {
2881 return parent;
2882 }
2883
2884
2885 bool isError() const { return diagnosticType == DT_Error; }
2886 bool isWarning() const { return diagnosticType == DT_Warning; }
2887
2888
2889 static bool classof(const Attr *A) { return A->getKind() == attr::DiagnoseIf; }
2890};
2891
2892class DisableTailCallsAttr : public InheritableAttr {
2893public:
2894 static DisableTailCallsAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
2895 auto *A = new (Ctx) DisableTailCallsAttr(Loc, Ctx, 0);
2896 A->setImplicit(true);
2897 return A;
2898 }
2899
2900 DisableTailCallsAttr(SourceRange R, ASTContext &Ctx
2901 , unsigned SI
2902 )
2903 : InheritableAttr(attr::DisableTailCalls, R, SI, false, false)
2904 {
2905 }
2906
2907 DisableTailCallsAttr *clone(ASTContext &C) const;
2908 void printPretty(raw_ostream &OS,
2909 const PrintingPolicy &Policy) const;
2910 const char *getSpelling() const;
2911
2912
2913 static bool classof(const Attr *A) { return A->getKind() == attr::DisableTailCalls; }
2914};
2915
2916class EmptyBasesAttr : public InheritableAttr {
2917public:
2918 static EmptyBasesAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
2919 auto *A = new (Ctx) EmptyBasesAttr(Loc, Ctx, 0);
2920 A->setImplicit(true);
2921 return A;
2922 }
2923
2924 EmptyBasesAttr(SourceRange R, ASTContext &Ctx
2925 , unsigned SI
2926 )
2927 : InheritableAttr(attr::EmptyBases, R, SI, false, false)
2928 {
2929 }
2930
2931 EmptyBasesAttr *clone(ASTContext &C) const;
2932 void printPretty(raw_ostream &OS,
2933 const PrintingPolicy &Policy) const;
2934 const char *getSpelling() const;
2935
2936
2937 static bool classof(const Attr *A) { return A->getKind() == attr::EmptyBases; }
2938};
2939
2940class EnableIfAttr : public InheritableAttr {
2941Expr * cond;
2942
2943unsigned messageLength;
2944char *message;
2945
2946public:
2947 static EnableIfAttr *CreateImplicit(ASTContext &Ctx, Expr * Cond, llvm::StringRef Message, SourceRange Loc = SourceRange()) {
2948 auto *A = new (Ctx) EnableIfAttr(Loc, Ctx, Cond, Message, 0);
2949 A->setImplicit(true);
2950 return A;
2951 }
2952
2953 EnableIfAttr(SourceRange R, ASTContext &Ctx
2954 , Expr * Cond
2955 , llvm::StringRef Message
2956 , unsigned SI
2957 )
2958 : InheritableAttr(attr::EnableIf, R, SI, false, false)
2959 , cond(Cond)
2960 , messageLength(Message.size()),message(new (Ctx, 1) char[messageLength])
2961 {
2962 if (!Message.empty())
2963 std::memcpy(message, Message.data(), messageLength);
2964 }
2965
2966 EnableIfAttr *clone(ASTContext &C) const;
2967 void printPretty(raw_ostream &OS,
2968 const PrintingPolicy &Policy) const;
2969 const char *getSpelling() const;
2970 Expr * getCond() const {
2971 return cond;
2972 }
2973
2974 llvm::StringRef getMessage() const {
2975 return llvm::StringRef(message, messageLength);
2976 }
2977 unsigned getMessageLength() const {
2978 return messageLength;
2979 }
2980 void setMessage(ASTContext &C, llvm::StringRef S) {
2981 messageLength = S.size();
2982 this->message = new (C, 1) char [messageLength];
2983 if (!S.empty())
2984 std::memcpy(this->message, S.data(), messageLength);
2985 }
2986
2987
2988
2989 static bool classof(const Attr *A) { return A->getKind() == attr::EnableIf; }
2990};
2991
2992class EnumExtensibilityAttr : public InheritableAttr {
2993public:
2994 enum Kind {
2995 Closed,
2996 Open
2997 };
2998private:
2999 Kind extensibility;
3000
3001public:
3002 static EnumExtensibilityAttr *CreateImplicit(ASTContext &Ctx, Kind Extensibility, SourceRange Loc = SourceRange()) {
3003 auto *A = new (Ctx) EnumExtensibilityAttr(Loc, Ctx, Extensibility, 0);
3004 A->setImplicit(true);
3005 return A;
3006 }
3007
3008 EnumExtensibilityAttr(SourceRange R, ASTContext &Ctx
3009 , Kind Extensibility
3010 , unsigned SI
3011 )
3012 : InheritableAttr(attr::EnumExtensibility, R, SI, false, false)
3013 , extensibility(Extensibility)
3014 {
3015 }
3016
3017 EnumExtensibilityAttr *clone(ASTContext &C) const;
3018 void printPretty(raw_ostream &OS,
3019 const PrintingPolicy &Policy) const;
3020 const char *getSpelling() const;
3021 Kind getExtensibility() const {
3022 return extensibility;
3023 }
3024
3025 static bool ConvertStrToKind(StringRef Val, Kind &Out) {
3026 Optional<Kind> R = llvm::StringSwitch<Optional<Kind>>(Val)
3027 .Case("closed", EnumExtensibilityAttr::Closed)
3028 .Case("open", EnumExtensibilityAttr::Open)
3029 .Default(Optional<Kind>());
3030 if (R) {
3031 Out = *R;
3032 return true;
3033 }
3034 return false;
3035 }
3036
3037 static const char *ConvertKindToStr(Kind Val) {
3038 switch(Val) {
3039 case EnumExtensibilityAttr::Closed: return "closed";
3040 case EnumExtensibilityAttr::Open: return "open";
3041 }
3042 llvm_unreachable("No enumerator with that value")::llvm::llvm_unreachable_internal("No enumerator with that value"
, "/build/llvm-toolchain-snapshot-8~svn345461/build-llvm/tools/lldb/../clang/include/clang/AST/Attrs.inc"
, 3042)
;
3043 }
3044
3045
3046 static bool classof(const Attr *A) { return A->getKind() == attr::EnumExtensibility; }
3047};
3048
3049class ExcludeFromExplicitInstantiationAttr : public InheritableAttr {
3050public:
3051 static ExcludeFromExplicitInstantiationAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
3052 auto *A = new (Ctx) ExcludeFromExplicitInstantiationAttr(Loc, Ctx, 0);
3053 A->setImplicit(true);
3054 return A;
3055 }
3056
3057 ExcludeFromExplicitInstantiationAttr(SourceRange R, ASTContext &Ctx
3058 , unsigned SI
3059 )
3060 : InheritableAttr(attr::ExcludeFromExplicitInstantiation, R, SI, false, false)
3061 {
3062 }
3063
3064 ExcludeFromExplicitInstantiationAttr *clone(ASTContext &C) const;
3065 void printPretty(raw_ostream &OS,
3066 const PrintingPolicy &Policy) const;
3067 const char *getSpelling() const;
3068
3069
3070 static bool classof(const Attr *A) { return A->getKind() == attr::ExcludeFromExplicitInstantiation; }
3071};
3072
3073class ExclusiveTrylockFunctionAttr : public InheritableAttr {
3074Expr * successValue;
3075
3076 unsigned args_Size;
3077 Expr * *args_;
3078
3079public:
3080 static ExclusiveTrylockFunctionAttr *CreateImplicit(ASTContext &Ctx, Expr * SuccessValue, Expr * *Args, unsigned ArgsSize, SourceRange Loc = SourceRange()) {
3081 auto *A = new (Ctx) ExclusiveTrylockFunctionAttr(Loc, Ctx, SuccessValue, Args, ArgsSize, 0);
3082 A->setImplicit(true);
3083 return A;
3084 }
3085
3086 ExclusiveTrylockFunctionAttr(SourceRange R, ASTContext &Ctx
3087 , Expr * SuccessValue
3088 , Expr * *Args, unsigned ArgsSize
3089 , unsigned SI
3090 )
3091 : InheritableAttr(attr::ExclusiveTrylockFunction, R, SI, true, true)
3092 , successValue(SuccessValue)
3093 , args_Size(ArgsSize), args_(new (Ctx, 16) Expr *[args_Size])
3094 {
3095 std::copy(Args, Args + args_Size, args_);
3096 }
3097
3098 ExclusiveTrylockFunctionAttr(SourceRange R, ASTContext &Ctx
3099 , Expr * SuccessValue
3100 , unsigned SI
3101 )
3102 : InheritableAttr(attr::ExclusiveTrylockFunction, R, SI, true, true)
3103 , successValue(SuccessValue)
3104 , args_Size(0), args_(nullptr)
3105 {
3106 }
3107
3108 ExclusiveTrylockFunctionAttr *clone(ASTContext &C) const;
3109 void printPretty(raw_ostream &OS,
3110 const PrintingPolicy &Policy) const;
3111 const char *getSpelling() const;
3112 Expr * getSuccessValue() const {
3113 return successValue;
3114 }
3115
3116 typedef Expr ** args_iterator;
3117 args_iterator args_begin() const { return args_; }
3118 args_iterator args_end() const { return args_ + args_Size; }
3119 unsigned args_size() const { return args_Size; }
3120 llvm::iterator_range<args_iterator> args() const { return llvm::make_range(args_begin(), args_end()); }
3121
3122
3123
3124
3125 static bool classof(const Attr *A) { return A->getKind() == attr::ExclusiveTrylockFunction; }
3126};
3127
3128class ExternalSourceSymbolAttr : public InheritableAttr {
3129unsigned languageLength;
3130char *language;
3131
3132unsigned definedInLength;
3133char *definedIn;
3134
3135bool generatedDeclaration;
3136
3137public:
3138 static ExternalSourceSymbolAttr *CreateImplicit(ASTContext &Ctx, llvm::StringRef Language, llvm::StringRef DefinedIn, bool GeneratedDeclaration, SourceRange Loc = SourceRange()) {
3139 auto *A = new (Ctx) ExternalSourceSymbolAttr(Loc, Ctx, Language, DefinedIn, GeneratedDeclaration, 0);
3140 A->setImplicit(true);
3141 return A;
3142 }
3143
3144 ExternalSourceSymbolAttr(SourceRange R, ASTContext &Ctx
3145 , llvm::StringRef Language
3146 , llvm::StringRef DefinedIn
3147 , bool GeneratedDeclaration
3148 , unsigned SI
3149 )
3150 : InheritableAttr(attr::ExternalSourceSymbol, R, SI, false, false)
3151 , languageLength(Language.size()),language(new (Ctx, 1) char[languageLength])
3152 , definedInLength(DefinedIn.size()),definedIn(new (Ctx, 1) char[definedInLength])
3153 , generatedDeclaration(GeneratedDeclaration)
3154 {
3155 if (!Language.empty())
3156 std::memcpy(language, Language.data(), languageLength);
3157 if (!DefinedIn.empty())
3158 std::memcpy(definedIn, DefinedIn.data(), definedInLength);
3159 }
3160
3161 ExternalSourceSymbolAttr(SourceRange R, ASTContext &Ctx
3162 , unsigned SI
3163 )
3164 : InheritableAttr(attr::ExternalSourceSymbol, R, SI, false, false)
3165 , languageLength(0),language(nullptr)
3166 , definedInLength(0),definedIn(nullptr)
3167 , generatedDeclaration()
3168 {
3169 }
3170
3171 ExternalSourceSymbolAttr *clone(ASTContext &C) const;
3172 void printPretty(raw_ostream &OS,
3173 const PrintingPolicy &Policy) const;
3174 const char *getSpelling() const;
3175 llvm::StringRef getLanguage() const {
3176 return llvm::StringRef(language, languageLength);
3177 }
3178 unsigned getLanguageLength() const {
3179 return languageLength;
3180 }
3181 void setLanguage(ASTContext &C, llvm::StringRef S) {
3182 languageLength = S.size();
3183 this->language = new (C, 1) char [languageLength];
3184 if (!S.empty())
3185 std::memcpy(this->language, S.data(), languageLength);
3186 }
3187
3188 llvm::StringRef getDefinedIn() const {
3189 return llvm::StringRef(definedIn, definedInLength);
3190 }
3191 unsigned getDefinedInLength() const {
3192 return definedInLength;
3193 }
3194 void setDefinedIn(ASTContext &C, llvm::StringRef S) {
3195 definedInLength = S.size();
3196 this->definedIn = new (C, 1) char [definedInLength];
3197 if (!S.empty())
3198 std::memcpy(this->definedIn, S.data(), definedInLength);
3199 }
3200
3201 bool getGeneratedDeclaration() const {
3202 return generatedDeclaration;
3203 }
3204
3205
3206
3207 static bool classof(const Attr *A) { return A->getKind() == attr::ExternalSourceSymbol; }
3208};
3209
3210class FallThroughAttr : public StmtAttr {
3211public:
3212 static FallThroughAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
3213 auto *A = new (Ctx) FallThroughAttr(Loc, Ctx, 0);
3214 A->setImplicit(true);
3215 return A;
3216 }
3217
3218 FallThroughAttr(SourceRange R, ASTContext &Ctx
3219 , unsigned SI
3220 )
3221 : StmtAttr(attr::FallThrough, R, SI, false)
3222 {
3223 }
3224
3225 FallThroughAttr *clone(ASTContext &C) const;
3226 void printPretty(raw_ostream &OS,
3227 const PrintingPolicy &Policy) const;
3228 const char *getSpelling() const;
3229
3230
3231 static bool classof(const Attr *A) { return A->getKind() == attr::FallThrough; }
3232};
3233
3234class FastCallAttr : public InheritableAttr {
3235public:
3236 static FastCallAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
3237 auto *A = new (Ctx) FastCallAttr(Loc, Ctx, 0);
3238 A->setImplicit(true);
3239 return A;
3240 }
3241
3242 FastCallAttr(SourceRange R, ASTContext &Ctx
3243 , unsigned SI
3244 )
3245 : InheritableAttr(attr::FastCall, R, SI, false, false)
3246 {
3247 }
3248
3249 FastCallAttr *clone(ASTContext &C) const;
3250 void printPretty(raw_ostream &OS,
3251 const PrintingPolicy &Policy) const;
3252 const char *getSpelling() const;
3253
3254
3255 static bool classof(const Attr *A) { return A->getKind() == attr::FastCall; }
3256};
3257
3258class FinalAttr : public InheritableAttr {
3259public:
3260 enum Spelling {
3261 Keyword_final = 0,
3262 Keyword_sealed = 1
3263 };
3264
3265 static FinalAttr *CreateImplicit(ASTContext &Ctx, Spelling S, SourceRange Loc = SourceRange()) {
3266 auto *A = new (Ctx) FinalAttr(Loc, Ctx, S);
3267 A->setImplicit(true);
3268 return A;
3269 }
3270
3271 FinalAttr(SourceRange R, ASTContext &Ctx
3272 , unsigned SI
3273 )
3274 : InheritableAttr(attr::Final, R, SI, false, false)
3275 {
3276 }
3277
3278 FinalAttr *clone(ASTContext &C) const;
3279 void printPretty(raw_ostream &OS,
3280 const PrintingPolicy &Policy) const;
3281 const char *getSpelling() const;
3282 Spelling getSemanticSpelling() const {
3283 switch (SpellingListIndex) {
3284 default: llvm_unreachable("Unknown spelling list index")::llvm::llvm_unreachable_internal("Unknown spelling list index"
, "/build/llvm-toolchain-snapshot-8~svn345461/build-llvm/tools/lldb/../clang/include/clang/AST/Attrs.inc"
, 3284)
;
3285 case 0: return Keyword_final;
3286 case 1: return Keyword_sealed;
3287 }
3288 }
3289 bool isSpelledAsSealed() const { return SpellingListIndex == 1; }
3290
3291
3292 static bool classof(const Attr *A) { return A->getKind() == attr::Final; }
3293};
3294
3295class FlagEnumAttr : public InheritableAttr {
3296public:
3297 static FlagEnumAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
3298 auto *A = new (Ctx) FlagEnumAttr(Loc, Ctx, 0);
3299 A->setImplicit(true);
3300 return A;
3301 }
3302
3303 FlagEnumAttr(SourceRange R, ASTContext &Ctx
3304 , unsigned SI
3305 )
3306 : InheritableAttr(attr::FlagEnum, R, SI, false, false)
3307 {
3308 }
3309
3310 FlagEnumAttr *clone(ASTContext &C) const;
3311 void printPretty(raw_ostream &OS,
3312 const PrintingPolicy &Policy) const;
3313 const char *getSpelling() const;
3314
3315
3316 static bool classof(const Attr *A) { return A->getKind() == attr::FlagEnum; }
3317};
3318
3319class FlattenAttr : public InheritableAttr {
3320public:
3321 static FlattenAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
3322 auto *A = new (Ctx) FlattenAttr(Loc, Ctx, 0);
3323 A->setImplicit(true);
3324 return A;
3325 }
3326
3327 FlattenAttr(SourceRange R, ASTContext &Ctx
3328 , unsigned SI
3329 )
3330 : InheritableAttr(attr::Flatten, R, SI, false, false)
3331 {
3332 }
3333
3334 FlattenAttr *clone(ASTContext &C) const;
3335 void printPretty(raw_ostream &OS,
3336 const PrintingPolicy &Policy) const;
3337 const char *getSpelling() const;
3338
3339
3340 static bool classof(const Attr *A) { return A->getKind() == attr::Flatten; }
3341};
3342
3343class FormatAttr : public InheritableAttr {
3344IdentifierInfo * type;
3345
3346int formatIdx;
3347
3348int firstArg;
3349
3350public:
3351 static FormatAttr *CreateImplicit(ASTContext &Ctx, IdentifierInfo * Type, int FormatIdx, int FirstArg, SourceRange Loc = SourceRange()) {
3352 auto *A = new (Ctx) FormatAttr(Loc, Ctx, Type, FormatIdx, FirstArg, 0);
3353 A->setImplicit(true);
3354 return A;
3355 }
3356
3357 FormatAttr(SourceRange R, ASTContext &Ctx
3358 , IdentifierInfo * Type
3359 , int FormatIdx
3360 , int FirstArg
3361 , unsigned SI
3362 )
3363 : InheritableAttr(attr::Format, R, SI, false, false)
3364 , type(Type)
3365 , formatIdx(FormatIdx)
3366 , firstArg(FirstArg)
3367 {
3368 }
3369
3370 FormatAttr *clone(ASTContext &C) const;
3371 void printPretty(raw_ostream &OS,
3372 const PrintingPolicy &Policy) const;
3373 const char *getSpelling() const;
3374 IdentifierInfo * getType() const {
3375 return type;
3376 }
3377
3378 int getFormatIdx() const {
3379 return formatIdx;
3380 }
3381
3382 int getFirstArg() const {
3383 return firstArg;
3384 }
3385
3386
3387
3388 static bool classof(const Attr *A) { return A->getKind() == attr::Format; }
3389};
3390
3391class FormatArgAttr : public InheritableAttr {
3392ParamIdx formatIdx;
3393
3394public:
3395 static FormatArgAttr *CreateImplicit(ASTContext &Ctx, ParamIdx FormatIdx, SourceRange Loc = SourceRange()) {
3396 auto *A = new (Ctx) FormatArgAttr(Loc, Ctx, FormatIdx, 0);
3397 A->setImplicit(true);
3398 return A;
3399 }
3400
3401 FormatArgAttr(SourceRange R, ASTContext &Ctx
3402 , ParamIdx FormatIdx
3403 , unsigned SI
3404 )
3405 : InheritableAttr(attr::FormatArg, R, SI, false, false)
3406 , formatIdx(FormatIdx)
3407 {
3408 }
3409
3410 FormatArgAttr *clone(ASTContext &C) const;
3411 void printPretty(raw_ostream &OS,
3412 const PrintingPolicy &Policy) const;
3413 const char *getSpelling() const;
3414 ParamIdx getFormatIdx() const {
3415 return formatIdx;
3416 }
3417
3418
3419
3420 static bool classof(const Attr *A) { return A->getKind() == attr::FormatArg; }
3421};
3422
3423class GNUInlineAttr : public InheritableAttr {
3424public:
3425 static GNUInlineAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
3426 auto *A = new (Ctx) GNUInlineAttr(Loc, Ctx, 0);
3427 A->setImplicit(true);
3428 return A;
3429 }
3430
3431 GNUInlineAttr(SourceRange R, ASTContext &Ctx
3432 , unsigned SI
3433 )
3434 : InheritableAttr(attr::GNUInline, R, SI, false, false)
3435 {
3436 }
3437
3438 GNUInlineAttr *clone(ASTContext &C) const;
3439 void printPretty(raw_ostream &OS,
3440 const PrintingPolicy &Policy) const;
3441 const char *getSpelling() const;
3442
3443
3444 static bool classof(const Attr *A) { return A->getKind() == attr::GNUInline; }
3445};
3446
3447class GuardedByAttr : public InheritableAttr {
3448Expr * arg;
3449
3450public:
3451 static GuardedByAttr *CreateImplicit(ASTContext &Ctx, Expr * Arg, SourceRange Loc = SourceRange()) {
3452 auto *A = new (Ctx) GuardedByAttr(Loc, Ctx, Arg, 0);
3453 A->setImplicit(true);
3454 return A;
3455 }
3456
3457 GuardedByAttr(SourceRange R, ASTContext &Ctx
3458 , Expr * Arg
3459 , unsigned SI
3460 )
3461 : InheritableAttr(attr::GuardedBy, R, SI, true, true)
3462 , arg(Arg)
3463 {
3464 }
3465
3466 GuardedByAttr *clone(ASTContext &C) const;
3467 void printPretty(raw_ostream &OS,
3468 const PrintingPolicy &Policy) const;
3469 const char *getSpelling() const;
3470 Expr * getArg() const {
3471 return arg;
3472 }
3473
3474
3475
3476 static bool classof(const Attr *A) { return A->getKind() == attr::GuardedBy; }
3477};
3478
3479class GuardedVarAttr : public InheritableAttr {
3480public:
3481 static GuardedVarAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
3482 auto *A = new (Ctx) GuardedVarAttr(Loc, Ctx, 0);
3483 A->setImplicit(true);
3484 return A;
3485 }
3486
3487 GuardedVarAttr(SourceRange R, ASTContext &Ctx
3488 , unsigned SI
3489 )
3490 : InheritableAttr(attr::GuardedVar, R, SI, false, false)
3491 {
3492 }
3493
3494 GuardedVarAttr *clone(ASTContext &C) const;
3495 void printPretty(raw_ostream &OS,
3496 const PrintingPolicy &Policy) const;
3497 const char *getSpelling() const;
3498
3499
3500 static bool classof(const Attr *A) { return A->getKind() == attr::GuardedVar; }
3501};
3502
3503class HotAttr : public InheritableAttr {
3504public:
3505 static HotAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
3506 auto *A = new (Ctx) HotAttr(Loc, Ctx, 0);
3507 A->setImplicit(true);
3508 return A;
3509 }
3510
3511 HotAttr(SourceRange R, ASTContext &Ctx
3512 , unsigned SI
3513 )
3514 : InheritableAttr(attr::Hot, R, SI, false, false)
3515 {
3516 }
3517
3518 HotAttr *clone(ASTContext &C) const;
3519 void printPretty(raw_ostream &OS,
3520 const PrintingPolicy &Policy) const;
3521 const char *getSpelling() const;
3522
3523
3524 static bool classof(const Attr *A) { return A->getKind() == attr::Hot; }
3525};
3526
3527class IBActionAttr : public InheritableAttr {
3528public:
3529 static IBActionAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
3530 auto *A = new (Ctx) IBActionAttr(Loc, Ctx, 0);
3531 A->setImplicit(true);
3532 return A;
3533 }
3534
3535 IBActionAttr(SourceRange R, ASTContext &Ctx
3536 , unsigned SI
3537 )
3538 : InheritableAttr(attr::IBAction, R, SI, false, false)
3539 {
3540 }
3541
3542 IBActionAttr *clone(ASTContext &C) const;
3543 void printPretty(raw_ostream &OS,
3544 const PrintingPolicy &Policy) const;
3545 const char *getSpelling() const;
3546
3547
3548 static bool classof(const Attr *A) { return A->getKind() == attr::IBAction; }
3549};
3550
3551class IBOutletAttr : public InheritableAttr {
3552public:
3553 static IBOutletAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
3554 auto *A = new (Ctx) IBOutletAttr(Loc, Ctx, 0);
3555 A->setImplicit(true);
3556 return A;
3557 }
3558
3559 IBOutletAttr(SourceRange R, ASTContext &Ctx
3560 , unsigned SI
3561 )
3562 : InheritableAttr(attr::IBOutlet, R, SI, false, false)
3563 {
3564 }
3565
3566 IBOutletAttr *clone(ASTContext &C) const;
3567 void printPretty(raw_ostream &OS,
3568 const PrintingPolicy &Policy) const;
3569 const char *getSpelling() const;
3570
3571
3572 static bool classof(const Attr *A) { return A->getKind() == attr::IBOutlet; }
3573};
3574
3575class IBOutletCollectionAttr : public InheritableAttr {
3576TypeSourceInfo * interface_;
3577
3578public:
3579 static IBOutletCollectionAttr *CreateImplicit(ASTContext &Ctx, TypeSourceInfo * Interface, SourceRange Loc = SourceRange()) {
3580 auto *A = new (Ctx) IBOutletCollectionAttr(Loc, Ctx, Interface, 0);
3581 A->setImplicit(true);
3582 return A;
3583 }
3584
3585 IBOutletCollectionAttr(SourceRange R, ASTContext &Ctx
3586 , TypeSourceInfo * Interface
3587 , unsigned SI
3588 )
3589 : InheritableAttr(attr::IBOutletCollection, R, SI, false, false)
3590 , interface_(Interface)
3591 {
3592 }
3593
3594 IBOutletCollectionAttr(SourceRange R, ASTContext &Ctx
3595 , unsigned SI
3596 )
3597 : InheritableAttr(attr::IBOutletCollection, R, SI, false, false)
3598 , interface_()
3599 {
3600 }
3601
3602 IBOutletCollectionAttr *clone(ASTContext &C) const;
3603 void printPretty(raw_ostream &OS,
3604 const PrintingPolicy &Policy) const;
3605 const char *getSpelling() const;
3606 QualType getInterface() const {
3607 return interface_->getType();
3608 } TypeSourceInfo * getInterfaceLoc() const {
3609 return interface_;
3610 }
3611
3612
3613
3614 static bool classof(const Attr *A) { return A->getKind() == attr::IBOutletCollection; }
3615};
3616
3617class IFuncAttr : public Attr {
3618unsigned resolverLength;
3619char *resolver;
3620
3621public:
3622 static IFuncAttr *CreateImplicit(ASTContext &Ctx, llvm::StringRef Resolver, SourceRange Loc = SourceRange()) {
3623 auto *A = new (Ctx) IFuncAttr(Loc, Ctx, Resolver, 0);
3624 A->setImplicit(true);
3625 return A;
3626 }
3627
3628 IFuncAttr(SourceRange R, ASTContext &Ctx
3629 , llvm::StringRef Resolver
3630 , unsigned SI
3631 )
3632 : Attr(attr::IFunc, R, SI, false)
3633 , resolverLength(Resolver.size()),resolver(new (Ctx, 1) char[resolverLength])
3634 {
3635 if (!Resolver.empty())
3636 std::memcpy(resolver, Resolver.data(), resolverLength);
3637 }
3638
3639 IFuncAttr *clone(ASTContext &C) const;
3640 void printPretty(raw_ostream &OS,
3641 const PrintingPolicy &Policy) const;
3642 const char *getSpelling() const;
3643 llvm::StringRef getResolver() const {
3644 return llvm::StringRef(resolver, resolverLength);
3645 }
3646 unsigned getResolverLength() const {
3647 return resolverLength;
3648 }
3649 void setResolver(ASTContext &C, llvm::StringRef S) {
3650 resolverLength = S.size();
3651 this->resolver = new (C, 1) char [resolverLength];
3652 if (!S.empty())
3653 std::memcpy(this->resolver, S.data(), resolverLength);
3654 }
3655
3656
3657
3658 static bool classof(const Attr *A) { return A->getKind() == attr::IFunc; }
3659};
3660
3661class InitPriorityAttr : public InheritableAttr {
3662unsigned priority;
3663
3664public:
3665 static InitPriorityAttr *CreateImplicit(ASTContext &Ctx, unsigned Priority, SourceRange Loc = SourceRange()) {
3666 auto *A = new (Ctx) InitPriorityAttr(Loc, Ctx, Priority, 0);
3667 A->setImplicit(true);
3668 return A;
3669 }
3670
3671 InitPriorityAttr(SourceRange R, ASTContext &Ctx
3672 , unsigned Priority
3673 , unsigned SI
3674 )
3675 : InheritableAttr(attr::InitPriority, R, SI, false, false)
3676 , priority(Priority)
3677 {
3678 }
3679
3680 InitPriorityAttr *clone(ASTContext &C) const;
3681 void printPretty(raw_ostream &OS,
3682 const PrintingPolicy &Policy) const;
3683 const char *getSpelling() const;
3684 unsigned getPriority() const {
3685 return priority;
3686 }
3687
3688
3689
3690 static bool classof(const Attr *A) { return A->getKind() == attr::InitPriority; }
3691};
3692
3693class InitSegAttr : public Attr {
3694unsigned sectionLength;
3695char *section;
3696
3697public:
3698 static InitSegAttr *CreateImplicit(ASTContext &Ctx, llvm::StringRef Section, SourceRange Loc = SourceRange()) {
3699 auto *A = new (Ctx) InitSegAttr(Loc, Ctx, Section, 0);
3700 A->setImplicit(true);
3701 return A;
3702 }
3703
3704 InitSegAttr(SourceRange R, ASTContext &Ctx
3705 , llvm::StringRef Section
3706 , unsigned SI
3707 )
3708 : Attr(attr::InitSeg, R, SI, false)
3709 , sectionLength(Section.size()),section(new (Ctx, 1) char[sectionLength])
3710 {
3711 if (!Section.empty())
3712 std::memcpy(section, Section.data(), sectionLength);
3713 }
3714
3715 InitSegAttr *clone(ASTContext &C) const;
3716 void printPretty(raw_ostream &OS,
3717 const PrintingPolicy &Policy) const;
3718 const char *getSpelling() const;
3719 llvm::StringRef getSection() const {
3720 return llvm::StringRef(section, sectionLength);
3721 }
3722 unsigned getSectionLength() const {
3723 return sectionLength;
3724 }
3725 void setSection(ASTContext &C, llvm::StringRef S) {
3726 sectionLength = S.size();
3727 this->section = new (C, 1) char [sectionLength];
3728 if (!S.empty())
3729 std::memcpy(this->section, S.data(), sectionLength);
3730 }
3731
3732
3733 void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const {
3734 OS << " (" << getSection() << ')';
3735 }
3736
3737
3738 static bool classof(const Attr *A) { return A->getKind() == attr::InitSeg; }
3739};
3740
3741class IntelOclBiccAttr : public InheritableAttr {
3742public:
3743 static IntelOclBiccAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
3744 auto *A = new (Ctx) IntelOclBiccAttr(Loc, Ctx, 0);
3745 A->setImplicit(true);
3746 return A;
3747 }
3748
3749 IntelOclBiccAttr(SourceRange R, ASTContext &Ctx
3750 , unsigned SI
3751 )
3752 : InheritableAttr(attr::IntelOclBicc, R, SI, false, false)
3753 {
3754 }
3755
3756 IntelOclBiccAttr *clone(ASTContext &C) const;
3757 void printPretty(raw_ostream &OS,
3758 const PrintingPolicy &Policy) const;
3759 const char *getSpelling() const;
3760
3761
3762 static bool classof(const Attr *A) { return A->getKind() == attr::IntelOclBicc; }
3763};
3764
3765class InternalLinkageAttr : public InheritableAttr {
3766public:
3767 static InternalLinkageAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
3768 auto *A = new (Ctx) InternalLinkageAttr(Loc, Ctx, 0);
3769 A->setImplicit(true);
3770 return A;
3771 }
3772
3773 InternalLinkageAttr(SourceRange R, ASTContext &Ctx
3774 , unsigned SI
3775 )
3776 : InheritableAttr(attr::InternalLinkage, R, SI, false, false)
3777 {
3778 }
3779
3780 InternalLinkageAttr *clone(ASTContext &C) const;
3781 void printPretty(raw_ostream &OS,
3782 const PrintingPolicy &Policy) const;
3783 const char *getSpelling() const;
3784
3785
3786 static bool classof(const Attr *A) { return A->getKind() == attr::InternalLinkage; }
3787};
3788
3789class LTOVisibilityPublicAttr : public InheritableAttr {
3790public:
3791 static LTOVisibilityPublicAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
3792 auto *A = new (Ctx) LTOVisibilityPublicAttr(Loc, Ctx, 0);
3793 A->setImplicit(true);
3794 return A;
3795 }
3796
3797 LTOVisibilityPublicAttr(SourceRange R, ASTContext &Ctx
3798 , unsigned SI
3799 )
3800 : InheritableAttr(attr::LTOVisibilityPublic, R, SI, false, false)
3801 {
3802 }
3803
3804 LTOVisibilityPublicAttr *clone(ASTContext &C) const;
3805 void printPretty(raw_ostream &OS,
3806 const PrintingPolicy &Policy) const;
3807 const char *getSpelling() const;
3808
3809
3810 static bool classof(const Attr *A) { return A->getKind() == attr::LTOVisibilityPublic; }
3811};
3812
3813class LayoutVersionAttr : public InheritableAttr {
3814unsigned version;
3815
3816public:
3817 static LayoutVersionAttr *CreateImplicit(ASTContext &Ctx, unsigned Version, SourceRange Loc = SourceRange()) {
3818 auto *A = new (Ctx) LayoutVersionAttr(Loc, Ctx, Version, 0);
3819 A->setImplicit(true);
3820 return A;
3821 }
3822
3823 LayoutVersionAttr(SourceRange R, ASTContext &Ctx
3824 , unsigned Version
3825 , unsigned SI
3826 )
3827 : InheritableAttr(attr::LayoutVersion, R, SI, false, false)
3828 , version(Version)
3829 {
3830 }
3831
3832 LayoutVersionAttr *clone(ASTContext &C) const;
3833 void printPretty(raw_ostream &OS,
3834 const PrintingPolicy &Policy) const;
3835 const char *getSpelling() const;
3836 unsigned getVersion() const {
3837 return version;
3838 }
3839
3840
3841
3842 static bool classof(const Attr *A) { return A->getKind() == attr::LayoutVersion; }
3843};
3844
3845class LifetimeBoundAttr : public InheritableAttr {
3846public:
3847 static LifetimeBoundAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
3848 auto *A = new (Ctx) LifetimeBoundAttr(Loc, Ctx, 0);
3849 A->setImplicit(true);
3850 return A;
3851 }
3852
3853 LifetimeBoundAttr(SourceRange R, ASTContext &Ctx
3854 , unsigned SI
3855 )
3856 : InheritableAttr(attr::LifetimeBound, R, SI, false, false)
3857 {
3858 }
3859
3860 LifetimeBoundAttr *clone(ASTContext &C) const;
3861 void printPretty(raw_ostream &OS,
3862 const PrintingPolicy &Policy) const;
3863 const char *getSpelling() const;
3864
3865
3866 static bool classof(const Attr *A) { return A->getKind() == attr::LifetimeBound; }
3867};
3868
3869class LockReturnedAttr : public InheritableAttr {
3870Expr * arg;
3871
3872public:
3873 static LockReturnedAttr *CreateImplicit(ASTContext &Ctx, Expr * Arg, SourceRange Loc = SourceRange()) {
3874 auto *A = new (Ctx) LockReturnedAttr(Loc, Ctx, Arg, 0);
3875 A->setImplicit(true);
3876 return A;
3877 }
3878
3879 LockReturnedAttr(SourceRange R, ASTContext &Ctx
3880 , Expr * Arg
3881 , unsigned SI
3882 )
3883 : InheritableAttr(attr::LockReturned, R, SI, true, false)
3884 , arg(Arg)
3885 {
3886 }
3887
3888 LockReturnedAttr *clone(ASTContext &C) const;
3889 void printPretty(raw_ostream &OS,
3890 const PrintingPolicy &Policy) const;
3891 const char *getSpelling() const;
3892 Expr * getArg() const {
3893 return arg;
3894 }
3895
3896
3897
3898 static bool classof(const Attr *A) { return A->getKind() == attr::LockReturned; }
3899};
3900
3901class LocksExcludedAttr : public InheritableAttr {
3902 unsigned args_Size;
3903 Expr * *args_;
3904
3905public:
3906 static LocksExcludedAttr *CreateImplicit(ASTContext &Ctx, Expr * *Args, unsigned ArgsSize, SourceRange Loc = SourceRange()) {
3907 auto *A = new (Ctx) LocksExcludedAttr(Loc, Ctx, Args, ArgsSize, 0);
3908 A->setImplicit(true);
3909 return A;
3910 }
3911
3912 LocksExcludedAttr(SourceRange R, ASTContext &Ctx
3913 , Expr * *Args, unsigned ArgsSize
3914 , unsigned SI
3915 )
3916 : InheritableAttr(attr::LocksExcluded, R, SI, true, true)
3917 , args_Size(ArgsSize), args_(new (Ctx, 16) Expr *[args_Size])
3918 {
3919 std::copy(Args, Args + args_Size, args_);
3920 }
3921
3922 LocksExcludedAttr(SourceRange R, ASTContext &Ctx
3923 , unsigned SI
3924 )
3925 : InheritableAttr(attr::LocksExcluded, R, SI, true, true)
3926 , args_Size(0), args_(nullptr)
3927 {
3928 }
3929
3930 LocksExcludedAttr *clone(ASTContext &C) const;
3931 void printPretty(raw_ostream &OS,
3932 const PrintingPolicy &Policy) const;
3933 const char *getSpelling() const;
3934 typedef Expr ** args_iterator;
3935 args_iterator args_begin() const { return args_; }
3936 args_iterator args_end() const { return args_ + args_Size; }
3937 unsigned args_size() const { return args_Size; }
3938 llvm::iterator_range<args_iterator> args() const { return llvm::make_range(args_begin(), args_end()); }
3939
3940
3941
3942
3943 static bool classof(const Attr *A) { return A->getKind() == attr::LocksExcluded; }
3944};
3945
3946class LoopHintAttr : public Attr {
3947public:
3948 enum OptionType {
3949 Vectorize,
3950 VectorizeWidth,
3951 Interleave,
3952 InterleaveCount,
3953 Unroll,
3954 UnrollCount,
3955 UnrollAndJam,
3956 UnrollAndJamCount,
3957 Distribute
3958 };
3959private:
3960 OptionType option;
3961
3962public:
3963 enum LoopHintState {
3964 Enable,
3965 Disable,
3966 Numeric,
3967 AssumeSafety,
3968 Full
3969 };
3970private:
3971 LoopHintState state;
3972
3973Expr * value;
3974
3975public:
3976 enum Spelling {
3977 Pragma_clang_loop = 0,
3978 Pragma_unroll = 1,
3979 Pragma_nounroll = 2,
3980 Pragma_unroll_and_jam = 3,
3981 Pragma_nounroll_and_jam = 4
3982 };
3983
3984 static LoopHintAttr *CreateImplicit(ASTContext &Ctx, Spelling S, OptionType Option, LoopHintState State, Expr * Value, SourceRange Loc = SourceRange()) {
3985 auto *A = new (Ctx) LoopHintAttr(Loc, Ctx, Option, State, Value, S);
3986 A->setImplicit(true);
3987 return A;
3988 }
3989
3990 LoopHintAttr(SourceRange R, ASTContext &Ctx
3991 , OptionType Option
3992 , LoopHintState State
3993 , Expr * Value
3994 , unsigned SI
3995 )
3996 : Attr(attr::LoopHint, R, SI, false)
3997 , option(Option)
3998 , state(State)
3999 , value(Value)
4000 {
4001 }
4002
4003 LoopHintAttr *clone(ASTContext &C) const;
4004 void printPretty(raw_ostream &OS,
4005 const PrintingPolicy &Policy) const;
4006 const char *getSpelling() const;
4007 Spelling getSemanticSpelling() const {
4008 switch (SpellingListIndex) {
4009 default: llvm_unreachable("Unknown spelling list index")::llvm::llvm_unreachable_internal("Unknown spelling list index"
, "/build/llvm-toolchain-snapshot-8~svn345461/build-llvm/tools/lldb/../clang/include/clang/AST/Attrs.inc"
, 4009)
;
4010 case 0: return Pragma_clang_loop;
4011 case 1: return Pragma_unroll;
4012 case 2: return Pragma_nounroll;
4013 case 3: return Pragma_unroll_and_jam;
4014 case 4: return Pragma_nounroll_and_jam;
4015 }
4016 }
4017 OptionType getOption() const {
4018 return option;
4019 }
4020
4021 static bool ConvertStrToOptionType(StringRef Val, OptionType &Out) {
4022 Optional<OptionType> R = llvm::StringSwitch<Optional<OptionType>>(Val)
4023 .Case("vectorize", LoopHintAttr::Vectorize)
4024 .Case("vectorize_width", LoopHintAttr::VectorizeWidth)
4025 .Case("interleave", LoopHintAttr::Interleave)
4026 .Case("interleave_count", LoopHintAttr::InterleaveCount)
4027 .Case("unroll", LoopHintAttr::Unroll)
4028 .Case("unroll_count", LoopHintAttr::UnrollCount)
4029 .Case("unroll_and_jam", LoopHintAttr::UnrollAndJam)
4030 .Case("unroll_and_jam_count", LoopHintAttr::UnrollAndJamCount)
4031 .Case("distribute", LoopHintAttr::Distribute)
4032 .Default(Optional<OptionType>());
4033 if (R) {
4034 Out = *R;
4035 return true;
4036 }
4037 return false;
4038 }
4039
4040 static const char *ConvertOptionTypeToStr(OptionType Val) {
4041 switch(Val) {
4042 case LoopHintAttr::Vectorize: return "vectorize";
4043 case LoopHintAttr::VectorizeWidth: return "vectorize_width";
4044 case LoopHintAttr::Interleave: return "interleave";
4045 case LoopHintAttr::InterleaveCount: return "interleave_count";
4046 case LoopHintAttr::Unroll: return "unroll";
4047 case LoopHintAttr::UnrollCount: return "unroll_count";
4048 case LoopHintAttr::UnrollAndJam: return "unroll_and_jam";
4049 case LoopHintAttr::UnrollAndJamCount: return "unroll_and_jam_count";
4050 case LoopHintAttr::Distribute: return "distribute";
4051 }
4052 llvm_unreachable("No enumerator with that value")::llvm::llvm_unreachable_internal("No enumerator with that value"
, "/build/llvm-toolchain-snapshot-8~svn345461/build-llvm/tools/lldb/../clang/include/clang/AST/Attrs.inc"
, 4052)
;
4053 }
4054 LoopHintState getState() const {
4055 return state;
4056 }
4057
4058 static bool ConvertStrToLoopHintState(StringRef Val, LoopHintState &Out) {
4059 Optional<LoopHintState> R = llvm::StringSwitch<Optional<LoopHintState>>(Val)
4060 .Case("enable", LoopHintAttr::Enable)
4061 .Case("disable", LoopHintAttr::Disable)
4062 .Case("numeric", LoopHintAttr::Numeric)
4063 .Case("assume_safety", LoopHintAttr::AssumeSafety)
4064 .Case("full", LoopHintAttr::Full)
4065 .Default(Optional<LoopHintState>());
4066 if (R) {
4067 Out = *R;
4068 return true;
4069 }
4070 return false;
4071 }
4072
4073 static const char *ConvertLoopHintStateToStr(LoopHintState Val) {
4074 switch(Val) {
4075 case LoopHintAttr::Enable: return "enable";
4076 case LoopHintAttr::Disable: return "disable";
4077 case LoopHintAttr::Numeric: return "numeric";
4078 case LoopHintAttr::AssumeSafety: return "assume_safety";
4079 case LoopHintAttr::Full: return "full";
4080 }
4081 llvm_unreachable("No enumerator with that value")::llvm::llvm_unreachable_internal("No enumerator with that value"
, "/build/llvm-toolchain-snapshot-8~svn345461/build-llvm/tools/lldb/../clang/include/clang/AST/Attrs.inc"
, 4081)
;
4082 }
4083 Expr * getValue() const {
4084 return value;
4085 }
4086
4087
4088 static const char *getOptionName(int Option) {
4089 switch(Option) {
4090 case Vectorize: return "vectorize";
4091 case VectorizeWidth: return "vectorize_width";
4092 case Interleave: return "interleave";
4093 case InterleaveCount: return "interleave_count";
4094 case Unroll: return "unroll";
4095 case UnrollCount: return "unroll_count";
4096 case UnrollAndJam: return "unroll_and_jam";
4097 case UnrollAndJamCount: return "unroll_and_jam_count";
4098 case Distribute: return "distribute";
4099 }
4100 llvm_unreachable("Unhandled LoopHint option.")::llvm::llvm_unreachable_internal("Unhandled LoopHint option."
, "/build/llvm-toolchain-snapshot-8~svn345461/build-llvm/tools/lldb/../clang/include/clang/AST/Attrs.inc"
, 4100)
;
4101 }
4102
4103 void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const {
4104 unsigned SpellingIndex = getSpellingListIndex();
4105 // For "#pragma unroll" and "#pragma nounroll" the string "unroll" or
4106 // "nounroll" is already emitted as the pragma name.
4107 if (SpellingIndex == Pragma_nounroll || SpellingIndex == Pragma_nounroll_and_jam)
4108 return;
4109 else if (SpellingIndex == Pragma_unroll || SpellingIndex == Pragma_unroll_and_jam) {
4110 OS << ' ' << getValueString(Policy);
4111 return;
4112 }
4113
4114 assert(SpellingIndex == Pragma_clang_loop && "Unexpected spelling")((SpellingIndex == Pragma_clang_loop && "Unexpected spelling"
) ? static_cast<void> (0) : __assert_fail ("SpellingIndex == Pragma_clang_loop && \"Unexpected spelling\""
, "/build/llvm-toolchain-snapshot-8~svn345461/build-llvm/tools/lldb/../clang/include/clang/AST/Attrs.inc"
, 4114, __PRETTY_FUNCTION__))
;
4115 OS << ' ' << getOptionName(option) << getValueString(Policy);
4116 }
4117
4118 // Return a string containing the loop hint argument including the
4119 // enclosing parentheses.
4120 std::string getValueString(const PrintingPolicy &Policy) const {
4121 std::string ValueName;
4122 llvm::raw_string_ostream OS(ValueName);
4123 OS << "(";
4124 if (state == Numeric)
4125 value->printPretty(OS, nullptr, Policy);
4126 else if (state == Enable)
4127 OS << "enable";
4128 else if (state == Full)
4129 OS << "full";
4130 else if (state == AssumeSafety)
4131 OS << "assume_safety";
4132 else
4133 OS << "disable";
4134 OS << ")";
4135 return OS.str();
4136 }
4137
4138 // Return a string suitable for identifying this attribute in diagnostics.
4139 std::string getDiagnosticName(const PrintingPolicy &Policy) const {
4140 unsigned SpellingIndex = getSpellingListIndex();
4141 if (SpellingIndex == Pragma_nounroll)
4142 return "#pragma nounroll";
4143 else if (SpellingIndex == Pragma_unroll)
4144 return "#pragma unroll" + (option == UnrollCount ? getValueString(Policy) : "");
4145 else if (SpellingIndex == Pragma_nounroll_and_jam)
4146 return "#pragma nounroll_and_jam";
4147 else if (SpellingIndex == Pragma_unroll_and_jam)
4148 return "#pragma unroll_and_jam" +
4149 (option == UnrollAndJamCount ? getValueString(Policy) : "");
4150
4151 assert(SpellingIndex == Pragma_clang_loop && "Unexpected spelling")((SpellingIndex == Pragma_clang_loop && "Unexpected spelling"
) ? static_cast<void> (0) : __assert_fail ("SpellingIndex == Pragma_clang_loop && \"Unexpected spelling\""
, "/build/llvm-toolchain-snapshot-8~svn345461/build-llvm/tools/lldb/../clang/include/clang/AST/Attrs.inc"
, 4151, __PRETTY_FUNCTION__))
;
4152 return getOptionName(option) + getValueString(Policy);
4153 }
4154
4155
4156 static bool classof(const Attr *A) { return A->getKind() == attr::LoopHint; }
4157};
4158
4159class MSABIAttr : public InheritableAttr {
4160public:
4161 static MSABIAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
4162 auto *A = new (Ctx) MSABIAttr(Loc, Ctx, 0);
4163 A->setImplicit(true);
4164 return A;
4165 }
4166
4167 MSABIAttr(SourceRange R, ASTContext &Ctx
4168 , unsigned SI
4169 )
4170 : InheritableAttr(attr::MSABI, R, SI, false, false)
4171 {
4172 }
4173
4174 MSABIAttr *clone(ASTContext &C) const;
4175 void printPretty(raw_ostream &OS,
4176 const PrintingPolicy &Policy) const;
4177 const char *getSpelling() const;
4178
4179
4180 static bool classof(const Attr *A) { return A->getKind() == attr::MSABI; }
4181};
4182
4183class MSInheritanceAttr : public InheritableAttr {
4184bool bestCase;
4185
4186public:
4187 enum Spelling {
4188 Keyword_single_inheritance = 0,
4189 Keyword_multiple_inheritance = 1,
4190 Keyword_virtual_inheritance = 2,
4191 Keyword_unspecified_inheritance = 3
4192 };
4193
4194 static MSInheritanceAttr *CreateImplicit(ASTContext &Ctx, Spelling S, bool BestCase, SourceRange Loc = SourceRange()) {
4195 auto *A = new (Ctx) MSInheritanceAttr(Loc, Ctx, BestCase, S);
4196 A->setImplicit(true);
4197 return A;
4198 }
4199
4200 static MSInheritanceAttr *CreateImplicit(ASTContext &Ctx, Spelling S, SourceRange Loc = SourceRange()) {
4201 auto *A = new (Ctx) MSInheritanceAttr(Loc, Ctx, S);
4202 A->setImplicit(true);
4203 return A;
4204 }
4205
4206 MSInheritanceAttr(SourceRange R, ASTContext &Ctx
4207 , bool BestCase
4208 , unsigned SI
4209 )
4210 : InheritableAttr(attr::MSInheritance, R, SI, false, false)
4211 , bestCase(BestCase)
4212 {
4213 }
4214
4215 MSInheritanceAttr(SourceRange R, ASTContext &Ctx
4216 , unsigned SI
4217 )
4218 : InheritableAttr(attr::MSInheritance, R, SI, false, false)
4219 , bestCase()
4220 {
4221 }
4222
4223 MSInheritanceAttr *clone(ASTContext &C) const;
4224 void printPretty(raw_ostream &OS,
4225 const PrintingPolicy &Policy) const;
4226 const char *getSpelling() const;
4227 Spelling getSemanticSpelling() const {
4228 switch (SpellingListIndex) {
4229 default: llvm_unreachable("Unknown spelling list index")::llvm::llvm_unreachable_internal("Unknown spelling list index"
, "/build/llvm-toolchain-snapshot-8~svn345461/build-llvm/tools/lldb/../clang/include/clang/AST/Attrs.inc"
, 4229)
;
4230 case 0: return Keyword_single_inheritance;
4231 case 1: return Keyword_multiple_inheritance;
4232 case 2: return Keyword_virtual_inheritance;
4233 case 3: return Keyword_unspecified_inheritance;
4234 }
4235 }
4236 bool getBestCase() const {
4237 return bestCase;
4238 }
4239
4240 static const bool DefaultBestCase = true;
4241
4242
4243 static bool hasVBPtrOffsetField(Spelling Inheritance) {
4244 return Inheritance == Keyword_unspecified_inheritance;
4245 }
4246
4247 // Only member pointers to functions need a this adjustment, since it can be
4248 // combined with the field offset for data pointers.
4249 static bool hasNVOffsetField(bool IsMemberFunction, Spelling Inheritance) {
4250 return IsMemberFunction && Inheritance >= Keyword_multiple_inheritance;
4251 }
4252
4253 static bool hasVBTableOffsetField(Spelling Inheritance) {
4254 return Inheritance >= Keyword_virtual_inheritance;
4255 }
4256
4257 static bool hasOnlyOneField(bool IsMemberFunction,
4258 Spelling Inheritance) {
4259 if (IsMemberFunction)
4260 return Inheritance <= Keyword_single_inheritance;
4261 return Inheritance <= Keyword_multiple_inheritance;
4262 }
4263
4264
4265 static bool classof(const Attr *A) { return A->getKind() == attr::MSInheritance; }
4266};
4267
4268class MSNoVTableAttr : public InheritableAttr {
4269public:
4270 static MSNoVTableAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
4271 auto *A = new (Ctx) MSNoVTableAttr(Loc, Ctx, 0);
4272 A->setImplicit(true);
4273 return A;
4274 }
4275
4276 MSNoVTableAttr(SourceRange R, ASTContext &Ctx
4277 , unsigned SI
4278 )
4279 : InheritableAttr(attr::MSNoVTable, R, SI, false, false)
4280 {
4281 }
4282
4283 MSNoVTableAttr *clone(ASTContext &C) const;
4284 void printPretty(raw_ostream &OS,
4285 const PrintingPolicy &Policy) const;
4286 const char *getSpelling() const;
4287
4288
4289 static bool classof(const Attr *A) { return A->getKind() == attr::MSNoVTable; }
4290};
4291
4292class MSP430InterruptAttr : public InheritableAttr {
4293unsigned number;
4294
4295public:
4296 static MSP430InterruptAttr *CreateImplicit(ASTContext &Ctx, unsigned Number, SourceRange Loc = SourceRange()) {
4297 auto *A = new (Ctx) MSP430InterruptAttr(Loc, Ctx, Number, 0);
4298 A->setImplicit(true);
4299 return A;
4300 }
4301
4302 MSP430InterruptAttr(SourceRange R, ASTContext &Ctx
4303 , unsigned Number
4304 , unsigned SI
4305 )
4306 : InheritableAttr(attr::MSP430Interrupt, R, SI, false, false)
4307 , number(Number)
4308 {
4309 }
4310
4311 MSP430InterruptAttr *clone(ASTContext &C) const;
4312 void printPretty(raw_ostream &OS,
4313 const PrintingPolicy &Policy) const;
4314 const char *getSpelling() const;
4315 unsigned getNumber() const {
4316 return number;
4317 }
4318
4319
4320
4321 static bool classof(const Attr *A) { return A->getKind() == attr::MSP430Interrupt; }
4322};
4323
4324class MSStructAttr : public InheritableAttr {
4325public:
4326 static MSStructAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
4327 auto *A = new (Ctx) MSStructAttr(Loc, Ctx, 0);
4328 A->setImplicit(true);
4329 return A;
4330 }
4331
4332 MSStructAttr(SourceRange R, ASTContext &Ctx
4333 , unsigned SI
4334 )
4335 : InheritableAttr(attr::MSStruct, R, SI, false, false)
4336 {
4337 }
4338
4339 MSStructAttr *clone(ASTContext &C) const;
4340 void printPretty(raw_ostream &OS,
4341 const PrintingPolicy &Policy) const;
4342 const char *getSpelling() const;
4343
4344
4345 static bool classof(const Attr *A) { return A->getKind() == attr::MSStruct; }
4346};
4347
4348class MSVtorDispAttr : public InheritableAttr {
4349unsigned vdm;
4350
4351public:
4352 static MSVtorDispAttr *CreateImplicit(ASTContext &Ctx, unsigned Vdm, SourceRange Loc = SourceRange()) {
4353 auto *A = new (Ctx) MSVtorDispAttr(Loc, Ctx, Vdm, 0);
4354 A->setImplicit(true);
4355 return A;
4356 }
4357
4358 MSVtorDispAttr(SourceRange R, ASTContext &Ctx
4359 , unsigned Vdm
4360 , unsigned SI
4361 )
4362 : InheritableAttr(attr::MSVtorDisp, R, SI, false, false)
4363 , vdm(Vdm)
4364 {
4365 }
4366
4367 MSVtorDispAttr *clone(ASTContext &C) const;
4368 void printPretty(raw_ostream &OS,
4369 const PrintingPolicy &Policy) const;
4370 const char *getSpelling() const;
4371 unsigned getVdm() const {
4372 return vdm;
4373 }
4374
4375
4376 enum Mode {
4377 Never,
4378 ForVBaseOverride,
4379 ForVFTable
4380 };
4381
4382 Mode getVtorDispMode() const { return Mode(vdm); }
4383
4384
4385 static bool classof(const Attr *A) { return A->getKind() == attr::MSVtorDisp; }
4386};
4387
4388class MaxFieldAlignmentAttr : public InheritableAttr {
4389unsigned alignment;
4390
4391public:
4392 static MaxFieldAlignmentAttr *CreateImplicit(ASTContext &Ctx, unsigned Alignment, SourceRange Loc = SourceRange()) {
4393 auto *A = new (Ctx) MaxFieldAlignmentAttr(Loc, Ctx, Alignment, 0);
4394 A->setImplicit(true);
4395 return A;
4396 }
4397
4398 MaxFieldAlignmentAttr(SourceRange R, ASTContext &Ctx
4399 , unsigned Alignment
4400 , unsigned SI
4401 )
4402 : InheritableAttr(attr::MaxFieldAlignment, R, SI, false, false)
4403 , alignment(Alignment)
4404 {
4405 }
4406
4407 MaxFieldAlignmentAttr *clone(ASTContext &C) const;
4408 void printPretty(raw_ostream &OS,
4409 const PrintingPolicy &Policy) const;
4410 const char *getSpelling() const;
4411 unsigned getAlignment() const {
4412 return alignment;
4413 }
4414
4415
4416
4417 static bool classof(const Attr *A) { return A->getKind() == attr::MaxFieldAlignment; }
4418};
4419
4420class MayAliasAttr : public InheritableAttr {
4421public:
4422 static MayAliasAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
4423 auto *A = new (Ctx) MayAliasAttr(Loc, Ctx, 0);
4424 A->setImplicit(true);
4425 return A;
4426 }
4427
4428 MayAliasAttr(SourceRange R, ASTContext &Ctx
4429 , unsigned SI
4430 )
4431 : InheritableAttr(attr::MayAlias, R, SI, false, false)
4432 {
4433 }
4434
4435 MayAliasAttr *clone(ASTContext &C) const;
4436 void printPretty(raw_ostream &OS,
4437 const PrintingPolicy &Policy) const;
4438 const char *getSpelling() const;
4439
4440
4441 static bool classof(const Attr *A) { return A->getKind() == attr::MayAlias; }
4442};
4443
4444class MicroMipsAttr : public InheritableAttr {
4445public:
4446 static MicroMipsAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
4447 auto *A = new (Ctx) MicroMipsAttr(Loc, Ctx, 0);
4448 A->setImplicit(true);
4449 return A;
4450 }
4451
4452 MicroMipsAttr(SourceRange R, ASTContext &Ctx
4453 , unsigned SI
4454 )
4455 : InheritableAttr(attr::MicroMips, R, SI, false, false)
4456 {
4457 }
4458
4459 MicroMipsAttr *clone(ASTContext &C) const;
4460 void printPretty(raw_ostream &OS,
4461 const PrintingPolicy &Policy) const;
4462 const char *getSpelling() const;
4463
4464
4465 static bool classof(const Attr *A) { return A->getKind() == attr::MicroMips; }
4466};
4467
4468class MinSizeAttr : public InheritableAttr {
4469public:
4470 static MinSizeAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
4471 auto *A = new (Ctx) MinSizeAttr(Loc, Ctx, 0);
4472 A->setImplicit(true);
4473 return A;
4474 }
4475
4476 MinSizeAttr(SourceRange R, ASTContext &Ctx
4477 , unsigned SI
4478 )
4479 : InheritableAttr(attr::MinSize, R, SI, false, false)
4480 {
4481 }
4482
4483 MinSizeAttr *clone(ASTContext &C) const;
4484 void printPretty(raw_ostream &OS,
4485 const PrintingPolicy &Policy) const;
4486 const char *getSpelling() const;
4487
4488
4489 static bool classof(const Attr *A) { return A->getKind() == attr::MinSize; }
4490};
4491
4492class MinVectorWidthAttr : public InheritableAttr {
4493unsigned vectorWidth;
4494
4495public:
4496 static MinVectorWidthAttr *CreateImplicit(ASTContext &Ctx, unsigned VectorWidth, SourceRange Loc = SourceRange()) {
4497 auto *A = new (Ctx) MinVectorWidthAttr(Loc, Ctx, VectorWidth, 0);
4498 A->setImplicit(true);
4499 return A;
4500 }
4501
4502 MinVectorWidthAttr(SourceRange R, ASTContext &Ctx
4503 , unsigned VectorWidth
4504 , unsigned SI
4505 )
4506 : InheritableAttr(attr::MinVectorWidth, R, SI, false, false)
4507 , vectorWidth(VectorWidth)
4508 {
4509 }
4510
4511 MinVectorWidthAttr *clone(ASTContext &C) const;
4512 void printPretty(raw_ostream &OS,
4513 const PrintingPolicy &Policy) const;
4514 const char *getSpelling() const;
4515 unsigned getVectorWidth() const {
4516 return vectorWidth;
4517 }
4518
4519
4520
4521 static bool classof(const Attr *A) { return A->getKind() == attr::MinVectorWidth; }
4522};
4523
4524class Mips16Attr : public InheritableAttr {
4525public:
4526 static Mips16Attr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
4527 auto *A = new (Ctx) Mips16Attr(Loc, Ctx, 0);
4528 A->setImplicit(true);
4529 return A;
4530 }
4531
4532 Mips16Attr(SourceRange R, ASTContext &Ctx
4533 , unsigned SI
4534 )
4535 : InheritableAttr(attr::Mips16, R, SI, false, false)
4536 {
4537 }
4538
4539 Mips16Attr *clone(ASTContext &C) const;
4540 void printPretty(raw_ostream &OS,
4541 const PrintingPolicy &Policy) const;
4542 const char *getSpelling() const;
4543
4544
4545 static bool classof(const Attr *A) { return A->getKind() == attr::Mips16; }
4546};
4547
4548class MipsInterruptAttr : public InheritableAttr {
4549public:
4550 enum InterruptType {
4551 sw0,
4552 sw1,
4553 hw0,
4554 hw1,
4555 hw2,
4556 hw3,
4557 hw4,
4558 hw5,
4559 eic
4560 };
4561private:
4562 InterruptType interrupt;
4563
4564public:
4565 static MipsInterruptAttr *CreateImplicit(ASTContext &Ctx, InterruptType Interrupt, SourceRange Loc = SourceRange()) {
4566 auto *A = new (Ctx) MipsInterruptAttr(Loc, Ctx, Interrupt, 0);
4567 A->setImplicit(true);
4568 return A;
4569 }
4570
4571 MipsInterruptAttr(SourceRange R, ASTContext &Ctx
4572 , InterruptType Interrupt
4573 , unsigned SI
4574 )
4575 : InheritableAttr(attr::MipsInterrupt, R, SI, false, false)
4576 , interrupt(Interrupt)
4577 {
4578 }
4579
4580 MipsInterruptAttr *clone(ASTContext &C) const;
4581 void printPretty(raw_ostream &OS,
4582 const PrintingPolicy &Policy) const;
4583 const char *getSpelling() const;
4584 InterruptType getInterrupt() const {
4585 return interrupt;
4586 }
4587
4588 static bool ConvertStrToInterruptType(StringRef Val, InterruptType &Out) {
4589 Optional<InterruptType> R = llvm::StringSwitch<Optional<InterruptType>>(Val)
4590 .Case("vector=sw0", MipsInterruptAttr::sw0)
4591 .Case("vector=sw1", MipsInterruptAttr::sw1)
4592 .Case("vector=hw0", MipsInterruptAttr::hw0)
4593 .Case("vector=hw1", MipsInterruptAttr::hw1)
4594 .Case("vector=hw2", MipsInterruptAttr::hw2)
4595 .Case("vector=hw3", MipsInterruptAttr::hw3)
4596 .Case("vector=hw4", MipsInterruptAttr::hw4)
4597 .Case("vector=hw5", MipsInterruptAttr::hw5)
4598 .Case("eic", MipsInterruptAttr::eic)
4599 .Case("", MipsInterruptAttr::eic)
4600 .Default(Optional<InterruptType>());
4601 if (R) {
4602 Out = *R;
4603 return true;
4604 }
4605 return false;
4606 }
4607
4608 static const char *ConvertInterruptTypeToStr(InterruptType Val) {
4609 switch(Val) {
4610 case MipsInterruptAttr::sw0: return "vector=sw0";
4611 case MipsInterruptAttr::sw1: return "vector=sw1";
4612 case MipsInterruptAttr::hw0: return "vector=hw0";
4613 case MipsInterruptAttr::hw1: return "vector=hw1";
4614 case MipsInterruptAttr::hw2: return "vector=hw2";
4615 case MipsInterruptAttr::hw3: return "vector=hw3";
4616 case MipsInterruptAttr::hw4: return "vector=hw4";
4617 case MipsInterruptAttr::hw5: return "vector=hw5";
4618 case MipsInterruptAttr::eic: return "eic";
4619 }
4620 llvm_unreachable("No enumerator with that value")::llvm::llvm_unreachable_internal("No enumerator with that value"
, "/build/llvm-toolchain-snapshot-8~svn345461/build-llvm/tools/lldb/../clang/include/clang/AST/Attrs.inc"
, 4620)
;
4621 }
4622
4623
4624 static bool classof(const Attr *A) { return A->getKind() == attr::MipsInterrupt; }
4625};
4626
4627class MipsLongCallAttr : public InheritableAttr {
4628public:
4629 enum Spelling {
4630 GNU_long_call = 0,
4631 CXX11_gnu_long_call = 1,
4632 GNU_far = 2,
4633 CXX11_gnu_far = 3
4634 };
4635
4636 static MipsLongCallAttr *CreateImplicit(ASTContext &Ctx, Spelling S, SourceRange Loc = SourceRange()) {
4637 auto *A = new (Ctx) MipsLongCallAttr(Loc, Ctx, S);
4638 A->setImplicit(true);
4639 return A;
4640 }
4641
4642 MipsLongCallAttr(SourceRange R, ASTContext &Ctx
4643 , unsigned SI
4644 )
4645 : InheritableAttr(attr::MipsLongCall, R, SI, false, false)
4646 {
4647 }
4648
4649 MipsLongCallAttr *clone(ASTContext &C) const;
4650 void printPretty(raw_ostream &OS,
4651 const PrintingPolicy &Policy) const;
4652 const char *getSpelling() const;
4653 Spelling getSemanticSpelling() const {
4654 switch (SpellingListIndex) {
4655 default: llvm_unreachable("Unknown spelling list index")::llvm::llvm_unreachable_internal("Unknown spelling list index"
, "/build/llvm-toolchain-snapshot-8~svn345461/build-llvm/tools/lldb/../clang/include/clang/AST/Attrs.inc"
, 4655)
;
4656 case 0: return GNU_long_call;
4657 case 1: return CXX11_gnu_long_call;
4658 case 2: return GNU_far;
4659 case 3: return CXX11_gnu_far;
4660 }
4661 }
4662
4663
4664 static bool classof(const Attr *A) { return A->getKind() == attr::MipsLongCall; }
4665};
4666
4667class MipsShortCallAttr : public InheritableAttr {
4668public:
4669 enum Spelling {
4670 GNU_short_call = 0,
4671 CXX11_gnu_short_call = 1,
4672 GNU_near = 2,
4673 CXX11_gnu_near = 3
4674 };
4675
4676 static MipsShortCallAttr *CreateImplicit(ASTContext &Ctx, Spelling S, SourceRange Loc = SourceRange()) {
4677 auto *A = new (Ctx) MipsShortCallAttr(Loc, Ctx, S);
4678 A->setImplicit(true);
4679 return A;
4680 }
4681
4682 MipsShortCallAttr(SourceRange R, ASTContext &Ctx
4683 , unsigned SI
4684 )
4685 : InheritableAttr(attr::MipsShortCall, R, SI, false, false)
4686 {
4687 }
4688
4689 MipsShortCallAttr *clone(ASTContext &C) const;
4690 void printPretty(raw_ostream &OS,
4691 const PrintingPolicy &Policy) const;
4692 const char *getSpelling() const;
4693 Spelling getSemanticSpelling() const {
4694 switch (SpellingListIndex) {
4695 default: llvm_unreachable("Unknown spelling list index")::llvm::llvm_unreachable_internal("Unknown spelling list index"
, "/build/llvm-toolchain-snapshot-8~svn345461/build-llvm/tools/lldb/../clang/include/clang/AST/Attrs.inc"
, 4695)
;
4696 case 0: return GNU_short_call;
4697 case 1: return CXX11_gnu_short_call;
4698 case 2: return GNU_near;
4699 case 3: return CXX11_gnu_near;
4700 }
4701 }
4702
4703
4704 static bool classof(const Attr *A) { return A->getKind() == attr::MipsShortCall; }
4705};
4706
4707class ModeAttr : public Attr {
4708IdentifierInfo * mode;
4709
4710public:
4711 static ModeAttr *CreateImplicit(ASTContext &Ctx, IdentifierInfo * Mode, SourceRange Loc = SourceRange()) {
4712 auto *A = new (Ctx) ModeAttr(Loc, Ctx, Mode, 0);
4713 A->setImplicit(true);
4714 return A;
4715 }
4716
4717 ModeAttr(SourceRange R, ASTContext &Ctx
4718 , IdentifierInfo * Mode
4719 , unsigned SI
4720 )
4721 : Attr(attr::Mode, R, SI, false)
4722 , mode(Mode)
4723 {
4724 }
4725
4726 ModeAttr *clone(ASTContext &C) const;
4727 void printPretty(raw_ostream &OS,
4728 const PrintingPolicy &Policy) const;
4729 const char *getSpelling() const;
4730 IdentifierInfo * getMode() const {
4731 return mode;
4732 }
4733
4734
4735
4736 static bool classof(const Attr *A) { return A->getKind() == attr::Mode; }
4737};
4738
4739class NSConsumedAttr : public InheritableParamAttr {
4740public:
4741 static NSConsumedAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
4742 auto *A = new (Ctx) NSConsumedAttr(Loc, Ctx, 0);
4743 A->setImplicit(true);
4744 return A;
4745 }
4746
4747 NSConsumedAttr(SourceRange R, ASTContext &Ctx
4748 , unsigned SI
4749 )
4750 : InheritableParamAttr(attr::NSConsumed, R, SI, false, false)
4751 {
4752 }
4753
4754 NSConsumedAttr *clone(ASTContext &C) const;
4755 void printPretty(raw_ostream &OS,
4756 const PrintingPolicy &Policy) const;
4757 const char *getSpelling() const;
4758
4759
4760 static bool classof(const Attr *A) { return A->getKind() == attr::NSConsumed; }
4761};
4762
4763class NSConsumesSelfAttr : public InheritableAttr {
4764public:
4765 static NSConsumesSelfAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
4766 auto *A = new (Ctx) NSConsumesSelfAttr(Loc, Ctx, 0);
4767 A->setImplicit(true);
4768 return A;
4769 }
4770
4771 NSConsumesSelfAttr(SourceRange R, ASTContext &Ctx
4772 , unsigned SI
4773 )
4774 : InheritableAttr(attr::NSConsumesSelf, R, SI, false, false)
4775 {
4776 }
4777
4778 NSConsumesSelfAttr *clone(ASTContext &C) const;
4779 void printPretty(raw_ostream &OS,
4780 const PrintingPolicy &Policy) const;
4781 const char *getSpelling() const;
4782
4783
4784 static bool classof(const Attr *A) { return A->getKind() == attr::NSConsumesSelf; }
4785};
4786
4787class NSReturnsAutoreleasedAttr : public InheritableAttr {
4788public:
4789 static NSReturnsAutoreleasedAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
4790 auto *A = new (Ctx) NSReturnsAutoreleasedAttr(Loc, Ctx, 0);
4791 A->setImplicit(true);
4792 return A;
4793 }
4794
4795 NSReturnsAutoreleasedAttr(SourceRange R, ASTContext &Ctx
4796 , unsigned SI
4797 )
4798 : InheritableAttr(attr::NSReturnsAutoreleased, R, SI, false, false)
4799 {
4800 }
4801
4802 NSReturnsAutoreleasedAttr *clone(ASTContext &C) const;
4803 void printPretty(raw_ostream &OS,
4804 const PrintingPolicy &Policy) const;
4805 const char *getSpelling() const;
4806
4807
4808 static bool classof(const Attr *A) { return A->getKind() == attr::NSReturnsAutoreleased; }
4809};
4810
4811class NSReturnsNotRetainedAttr : public InheritableAttr {
4812public:
4813 static NSReturnsNotRetainedAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
4814 auto *A = new (Ctx) NSReturnsNotRetainedAttr(Loc, Ctx, 0);
4815 A->setImplicit(true);
4816 return A;
4817 }
4818
4819 NSReturnsNotRetainedAttr(SourceRange R, ASTContext &Ctx
4820 , unsigned SI
4821 )
4822 : InheritableAttr(attr::NSReturnsNotRetained, R, SI, false, false)
4823 {
4824 }
4825
4826 NSReturnsNotRetainedAttr *clone(ASTContext &C) const;
4827 void printPretty(raw_ostream &OS,
4828 const PrintingPolicy &Policy) const;
4829 const char *getSpelling() const;
4830
4831
4832 static bool classof(const Attr *A) { return A->getKind() == attr::NSReturnsNotRetained; }
4833};
4834
4835class NSReturnsRetainedAttr : public InheritableAttr {
4836public:
4837 static NSReturnsRetainedAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
4838 auto *A = new (Ctx) NSReturnsRetainedAttr(Loc, Ctx, 0);
4839 A->setImplicit(true);
4840 return A;
4841 }
4842
4843 NSReturnsRetainedAttr(SourceRange R, ASTContext &Ctx
4844 , unsigned SI
4845 )
4846 : InheritableAttr(attr::NSReturnsRetained, R, SI, false, false)
4847 {
4848 }
4849
4850 NSReturnsRetainedAttr *clone(ASTContext &C) const;
4851 void printPretty(raw_ostream &OS,
4852 const PrintingPolicy &Policy) const;
4853 const char *getSpelling() const;
4854
4855
4856 static bool classof(const Attr *A) { return A->getKind() == attr::NSReturnsRetained; }
4857};
4858
4859class NakedAttr : public InheritableAttr {
4860public:
4861 static NakedAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
4862 auto *A = new (Ctx) NakedAttr(Loc, Ctx, 0);
4863 A->setImplicit(true);
4864 return A;
4865 }
4866
4867 NakedAttr(SourceRange R, ASTContext &Ctx
4868 , unsigned SI
4869 )
4870 : InheritableAttr(attr::Naked, R, SI, false, false)
4871 {
4872 }
4873
4874 NakedAttr *clone(ASTContext &C) const;
4875 void printPretty(raw_ostream &OS,
4876 const PrintingPolicy &Policy) const;
4877 const char *getSpelling() const;
4878
4879
4880 static bool classof(const Attr *A) { return A->getKind() == attr::Naked; }
4881};
4882
4883class NoAliasAttr : public InheritableAttr {
4884public:
4885 static NoAliasAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
4886 auto *A = new (Ctx) NoAliasAttr(Loc, Ctx, 0);
4887 A->setImplicit(true);
4888 return A;
4889 }
4890
4891 NoAliasAttr(SourceRange R, ASTContext &Ctx
4892 , unsigned SI
4893 )
4894 : InheritableAttr(attr::NoAlias, R, SI, false, false)
4895 {
4896 }
4897
4898 NoAliasAttr *clone(ASTContext &C) const;
4899 void printPretty(raw_ostream &OS,
4900 const PrintingPolicy &Policy) const;
4901 const char *getSpelling() const;
4902
4903
4904 static bool classof(const Attr *A) { return A->getKind() == attr::NoAlias; }
4905};
4906
4907class NoCommonAttr : public InheritableAttr {
4908public:
4909 static NoCommonAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
4910 auto *A = new (Ctx) NoCommonAttr(Loc, Ctx, 0);
4911 A->setImplicit(true);
4912 return A;
4913 }
4914
4915 NoCommonAttr(SourceRange R, ASTContext &Ctx
4916 , unsigned SI
4917 )
4918 : InheritableAttr(attr::NoCommon, R, SI, false, false)
4919 {
4920 }
4921
4922 NoCommonAttr *clone(ASTContext &C) const;
4923 void printPretty(raw_ostream &OS,
4924 const PrintingPolicy &Policy) const;
4925 const char *getSpelling() const;
4926
4927
4928 static bool classof(const Attr *A) { return A->getKind() == attr::NoCommon; }
4929};
4930
4931class NoDebugAttr : public InheritableAttr {
4932public:
4933 static NoDebugAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
4934 auto *A = new (Ctx) NoDebugAttr(Loc, Ctx, 0);
4935 A->setImplicit(true);
4936 return A;
4937 }
4938
4939 NoDebugAttr(SourceRange R, ASTContext &Ctx
4940 , unsigned SI
4941 )
4942 : InheritableAttr(attr::NoDebug, R, SI, false, false)
4943 {
4944 }
4945
4946 NoDebugAttr *clone(ASTContext &C) const;
4947 void printPretty(raw_ostream &OS,
4948 const PrintingPolicy &Policy) const;
4949 const char *getSpelling() const;
4950
4951
4952 static bool classof(const Attr *A) { return A->getKind() == attr::NoDebug; }
4953};
4954
4955class NoDestroyAttr : public InheritableAttr {
4956public:
4957 static NoDestroyAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
4958 auto *A = new (Ctx) NoDestroyAttr(Loc, Ctx, 0);
4959 A->setImplicit(true);
4960 return A;
4961 }
4962
4963 NoDestroyAttr(SourceRange R, ASTContext &Ctx
4964 , unsigned SI
4965 )
4966 : InheritableAttr(attr::NoDestroy, R, SI, false, false)
4967 {
4968 }
4969
4970 NoDestroyAttr *clone(ASTContext &C) const;
4971 void printPretty(raw_ostream &OS,
4972 const PrintingPolicy &Policy) const;
4973 const char *getSpelling() const;
4974
4975
4976 static bool classof(const Attr *A) { return A->getKind() == attr::NoDestroy; }
4977};
4978
4979class NoDuplicateAttr : public InheritableAttr {
4980public:
4981 static NoDuplicateAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
4982 auto *A = new (Ctx) NoDuplicateAttr(Loc, Ctx, 0);
4983 A->setImplicit(true);
4984 return A;
4985 }
4986
4987 NoDuplicateAttr(SourceRange R, ASTContext &Ctx
4988 , unsigned SI
4989 )
4990 : InheritableAttr(attr::NoDuplicate, R, SI, false, false)
4991 {
4992 }
4993
4994 NoDuplicateAttr *clone(ASTContext &C) const;
4995 void printPretty(raw_ostream &OS,
4996 const PrintingPolicy &Policy) const;
4997 const char *getSpelling() const;
4998
4999
5000 static bool classof(const Attr *A) { return A->getKind() == attr::NoDuplicate; }
5001};
5002
5003class NoEscapeAttr : public Attr {
5004public:
5005 static NoEscapeAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
5006 auto *A = new (Ctx) NoEscapeAttr(Loc, Ctx, 0);
5007 A->setImplicit(true);
5008 return A;
5009 }
5010
5011 NoEscapeAttr(SourceRange R, ASTContext &Ctx
5012 , unsigned SI
5013 )
5014 : Attr(attr::NoEscape, R, SI, false)
5015 {
5016 }
5017
5018 NoEscapeAttr *clone(ASTContext &C) const;
5019 void printPretty(raw_ostream &OS,
5020 const PrintingPolicy &Policy) const;
5021 const char *getSpelling() const;
5022
5023
5024 static bool classof(const Attr *A) { return A->getKind() == attr::NoEscape; }
5025};
5026
5027class NoInlineAttr : public InheritableAttr {
5028public:
5029 static NoInlineAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
5030 auto *A = new (Ctx) NoInlineAttr(Loc, Ctx, 0);
5031 A->setImplicit(true);
5032 return A;
5033 }
5034
5035 NoInlineAttr(SourceRange R, ASTContext &Ctx
5036 , unsigned SI
5037 )
5038 : InheritableAttr(attr::NoInline, R, SI, false, false)
5039 {
5040 }
5041
5042 NoInlineAttr *clone(ASTContext &C) const;
5043 void printPretty(raw_ostream &OS,
5044 const PrintingPolicy &Policy) const;
5045 const char *getSpelling() const;
5046
5047
5048 static bool classof(const Attr *A) { return A->getKind() == attr::NoInline; }
5049};
5050
5051class NoInstrumentFunctionAttr : public InheritableAttr {
5052public:
5053 static NoInstrumentFunctionAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
5054 auto *A = new (Ctx) NoInstrumentFunctionAttr(Loc, Ctx, 0);
5055 A->setImplicit(true);
5056 return A;
5057 }
5058
5059 NoInstrumentFunctionAttr(SourceRange R, ASTContext &Ctx
5060 , unsigned SI
5061 )
5062 : InheritableAttr(attr::NoInstrumentFunction, R, SI, false, false)
5063 {
5064 }
5065
5066 NoInstrumentFunctionAttr *clone(ASTContext &C) const;
5067 void printPretty(raw_ostream &OS,
5068 const PrintingPolicy &Policy) const;
5069 const char *getSpelling() const;
5070
5071
5072 static bool classof(const Attr *A) { return A->getKind() == attr::NoInstrumentFunction; }
5073};
5074
5075class NoMicroMipsAttr : public InheritableAttr {
5076public:
5077 static NoMicroMipsAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
5078 auto *A = new (Ctx) NoMicroMipsAttr(Loc, Ctx, 0);
5079 A->setImplicit(true);
5080 return A;
5081 }
5082
5083 NoMicroMipsAttr(SourceRange R, ASTContext &Ctx
5084 , unsigned SI
5085 )
5086 : InheritableAttr(attr::NoMicroMips, R, SI, false, false)
5087 {
5088 }
5089
5090 NoMicroMipsAttr *clone(ASTContext &C) const;
5091 void printPretty(raw_ostream &OS,
5092 const PrintingPolicy &Policy) const;
5093 const char *getSpelling() const;
5094
5095
5096 static bool classof(const Attr *A) { return A->getKind() == attr::NoMicroMips; }
5097};
5098
5099class NoMips16Attr : public InheritableAttr {
5100public:
5101 static NoMips16Attr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
5102 auto *A = new (Ctx) NoMips16Attr(Loc, Ctx, 0);
5103 A->setImplicit(true);
5104 return A;
5105 }
5106
5107 NoMips16Attr(SourceRange R, ASTContext &Ctx
5108 , unsigned SI
5109 )
5110 : InheritableAttr(attr::NoMips16, R, SI, false, false)
5111 {
5112 }
5113
5114 NoMips16Attr *clone(ASTContext &C) const;
5115 void printPretty(raw_ostream &OS,
5116 const PrintingPolicy &Policy) const;
5117 const char *getSpelling() const;
5118
5119
5120 static bool classof(const Attr *A) { return A->getKind() == attr::NoMips16; }
5121};
5122
5123class NoReturnAttr : public InheritableAttr {
5124public:
5125 static NoReturnAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
5126 auto *A = new (Ctx) NoReturnAttr(Loc, Ctx, 0);
5127 A->setImplicit(true);
5128 return A;
5129 }
5130
5131 NoReturnAttr(SourceRange R, ASTContext &Ctx
5132 , unsigned SI
5133 )
5134 : InheritableAttr(attr::NoReturn, R, SI, false, false)
5135 {
5136 }
5137
5138 NoReturnAttr *clone(ASTContext &C) const;
5139 void printPretty(raw_ostream &OS,
5140 const PrintingPolicy &Policy) const;
5141 const char *getSpelling() const;
5142
5143
5144 static bool classof(const Attr *A) { return A->getKind() == attr::NoReturn; }
5145};
5146
5147class NoSanitizeAttr : public InheritableAttr {
5148 unsigned sanitizers_Size;
5149 StringRef *sanitizers_;
5150
5151public:
5152 static NoSanitizeAttr *CreateImplicit(ASTContext &Ctx, StringRef *Sanitizers, unsigned SanitizersSize, SourceRange Loc = SourceRange()) {
5153 auto *A = new (Ctx) NoSanitizeAttr(Loc, Ctx, Sanitizers, SanitizersSize, 0);
5154 A->setImplicit(true);
5155 return A;
5156 }
5157
5158 NoSanitizeAttr(SourceRange R, ASTContext &Ctx
5159 , StringRef *Sanitizers, unsigned SanitizersSize
5160 , unsigned SI
5161 )
5162 : InheritableAttr(attr::NoSanitize, R, SI, false, false)
5163 , sanitizers_Size(SanitizersSize), sanitizers_(new (Ctx, 16) StringRef[sanitizers_Size])
5164 {
5165 for (size_t I = 0, E = sanitizers_Size; I != E;
5166 ++I) {
5167 StringRef Ref = Sanitizers[I];
5168 if (!Ref.empty()) {
5169 char *Mem = new (Ctx, 1) char[Ref.size()];
5170 std::memcpy(Mem, Ref.data(), Ref.size());
5171 sanitizers_[I] = StringRef(Mem, Ref.size());
5172 }
5173 }
5174 }
5175
5176 NoSanitizeAttr(SourceRange R, ASTContext &Ctx
5177 , unsigned SI
5178 )
5179 : InheritableAttr(attr::NoSanitize, R, SI, false, false)
5180 , sanitizers_Size(0), sanitizers_(nullptr)
5181 {
5182 }
5183
5184 NoSanitizeAttr *clone(ASTContext &C) const;
5185 void printPretty(raw_ostream &OS,
5186 const PrintingPolicy &Policy) const;
5187 const char *getSpelling() const;
5188 typedef StringRef* sanitizers_iterator;
5189 sanitizers_iterator sanitizers_begin() const { return sanitizers_; }
5190 sanitizers_iterator sanitizers_end() const { return sanitizers_ + sanitizers_Size; }
5191 unsigned sanitizers_size() const { return sanitizers_Size; }
5192 llvm::iterator_range<sanitizers_iterator> sanitizers() const { return llvm::make_range(sanitizers_begin(), sanitizers_end()); }
5193
5194
5195
5196 SanitizerMask getMask() const {
5197 SanitizerMask Mask = 0;
5198 for (auto SanitizerName : sanitizers()) {
5199 SanitizerMask ParsedMask =
5200 parseSanitizerValue(SanitizerName, /*AllowGroups=*/true);
5201 Mask |= expandSanitizerGroups(ParsedMask);
5202 }
5203 return Mask;
5204 }
5205
5206
5207 static bool classof(const Attr *A) { return A->getKind() == attr::NoSanitize; }
5208};
5209
5210class NoSplitStackAttr : public InheritableAttr {
5211public:
5212 static NoSplitStackAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
5213 auto *A = new (Ctx) NoSplitStackAttr(Loc, Ctx, 0);
5214 A->setImplicit(true);
5215 return A;
5216 }
5217
5218 NoSplitStackAttr(SourceRange R, ASTContext &Ctx
5219 , unsigned SI
5220 )
5221 : InheritableAttr(attr::NoSplitStack, R, SI, false, false)
5222 {
5223 }
5224
5225 NoSplitStackAttr *clone(ASTContext &C) const;
5226 void printPretty(raw_ostream &OS,
5227 const PrintingPolicy &Policy) const;
5228 const char *getSpelling() const;
5229
5230
5231 static bool classof(const Attr *A) { return A->getKind() == attr::NoSplitStack; }
5232};
5233
5234class NoStackProtectorAttr : public InheritableAttr {
5235public:
5236 static NoStackProtectorAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
5237 auto *A = new (Ctx) NoStackProtectorAttr(Loc, Ctx, 0);
5238 A->setImplicit(true);
5239 return A;
5240 }
5241
5242 NoStackProtectorAttr(SourceRange R, ASTContext &Ctx
5243 , unsigned SI
5244 )
5245 : InheritableAttr(attr::NoStackProtector, R, SI, false, false)
5246 {
5247 }
5248
5249 NoStackProtectorAttr *clone(ASTContext &C) const;
5250 void printPretty(raw_ostream &OS,
5251 const PrintingPolicy &Policy) const;
5252 const char *getSpelling() const;
5253
5254
5255 static bool classof(const Attr *A) { return A->getKind() == attr::NoStackProtector; }
5256};
5257
5258class NoThreadSafetyAnalysisAttr : public InheritableAttr {
5259public:
5260 static NoThreadSafetyAnalysisAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
5261 auto *A = new (Ctx) NoThreadSafetyAnalysisAttr(Loc, Ctx, 0);
5262 A->setImplicit(true);
5263 return A;
5264 }
5265
5266 NoThreadSafetyAnalysisAttr(SourceRange R, ASTContext &Ctx
5267 , unsigned SI
5268 )
5269 : InheritableAttr(attr::NoThreadSafetyAnalysis, R, SI, false, false)
5270 {
5271 }
5272
5273 NoThreadSafetyAnalysisAttr *clone(ASTContext &C) const;
5274 void printPretty(raw_ostream &OS,
5275 const PrintingPolicy &Policy) const;
5276 const char *getSpelling() const;
5277
5278
5279 static bool classof(const Attr *A) { return A->getKind() == attr::NoThreadSafetyAnalysis; }
5280};
5281
5282class NoThrowAttr : public InheritableAttr {
5283public:
5284 static NoThrowAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
5285 auto *A = new (Ctx) NoThrowAttr(Loc, Ctx, 0);
5286 A->setImplicit(true);
5287 return A;
5288 }
5289
5290 NoThrowAttr(SourceRange R, ASTContext &Ctx
5291 , unsigned SI
5292 )
5293 : InheritableAttr(attr::NoThrow, R, SI, false, false)
5294 {
5295 }
5296
5297 NoThrowAttr *clone(ASTContext &C) const;
5298 void printPretty(raw_ostream &OS,
5299 const PrintingPolicy &Policy) const;
5300 const char *getSpelling() const;
5301
5302
5303 static bool classof(const Attr *A) { return A->getKind() == attr::NoThrow; }
5304};
5305
5306class NonNullAttr : public InheritableParamAttr {
5307 unsigned args_Size;
5308 ParamIdx *args_;
5309
5310public:
5311 static NonNullAttr *CreateImplicit(ASTContext &Ctx, ParamIdx *Args, unsigned ArgsSize, SourceRange Loc = SourceRange()) {
5312 auto *A = new (Ctx) NonNullAttr(Loc, Ctx, Args, ArgsSize, 0);
5313 A->setImplicit(true);
5314 return A;
5315 }
5316
5317 NonNullAttr(SourceRange R, ASTContext &Ctx
5318 , ParamIdx *Args, unsigned ArgsSize
5319 , unsigned SI
5320 )
5321 : InheritableParamAttr(attr::NonNull, R, SI, false, true)
5322 , args_Size(ArgsSize), args_(new (Ctx, 16) ParamIdx[args_Size])
5323 {
5324 std::copy(Args, Args + args_Size, args_);
5325 }
5326
5327 NonNullAttr(SourceRange R, ASTContext &Ctx
5328 , unsigned SI
5329 )
5330 : InheritableParamAttr(attr::NonNull, R, SI, false, true)
5331 , args_Size(0), args_(nullptr)
5332 {
5333 }
5334
5335 NonNullAttr *clone(ASTContext &C) const;
5336 void printPretty(raw_ostream &OS,
5337 const PrintingPolicy &Policy) const;
5338 const char *getSpelling() const;
5339 typedef ParamIdx* args_iterator;
5340 args_iterator args_begin() const { return args_; }
5341 args_iterator args_end() const { return args_ + args_Size; }
5342 unsigned args_size() const { return args_Size; }
5343 llvm::iterator_range<args_iterator> args() const { return llvm::make_range(args_begin(), args_end()); }
5344
5345
5346
5347 bool isNonNull(unsigned IdxAST) const {
5348 if (!args_size())
5349 return true;
5350 return args_end() != std::find_if(
5351 args_begin(), args_end(),
5352 [=](const ParamIdx &Idx) { return Idx.getASTIndex() == IdxAST; });
5353 }
5354
5355
5356 static bool classof(const Attr *A) { return A->getKind() == attr::NonNull; }
5357};
5358
5359class NotTailCalledAttr : public InheritableAttr {
5360public:
5361 static NotTailCalledAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
5362 auto *A = new (Ctx) NotTailCalledAttr(Loc, Ctx, 0);
5363 A->setImplicit(true);
5364 return A;
5365 }
5366
5367 NotTailCalledAttr(SourceRange R, ASTContext &Ctx
5368 , unsigned SI
5369 )
5370 : InheritableAttr(attr::NotTailCalled, R, SI, false, false)
5371 {
5372 }
5373
5374 NotTailCalledAttr *clone(ASTContext &C) const;
5375 void printPretty(raw_ostream &OS,
5376 const PrintingPolicy &Policy) const;
5377 const char *getSpelling() const;
5378
5379
5380 static bool classof(const Attr *A) { return A->getKind() == attr::NotTailCalled; }
5381};
5382
5383class OMPCaptureKindAttr : public Attr {
5384unsigned captureKind;
5385
5386public:
5387 static OMPCaptureKindAttr *CreateImplicit(ASTContext &Ctx, unsigned CaptureKind, SourceRange Loc = SourceRange()) {
5388 auto *A = new (Ctx) OMPCaptureKindAttr(Loc, Ctx, CaptureKind, 0);
5389 A->setImplicit(true);
5390 return A;
5391 }
5392
5393 OMPCaptureKindAttr(SourceRange R, ASTContext &Ctx
5394 , unsigned CaptureKind
5395 , unsigned SI
5396 )
5397 : Attr(attr::OMPCaptureKind, R, SI, false)
5398 , captureKind(CaptureKind)
5399 {
5400 }
5401
5402 OMPCaptureKindAttr *clone(ASTContext &C) const;
5403 void printPretty(raw_ostream &OS,
5404 const PrintingPolicy &Policy) const;
5405 const char *getSpelling() const;
5406 unsigned getCaptureKind() const {
5407 return captureKind;
5408 }
5409
5410
5411
5412 static bool classof(const Attr *A) { return A->getKind() == attr::OMPCaptureKind; }
5413};
5414
5415class OMPCaptureNoInitAttr : public InheritableAttr {
5416public:
5417 static OMPCaptureNoInitAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
5418 auto *A = new (Ctx) OMPCaptureNoInitAttr(Loc, Ctx, 0);
5419 A->setImplicit(true);
5420 return A;
5421 }
5422
5423 OMPCaptureNoInitAttr(SourceRange R, ASTContext &Ctx
5424 , unsigned SI
5425 )
5426 : InheritableAttr(attr::OMPCaptureNoInit, R, SI, false, false)
5427 {
5428 }
5429
5430 OMPCaptureNoInitAttr *clone(ASTContext &C) const;
5431 void printPretty(raw_ostream &OS,
5432 const PrintingPolicy &Policy) const;
5433 const char *getSpelling() const;
5434
5435
5436 static bool classof(const Attr *A) { return A->getKind() == attr::OMPCaptureNoInit; }
5437};
5438
5439class OMPDeclareSimdDeclAttr : public Attr {
5440public:
5441 enum BranchStateTy {
5442 BS_Undefined,
5443 BS_Inbranch,
5444 BS_Notinbranch
5445 };
5446private:
5447 BranchStateTy branchState;
5448
5449Expr * simdlen;
5450
5451 unsigned uniforms_Size;
5452 Expr * *uniforms_;
5453
5454 unsigned aligneds_Size;
5455 Expr * *aligneds_;
5456
5457 unsigned alignments_Size;
5458 Expr * *alignments_;
5459
5460 unsigned linears_Size;
5461 Expr * *linears_;
5462
5463 unsigned modifiers_Size;
5464 unsigned *modifiers_;
5465
5466 unsigned steps_Size;
5467 Expr * *steps_;
5468
5469public:
5470 static OMPDeclareSimdDeclAttr *CreateImplicit(ASTContext &Ctx, BranchStateTy BranchState, Expr * Simdlen, Expr * *Uniforms, unsigned UniformsSize, Expr * *Aligneds, unsigned AlignedsSize, Expr * *Alignments, unsigned AlignmentsSize, Expr * *Linears, unsigned LinearsSize, unsigned *Modifiers, unsigned ModifiersSize, Expr * *Steps, unsigned StepsSize, SourceRange Loc = SourceRange()) {
5471 auto *A = new (Ctx) OMPDeclareSimdDeclAttr(Loc, Ctx, BranchState, Simdlen, Uniforms, UniformsSize, Aligneds, AlignedsSize, Alignments, AlignmentsSize, Linears, LinearsSize, Modifiers, ModifiersSize, Steps, StepsSize, 0);
5472 A->setImplicit(true);
5473 return A;
5474 }
5475
5476 OMPDeclareSimdDeclAttr(SourceRange R, ASTContext &Ctx
5477 , BranchStateTy BranchState
5478 , Expr * Simdlen
5479 , Expr * *Uniforms, unsigned UniformsSize
5480 , Expr * *Aligneds, unsigned AlignedsSize
5481 , Expr * *Alignments, unsigned AlignmentsSize
5482 , Expr * *Linears, unsigned LinearsSize
5483 , unsigned *Modifiers, unsigned ModifiersSize
5484 , Expr * *Steps, unsigned StepsSize
5485 , unsigned SI
5486 )
5487 : Attr(attr::OMPDeclareSimdDecl, R, SI, false)
5488 , branchState(BranchState)
5489 , simdlen(Simdlen)
5490 , uniforms_Size(UniformsSize), uniforms_(new (Ctx, 16) Expr *[uniforms_Size])
5491 , aligneds_Size(AlignedsSize), aligneds_(new (Ctx, 16) Expr *[aligneds_Size])
5492 , alignments_Size(AlignmentsSize), alignments_(new (Ctx, 16) Expr *[alignments_Size])
5493 , linears_Size(LinearsSize), linears_(new (Ctx, 16) Expr *[linears_Size])
5494 , modifiers_Size(ModifiersSize), modifiers_(new (Ctx, 16) unsigned[modifiers_Size])
5495 , steps_Size(StepsSize), steps_(new (Ctx, 16) Expr *[steps_Size])
5496 {
5497 std::copy(Uniforms, Uniforms + uniforms_Size, uniforms_);
5498 std::copy(Aligneds, Aligneds + aligneds_Size, aligneds_);
5499 std::copy(Alignments, Alignments + alignments_Size, alignments_);
5500 std::copy(Linears, Linears + linears_Size, linears_);
5501 std::copy(Modifiers, Modifiers + modifiers_Size, modifiers_);
5502 std::copy(Steps, Steps + steps_Size, steps_);
5503 }
5504
5505 OMPDeclareSimdDeclAttr(SourceRange R, ASTContext &Ctx
5506 , BranchStateTy BranchState
5507 , Expr * Simdlen
5508 , unsigned SI
5509 )
5510 : Attr(attr::OMPDeclareSimdDecl, R, SI, false)
5511 , branchState(BranchState)
5512 , simdlen(Simdlen)
5513 , uniforms_Size(0), uniforms_(nullptr)
5514 , aligneds_Size(0), aligneds_(nullptr)
5515 , alignments_Size(0), alignments_(nullptr)
5516 , linears_Size(0), linears_(nullptr)
5517 , modifiers_Size(0), modifiers_(nullptr)
5518 , steps_Size(0), steps_(nullptr)
5519 {
5520 }
5521
5522 OMPDeclareSimdDeclAttr *clone(ASTContext &C) const;
5523 void printPretty(raw_ostream &OS,
5524 const PrintingPolicy &Policy) const;
5525 const char *getSpelling() const;
5526 BranchStateTy getBranchState() const {
5527 return branchState;
5528 }
5529
5530 static bool ConvertStrToBranchStateTy(StringRef Val, BranchStateTy &Out) {
5531 Optional<BranchStateTy> R = llvm::StringSwitch<Optional<BranchStateTy>>(Val)
5532 .Case("", OMPDeclareSimdDeclAttr::BS_Undefined)
5533 .Case("inbranch", OMPDeclareSimdDeclAttr::BS_Inbranch)
5534 .Case("notinbranch", OMPDeclareSimdDeclAttr::BS_Notinbranch)
5535 .Default(Optional<BranchStateTy>());
5536 if (R) {
5537 Out = *R;
5538 return true;
5539 }
5540 return false;
5541 }
5542
5543 static const char *ConvertBranchStateTyToStr(BranchStateTy Val) {
5544 switch(Val) {
5545 case OMPDeclareSimdDeclAttr::BS_Undefined: return "";
5546 case OMPDeclareSimdDeclAttr::BS_Inbranch: return "inbranch";
5547 case OMPDeclareSimdDeclAttr::BS_Notinbranch: return "notinbranch";
5548 }
5549 llvm_unreachable("No enumerator with that value")::llvm::llvm_unreachable_internal("No enumerator with that value"
, "/build/llvm-toolchain-snapshot-8~svn345461/build-llvm/tools/lldb/../clang/include/clang/AST/Attrs.inc"
, 5549)
;
5550 }
5551 Expr * getSimdlen() const {
5552 return simdlen;
5553 }
5554
5555 typedef Expr ** uniforms_iterator;
5556 uniforms_iterator uniforms_begin() const { return uniforms_; }
5557 uniforms_iterator uniforms_end() const { return uniforms_ + uniforms_Size; }
5558 unsigned uniforms_size() const { return uniforms_Size; }
5559 llvm::iterator_range<uniforms_iterator> uniforms() const { return llvm::make_range(uniforms_begin(), uniforms_end()); }
5560
5561
5562 typedef Expr ** aligneds_iterator;
5563 aligneds_iterator aligneds_begin() const { return aligneds_; }
5564 aligneds_iterator aligneds_end() const { return aligneds_ + aligneds_Size; }
5565 unsigned aligneds_size() const { return aligneds_Size; }
5566 llvm::iterator_range<aligneds_iterator> aligneds() const { return llvm::make_range(aligneds_begin(), aligneds_end()); }
5567
5568
5569 typedef Expr ** alignments_iterator;
5570 alignments_iterator alignments_begin() const { return alignments_; }
5571 alignments_iterator alignments_end() const { return alignments_ + alignments_Size; }
5572 unsigned alignments_size() const { return alignments_Size; }
5573 llvm::iterator_range<alignments_iterator> alignments() const { return llvm::make_range(alignments_begin(), alignments_end()); }
5574
5575
5576 typedef Expr ** linears_iterator;
5577 linears_iterator linears_begin() const { return linears_; }
5578 linears_iterator linears_end() const { return linears_ + linears_Size; }
5579 unsigned linears_size() const { return linears_Size; }
5580 llvm::iterator_range<linears_iterator> linears() const { return llvm::make_range(linears_begin(), linears_end()); }
5581
5582
5583 typedef unsigned* modifiers_iterator;
5584 modifiers_iterator modifiers_begin() const { return modifiers_; }
5585 modifiers_iterator modifiers_end() const { return modifiers_ + modifiers_Size; }
5586 unsigned modifiers_size() const { return modifiers_Size; }
5587 llvm::iterator_range<modifiers_iterator> modifiers() const { return llvm::make_range(modifiers_begin(), modifiers_end()); }
5588
5589
5590 typedef Expr ** steps_iterator;
5591 steps_iterator steps_begin() const { return steps_; }
5592 steps_iterator steps_end() const { return steps_ + steps_Size; }
5593 unsigned steps_size() const { return steps_Size; }
5594 llvm::iterator_range<steps_iterator> steps() const { return llvm::make_range(steps_begin(), steps_end()); }
5595
5596
5597
5598 void printPrettyPragma(raw_ostream & OS, const PrintingPolicy &Policy)
5599 const {
5600 if (getBranchState() != BS_Undefined)
5601 OS << ' ' << ConvertBranchStateTyToStr(getBranchState());
5602 if (auto *E = getSimdlen()) {
5603 OS << " simdlen(";
5604 E->printPretty(OS, nullptr, Policy);
5605 OS << ")";
5606 }
5607 if (uniforms_size() > 0) {
5608 OS << " uniform";
5609 StringRef Sep = "(";
5610 for (auto *E : uniforms()) {
5611 OS << Sep;
5612 E->printPretty(OS, nullptr, Policy);
5613 Sep = ", ";
5614 }
5615 OS << ")";
5616 }
5617 alignments_iterator NI = alignments_begin();
5618 for (auto *E : aligneds()) {
5619 OS << " aligned(";
5620 E->printPretty(OS, nullptr, Policy);
5621 if (*NI) {
5622 OS << ": ";
5623 (*NI)->printPretty(OS, nullptr, Policy);
5624 }
5625 OS << ")";
5626 ++NI;
5627 }
5628 steps_iterator I = steps_begin();
5629 modifiers_iterator MI = modifiers_begin();
5630 for (auto *E : linears()) {
5631 OS << " linear(";
5632 if (*MI != OMPC_LINEAR_unknown)
5633 OS << getOpenMPSimpleClauseTypeName(OMPC_linear, *MI) << "(";
5634 E->printPretty(OS, nullptr, Policy);
5635 if (*MI != OMPC_LINEAR_unknown)
5636 OS << ")";
5637 if (*I) {
5638 OS << ": ";
5639 (*I)->printPretty(OS, nullptr, Policy);
5640 }
5641 OS << ")";
5642 ++I;
5643 ++MI;
5644 }
5645 }
5646
5647
5648 static bool classof(const Attr *A) { return A->getKind() == attr::OMPDeclareSimdDecl; }
5649};
5650
5651class OMPDeclareTargetDeclAttr : public InheritableAttr {
5652public:
5653 enum MapTypeTy {
5654 MT_To,
5655 MT_Link
5656 };
5657private:
5658 MapTypeTy mapType;
5659
5660public:
5661 static OMPDeclareTargetDeclAttr *CreateImplicit(ASTContext &Ctx, MapTypeTy MapType, SourceRange Loc = SourceRange()) {
5662 auto *A = new (Ctx) OMPDeclareTargetDeclAttr(Loc, Ctx, MapType, 0);
5663 A->setImplicit(true);
5664 return A;
5665 }
5666
5667 OMPDeclareTargetDeclAttr(SourceRange R, ASTContext &Ctx
5668 , MapTypeTy MapType
5669 , unsigned SI
5670 )
5671 : InheritableAttr(attr::OMPDeclareTargetDecl, R, SI, false, false)
5672 , mapType(MapType)
5673 {
5674 }
5675
5676 OMPDeclareTargetDeclAttr *clone(ASTContext &C) const;
5677 void printPretty(raw_ostream &OS,
5678 const PrintingPolicy &Policy) const;
5679 const char *getSpelling() const;
5680 MapTypeTy getMapType() const {
5681 return mapType;
5682 }
5683
5684 static bool ConvertStrToMapTypeTy(StringRef Val, MapTypeTy &Out) {
5685 Optional<MapTypeTy> R = llvm::StringSwitch<Optional<MapTypeTy>>(Val)
5686 .Case("to", OMPDeclareTargetDeclAttr::MT_To)
5687 .Case("link", OMPDeclareTargetDeclAttr::MT_Link)
5688 .Default(Optional<MapTypeTy>());
5689 if (R) {
5690 Out = *R;
5691 return true;
5692 }
5693 return false;
5694 }
5695
5696 static const char *ConvertMapTypeTyToStr(MapTypeTy Val) {
5697 switch(Val) {
5698 case OMPDeclareTargetDeclAttr::MT_To: return "to";
5699 case OMPDeclareTargetDeclAttr::MT_Link: return "link";
5700 }
5701 llvm_unreachable("No enumerator with that value")::llvm::llvm_unreachable_internal("No enumerator with that value"
, "/build/llvm-toolchain-snapshot-8~svn345461/build-llvm/tools/lldb/../clang/include/clang/AST/Attrs.inc"
, 5701)
;
5702 }
5703
5704 void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const {
5705 // Use fake syntax because it is for testing and debugging purpose only.
5706 if (getMapType() != MT_To)
5707 OS << ' ' << ConvertMapTypeTyToStr(getMapType());
5708 }
5709 static llvm::Optional<MapTypeTy>
5710 isDeclareTargetDeclaration(const ValueDecl *VD) {
5711 if (!VD->hasAttrs())
5712 return llvm::None;
5713 if (const auto *Attr = VD->getAttr<OMPDeclareTargetDeclAttr>())
5714 return Attr->getMapType();
5715
5716 return llvm::None;
5717 }
5718
5719
5720 static bool classof(const Attr *A) { return A->getKind() == attr::OMPDeclareTargetDecl; }
5721};
5722
5723class OMPReferencedVarAttr : public Attr {
5724Expr * ref;
5725
5726public:
5727 static OMPReferencedVarAttr *CreateImplicit(ASTContext &Ctx, Expr * Ref, SourceRange Loc = SourceRange()) {
5728 auto *A = new (Ctx) OMPReferencedVarAttr(Loc, Ctx, Ref, 0);
5729 A->setImplicit(true);
5730 return A;
5731 }
5732
5733 OMPReferencedVarAttr(SourceRange R, ASTContext &Ctx
5734 , Expr * Ref
5735 , unsigned SI
5736 )
5737 : Attr(attr::OMPReferencedVar, R, SI, false)
5738 , ref(Ref)
5739 {
5740 }
5741
5742 OMPReferencedVarAttr *clone(ASTContext &C) const;
5743 void printPretty(raw_ostream &OS,
5744 const PrintingPolicy &Policy) const;
5745 const char *getSpelling() const;
5746 Expr * getRef() const {
5747 return ref;
5748 }
5749
5750
5751
5752 static bool classof(const Attr *A) { return A->getKind() == attr::OMPReferencedVar; }
5753};
5754
5755class OMPThreadPrivateDeclAttr : public InheritableAttr {
5756public:
5757 static OMPThreadPrivateDeclAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
5758 auto *A = new (Ctx) OMPThreadPrivateDeclAttr(Loc, Ctx, 0);
5759 A->setImplicit(true);
5760 return A;
5761 }
5762
5763 OMPThreadPrivateDeclAttr(SourceRange R, ASTContext &Ctx
5764 , unsigned SI
5765 )
5766 : InheritableAttr(attr::OMPThreadPrivateDecl, R, SI, false, false)
5767 {
5768 }
5769
5770 OMPThreadPrivateDeclAttr *clone(ASTContext &C) const;
5771 void printPretty(raw_ostream &OS,
5772 const PrintingPolicy &Policy) const;
5773 const char *getSpelling() const;
5774
5775
5776 static bool classof(const Attr *A) { return A->getKind() == attr::OMPThreadPrivateDecl; }
5777};
5778
5779class ObjCBoxableAttr : public Attr {
5780public:
5781 static ObjCBoxableAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
5782 auto *A = new (Ctx) ObjCBoxableAttr(Loc, Ctx, 0);
5783 A->setImplicit(true);
5784 return A;
5785 }
5786
5787 ObjCBoxableAttr(SourceRange R, ASTContext &Ctx
5788 , unsigned SI
5789 )
5790 : Attr(attr::ObjCBoxable, R, SI, false)
5791 {
5792 }
5793
5794 ObjCBoxableAttr *clone(ASTContext &C) const;
5795 void printPretty(raw_ostream &OS,
5796 const PrintingPolicy &Policy) const;
5797 const char *getSpelling() const;
5798
5799
5800 static bool classof(const Attr *A) { return A->getKind() == attr::ObjCBoxable; }
5801};
5802
5803class ObjCBridgeAttr : public InheritableAttr {
5804IdentifierInfo * bridgedType;
5805
5806public:
5807 static ObjCBridgeAttr *CreateImplicit(ASTContext &Ctx, IdentifierInfo * BridgedType, SourceRange Loc = SourceRange()) {
5808 auto *A = new (Ctx) ObjCBridgeAttr(Loc, Ctx, BridgedType, 0);
5809 A->setImplicit(true);
5810 return A;
5811 }
5812
5813 ObjCBridgeAttr(SourceRange R, ASTContext &Ctx
5814 , IdentifierInfo * BridgedType
5815 , unsigned SI
5816 )
5817 : InheritableAttr(attr::ObjCBridge, R, SI, false, false)
5818 , bridgedType(BridgedType)
5819 {
5820 }
5821
5822 ObjCBridgeAttr *clone(ASTContext &C) const;
5823 void printPretty(raw_ostream &OS,
5824 const PrintingPolicy &Policy) const;
5825 const char *getSpelling() const;
5826 IdentifierInfo * getBridgedType() const {
5827 return bridgedType;
5828 }
5829
5830
5831
5832 static bool classof(const Attr *A) { return A->getKind() == attr::ObjCBridge; }
5833};
5834
5835class ObjCBridgeMutableAttr : public InheritableAttr {
5836IdentifierInfo * bridgedType;
5837
5838public:
5839 static ObjCBridgeMutableAttr *CreateImplicit(ASTContext &Ctx, IdentifierInfo * BridgedType, SourceRange Loc = SourceRange()) {
5840 auto *A = new (Ctx) ObjCBridgeMutableAttr(Loc, Ctx, BridgedType, 0);
5841 A->setImplicit(true);
5842 return A;
5843 }
5844
5845 ObjCBridgeMutableAttr(SourceRange R, ASTContext &Ctx
5846 , IdentifierInfo * BridgedType
5847 , unsigned SI
5848 )
5849 : InheritableAttr(attr::ObjCBridgeMutable, R, SI, false, false)
5850 , bridgedType(BridgedType)
5851 {
5852 }
5853
5854 ObjCBridgeMutableAttr *clone(ASTContext &C) const;
5855 void printPretty(raw_ostream &OS,
5856 const PrintingPolicy &Policy) const;
5857 const char *getSpelling() const;
5858 IdentifierInfo * getBridgedType() const {
5859 return bridgedType;
5860 }
5861
5862
5863
5864 static bool classof(const Attr *A) { return A->getKind() == attr::ObjCBridgeMutable; }
5865};
5866
5867class ObjCBridgeRelatedAttr : public InheritableAttr {
5868IdentifierInfo * relatedClass;
5869
5870IdentifierInfo * classMethod;
5871
5872IdentifierInfo * instanceMethod;
5873
5874public:
5875 static ObjCBridgeRelatedAttr *CreateImplicit(ASTContext &Ctx, IdentifierInfo * RelatedClass, IdentifierInfo * ClassMethod, IdentifierInfo * InstanceMethod, SourceRange Loc = SourceRange()) {
5876 auto *A = new (Ctx) ObjCBridgeRelatedAttr(Loc, Ctx, RelatedClass, ClassMethod, InstanceMethod, 0);
5877 A->setImplicit(true);
5878 return A;
5879 }
5880
5881 ObjCBridgeRelatedAttr(SourceRange R, ASTContext &Ctx
5882 , IdentifierInfo * RelatedClass
5883 , IdentifierInfo * ClassMethod
5884 , IdentifierInfo * InstanceMethod
5885 , unsigned SI
5886 )
5887 : InheritableAttr(attr::ObjCBridgeRelated, R, SI, false, false)
5888 , relatedClass(RelatedClass)
5889 , classMethod(ClassMethod)
5890 , instanceMethod(InstanceMethod)
5891 {
5892 }
5893
5894 ObjCBridgeRelatedAttr *clone(ASTContext &C) const;
5895 void printPretty(raw_ostream &OS,
5896 const PrintingPolicy &Policy) const;
5897 const char *getSpelling() const;
5898 IdentifierInfo * getRelatedClass() const {
5899 return relatedClass;
5900 }
5901
5902 IdentifierInfo * getClassMethod() const {
5903 return classMethod;
5904 }
5905
5906 IdentifierInfo * getInstanceMethod() const {
5907 return instanceMethod;
5908 }
5909
5910
5911
5912 static bool classof(const Attr *A) { return A->getKind() == attr::ObjCBridgeRelated; }
5913};
5914
5915class ObjCDesignatedInitializerAttr : public Attr {
5916public:
5917 static ObjCDesignatedInitializerAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
5918 auto *A = new (Ctx) ObjCDesignatedInitializerAttr(Loc, Ctx, 0);
5919 A->setImplicit(true);
5920 return A;
5921 }
5922
5923 ObjCDesignatedInitializerAttr(SourceRange R, ASTContext &Ctx
5924 , unsigned SI
5925 )
5926 : Attr(attr::ObjCDesignatedInitializer, R, SI, false)
5927 {
5928 }
5929
5930 ObjCDesignatedInitializerAttr *clone(ASTContext &C) const;
5931 void printPretty(raw_ostream &OS,
5932 const PrintingPolicy &Policy) const;
5933 const char *getSpelling() const;
5934
5935
5936 static bool classof(const Attr *A) { return A->getKind() == attr::ObjCDesignatedInitializer; }
5937};
5938
5939class ObjCExceptionAttr : public InheritableAttr {
5940public:
5941 static ObjCExceptionAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
5942 auto *A = new (Ctx) ObjCExceptionAttr(Loc, Ctx, 0);
5943 A->setImplicit(true);
5944 return A;
5945 }
5946
5947 ObjCExceptionAttr(SourceRange R, ASTContext &Ctx
5948 , unsigned SI
5949 )
5950 : InheritableAttr(attr::ObjCException, R, SI, false, false)
5951 {
5952 }
5953
5954 ObjCExceptionAttr *clone(ASTContext &C) const;
5955 void printPretty(raw_ostream &OS,
5956 const PrintingPolicy &Policy) const;
5957 const char *getSpelling() const;
5958
5959
5960 static bool classof(const Attr *A) { return A->getKind() == attr::ObjCException; }
5961};
5962
5963class ObjCExplicitProtocolImplAttr : public InheritableAttr {
5964public:
5965 static ObjCExplicitProtocolImplAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
5966 auto *A = new (Ctx) ObjCExplicitProtocolImplAttr(Loc, Ctx, 0);
5967 A->setImplicit(true);
5968 return A;
5969 }
5970
5971 ObjCExplicitProtocolImplAttr(SourceRange R, ASTContext &Ctx
5972 , unsigned SI
5973 )
5974 : InheritableAttr(attr::ObjCExplicitProtocolImpl, R, SI, false, false)
5975 {
5976 }
5977
5978 ObjCExplicitProtocolImplAttr *clone(ASTContext &C) const;
5979 void printPretty(raw_ostream &OS,
5980 const PrintingPolicy &Policy) const;
5981 const char *getSpelling() const;
5982
5983
5984 static bool classof(const Attr *A) { return A->getKind() == attr::ObjCExplicitProtocolImpl; }
5985};
5986
5987class ObjCGCAttr : public TypeAttr {
5988IdentifierInfo * kind;
5989
5990public:
5991 static ObjCGCAttr *CreateImplicit(ASTContext &Ctx, IdentifierInfo * Kind, SourceRange Loc = SourceRange()) {
5992 auto *A = new (Ctx) ObjCGCAttr(Loc, Ctx, Kind, 0);
5993 A->setImplicit(true);
5994 return A;
5995 }
5996
5997 ObjCGCAttr(SourceRange R, ASTContext &Ctx
5998 , IdentifierInfo * Kind
5999 , unsigned SI
6000 )
6001 : TypeAttr(attr::ObjCGC, R, SI, false)
6002 , kind(Kind)
6003 {
6004 }
6005
6006 ObjCGCAttr *clone(ASTContext &C) const;
6007 void printPretty(raw_ostream &OS,
6008 const PrintingPolicy &Policy) const;
6009 const char *getSpelling() const;
6010 IdentifierInfo * getKind() const {
6011 return kind;
6012 }
6013
6014
6015
6016 static bool classof(const Attr *A) { return A->getKind() == attr::ObjCGC; }
6017};
6018
6019class ObjCIndependentClassAttr : public InheritableAttr {
6020public:
6021 static ObjCIndependentClassAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
6022 auto *A = new (Ctx) ObjCIndependentClassAttr(Loc, Ctx, 0);
6023 A->setImplicit(true);
6024 return A;
6025 }
6026
6027 ObjCIndependentClassAttr(SourceRange R, ASTContext &Ctx
6028 , unsigned SI
6029 )
6030 : InheritableAttr(attr::ObjCIndependentClass, R, SI, false, false)
6031 {
6032 }
6033
6034 ObjCIndependentClassAttr *clone(ASTContext &C) const;
6035 void printPretty(raw_ostream &OS,
6036 const PrintingPolicy &Policy) const;
6037 const char *getSpelling() const;
6038
6039
6040 static bool classof(const Attr *A) { return A->getKind() == attr::ObjCIndependentClass; }
6041};
6042
6043class ObjCInertUnsafeUnretainedAttr : public TypeAttr {
6044public:
6045 static ObjCInertUnsafeUnretainedAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
6046 auto *A = new (Ctx) ObjCInertUnsafeUnretainedAttr(Loc, Ctx, 0);
6047 A->setImplicit(true);
6048 return A;
6049 }
6050
6051 ObjCInertUnsafeUnretainedAttr(SourceRange R, ASTContext &Ctx
6052 , unsigned SI
6053 )
6054 : TypeAttr(attr::ObjCInertUnsafeUnretained, R, SI, false)
6055 {
6056 }
6057
6058 ObjCInertUnsafeUnretainedAttr *clone(ASTContext &C) const;
6059 void printPretty(raw_ostream &OS,
6060 const PrintingPolicy &Policy) const;
6061 const char *getSpelling() const;
6062
6063
6064 static bool classof(const Attr *A) { return A->getKind() == attr::ObjCInertUnsafeUnretained; }
6065};
6066
6067class ObjCKindOfAttr : public TypeAttr {
6068public:
6069 static ObjCKindOfAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
6070 auto *A = new (Ctx) ObjCKindOfAttr(Loc, Ctx, 0);
6071 A->setImplicit(true);
6072 return A;
6073 }
6074
6075 ObjCKindOfAttr(SourceRange R, ASTContext &Ctx
6076 , unsigned SI
6077 )
6078 : TypeAttr(attr::ObjCKindOf, R, SI, false)
6079 {
6080 }
6081
6082 ObjCKindOfAttr *clone(ASTContext &C) const;
6083 void printPretty(raw_ostream &OS,
6084 const PrintingPolicy &Policy) const;
6085 const char *getSpelling() const;
6086
6087
6088 static bool classof(const Attr *A) { return A->getKind() == attr::ObjCKindOf; }
6089};
6090
6091class ObjCMethodFamilyAttr : public InheritableAttr {
6092public:
6093 enum FamilyKind {
6094 OMF_None,
6095 OMF_alloc,
6096 OMF_copy,
6097 OMF_init,
6098 OMF_mutableCopy,
6099 OMF_new
6100 };
6101private:
6102 FamilyKind family;
6103
6104public:
6105 static ObjCMethodFamilyAttr *CreateImplicit(ASTContext &Ctx, FamilyKind Family, SourceRange Loc = SourceRange()) {
6106 auto *A = new (Ctx) ObjCMethodFamilyAttr(Loc, Ctx, Family, 0);
6107 A->setImplicit(true);
6108 return A;
6109 }
6110
6111 ObjCMethodFamilyAttr(SourceRange R, ASTContext &Ctx
6112 , FamilyKind Family
6113 , unsigned SI
6114 )
6115 : InheritableAttr(attr::ObjCMethodFamily, R, SI, false, false)
6116 , family(Family)
6117 {
6118 }
6119
6120 ObjCMethodFamilyAttr *clone(ASTContext &C) const;
6121 void printPretty(raw_ostream &OS,
6122 const PrintingPolicy &Policy) const;
6123 const char *getSpelling() const;
6124 FamilyKind getFamily() const {
6125 return family;
6126 }
6127
6128 static bool ConvertStrToFamilyKind(StringRef Val, FamilyKind &Out) {
6129 Optional<FamilyKind> R = llvm::StringSwitch<Optional<FamilyKind>>(Val)
6130 .Case("none", ObjCMethodFamilyAttr::OMF_None)
6131 .Case("alloc", ObjCMethodFamilyAttr::OMF_alloc)
6132 .Case("copy", ObjCMethodFamilyAttr::OMF_copy)
6133 .Case("init", ObjCMethodFamilyAttr::OMF_init)
6134 .Case("mutableCopy", ObjCMethodFamilyAttr::OMF_mutableCopy)
6135 .Case("new", ObjCMethodFamilyAttr::OMF_new)
6136 .Default(Optional<FamilyKind>());
6137 if (R) {
6138 Out = *R;
6139 return true;
6140 }
6141 return false;
6142 }
6143
6144 static const char *ConvertFamilyKindToStr(FamilyKind Val) {
6145 switch(Val) {
6146 case ObjCMethodFamilyAttr::OMF_None: return "none";
6147 case ObjCMethodFamilyAttr::OMF_alloc: return "alloc";
6148 case ObjCMethodFamilyAttr::OMF_copy: return "copy";
6149 case ObjCMethodFamilyAttr::OMF_init: return "init";
6150 case ObjCMethodFamilyAttr::OMF_mutableCopy: return "mutableCopy";
6151 case ObjCMethodFamilyAttr::OMF_new: return "new";
6152 }
6153 llvm_unreachable("No enumerator with that value")::llvm::llvm_unreachable_internal("No enumerator with that value"
, "/build/llvm-toolchain-snapshot-8~svn345461/build-llvm/tools/lldb/../clang/include/clang/AST/Attrs.inc"
, 6153)
;
6154 }
6155
6156
6157 static bool classof(const Attr *A) { return A->getKind() == attr::ObjCMethodFamily; }
6158};
6159
6160class ObjCNSObjectAttr : public InheritableAttr {
6161public:
6162 static ObjCNSObjectAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
6163 auto *A = new (Ctx) ObjCNSObjectAttr(Loc, Ctx, 0);
6164 A->setImplicit(true);
6165 return A;
6166 }
6167
6168 ObjCNSObjectAttr(SourceRange R, ASTContext &Ctx
6169 , unsigned SI
6170 )
6171 : InheritableAttr(attr::ObjCNSObject, R, SI, false, false)
6172 {
6173 }
6174
6175 ObjCNSObjectAttr *clone(ASTContext &C) const;
6176 void printPretty(raw_ostream &OS,
6177 const PrintingPolicy &Policy) const;
6178 const char *getSpelling() const;
6179
6180
6181 static bool classof(const Attr *A) { return A->getKind() == attr::ObjCNSObject; }
6182};
6183
6184class ObjCOwnershipAttr : public InheritableAttr {
6185IdentifierInfo * kind;
6186
6187public:
6188 static ObjCOwnershipAttr *CreateImplicit(ASTContext &Ctx, IdentifierInfo * Kind, SourceRange Loc = SourceRange()) {
6189 auto *A = new (Ctx) ObjCOwnershipAttr(Loc, Ctx, Kind, 0);
6190 A->setImplicit(true);
6191 return A;
6192 }
6193
6194 ObjCOwnershipAttr(SourceRange R, ASTContext &Ctx
6195 , IdentifierInfo * Kind
6196 , unsigned SI
6197 )
6198 : InheritableAttr(attr::ObjCOwnership, R, SI, false, false)
6199 , kind(Kind)
6200 {
6201 }
6202
6203 ObjCOwnershipAttr *clone(ASTContext &C) const;
6204 void printPretty(raw_ostream &OS,
6205 const PrintingPolicy &Policy) const;
6206 const char *getSpelling() const;
6207 IdentifierInfo * getKind() const {
6208 return kind;
6209 }
6210
6211
6212
6213 static bool classof(const Attr *A) { return A->getKind() == attr::ObjCOwnership; }
6214};
6215
6216class ObjCPreciseLifetimeAttr : public InheritableAttr {
6217public:
6218 static ObjCPreciseLifetimeAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
6219 auto *A = new (Ctx) ObjCPreciseLifetimeAttr(Loc, Ctx, 0);
6220 A->setImplicit(true);
6221 return A;
6222 }
6223
6224 ObjCPreciseLifetimeAttr(SourceRange R, ASTContext &Ctx
6225 , unsigned SI
6226 )
6227 : InheritableAttr(attr::ObjCPreciseLifetime, R, SI, false, false)
6228 {
6229 }
6230
6231 ObjCPreciseLifetimeAttr *clone(ASTContext &C) const;
6232 void printPretty(raw_ostream &OS,
6233 const PrintingPolicy &Policy) const;
6234 const char *getSpelling() const;
6235
6236
6237 static bool classof(const Attr *A) { return A->getKind() == attr::ObjCPreciseLifetime; }
6238};
6239
6240class ObjCRequiresPropertyDefsAttr : public InheritableAttr {
6241public:
6242 static ObjCRequiresPropertyDefsAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
6243 auto *A = new (Ctx) ObjCRequiresPropertyDefsAttr(Loc, Ctx, 0);
6244 A->setImplicit(true);
6245 return A;
6246 }
6247
6248 ObjCRequiresPropertyDefsAttr(SourceRange R, ASTContext &Ctx
6249 , unsigned SI
6250 )
6251 : InheritableAttr(attr::ObjCRequiresPropertyDefs, R, SI, false, false)
6252 {
6253 }
6254
6255 ObjCRequiresPropertyDefsAttr *clone(ASTContext &C) const;
6256 void printPretty(raw_ostream &OS,
6257 const PrintingPolicy &Policy) const;
6258 const char *getSpelling() const;
6259
6260
6261 static bool classof(const Attr *A) { return A->getKind() == attr::ObjCRequiresPropertyDefs; }
6262};
6263
6264class ObjCRequiresSuperAttr : public InheritableAttr {
6265public:
6266 static ObjCRequiresSuperAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
6267 auto *A = new (Ctx) ObjCRequiresSuperAttr(Loc, Ctx, 0);
6268 A->setImplicit(true);
6269 return A;
6270 }
6271
6272 ObjCRequiresSuperAttr(SourceRange R, ASTContext &Ctx
6273 , unsigned SI
6274 )
6275 : InheritableAttr(attr::ObjCRequiresSuper, R, SI, false, false)
6276 {
6277 }
6278
6279 ObjCRequiresSuperAttr *clone(ASTContext &C) const;
6280 void printPretty(raw_ostream &OS,
6281 const PrintingPolicy &Policy) const;
6282 const char *getSpelling() const;
6283
6284
6285 static bool classof(const Attr *A) { return A->getKind() == attr::ObjCRequiresSuper; }
6286};
6287
6288class ObjCReturnsInnerPointerAttr : public InheritableAttr {
6289public:
6290 static ObjCReturnsInnerPointerAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
6291 auto *A = new (Ctx) ObjCReturnsInnerPointerAttr(Loc, Ctx, 0);
6292 A->setImplicit(true);
6293 return A;
6294 }
6295
6296 ObjCReturnsInnerPointerAttr(SourceRange R, ASTContext &Ctx
6297 , unsigned SI
6298 )
6299 : InheritableAttr(attr::ObjCReturnsInnerPointer, R, SI, false, false)
6300 {
6301 }
6302
6303 ObjCReturnsInnerPointerAttr *clone(ASTContext &C) const;
6304 void printPretty(raw_ostream &OS,
6305 const PrintingPolicy &Policy) const;
6306 const char *getSpelling() const;
6307
6308
6309 static bool classof(const Attr *A) { return A->getKind() == attr::ObjCReturnsInnerPointer; }
6310};
6311
6312class ObjCRootClassAttr : public InheritableAttr {
6313public:
6314 static ObjCRootClassAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
6315 auto *A = new (Ctx) ObjCRootClassAttr(Loc, Ctx, 0);
6316 A->setImplicit(true);
6317 return A;
6318 }
6319
6320 ObjCRootClassAttr(SourceRange R, ASTContext &Ctx
6321 , unsigned SI
6322 )
6323 : InheritableAttr(attr::ObjCRootClass, R, SI, false, false)
6324 {
6325 }
6326
6327 ObjCRootClassAttr *clone(ASTContext &C) const;
6328 void printPretty(raw_ostream &OS,
6329 const PrintingPolicy &Policy) const;
6330 const char *getSpelling() const;
6331
6332
6333 static bool classof(const Attr *A) { return A->getKind() == attr::ObjCRootClass; }
6334};
6335
6336class ObjCRuntimeNameAttr : public Attr {
6337unsigned metadataNameLength;
6338char *metadataName;
6339
6340public:
6341 static ObjCRuntimeNameAttr *CreateImplicit(ASTContext &Ctx, llvm::StringRef MetadataName, SourceRange Loc = SourceRange()) {
6342 auto *A = new (Ctx) ObjCRuntimeNameAttr(Loc, Ctx, MetadataName, 0);
6343 A->setImplicit(true);
6344 return A;
6345 }
6346
6347 ObjCRuntimeNameAttr(SourceRange R, ASTContext &Ctx
6348 , llvm::StringRef MetadataName
6349 , unsigned SI
6350 )
6351 : Attr(attr::ObjCRuntimeName, R, SI, false)
6352 , metadataNameLength(MetadataName.size()),metadataName(new (Ctx, 1) char[metadataNameLength])
6353 {
6354 if (!MetadataName.empty())
6355 std::memcpy(metadataName, MetadataName.data(), metadataNameLength);
6356 }
6357
6358 ObjCRuntimeNameAttr *clone(ASTContext &C) const;
6359 void printPretty(raw_ostream &OS,
6360 const PrintingPolicy &Policy) const;
6361 const char *getSpelling() const;
6362 llvm::StringRef getMetadataName() const {
6363 return llvm::StringRef(metadataName, metadataNameLength);
6364 }
6365 unsigned getMetadataNameLength() const {
6366 return metadataNameLength;
6367 }
6368 void setMetadataName(ASTContext &C, llvm::StringRef S) {
6369 metadataNameLength = S.size();
6370 this->metadataName = new (C, 1) char [metadataNameLength];
6371 if (!S.empty())
6372 std::memcpy(this->metadataName, S.data(), metadataNameLength);
6373 }
6374
6375
6376
6377 static bool classof(const Attr *A) { return A->getKind() == attr::ObjCRuntimeName; }
6378};
6379
6380class ObjCRuntimeVisibleAttr : public Attr {
6381public:
6382 static ObjCRuntimeVisibleAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
6383 auto *A = new (Ctx) ObjCRuntimeVisibleAttr(Loc, Ctx, 0);
6384 A->setImplicit(true);
6385 return A;
6386 }
6387
6388 ObjCRuntimeVisibleAttr(SourceRange R, ASTContext &Ctx
6389 , unsigned SI
6390 )
6391 : Attr(attr::ObjCRuntimeVisible, R, SI, false)
6392 {
6393 }
6394
6395 ObjCRuntimeVisibleAttr *clone(ASTContext &C) const;
6396 void printPretty(raw_ostream &OS,
6397 const PrintingPolicy &Policy) const;
6398 const char *getSpelling() const;
6399
6400
6401 static bool classof(const Attr *A) { return A->getKind() == attr::ObjCRuntimeVisible; }
6402};
6403
6404class ObjCSubclassingRestrictedAttr : public InheritableAttr {
6405public:
6406 static ObjCSubclassingRestrictedAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
6407 auto *A = new (Ctx) ObjCSubclassingRestrictedAttr(Loc, Ctx, 0);
6408 A->setImplicit(true);
6409 return A;
6410 }
6411
6412 ObjCSubclassingRestrictedAttr(SourceRange R, ASTContext &Ctx
6413 , unsigned SI
6414 )
6415 : InheritableAttr(attr::ObjCSubclassingRestricted, R, SI, false, false)
6416 {
6417 }
6418
6419 ObjCSubclassingRestrictedAttr *clone(ASTContext &C) const;
6420 void printPretty(raw_ostream &OS,
6421 const PrintingPolicy &Policy) const;
6422 const char *getSpelling() const;
6423
6424
6425 static bool classof(const Attr *A) { return A->getKind() == attr::ObjCSubclassingRestricted; }
6426};
6427
6428class OpenCLAccessAttr : public Attr {
6429public:
6430 enum Spelling {
6431 Keyword_read_only = 0,
6432 Keyword_write_only = 2,
6433 Keyword_read_write = 4
6434 };
6435
6436 static OpenCLAccessAttr *CreateImplicit(ASTContext &Ctx, Spelling S, SourceRange Loc = SourceRange()) {
6437 auto *A = new (Ctx) OpenCLAccessAttr(Loc, Ctx, S);
6438 A->setImplicit(true);
6439 return A;
6440 }
6441
6442 OpenCLAccessAttr(SourceRange R, ASTContext &Ctx
6443 , unsigned SI
6444 )
6445 : Attr(attr::OpenCLAccess, R, SI, false)
6446 {
6447 }
6448
6449 OpenCLAccessAttr *clone(ASTContext &C) const;
6450 void printPretty(raw_ostream &OS,
6451 const PrintingPolicy &Policy) const;
6452 const char *getSpelling() const;
6453 Spelling getSemanticSpelling() const {
6454 switch (SpellingListIndex) {
6455 default: llvm_unreachable("Unknown spelling list index")::llvm::llvm_unreachable_internal("Unknown spelling list index"
, "/build/llvm-toolchain-snapshot-8~svn345461/build-llvm/tools/lldb/../clang/include/clang/AST/Attrs.inc"
, 6455)
;
6456 case 0: return Keyword_read_only;
6457 case 1: return Keyword_read_only;
6458 case 2: return Keyword_write_only;
6459 case 3: return Keyword_write_only;
6460 case 4: return Keyword_read_write;
6461 case 5: return Keyword_read_write;
6462 }
6463 }
6464 bool isReadOnly() const { return SpellingListIndex == 0 ||
6465 SpellingListIndex == 1; }
6466 bool isReadWrite() const { return SpellingListIndex == 4 ||
6467 SpellingListIndex == 5; }
6468 bool isWriteOnly() const { return SpellingListIndex == 2 ||
6469 SpellingListIndex == 3; }
6470
6471
6472 static bool classof(const Attr *A) { return A->getKind() == attr::OpenCLAccess; }
6473};
6474
6475class OpenCLConstantAddressSpaceAttr : public TypeAttr {
6476public:
6477 static OpenCLConstantAddressSpaceAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
6478 auto *A = new (Ctx) OpenCLConstantAddressSpaceAttr(Loc, Ctx, 0);
6479 A->setImplicit(true);
6480 return A;
6481 }
6482
6483 OpenCLConstantAddressSpaceAttr(SourceRange R, ASTContext &Ctx
6484 , unsigned SI
6485 )
6486 : TypeAttr(attr::OpenCLConstantAddressSpace, R, SI, false)
6487 {
6488 }
6489
6490 OpenCLConstantAddressSpaceAttr *clone(ASTContext &C) const;
6491 void printPretty(raw_ostream &OS,
6492 const PrintingPolicy &Policy) const;
6493 const char *getSpelling() const;
6494
6495
6496 static bool classof(const Attr *A) { return A->getKind() == attr::OpenCLConstantAddressSpace; }
6497};
6498
6499class OpenCLGenericAddressSpaceAttr : public TypeAttr {
6500public:
6501 static OpenCLGenericAddressSpaceAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
6502 auto *A = new (Ctx) OpenCLGenericAddressSpaceAttr(Loc, Ctx, 0);
6503 A->setImplicit(true);
6504 return A;
6505 }
6506
6507 OpenCLGenericAddressSpaceAttr(SourceRange R, ASTContext &Ctx
6508 , unsigned SI
6509 )
6510 : TypeAttr(attr::OpenCLGenericAddressSpace, R, SI, false)
6511 {
6512 }
6513
6514 OpenCLGenericAddressSpaceAttr *clone(ASTContext &C) const;
6515 void printPretty(raw_ostream &OS,
6516 const PrintingPolicy &Policy) const;
6517 const char *getSpelling() const;
6518
6519
6520 static bool classof(const Attr *A) { return A->getKind() == attr::OpenCLGenericAddressSpace; }
6521};
6522
6523class OpenCLGlobalAddressSpaceAttr : public TypeAttr {
6524public:
6525 static OpenCLGlobalAddressSpaceAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
6526 auto *A = new (Ctx) OpenCLGlobalAddressSpaceAttr(Loc, Ctx, 0);
6527 A->setImplicit(true);
6528 return A;
6529 }
6530
6531 OpenCLGlobalAddressSpaceAttr(SourceRange R, ASTContext &Ctx
6532 , unsigned SI
6533 )
6534 : TypeAttr(attr::OpenCLGlobalAddressSpace, R, SI, false)
6535 {
6536 }
6537
6538 OpenCLGlobalAddressSpaceAttr *clone(ASTContext &C) const;
6539 void printPretty(raw_ostream &OS,
6540 const PrintingPolicy &Policy) const;
6541 const char *getSpelling() const;
6542
6543
6544 static bool classof(const Attr *A) { return A->getKind() == attr::OpenCLGlobalAddressSpace; }
6545};
6546
6547class OpenCLIntelReqdSubGroupSizeAttr : public InheritableAttr {
6548unsigned subGroupSize;
6549
6550public:
6551 static OpenCLIntelReqdSubGroupSizeAttr *CreateImplicit(ASTContext &Ctx, unsigned SubGroupSize, SourceRange Loc = SourceRange()) {
6552 auto *A = new (Ctx) OpenCLIntelReqdSubGroupSizeAttr(Loc, Ctx, SubGroupSize, 0);
6553 A->setImplicit(true);
6554 return A;
6555 }
6556
6557 OpenCLIntelReqdSubGroupSizeAttr(SourceRange R, ASTContext &Ctx
6558 , unsigned SubGroupSize
6559 , unsigned SI
6560 )
6561 : InheritableAttr(attr::OpenCLIntelReqdSubGroupSize, R, SI, false, false)
6562 , subGroupSize(SubGroupSize)
6563 {
6564 }
6565
6566 OpenCLIntelReqdSubGroupSizeAttr *clone(ASTContext &C) const;
6567 void printPretty(raw_ostream &OS,
6568 const PrintingPolicy &Policy) const;
6569 const char *getSpelling() const;
6570 unsigned getSubGroupSize() const {
6571 return subGroupSize;
6572 }
6573
6574
6575
6576 static bool classof(const Attr *A) { return A->getKind() == attr::OpenCLIntelReqdSubGroupSize; }
6577};
6578
6579class OpenCLKernelAttr : public InheritableAttr {
6580public:
6581 static OpenCLKernelAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
6582 auto *A = new (Ctx) OpenCLKernelAttr(Loc, Ctx, 0);
6583 A->setImplicit(true);
6584 return A;
6585 }
6586
6587 OpenCLKernelAttr(SourceRange R, ASTContext &Ctx
6588 , unsigned SI
6589 )
6590 : InheritableAttr(attr::OpenCLKernel, R, SI, false, false)
6591 {
6592 }
6593
6594 OpenCLKernelAttr *clone(ASTContext &C) const;
6595 void printPretty(raw_ostream &OS,
6596 const PrintingPolicy &Policy) const;
6597 const char *getSpelling() const;
6598
6599
6600 static bool classof(const Attr *A) { return A->getKind() == attr::OpenCLKernel; }
6601};
6602
6603class OpenCLLocalAddressSpaceAttr : public TypeAttr {
6604public:
6605 static OpenCLLocalAddressSpaceAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
6606 auto *A = new (Ctx) OpenCLLocalAddressSpaceAttr(Loc, Ctx, 0);
6607 A->setImplicit(true);
6608 return A;
6609 }
6610
6611 OpenCLLocalAddressSpaceAttr(SourceRange R, ASTContext &Ctx
6612 , unsigned SI
6613 )
6614 : TypeAttr(attr::OpenCLLocalAddressSpace, R, SI, false)
6615 {
6616 }
6617
6618 OpenCLLocalAddressSpaceAttr *clone(ASTContext &C) const;
6619 void printPretty(raw_ostream &OS,
6620 const PrintingPolicy &Policy) const;
6621 const char *getSpelling() const;
6622
6623
6624 static bool classof(const Attr *A) { return A->getKind() == attr::OpenCLLocalAddressSpace; }
6625};
6626
6627class OpenCLPrivateAddressSpaceAttr : public TypeAttr {
6628public:
6629 static OpenCLPrivateAddressSpaceAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
6630 auto *A = new (Ctx) OpenCLPrivateAddressSpaceAttr(Loc, Ctx, 0);
6631 A->setImplicit(true);
6632 return A;
6633 }
6634
6635 OpenCLPrivateAddressSpaceAttr(SourceRange R, ASTContext &Ctx
6636 , unsigned SI
6637 )
6638 : TypeAttr(attr::OpenCLPrivateAddressSpace, R, SI, false)
6639 {
6640 }
6641
6642 OpenCLPrivateAddressSpaceAttr *clone(ASTContext &C) const;
6643 void printPretty(raw_ostream &OS,
6644 const PrintingPolicy &Policy) const;
6645 const char *getSpelling() const;
6646
6647
6648 static bool classof(const Attr *A) { return A->getKind() == attr::OpenCLPrivateAddressSpace; }
6649};
6650
6651class OpenCLUnrollHintAttr : public InheritableAttr {
6652unsigned unrollHint;
6653
6654public:
6655 static OpenCLUnrollHintAttr *CreateImplicit(ASTContext &Ctx, unsigned UnrollHint, SourceRange Loc = SourceRange()) {
6656 auto *A = new (Ctx) OpenCLUnrollHintAttr(Loc, Ctx, UnrollHint, 0);
6657 A->setImplicit(true);
6658 return A;
6659 }
6660
6661 OpenCLUnrollHintAttr(SourceRange R, ASTContext &Ctx
6662 , unsigned UnrollHint
6663 , unsigned SI
6664 )
6665 : InheritableAttr(attr::OpenCLUnrollHint, R, SI, false, false)
6666 , unrollHint(UnrollHint)
6667 {
6668 }
6669
6670 OpenCLUnrollHintAttr *clone(ASTContext &C) const;
6671 void printPretty(raw_ostream &OS,
6672 const PrintingPolicy &Policy) const;
6673 const char *getSpelling() const;
6674 unsigned getUnrollHint() const {
6675 return unrollHint;
6676 }
6677
6678
6679
6680 static bool classof(const Attr *A) { return A->getKind() == attr::OpenCLUnrollHint; }
6681};
6682
6683class OptimizeNoneAttr : public InheritableAttr {
6684public:
6685 static OptimizeNoneAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
6686 auto *A = new (Ctx) OptimizeNoneAttr(Loc, Ctx, 0);
6687 A->setImplicit(true);
6688 return A;
6689 }
6690
6691 OptimizeNoneAttr(SourceRange R, ASTContext &Ctx
6692 , unsigned SI
6693 )
6694 : InheritableAttr(attr::OptimizeNone, R, SI, false, false)
6695 {
6696 }
6697
6698 OptimizeNoneAttr *clone(ASTContext &C) const;
6699 void printPretty(raw_ostream &OS,
6700 const PrintingPolicy &Policy) const;
6701 const char *getSpelling() const;
6702
6703
6704 static bool classof(const Attr *A) { return A->getKind() == attr::OptimizeNone; }
6705};
6706
6707class OverloadableAttr : public Attr {
6708public:
6709 static OverloadableAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
6710 auto *A = new (Ctx) OverloadableAttr(Loc, Ctx, 0);
6711 A->setImplicit(true);
6712 return A;
6713 }
6714
6715 OverloadableAttr(SourceRange R, ASTContext &Ctx
6716 , unsigned SI
6717 )
6718 : Attr(attr::Overloadable, R, SI, false)
6719 {
6720 }
6721
6722 OverloadableAttr *clone(ASTContext &C) const;
6723 void printPretty(raw_ostream &OS,
6724 const PrintingPolicy &Policy) const;
6725 const char *getSpelling() const;
6726
6727
6728 static bool classof(const Attr *A) { return A->getKind() == attr::Overloadable; }
6729};
6730
6731class OverrideAttr : public InheritableAttr {
6732public:
6733 static OverrideAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
6734 auto *A = new (Ctx) OverrideAttr(Loc, Ctx, 0);
6735 A->setImplicit(true);
6736 return A;
6737 }
6738
6739 OverrideAttr(SourceRange R, ASTContext &Ctx
6740 , unsigned SI
6741 )
6742 : InheritableAttr(attr::Override, R, SI, false, false)
6743 {
6744 }
6745
6746 OverrideAttr *clone(ASTContext &C) const;
6747 void printPretty(raw_ostream &OS,
6748 const PrintingPolicy &Policy) const;
6749 const char *getSpelling() const;
6750
6751
6752 static bool classof(const Attr *A) { return A->getKind() == attr::Override; }
6753};
6754
6755class OwnershipAttr : public InheritableAttr {
6756IdentifierInfo * module;
6757
6758 unsigned args_Size;
6759 ParamIdx *args_;
6760
6761public:
6762 enum Spelling {
6763 GNU_ownership_holds = 0,
6764 CXX11_clang_ownership_holds = 1,
6765 C2x_clang_ownership_holds = 2,
6766 GNU_ownership_returns = 3,
6767 CXX11_clang_ownership_returns = 4,
6768 C2x_clang_ownership_returns = 5,
6769 GNU_ownership_takes = 6,
6770 CXX11_clang_ownership_takes = 7,
6771 C2x_clang_ownership_takes = 8
6772 };
6773
6774 static OwnershipAttr *CreateImplicit(ASTContext &Ctx, Spelling S, IdentifierInfo * Module, ParamIdx *Args, unsigned ArgsSize, SourceRange Loc = SourceRange()) {
6775 auto *A = new (Ctx) OwnershipAttr(Loc, Ctx, Module, Args, ArgsSize, S);
6776 A->setImplicit(true);
6777 return A;
6778 }
6779
6780 OwnershipAttr(SourceRange R, ASTContext &Ctx
6781 , IdentifierInfo * Module
6782 , ParamIdx *Args, unsigned ArgsSize
6783 , unsigned SI
6784 )
6785 : InheritableAttr(attr::Ownership, R, SI, false, false)
6786 , module(Module)
6787 , args_Size(ArgsSize), args_(new (Ctx, 16) ParamIdx[args_Size])
6788 {
6789 std::copy(Args, Args + args_Size, args_);
6790 }
6791
6792 OwnershipAttr(SourceRange R, ASTContext &Ctx
6793 , IdentifierInfo * Module
6794 , unsigned SI
6795 )
6796 : InheritableAttr(attr::Ownership, R, SI, false, false)
6797 , module(Module)
6798 , args_Size(0), args_(nullptr)
6799 {
6800 }
6801
6802 OwnershipAttr *clone(ASTContext &C) const;
6803 void printPretty(raw_ostream &OS,
6804 const PrintingPolicy &Policy) const;
6805 const char *getSpelling() const;
6806 Spelling getSemanticSpelling() const {
6807 switch (SpellingListIndex) {
6808 default: llvm_unreachable("Unknown spelling list index")::llvm::llvm_unreachable_internal("Unknown spelling list index"
, "/build/llvm-toolchain-snapshot-8~svn345461/build-llvm/tools/lldb/../clang/include/clang/AST/Attrs.inc"
, 6808)
;
6809 case 0: return GNU_ownership_holds;
6810 case 1: return CXX11_clang_ownership_holds;
6811 case 2: return C2x_clang_ownership_holds;
6812 case 3: return GNU_ownership_returns;
6813 case 4: return CXX11_clang_ownership_returns;
6814 case 5: return C2x_clang_ownership_returns;
6815 case 6: return GNU_ownership_takes;
6816 case 7: return CXX11_clang_ownership_takes;
6817 case 8: return C2x_clang_ownership_takes;
6818 }
6819 }
6820 bool isHolds() const { return SpellingListIndex == 0 ||
6821 SpellingListIndex == 1 ||
6822 SpellingListIndex == 2; }
6823 bool isReturns() const { return SpellingListIndex == 3 ||
6824 SpellingListIndex == 4 ||
6825 SpellingListIndex == 5; }
6826 bool isTakes() const { return SpellingListIndex == 6 ||
6827 SpellingListIndex == 7 ||
6828 SpellingListIndex == 8; }
6829 IdentifierInfo * getModule() const {
6830 return module;
6831 }
6832
6833 typedef ParamIdx* args_iterator;
6834 args_iterator args_begin() const { return args_; }
6835 args_iterator args_end() const { return args_ + args_Size; }
6836 unsigned args_size() const { return args_Size; }
6837 llvm::iterator_range<args_iterator> args() const { return llvm::make_range(args_begin(), args_end()); }
6838
6839
6840
6841 enum OwnershipKind { Holds, Returns, Takes };
6842 OwnershipKind getOwnKind() const {
6843 return isHolds() ? Holds :
6844 isTakes() ? Takes :
6845 Returns;
6846 }
6847
6848
6849 static bool classof(const Attr *A) { return A->getKind() == attr::Ownership; }
6850};
6851
6852class PackedAttr : public InheritableAttr {
6853public:
6854 static PackedAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
6855 auto *A = new (Ctx) PackedAttr(Loc, Ctx, 0);
6856 A->setImplicit(true);
6857 return A;
6858 }
6859
6860 PackedAttr(SourceRange R, ASTContext &Ctx
6861 , unsigned SI
6862 )
6863 : InheritableAttr(attr::Packed, R, SI, false, false)
6864 {
6865 }
6866
6867 PackedAttr *clone(ASTContext &C) const;
6868 void printPretty(raw_ostream &OS,
6869 const PrintingPolicy &Policy) const;
6870 const char *getSpelling() const;
6871
6872
6873 static bool classof(const Attr *A) { return A->getKind() == attr::Packed; }
6874};
6875
6876class ParamTypestateAttr : public InheritableAttr {
6877public:
6878 enum ConsumedState {
6879 Unknown,
6880 Consumed,
6881 Unconsumed
6882 };
6883private:
6884 ConsumedState paramState;
6885
6886public:
6887 static ParamTypestateAttr *CreateImplicit(ASTContext &Ctx, ConsumedState ParamState, SourceRange Loc = SourceRange()) {
6888 auto *A = new (Ctx) ParamTypestateAttr(Loc, Ctx, ParamState, 0);
6889 A->setImplicit(true);
6890 return A;
6891 }
6892
6893 ParamTypestateAttr(SourceRange R, ASTContext &Ctx
6894 , ConsumedState ParamState
6895 , unsigned SI
6896 )
6897 : InheritableAttr(attr::ParamTypestate, R, SI, false, false)
6898 , paramState(ParamState)
6899 {
6900 }
6901
6902 ParamTypestateAttr *clone(ASTContext &C) const;
6903 void printPretty(raw_ostream &OS,
6904 const PrintingPolicy &Policy) const;
6905 const char *getSpelling() const;
6906 ConsumedState getParamState() const {
6907 return paramState;
6908 }
6909
6910 static bool ConvertStrToConsumedState(StringRef Val, ConsumedState &Out) {
6911 Optional<ConsumedState> R = llvm::StringSwitch<Optional<ConsumedState>>(Val)
6912 .Case("unknown", ParamTypestateAttr::Unknown)
6913 .Case("consumed", ParamTypestateAttr::Consumed)
6914 .Case("unconsumed", ParamTypestateAttr::Unconsumed)
6915 .Default(Optional<ConsumedState>());
6916 if (R) {
6917 Out = *R;
6918 return true;
6919 }
6920 return false;
6921 }
6922
6923 static const char *ConvertConsumedStateToStr(ConsumedState Val) {
6924 switch(Val) {
6925 case ParamTypestateAttr::Unknown: return "unknown";
6926 case ParamTypestateAttr::Consumed: return "consumed";
6927 case ParamTypestateAttr::Unconsumed: return "unconsumed";
6928 }
6929 llvm_unreachable("No enumerator with that value")::llvm::llvm_unreachable_internal("No enumerator with that value"
, "/build/llvm-toolchain-snapshot-8~svn345461/build-llvm/tools/lldb/../clang/include/clang/AST/Attrs.inc"
, 6929)
;
6930 }
6931
6932
6933 static bool classof(const Attr *A) { return A->getKind() == attr::ParamTypestate; }
6934};
6935
6936class PascalAttr : public InheritableAttr {
6937public:
6938 static PascalAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
6939 auto *A = new (Ctx) PascalAttr(Loc, Ctx, 0);
6940 A->setImplicit(true);
6941 return A;
6942 }
6943
6944 PascalAttr(SourceRange R, ASTContext &Ctx
6945 , unsigned SI
6946 )
6947 : InheritableAttr(attr::Pascal, R, SI, false, false)
6948 {
6949 }
6950
6951 PascalAttr *clone(ASTContext &C) const;
6952 void printPretty(raw_ostream &OS,
6953 const PrintingPolicy &Policy) const;
6954 const char *getSpelling() const;
6955
6956
6957 static bool classof(const Attr *A) { return A->getKind() == attr::Pascal; }
6958};
6959
6960class PassObjectSizeAttr : public InheritableParamAttr {
6961int type;
6962
6963public:
6964 static PassObjectSizeAttr *CreateImplicit(ASTContext &Ctx, int Type, SourceRange Loc = SourceRange()) {
6965 auto *A = new (Ctx) PassObjectSizeAttr(Loc, Ctx, Type, 0);
6966 A->setImplicit(true);
6967 return A;
6968 }
6969
6970 PassObjectSizeAttr(SourceRange R, ASTContext &Ctx
6971 , int Type
6972 , unsigned SI
6973 )
6974 : InheritableParamAttr(attr::PassObjectSize, R, SI, false, false)
6975 , type(Type)
6976 {
6977 }
6978
6979 PassObjectSizeAttr *clone(ASTContext &C) const;
6980 void printPretty(raw_ostream &OS,
6981 const PrintingPolicy &Policy) const;
6982 const char *getSpelling() const;
6983 int getType() const {
6984 return type;
6985 }
6986
6987
6988
6989 static bool classof(const Attr *A) { return A->getKind() == attr::PassObjectSize; }
6990};
6991
6992class PcsAttr : public InheritableAttr {
6993public:
6994 enum PCSType {
6995 AAPCS,
6996 AAPCS_VFP
6997 };
6998private:
6999 PCSType pCS;
7000
7001public:
7002 static PcsAttr *CreateImplicit(ASTContext &Ctx, PCSType PCS, SourceRange Loc = SourceRange()) {
7003 auto *A = new (Ctx) PcsAttr(Loc, Ctx, PCS, 0);
7004 A->setImplicit(true);
7005 return A;
7006 }
7007
7008 PcsAttr(SourceRange R, ASTContext &Ctx
7009 , PCSType PCS
7010 , unsigned SI
7011 )
7012 : InheritableAttr(attr::Pcs, R, SI, false, false)
7013 , pCS(PCS)
7014 {
7015 }
7016
7017 PcsAttr *clone(ASTContext &C) const;
7018 void printPretty(raw_ostream &OS,
7019 const PrintingPolicy &Policy) const;
7020 const char *getSpelling() const;
7021 PCSType getPCS() const {
7022 return pCS;
7023 }
7024
7025 static bool ConvertStrToPCSType(StringRef Val, PCSType &Out) {
7026 Optional<PCSType> R = llvm::StringSwitch<Optional<PCSType>>(Val)
7027 .Case("aapcs", PcsAttr::AAPCS)
7028 .Case("aapcs-vfp", PcsAttr::AAPCS_VFP)
7029 .Default(Optional<PCSType>());
7030 if (R) {
7031 Out = *R;
7032 return true;
7033 }
7034 return false;
7035 }
7036
7037 static const char *ConvertPCSTypeToStr(PCSType Val) {
7038 switch(Val) {
7039 case PcsAttr::AAPCS: return "aapcs";
7040 case PcsAttr::AAPCS_VFP: return "aapcs-vfp";
7041 }
7042 llvm_unreachable("No enumerator with that value")::llvm::llvm_unreachable_internal("No enumerator with that value"
, "/build/llvm-toolchain-snapshot-8~svn345461/build-llvm/tools/lldb/../clang/include/clang/AST/Attrs.inc"
, 7042)
;
7043 }
7044
7045
7046 static bool classof(const Attr *A) { return A->getKind() == attr::Pcs; }
7047};
7048
7049class PragmaClangBSSSectionAttr : public InheritableAttr {
7050unsigned nameLength;
7051char *name;
7052
7053public:
7054 static PragmaClangBSSSectionAttr *CreateImplicit(ASTContext &Ctx, llvm::StringRef Name, SourceRange Loc = SourceRange()) {
7055 auto *A = new (Ctx) PragmaClangBSSSectionAttr(Loc, Ctx, Name, 0);
7056 A->setImplicit(true);
7057 return A;
7058 }
7059
7060 PragmaClangBSSSectionAttr(SourceRange R, ASTContext &Ctx
7061 , llvm::StringRef Name
7062 , unsigned SI
7063 )
7064 : InheritableAttr(attr::PragmaClangBSSSection, R, SI, false, false)
7065 , nameLength(Name.size()),name(new (Ctx, 1) char[nameLength])
7066 {
7067 if (!Name.empty())
7068 std::memcpy(name, Name.data(), nameLength);
7069 }
7070
7071 PragmaClangBSSSectionAttr *clone(ASTContext &C) const;
7072 void printPretty(raw_ostream &OS,
7073 const PrintingPolicy &Policy) const;
7074 const char *getSpelling() const;
7075 llvm::StringRef getName() const {
7076 return llvm::StringRef(name, nameLength);
7077 }
7078 unsigned getNameLength() const {
7079 return nameLength;
7080 }
7081 void setName(ASTContext &C, llvm::StringRef S) {
7082 nameLength = S.size();
7083 this->name = new (C, 1) char [nameLength];
7084 if (!S.empty())
7085 std::memcpy(this->name, S.data(), nameLength);
7086 }
7087
7088
7089
7090 static bool classof(const Attr *A) { return A->getKind() == attr::PragmaClangBSSSection; }
7091};
7092
7093class PragmaClangDataSectionAttr : public InheritableAttr {
7094unsigned nameLength;
7095char *name;
7096
7097public:
7098 static PragmaClangDataSectionAttr *CreateImplicit(ASTContext &Ctx, llvm::StringRef Name, SourceRange Loc = SourceRange()) {
7099 auto *A = new (Ctx) PragmaClangDataSectionAttr(Loc, Ctx, Name, 0);
7100 A->setImplicit(true);
7101 return A;
7102 }
7103
7104 PragmaClangDataSectionAttr(SourceRange R, ASTContext &Ctx
7105 , llvm::StringRef Name
7106 , unsigned SI
7107 )
7108 : InheritableAttr(attr::PragmaClangDataSection, R, SI, false, false)
7109 , nameLength(Name.size()),name(new (Ctx, 1) char[nameLength])
7110 {
7111 if (!Name.empty())
7112 std::memcpy(name, Name.data(), nameLength);
7113 }
7114
7115 PragmaClangDataSectionAttr *clone(ASTContext &C) const;
7116 void printPretty(raw_ostream &OS,
7117 const PrintingPolicy &Policy) const;
7118 const char *getSpelling() const;
7119 llvm::StringRef getName() const {
7120 return llvm::StringRef(name, nameLength);
7121 }
7122 unsigned getNameLength() const {
7123 return nameLength;
7124 }
7125 void setName(ASTContext &C, llvm::StringRef S) {
7126 nameLength = S.size();
7127 this->name = new (C, 1) char [nameLength];
7128 if (!S.empty())
7129 std::memcpy(this->name, S.data(), nameLength);
7130 }
7131
7132
7133
7134 static bool classof(const Attr *A) { return A->getKind() == attr::PragmaClangDataSection; }
7135};
7136
7137class PragmaClangRodataSectionAttr : public InheritableAttr {
7138unsigned nameLength;
7139char *name;
7140
7141public:
7142 static PragmaClangRodataSectionAttr *CreateImplicit(ASTContext &Ctx, llvm::StringRef Name, SourceRange Loc = SourceRange()) {
7143 auto *A = new (Ctx) PragmaClangRodataSectionAttr(Loc, Ctx, Name, 0);
7144 A->setImplicit(true);
7145 return A;
7146 }
7147
7148 PragmaClangRodataSectionAttr(SourceRange R, ASTContext &Ctx
7149 , llvm::StringRef Name
7150 , unsigned SI
7151 )
7152 : InheritableAttr(attr::PragmaClangRodataSection, R, SI, false, false)
7153 , nameLength(Name.size()),name(new (Ctx, 1) char[nameLength])
7154 {
7155 if (!Name.empty())
7156 std::memcpy(name, Name.data(), nameLength);
7157 }
7158
7159 PragmaClangRodataSectionAttr *clone(ASTContext &C) const;
7160 void printPretty(raw_ostream &OS,
7161 const PrintingPolicy &Policy) const;
7162 const char *getSpelling() const;
7163 llvm::StringRef getName() const {
7164 return llvm::StringRef(name, nameLength);
7165 }
7166 unsigned getNameLength() const {
7167 return nameLength;
7168 }
7169 void setName(ASTContext &C, llvm::StringRef S) {
7170 nameLength = S.size();
7171 this->name = new (C, 1) char [nameLength];
7172 if (!S.empty())
7173 std::memcpy(this->name, S.data(), nameLength);
7174 }
7175
7176
7177
7178 static bool classof(const Attr *A) { return A->getKind() == attr::PragmaClangRodataSection; }
7179};
7180
7181class PragmaClangTextSectionAttr : public InheritableAttr {
7182unsigned nameLength;
7183char *name;
7184
7185public:
7186 static PragmaClangTextSectionAttr *CreateImplicit(ASTContext &Ctx, llvm::StringRef Name, SourceRange Loc = SourceRange()) {
7187 auto *A = new (Ctx) PragmaClangTextSectionAttr(Loc, Ctx, Name, 0);
7188 A->setImplicit(true);
7189 return A;
7190 }
7191
7192 PragmaClangTextSectionAttr(SourceRange R, ASTContext &Ctx
7193 , llvm::StringRef Name
7194 , unsigned SI
7195 )
7196 : InheritableAttr(attr::PragmaClangTextSection, R, SI, false, false)
7197 , nameLength(Name.size()),name(new (Ctx, 1) char[nameLength])
7198 {
7199 if (!Name.empty())
7200 std::memcpy(name, Name.data(), nameLength);
7201 }
7202
7203 PragmaClangTextSectionAttr *clone(ASTContext &C) const;
7204 void printPretty(raw_ostream &OS,
7205 const PrintingPolicy &Policy) const;
7206 const char *getSpelling() const;
7207 llvm::StringRef getName() const {
7208 return llvm::StringRef(name, nameLength);
7209 }
7210 unsigned getNameLength() const {
7211 return nameLength;
7212 }
7213 void setName(ASTContext &C, llvm::StringRef S) {
7214 nameLength = S.size();
7215 this->name = new (C, 1) char [nameLength];
7216 if (!S.empty())
7217 std::memcpy(this->name, S.data(), nameLength);
7218 }
7219
7220
7221
7222 static bool classof(const Attr *A) { return A->getKind() == attr::PragmaClangTextSection; }
7223};
7224
7225class PreserveAllAttr : public InheritableAttr {
7226public:
7227 static PreserveAllAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
7228 auto *A = new (Ctx) PreserveAllAttr(Loc, Ctx, 0);
7229 A->setImplicit(true);
7230 return A;
7231 }
7232
7233 PreserveAllAttr(SourceRange R, ASTContext &Ctx
7234 , unsigned SI
7235 )
7236 : InheritableAttr(attr::PreserveAll, R, SI, false, false)
7237 {
7238 }
7239
7240 PreserveAllAttr *clone(ASTContext &C) const;
7241 void printPretty(raw_ostream &OS,
7242 const PrintingPolicy &Policy) const;
7243 const char *getSpelling() const;
7244
7245
7246 static bool classof(const Attr *A) { return A->getKind() == attr::PreserveAll; }
7247};
7248
7249class PreserveMostAttr : public InheritableAttr {
7250public:
7251 static PreserveMostAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
7252 auto *A = new (Ctx) PreserveMostAttr(Loc, Ctx, 0);
7253 A->setImplicit(true);
7254 return A;
7255 }
7256
7257 PreserveMostAttr(SourceRange R, ASTContext &Ctx
7258 , unsigned SI
7259 )
7260 : InheritableAttr(attr::PreserveMost, R, SI, false, false)
7261 {
7262 }
7263
7264 PreserveMostAttr *clone(ASTContext &C) const;
7265 void printPretty(raw_ostream &OS,
7266 const PrintingPolicy &Policy) const;
7267 const char *getSpelling() const;
7268
7269
7270 static bool classof(const Attr *A) { return A->getKind() == attr::PreserveMost; }
7271};
7272
7273class PtGuardedByAttr : public InheritableAttr {
7274Expr * arg;
7275
7276public:
7277 static PtGuardedByAttr *CreateImplicit(ASTContext &Ctx, Expr * Arg, SourceRange Loc = SourceRange()) {
7278 auto *A = new (Ctx) PtGuardedByAttr(Loc, Ctx, Arg, 0);
7279 A->setImplicit(true);
7280 return A;
7281 }
7282
7283 PtGuardedByAttr(SourceRange R, ASTContext &Ctx
7284 , Expr * Arg
7285 , unsigned SI
7286 )
7287 : InheritableAttr(attr::PtGuardedBy, R, SI, true, true)
7288 , arg(Arg)
7289 {
7290 }
7291
7292 PtGuardedByAttr *clone(ASTContext &C) const;
7293 void printPretty(raw_ostream &OS,
7294 const PrintingPolicy &Policy) const;
7295 const char *getSpelling() const;
7296 Expr * getArg() const {
7297 return arg;
7298 }
7299
7300
7301
7302 static bool classof(const Attr *A) { return A->getKind() == attr::PtGuardedBy; }
7303};
7304
7305class PtGuardedVarAttr : public InheritableAttr {
7306public:
7307 static PtGuardedVarAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
7308 auto *A = new (Ctx) PtGuardedVarAttr(Loc, Ctx, 0);
7309 A->setImplicit(true);
7310 return A;
7311 }
7312
7313 PtGuardedVarAttr(SourceRange R, ASTContext &Ctx
7314 , unsigned SI
7315 )
7316 : InheritableAttr(attr::PtGuardedVar, R, SI, false, false)
7317 {
7318 }
7319
7320 PtGuardedVarAttr *clone(ASTContext &C) const;
7321 void printPretty(raw_ostream &OS,
7322 const PrintingPolicy &Policy) const;
7323 const char *getSpelling() const;
7324
7325
7326 static bool classof(const Attr *A) { return A->getKind() == attr::PtGuardedVar; }
7327};
7328
7329class Ptr32Attr : public TypeAttr {
7330public:
7331 static Ptr32Attr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
7332 auto *A = new (Ctx) Ptr32Attr(Loc, Ctx, 0);
7333 A->setImplicit(true);
7334 return A;
7335 }
7336
7337 Ptr32Attr(SourceRange R, ASTContext &Ctx
7338 , unsigned SI
7339 )
7340 : TypeAttr(attr::Ptr32, R, SI, false)
7341 {
7342 }
7343
7344 Ptr32Attr *clone(ASTContext &C) const;
7345 void printPretty(raw_ostream &OS,
7346 const PrintingPolicy &Policy) const;
7347 const char *getSpelling() const;
7348
7349
7350 static bool classof(const Attr *A) { return A->getKind() == attr::Ptr32; }
7351};
7352
7353class Ptr64Attr : public TypeAttr {
7354public:
7355 static Ptr64Attr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
7356 auto *A = new (Ctx) Ptr64Attr(Loc, Ctx, 0);
7357 A->setImplicit(true);
7358 return A;
7359 }
7360
7361 Ptr64Attr(SourceRange R, ASTContext &Ctx
7362 , unsigned SI
7363 )
7364 : TypeAttr(attr::Ptr64, R, SI, false)
7365 {
7366 }
7367
7368 Ptr64Attr *clone(ASTContext &C) const;
7369 void printPretty(raw_ostream &OS,
7370 const PrintingPolicy &Policy) const;
7371 const char *getSpelling() const;
7372
7373
7374 static bool classof(const Attr *A) { return A->getKind() == attr::Ptr64; }
7375};
7376
7377class PureAttr : public InheritableAttr {
7378public:
7379 static PureAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
7380 auto *A = new (Ctx) PureAttr(Loc, Ctx, 0);
7381 A->setImplicit(true);
7382 return A;
7383 }
7384
7385 PureAttr(SourceRange R, ASTContext &Ctx
7386 , unsigned SI
7387 )
7388 : InheritableAttr(attr::Pure, R, SI, false, false)
7389 {
7390 }
7391
7392 PureAttr *clone(ASTContext &C) const;
7393 void printPretty(raw_ostream &OS,
7394 const PrintingPolicy &Policy) const;
7395 const char *getSpelling() const;
7396
7397
7398 static bool classof(const Attr *A) { return A->getKind() == attr::Pure; }
7399};
7400
7401class RISCVInterruptAttr : public InheritableAttr {
7402public:
7403 enum InterruptType {
7404 user,
7405 supervisor,
7406 machine
7407 };
7408private:
7409 InterruptType interrupt;
7410
7411public:
7412 static RISCVInterruptAttr *CreateImplicit(ASTContext &Ctx, InterruptType Interrupt, SourceRange Loc = SourceRange()) {
7413 auto *A = new (Ctx) RISCVInterruptAttr(Loc, Ctx, Interrupt, 0);
7414 A->setImplicit(true);
7415 return A;
7416 }
7417
7418 RISCVInterruptAttr(SourceRange R, ASTContext &Ctx
7419 , InterruptType Interrupt
7420 , unsigned SI
7421 )
7422 : InheritableAttr(attr::RISCVInterrupt, R, SI, false, false)
7423 , interrupt(Interrupt)
7424 {
7425 }
7426
7427 RISCVInterruptAttr(SourceRange R, ASTContext &Ctx
7428 , unsigned SI
7429 )
7430 : InheritableAttr(attr::RISCVInterrupt, R, SI, false, false)
7431 , interrupt(InterruptType(0))
7432 {
7433 }
7434
7435 RISCVInterruptAttr *clone(ASTContext &C) const;
7436 void printPretty(raw_ostream &OS,
7437 const PrintingPolicy &Policy) const;
7438 const char *getSpelling() const;
7439 InterruptType getInterrupt() const {
7440 return interrupt;
7441 }
7442
7443 static bool ConvertStrToInterruptType(StringRef Val, InterruptType &Out) {
7444 Optional<InterruptType> R = llvm::StringSwitch<Optional<InterruptType>>(Val)
7445 .Case("user", RISCVInterruptAttr::user)
7446 .Case("supervisor", RISCVInterruptAttr::supervisor)
7447 .Case("machine", RISCVInterruptAttr::machine)
7448 .Default(Optional<InterruptType>());
7449 if (R) {
7450 Out = *R;
7451 return true;
7452 }
7453 return false;
7454 }
7455
7456 static const char *ConvertInterruptTypeToStr(InterruptType Val) {
7457 switch(Val) {
7458 case RISCVInterruptAttr::user: return "user";
7459 case RISCVInterruptAttr::supervisor: return "supervisor";
7460 case RISCVInterruptAttr::machine: return "machine";
7461 }
7462 llvm_unreachable("No enumerator with that value")::llvm::llvm_unreachable_internal("No enumerator with that value"
, "/build/llvm-toolchain-snapshot-8~svn345461/build-llvm/tools/lldb/../clang/include/clang/AST/Attrs.inc"
, 7462)
;
7463 }
7464
7465
7466 static bool classof(const Attr *A) { return A->getKind() == attr::RISCVInterrupt; }
7467};
7468
7469class RegCallAttr : public InheritableAttr {
7470public:
7471 static RegCallAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
7472 auto *A = new (Ctx) RegCallAttr(Loc, Ctx, 0);
7473 A->setImplicit(true);
7474 return A;
7475 }
7476
7477 RegCallAttr(SourceRange R, ASTContext &Ctx
7478 , unsigned SI
7479 )
7480 : InheritableAttr(attr::RegCall, R, SI, false, false)
7481 {
7482 }
7483
7484 RegCallAttr *clone(ASTContext &C) const;
7485 void printPretty(raw_ostream &OS,
7486 const PrintingPolicy &Policy) const;
7487 const char *getSpelling() const;
7488
7489
7490 static bool classof(const Attr *A) { return A->getKind() == attr::RegCall; }
7491};
7492
7493class ReinitializesAttr : public InheritableAttr {
7494public:
7495 static ReinitializesAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
7496 auto *A = new (Ctx) ReinitializesAttr(Loc, Ctx, 0);
7497 A->setImplicit(true);
7498 return A;
7499 }
7500
7501 ReinitializesAttr(SourceRange R, ASTContext &Ctx
7502 , unsigned SI
7503 )
7504 : InheritableAttr(attr::Reinitializes, R, SI, false, false)
7505 {
7506 }
7507
7508 ReinitializesAttr *clone(ASTContext &C) const;
7509 void printPretty(raw_ostream &OS,
7510 const PrintingPolicy &Policy) const;
7511 const char *getSpelling() const;
7512
7513
7514 static bool classof(const Attr *A) { return A->getKind() == attr::Reinitializes; }
7515};
7516
7517class ReleaseCapabilityAttr : public InheritableAttr {
7518 unsigned args_Size;
7519 Expr * *args_;
7520
7521public:
7522 enum Spelling {
7523 GNU_release_capability = 0,
7524 CXX11_clang_release_capability = 1,
7525 GNU_release_shared_capability = 2,
7526 CXX11_clang_release_shared_capability = 3,
7527 GNU_release_generic_capability = 4,
7528 CXX11_clang_release_generic_capability = 5,
7529 GNU_unlock_function = 6,
7530 CXX11_clang_unlock_function = 7
7531 };
7532
7533 static ReleaseCapabilityAttr *CreateImplicit(ASTContext &Ctx, Spelling S, Expr * *Args, unsigned ArgsSize, SourceRange Loc = SourceRange()) {
7534 auto *A = new (Ctx) ReleaseCapabilityAttr(Loc, Ctx, Args, ArgsSize, S);
7535 A->setImplicit(true);
7536 return A;
7537 }
7538
7539 ReleaseCapabilityAttr(SourceRange R, ASTContext &Ctx
7540 , Expr * *Args, unsigned ArgsSize
7541 , unsigned SI
7542 )
7543 : InheritableAttr(attr::ReleaseCapability, R, SI, true, true)
7544 , args_Size(ArgsSize), args_(new (Ctx, 16) Expr *[args_Size])
7545 {
7546 std::copy(Args, Args + args_Size, args_);
7547 }
7548
7549 ReleaseCapabilityAttr(SourceRange R, ASTContext &Ctx
7550 , unsigned SI
7551 )
7552 : InheritableAttr(attr::ReleaseCapability, R, SI, true, true)
7553 , args_Size(0), args_(nullptr)
7554 {
7555 }
7556
7557 ReleaseCapabilityAttr *clone(ASTContext &C) const;
7558 void printPretty(raw_ostream &OS,
7559 const PrintingPolicy &Policy) const;
7560 const char *getSpelling() const;
7561 Spelling getSemanticSpelling() const {
7562 switch (SpellingListIndex) {
7563 default: llvm_unreachable("Unknown spelling list index")::llvm::llvm_unreachable_internal("Unknown spelling list index"
, "/build/llvm-toolchain-snapshot-8~svn345461/build-llvm/tools/lldb/../clang/include/clang/AST/Attrs.inc"
, 7563)
;
7564 case 0: return GNU_release_capability;
7565 case 1: return CXX11_clang_release_capability;
7566 case 2: return GNU_release_shared_capability;
7567 case 3: return CXX11_clang_release_shared_capability;
7568 case 4: return GNU_release_generic_capability;
7569 case 5: return CXX11_clang_release_generic_capability;
7570 case 6: return GNU_unlock_function;
7571 case 7: return CXX11_clang_unlock_function;
7572 }
7573 }
7574 bool isShared() const { return SpellingListIndex == 2 ||
7575 SpellingListIndex == 3; }
7576 bool isGeneric() const { return SpellingListIndex == 4 ||
7577 SpellingListIndex == 5 ||
7578 SpellingListIndex == 6 ||
7579 SpellingListIndex == 7; }
7580 typedef Expr ** args_iterator;
7581 args_iterator args_begin() const { return args_; }
7582 args_iterator args_end() const { return args_ + args_Size; }
7583 unsigned args_size() const { return args_Size; }
7584 llvm::iterator_range<args_iterator> args() const { return llvm::make_range(args_begin(), args_end()); }
7585
7586
7587
7588
7589 static bool classof(const Attr *A) { return A->getKind() == attr::ReleaseCapability; }
7590};
7591
7592class RenderScriptKernelAttr : public Attr {
7593public:
7594 static RenderScriptKernelAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
7595 auto *A = new (Ctx) RenderScriptKernelAttr(Loc, Ctx, 0);
7596 A->setImplicit(true);
7597 return A;
7598 }
7599
7600 RenderScriptKernelAttr(SourceRange R, ASTContext &Ctx
7601 , unsigned SI
7602 )
7603 : Attr(attr::RenderScriptKernel, R, SI, false)
7604 {
7605 }
7606
7607 RenderScriptKernelAttr *clone(ASTContext &C) const;
7608 void printPretty(raw_ostream &OS,
7609 const PrintingPolicy &Policy) const;
7610 const char *getSpelling() const;
7611
7612
7613 static bool classof(const Attr *A) { return A->getKind() == attr::RenderScriptKernel; }
7614};
7615
7616class ReqdWorkGroupSizeAttr : public InheritableAttr {
7617unsigned xDim;
7618
7619unsigned yDim;
7620
7621unsigned zDim;
7622
7623public:
7624 static ReqdWorkGroupSizeAttr *CreateImplicit(ASTContext &Ctx, unsigned XDim, unsigned YDim, unsigned ZDim, SourceRange Loc = SourceRange()) {
7625 auto *A = new (Ctx) ReqdWorkGroupSizeAttr(Loc, Ctx, XDim, YDim, ZDim, 0);
7626 A->setImplicit(true);
7627 return A;
7628 }
7629
7630 ReqdWorkGroupSizeAttr(SourceRange R, ASTContext &Ctx
7631 , unsigned XDim
7632 , unsigned YDim
7633 , unsigned ZDim
7634 , unsigned SI
7635 )
7636 : InheritableAttr(attr::ReqdWorkGroupSize, R, SI, false, false)
7637 , xDim(XDim)
7638 , yDim(YDim)
7639 , zDim(ZDim)
7640 {
7641 }
7642
7643 ReqdWorkGroupSizeAttr *clone(ASTContext &C) const;
7644 void printPretty(raw_ostream &OS,
7645 const PrintingPolicy &Policy) const;
7646 const char *getSpelling() const;
7647 unsigned getXDim() const {
7648 return xDim;
7649 }
7650
7651 unsigned getYDim() const {
7652 return yDim;
7653 }
7654
7655 unsigned getZDim() const {
7656 return zDim;
7657 }
7658
7659
7660
7661 static bool classof(const Attr *A) { return A->getKind() == attr::ReqdWorkGroupSize; }
7662};
7663
7664class RequireConstantInitAttr : public InheritableAttr {
7665public:
7666 static RequireConstantInitAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
7667 auto *A = new (Ctx) RequireConstantInitAttr(Loc, Ctx, 0);
7668 A->setImplicit(true);
7669 return A;
7670 }
7671
7672 RequireConstantInitAttr(SourceRange R, ASTContext &Ctx
7673 , unsigned SI
7674 )
7675 : InheritableAttr(attr::RequireConstantInit, R, SI, false, false)
7676 {
7677 }
7678
7679 RequireConstantInitAttr *clone(ASTContext &C) const;
7680 void printPretty(raw_ostream &OS,
7681 const PrintingPolicy &Policy) const;
7682 const char *getSpelling() const;
7683
7684
7685 static bool classof(const Attr *A) { return A->getKind() == attr::RequireConstantInit; }
7686};
7687
7688class RequiresCapabilityAttr : public InheritableAttr {
7689 unsigned args_Size;
7690 Expr * *args_;
7691
7692public:
7693 enum Spelling {
7694 GNU_requires_capability = 0,
7695 CXX11_clang_requires_capability = 1,
7696 GNU_exclusive_locks_required = 2,
7697 CXX11_clang_exclusive_locks_required = 3,
7698 GNU_requires_shared_capability = 4,
7699 CXX11_clang_requires_shared_capability = 5,
7700 GNU_shared_locks_required = 6,
7701 CXX11_clang_shared_locks_required = 7
7702 };
7703
7704 static RequiresCapabilityAttr *CreateImplicit(ASTContext &Ctx, Spelling S, Expr * *Args, unsigned ArgsSize, SourceRange Loc = SourceRange()) {
7705 auto *A = new (Ctx) RequiresCapabilityAttr(Loc, Ctx, Args, ArgsSize, S);
7706 A->setImplicit(true);
7707 return A;
7708 }
7709
7710 RequiresCapabilityAttr(SourceRange R, ASTContext &Ctx
7711 , Expr * *Args, unsigned ArgsSize
7712 , unsigned SI
7713 )
7714 : InheritableAttr(attr::RequiresCapability, R, SI, true, true)
7715 , args_Size(ArgsSize), args_(new (Ctx, 16) Expr *[args_Size])
7716 {
7717 std::copy(Args, Args + args_Size, args_);
7718 }
7719
7720 RequiresCapabilityAttr(SourceRange R, ASTContext &Ctx
7721 , unsigned SI
7722 )
7723 : InheritableAttr(attr::RequiresCapability, R, SI, true, true)
7724 , args_Size(0), args_(nullptr)
7725 {
7726 }
7727
7728 RequiresCapabilityAttr *clone(ASTContext &C) const;
7729 void printPretty(raw_ostream &OS,
7730 const PrintingPolicy &Policy) const;
7731 const char *getSpelling() const;
7732 Spelling getSemanticSpelling() const {
7733 switch (SpellingListIndex) {
7734 default: llvm_unreachable("Unknown spelling list index")::llvm::llvm_unreachable_internal("Unknown spelling list index"
, "/build/llvm-toolchain-snapshot-8~svn345461/build-llvm/tools/lldb/../clang/include/clang/AST/Attrs.inc"
, 7734)
;
7735 case 0: return GNU_requires_capability;
7736 case 1: return CXX11_clang_requires_capability;
7737 case 2: return GNU_exclusive_locks_required;
7738 case 3: return CXX11_clang_exclusive_locks_required;
7739 case 4: return GNU_requires_shared_capability;
7740 case 5: return CXX11_clang_requires_shared_capability;
7741 case 6: return GNU_shared_locks_required;
7742 case 7: return CXX11_clang_shared_locks_required;
7743 }
7744 }
7745 bool isShared() const { return SpellingListIndex == 4 ||
7746 SpellingListIndex == 5 ||
7747 SpellingListIndex == 6 ||
7748 SpellingListIndex == 7; }
7749 typedef Expr ** args_iterator;
7750 args_iterator args_begin() const { return args_; }
7751 args_iterator args_end() const { return args_ + args_Size; }
7752 unsigned args_size() const { return args_Size; }
7753 llvm::iterator_range<args_iterator> args() const { return llvm::make_range(args_begin(), args_end()); }
7754
7755
7756
7757
7758 static bool classof(const Attr *A) { return A->getKind() == attr::RequiresCapability; }
7759};
7760
7761class RestrictAttr : public InheritableAttr {
7762public:
7763 enum Spelling {
7764 Declspec_restrict = 0,
7765 GNU_malloc = 1,
7766 CXX11_gnu_malloc = 2
7767 };
7768
7769 static RestrictAttr *CreateImplicit(ASTContext &Ctx, Spelling S, SourceRange Loc = SourceRange()) {
7770 auto *A = new (Ctx) RestrictAttr(Loc, Ctx, S);
7771 A->setImplicit(true);
7772 return A;
7773 }
7774
7775 RestrictAttr(SourceRange R, ASTContext &Ctx
7776 , unsigned SI
7777 )
7778 : InheritableAttr(attr::Restrict, R, SI, false, false)
7779 {
7780 }
7781
7782 RestrictAttr *clone(ASTContext &C) const;
7783 void printPretty(raw_ostream &OS,
7784 const PrintingPolicy &Policy) const;
7785 const char *getSpelling() const;
7786 Spelling getSemanticSpelling() const {
7787 switch (SpellingListIndex) {
7788 default: llvm_unreachable("Unknown spelling list index")::llvm::llvm_unreachable_internal("Unknown spelling list index"
, "/build/llvm-toolchain-snapshot-8~svn345461/build-llvm/tools/lldb/../clang/include/clang/AST/Attrs.inc"
, 7788)
;
7789 case 0: return Declspec_restrict;
7790 case 1: return GNU_malloc;
7791 case 2: return CXX11_gnu_malloc;
7792 }
7793 }
7794
7795
7796 static bool classof(const Attr *A) { return A->getKind() == attr::Restrict; }
7797};
7798
7799class ReturnTypestateAttr : public InheritableAttr {
7800public:
7801 enum ConsumedState {
7802 Unknown,
7803 Consumed,
7804 Unconsumed
7805 };
7806private:
7807 ConsumedState state;
7808
7809public:
7810 static ReturnTypestateAttr *CreateImplicit(ASTContext &Ctx, ConsumedState State, SourceRange Loc = SourceRange()) {
7811 auto *A = new (Ctx) ReturnTypestateAttr(Loc, Ctx, State, 0);
7812 A->setImplicit(true);
7813 return A;
7814 }
7815
7816 ReturnTypestateAttr(SourceRange R, ASTContext &Ctx
7817 , ConsumedState State
7818 , unsigned SI
7819 )
7820 : InheritableAttr(attr::ReturnTypestate, R, SI, false, false)
7821 , state(State)
7822 {
7823 }
7824
7825 ReturnTypestateAttr *clone(ASTContext &C) const;
7826 void printPretty(raw_ostream &OS,
7827 const PrintingPolicy &Policy) const;
7828 const char *getSpelling() const;
7829 ConsumedState getState() const {
7830 return state;
7831 }
7832
7833 static bool ConvertStrToConsumedState(StringRef Val, ConsumedState &Out) {
7834 Optional<ConsumedState> R = llvm::StringSwitch<Optional<ConsumedState>>(Val)
7835 .Case("unknown", ReturnTypestateAttr::Unknown)
7836 .Case("consumed", ReturnTypestateAttr::Consumed)
7837 .Case("unconsumed", ReturnTypestateAttr::Unconsumed)
7838 .Default(Optional<ConsumedState>());
7839 if (R) {
7840 Out = *R;
7841 return true;
7842 }
7843 return false;
7844 }
7845
7846 static const char *ConvertConsumedStateToStr(ConsumedState Val) {
7847 switch(Val) {
7848 case ReturnTypestateAttr::Unknown: return "unknown";
7849 case ReturnTypestateAttr::Consumed: return "consumed";
7850 case ReturnTypestateAttr::Unconsumed: return "unconsumed";
7851 }
7852 llvm_unreachable("No enumerator with that value")::llvm::llvm_unreachable_internal("No enumerator with that value"
, "/build/llvm-toolchain-snapshot-8~svn345461/build-llvm/tools/lldb/../clang/include/clang/AST/Attrs.inc"
, 7852)
;
7853 }
7854
7855
7856 static bool classof(const Attr *A) { return A->getKind() == attr::ReturnTypestate; }
7857};
7858
7859class ReturnsNonNullAttr : public InheritableAttr {
7860public:
7861 static ReturnsNonNullAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
7862 auto *A = new (Ctx) ReturnsNonNullAttr(Loc, Ctx, 0);
7863 A->setImplicit(true);
7864 return A;
7865 }
7866
7867 ReturnsNonNullAttr(SourceRange R, ASTContext &Ctx
7868 , unsigned SI
7869 )
7870 : InheritableAttr(attr::ReturnsNonNull, R, SI, false, false)
7871 {
7872 }
7873
7874 ReturnsNonNullAttr *clone(ASTContext &C) const;
7875 void printPretty(raw_ostream &OS,
7876 const PrintingPolicy &Policy) const;
7877 const char *getSpelling() const;
7878
7879
7880 static bool classof(const Attr *A) { return A->getKind() == attr::ReturnsNonNull; }
7881};
7882
7883class ReturnsTwiceAttr : public InheritableAttr {
7884public:
7885 static ReturnsTwiceAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
7886 auto *A = new (Ctx) ReturnsTwiceAttr(Loc, Ctx, 0);
7887 A->setImplicit(true);
7888 return A;
7889 }
7890
7891 ReturnsTwiceAttr(SourceRange R, ASTContext &Ctx
7892 , unsigned SI
7893 )
7894 : InheritableAttr(attr::ReturnsTwice, R, SI, false, false)
7895 {
7896 }
7897
7898 ReturnsTwiceAttr *clone(ASTContext &C) const;
7899 void printPretty(raw_ostream &OS,
7900 const PrintingPolicy &Policy) const;
7901 const char *getSpelling() const;
7902
7903
7904 static bool classof(const Attr *A) { return A->getKind() == attr::ReturnsTwice; }
7905};
7906
7907class SPtrAttr : public TypeAttr {
7908public:
7909 static SPtrAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
7910 auto *A = new (Ctx) SPtrAttr(Loc, Ctx, 0);
7911 A->setImplicit(true);
7912 return A;
7913 }
7914
7915 SPtrAttr(SourceRange R, ASTContext &Ctx
7916 , unsigned SI
7917 )
7918 : TypeAttr(attr::SPtr, R, SI, false)
7919 {
7920 }
7921
7922 SPtrAttr *clone(ASTContext &C) const;
7923 void printPretty(raw_ostream &OS,
7924 const PrintingPolicy &Policy) const;
7925 const char *getSpelling() const;
7926
7927
7928 static bool classof(const Attr *A) { return A->getKind() == attr::SPtr; }
7929};
7930
7931class ScopedLockableAttr : public InheritableAttr {
7932public:
7933 static ScopedLockableAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
7934 auto *A = new (Ctx) ScopedLockableAttr(Loc, Ctx, 0);
7935 A->setImplicit(true);
7936 return A;
7937 }
7938
7939 ScopedLockableAttr(SourceRange R, ASTContext &Ctx
7940 , unsigned SI
7941 )
7942 : InheritableAttr(attr::ScopedLockable, R, SI, false, false)
7943 {
7944 }
7945
7946 ScopedLockableAttr *clone(ASTContext &C) const;
7947 void printPretty(raw_ostream &OS,
7948 const PrintingPolicy &Policy) const;
7949 const char *getSpelling() const;
7950
7951
7952 static bool classof(const Attr *A) { return A->getKind() == attr::ScopedLockable; }
7953};
7954
7955class SectionAttr : public InheritableAttr {
7956unsigned nameLength;
7957char *name;
7958
7959public:
7960 enum Spelling {
7961 GNU_section = 0,
7962 CXX11_gnu_section = 1,
7963 Declspec_allocate = 2
7964 };
7965
7966 static SectionAttr *CreateImplicit(ASTContext &Ctx, Spelling S, llvm::StringRef Name, SourceRange Loc = SourceRange()) {
7967 auto *A = new (Ctx) SectionAttr(Loc, Ctx, Name, S);
7968 A->setImplicit(true);
7969 return A;
7970 }
7971
7972 SectionAttr(SourceRange R, ASTContext &Ctx
7973 , llvm::StringRef Name
7974 , unsigned SI
7975 )
7976 : InheritableAttr(attr::Section, R, SI, false, false)
7977 , nameLength(Name.size()),name(new (Ctx, 1) char[nameLength])
7978 {
7979 if (!Name.empty())
7980 std::memcpy(name, Name.data(), nameLength);
7981 }
7982
7983 SectionAttr *clone(ASTContext &C) const;
7984 void printPretty(raw_ostream &OS,
7985 const PrintingPolicy &Policy) const;
7986 const char *getSpelling() const;
7987 Spelling getSemanticSpelling() const {
7988 switch (SpellingListIndex) {
7989 default: llvm_unreachable("Unknown spelling list index")::llvm::llvm_unreachable_internal("Unknown spelling list index"
, "/build/llvm-toolchain-snapshot-8~svn345461/build-llvm/tools/lldb/../clang/include/clang/AST/Attrs.inc"
, 7989)
;
7990 case 0: return GNU_section;
7991 case 1: return CXX11_gnu_section;
7992 case 2: return Declspec_allocate;
7993 }
7994 }
7995 llvm::StringRef getName() const {
7996 return llvm::StringRef(name, nameLength);
7997 }
7998 unsigned getNameLength() const {
7999 return nameLength;
8000 }
8001 void setName(ASTContext &C, llvm::StringRef S) {
8002 nameLength = S.size();
8003 this->name = new (C, 1) char [nameLength];
8004 if (!S.empty())
8005 std::memcpy(this->name, S.data(), nameLength);
8006 }
8007
8008
8009
8010 static bool classof(const Attr *A) { return A->getKind() == attr::Section; }
8011};
8012
8013class SelectAnyAttr : public InheritableAttr {
8014public:
8015 static SelectAnyAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
8016 auto *A = new (Ctx) SelectAnyAttr(Loc, Ctx, 0);
8017 A->setImplicit(true);
8018 return A;
8019 }
8020
8021 SelectAnyAttr(SourceRange R, ASTContext &Ctx
8022 , unsigned SI
8023 )
8024 : InheritableAttr(attr::SelectAny, R, SI, false, false)
8025 {
8026 }
8027
8028 SelectAnyAttr *clone(ASTContext &C) const;
8029 void printPretty(raw_ostream &OS,
8030 const PrintingPolicy &Policy) const;
8031 const char *getSpelling() const;
8032
8033
8034 static bool classof(const Attr *A) { return A->getKind() == attr::SelectAny; }
8035};
8036
8037class SentinelAttr : public InheritableAttr {
8038int sentinel;
8039
8040int nullPos;
8041
8042public:
8043 static SentinelAttr *CreateImplicit(ASTContext &Ctx, int Sentinel, int NullPos, SourceRange Loc = SourceRange()) {
8044 auto *A = new (Ctx) SentinelAttr(Loc, Ctx, Sentinel, NullPos, 0);
8045 A->setImplicit(true);
8046 return A;
8047 }
8048
8049 SentinelAttr(SourceRange R, ASTContext &Ctx
8050 , int Sentinel
8051 , int NullPos
8052 , unsigned SI
8053 )
8054 : InheritableAttr(attr::Sentinel, R, SI, false, false)
8055 , sentinel(Sentinel)
8056 , nullPos(NullPos)
8057 {
8058 }
8059
8060 SentinelAttr(SourceRange R, ASTContext &Ctx
8061 , unsigned SI
8062 )
8063 : InheritableAttr(attr::Sentinel, R, SI, false, false)
8064 , sentinel()
8065 , nullPos()
8066 {
8067 }
8068
8069 SentinelAttr *clone(ASTContext &C) const;
8070 void printPretty(raw_ostream &OS,
8071 const PrintingPolicy &Policy) const;
8072 const char *getSpelling() const;
8073 int getSentinel() const {
8074 return sentinel;
8075 }
8076
8077 static const int DefaultSentinel = 0;
8078
8079 int getNullPos() const {
8080 return nullPos;
8081 }
8082
8083 static const int DefaultNullPos = 0;
8084
8085
8086
8087 static bool classof(const Attr *A) { return A->getKind() == attr::Sentinel; }
8088};
8089
8090class SetTypestateAttr : public InheritableAttr {
8091public:
8092 enum ConsumedState {
8093 Unknown,
8094 Consumed,
8095 Unconsumed
8096 };
8097private:
8098 ConsumedState newState;
8099
8100public:
8101 static SetTypestateAttr *CreateImplicit(ASTContext &Ctx, ConsumedState NewState, SourceRange Loc = SourceRange()) {
8102 auto *A = new (Ctx) SetTypestateAttr(Loc, Ctx, NewState, 0);
8103 A->setImplicit(true);
8104 return A;
8105 }
8106
8107 SetTypestateAttr(SourceRange R, ASTContext &Ctx
8108 , ConsumedState NewState
8109 , unsigned SI
8110 )
8111 : InheritableAttr(attr::SetTypestate, R, SI, false, false)
8112 , newState(NewState)
8113 {
8114 }
8115
8116 SetTypestateAttr *clone(ASTContext &C) const;
8117 void printPretty(raw_ostream &OS,
8118 const PrintingPolicy &Policy) const;
8119 const char *getSpelling() const;
8120 ConsumedState getNewState() const {
8121 return newState;
8122 }
8123
8124 static bool ConvertStrToConsumedState(StringRef Val, ConsumedState &Out) {
8125 Optional<ConsumedState> R = llvm::StringSwitch<Optional<ConsumedState>>(Val)
8126 .Case("unknown", SetTypestateAttr::Unknown)
8127 .Case("consumed", SetTypestateAttr::Consumed)
8128 .Case("unconsumed", SetTypestateAttr::Unconsumed)
8129 .Default(Optional<ConsumedState>());
8130 if (R) {
8131 Out = *R;
8132 return true;
8133 }
8134 return false;
8135 }
8136
8137 static const char *ConvertConsumedStateToStr(ConsumedState Val) {
8138 switch(Val) {
8139 case SetTypestateAttr::Unknown: return "unknown";
8140 case SetTypestateAttr::Consumed: return "consumed";
8141 case SetTypestateAttr::Unconsumed: return "unconsumed";
8142 }
8143 llvm_unreachable("No enumerator with that value")::llvm::llvm_unreachable_internal("No enumerator with that value"
, "/build/llvm-toolchain-snapshot-8~svn345461/build-llvm/tools/lldb/../clang/include/clang/AST/Attrs.inc"
, 8143)
;
8144 }
8145
8146
8147 static bool classof(const Attr *A) { return A->getKind() == attr::SetTypestate; }
8148};
8149
8150class SharedTrylockFunctionAttr : public InheritableAttr {
8151Expr * successValue;
8152
8153 unsigned args_Size;
8154 Expr * *args_;
8155
8156public:
8157 static SharedTrylockFunctionAttr *CreateImplicit(ASTContext &Ctx, Expr * SuccessValue, Expr * *Args, unsigned ArgsSize, SourceRange Loc = SourceRange()) {
8158 auto *A = new (Ctx) SharedTrylockFunctionAttr(Loc, Ctx, SuccessValue, Args, ArgsSize, 0);
8159 A->setImplicit(true);
8160 return A;
8161 }
8162
8163 SharedTrylockFunctionAttr(SourceRange R, ASTContext &Ctx
8164 , Expr * SuccessValue
8165 , Expr * *Args, unsigned ArgsSize
8166 , unsigned SI
8167 )
8168 : InheritableAttr(attr::SharedTrylockFunction, R, SI, true, true)
8169 , successValue(SuccessValue)
8170 , args_Size(ArgsSize), args_(new (Ctx, 16) Expr *[args_Size])
8171 {
8172 std::copy(Args, Args + args_Size, args_);
8173 }
8174
8175 SharedTrylockFunctionAttr(SourceRange R, ASTContext &Ctx
8176 , Expr * SuccessValue
8177 , unsigned SI
8178 )
8179 : InheritableAttr(attr::SharedTrylockFunction, R, SI, true, true)
8180 , successValue(SuccessValue)
8181 , args_Size(0), args_(nullptr)
8182 {
8183 }
8184
8185 SharedTrylockFunctionAttr *clone(ASTContext &C) const;
8186 void printPretty(raw_ostream &OS,
8187 const PrintingPolicy &Policy) const;
8188 const char *getSpelling() const;
8189 Expr * getSuccessValue() const {
8190 return successValue;
8191 }
8192
8193 typedef Expr ** args_iterator;
8194 args_iterator args_begin() const { return args_; }
8195 args_iterator args_end() const { return args_ + args_Size; }
8196 unsigned args_size() const { return args_Size; }
8197 llvm::iterator_range<args_iterator> args() const { return llvm::make_range(args_begin(), args_end()); }
8198
8199
8200
8201
8202 static bool classof(const Attr *A) { return A->getKind() == attr::SharedTrylockFunction; }
8203};
8204
8205class StdCallAttr : public InheritableAttr {
8206public:
8207 static StdCallAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
8208 auto *A = new (Ctx) StdCallAttr(Loc, Ctx, 0);
8209 A->setImplicit(true);
8210 return A;
8211 }
8212
8213 StdCallAttr(SourceRange R, ASTContext &Ctx
8214 , unsigned SI
8215 )
8216 : InheritableAttr(attr::StdCall, R, SI, false, false)
8217 {
8218 }
8219
8220 StdCallAttr *clone(ASTContext &C) const;
8221 void printPretty(raw_ostream &OS,
8222 const PrintingPolicy &Policy) const;
8223 const char *getSpelling() const;
8224
8225
8226 static bool classof(const Attr *A) { return A->getKind() == attr::StdCall; }
8227};
8228
8229class SuppressAttr : public StmtAttr {
8230 unsigned diagnosticIdentifiers_Size;
8231 StringRef *diagnosticIdentifiers_;
8232
8233public:
8234 static SuppressAttr *CreateImplicit(ASTContext &Ctx, StringRef *DiagnosticIdentifiers, unsigned DiagnosticIdentifiersSize, SourceRange Loc = SourceRange()) {
8235 auto *A = new (Ctx) SuppressAttr(Loc, Ctx, DiagnosticIdentifiers, DiagnosticIdentifiersSize, 0);
8236 A->setImplicit(true);
8237 return A;
8238 }
8239
8240 SuppressAttr(SourceRange R, ASTContext &Ctx
8241 , StringRef *DiagnosticIdentifiers, unsigned DiagnosticIdentifiersSize
8242 , unsigned SI
8243 )
8244 : StmtAttr(attr::Suppress, R, SI, false)
8245 , diagnosticIdentifiers_Size(DiagnosticIdentifiersSize), diagnosticIdentifiers_(new (Ctx, 16) StringRef[diagnosticIdentifiers_Size])
8246 {
8247 for (size_t I = 0, E = diagnosticIdentifiers_Size; I != E;
8248 ++I) {
8249 StringRef Ref = DiagnosticIdentifiers[I];
8250 if (!Ref.empty()) {
8251 char *Mem = new (Ctx, 1) char[Ref.size()];
8252 std::memcpy(Mem, Ref.data(), Ref.size());
8253 diagnosticIdentifiers_[I] = StringRef(Mem, Ref.size());
8254 }
8255 }
8256 }
8257
8258 SuppressAttr(SourceRange R, ASTContext &Ctx
8259 , unsigned SI
8260 )
8261 : StmtAttr(attr::Suppress, R, SI, false)
8262 , diagnosticIdentifiers_Size(0), diagnosticIdentifiers_(nullptr)
8263 {
8264 }
8265
8266 SuppressAttr *clone(ASTContext &C) const;
8267 void printPretty(raw_ostream &OS,
8268 const PrintingPolicy &Policy) const;
8269 const char *getSpelling() const;
8270 typedef StringRef* diagnosticIdentifiers_iterator;
8271 diagnosticIdentifiers_iterator diagnosticIdentifiers_begin() const { return diagnosticIdentifiers_; }
8272 diagnosticIdentifiers_iterator diagnosticIdentifiers_end() const { return diagnosticIdentifiers_ + diagnosticIdentifiers_Size; }
8273 unsigned diagnosticIdentifiers_size() const { return diagnosticIdentifiers_Size; }
8274 llvm::iterator_range<diagnosticIdentifiers_iterator> diagnosticIdentifiers() const { return llvm::make_range(diagnosticIdentifiers_begin(), diagnosticIdentifiers_end()); }
8275
8276
8277
8278
8279 static bool classof(const Attr *A) { return A->getKind() == attr::Suppress; }
8280};
8281
8282class SwiftCallAttr : public InheritableAttr {
8283public:
8284 static SwiftCallAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
8285 auto *A = new (Ctx) SwiftCallAttr(Loc, Ctx, 0);
8286 A->setImplicit(true);
8287 return A;
8288 }
8289
8290 SwiftCallAttr(SourceRange R, ASTContext &Ctx
8291 , unsigned SI
8292 )
8293 : InheritableAttr(attr::SwiftCall, R, SI, false, false)
8294 {
8295 }
8296
8297 SwiftCallAttr *clone(ASTContext &C) const;
8298 void printPretty(raw_ostream &OS,
8299 const PrintingPolicy &Policy) const;
8300 const char *getSpelling() const;
8301
8302
8303 static bool classof(const Attr *A) { return A->getKind() == attr::SwiftCall; }
8304};
8305
8306class SwiftContextAttr : public ParameterABIAttr {
8307public:
8308 static SwiftContextAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
8309 auto *A = new (Ctx) SwiftContextAttr(Loc, Ctx, 0);
8310 A->setImplicit(true);
8311 return A;
8312 }
8313
8314 SwiftContextAttr(SourceRange R, ASTContext &Ctx
8315 , unsigned SI
8316 )
8317 : ParameterABIAttr(attr::SwiftContext, R, SI, false, false)
8318 {
8319 }
8320
8321 SwiftContextAttr *clone(ASTContext &C) const;
8322 void printPretty(raw_ostream &OS,
8323 const PrintingPolicy &Policy) const;
8324 const char *getSpelling() const;
8325
8326
8327 static bool classof(const Attr *A) { return A->getKind() == attr::SwiftContext; }
8328};
8329
8330class SwiftErrorResultAttr : public ParameterABIAttr {
8331public:
8332 static SwiftErrorResultAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
8333 auto *A = new (Ctx) SwiftErrorResultAttr(Loc, Ctx, 0);
8334 A->setImplicit(true);
8335 return A;
8336 }
8337
8338 SwiftErrorResultAttr(SourceRange R, ASTContext &Ctx
8339 , unsigned SI
8340 )
8341 : ParameterABIAttr(attr::SwiftErrorResult, R, SI, false, false)
8342 {
8343 }
8344
8345 SwiftErrorResultAttr *clone(ASTContext &C) const;
8346 void printPretty(raw_ostream &OS,
8347 const PrintingPolicy &Policy) const;
8348 const char *getSpelling() const;
8349
8350
8351 static bool classof(const Attr *A) { return A->getKind() == attr::SwiftErrorResult; }
8352};
8353
8354class SwiftIndirectResultAttr : public ParameterABIAttr {
8355public:
8356 static SwiftIndirectResultAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
8357 auto *A = new (Ctx) SwiftIndirectResultAttr(Loc, Ctx, 0);
8358 A->setImplicit(true);
8359 return A;
8360 }
8361
8362 SwiftIndirectResultAttr(SourceRange R, ASTContext &Ctx
8363 , unsigned SI
8364 )
8365 : ParameterABIAttr(attr::SwiftIndirectResult, R, SI, false, false)
8366 {
8367 }
8368
8369 SwiftIndirectResultAttr *clone(ASTContext &C) const;
8370 void printPretty(raw_ostream &OS,
8371 const PrintingPolicy &Policy) const;
8372 const char *getSpelling() const;
8373
8374
8375 static bool classof(const Attr *A) { return A->getKind() == attr::SwiftIndirectResult; }
8376};
8377
8378class SysVABIAttr : public InheritableAttr {
8379public:
8380 static SysVABIAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
8381 auto *A = new (Ctx) SysVABIAttr(Loc, Ctx, 0);
8382 A->setImplicit(true);
8383 return A;
8384 }
8385
8386 SysVABIAttr(SourceRange R, ASTContext &Ctx
8387 , unsigned SI
8388 )
8389 : InheritableAttr(attr::SysVABI, R, SI, false, false)
8390 {
8391 }
8392
8393 SysVABIAttr *clone(ASTContext &C) const;
8394 void printPretty(raw_ostream &OS,
8395 const PrintingPolicy &Policy) const;
8396 const char *getSpelling() const;
8397
8398
8399 static bool classof(const Attr *A) { return A->getKind() == attr::SysVABI; }
8400};
8401
8402class TLSModelAttr : public InheritableAttr {
8403unsigned modelLength;
8404char *model;
8405
8406public:
8407 static TLSModelAttr *CreateImplicit(ASTContext &Ctx, llvm::StringRef Model, SourceRange Loc = SourceRange()) {
8408 auto *A = new (Ctx) TLSModelAttr(Loc, Ctx, Model, 0);
8409 A->setImplicit(true);
8410 return A;
8411 }
8412
8413 TLSModelAttr(SourceRange R, ASTContext &Ctx
8414 , llvm::StringRef Model
8415 , unsigned SI
8416 )
8417 : InheritableAttr(attr::TLSModel, R, SI, false, false)
8418 , modelLength(Model.size()),model(new (Ctx, 1) char[modelLength])
8419 {
8420 if (!Model.empty())
8421 std::memcpy(model, Model.data(), modelLength);
8422 }
8423
8424 TLSModelAttr *clone(ASTContext &C) const;
8425 void printPretty(raw_ostream &OS,
8426 const PrintingPolicy &Policy) const;
8427 const char *getSpelling() const;
8428 llvm::StringRef getModel() const {
8429 return llvm::StringRef(model, modelLength);
8430 }
8431 unsigned getModelLength() const {
8432 return modelLength;
8433 }
8434 void setModel(ASTContext &C, llvm::StringRef S) {
8435 modelLength = S.size();
8436 this->model = new (C, 1) char [modelLength];
8437 if (!S.empty())
8438 std::memcpy(this->model, S.data(), modelLength);
8439 }
8440
8441
8442
8443 static bool classof(const Attr *A) { return A->getKind() == attr::TLSModel; }
8444};
8445
8446class TargetAttr : public InheritableAttr {
8447unsigned featuresStrLength;
8448char *featuresStr;
8449
8450public:
8451 static TargetAttr *CreateImplicit(ASTContext &Ctx, llvm::StringRef FeaturesStr, SourceRange Loc = SourceRange()) {
8452 auto *A = new (Ctx) TargetAttr(Loc, Ctx, FeaturesStr, 0);
8453 A->setImplicit(true);
8454 return A;
8455 }
8456
8457 TargetAttr(SourceRange R, ASTContext &Ctx
8458 , llvm::StringRef FeaturesStr
8459 , unsigned SI
8460 )
8461 : InheritableAttr(attr::Target, R, SI, false, false)
8462 , featuresStrLength(FeaturesStr.size()),featuresStr(new (Ctx, 1) char[featuresStrLength])
8463 {
8464 if (!FeaturesStr.empty())
8465 std::memcpy(featuresStr, FeaturesStr.data(), featuresStrLength);
8466 }
8467
8468 TargetAttr *clone(ASTContext &C) const;
8469 void printPretty(raw_ostream &OS,
8470 const PrintingPolicy &Policy) const;
8471 const char *getSpelling() const;
8472 llvm::StringRef getFeaturesStr() const {
8473 return llvm::StringRef(featuresStr, featuresStrLength);
8474 }
8475 unsigned getFeaturesStrLength() const {
8476 return featuresStrLength;
8477 }
8478 void setFeaturesStr(ASTContext &C, llvm::StringRef S) {
8479 featuresStrLength = S.size();
8480 this->featuresStr = new (C, 1) char [featuresStrLength];
8481 if (!S.empty())
8482 std::memcpy(this->featuresStr, S.data(), featuresStrLength);
8483 }
8484
8485
8486 struct ParsedTargetAttr {
8487 std::vector<std::string> Features;
8488 StringRef Architecture;
8489 bool DuplicateArchitecture = false;
8490 bool operator ==(const ParsedTargetAttr &Other) const {
8491 return DuplicateArchitecture == Other.DuplicateArchitecture &&
8492 Architecture == Other.Architecture && Features == Other.Features;
8493 }
8494 };
8495 ParsedTargetAttr parse() const {
8496 return parse(getFeaturesStr());
8497 }
8498
8499 StringRef getArchitecture() const {
8500 StringRef Features = getFeaturesStr();
8501 if (Features == "default") return {};
8502
8503 SmallVector<StringRef, 1> AttrFeatures;
8504 Features.split(AttrFeatures, ",");
8505
8506 for (auto &Feature : AttrFeatures) {
8507 Feature = Feature.trim();
8508 if (Feature.startswith("arch="))
8509 return Feature.drop_front(sizeof("arch=") - 1);
8510 }
8511 return "";
8512 }
8513
8514 // Gets the list of features as simple string-refs with no +/- or 'no-'.
8515 // Only adds the items to 'Out' that are additions.
8516 void getAddedFeatures(llvm::SmallVectorImpl<StringRef> &Out) const {
8517 StringRef Features = getFeaturesStr();
8518 if (Features == "default") return;
8519
8520 SmallVector<StringRef, 1> AttrFeatures;
8521 Features.split(AttrFeatures, ",");
8522
8523 for (auto &Feature : AttrFeatures) {
8524 Feature = Feature.trim();
8525
8526 if (!Feature.startswith("no-") && !Feature.startswith("arch=") &&
8527 !Feature.startswith("fpmath=") && !Feature.startswith("tune="))
8528 Out.push_back(Feature);
8529 }
8530 }
8531
8532 template<class Compare>
8533 ParsedTargetAttr parse(Compare cmp) const {
8534 ParsedTargetAttr Attrs = parse();
8535 llvm::sort(std::begin(Attrs.Features), std::end(Attrs.Features), cmp);
8536 return Attrs;
8537 }
8538
8539 bool isDefaultVersion() const { return getFeaturesStr() == "default"; }
8540
8541 static ParsedTargetAttr parse(StringRef Features) {
8542 ParsedTargetAttr Ret;
8543 if (Features == "default") return Ret;
8544 SmallVector<StringRef, 1> AttrFeatures;
8545 Features.split(AttrFeatures, ",");
8546
8547 // Grab the various features and prepend a "+" to turn on the feature to
8548 // the backend and add them to our existing set of features.
8549 for (auto &Feature : AttrFeatures) {
8550 // Go ahead and trim whitespace rather than either erroring or
8551 // accepting it weirdly.
8552 Feature = Feature.trim();
8553
8554 // We don't support cpu tuning this way currently.
8555 // TODO: Support the fpmath option. It will require checking
8556 // overall feature validity for the function with the rest of the
8557 // attributes on the function.
8558 if (Feature.startswith("fpmath=") || Feature.startswith("tune="))
8559 continue;
8560
8561 // While we're here iterating check for a different target cpu.
8562 if (Feature.startswith("arch=")) {
8563 if (!Ret.Architecture.empty())
8564 Ret.DuplicateArchitecture = true;
8565 else
8566 Ret.Architecture = Feature.split("=").second.trim();
8567 } else if (Feature.startswith("no-"))
8568 Ret.Features.push_back("-" + Feature.split("-").second.str());
8569 else
8570 Ret.Features.push_back("+" + Feature.str());
8571 }
8572 return Ret;
8573 }
8574
8575
8576 static bool classof(const Attr *A) { return A->getKind() == attr::Target; }
8577};
8578
8579class TestTypestateAttr : public InheritableAttr {
8580public:
8581 enum ConsumedState {
8582 Consumed,
8583 Unconsumed
8584 };
8585private:
8586 ConsumedState testState;
8587
8588public:
8589 static TestTypestateAttr *CreateImplicit(ASTContext &Ctx, ConsumedState TestState, SourceRange Loc = SourceRange()) {
8590 auto *A = new (Ctx) TestTypestateAttr(Loc, Ctx, TestState, 0);
8591 A->setImplicit(true);
8592 return A;
8593 }
8594
8595 TestTypestateAttr(SourceRange R, ASTContext &Ctx
8596 , ConsumedState TestState
8597 , unsigned SI
8598 )
8599 : InheritableAttr(attr::TestTypestate, R, SI, false, false)
8600 , testState(TestState)
8601 {
8602 }
8603
8604 TestTypestateAttr *clone(ASTContext &C) const;
8605 void printPretty(raw_ostream &OS,
8606 const PrintingPolicy &Policy) const;
8607 const char *getSpelling() const;
8608 ConsumedState getTestState() const {
8609 return testState;
8610 }
8611
8612 static bool ConvertStrToConsumedState(StringRef Val, ConsumedState &Out) {
8613 Optional<ConsumedState> R = llvm::StringSwitch<Optional<ConsumedState>>(Val)
8614 .Case("consumed", TestTypestateAttr::Consumed)
8615 .Case("unconsumed", TestTypestateAttr::Unconsumed)
8616 .Default(Optional<ConsumedState>());
8617 if (R) {
8618 Out = *R;
8619 return true;
8620 }
8621 return false;
8622 }
8623
8624 static const char *ConvertConsumedStateToStr(ConsumedState Val) {
8625 switch(Val) {
8626 case TestTypestateAttr::Consumed: return "consumed";
8627 case TestTypestateAttr::Unconsumed: return "unconsumed";
8628 }
8629 llvm_unreachable("No enumerator with that value")::llvm::llvm_unreachable_internal("No enumerator with that value"
, "/build/llvm-toolchain-snapshot-8~svn345461/build-llvm/tools/lldb/../clang/include/clang/AST/Attrs.inc"
, 8629)
;
8630 }
8631
8632
8633 static bool classof(const Attr *A) { return A->getKind() == attr::TestTypestate; }
8634};
8635
8636class ThisCallAttr : public InheritableAttr {
8637public:
8638 static ThisCallAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
8639 auto *A = new (Ctx) ThisCallAttr(Loc, Ctx, 0);
8640 A->setImplicit(true);
8641 return A;
8642 }
8643
8644 ThisCallAttr(SourceRange R, ASTContext &Ctx
8645 , unsigned SI
8646 )
8647 : InheritableAttr(attr::ThisCall, R, SI, false, false)
8648 {
8649 }
8650
8651 ThisCallAttr *clone(ASTContext &C) const;
8652 void printPretty(raw_ostream &OS,
8653 const PrintingPolicy &Policy) const;
8654 const char *getSpelling() const;
8655
8656
8657 static bool classof(const Attr *A) { return A->getKind() == attr::ThisCall; }
8658};
8659
8660class ThreadAttr : public Attr {
8661public:
8662 static ThreadAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
8663 auto *A = new (Ctx) ThreadAttr(Loc, Ctx, 0);
8664 A->setImplicit(true);
8665 return A;
8666 }
8667
8668 ThreadAttr(SourceRange R, ASTContext &Ctx
8669 , unsigned SI
8670 )
8671 : Attr(attr::Thread, R, SI, false)
8672 {
8673 }
8674
8675 ThreadAttr *clone(ASTContext &C) const;
8676 void printPretty(raw_ostream &OS,
8677 const PrintingPolicy &Policy) const;
8678 const char *getSpelling() const;
8679
8680
8681 static bool classof(const Attr *A) { return A->getKind() == attr::Thread; }
8682};
8683
8684class TransparentUnionAttr : public InheritableAttr {
8685public:
8686 static TransparentUnionAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
8687 auto *A = new (Ctx) TransparentUnionAttr(Loc, Ctx, 0);
8688 A->setImplicit(true);
8689 return A;
8690 }
8691
8692 TransparentUnionAttr(SourceRange R, ASTContext &Ctx
8693 , unsigned SI
8694 )
8695 : InheritableAttr(attr::TransparentUnion, R, SI, false, false)
8696 {
8697 }
8698
8699 TransparentUnionAttr *clone(ASTContext &C) const;
8700 void printPretty(raw_ostream &OS,
8701 const PrintingPolicy &Policy) const;
8702 const char *getSpelling() const;
8703
8704
8705 static bool classof(const Attr *A) { return A->getKind() == attr::TransparentUnion; }
8706};
8707
8708class TrivialABIAttr : public InheritableAttr {
8709public:
8710 static TrivialABIAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
8711 auto *A = new (Ctx) TrivialABIAttr(Loc, Ctx, 0);
8712 A->setImplicit(true);
8713 return A;
8714 }
8715
8716 TrivialABIAttr(SourceRange R, ASTContext &Ctx
8717 , unsigned SI
8718 )
8719 : InheritableAttr(attr::TrivialABI, R, SI, false, false)
8720 {
8721 }
8722
8723 TrivialABIAttr *clone(ASTContext &C) const;
8724 void printPretty(raw_ostream &OS,
8725 const PrintingPolicy &Policy) const;
8726 const char *getSpelling() const;
8727
8728
8729 static bool classof(const Attr *A) { return A->getKind() == attr::TrivialABI; }
8730};
8731
8732class TryAcquireCapabilityAttr : public InheritableAttr {
8733Expr * successValue;
8734
8735 unsigned args_Size;
8736 Expr * *args_;
8737
8738public:
8739 enum Spelling {
8740 GNU_try_acquire_capability = 0,
8741 CXX11_clang_try_acquire_capability = 1,
8742 GNU_try_acquire_shared_capability = 2,
8743 CXX11_clang_try_acquire_shared_capability = 3
8744 };
8745
8746 static TryAcquireCapabilityAttr *CreateImplicit(ASTContext &Ctx, Spelling S, Expr * SuccessValue, Expr * *Args, unsigned ArgsSize, SourceRange Loc = SourceRange()) {
8747 auto *A = new (Ctx) TryAcquireCapabilityAttr(Loc, Ctx, SuccessValue, Args, ArgsSize, S);
8748 A->setImplicit(true);
8749 return A;
8750 }
8751
8752 TryAcquireCapabilityAttr(SourceRange R, ASTContext &Ctx
8753 , Expr * SuccessValue
8754 , Expr * *Args, unsigned ArgsSize
8755 , unsigned SI
8756 )
8757 : InheritableAttr(attr::TryAcquireCapability, R, SI, true, true)
8758 , successValue(SuccessValue)
8759 , args_Size(ArgsSize), args_(new (Ctx, 16) Expr *[args_Size])
8760 {
8761 std::copy(Args, Args + args_Size, args_);
8762 }
8763
8764 TryAcquireCapabilityAttr(SourceRange R, ASTContext &Ctx
8765 , Expr * SuccessValue
8766 , unsigned SI
8767 )
8768 : InheritableAttr(attr::TryAcquireCapability, R, SI, true, true)
8769 , successValue(SuccessValue)
8770 , args_Size(0), args_(nullptr)
8771 {
8772 }
8773
8774 TryAcquireCapabilityAttr *clone(ASTContext &C) const;
8775 void printPretty(raw_ostream &OS,
8776 const PrintingPolicy &Policy) const;
8777 const char *getSpelling() const;
8778 Spelling getSemanticSpelling() const {
8779 switch (SpellingListIndex) {
8780 default: llvm_unreachable("Unknown spelling list index")::llvm::llvm_unreachable_internal("Unknown spelling list index"
, "/build/llvm-toolchain-snapshot-8~svn345461/build-llvm/tools/lldb/../clang/include/clang/AST/Attrs.inc"
, 8780)
;
8781 case 0: return GNU_try_acquire_capability;
8782 case 1: return CXX11_clang_try_acquire_capability;
8783 case 2: return GNU_try_acquire_shared_capability;
8784 case 3: return CXX11_clang_try_acquire_shared_capability;
8785 }
8786 }
8787 bool isShared() const { return SpellingListIndex == 2 ||
8788 SpellingListIndex == 3; }
8789 Expr * getSuccessValue() const {
8790 return successValue;
8791 }
8792
8793 typedef Expr ** args_iterator;
8794 args_iterator args_begin() const { return args_; }
8795 args_iterator args_end() const { return args_ + args_Size; }
8796 unsigned args_size() const { return args_Size; }
8797 llvm::iterator_range<args_iterator> args() const { return llvm::make_range(args_begin(), args_end()); }
8798
8799
8800
8801
8802 static bool classof(const Attr *A) { return A->getKind() == attr::TryAcquireCapability; }
8803};
8804
8805class TypeNonNullAttr : public TypeAttr {
8806public:
8807 static TypeNonNullAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
8808 auto *A = new (Ctx) TypeNonNullAttr(Loc, Ctx, 0);
8809 A->setImplicit(true);
8810 return A;
8811 }
8812
8813 TypeNonNullAttr(SourceRange R, ASTContext &Ctx
8814 , unsigned SI
8815 )
8816 : TypeAttr(attr::TypeNonNull, R, SI, false)
8817 {
8818 }
8819
8820 TypeNonNullAttr *clone(ASTContext &C) const;
8821 void printPretty(raw_ostream &OS,
8822 const PrintingPolicy &Policy) const;
8823 const char *getSpelling() const;
8824
8825
8826 static bool classof(const Attr *A) { return A->getKind() == attr::TypeNonNull; }
8827};
8828
8829class TypeNullUnspecifiedAttr : public TypeAttr {
8830public:
8831 static TypeNullUnspecifiedAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
8832 auto *A = new (Ctx) TypeNullUnspecifiedAttr(Loc, Ctx, 0);
8833 A->setImplicit(true);
8834 return A;
8835 }
8836
8837 TypeNullUnspecifiedAttr(SourceRange R, ASTContext &Ctx
8838 , unsigned SI
8839 )
8840 : TypeAttr(attr::TypeNullUnspecified, R, SI, false)
8841 {
8842 }
8843
8844 TypeNullUnspecifiedAttr *clone(ASTContext &C) const;
8845 void printPretty(raw_ostream &OS,
8846 const PrintingPolicy &Policy) const;
8847 const char *getSpelling() const;
8848
8849
8850 static bool classof(const Attr *A) { return A->getKind() == attr::TypeNullUnspecified; }
8851};
8852
8853class TypeNullableAttr : public TypeAttr {
8854public:
8855 static TypeNullableAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
8856 auto *A = new (Ctx) TypeNullableAttr(Loc, Ctx, 0);
8857 A->setImplicit(true);
8858 return A;
8859 }
8860
8861 TypeNullableAttr(SourceRange R, ASTContext &Ctx
8862 , unsigned SI
8863 )
8864 : TypeAttr(attr::TypeNullable, R, SI, false)
8865 {
8866 }
8867
8868 TypeNullableAttr *clone(ASTContext &C) const;
8869 void printPretty(raw_ostream &OS,
8870 const PrintingPolicy &Policy) const;
8871 const char *getSpelling() const;
8872
8873
8874 static bool classof(const Attr *A) { return A->getKind() == attr::TypeNullable; }
8875};
8876
8877class TypeTagForDatatypeAttr : public InheritableAttr {
8878IdentifierInfo * argumentKind;
8879
8880TypeSourceInfo * matchingCType;
8881
8882bool layoutCompatible;
8883
8884bool mustBeNull;
8885
8886public:
8887 static TypeTagForDatatypeAttr *CreateImplicit(ASTContext &Ctx, IdentifierInfo * ArgumentKind, TypeSourceInfo * MatchingCType, bool LayoutCompatible, bool MustBeNull, SourceRange Loc = SourceRange()) {
8888 auto *A = new (Ctx) TypeTagForDatatypeAttr(Loc, Ctx, ArgumentKind, MatchingCType, LayoutCompatible, MustBeNull, 0);
8889 A->setImplicit(true);
8890 return A;
8891 }
8892
8893 TypeTagForDatatypeAttr(SourceRange R, ASTContext &Ctx
8894 , IdentifierInfo * ArgumentKind
8895 , TypeSourceInfo * MatchingCType
8896 , bool LayoutCompatible
8897 , bool MustBeNull
8898 , unsigned SI
8899 )
8900 : InheritableAttr(attr::TypeTagForDatatype, R, SI, false, false)
8901 , argumentKind(ArgumentKind)
8902 , matchingCType(MatchingCType)
8903 , layoutCompatible(LayoutCompatible)
8904 , mustBeNull(MustBeNull)
8905 {
8906 }
8907
8908 TypeTagForDatatypeAttr *clone(ASTContext &C) const;
8909 void printPretty(raw_ostream &OS,
8910 const PrintingPolicy &Policy) const;
8911 const char *getSpelling() const;
8912 IdentifierInfo * getArgumentKind() const {
8913 return argumentKind;
8914 }
8915
8916 QualType getMatchingCType() const {
8917 return matchingCType->getType();
8918 } TypeSourceInfo * getMatchingCTypeLoc() const {
8919 return matchingCType;
8920 }
8921
8922 bool getLayoutCompatible() const {
8923 return layoutCompatible;
8924 }
8925
8926 bool getMustBeNull() const {
8927 return mustBeNull;
8928 }
8929
8930
8931
8932 static bool classof(const Attr *A) { return A->getKind() == attr::TypeTagForDatatype; }
8933};
8934
8935class TypeVisibilityAttr : public InheritableAttr {
8936public:
8937 enum VisibilityType {
8938 Default,
8939 Hidden,
8940 Protected
8941 };
8942private:
8943 VisibilityType visibility;
8944
8945public:
8946 static TypeVisibilityAttr *CreateImplicit(ASTContext &Ctx, VisibilityType Visibility, SourceRange Loc = SourceRange()) {
8947 auto *A = new (Ctx) TypeVisibilityAttr(Loc, Ctx, Visibility, 0);
8948 A->setImplicit(true);
8949 return A;
8950 }
8951
8952 TypeVisibilityAttr(SourceRange R, ASTContext &Ctx
8953 , VisibilityType Visibility
8954 , unsigned SI
8955 )
8956 : InheritableAttr(attr::TypeVisibility, R, SI, false, false)
8957 , visibility(Visibility)
8958 {
8959 }
8960
8961 TypeVisibilityAttr *clone(ASTContext &C) const;
8962 void printPretty(raw_ostream &OS,
8963 const PrintingPolicy &Policy) const;
8964 const char *getSpelling() const;
8965 VisibilityType getVisibility() const {
8966 return visibility;
8967 }
8968
8969 static bool ConvertStrToVisibilityType(StringRef Val, VisibilityType &Out) {
8970 Optional<VisibilityType> R = llvm::StringSwitch<Optional<VisibilityType>>(Val)
8971 .Case("default", TypeVisibilityAttr::Default)
8972 .Case("hidden", TypeVisibilityAttr::Hidden)
8973 .Case("internal", TypeVisibilityAttr::Hidden)
8974 .Case("protected", TypeVisibilityAttr::Protected)
8975 .Default(Optional<VisibilityType>());
8976 if (R) {
8977 Out = *R;
8978 return true;
8979 }
8980 return false;
8981 }
8982
8983 static const char *ConvertVisibilityTypeToStr(VisibilityType Val) {
8984 switch(Val) {
8985 case TypeVisibilityAttr::Default: return "default";
8986 case TypeVisibilityAttr::Hidden: return "hidden";
8987 case TypeVisibilityAttr::Protected: return "protected";
8988 }
8989 llvm_unreachable("No enumerator with that value")::llvm::llvm_unreachable_internal("No enumerator with that value"
, "/build/llvm-toolchain-snapshot-8~svn345461/build-llvm/tools/lldb/../clang/include/clang/AST/Attrs.inc"
, 8989)
;
8990 }
8991
8992
8993 static bool classof(const Attr *A) { return A->getKind() == attr::TypeVisibility; }
8994};
8995
8996class UPtrAttr : public TypeAttr {
8997public:
8998 static UPtrAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
8999 auto *A = new (Ctx) UPtrAttr(Loc, Ctx, 0);
9000 A->setImplicit(true);
9001 return A;
9002 }
9003
9004 UPtrAttr(SourceRange R, ASTContext &Ctx
9005 , unsigned SI
9006 )
9007 : TypeAttr(attr::UPtr, R, SI, false)
9008 {
9009 }
9010
9011 UPtrAttr *clone(ASTContext &C) const;
9012 void printPretty(raw_ostream &OS,
9013 const PrintingPolicy &Policy) const;
9014 const char *getSpelling() const;
9015
9016
9017 static bool classof(const Attr *A) { return A->getKind() == attr::UPtr; }
9018};
9019
9020class UnavailableAttr : public InheritableAttr {
9021unsigned messageLength;
9022char *message;
9023
9024public:
9025 enum ImplicitReason {
9026 IR_None,
9027 IR_ARCForbiddenType,
9028 IR_ForbiddenWeak,
9029 IR_ARCForbiddenConversion,
9030 IR_ARCInitReturnsUnrelated,
9031 IR_ARCFieldWithOwnership
9032 };
9033private:
9034 ImplicitReason implicitReason;
9035
9036public:
9037 static UnavailableAttr *CreateImplicit(ASTContext &Ctx, llvm::StringRef Message, ImplicitReason ImplicitReason, SourceRange Loc = SourceRange()) {
9038 auto *A = new (Ctx) UnavailableAttr(Loc, Ctx, Message, ImplicitReason, 0);
9039 A->setImplicit(true);
9040 return A;
9041 }
9042
9043 static UnavailableAttr *CreateImplicit(ASTContext &Ctx, llvm::StringRef Message, SourceRange Loc = SourceRange()) {
9044 auto *A = new (Ctx) UnavailableAttr(Loc, Ctx, Message, 0);
9045 A->setImplicit(true);
9046 return A;
9047 }
9048
9049 UnavailableAttr(SourceRange R, ASTContext &Ctx
9050 , llvm::StringRef Message
9051 , ImplicitReason ImplicitReason
9052 , unsigned SI
9053 )
9054 : InheritableAttr(attr::Unavailable, R, SI, false, false)
9055 , messageLength(Message.size()),message(new (Ctx, 1) char[messageLength])
9056 , implicitReason(ImplicitReason)
9057 {
9058 if (!Message.empty())
9059 std::memcpy(message, Message.data(), messageLength);
9060 }
9061
9062 UnavailableAttr(SourceRange R, ASTContext &Ctx
9063 , llvm::StringRef Message
9064 , unsigned SI
9065 )
9066 : InheritableAttr(attr::Unavailable, R, SI, false, false)
9067 , messageLength(Message.size()),message(new (Ctx, 1) char[messageLength])
9068 , implicitReason(ImplicitReason(0))
9069 {
9070 if (!Message.empty())
9071 std::memcpy(message, Message.data(), messageLength);
9072 }
9073
9074 UnavailableAttr(SourceRange R, ASTContext &Ctx
9075 , unsigned SI
9076 )
9077 : InheritableAttr(attr::Unavailable, R, SI, false, false)
9078 , messageLength(0),message(nullptr)
9079 , implicitReason(ImplicitReason(0))
9080 {
9081 }
9082
9083 UnavailableAttr *clone(ASTContext &C) const;
9084 void printPretty(raw_ostream &OS,
9085 const PrintingPolicy &Policy) const;
9086 const char *getSpelling() const;
9087 llvm::StringRef getMessage() const {
9088 return llvm::StringRef(message, messageLength);
9089 }
9090 unsigned getMessageLength() const {
9091 return messageLength;
9092 }
9093 void setMessage(ASTContext &C, llvm::StringRef S) {
9094 messageLength = S.size();
9095 this->message = new (C, 1) char [messageLength];
9096 if (!S.empty())
9097 std::memcpy(this->message, S.data(), messageLength);
9098 }
9099
9100 ImplicitReason getImplicitReason() const {
9101 return implicitReason;
9102 }
9103
9104
9105
9106 static bool classof(const Attr *A) { return A->getKind() == attr::Unavailable; }
9107};
9108
9109class UnusedAttr : public InheritableAttr {
9110public:
9111 enum Spelling {
9112 CXX11_maybe_unused = 0,
9113 GNU_unused = 1,
9114 CXX11_gnu_unused = 2,
9115 C2x_maybe_unused = 3
9116 };
9117
9118 static UnusedAttr *CreateImplicit(ASTContext &Ctx, Spelling S, SourceRange Loc = SourceRange()) {
9119 auto *A = new (Ctx) UnusedAttr(Loc, Ctx, S);
9120 A->setImplicit(true);
9121 return A;
9122 }
9123
9124 UnusedAttr(SourceRange R, ASTContext &Ctx
9125 , unsigned SI
9126 )
9127 : InheritableAttr(attr::Unused, R, SI, false, false)
9128 {
9129 }
9130
9131 UnusedAttr *clone(ASTContext &C) const;
9132 void printPretty(raw_ostream &OS,
9133 const PrintingPolicy &Policy) const;
9134 const char *getSpelling() const;
9135 Spelling getSemanticSpelling() const {
9136 switch (SpellingListIndex) {
9137 default: llvm_unreachable("Unknown spelling list index")::llvm::llvm_unreachable_internal("Unknown spelling list index"
, "/build/llvm-toolchain-snapshot-8~svn345461/build-llvm/tools/lldb/../clang/include/clang/AST/Attrs.inc"
, 9137)
;
9138 case 0: return CXX11_maybe_unused;
9139 case 1: return GNU_unused;
9140 case 2: return CXX11_gnu_unused;
9141 case 3: return C2x_maybe_unused;
9142 }
9143 }
9144
9145
9146 static bool classof(const Attr *A) { return A->getKind() == attr::Unused; }
9147};
9148
9149class UsedAttr : public InheritableAttr {
9150public:
9151 static UsedAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
9152 auto *A = new (Ctx) UsedAttr(Loc, Ctx, 0);
9153 A->setImplicit(true);
9154 return A;
9155 }
9156
9157 UsedAttr(SourceRange R, ASTContext &Ctx
9158 , unsigned SI
9159 )
9160 : InheritableAttr(attr::Used, R, SI, false, false)
9161 {
9162 }
9163
9164 UsedAttr *clone(ASTContext &C) const;
9165 void printPretty(raw_ostream &OS,
9166 const PrintingPolicy &Policy) const;
9167 const char *getSpelling() const;
9168
9169
9170 static bool classof(const Attr *A) { return A->getKind() == attr::Used; }
9171};
9172
9173class UuidAttr : public InheritableAttr {
9174unsigned guidLength;
9175char *guid;
9176
9177public:
9178 static UuidAttr *CreateImplicit(ASTContext &Ctx, llvm::StringRef Guid, SourceRange Loc = SourceRange()) {
9179 auto *A = new (Ctx) UuidAttr(Loc, Ctx, Guid, 0);
9180 A->setImplicit(true);
9181 return A;
9182 }
9183
9184 UuidAttr(SourceRange R, ASTContext &Ctx
9185 , llvm::StringRef Guid
9186 , unsigned SI
9187 )
9188 : InheritableAttr(attr::Uuid, R, SI, false, false)
9189 , guidLength(Guid.size()),guid(new (Ctx, 1) char[guidLength])
9190 {
9191 if (!Guid.empty())
9192 std::memcpy(guid, Guid.data(), guidLength);
9193 }
9194
9195 UuidAttr *clone(ASTContext &C) const;
9196 void printPretty(raw_ostream &OS,
9197 const PrintingPolicy &Policy) const;
9198 const char *getSpelling() const;
9199 llvm::StringRef getGuid() const {
9200 return llvm::StringRef(guid, guidLength);
9201 }
9202 unsigned getGuidLength() const {
9203 return guidLength;
9204 }
9205 void setGuid(ASTContext &C, llvm::StringRef S) {
9206 guidLength = S.size();
9207 this->guid = new (C, 1) char [guidLength];
9208 if (!S.empty())
9209 std::memcpy(this->guid, S.data(), guidLength);
9210 }
9211
9212
9213
9214 static bool classof(const Attr *A) { return A->getKind() == attr::Uuid; }
9215};
9216
9217class VecReturnAttr : public InheritableAttr {
9218public:
9219 static VecReturnAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
9220 auto *A = new (Ctx) VecReturnAttr(Loc, Ctx, 0);
9221 A->setImplicit(true);
9222 return A;
9223 }
9224
9225 VecReturnAttr(SourceRange R, ASTContext &Ctx
9226 , unsigned SI
9227 )
9228 : InheritableAttr(attr::VecReturn, R, SI, false, false)
9229 {
9230 }
9231
9232 VecReturnAttr *clone(ASTContext &C) const;
9233 void printPretty(raw_ostream &OS,
9234 const PrintingPolicy &Policy) const;
9235 const char *getSpelling() const;
9236
9237
9238 static bool classof(const Attr *A) { return A->getKind() == attr::VecReturn; }
9239};
9240
9241class VecTypeHintAttr : public InheritableAttr {
9242TypeSourceInfo * typeHint;
9243
9244public:
9245 static VecTypeHintAttr *CreateImplicit(ASTContext &Ctx, TypeSourceInfo * TypeHint, SourceRange Loc = SourceRange()) {
9246 auto *A = new (Ctx) VecTypeHintAttr(Loc, Ctx, TypeHint, 0);
9247 A->setImplicit(true);
9248 return A;
9249 }
9250
9251 VecTypeHintAttr(SourceRange R, ASTContext &Ctx
9252 , TypeSourceInfo * TypeHint
9253 , unsigned SI
9254 )
9255 : InheritableAttr(attr::VecTypeHint, R, SI, false, false)
9256 , typeHint(TypeHint)
9257 {
9258 }
9259
9260 VecTypeHintAttr *clone(ASTContext &C) const;
9261 void printPretty(raw_ostream &OS,
9262 const PrintingPolicy &Policy) const;
9263 const char *getSpelling() const;
9264 QualType getTypeHint() const {
9265 return typeHint->getType();
9266 } TypeSourceInfo * getTypeHintLoc() const {
9267 return typeHint;
9268 }
9269
9270
9271
9272 static bool classof(const Attr *A) { return A->getKind() == attr::VecTypeHint; }
9273};
9274
9275class VectorCallAttr : public InheritableAttr {
9276public:
9277 static VectorCallAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
9278 auto *A = new (Ctx) VectorCallAttr(Loc, Ctx, 0);
9279 A->setImplicit(true);
9280 return A;
9281 }
9282
9283 VectorCallAttr(SourceRange R, ASTContext &Ctx
9284 , unsigned SI
9285 )
9286 : InheritableAttr(attr::VectorCall, R, SI, false, false)
9287 {
9288 }
9289
9290 VectorCallAttr *clone(ASTContext &C) const;
9291 void printPretty(raw_ostream &OS,
9292 const PrintingPolicy &Policy) const;
9293 const char *getSpelling() const;
9294
9295
9296 static bool classof(const Attr *A) { return A->getKind() == attr::VectorCall; }
9297};
9298
9299class VisibilityAttr : public InheritableAttr {
9300public:
9301 enum VisibilityType {
9302 Default,
9303 Hidden,
9304 Protected
9305 };
9306private:
9307 VisibilityType visibility;
9308
9309public:
9310 static VisibilityAttr *CreateImplicit(ASTContext &Ctx, VisibilityType Visibility, SourceRange Loc = SourceRange()) {
9311 auto *A = new (Ctx) VisibilityAttr(Loc, Ctx, Visibility, 0);
9312 A->setImplicit(true);
9313 return A;
9314 }
9315
9316 VisibilityAttr(SourceRange R, ASTContext &Ctx
9317 , VisibilityType Visibility
9318 , unsigned SI
9319 )
9320 : InheritableAttr(attr::Visibility, R, SI, false, false)
9321 , visibility(Visibility)
9322 {
9323 }
9324
9325 VisibilityAttr *clone(ASTContext &C) const;
9326 void printPretty(raw_ostream &OS,
9327 const PrintingPolicy &Policy) const;
9328 const char *getSpelling() const;
9329 VisibilityType getVisibility() const {
9330 return visibility;
9331 }
9332
9333 static bool ConvertStrToVisibilityType(StringRef Val, VisibilityType &Out) {
9334 Optional<VisibilityType> R = llvm::StringSwitch<Optional<VisibilityType>>(Val)
9335 .Case("default", VisibilityAttr::Default)
9336 .Case("hidden", VisibilityAttr::Hidden)
9337 .Case("internal", VisibilityAttr::Hidden)
9338 .Case("protected", VisibilityAttr::Protected)
9339 .Default(Optional<VisibilityType>());
9340 if (R) {
9341 Out = *R;
9342 return true;
9343 }
9344 return false;
9345 }
9346
9347 static const char *ConvertVisibilityTypeToStr(VisibilityType Val) {
9348 switch(Val) {
9349 case VisibilityAttr::Default: return "default";
9350 case VisibilityAttr::Hidden: return "hidden";
9351 case VisibilityAttr::Protected: return "protected";
9352 }
9353 llvm_unreachable("No enumerator with that value")::llvm::llvm_unreachable_internal("No enumerator with that value"
, "/build/llvm-toolchain-snapshot-8~svn345461/build-llvm/tools/lldb/../clang/include/clang/AST/Attrs.inc"
, 9353)
;
9354 }
9355
9356
9357 static bool classof(const Attr *A) { return A->getKind() == attr::Visibility; }
9358};
9359
9360class WarnUnusedAttr : public InheritableAttr {
9361public:
9362 static WarnUnusedAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
9363 auto *A = new (Ctx) WarnUnusedAttr(Loc, Ctx, 0);
9364 A->setImplicit(true);
9365 return A;
9366 }
9367
9368 WarnUnusedAttr(SourceRange R, ASTContext &Ctx
9369 , unsigned SI
9370 )
9371 : InheritableAttr(attr::WarnUnused, R, SI, false, false)
9372 {
9373 }
9374
9375 WarnUnusedAttr *clone(ASTContext &C) const;
9376 void printPretty(raw_ostream &OS,
9377 const PrintingPolicy &Policy) const;
9378 const char *getSpelling() const;
9379
9380
9381 static bool classof(const Attr *A) { return A->getKind() == attr::WarnUnused; }
9382};
9383
9384class WarnUnusedResultAttr : public InheritableAttr {
9385public:
9386 enum Spelling {
9387 CXX11_nodiscard = 0,
9388 C2x_nodiscard = 1,
9389 CXX11_clang_warn_unused_result = 2,
9390 GNU_warn_unused_result = 3,
9391 CXX11_gnu_warn_unused_result = 4
9392 };
9393
9394 static WarnUnusedResultAttr *CreateImplicit(ASTContext &Ctx, Spelling S, SourceRange Loc = SourceRange()) {
9395 auto *A = new (Ctx) WarnUnusedResultAttr(Loc, Ctx, S);
9396 A->setImplicit(true);
9397 return A;
9398 }
9399
9400 WarnUnusedResultAttr(SourceRange R, ASTContext &Ctx
9401 , unsigned SI
9402 )
9403 : InheritableAttr(attr::WarnUnusedResult, R, SI, false, false)
9404 {
9405 }
9406
9407 WarnUnusedResultAttr *clone(ASTContext &C) const;
9408 void printPretty(raw_ostream &OS,
9409 const PrintingPolicy &Policy) const;
9410 const char *getSpelling() const;
9411 Spelling getSemanticSpelling() const {
9412 switch (SpellingListIndex) {
9413 default: llvm_unreachable("Unknown spelling list index")::llvm::llvm_unreachable_internal("Unknown spelling list index"
, "/build/llvm-toolchain-snapshot-8~svn345461/build-llvm/tools/lldb/../clang/include/clang/AST/Attrs.inc"
, 9413)
;
9414 case 0: return CXX11_nodiscard;
9415 case 1: return C2x_nodiscard;
9416 case 2: return CXX11_clang_warn_unused_result;
9417 case 3: return GNU_warn_unused_result;
9418 case 4: return CXX11_gnu_warn_unused_result;
9419 }
9420 }
9421
9422
9423 static bool classof(const Attr *A) { return A->getKind() == attr::WarnUnusedResult; }
9424};
9425
9426class WeakAttr : public InheritableAttr {
9427public:
9428 static WeakAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
9429 auto *A = new (Ctx) WeakAttr(Loc, Ctx, 0);
9430 A->setImplicit(true);
9431 return A;
9432 }
9433
9434 WeakAttr(SourceRange R, ASTContext &Ctx
9435 , unsigned SI
9436 )
9437 : InheritableAttr(attr::Weak, R, SI, false, false)
9438 {
9439 }
9440
9441 WeakAttr *clone(ASTContext &C) const;
9442 void printPretty(raw_ostream &OS,
9443 const PrintingPolicy &Policy) const;
9444 const char *getSpelling() const;
9445
9446
9447 static bool classof(const Attr *A) { return A->getKind() == attr::Weak; }
9448};
9449
9450class WeakImportAttr : public InheritableAttr {
9451public:
9452 static WeakImportAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
9453 auto *A = new (Ctx) WeakImportAttr(Loc, Ctx, 0);
9454 A->setImplicit(true);
9455 return A;
9456 }
9457
9458 WeakImportAttr(SourceRange R, ASTContext &Ctx
9459 , unsigned SI
9460 )
9461 : InheritableAttr(attr::WeakImport, R, SI, false, false)
9462 {
9463 }
9464
9465 WeakImportAttr *clone(ASTContext &C) const;
9466 void printPretty(raw_ostream &OS,
9467 const PrintingPolicy &Policy) const;
9468 const char *getSpelling() const;
9469
9470
9471 static bool classof(const Attr *A) { return A->getKind() == attr::WeakImport; }
9472};
9473
9474class WeakRefAttr : public InheritableAttr {
9475unsigned aliaseeLength;
9476char *aliasee;
9477
9478public:
9479 static WeakRefAttr *CreateImplicit(ASTContext &Ctx, llvm::StringRef Aliasee, SourceRange Loc = SourceRange()) {
9480 auto *A = new (Ctx) WeakRefAttr(Loc, Ctx, Aliasee, 0);
9481 A->setImplicit(true);
9482 return A;
9483 }
9484
9485 WeakRefAttr(SourceRange R, ASTContext &Ctx
9486 , llvm::StringRef Aliasee
9487 , unsigned SI
9488 )
9489 : InheritableAttr(attr::WeakRef, R, SI, false, false)
9490 , aliaseeLength(Aliasee.size()),aliasee(new (Ctx, 1) char[aliaseeLength])
9491 {
9492 if (!Aliasee.empty())
9493 std::memcpy(aliasee, Aliasee.data(), aliaseeLength);
9494 }
9495
9496 WeakRefAttr(SourceRange R, ASTContext &Ctx
9497 , unsigned SI
9498 )
9499 : InheritableAttr(attr::WeakRef, R, SI, false, false)
9500 , aliaseeLength(0),aliasee(nullptr)
9501 {
9502 }
9503
9504 WeakRefAttr *clone(ASTContext &C) const;
9505 void printPretty(raw_ostream &OS,
9506 const PrintingPolicy &Policy) const;
9507 const char *getSpelling() const;
9508 llvm::StringRef getAliasee() const {
9509 return llvm::StringRef(aliasee, aliaseeLength);
9510 }
9511 unsigned getAliaseeLength() const {
9512 return aliaseeLength;
9513 }
9514 void setAliasee(ASTContext &C, llvm::StringRef S) {
9515 aliaseeLength = S.size();
9516 this->aliasee = new (C, 1) char [aliaseeLength];
9517 if (!S.empty())
9518 std::memcpy(this->aliasee, S.data(), aliaseeLength);
9519 }
9520
9521
9522
9523 static bool classof(const Attr *A) { return A->getKind() == attr::WeakRef; }
9524};
9525
9526class WorkGroupSizeHintAttr : public InheritableAttr {
9527unsigned xDim;
9528
9529unsigned yDim;
9530
9531unsigned zDim;
9532
9533public:
9534 static WorkGroupSizeHintAttr *CreateImplicit(ASTContext &Ctx, unsigned XDim, unsigned YDim, unsigned ZDim, SourceRange Loc = SourceRange()) {
9535 auto *A = new (Ctx) WorkGroupSizeHintAttr(Loc, Ctx, XDim, YDim, ZDim, 0);
9536 A->setImplicit(true);
9537 return A;
9538 }
9539
9540 WorkGroupSizeHintAttr(SourceRange R, ASTContext &Ctx
9541 , unsigned XDim
9542 , unsigned YDim
9543 , unsigned ZDim
9544 , unsigned SI
9545 )
9546 : InheritableAttr(attr::WorkGroupSizeHint, R, SI, false, false)
9547 , xDim(XDim)
9548 , yDim(YDim)
9549 , zDim(ZDim)
9550 {
9551 }
9552
9553 WorkGroupSizeHintAttr *clone(ASTContext &C) const;
9554 void printPretty(raw_ostream &OS,
9555 const PrintingPolicy &Policy) const;
9556 const char *getSpelling() const;
9557 unsigned getXDim() const {
9558 return xDim;
9559 }
9560
9561 unsigned getYDim() const {
9562 return yDim;
9563 }
9564
9565 unsigned getZDim() const {
9566 return zDim;
9567 }
9568
9569
9570
9571 static bool classof(const Attr *A) { return A->getKind() == attr::WorkGroupSizeHint; }
9572};
9573
9574class X86ForceAlignArgPointerAttr : public InheritableAttr {
9575public:
9576 static X86ForceAlignArgPointerAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
9577 auto *A = new (Ctx) X86ForceAlignArgPointerAttr(Loc, Ctx, 0);
9578 A->setImplicit(true);
9579 return A;
9580 }
9581
9582 X86ForceAlignArgPointerAttr(SourceRange R, ASTContext &Ctx
9583 , unsigned SI
9584 )
9585 : InheritableAttr(attr::X86ForceAlignArgPointer, R, SI, false, false)
9586 {
9587 }
9588
9589 X86ForceAlignArgPointerAttr *clone(ASTContext &C) const;
9590 void printPretty(raw_ostream &OS,
9591 const PrintingPolicy &Policy) const;
9592 const char *getSpelling() const;
9593
9594
9595 static bool classof(const Attr *A) { return A->getKind() == attr::X86ForceAlignArgPointer; }
9596};
9597
9598class XRayInstrumentAttr : public InheritableAttr {
9599public:
9600 enum Spelling {
9601 GNU_xray_always_instrument = 0,
9602 CXX11_clang_xray_always_instrument = 1,
9603 C2x_clang_xray_always_instrument = 2,
9604 GNU_xray_never_instrument = 3,
9605 CXX11_clang_xray_never_instrument = 4,
9606 C2x_clang_xray_never_instrument = 5
9607 };
9608
9609 static XRayInstrumentAttr *CreateImplicit(ASTContext &Ctx, Spelling S, SourceRange Loc = SourceRange()) {
9610 auto *A = new (Ctx) XRayInstrumentAttr(Loc, Ctx, S);
9611 A->setImplicit(true);
9612 return A;
9613 }
9614
9615 XRayInstrumentAttr(SourceRange R, ASTContext &Ctx
9616 , unsigned SI
9617 )
9618 : InheritableAttr(attr::XRayInstrument, R, SI, false, false)
9619 {
9620 }
9621
9622 XRayInstrumentAttr *clone(ASTContext &C) const;
9623 void printPretty(raw_ostream &OS,
9624 const PrintingPolicy &Policy) const;
9625 const char *getSpelling() const;
9626 Spelling getSemanticSpelling() const {
9627 switch (SpellingListIndex) {
9628 default: llvm_unreachable("Unknown spelling list index")::llvm::llvm_unreachable_internal("Unknown spelling list index"
, "/build/llvm-toolchain-snapshot-8~svn345461/build-llvm/tools/lldb/../clang/include/clang/AST/Attrs.inc"
, 9628)
;
9629 case 0: return GNU_xray_always_instrument;
9630 case 1: return CXX11_clang_xray_always_instrument;
9631 case 2: return C2x_clang_xray_always_instrument;
9632 case 3: return GNU_xray_never_instrument;
9633 case 4: return CXX11_clang_xray_never_instrument;
9634 case 5: return C2x_clang_xray_never_instrument;
9635 }
9636 }
9637 bool alwaysXRayInstrument() const { return SpellingListIndex == 0 ||
9638 SpellingListIndex == 1 ||
9639 SpellingListIndex == 2; }
9640 bool neverXRayInstrument() const { return SpellingListIndex == 3 ||
9641 SpellingListIndex == 4 ||
9642 SpellingListIndex == 5; }
9643
9644
9645 static bool classof(const Attr *A) { return A->getKind() == attr::XRayInstrument; }
9646};
9647
9648class XRayLogArgsAttr : public InheritableAttr {
9649unsigned argumentCount;
9650
9651public:
9652 static XRayLogArgsAttr *CreateImplicit(ASTContext &Ctx, unsigned ArgumentCount, SourceRange Loc = SourceRange()) {
9653 auto *A = new (Ctx) XRayLogArgsAttr(Loc, Ctx, ArgumentCount, 0);
9654 A->setImplicit(true);
9655 return A;
9656 }
9657
9658 XRayLogArgsAttr(SourceRange R, ASTContext &Ctx
9659 , unsigned ArgumentCount
9660 , unsigned SI
9661 )
9662 : InheritableAttr(attr::XRayLogArgs, R, SI, false, false)
9663 , argumentCount(ArgumentCount)
9664 {
9665 }
9666
9667 XRayLogArgsAttr *clone(ASTContext &C) const;
9668 void printPretty(raw_ostream &OS,
9669 const PrintingPolicy &Policy) const;
9670 const char *getSpelling() const;
9671 unsigned getArgumentCount() const {
9672 return argumentCount;
9673 }
9674
9675
9676
9677 static bool classof(const Attr *A) { return A->getKind() == attr::XRayLogArgs; }
9678};
9679
9680#endif // LLVM_CLANG_ATTR_CLASSES_INC