clang 17.0.0git
Go to the documentation of this file.
2#include "clang/AST/Type.h"
5#include "clang/Lex/Lexer.h"
6#include <optional>
8using namespace clang;
10void JSONNodeDumper::addPreviousDeclaration(const Decl *D) {
11 switch (D->getKind()) {
12#define DECL(DERIVED, BASE) \
13 case Decl::DERIVED: \
14 return writePreviousDeclImpl(cast<DERIVED##Decl>(D));
16#include "clang/AST/"
18#undef DECL
19 }
20 llvm_unreachable("Decl that isn't part of!");
24 const char *AttrName = nullptr;
25 switch (A->getKind()) {
26#define ATTR(X) \
27 case attr::X: \
28 AttrName = #X"Attr"; \
29 break;
30#include "clang/Basic/"
31#undef ATTR
32 }
33 JOS.attribute("id", createPointerRepresentation(A));
34 JOS.attribute("kind", AttrName);
35 JOS.attributeObject("range", [A, this] { writeSourceRange(A->getRange()); });
36 attributeOnlyIfTrue("inherited", A->isInherited());
37 attributeOnlyIfTrue("implicit", A->isImplicit());
39 // FIXME: it would be useful for us to output the spelling kind as well as
40 // the actual spelling. This would allow us to distinguish between the
41 // various attribute syntaxes, but we don't currently track that information
42 // within the AST.
43 //JOS.attribute("spelling", A->getSpelling());
49 if (!S)
50 return;
52 JOS.attribute("id", createPointerRepresentation(S));
53 JOS.attribute("kind", S->getStmtClassName());
54 JOS.attributeObject("range",
55 [S, this] { writeSourceRange(S->getSourceRange()); });
57 if (const auto *E = dyn_cast<Expr>(S)) {
58 JOS.attribute("type", createQualType(E->getType()));
59 const char *Category = nullptr;
60 switch (E->getValueKind()) {
61 case VK_LValue: Category = "lvalue"; break;
62 case VK_XValue: Category = "xvalue"; break;
63 case VK_PRValue:
64 Category = "prvalue";
65 break;
66 }
67 JOS.attribute("valueCategory", Category);
68 }
73 JOS.attribute("id", createPointerRepresentation(T));
75 if (!T)
76 return;
78 JOS.attribute("kind", (llvm::Twine(T->getTypeClassName()) + "Type").str());
79 JOS.attribute("type", createQualType(QualType(T, 0), /*Desugar*/ false));
80 attributeOnlyIfTrue("containsErrors", T->containsErrors());
81 attributeOnlyIfTrue("isDependent", T->isDependentType());
82 attributeOnlyIfTrue("isInstantiationDependent",
84 attributeOnlyIfTrue("isVariablyModified", T->isVariablyModifiedType());
85 attributeOnlyIfTrue("containsUnexpandedPack",
87 attributeOnlyIfTrue("isImported", T->isFromAST());
92 JOS.attribute("id", createPointerRepresentation(T.getAsOpaquePtr()));
93 JOS.attribute("kind", "QualType");
94 JOS.attribute("type", createQualType(T));
95 JOS.attribute("qualifiers", T.split().Quals.getAsString());
99 JOS.attribute("id", createPointerRepresentation(D));
101 if (!D)
102 return;
104 JOS.attribute("kind", (llvm::Twine(D->getDeclKindName()) + "Decl").str());
105 JOS.attributeObject("loc",
106 [D, this] { writeSourceLocation(D->getLocation()); });
107 JOS.attributeObject("range",
108 [D, this] { writeSourceRange(D->getSourceRange()); });
109 attributeOnlyIfTrue("isImplicit", D->isImplicit());
110 attributeOnlyIfTrue("isInvalid", D->isInvalidDecl());
112 if (D->isUsed())
113 JOS.attribute("isUsed", true);
114 else if (D->isThisDeclarationReferenced())
115 JOS.attribute("isReferenced", true);
117 if (const auto *ND = dyn_cast<NamedDecl>(D))
118 attributeOnlyIfTrue("isHidden", !ND->isUnconditionallyVisible());
120 if (D->getLexicalDeclContext() != D->getDeclContext()) {
121 // Because of multiple inheritance, a DeclContext pointer does not produce
122 // the same pointer representation as a Decl pointer that references the
123 // same AST Node.
124 const auto *ParentDeclContextDecl = dyn_cast<Decl>(D->getDeclContext());
125 JOS.attribute("parentDeclContextId",
126 createPointerRepresentation(ParentDeclContextDecl));
127 }
129 addPreviousDeclaration(D);
134 const comments::FullComment *FC) {
135 if (!C)
136 return;
138 JOS.attribute("id", createPointerRepresentation(C));
139 JOS.attribute("kind", C->getCommentKindName());
140 JOS.attributeObject("loc",
141 [C, this] { writeSourceLocation(C->getLocation()); });
142 JOS.attributeObject("range",
143 [C, this] { writeSourceRange(C->getSourceRange()); });
149 const Decl *From, StringRef Label) {
150 JOS.attribute("kind", "TemplateArgument");
151 if (R.isValid())
152 JOS.attributeObject("range", [R, this] { writeSourceRange(R); });
154 if (From)
155 JOS.attribute(Label.empty() ? "fromDecl" : Label, createBareDeclRef(From));
161 JOS.attribute("kind", "CXXCtorInitializer");
162 if (Init->isAnyMemberInitializer())
163 JOS.attribute("anyInit", createBareDeclRef(Init->getAnyMember()));
164 else if (Init->isBaseInitializer())
165 JOS.attribute("baseInit",
166 createQualType(QualType(Init->getBaseClass(), 0)));
167 else if (Init->isDelegatingInitializer())
168 JOS.attribute("delegatingInit",
169 createQualType(Init->getTypeSourceInfo()->getType()));
170 else
171 llvm_unreachable("Unknown initializer type");
177 JOS.attribute("kind", "Capture");
178 attributeOnlyIfTrue("byref", C.isByRef());
179 attributeOnlyIfTrue("nested", C.isNested());
180 if (C.getVariable())
181 JOS.attribute("var", createBareDeclRef(C.getVariable()));
185 JOS.attribute("associationKind", A.getTypeSourceInfo() ? "case" : "default");
186 attributeOnlyIfTrue("selected", A.isSelected());
190 if (!R)
191 return;
193 switch (R->getKind()) {
195 JOS.attribute("kind", "TypeRequirement");
196 break;
198 JOS.attribute("kind", "SimpleRequirement");
199 break;
201 JOS.attribute("kind", "CompoundRequirement");
202 break;
204 JOS.attribute("kind", "NestedRequirement");
205 break;
206 }
208 if (auto *ER = dyn_cast<concepts::ExprRequirement>(R))
209 attributeOnlyIfTrue("noexcept", ER->hasNoexceptRequirement());
211 attributeOnlyIfTrue("isDependent", R->isDependent());
212 if (!R->isDependent())
213 JOS.attribute("satisfied", R->isSatisfied());
214 attributeOnlyIfTrue("containsUnexpandedPack",
219 std::string Str;
220 llvm::raw_string_ostream OS(Str);
221 Value.printPretty(OS, Ctx, Ty);
222 JOS.attribute("value", OS.str());
225void JSONNodeDumper::writeIncludeStack(PresumedLoc Loc, bool JustFirst) {
226 if (Loc.isInvalid())
227 return;
229 JOS.attributeBegin("includedFrom");
230 JOS.objectBegin();
232 if (!JustFirst) {
233 // Walk the stack recursively, then print out the presumed location.
234 writeIncludeStack(SM.getPresumedLoc(Loc.getIncludeLoc()));
235 }
237 JOS.attribute("file", Loc.getFilename());
238 JOS.objectEnd();
239 JOS.attributeEnd();
242void JSONNodeDumper::writeBareSourceLocation(SourceLocation Loc,
243 bool IsSpelling) {
244 PresumedLoc Presumed = SM.getPresumedLoc(Loc);
245 unsigned ActualLine = IsSpelling ? SM.getSpellingLineNumber(Loc)
246 : SM.getExpansionLineNumber(Loc);
247 StringRef ActualFile = SM.getBufferName(Loc);
249 if (Presumed.isValid()) {
250 JOS.attribute("offset", SM.getDecomposedLoc(Loc).second);
251 if (LastLocFilename != ActualFile) {
252 JOS.attribute("file", ActualFile);
253 JOS.attribute("line", ActualLine);
254 } else if (LastLocLine != ActualLine)
255 JOS.attribute("line", ActualLine);
257 StringRef PresumedFile = Presumed.getFilename();
258 if (PresumedFile != ActualFile && LastLocPresumedFilename != PresumedFile)
259 JOS.attribute("presumedFile", PresumedFile);
261 unsigned PresumedLine = Presumed.getLine();
262 if (ActualLine != PresumedLine && LastLocPresumedLine != PresumedLine)
263 JOS.attribute("presumedLine", PresumedLine);
265 JOS.attribute("col", Presumed.getColumn());
266 JOS.attribute("tokLen",
267 Lexer::MeasureTokenLength(Loc, SM, Ctx.getLangOpts()));
268 LastLocFilename = ActualFile;
269 LastLocPresumedFilename = PresumedFile;
270 LastLocPresumedLine = PresumedLine;
271 LastLocLine = ActualLine;
273 // Orthogonal to the file, line, and column de-duplication is whether the
274 // given location was a result of an include. If so, print where the
275 // include location came from.
276 writeIncludeStack(SM.getPresumedLoc(Presumed.getIncludeLoc()),
277 /*JustFirst*/ true);
278 }
281void JSONNodeDumper::writeSourceLocation(SourceLocation Loc) {
282 SourceLocation Spelling = SM.getSpellingLoc(Loc);
283 SourceLocation Expansion = SM.getExpansionLoc(Loc);
285 if (Expansion != Spelling) {
286 // If the expansion and the spelling are different, output subobjects
287 // describing both locations.
288 JOS.attributeObject("spellingLoc", [Spelling, this] {
289 writeBareSourceLocation(Spelling, /*IsSpelling*/ true);
290 });
291 JOS.attributeObject("expansionLoc", [Expansion, Loc, this] {
292 writeBareSourceLocation(Expansion, /*IsSpelling*/ false);
293 // If there is a macro expansion, add extra information if the interesting
294 // bit is the macro arg expansion.
295 if (SM.isMacroArgExpansion(Loc))
296 JOS.attribute("isMacroArgExpansion", true);
297 });
298 } else
299 writeBareSourceLocation(Spelling, /*IsSpelling*/ true);
302void JSONNodeDumper::writeSourceRange(SourceRange R) {
303 JOS.attributeObject("begin",
304 [R, this] { writeSourceLocation(R.getBegin()); });
305 JOS.attributeObject("end", [R, this] { writeSourceLocation(R.getEnd()); });
308std::string JSONNodeDumper::createPointerRepresentation(const void *Ptr) {
309 // Because JSON stores integer values as signed 64-bit integers, trying to
310 // represent them as such makes for very ugly pointer values in the resulting
311 // output. Instead, we convert the value to hex and treat it as a string.
312 return "0x" + llvm::utohexstr(reinterpret_cast<uint64_t>(Ptr), true);
315llvm::json::Object JSONNodeDumper::createQualType(QualType QT, bool Desugar) {
316 SplitQualType SQT = QT.split();
317 llvm::json::Object Ret{{"qualType", QualType::getAsString(SQT, PrintPolicy)}};
319 if (Desugar && !QT.isNull()) {
321 if (DSQT != SQT)
322 Ret["desugaredQualType"] = QualType::getAsString(DSQT, PrintPolicy);
323 if (const auto *TT = QT->getAs<TypedefType>())
324 Ret["typeAliasDeclId"] = createPointerRepresentation(TT->getDecl());
325 }
326 return Ret;
329void JSONNodeDumper::writeBareDeclRef(const Decl *D) {
330 JOS.attribute("id", createPointerRepresentation(D));
331 if (!D)
332 return;
334 JOS.attribute("kind", (llvm::Twine(D->getDeclKindName()) + "Decl").str());
335 if (const auto *ND = dyn_cast<NamedDecl>(D))
336 JOS.attribute("name", ND->getDeclName().getAsString());
337 if (const auto *VD = dyn_cast<ValueDecl>(D))
338 JOS.attribute("type", createQualType(VD->getType()));
341llvm::json::Object JSONNodeDumper::createBareDeclRef(const Decl *D) {
342 llvm::json::Object Ret{{"id", createPointerRepresentation(D)}};
343 if (!D)
344 return Ret;
346 Ret["kind"] = (llvm::Twine(D->getDeclKindName()) + "Decl").str();
347 if (const auto *ND = dyn_cast<NamedDecl>(D))
348 Ret["name"] = ND->getDeclName().getAsString();
349 if (const auto *VD = dyn_cast<ValueDecl>(D))
350 Ret["type"] = createQualType(VD->getType());
351 return Ret;
354llvm::json::Array JSONNodeDumper::createCastPath(const CastExpr *C) {
355 llvm::json::Array Ret;
356 if (C->path_empty())
357 return Ret;
359 for (auto I = C->path_begin(), E = C->path_end(); I != E; ++I) {
360 const CXXBaseSpecifier *Base = *I;
361 const auto *RD =
362 cast<CXXRecordDecl>(Base->getType()->castAs<RecordType>()->getDecl());
364 llvm::json::Object Val{{"name", RD->getName()}};
365 if (Base->isVirtual())
366 Val["isVirtual"] = true;
367 Ret.push_back(std::move(Val));
368 }
369 return Ret;
372#define FIELD2(Name, Flag) if (RD->Flag()) Ret[Name] = true
373#define FIELD1(Flag) FIELD2(#Flag, Flag)
375static llvm::json::Object
377 llvm::json::Object Ret;
379 FIELD2("exists", hasDefaultConstructor);
380 FIELD2("trivial", hasTrivialDefaultConstructor);
381 FIELD2("nonTrivial", hasNonTrivialDefaultConstructor);
382 FIELD2("userProvided", hasUserProvidedDefaultConstructor);
383 FIELD2("isConstexpr", hasConstexprDefaultConstructor);
384 FIELD2("needsImplicit", needsImplicitDefaultConstructor);
385 FIELD2("defaultedIsConstexpr", defaultedDefaultConstructorIsConstexpr);
387 return Ret;
390static llvm::json::Object
392 llvm::json::Object Ret;
394 FIELD2("simple", hasSimpleCopyConstructor);
395 FIELD2("trivial", hasTrivialCopyConstructor);
396 FIELD2("nonTrivial", hasNonTrivialCopyConstructor);
397 FIELD2("userDeclared", hasUserDeclaredCopyConstructor);
398 FIELD2("hasConstParam", hasCopyConstructorWithConstParam);
399 FIELD2("implicitHasConstParam", implicitCopyConstructorHasConstParam);
400 FIELD2("needsImplicit", needsImplicitCopyConstructor);
401 FIELD2("needsOverloadResolution", needsOverloadResolutionForCopyConstructor);
403 FIELD2("defaultedIsDeleted", defaultedCopyConstructorIsDeleted);
405 return Ret;
408static llvm::json::Object
410 llvm::json::Object Ret;
412 FIELD2("exists", hasMoveConstructor);
413 FIELD2("simple", hasSimpleMoveConstructor);
414 FIELD2("trivial", hasTrivialMoveConstructor);
415 FIELD2("nonTrivial", hasNonTrivialMoveConstructor);
416 FIELD2("userDeclared", hasUserDeclaredMoveConstructor);
417 FIELD2("needsImplicit", needsImplicitMoveConstructor);
418 FIELD2("needsOverloadResolution", needsOverloadResolutionForMoveConstructor);
420 FIELD2("defaultedIsDeleted", defaultedMoveConstructorIsDeleted);
422 return Ret;
425static llvm::json::Object
427 llvm::json::Object Ret;
429 FIELD2("simple", hasSimpleCopyAssignment);
430 FIELD2("trivial", hasTrivialCopyAssignment);
431 FIELD2("nonTrivial", hasNonTrivialCopyAssignment);
432 FIELD2("hasConstParam", hasCopyAssignmentWithConstParam);
433 FIELD2("implicitHasConstParam", implicitCopyAssignmentHasConstParam);
434 FIELD2("userDeclared", hasUserDeclaredCopyAssignment);
435 FIELD2("needsImplicit", needsImplicitCopyAssignment);
436 FIELD2("needsOverloadResolution", needsOverloadResolutionForCopyAssignment);
438 return Ret;
441static llvm::json::Object
443 llvm::json::Object Ret;
445 FIELD2("exists", hasMoveAssignment);
446 FIELD2("simple", hasSimpleMoveAssignment);
447 FIELD2("trivial", hasTrivialMoveAssignment);
448 FIELD2("nonTrivial", hasNonTrivialMoveAssignment);
449 FIELD2("userDeclared", hasUserDeclaredMoveAssignment);
450 FIELD2("needsImplicit", needsImplicitMoveAssignment);
451 FIELD2("needsOverloadResolution", needsOverloadResolutionForMoveAssignment);
453 return Ret;
456static llvm::json::Object
458 llvm::json::Object Ret;
460 FIELD2("simple", hasSimpleDestructor);
461 FIELD2("irrelevant", hasIrrelevantDestructor);
462 FIELD2("trivial", hasTrivialDestructor);
463 FIELD2("nonTrivial", hasNonTrivialDestructor);
464 FIELD2("userDeclared", hasUserDeclaredDestructor);
465 FIELD2("needsImplicit", needsImplicitDestructor);
466 FIELD2("needsOverloadResolution", needsOverloadResolutionForDestructor);
468 FIELD2("defaultedIsDeleted", defaultedDestructorIsDeleted);
470 return Ret;
474JSONNodeDumper::createCXXRecordDefinitionData(const CXXRecordDecl *RD) {
475 llvm::json::Object Ret;
477 // This data is common to all C++ classes.
478 FIELD1(isGenericLambda);
479 FIELD1(isLambda);
480 FIELD1(isEmpty);
481 FIELD1(isAggregate);
482 FIELD1(isStandardLayout);
483 FIELD1(isTriviallyCopyable);
484 FIELD1(isPOD);
486 FIELD1(isPolymorphic);
487 FIELD1(isAbstract);
488 FIELD1(isLiteral);
490 FIELD1(hasUserDeclaredConstructor);
491 FIELD1(hasConstexprNonCopyMoveConstructor);
492 FIELD1(hasMutableFields);
493 FIELD1(hasVariantMembers);
494 FIELD2("canConstDefaultInit", allowConstDefaultInit);
496 Ret["defaultCtor"] = createDefaultConstructorDefinitionData(RD);
499 Ret["copyAssign"] = createCopyAssignmentDefinitionData(RD);
500 Ret["moveAssign"] = createMoveAssignmentDefinitionData(RD);
503 return Ret;
506#undef FIELD1
507#undef FIELD2
509std::string JSONNodeDumper::createAccessSpecifier(AccessSpecifier AS) {
510 const auto AccessSpelling = getAccessSpelling(AS);
511 if (AccessSpelling.empty())
512 return "none";
513 return AccessSpelling.str();
517JSONNodeDumper::createCXXBaseSpecifier(const CXXBaseSpecifier &BS) {
518 llvm::json::Object Ret;
520 Ret["type"] = createQualType(BS.getType());
521 Ret["access"] = createAccessSpecifier(BS.getAccessSpecifier());
522 Ret["writtenAccess"] =
523 createAccessSpecifier(BS.getAccessSpecifierAsWritten());
524 if (BS.isVirtual())
525 Ret["isVirtual"] = true;
526 if (BS.isPackExpansion())
527 Ret["isPackExpansion"] = true;
529 return Ret;
533 JOS.attribute("decl", createBareDeclRef(TT->getDecl()));
534 if (!TT->typeMatchesDecl())
535 JOS.attribute("type", createQualType(TT->desugar()));
539 JOS.attribute("decl", createBareDeclRef(TT->getFoundDecl()));
540 if (!TT->typeMatchesDecl())
541 JOS.attribute("type", createQualType(TT->desugar()));
546 attributeOnlyIfTrue("noreturn", E.getNoReturn());
547 attributeOnlyIfTrue("producesResult", E.getProducesResult());
548 if (E.getHasRegParm())
549 JOS.attribute("regParm", E.getRegParm());
550 JOS.attribute("cc", FunctionType::getNameForCallConv(E.getCC()));
555 attributeOnlyIfTrue("trailingReturn", E.HasTrailingReturn);
556 attributeOnlyIfTrue("const", T->isConst());
557 attributeOnlyIfTrue("volatile", T->isVolatile());
558 attributeOnlyIfTrue("restrict", T->isRestrict());
559 attributeOnlyIfTrue("variadic", E.Variadic);
560 switch (E.RefQualifier) {
561 case RQ_LValue: JOS.attribute("refQualifier", "&"); break;
562 case RQ_RValue: JOS.attribute("refQualifier", "&&"); break;
563 case RQ_None: break;
564 }
565 switch (E.ExceptionSpec.Type) {
566 case EST_DynamicNone:
567 case EST_Dynamic: {
568 JOS.attribute("exceptionSpec", "throw");
569 llvm::json::Array Types;
571 Types.push_back(createQualType(QT));
572 JOS.attribute("exceptionTypes", std::move(Types));
573 } break;
574 case EST_MSAny:
575 JOS.attribute("exceptionSpec", "throw");
576 JOS.attribute("throwsAny", true);
577 break;
579 JOS.attribute("exceptionSpec", "noexcept");
580 break;
581 case EST_NoexceptTrue:
583 JOS.attribute("exceptionSpec", "noexcept");
584 JOS.attribute("conditionEvaluatesTo",
586 //JOS.attributeWithCall("exceptionSpecExpr",
587 // [this, E]() { Visit(E.ExceptionSpec.NoexceptExpr); });
588 break;
589 case EST_NoThrow:
590 JOS.attribute("exceptionSpec", "nothrow");
591 break;
592 // FIXME: I cannot find a way to trigger these cases while dumping the AST. I
593 // suspect you can only run into them when executing an AST dump from within
594 // the debugger, which is not a use case we worry about for the JSON dumping
595 // feature.
597 case EST_Unevaluated:
599 case EST_Unparsed:
600 case EST_None: break;
601 }
606 attributeOnlyIfTrue("spelledAsLValue", RT->isSpelledAsLValue());
610 switch (AT->getSizeModifier()) {
611 case ArrayType::Star:
612 JOS.attribute("sizeModifier", "*");
613 break;
615 JOS.attribute("sizeModifier", "static");
616 break;
618 break;
619 }
621 std::string Str = AT->getIndexTypeQualifiers().getAsString();
622 if (!Str.empty())
623 JOS.attribute("indexTypeQualifiers", Str);
627 // FIXME: this should use ZExt instead of SExt, but JSON doesn't allow a
628 // narrowing conversion to int64_t so it cannot be expressed.
629 JOS.attribute("size", CAT->getSize().getSExtValue());
630 VisitArrayType(CAT);
634 const DependentSizedExtVectorType *VT) {
635 JOS.attributeObject(
636 "attrLoc", [VT, this] { writeSourceLocation(VT->getAttributeLoc()); });
640 JOS.attribute("numElements", VT->getNumElements());
641 switch (VT->getVectorKind()) {
643 break;
645 JOS.attribute("vectorKind", "altivec");
646 break;
648 JOS.attribute("vectorKind", "altivec pixel");
649 break;
651 JOS.attribute("vectorKind", "altivec bool");
652 break;
654 JOS.attribute("vectorKind", "neon");
655 break;
657 JOS.attribute("vectorKind", "neon poly");
658 break;
660 JOS.attribute("vectorKind", "fixed-length sve data vector");
661 break;
663 JOS.attribute("vectorKind", "fixed-length sve predicate vector");
664 break;
665 }
669 JOS.attribute("decl", createBareDeclRef(UUT->getDecl()));
673 switch (UTT->getUTTKind()) {
674#define TRANSFORM_TYPE_TRAIT_DEF(Enum, Trait) \
675 case UnaryTransformType::Enum: \
676 JOS.attribute("transformKind", #Trait); \
677 break;
678#include "clang/Basic/TransformTypeTraits.def"
679 }
683 JOS.attribute("decl", createBareDeclRef(TT->getDecl()));
687 const TemplateTypeParmType *TTPT) {
688 JOS.attribute("depth", TTPT->getDepth());
689 JOS.attribute("index", TTPT->getIndex());
690 attributeOnlyIfTrue("isPack", TTPT->isParameterPack());
691 JOS.attribute("decl", createBareDeclRef(TTPT->getDecl()));
695 const SubstTemplateTypeParmType *STTPT) {
696 JOS.attribute("index", STTPT->getIndex());
697 if (auto PackIndex = STTPT->getPackIndex())
698 JOS.attribute("pack_index", *PackIndex);
703 JOS.attribute("index", T->getIndex());
707 JOS.attribute("undeduced", !AT->isDeduced());
708 switch (AT->getKeyword()) {
710 JOS.attribute("typeKeyword", "auto");
711 break;
713 JOS.attribute("typeKeyword", "decltype(auto)");
714 break;
716 JOS.attribute("typeKeyword", "__auto_type");
717 break;
718 }
722 const TemplateSpecializationType *TST) {
723 attributeOnlyIfTrue("isAlias", TST->isTypeAlias());
725 std::string Str;
726 llvm::raw_string_ostream OS(Str);
727 TST->getTemplateName().print(OS, PrintPolicy);
728 JOS.attribute("templateName", OS.str());
732 const InjectedClassNameType *ICNT) {
733 JOS.attribute("decl", createBareDeclRef(ICNT->getDecl()));
737 JOS.attribute("decl", createBareDeclRef(OIT->getDecl()));
741 if (std::optional<unsigned> N = PET->getNumExpansions())
742 JOS.attribute("numExpansions", *N);
746 if (const NestedNameSpecifier *NNS = ET->getQualifier()) {
747 std::string Str;
748 llvm::raw_string_ostream OS(Str);
749 NNS->print(OS, PrintPolicy, /*ResolveTemplateArgs*/ true);
750 JOS.attribute("qualifier", OS.str());
751 }
752 if (const TagDecl *TD = ET->getOwnedTagDecl())
753 JOS.attribute("ownedTagDecl", createBareDeclRef(TD));
757 JOS.attribute("macroName", MQT->getMacroIdentifier()->getName());
761 attributeOnlyIfTrue("isData", MPT->isMemberDataPointer());
762 attributeOnlyIfTrue("isFunction", MPT->isMemberFunctionPointer());
766 if (ND && ND->getDeclName()) {
767 JOS.attribute("name", ND->getNameAsString());
768 // FIXME: There are likely other contexts in which it makes no sense to ask
769 // for a mangled name.
770 if (isa<RequiresExprBodyDecl>(ND->getDeclContext()))
771 return;
773 // Mangled names are not meaningful for locals, and may not be well-defined
774 // in the case of VLAs.
775 auto *VD = dyn_cast<VarDecl>(ND);
776 if (VD && VD->hasLocalStorage())
777 return;
779 std::string MangledName = ASTNameGen.getName(ND);
780 if (!MangledName.empty())
781 JOS.attribute("mangledName", MangledName);
782 }
786 VisitNamedDecl(TD);
787 JOS.attribute("type", createQualType(TD->getUnderlyingType()));
791 VisitNamedDecl(TAD);
792 JOS.attribute("type", createQualType(TAD->getUnderlyingType()));
796 VisitNamedDecl(ND);
797 attributeOnlyIfTrue("isInline", ND->isInline());
798 attributeOnlyIfTrue("isNested", ND->isNested());
799 if (!ND->isOriginalNamespace())
800 JOS.attribute("originalNamespace",
801 createBareDeclRef(ND->getOriginalNamespace()));
805 JOS.attribute("nominatedNamespace",
806 createBareDeclRef(UDD->getNominatedNamespace()));
810 VisitNamedDecl(NAD);
811 JOS.attribute("aliasedNamespace",
812 createBareDeclRef(NAD->getAliasedNamespace()));
816 std::string Name;
817 if (const NestedNameSpecifier *NNS = UD->getQualifier()) {
818 llvm::raw_string_ostream SOS(Name);
819 NNS->print(SOS, UD->getASTContext().getPrintingPolicy());
820 }
821 Name += UD->getNameAsString();
822 JOS.attribute("name", Name);
826 JOS.attribute("target", createBareDeclRef(UED->getEnumDecl()));
830 JOS.attribute("target", createBareDeclRef(USD->getTargetDecl()));
834 VisitNamedDecl(VD);
835 JOS.attribute("type", createQualType(VD->getType()));
837 StorageClass SC = VD->getStorageClass();
838 if (SC != SC_None)
839 JOS.attribute("storageClass", VarDecl::getStorageClassSpecifierString(SC));
840 switch (VD->getTLSKind()) {
841 case VarDecl::TLS_Dynamic: JOS.attribute("tls", "dynamic"); break;
842 case VarDecl::TLS_Static: JOS.attribute("tls", "static"); break;
843 case VarDecl::TLS_None: break;
844 }
845 attributeOnlyIfTrue("nrvo", VD->isNRVOVariable());
846 attributeOnlyIfTrue("inline", VD->isInline());
847 attributeOnlyIfTrue("constexpr", VD->isConstexpr());
848 attributeOnlyIfTrue("modulePrivate", VD->isModulePrivate());
849 if (VD->hasInit()) {
850 switch (VD->getInitStyle()) {
851 case VarDecl::CInit: JOS.attribute("init", "c"); break;
852 case VarDecl::CallInit: JOS.attribute("init", "call"); break;
853 case VarDecl::ListInit: JOS.attribute("init", "list"); break;
855 JOS.attribute("init", "paren-list");
856 break;
857 }
858 }
859 attributeOnlyIfTrue("isParameterPack", VD->isParameterPack());
863 VisitNamedDecl(FD);
864 JOS.attribute("type", createQualType(FD->getType()));
865 attributeOnlyIfTrue("mutable", FD->isMutable());
866 attributeOnlyIfTrue("modulePrivate", FD->isModulePrivate());
867 attributeOnlyIfTrue("isBitfield", FD->isBitField());
868 attributeOnlyIfTrue("hasInClassInitializer", FD->hasInClassInitializer());
872 VisitNamedDecl(FD);
873 JOS.attribute("type", createQualType(FD->getType()));
874 StorageClass SC = FD->getStorageClass();
875 if (SC != SC_None)
876 JOS.attribute("storageClass", VarDecl::getStorageClassSpecifierString(SC));
877 attributeOnlyIfTrue("inline", FD->isInlineSpecified());
878 attributeOnlyIfTrue("virtual", FD->isVirtualAsWritten());
879 attributeOnlyIfTrue("pure", FD->isPure());
880 attributeOnlyIfTrue("explicitlyDeleted", FD->isDeletedAsWritten());
881 attributeOnlyIfTrue("constexpr", FD->isConstexpr());
882 attributeOnlyIfTrue("variadic", FD->isVariadic());
884 if (FD->isDefaulted())
885 JOS.attribute("explicitlyDefaulted",
886 FD->isDeleted() ? "deleted" : "default");
890 VisitNamedDecl(ED);
891 if (ED->isFixed())
892 JOS.attribute("fixedUnderlyingType", createQualType(ED->getIntegerType()));
893 if (ED->isScoped())
894 JOS.attribute("scopedEnumTag",
895 ED->isScopedUsingClassTag() ? "class" : "struct");
898 VisitNamedDecl(ECD);
899 JOS.attribute("type", createQualType(ECD->getType()));
903 VisitNamedDecl(RD);
904 JOS.attribute("tagUsed", RD->getKindName());
905 attributeOnlyIfTrue("completeDefinition", RD->isCompleteDefinition());
908 VisitRecordDecl(RD);
910 // All other information requires a complete definition.
911 if (!RD->isCompleteDefinition())
912 return;
914 JOS.attribute("definitionData", createCXXRecordDefinitionData(RD));
915 if (RD->getNumBases()) {
916 JOS.attributeArray("bases", [this, RD] {
917 for (const auto &Spec : RD->bases())
918 JOS.value(createCXXBaseSpecifier(Spec));
919 });
920 }
925 JOS.attribute("bufferKind", D->isCBuffer() ? "cbuffer" : "tbuffer");
930 JOS.attribute("tagUsed", D->wasDeclaredWithTypename() ? "typename" : "class");
931 JOS.attribute("depth", D->getDepth());
932 JOS.attribute("index", D->getIndex());
933 attributeOnlyIfTrue("isParameterPack", D->isParameterPack());
935 if (D->hasDefaultArgument())
936 JOS.attributeObject("defaultArg", [=] {
939 D->defaultArgumentWasInherited() ? "inherited from" : "previous");
940 });
944 const NonTypeTemplateParmDecl *D) {
946 JOS.attribute("type", createQualType(D->getType()));
947 JOS.attribute("depth", D->getDepth());
948 JOS.attribute("index", D->getIndex());
949 attributeOnlyIfTrue("isParameterPack", D->isParameterPack());
951 if (D->hasDefaultArgument())
952 JOS.attributeObject("defaultArg", [=] {
955 D->defaultArgumentWasInherited() ? "inherited from" : "previous");
956 });
960 const TemplateTemplateParmDecl *D) {
962 JOS.attribute("depth", D->getDepth());
963 JOS.attribute("index", D->getIndex());
964 attributeOnlyIfTrue("isParameterPack", D->isParameterPack());
966 if (D->hasDefaultArgument())
967 JOS.attributeObject("defaultArg", [=] {
968 const auto *InheritedFrom = D->getDefaultArgStorage().getInheritedFrom();
970 InheritedFrom ? InheritedFrom->getSourceRange() : SourceLocation{},
971 InheritedFrom,
972 D->defaultArgumentWasInherited() ? "inherited from" : "previous");
973 });
977 StringRef Lang;
978 switch (LSD->getLanguage()) {
979 case LinkageSpecDecl::lang_c: Lang = "C"; break;
980 case LinkageSpecDecl::lang_cxx: Lang = "C++"; break;
981 }
982 JOS.attribute("language", Lang);
983 attributeOnlyIfTrue("hasBraces", LSD->hasBraces());
987 JOS.attribute("access", createAccessSpecifier(ASD->getAccess()));
991 if (const TypeSourceInfo *T = FD->getFriendType())
992 JOS.attribute("type", createQualType(T->getType()));
997 JOS.attribute("type", createQualType(D->getType()));
998 attributeOnlyIfTrue("synthesized", D->getSynthesize());
999 switch (D->getAccessControl()) {
1000 case ObjCIvarDecl::None: JOS.attribute("access", "none"); break;
1001 case ObjCIvarDecl::Private: JOS.attribute("access", "private"); break;
1002 case ObjCIvarDecl::Protected: JOS.attribute("access", "protected"); break;
1003 case ObjCIvarDecl::Public: JOS.attribute("access", "public"); break;
1004 case ObjCIvarDecl::Package: JOS.attribute("access", "package"); break;
1005 }
1009 VisitNamedDecl(D);
1010 JOS.attribute("returnType", createQualType(D->getReturnType()));
1011 JOS.attribute("instance", D->isInstanceMethod());
1012 attributeOnlyIfTrue("variadic", D->isVariadic());
1016 VisitNamedDecl(D);
1017 JOS.attribute("type", createQualType(D->getUnderlyingType()));
1018 attributeOnlyIfTrue("bounded", D->hasExplicitBound());
1019 switch (D->getVariance()) {
1021 break;
1023 JOS.attribute("variance", "covariant");
1024 break;
1026 JOS.attribute("variance", "contravariant");
1027 break;
1028 }
1032 VisitNamedDecl(D);
1033 JOS.attribute("interface", createBareDeclRef(D->getClassInterface()));
1034 JOS.attribute("implementation", createBareDeclRef(D->getImplementation()));
1036 llvm::json::Array Protocols;
1037 for (const auto* P : D->protocols())
1038 Protocols.push_back(createBareDeclRef(P));
1039 if (!Protocols.empty())
1040 JOS.attribute("protocols", std::move(Protocols));
1044 VisitNamedDecl(D);
1045 JOS.attribute("interface", createBareDeclRef(D->getClassInterface()));
1046 JOS.attribute("categoryDecl", createBareDeclRef(D->getCategoryDecl()));
1050 VisitNamedDecl(D);
1052 llvm::json::Array Protocols;
1053 for (const auto *P : D->protocols())
1054 Protocols.push_back(createBareDeclRef(P));
1055 if (!Protocols.empty())
1056 JOS.attribute("protocols", std::move(Protocols));
1060 VisitNamedDecl(D);
1061 JOS.attribute("super", createBareDeclRef(D->getSuperClass()));
1062 JOS.attribute("implementation", createBareDeclRef(D->getImplementation()));
1064 llvm::json::Array Protocols;
1065 for (const auto* P : D->protocols())
1066 Protocols.push_back(createBareDeclRef(P));
1067 if (!Protocols.empty())
1068 JOS.attribute("protocols", std::move(Protocols));
1072 const ObjCImplementationDecl *D) {
1073 VisitNamedDecl(D);
1074 JOS.attribute("super", createBareDeclRef(D->getSuperClass()));
1075 JOS.attribute("interface", createBareDeclRef(D->getClassInterface()));
1079 const ObjCCompatibleAliasDecl *D) {
1080 VisitNamedDecl(D);
1081 JOS.attribute("interface", createBareDeclRef(D->getClassInterface()));
1085 VisitNamedDecl(D);
1086 JOS.attribute("type", createQualType(D->getType()));
1088 switch (D->getPropertyImplementation()) {
1089 case ObjCPropertyDecl::None: break;
1090 case ObjCPropertyDecl::Required: JOS.attribute("control", "required"); break;
1091 case ObjCPropertyDecl::Optional: JOS.attribute("control", "optional"); break;
1092 }
1097 JOS.attribute("getter", createBareDeclRef(D->getGetterMethodDecl()));
1099 JOS.attribute("setter", createBareDeclRef(D->getSetterMethodDecl()));
1100 attributeOnlyIfTrue("readonly",
1102 attributeOnlyIfTrue("assign", Attrs & ObjCPropertyAttribute::kind_assign);
1103 attributeOnlyIfTrue("readwrite",
1105 attributeOnlyIfTrue("retain", Attrs & ObjCPropertyAttribute::kind_retain);
1106 attributeOnlyIfTrue("copy", Attrs & ObjCPropertyAttribute::kind_copy);
1107 attributeOnlyIfTrue("nonatomic",
1109 attributeOnlyIfTrue("atomic", Attrs & ObjCPropertyAttribute::kind_atomic);
1110 attributeOnlyIfTrue("weak", Attrs & ObjCPropertyAttribute::kind_weak);
1111 attributeOnlyIfTrue("strong", Attrs & ObjCPropertyAttribute::kind_strong);
1112 attributeOnlyIfTrue("unsafe_unretained",
1114 attributeOnlyIfTrue("class", Attrs & ObjCPropertyAttribute::kind_class);
1115 attributeOnlyIfTrue("direct", Attrs & ObjCPropertyAttribute::kind_direct);
1116 attributeOnlyIfTrue("nullability",
1118 attributeOnlyIfTrue("null_resettable",
1120 }
1125 JOS.attribute("implKind", D->getPropertyImplementation() ==
1127 ? "synthesize"
1128 : "dynamic");
1129 JOS.attribute("propertyDecl", createBareDeclRef(D->getPropertyDecl()));
1130 JOS.attribute("ivarDecl", createBareDeclRef(D->getPropertyIvarDecl()));
1134 attributeOnlyIfTrue("variadic", D->isVariadic());
1135 attributeOnlyIfTrue("capturesThis", D->capturesCXXThis());
1139 JOS.attribute("encodedType", createQualType(OEE->getEncodedType()));
1143 std::string Str;
1144 llvm::raw_string_ostream OS(Str);
1146 OME->getSelector().print(OS);
1147 JOS.attribute("selector", OS.str());
1149 switch (OME->getReceiverKind()) {
1151 JOS.attribute("receiverKind", "instance");
1152 break;
1154 JOS.attribute("receiverKind", "class");
1155 JOS.attribute("classType", createQualType(OME->getClassReceiver()));
1156 break;
1158 JOS.attribute("receiverKind", "super (instance)");
1159 JOS.attribute("superType", createQualType(OME->getSuperType()));
1160 break;
1162 JOS.attribute("receiverKind", "super (class)");
1163 JOS.attribute("superType", createQualType(OME->getSuperType()));
1164 break;
1165 }
1167 QualType CallReturnTy = OME->getCallReturnType(Ctx);
1168 if (OME->getType() != CallReturnTy)
1169 JOS.attribute("callReturnType", createQualType(CallReturnTy));
1173 if (const ObjCMethodDecl *MD = OBE->getBoxingMethod()) {
1174 std::string Str;
1175 llvm::raw_string_ostream OS(Str);
1177 MD->getSelector().print(OS);
1178 JOS.attribute("selector", OS.str());
1179 }
1183 std::string Str;
1184 llvm::raw_string_ostream OS(Str);
1186 OSE->getSelector().print(OS);
1187 JOS.attribute("selector", OS.str());
1191 JOS.attribute("protocol", createBareDeclRef(OPE->getProtocol()));
1195 if (OPRE->isImplicitProperty()) {
1196 JOS.attribute("propertyKind", "implicit");
1197 if (const ObjCMethodDecl *MD = OPRE->getImplicitPropertyGetter())
1198 JOS.attribute("getter", createBareDeclRef(MD));
1199 if (const ObjCMethodDecl *MD = OPRE->getImplicitPropertySetter())
1200 JOS.attribute("setter", createBareDeclRef(MD));
1201 } else {
1202 JOS.attribute("propertyKind", "explicit");
1203 JOS.attribute("property", createBareDeclRef(OPRE->getExplicitProperty()));
1204 }
1206 attributeOnlyIfTrue("isSuperReceiver", OPRE->isSuperReceiver());
1207 attributeOnlyIfTrue("isMessagingGetter", OPRE->isMessagingGetter());
1208 attributeOnlyIfTrue("isMessagingSetter", OPRE->isMessagingSetter());
1212 const ObjCSubscriptRefExpr *OSRE) {
1213 JOS.attribute("subscriptKind",
1214 OSRE->isArraySubscriptRefExpr() ? "array" : "dictionary");
1216 if (const ObjCMethodDecl *MD = OSRE->getAtIndexMethodDecl())
1217 JOS.attribute("getter", createBareDeclRef(MD));
1218 if (const ObjCMethodDecl *MD = OSRE->setAtIndexMethodDecl())
1219 JOS.attribute("setter", createBareDeclRef(MD));
1223 JOS.attribute("decl", createBareDeclRef(OIRE->getDecl()));
1224 attributeOnlyIfTrue("isFreeIvar", OIRE->isFreeIvar());
1225 JOS.attribute("isArrow", OIRE->isArrow());
1229 JOS.attribute("value", OBLE->getValue() ? "__objc_yes" : "__objc_no");
1233 JOS.attribute("referencedDecl", createBareDeclRef(DRE->getDecl()));
1234 if (DRE->getDecl() != DRE->getFoundDecl())
1235 JOS.attribute("foundReferencedDecl",
1236 createBareDeclRef(DRE->getFoundDecl()));
1237 switch (DRE->isNonOdrUse()) {
1238 case NOUR_None: break;
1239 case NOUR_Unevaluated: JOS.attribute("nonOdrUseReason", "unevaluated"); break;
1240 case NOUR_Constant: JOS.attribute("nonOdrUseReason", "constant"); break;
1241 case NOUR_Discarded: JOS.attribute("nonOdrUseReason", "discarded"); break;
1242 }
1246 const SYCLUniqueStableNameExpr *E) {
1247 JOS.attribute("typeSourceInfo",
1248 createQualType(E->getTypeSourceInfo()->getType()));
1252 JOS.attribute("name", PredefinedExpr::getIdentKindName(PE->getIdentKind()));
1256 JOS.attribute("isPostfix", UO->isPostfix());
1257 JOS.attribute("opcode", UnaryOperator::getOpcodeStr(UO->getOpcode()));
1258 if (!UO->canOverflow())
1259 JOS.attribute("canOverflow", false);
1263 JOS.attribute("opcode", BinaryOperator::getOpcodeStr(BO->getOpcode()));
1267 const CompoundAssignOperator *CAO) {
1269 JOS.attribute("computeLHSType", createQualType(CAO->getComputationLHSType()));
1270 JOS.attribute("computeResultType",
1271 createQualType(CAO->getComputationResultType()));
1275 // Note, we always write this Boolean field because the information it conveys
1276 // is critical to understanding the AST node.
1277 ValueDecl *VD = ME->getMemberDecl();
1278 JOS.attribute("name", VD && VD->getDeclName() ? VD->getNameAsString() : "");
1279 JOS.attribute("isArrow", ME->isArrow());
1280 JOS.attribute("referencedMemberDecl", createPointerRepresentation(VD));
1281 switch (ME->isNonOdrUse()) {
1282 case NOUR_None: break;
1283 case NOUR_Unevaluated: JOS.attribute("nonOdrUseReason", "unevaluated"); break;
1284 case NOUR_Constant: JOS.attribute("nonOdrUseReason", "constant"); break;
1285 case NOUR_Discarded: JOS.attribute("nonOdrUseReason", "discarded"); break;
1286 }
1290 attributeOnlyIfTrue("isGlobal", NE->isGlobalNew());
1291 attributeOnlyIfTrue("isArray", NE->isArray());
1292 attributeOnlyIfTrue("isPlacement", NE->getNumPlacementArgs() != 0);
1293 switch (NE->getInitializationStyle()) {
1294 case CXXNewExpr::NoInit: break;
1295 case CXXNewExpr::CallInit: JOS.attribute("initStyle", "call"); break;
1296 case CXXNewExpr::ListInit: JOS.attribute("initStyle", "list"); break;
1297 }
1298 if (const FunctionDecl *FD = NE->getOperatorNew())
1299 JOS.attribute("operatorNewDecl", createBareDeclRef(FD));
1300 if (const FunctionDecl *FD = NE->getOperatorDelete())
1301 JOS.attribute("operatorDeleteDecl", createBareDeclRef(FD));
1304 attributeOnlyIfTrue("isGlobal", DE->isGlobalDelete());
1305 attributeOnlyIfTrue("isArray", DE->isArrayForm());
1306 attributeOnlyIfTrue("isArrayAsWritten", DE->isArrayFormAsWritten());
1307 if (const FunctionDecl *FD = DE->getOperatorDelete())
1308 JOS.attribute("operatorDeleteDecl", createBareDeclRef(FD));
1312 attributeOnlyIfTrue("implicit", TE->isImplicit());
1316 JOS.attribute("castKind", CE->getCastKindName());
1317 llvm::json::Array Path = createCastPath(CE);
1318 if (!Path.empty())
1319 JOS.attribute("path", std::move(Path));
1320 // FIXME: This may not be useful information as it can be obtusely gleaned
1321 // from the inner[] array.
1322 if (const NamedDecl *ND = CE->getConversionFunction())
1323 JOS.attribute("conversionFunc", createBareDeclRef(ND));
1327 VisitCastExpr(ICE);
1328 attributeOnlyIfTrue("isPartOfExplicitCast", ICE->isPartOfExplicitCast());
1332 attributeOnlyIfTrue("adl", CE->usesADL());
1336 const UnaryExprOrTypeTraitExpr *TTE) {
1337 JOS.attribute("name", getTraitSpelling(TTE->getKind()));
1338 if (TTE->isArgumentType())
1339 JOS.attribute("argType", createQualType(TTE->getArgumentType()));
1343 VisitNamedDecl(SOPE->getPack());
1347 const UnresolvedLookupExpr *ULE) {
1348 JOS.attribute("usesADL", ULE->requiresADL());
1349 JOS.attribute("name", ULE->getName().getAsString());
1351 JOS.attributeArray("lookups", [this, ULE] {
1352 for (const NamedDecl *D : ULE->decls())
1353 JOS.value(createBareDeclRef(D));
1354 });
1358 JOS.attribute("name", ALE->getLabel()->getName());
1359 JOS.attribute("labelDeclId", createPointerRepresentation(ALE->getLabel()));
1363 if (CTE->isTypeOperand()) {
1364 QualType Adjusted = CTE->getTypeOperand(Ctx);
1365 QualType Unadjusted = CTE->getTypeOperandSourceInfo()->getType();
1366 JOS.attribute("typeArg", createQualType(Unadjusted));
1367 if (Adjusted != Unadjusted)
1368 JOS.attribute("adjustedTypeArg", createQualType(Adjusted));
1369 }
1374 Visit(CE->getAPValueResult(), CE->getType());
1378 if (const FieldDecl *FD = ILE->getInitializedFieldInUnion())
1379 JOS.attribute("field", createBareDeclRef(FD));
1383 const GenericSelectionExpr *GSE) {
1384 attributeOnlyIfTrue("resultDependent", GSE->isResultDependent());
1388 const CXXUnresolvedConstructExpr *UCE) {
1389 if (UCE->getType() != UCE->getTypeAsWritten())
1390 JOS.attribute("typeAsWritten", createQualType(UCE->getTypeAsWritten()));
1391 attributeOnlyIfTrue("list", UCE->isListInitialization());
1395 CXXConstructorDecl *Ctor = CE->getConstructor();
1396 JOS.attribute("ctorType", createQualType(Ctor->getType()));
1397 attributeOnlyIfTrue("elidable", CE->isElidable());
1398 attributeOnlyIfTrue("list", CE->isListInitialization());
1399 attributeOnlyIfTrue("initializer_list", CE->isStdInitListInitialization());
1400 attributeOnlyIfTrue("zeroing", CE->requiresZeroInitialization());
1401 attributeOnlyIfTrue("hadMultipleCandidates", CE->hadMultipleCandidates());
1403 switch (CE->getConstructionKind()) {
1405 JOS.attribute("constructionKind", "complete");
1406 break;
1408 JOS.attribute("constructionKind", "delegating");
1409 break;
1411 JOS.attribute("constructionKind", "non-virtual base");
1412 break;
1414 JOS.attribute("constructionKind", "virtual base");
1415 break;
1416 }
1420 attributeOnlyIfTrue("cleanupsHaveSideEffects",
1422 if (EWC->getNumObjects()) {
1423 JOS.attributeArray("cleanups", [this, EWC] {
1424 for (const ExprWithCleanups::CleanupObject &CO : EWC->getObjects())
1425 if (auto *BD = CO.dyn_cast<BlockDecl *>()) {
1426 JOS.value(createBareDeclRef(BD));
1427 } else if (auto *CLE = CO.dyn_cast<CompoundLiteralExpr *>()) {
1428 llvm::json::Object Obj;
1429 Obj["id"] = createPointerRepresentation(CLE);
1430 Obj["kind"] = CLE->getStmtClassName();
1431 JOS.value(std::move(Obj));
1432 } else {
1433 llvm_unreachable("unexpected cleanup object type");
1434 }
1435 });
1436 }
1440 const CXXBindTemporaryExpr *BTE) {
1441 const CXXTemporary *Temp = BTE->getTemporary();
1442 JOS.attribute("temp", createPointerRepresentation(Temp));
1443 if (const CXXDestructorDecl *Dtor = Temp->getDestructor())
1444 JOS.attribute("dtor", createBareDeclRef(Dtor));
1448 const MaterializeTemporaryExpr *MTE) {
1449 if (const ValueDecl *VD = MTE->getExtendingDecl())
1450 JOS.attribute("extendingDecl", createBareDeclRef(VD));
1452 switch (MTE->getStorageDuration()) {
1453 case SD_Automatic:
1454 JOS.attribute("storageDuration", "automatic");
1455 break;
1456 case SD_Dynamic:
1457 JOS.attribute("storageDuration", "dynamic");
1458 break;
1459 case SD_FullExpression:
1460 JOS.attribute("storageDuration", "full expression");
1461 break;
1462 case SD_Static:
1463 JOS.attribute("storageDuration", "static");
1464 break;
1465 case SD_Thread:
1466 JOS.attribute("storageDuration", "thread");
1467 break;
1468 }
1470 attributeOnlyIfTrue("boundToLValueRef", MTE->isBoundToLvalueReference());
1474 const CXXDependentScopeMemberExpr *DSME) {
1475 JOS.attribute("isArrow", DSME->isArrow());
1476 JOS.attribute("member", DSME->getMember().getAsString());
1477 attributeOnlyIfTrue("hasTemplateKeyword", DSME->hasTemplateKeyword());
1478 attributeOnlyIfTrue("hasExplicitTemplateArgs",
1479 DSME->hasExplicitTemplateArgs());
1481 if (DSME->getNumTemplateArgs()) {
1482 JOS.attributeArray("explicitTemplateArgs", [DSME, this] {
1483 for (const TemplateArgumentLoc &TAL : DSME->template_arguments())
1484 JOS.object(
1485 [&TAL, this] { Visit(TAL.getArgument(), TAL.getSourceRange()); });
1486 });
1487 }
1491 if (!RE->isValueDependent())
1492 JOS.attribute("satisfied", RE->isSatisfied());
1496 llvm::SmallString<16> Buffer;
1497 IL->getValue().toString(Buffer,
1498 /*Radix=*/10, IL->getType()->isSignedIntegerType());
1499 JOS.attribute("value", Buffer);
1502 // FIXME: This should probably print the character literal as a string,
1503 // rather than as a numerical value. It would be nice if the behavior matched
1504 // what we do to print a string literal; right now, it is impossible to tell
1505 // the difference between 'a' and L'a' in C from the JSON output.
1506 JOS.attribute("value", CL->getValue());
1509 JOS.attribute("value", FPL->getValueAsString(/*Radix=*/10));
1512 llvm::SmallString<16> Buffer;
1513 FL->getValue().toString(Buffer);
1514 JOS.attribute("value", Buffer);
1517 std::string Buffer;
1518 llvm::raw_string_ostream SS(Buffer);
1519 SL->outputString(SS);
1520 JOS.attribute("value", SS.str());
1523 JOS.attribute("value", BLE->getValue());
1527 attributeOnlyIfTrue("hasInit", IS->hasInitStorage());
1528 attributeOnlyIfTrue("hasVar", IS->hasVarStorage());
1529 attributeOnlyIfTrue("hasElse", IS->hasElseStorage());
1530 attributeOnlyIfTrue("isConstexpr", IS->isConstexpr());
1531 attributeOnlyIfTrue("isConsteval", IS->isConsteval());
1532 attributeOnlyIfTrue("constevalIsNegated", IS->isNegatedConsteval());
1536 attributeOnlyIfTrue("hasInit", SS->hasInitStorage());
1537 attributeOnlyIfTrue("hasVar", SS->hasVarStorage());
1540 attributeOnlyIfTrue("isGNURange", CS->caseStmtIsGNURange());
1544 JOS.attribute("name", LS->getName());
1545 JOS.attribute("declId", createPointerRepresentation(LS->getDecl()));
1546 attributeOnlyIfTrue("sideEntry", LS->isSideEntry());
1549 JOS.attribute("targetLabelDeclId",
1550 createPointerRepresentation(GS->getLabel()));
1554 attributeOnlyIfTrue("hasVar", WS->hasVarStorage());
1558 // FIXME: it would be nice for the ASTNodeTraverser would handle the catch
1559 // parameter the same way for C++ and ObjC rather. In this case, C++ gets a
1560 // null child node and ObjC gets no child node.
1561 attributeOnlyIfTrue("isCatchAll", OACS->getCatchParamDecl() == nullptr);
1565 JOS.attribute("isNull", true);
1568 JOS.attribute("type", createQualType(TA.getAsType()));
1571 const TemplateArgument &TA) {
1572 JOS.attribute("decl", createBareDeclRef(TA.getAsDecl()));
1575 JOS.attribute("isNullptr", true);
1578 JOS.attribute("value", TA.getAsIntegral().getSExtValue());
1581 // FIXME: cannot just call dump() on the argument, as that doesn't specify
1582 // the output format.
1585 const TemplateArgument &TA) {
1586 // FIXME: cannot just call dump() on the argument, as that doesn't specify
1587 // the output format.
1590 const TemplateArgument &TA) {
1591 JOS.attribute("isExpr", true);
1594 JOS.attribute("isPack", true);
1597StringRef JSONNodeDumper::getCommentCommandName(unsigned CommandID) const {
1598 if (Traits)
1599 return Traits->getCommandInfo(CommandID)->Name;
1600 if (const comments::CommandInfo *Info =
1602 return Info->Name;
1603 return "<invalid>";
1607 const comments::FullComment *) {
1608 JOS.attribute("text", C->getText());
1613 JOS.attribute("name", getCommentCommandName(C->getCommandID()));
1615 switch (C->getRenderKind()) {
1617 JOS.attribute("renderKind", "normal");
1618 break;
1620 JOS.attribute("renderKind", "bold");
1621 break;
1623 JOS.attribute("renderKind", "emphasized");
1624 break;
1626 JOS.attribute("renderKind", "monospaced");
1627 break;
1629 JOS.attribute("renderKind", "anchor");
1630 break;
1631 }
1633 llvm::json::Array Args;
1634 for (unsigned I = 0, E = C->getNumArgs(); I < E; ++I)
1635 Args.push_back(C->getArgText(I));
1637 if (!Args.empty())
1638 JOS.attribute("args", std::move(Args));
1643 JOS.attribute("name", C->getTagName());
1644 attributeOnlyIfTrue("selfClosing", C->isSelfClosing());
1645 attributeOnlyIfTrue("malformed", C->isMalformed());
1647 llvm::json::Array Attrs;
1648 for (unsigned I = 0, E = C->getNumAttrs(); I < E; ++I)
1649 Attrs.push_back(
1650 {{"name", C->getAttr(I).Name}, {"value", C->getAttr(I).Value}});
1652 if (!Attrs.empty())
1653 JOS.attribute("attrs", std::move(Attrs));
1658 JOS.attribute("name", C->getTagName());
1663 JOS.attribute("name", getCommentCommandName(C->getCommandID()));
1665 llvm::json::Array Args;
1666 for (unsigned I = 0, E = C->getNumArgs(); I < E; ++I)
1667 Args.push_back(C->getArgText(I));
1669 if (!Args.empty())
1670 JOS.attribute("args", std::move(Args));
1675 switch (C->getDirection()) {
1677 JOS.attribute("direction", "in");
1678 break;
1680 JOS.attribute("direction", "out");
1681 break;
1683 JOS.attribute("direction", "in,out");
1684 break;
1685 }
1686 attributeOnlyIfTrue("explicit", C->isDirectionExplicit());
1688 if (C->hasParamName())
1689 JOS.attribute("param", C->isParamIndexValid() ? C->getParamName(FC)
1690 : C->getParamNameAsWritten());
1692 if (C->isParamIndexValid() && !C->isVarArgParam())
1693 JOS.attribute("paramIdx", C->getParamIndex());
1698 if (C->hasParamName())
1699 JOS.attribute("param", C->isPositionValid() ? C->getParamName(FC)
1700 : C->getParamNameAsWritten());
1701 if (C->isPositionValid()) {
1702 llvm::json::Array Positions;
1703 for (unsigned I = 0, E = C->getDepth(); I < E; ++I)
1704 Positions.push_back(C->getIndex(I));
1706 if (!Positions.empty())
1707 JOS.attribute("positions", std::move(Positions));
1708 }
1713 JOS.attribute("name", getCommentCommandName(C->getCommandID()));
1714 JOS.attribute("closeName", C->getCloseName());
1719 const comments::FullComment *) {
1720 JOS.attribute("text", C->getText());
1725 JOS.attribute("text", C->getText());
1728llvm::json::Object JSONNodeDumper::createFPOptions(FPOptionsOverride FPO) {
1729 llvm::json::Object Ret;
1731 if (FPO.has##NAME##Override()) \
1732 Ret.try_emplace(#NAME, static_cast<unsigned>(FPO.get##NAME##Override()));
1733#include "clang/Basic/FPOptions.def"
1734 return Ret;
1738 VisitStmt(S);
1739 if (S->hasStoredFPFeatures())
1740 JOS.attribute("fpoptions", createFPOptions(S->getStoredFPFeatures()));
static bool isTrivial(ASTContext &Ctx, const Expr *E)
Checks if the expression is constant or does not have non-trivial function calls.
int Category
Definition: Format.cpp:2777
#define FIELD1(Flag)
static llvm::json::Object createMoveAssignmentDefinitionData(const CXXRecordDecl *RD)
#define FIELD2(Name, Flag)
static llvm::json::Object createCopyAssignmentDefinitionData(const CXXRecordDecl *RD)
static llvm::json::Object createCopyConstructorDefinitionData(const CXXRecordDecl *RD)
static llvm::json::Object createDestructorDefinitionData(const CXXRecordDecl *RD)
static llvm::json::Object createDefaultConstructorDefinitionData(const CXXRecordDecl *RD)
static llvm::json::Object createMoveConstructorDefinitionData(const CXXRecordDecl *RD)
static bool canPassInRegisters(Sema &S, CXXRecordDecl *D, TargetInfo::CallingConvKind CCK)
Determine whether a type is permitted to be passed or returned in registers, per C++ [class....
Defines the SourceManager interface.
Defines various enumerations that describe declaration and type specifiers.
C Language Family Type Representation.
std::string Label
llvm::APInt getValue() const
Definition: Expr.h:1489
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...
Definition: APValue.h:122
@ None
There is no such object (it's outside its lifetime).
Definition: APValue.h:129
const LangOptions & getLangOpts() const
Definition: ASTContext.h:762
const clang::PrintingPolicy & getPrintingPolicy() const
Definition: ASTContext.h:684
std::string getName(const Decl *D)
Definition: Mangle.cpp:593
Represents an access specifier followed by colon ':'.
Definition: DeclCXX.h:86
AddrLabelExpr - The GNU address of label extension, representing &&label.
Definition: Expr.h:4311
LabelDecl * getLabel() const
Definition: Expr.h:4334
Represents an array type, per C99 - Array Declarators.
Definition: Type.h:3031
ArraySizeModifier getSizeModifier() const
Definition: Type.h:3054
Qualifiers getIndexTypeQualifiers() const
Definition: Type.h:3058
Attr - This represents one attribute.
Definition: Attr.h:40
attr::Kind getKind() const
Definition: Attr.h:80
bool isInherited() const
Definition: Attr.h:89
bool isImplicit() const
Returns true if the attribute has been implicitly created instead of explicitly written by the user.
Definition: Attr.h:93
Represents a C++11 auto or C++14 decltype(auto) type, possibly constrained by a type-constraint.
Definition: Type.h:5267
AutoTypeKeyword getKeyword() const
Definition: Type.h:5298
A builtin binary operation expression such as "x + y" or "x <= y".
Definition: Expr.h:3814
StringRef getOpcodeStr() const
Definition: Expr.h:3879
Opcode getOpcode() const
Definition: Expr.h:3858
A class which contains all the information about a particular captured value.
Definition: Decl.h:4340
Represents a block literal declaration, which is like an unnamed FunctionDecl.
Definition: Decl.h:4334
bool capturesCXXThis() const
Definition: Decl.h:4466
bool isVariadic() const
Definition: Decl.h:4409
Represents a base class of a C++ class.
Definition: DeclCXX.h:146
AccessSpecifier getAccessSpecifierAsWritten() const
Retrieves the access specifier as written in the source code (which may mean that no access specifier...
Definition: DeclCXX.h:238
bool isVirtual() const
Determines whether the base class is a virtual base class (or not).
Definition: DeclCXX.h:199
QualType getType() const
Retrieves the type of the base class.
Definition: DeclCXX.h:245
bool isPackExpansion() const
Determine whether this base specifier is a pack expansion.
Definition: DeclCXX.h:206
AccessSpecifier getAccessSpecifier() const
Returns the access specifier for this base specifier.
Definition: DeclCXX.h:226
Represents binding an expression to a temporary.
Definition: ExprCXX.h:1470
CXXTemporary * getTemporary()
Definition: ExprCXX.h:1488
A boolean literal, per ([C++ lex.bool] Boolean literals).
Definition: ExprCXX.h:720
bool getValue() const
Definition: ExprCXX.h:737
Represents a call to a C++ constructor.
Definition: ExprCXX.h:1518
bool isElidable() const
Whether this construction is elidable.
Definition: ExprCXX.h:1596
bool hadMultipleCandidates() const
Whether the referred constructor was resolved from an overloaded set having size greater than 1.
Definition: ExprCXX.h:1601
bool isStdInitListInitialization() const
Whether this constructor call was written as list-initialization, but was interpreted as forming a st...
Definition: ExprCXX.h:1620
bool requiresZeroInitialization() const
Whether this construction first requires zero-initialization before the initializer is called.
Definition: ExprCXX.h:1629
ConstructionKind getConstructionKind() const
Determine whether this constructor is actually constructing a base class (rather than a complete obje...
Definition: ExprCXX.h:1638
CXXConstructorDecl * getConstructor() const
Get the constructor that this expression will (ultimately) call.
Definition: ExprCXX.h:1590
bool isListInitialization() const
Whether this constructor call was written as list-initialization.
Definition: ExprCXX.h:1609
Represents a C++ constructor within a class.
Definition: DeclCXX.h:2470
Represents a C++ base or member initializer.
Definition: DeclCXX.h:2238
Represents a delete expression for memory deallocation and destructor calls, e.g.
Definition: ExprCXX.h:2473
FunctionDecl * getOperatorDelete() const
Definition: ExprCXX.h:2512
bool isArrayForm() const
Definition: ExprCXX.h:2499
bool isGlobalDelete() const
Definition: ExprCXX.h:2498
bool isArrayFormAsWritten() const
Definition: ExprCXX.h:2500
Represents a C++ member access expression where the actual member referenced could not be resolved be...
Definition: ExprCXX.h:3627
bool isArrow() const
Determine whether this member expression used the '->' operator; otherwise, it used the '.
Definition: ExprCXX.h:3730
unsigned getNumTemplateArgs() const
Retrieve the number of template arguments provided as part of this template-id.
Definition: ExprCXX.h:3825
bool hasExplicitTemplateArgs() const
Determines whether this member expression actually had a C++ template argument list explicitly specif...
Definition: ExprCXX.h:3804
DeclarationName getMember() const
Retrieve the name of the member that this expression refers to.
Definition: ExprCXX.h:3769
bool hasTemplateKeyword() const
Determines whether the member name was preceded by the template keyword.
Definition: ExprCXX.h:3800
ArrayRef< TemplateArgumentLoc > template_arguments() const
Definition: ExprCXX.h:3832
Represents a C++ destructor within a class.
Definition: DeclCXX.h:2734
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)".
Definition: ExprCXX.h:2199
@ ListInit
New-expression has a C++11 list-initializer.
Definition: ExprCXX.h:2257
@ CallInit
New-expression has a C++98 paren-delimited initializer.
Definition: ExprCXX.h:2254
@ NoInit
New-expression has no initializer as written.
Definition: ExprCXX.h:2251
Represents a C++ struct/union/class.
Definition: DeclCXX.h:254
base_class_range bases()
Definition: DeclCXX.h:602
unsigned getNumBases() const
Retrieves the number of base classes of this class.
Definition: DeclCXX.h:596
bool needsOverloadResolutionForMoveConstructor() const
Determine whether we need to eagerly declare a defaulted move constructor for this class.
Definition: DeclCXX.h:889
bool needsOverloadResolutionForDestructor() const
Determine whether we need to eagerly declare a destructor for this class.
Definition: DeclCXX.h:1000
bool needsOverloadResolutionForCopyConstructor() const
Determine whether we need to eagerly declare a defaulted copy constructor for this class.
Definition: DeclCXX.h:799
Represents a C++ temporary.
Definition: ExprCXX.h:1438
const CXXDestructorDecl * getDestructor() const
Definition: ExprCXX.h:1449
Represents the this expression in C++.
Definition: ExprCXX.h:1148
bool isImplicit() const
Definition: ExprCXX.h:1165
A C++ typeid expression (C++ [expr.typeid]), which gets the type_info that corresponds to the supplie...
Definition: ExprCXX.h:845
QualType getTypeOperand(ASTContext &Context) const
Retrieves the type operand of this typeid() expression after various required adjustments (removing r...
Definition: ExprCXX.cpp:162
bool isTypeOperand() const
Definition: ExprCXX.h:881
TypeSourceInfo * getTypeOperandSourceInfo() const
Retrieve source information for the type operand.
Definition: ExprCXX.h:888
Describes an explicit type conversion that uses functional notion but could not be resolved because o...
Definition: ExprCXX.h:3503
bool isListInitialization() const
Determine whether this expression models list-initialization.
Definition: ExprCXX.h:3556
QualType getTypeAsWritten() const
Retrieve the type that is being constructed, as specified in the source code.
Definition: ExprCXX.h:3537
CallExpr - Represents a function call (C99, C++ []).
Definition: Expr.h:2812
bool usesADL() const
Definition: Expr.h:2972
CaseStmt - Represent a case statement.
Definition: Stmt.h:1613
bool caseStmtIsGNURange() const
True if this case statement is of the form case LHS ... RHS, which is a GNU extension.
Definition: Stmt.h:1680
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
Definition: Expr.h:3482
NamedDecl * getConversionFunction() const
If this cast applies a user-defined conversion, retrieve the conversion function that it invokes.
Definition: Expr.cpp:1992
static const char * getCastKindName(CastKind CK)
Definition: Expr.cpp:1945
unsigned getValue() const
Definition: Expr.h:1629
CompoundAssignOperator - For compound assignments (e.g.
Definition: Expr.h:4061
QualType getComputationLHSType() const
Definition: Expr.h:4095
QualType getComputationResultType() const
Definition: Expr.h:4098
CompoundLiteralExpr - [C99].
Definition: Expr.h:3412
CompoundStmt - This represents a group of statements like { stmt stmt }.
Definition: Stmt.h:1420
Represents the canonical version of C arrays with a specified constant size.
Definition: Type.h:3079
const llvm::APInt & getSize() const
Definition: Type.h:3100
ConstantExpr - An expression that occurs in a constant context and optionally the result of evaluatin...
Definition: Expr.h:1045
APValue getAPValueResult() const
Definition: Expr.cpp:465
APValue::ValueKind getResultAPValueKind() const
Definition: Expr.h:1115
A reference to a declared variable, function, enum, etc.
Definition: Expr.h:1238
NamedDecl * getFoundDecl()
Get the NamedDecl through which this reference occurred.
Definition: Expr.h:1343
ValueDecl * getDecl()
Definition: Expr.h:1306
NonOdrUseReason isNonOdrUse() const
Is this expression a non-odr-use reference, and if so, why?
Definition: Expr.h:1430
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:83
ASTContext & getASTContext() const LLVM_READONLY
Definition: DeclBase.cpp:428
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
Definition: DeclBase.h:576
bool isInvalidDecl() const
Definition: DeclBase.h:571
SourceLocation getLocation() const
Definition: DeclBase.h:432
const char * getDeclKindName() const
Definition: DeclBase.cpp:123
bool isThisDeclarationReferenced() const
Whether this declaration was referenced.
Definition: DeclBase.h:604
bool isUsed(bool CheckUsedAttr=true) const
Whether any (re-)declaration of the entity was used, meaning that a definition is required.
Definition: DeclBase.cpp:457
DeclContext * getDeclContext()
Definition: DeclBase.h:441
AccessSpecifier getAccess() const
Definition: DeclBase.h:491
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC).
Definition: DeclBase.h:883
Kind getKind() const
Definition: DeclBase.h:435
virtual SourceRange getSourceRange() const LLVM_READONLY
Source range that this declaration covers.
Definition: DeclBase.h:420
std::string getAsString() const
Retrieve the human-readable string for this name.
bool isDeduced() const
Definition: Type.h:5255
const ParmDecl * getInheritedFrom() const
Get the parameter from which we inherit the default argument, if any.
Definition: DeclTemplate.h:359
Represents an extended vector type where either the type or size is dependent.
Definition: Type.h:3337
SourceLocation getAttributeLoc() const
Definition: Type.h:3354
Represents a type that was referred to using an elaborated type keyword, e.g., struct S,...
Definition: Type.h:5659
TagDecl * getOwnedTagDecl() const
Return the (re)declaration of this type owned by this occurrence of this type, or nullptr if there is...
Definition: Type.h:5707
NestedNameSpecifier * getQualifier() const
Retrieve the qualification on this type.
Definition: Type.h:5694
An instance of this object exists for each enum constant that is defined.
Definition: Decl.h:3160
Represents an enum.
Definition: Decl.h:3720
bool isScoped() const
Returns true if this is a C++11 scoped enumeration.
Definition: Decl.h:3925
bool isScopedUsingClassTag() const
Returns true if this is a C++11 scoped enumeration.
Definition: Decl.h:3928
bool isFixed() const
Returns true if this is an Objective-C, C++11, or Microsoft-style enumeration with a fixed underlying...
Definition: Decl.h:3934
QualType getIntegerType() const
Return the integer type this enum decl corresponds to.
Definition: Decl.h:3880
Represents an expression – generally a full-expression – that introduces cleanups to be run at the en...
Definition: ExprCXX.h:3420
bool cleanupsHaveSideEffects() const
Definition: ExprCXX.h:3455
ArrayRef< CleanupObject > getObjects() const
Definition: ExprCXX.h:3444
unsigned getNumObjects() const
Definition: ExprCXX.h:3448
llvm::PointerUnion< BlockDecl *, CompoundLiteralExpr * > CleanupObject
The type of objects that are kept in the cleanup.
Definition: ExprCXX.h:3426
bool isValueDependent() const
Determines whether the value of this expression depends on.
Definition: Expr.h:169
QualType getType() const
Definition: Expr.h:142
Represents difference between two FPOptions values.
Definition: LangOptions.h:806
Represents a member of a struct/union/class.
Definition: Decl.h:2941
bool isMutable() const
Determines whether this field is mutable (C++ only).
Definition: Decl.h:3016
bool isBitField() const
Determines whether this field is a bitfield.
Definition: Decl.h:3019
bool hasInClassInitializer() const
Determine whether this member has a C++11 default member initializer.
Definition: Decl.h:3085
std::string getValueAsString(unsigned Radix) const
Definition: Expr.cpp:1018
llvm::APFloat getValue() const
Definition: Expr.h:1664
FriendDecl - Represents the declaration of a friend entity, which can be a function,...
Definition: DeclFriend.h:54
TypeSourceInfo * getFriendType() const
If this friend declaration names an (untemplated but possibly dependent) type, return the type; other...
Definition: DeclFriend.h:121
Represents a function declaration or definition.
Definition: Decl.h:1917
bool isPure() const
Whether this virtual function is pure, i.e.
Definition: Decl.h:2255
bool isVariadic() const
Whether this function is variadic.
Definition: Decl.cpp:3022
bool isDeleted() const
Whether this function has been deleted.
Definition: Decl.h:2420
StorageClass getStorageClass() const
Returns the storage class as written in the source.
Definition: Decl.h:2679
bool isConstexpr() const
Whether this is a (C++11) constexpr function or constexpr constructor.
Definition: Decl.h:2365
bool isDeletedAsWritten() const
Definition: Decl.h:2424
bool isDefaulted() const
Whether this function is defaulted.
Definition: Decl.h:2280
bool isVirtualAsWritten() const
Whether this function is marked as virtual explicitly.
Definition: Decl.h:2246
bool isInlineSpecified() const
Determine whether the "inline" keyword was specified for this function.
Definition: Decl.h:2690
Represents a prototype with parameter type info, e.g.
Definition: Type.h:4041
ExtProtoInfo getExtProtoInfo() const
Definition: Type.h:4257
A class which abstracts out some details necessary for making a call.
Definition: Type.h:3805
CallingConv getCC() const
Definition: Type.h:3867
unsigned getRegParm() const
Definition: Type.h:3860
bool getHasRegParm() const
Definition: Type.h:3858
bool getNoReturn() const
Definition: Type.h:3853
bool getProducesResult() const
Definition: Type.h:3854
FunctionType - C99 - Function Declarators.
Definition: Type.h:3694
ExtInfo getExtInfo() const
Definition: Type.h:3971
static StringRef getNameForCallConv(CallingConv CC)
Definition: Type.cpp:3215
bool isConst() const
Definition: Type.h:3977
bool isRestrict() const
Definition: Type.h:3979
bool isVolatile() const
Definition: Type.h:3978
Represents a C11 generic selection.
Definition: Expr.h:5636
AssociationTy< true > ConstAssociation
Definition: Expr.h:5791
bool isResultDependent() const
Whether this generic selection is result-dependent.
Definition: Expr.h:5811
GotoStmt - This represents a direct goto.
Definition: Stmt.h:2649
LabelDecl * getLabel() const
Definition: Stmt.h:2662
HLSLBufferDecl - Represent a cbuffer or tbuffer declaration.
Definition: Decl.h:4780
bool isCBuffer() const
Definition: Decl.h:4808
StringRef getName() const
Return the actual identifier string.
IfStmt - This represents an if/then/else.
Definition: Stmt.h:1950
bool hasElseStorage() const
True if this IfStmt has storage for an else statement.
Definition: Stmt.h:2025
bool hasVarStorage() const
True if this IfStmt has storage for a variable declaration.
Definition: Stmt.h:2022
bool isConstexpr() const
Definition: Stmt.h:2138
bool hasInitStorage() const
True if this IfStmt has the storage for an init statement.
Definition: Stmt.h:2019
bool isNegatedConsteval() const
Definition: Stmt.h:2134
bool isConsteval() const
Definition: Stmt.h:2125
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
Definition: Expr.h:3629
bool isPartOfExplicitCast() const
Definition: Expr.h:3660
Describes an C or C++ initializer list.
Definition: Expr.h:4800
FieldDecl * getInitializedFieldInUnion()
If this initializes a union, specifies which field in the union to initialize.
Definition: Expr.h:4912
The injected class name of a C++ class template or class template partial specialization.
Definition: Type.h:5509
CXXRecordDecl * getDecl() const
Definition: Type.cpp:3708
void VisitObjCSubscriptRefExpr(const ObjCSubscriptRefExpr *OSRE)
void VisitObjCInterfaceDecl(const ObjCInterfaceDecl *D)
void VisitUnresolvedLookupExpr(const UnresolvedLookupExpr *ULE)
void VisitCaseStmt(const CaseStmt *CS)
void VisitImplicitCastExpr(const ImplicitCastExpr *ICE)
void VisitNamespaceAliasDecl(const NamespaceAliasDecl *NAD)
void VisitFunctionProtoType(const FunctionProtoType *T)
void VisitObjCImplementationDecl(const ObjCImplementationDecl *D)
void VisitVectorType(const VectorType *VT)
void VisitFunctionDecl(const FunctionDecl *FD)
void VisitObjCProtocolExpr(const ObjCProtocolExpr *OPE)
void VisitUsingDecl(const UsingDecl *UD)
void VisitEnumConstantDecl(const EnumConstantDecl *ECD)
void VisitConstantExpr(const ConstantExpr *CE)
void VisitRequiresExpr(const RequiresExpr *RE)
void VisitExprWithCleanups(const ExprWithCleanups *EWC)
void VisitCXXBoolLiteralExpr(const CXXBoolLiteralExpr *BLE)
void VisitTagType(const TagType *TT)
void Visit(const Attr *A)
void VisitLabelStmt(const LabelStmt *LS)
void VisitRValueReferenceType(const ReferenceType *RT)
void VisitObjCInterfaceType(const ObjCInterfaceType *OIT)
void VisitCXXConstructExpr(const CXXConstructExpr *CE)
void VisitObjCEncodeExpr(const ObjCEncodeExpr *OEE)
void VisitCXXDependentScopeMemberExpr(const CXXDependentScopeMemberExpr *ME)
void VisitStringLiteral(const StringLiteral *SL)
void VisitBlockDecl(const BlockDecl *D)
void VisitSizeOfPackExpr(const SizeOfPackExpr *SOPE)
void VisitCXXUnresolvedConstructExpr(const CXXUnresolvedConstructExpr *UCE)
void VisitCXXTypeidExpr(const CXXTypeidExpr *CTE)
void VisitObjCPropertyImplDecl(const ObjCPropertyImplDecl *D)
void VisitAccessSpecDecl(const AccessSpecDecl *ASD)
void VisitMemberPointerType(const MemberPointerType *MPT)
void VisitMemberExpr(const MemberExpr *ME)
void visitBlockCommandComment(const comments::BlockCommandComment *C, const comments::FullComment *)
void VisitCXXRecordDecl(const CXXRecordDecl *RD)
void VisitTemplateTemplateParmDecl(const TemplateTemplateParmDecl *D)
void VisitSwitchStmt(const SwitchStmt *SS)
void visitHTMLEndTagComment(const comments::HTMLEndTagComment *C, const comments::FullComment *)
void VisitBinaryOperator(const BinaryOperator *BO)
void visitVerbatimBlockLineComment(const comments::VerbatimBlockLineComment *C, const comments::FullComment *)
void VisitNonTypeTemplateParmDecl(const NonTypeTemplateParmDecl *D)
void VisitTemplateTypeParmDecl(const TemplateTypeParmDecl *D)
void VisitLinkageSpecDecl(const LinkageSpecDecl *LSD)
void VisitTypedefDecl(const TypedefDecl *TD)
void VisitTypedefType(const TypedefType *TT)
void VisitUnresolvedUsingType(const UnresolvedUsingType *UUT)
void VisitSubstTemplateTypeParmPackType(const SubstTemplateTypeParmPackType *T)
void VisitElaboratedType(const ElaboratedType *ET)
void VisitUnaryTransformType(const UnaryTransformType *UTT)
void VisitCallExpr(const CallExpr *CE)
void VisitCompoundAssignOperator(const CompoundAssignOperator *CAO)
void visitParamCommandComment(const comments::ParamCommandComment *C, const comments::FullComment *FC)
void visitVerbatimBlockComment(const comments::VerbatimBlockComment *C, const comments::FullComment *)
void VisitUsingShadowDecl(const UsingShadowDecl *USD)
void VisitFloatingLiteral(const FloatingLiteral *FL)
void VisitTemplateTypeParmType(const TemplateTypeParmType *TTPT)
void VisitUsingDirectiveDecl(const UsingDirectiveDecl *UDD)
void VisitTemplateSpecializationType(const TemplateSpecializationType *TST)
void VisitWhileStmt(const WhileStmt *WS)
void VisitDeclarationTemplateArgument(const TemplateArgument &TA)
void VisitVarDecl(const VarDecl *VD)
void VisitEnumDecl(const EnumDecl *ED)
void VisitPackTemplateArgument(const TemplateArgument &TA)
void VisitTemplateExpansionTemplateArgument(const TemplateArgument &TA)
void visitTextComment(const comments::TextComment *C, const comments::FullComment *)
void VisitFieldDecl(const FieldDecl *FD)
void VisitCXXBindTemporaryExpr(const CXXBindTemporaryExpr *BTE)
void VisitIntegralTemplateArgument(const TemplateArgument &TA)
void VisitObjCSelectorExpr(const ObjCSelectorExpr *OSE)
void VisitSYCLUniqueStableNameExpr(const SYCLUniqueStableNameExpr *E)
void VisitDeclRefExpr(const DeclRefExpr *DRE)
void VisitNullPtrTemplateArgument(const TemplateArgument &TA)
void VisitNamespaceDecl(const NamespaceDecl *ND)
void VisitObjCIvarRefExpr(const ObjCIvarRefExpr *OIRE)
void visitVerbatimLineComment(const comments::VerbatimLineComment *C, const comments::FullComment *)
void VisitAutoType(const AutoType *AT)
void VisitObjCIvarDecl(const ObjCIvarDecl *D)
void VisitMacroQualifiedType(const MacroQualifiedType *MQT)
void VisitObjCPropertyDecl(const ObjCPropertyDecl *D)
void VisitObjCMethodDecl(const ObjCMethodDecl *D)
void visitTParamCommandComment(const comments::TParamCommandComment *C, const comments::FullComment *FC)
void VisitAddrLabelExpr(const AddrLabelExpr *ALE)
void VisitPredefinedExpr(const PredefinedExpr *PE)
void VisitObjCCategoryImplDecl(const ObjCCategoryImplDecl *D)
void VisitPackExpansionType(const PackExpansionType *PET)
void VisitDependentSizedExtVectorType(const DependentSizedExtVectorType *VT)
void visitHTMLStartTagComment(const comments::HTMLStartTagComment *C, const comments::FullComment *)
void VisitUsingType(const UsingType *TT)
void VisitSubstTemplateTypeParmType(const SubstTemplateTypeParmType *STTPT)
void VisitArrayType(const ArrayType *AT)
void VisitTypeTemplateArgument(const TemplateArgument &TA)
void VisitObjCBoxedExpr(const ObjCBoxedExpr *OBE)
void VisitObjCTypeParamDecl(const ObjCTypeParamDecl *D)
void VisitGenericSelectionExpr(const GenericSelectionExpr *GSE)
void VisitTemplateTemplateArgument(const TemplateArgument &TA)
void VisitObjCBoolLiteralExpr(const ObjCBoolLiteralExpr *OBLE)
void VisitFixedPointLiteral(const FixedPointLiteral *FPL)
void VisitGotoStmt(const GotoStmt *GS)
void VisitCharacterLiteral(const CharacterLiteral *CL)
void VisitInitListExpr(const InitListExpr *ILE)
void VisitObjCProtocolDecl(const ObjCProtocolDecl *D)
void VisitCompoundStmt(const CompoundStmt *IS)
void VisitHLSLBufferDecl(const HLSLBufferDecl *D)
void VisitCXXThisExpr(const CXXThisExpr *TE)
void VisitObjCPropertyRefExpr(const ObjCPropertyRefExpr *OPRE)
void VisitConstantArrayType(const ConstantArrayType *CAT)
void VisitObjCCompatibleAliasDecl(const ObjCCompatibleAliasDecl *D)
void VisitCXXNewExpr(const CXXNewExpr *NE)
void VisitObjCAtCatchStmt(const ObjCAtCatchStmt *OACS)
void VisitNullTemplateArgument(const TemplateArgument &TA)
void VisitCastExpr(const CastExpr *CE)
void VisitInjectedClassNameType(const InjectedClassNameType *ICNT)
void VisitIfStmt(const IfStmt *IS)
void VisitUnaryOperator(const UnaryOperator *UO)
void visitInlineCommandComment(const comments::InlineCommandComment *C, const comments::FullComment *)
void VisitUnaryExprOrTypeTraitExpr(const UnaryExprOrTypeTraitExpr *TTE)
void VisitIntegerLiteral(const IntegerLiteral *IL)
void VisitUsingEnumDecl(const UsingEnumDecl *UED)
void VisitObjCMessageExpr(const ObjCMessageExpr *OME)
void VisitFunctionType(const FunctionType *T)
void VisitRecordDecl(const RecordDecl *RD)
void VisitTypeAliasDecl(const TypeAliasDecl *TAD)
void VisitExpressionTemplateArgument(const TemplateArgument &TA)
void VisitNamedDecl(const NamedDecl *ND)
void VisitObjCCategoryDecl(const ObjCCategoryDecl *D)
void VisitFriendDecl(const FriendDecl *FD)
void VisitCXXDeleteExpr(const CXXDeleteExpr *DE)
void VisitMaterializeTemporaryExpr(const MaterializeTemporaryExpr *MTE)
LabelStmt - Represents a label, which has a substatement.
Definition: Stmt.h:1843
LabelDecl * getDecl() const
Definition: Stmt.h:1861
bool isSideEntry() const
Definition: Stmt.h:1882
const char * getName() const
Definition: Stmt.cpp:420
static unsigned MeasureTokenLength(SourceLocation Loc, const SourceManager &SM, const LangOptions &LangOpts)
MeasureTokenLength - Relex the token at the specified location and return its length in bytes in the ...
Definition: Lexer.cpp:450
Represents a linkage specification.
Definition: DeclCXX.h:2863
LanguageIDs getLanguage() const
Return the language specified by this linkage specification.
Definition: DeclCXX.h:2892
bool hasBraces() const
Determines whether this linkage specification had braces in its syntactic form.
Definition: DeclCXX.h:2901
Sugar type that represents a type that was qualified by a qualifier written as a macro invocation.
Definition: Type.h:4590
const IdentifierInfo * getMacroIdentifier() const
Definition: Type.h:4605
Represents a prvalue temporary that is written into memory so that a reference can bind to it.
Definition: ExprCXX.h:4562
StorageDuration getStorageDuration() const
Retrieve the storage duration for the materialized temporary.
Definition: ExprCXX.h:4587
bool isBoundToLvalueReference() const
Determine whether this materialized temporary is bound to an lvalue reference; otherwise,...
Definition: ExprCXX.h:4631
ValueDecl * getExtendingDecl()
Get the declaration which triggered the lifetime-extension of this temporary, if any.
Definition: ExprCXX.h:4612
MemberExpr - [C99] Structure and Union Members.
Definition: Expr.h:3175
ValueDecl * getMemberDecl() const
Retrieve the member declaration to which this expression refers.
Definition: Expr.h:3254
NonOdrUseReason isNonOdrUse() const
Is this expression a non-odr-use reference, and if so, why? This is only meaningful if the named memb...
Definition: Expr.h:3395
bool isArrow() const
Definition: Expr.h:3355
A pointer to member type per C++ 8.3.3 - Pointers to members.
Definition: Type.h:2979
bool isMemberFunctionPointer() const
Returns true if the member type (i.e.
Definition: Type.h:2999
bool isMemberDataPointer() const
Returns true if the member type (i.e.
Definition: Type.h:3005
This represents a decl that may have a name.
Definition: Decl.h:247
bool isModulePrivate() const
Whether this declaration was marked as being private to the module in which it was defined.
Definition: DeclBase.h:625
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
Definition: Decl.h:274
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
Definition: Decl.h:313
std::string getNameAsString() const
Get a human-readable name for the declaration, even if it is one of the special kinds of names (C++ c...
Definition: Decl.h:290
Represents a C++ namespace alias.
Definition: DeclCXX.h:3053
NamedDecl * getAliasedNamespace() const
Retrieve the namespace that this alias refers to, which may either be a NamespaceDecl or a NamespaceA...
Definition: DeclCXX.h:3148
Represent a C++ namespace.
Definition: Decl.h:542
bool isOriginalNamespace() const
Return true if this declaration is an original (first) declaration of the namespace.
Definition: DeclCXX.cpp:2940
bool isInline() const
Returns true if this is an inline namespace declaration.
Definition: Decl.h:605
NamespaceDecl * getOriginalNamespace()
Get the original (first) namespace declaration.
Definition: DeclCXX.cpp:2926
bool isNested() const
Returns true if this is a nested namespace declaration.
Definition: Decl.h:622
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
llvm::json::OStream JOS
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
const DefArgStorage & getDefaultArgStorage() const
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
bool defaultArgumentWasInherited() const
Determines whether the default argument was inherited from a previous declaration of this template.
bool isParameterPack() const
Whether this parameter is a non-type template parameter pack.
unsigned getIndex() const
Get the index of the template parameter within its parameter list.
Expr * getDefaultArgument() const
Retrieve the default argument, if any.
unsigned getDepth() const
Get the nesting depth of the template parameter.
This is a basic class for representing single OpenMP clause.
Definition: OpenMPClause.h:55
Represents Objective-C's @catch statement.
Definition: StmtObjC.h:77
const VarDecl * getCatchParamDecl() const
Definition: StmtObjC.h:97
ObjCBoolLiteralExpr - Objective-C Boolean Literal.
Definition: ExprObjC.h:87
ObjCBoxedExpr - used for generalized expression boxing.
Definition: ExprObjC.h:127
ObjCMethodDecl * getBoxingMethod() const
Definition: ExprObjC.h:146
ObjCCategoryDecl - Represents a category declaration.
Definition: DeclObjC.h:2312
ObjCCategoryImplDecl * getImplementation() const
Definition: DeclObjC.cpp:2169
ObjCInterfaceDecl * getClassInterface()
Definition: DeclObjC.h:2357
protocol_range protocols() const
Definition: DeclObjC.h:2388
ObjCCategoryImplDecl - An object of this class encapsulates a category @implementation declaration.
Definition: DeclObjC.h:2531
ObjCCategoryDecl * getCategoryDecl() const
Definition: DeclObjC.cpp:2213
ObjCCompatibleAliasDecl - Represents alias of a class.
Definition: DeclObjC.h:2759
const ObjCInterfaceDecl * getClassInterface() const
Definition: DeclObjC.h:2777
ObjCEncodeExpr, used for @encode in Objective-C.
Definition: ExprObjC.h:409
QualType getEncodedType() const
Definition: ExprObjC.h:428
const ObjCInterfaceDecl * getClassInterface() const
Definition: DeclObjC.h:2472
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
Definition: DeclObjC.h:2584
const ObjCInterfaceDecl * getSuperClass() const
Definition: DeclObjC.h:2719
Represents an ObjC class declaration.
Definition: DeclObjC.h:1147
protocol_range protocols() const
Definition: DeclObjC.h:1347
ObjCImplementationDecl * getImplementation() const
Definition: DeclObjC.cpp:1635
ObjCInterfaceDecl * getSuperClass() const
Definition: DeclObjC.cpp:351
Interfaces are the core concept in Objective-C for object oriented design.
Definition: Type.h:6241
ObjCInterfaceDecl * getDecl() const
Get the declaration of this interface.
Definition: Type.cpp:827
ObjCIvarDecl - Represents an ObjC instance variable.
Definition: DeclObjC.h:1939
AccessControl getAccessControl() const
Definition: DeclObjC.h:1988
bool getSynthesize() const
Definition: DeclObjC.h:1995
ObjCIvarRefExpr - A reference to an ObjC instance variable.
Definition: ExprObjC.h:548
ObjCIvarDecl * getDecl()
Definition: ExprObjC.h:576
bool isArrow() const
Definition: ExprObjC.h:584
bool isFreeIvar() const
Definition: ExprObjC.h:585
An expression that sends a message to the given Objective-C object or class.
Definition: ExprObjC.h:942
QualType getCallReturnType(ASTContext &Ctx) const
Definition: ExprObjC.cpp:265
Selector getSelector() const
Definition: ExprObjC.cpp:293
@ SuperInstance
The receiver is the instance of the superclass object.
Definition: ExprObjC.h:1097
@ Instance
The receiver is an object instance.
Definition: ExprObjC.h:1091
@ SuperClass
The receiver is a superclass.
Definition: ExprObjC.h:1094
@ Class
The receiver is a class.
Definition: ExprObjC.h:1088
QualType getClassReceiver() const
Returns the type of a class message send, or NULL if the message is not a class message.
Definition: ExprObjC.h:1269
QualType getSuperType() const
Retrieve the type referred to by 'super'.
Definition: ExprObjC.h:1326
ReceiverKind getReceiverKind() const
Determine the kind of receiver that this message is being sent to.
Definition: ExprObjC.h:1224
ObjCMethodDecl - Represents an instance or class method declaration.
Definition: DeclObjC.h:138
bool isVariadic() const
Definition: DeclObjC.h:433
bool isInstanceMethod() const
Definition: DeclObjC.h:428
QualType getReturnType() const
Definition: DeclObjC.h:331
Represents one property declaration in an Objective-C interface.
Definition: DeclObjC.h:729
ObjCMethodDecl * getGetterMethodDecl() const
Definition: DeclObjC.h:894
ObjCMethodDecl * getSetterMethodDecl() const
Definition: DeclObjC.h:897
QualType getType() const
Definition: DeclObjC.h:797
ObjCPropertyAttribute::Kind getPropertyAttributes() const
Definition: DeclObjC.h:808
PropertyControl getPropertyImplementation() const
Definition: DeclObjC.h:905
ObjCPropertyImplDecl - Represents implementation declaration of a property in a class or category imp...
Definition: DeclObjC.h:2789
ObjCIvarDecl * getPropertyIvarDecl() const
Definition: DeclObjC.h:2862
Kind getPropertyImplementation() const
Definition: DeclObjC.h:2858
ObjCPropertyDecl * getPropertyDecl() const
Definition: DeclObjC.h:2853
ObjCPropertyRefExpr - A dot-syntax expression to access an ObjC property.
Definition: ExprObjC.h:614
bool isMessagingGetter() const
True if the property reference will result in a message to the getter.
Definition: ExprObjC.h:733
ObjCPropertyDecl * getExplicitProperty() const
Definition: ExprObjC.h:703
bool isMessagingSetter() const
True if the property reference will result in a message to the setter.
Definition: ExprObjC.h:740
ObjCMethodDecl * getImplicitPropertyGetter() const
Definition: ExprObjC.h:708
bool isImplicitProperty() const
Definition: ExprObjC.h:700
ObjCMethodDecl * getImplicitPropertySetter() const
Definition: ExprObjC.h:713
bool isSuperReceiver() const
Definition: ExprObjC.h:772
Represents an Objective-C protocol declaration.
Definition: DeclObjC.h:2069
protocol_range protocols() const
Definition: DeclObjC.h:2144
ObjCProtocolExpr used for protocol expression in Objective-C.
Definition: ExprObjC.h:504
ObjCProtocolDecl * getProtocol() const
Definition: ExprObjC.h:521
ObjCSelectorExpr used for @selector in Objective-C.
Definition: ExprObjC.h:454
Selector getSelector() const
Definition: ExprObjC.h:468
ObjCSubscriptRefExpr - used for array and dictionary subscripting.
Definition: ExprObjC.h:841
bool isArraySubscriptRefExpr() const
Definition: ExprObjC.h:894
ObjCMethodDecl * getAtIndexMethodDecl() const
Definition: ExprObjC.h:886
ObjCMethodDecl * setAtIndexMethodDecl() const
Definition: ExprObjC.h:890
Represents the declaration of an Objective-C type parameter.
Definition: DeclObjC.h:579
bool hasExplicitBound() const
Whether this type parameter has an explicitly-written type bound, e.g., "T : NSView".
Definition: DeclObjC.h:639
ObjCTypeParamVariance getVariance() const
Determine the variance of this type parameter.
Definition: DeclObjC.h:622
llvm::iterator_range< decls_iterator > decls() const
Definition: ExprCXX.h:3052
DeclarationName getName() const
Gets the name looked up.
Definition: ExprCXX.h:3063
Represents a pack expansion of types.
Definition: Type.h:5858
std::optional< unsigned > getNumExpansions() const
Retrieve the number of expansions that this pack expansion will generate, if known.
Definition: Type.h:5883
[C99] - A predefined identifier such as func.
Definition: Expr.h:1972
StringRef getIdentKindName() const
Definition: Expr.h:2038
IdentKind getIdentKind() const
Definition: Expr.h:2018
Represents an unpacked "presumed" location which can be presented to the user.
unsigned getColumn() const
Return the presumed column number of this location.
const char * getFilename() const
Return the presumed filename of this location.
bool isValid() const
unsigned getLine() const
Return the presumed line number of this location.
bool isInvalid() const
Return true if this object is invalid or uninitialized.
SourceLocation getIncludeLoc() const
Return the presumed include location of this location.
A (possibly-)qualified type.
Definition: Type.h:736
bool isNull() const
Return true if this QualType doesn't point to a type yet.
Definition: Type.h:803
SplitQualType getSplitDesugaredType() const
Definition: Type.h:1057
SplitQualType split() const
Divides a QualType into its unqualified type and a set of local qualifiers.
Definition: Type.h:6670
std::string getAsString() const
void * getAsOpaquePtr() const
Definition: Type.h:783
std::string getAsString() const
Represents a struct/union/class.
Definition: Decl.h:3998
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Definition: Type.h:4835
RecordDecl * getDecl() const
Definition: Type.h:4845
Base for LValueReferenceType and RValueReferenceType.
Definition: Type.h:2899
bool isSpelledAsLValue() const
Definition: Type.h:2912
C++2a [expr.prim.req]: A requires-expression provides a concise way to express requirements on templa...
Definition: ExprConcepts.h:478
bool isSatisfied() const
Whether or not the requires clause is satisfied.
Definition: ExprConcepts.h:525
TypeSourceInfo * getTypeSourceInfo()
Definition: Expr.h:2084
void print(llvm::raw_ostream &OS) const
Prints the full selector name (e.g. "foo:bar:").
Represents an expression that computes the length of a parameter pack.
Definition: ExprCXX.h:4202
NamedDecl * getPack() const
Retrieve the parameter pack.
Definition: ExprCXX.h:4271
Encodes a location in the source.
PresumedLoc getPresumedLoc(SourceLocation Loc, bool UseLineDirectives=true) const
Returns the "presumed" location of a SourceLocation specifies.
StringRef getBufferName(SourceLocation Loc, bool *Invalid=nullptr) const
Return the filename or buffer identifier of the buffer the location is in.
bool isMacroArgExpansion(SourceLocation Loc, SourceLocation *StartLoc=nullptr) const
Tests whether the given source location represents a macro argument's expansion into the function-lik...
SourceLocation getSpellingLoc(SourceLocation Loc) const
Given a SourceLocation object, return the spelling location referenced by the ID.
unsigned getSpellingLineNumber(SourceLocation Loc, bool *Invalid=nullptr) const
unsigned getExpansionLineNumber(SourceLocation Loc, bool *Invalid=nullptr) const
std::pair< FileID, unsigned > getDecomposedLoc(SourceLocation Loc) const
Decompose the specified location into a raw FileID + Offset pair.
SourceLocation getExpansionLoc(SourceLocation Loc) const
Given a SourceLocation object Loc, return the expansion location referenced by the ID.
A trivial tuple used to represent a source range.
SourceLocation getEnd() const
SourceLocation getBegin() const
bool isValid() const
RetTy Visit(PTR(Stmt) S, ParamTys... P)
Definition: StmtVisitor.h:43
Stmt - This represents one statement.
Definition: Stmt.h:72
StringLiteral - This represents a string literal expression, e.g.
Definition: Expr.h:1781
void outputString(raw_ostream &OS) const
Definition: Expr.cpp:1207
Represents the result of substituting a set of types for a template type parameter pack.
Definition: Type.h:5175
unsigned getIndex() const
Returns the index of the replaced parameter in the associated declaration.
Definition: Type.h:5201
Represents the result of substituting a type for a template type parameter.
Definition: Type.h:5105
std::optional< unsigned > getPackIndex() const
Definition: Type.h:5135
unsigned getIndex() const
Returns the index of the replaced parameter in the associated declaration.
Definition: Type.h:5133
SwitchStmt - This represents a 'switch' stmt.
Definition: Stmt.h:2195
bool hasVarStorage() const
True if this SwitchStmt has storage for a condition variable.
Definition: Stmt.h:2256
bool hasInitStorage() const
True if this SwitchStmt has storage for an init statement.
Definition: Stmt.h:2253
Represents the declaration of a struct/union/class/enum.
Definition: Decl.h:3440
StringRef getKindName() const
Definition: Decl.h:3631
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
Definition: Decl.h:3543
TagDecl * getDecl() const
Definition: Type.cpp:3610
Location wrapper for a TemplateArgument.
Definition: TemplateBase.h:484
const TemplateArgument & getArgument() const
Definition: TemplateBase.h:533
Represents a template argument.
Definition: TemplateBase.h:60
QualType getAsType() const
Retrieve the type for a type template argument.
Definition: TemplateBase.h:287
llvm::APSInt getAsIntegral() const
Retrieve the template argument as an integral value.
Definition: TemplateBase.h:331
ValueDecl * getAsDecl() const
Retrieve the declaration for a declaration non-type template argument.
Definition: TemplateBase.h:294
void print(raw_ostream &OS, const PrintingPolicy &Policy, Qualified Qual=Qualified::AsWritten) const
Print the template name.
Represents a type template specialization; the template must be a class template, a type alias templa...
Definition: Type.h:5377
TemplateName getTemplateName() const
Retrieve the name of the template that we are specializing.
Definition: Type.h:5443
bool isTypeAlias() const
Determine if this template specialization type is for a type alias template that has been substituted...
Definition: Type.h:5436
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
const DefArgStorage & getDefaultArgStorage() const
const TemplateArgumentLoc & getDefaultArgument() const
Retrieve the default argument, if any.
bool isParameterPack() const
Whether this template template parameter is a template parameter pack.
unsigned getIndex() const
Get the index of the template parameter within its parameter list.
bool defaultArgumentWasInherited() const
Determines whether the default argument was inherited from a previous declaration of this template.
unsigned getDepth() const
Get the nesting depth of the template parameter.
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
Declaration of a template type parameter.
bool wasDeclaredWithTypename() const
Whether this template type parameter was declared with the 'typename' keyword.
QualType getDefaultArgument() const
Retrieve the default argument, if any.
unsigned getIndex() const
Retrieve the index of the template parameter.
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
bool defaultArgumentWasInherited() const
Determines whether the default argument was inherited from a previous declaration of this template.
bool isParameterPack() const
Returns whether this is a parameter pack.
unsigned getDepth() const
Retrieve the depth of the template parameter.
const DefArgStorage & getDefaultArgStorage() const
TemplateTypeParmDecl * getDecl() const
Definition: Type.h:5068
bool isParameterPack() const
Definition: Type.h:5066
unsigned getIndex() const
Definition: Type.h:5065
unsigned getDepth() const
Definition: Type.h:5064
Represents the declaration of a typedef-name via a C++11 alias-declaration.
Definition: Decl.h:3412
A container of type source information.
Definition: Type.h:6620
QualType getType() const
Return the type wrapped by this type source info.
Definition: Type.h:6631
void Visit(const Type *T)
Performs the operation associated with this visitor object.
Definition: TypeVisitor.h:68
The base class of the type hierarchy.
Definition: Type.h:1566
bool isSignedIntegerType() const
Return true if this is an integer type that is signed, according to C99 6.2.5p4 [char,...
Definition: Type.cpp:2042
bool isInstantiationDependentType() const
Determine whether this type is an instantiation-dependent type, meaning that the type involves a temp...
Definition: Type.h:2325
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
Definition: Type.h:2317
bool containsUnexpandedParameterPack() const
Whether this type is or contains an unexpanded parameter pack, used to support C++0x variadic templat...
Definition: Type.h:2005
const char * getTypeClassName() const
Definition: Type.cpp:3006
bool containsErrors() const
Whether this type is an error type.
Definition: Type.h:2311
bool isVariablyModifiedType() const
Whether this type is a variably-modified type (C99 6.7.5).
Definition: Type.h:2335
bool isFromAST() const
Whether this type comes from an AST file.
Definition: Type.h:1988
const T * getAs() const
Member-template getAs<specific type>'.
Definition: Type.h:7424
Represents the declaration of a typedef-name via the 'typedef' type specifier.
Definition: Decl.h:3392
QualType getUnderlyingType() const
Definition: Decl.h:3345
TypedefNameDecl * getDecl() const
Definition: Type.h:4565
QualType desugar() const
Definition: Type.cpp:3487
bool typeMatchesDecl() const
Definition: Type.h:4573
UnaryExprOrTypeTraitExpr - expression with either a type or (unevaluated) expression operand.
Definition: Expr.h:2560
QualType getArgumentType() const
Definition: Expr.h:2603
bool isArgumentType() const
Definition: Expr.h:2602
UnaryExprOrTypeTrait getKind() const
Definition: Expr.h:2592
UnaryOperator - This represents the unary-expression's (except sizeof and alignof),...
Definition: Expr.h:2176
static bool isPostfix(Opcode Op)
isPostfix - Return true if this is a postfix operation, like x++.
Definition: Expr.h:2250
Opcode getOpcode() const
Definition: Expr.h:2216
static StringRef getOpcodeStr(Opcode Op)
getOpcodeStr - Turn an Opcode enum value into the punctuation char it corresponds to,...
Definition: Expr.cpp:1389
bool canOverflow() const
Returns true if the unary operator can cause an overflow.
Definition: Expr.h:2234
A unary type transform, which is a type constructed from another.
Definition: Type.h:4752
UTTKind getUTTKind() const
Definition: Type.h:4781
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
Definition: ExprCXX.h:3151
bool requiresADL() const
True if this declaration should be extended by argument-dependent lookup.
Definition: ExprCXX.h:3215
Represents the dependent type named by a dependently-scoped typename using declaration,...
Definition: Type.h:4491
UnresolvedUsingTypenameDecl * getDecl() const
Definition: Type.h:4502
Represents a C++ using-declaration.
Definition: DeclCXX.h:3445
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies the name.
Definition: DeclCXX.h:3482
Represents C++ using-directive.
Definition: DeclCXX.h:2948
NamespaceDecl * getNominatedNamespace()
Returns the namespace nominated by this using-directive.
Definition: DeclCXX.cpp:2889
Represents a C++ using-enum-declaration.
Definition: DeclCXX.h:3645
EnumDecl * getEnumDecl() const
Definition: DeclCXX.h:3689
Represents a shadow declaration implicitly introduced into a scope by a (resolved) using-declaration ...
Definition: DeclCXX.h:3253
NamedDecl * getTargetDecl() const
Gets the underlying declaration which has been brought into the local scope.
Definition: DeclCXX.h:3317
QualType desugar() const
Definition: Type.h:4537
UsingShadowDecl * getFoundDecl() const
Definition: Type.h:4531
bool typeMatchesDecl() const
Definition: Type.h:4540
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition: Decl.h:701
QualType getType() const
Definition: Decl.h:712
Represents a variable declaration or definition.
Definition: Decl.h:913
bool isConstexpr() const
Whether this variable is (C++11) constexpr.
Definition: Decl.h:1519
TLSKind getTLSKind() const
Definition: Decl.cpp:2112
bool hasInit() const
Definition: Decl.cpp:2343
InitializationStyle getInitStyle() const
The style of initialization for this declaration.
Definition: Decl.h:1416
static const char * getStorageClassSpecifierString(StorageClass SC)
Return the string used to specify the storage class SC.
Definition: Decl.cpp:2065
@ ListInit
Direct list-initialization (C++11)
Definition: Decl.h:924
@ CInit
C-style initialization with assignment.
Definition: Decl.h:918
@ ParenListInit
Parenthesized list-initialization (C++20)
Definition: Decl.h:927
@ CallInit
Call-style initialization (C++98)
Definition: Decl.h:921
bool isNRVOVariable() const
Determine whether this local variable can be used with the named return value optimization (NRVO).
Definition: Decl.h:1462
bool isInline() const
Whether this variable is (C++1z) inline.
Definition: Decl.h:1501
@ TLS_Static
TLS with a known-constant initializer.
Definition: Decl.h:936
@ TLS_Dynamic
TLS with a dynamic initializer.
Definition: Decl.h:939
@ TLS_None
Not a TLS variable.
Definition: Decl.h:933
StorageClass getStorageClass() const
Returns the storage class as written in the source.
Definition: Decl.h:1125
bool isParameterPack() const
Determine whether this variable is actually a function parameter pack or init-capture pack.
Definition: Decl.cpp:2598
Represents a GCC generic vector type.
Definition: Type.h:3377
unsigned getNumElements() const
Definition: Type.h:3419
@ AltiVecBool
is AltiVec 'vector bool ...'
Definition: Type.h:3390
@ SveFixedLengthPredicateVector
is AArch64 SVE fixed-length predicate vector
Definition: Type.h:3402
@ NeonPolyVector
is ARM Neon polynomial vector
Definition: Type.h:3396
@ GenericVector
not a target-specific vector type
Definition: Type.h:3381
@ AltiVecPixel
is AltiVec 'vector Pixel'
Definition: Type.h:3387
@ SveFixedLengthDataVector
is AArch64 SVE fixed-length data vector
Definition: Type.h:3399
@ AltiVecVector
is AltiVec vector
Definition: Type.h:3384
@ NeonVector
is ARM Neon vector
Definition: Type.h:3393
VectorKind getVectorKind() const
Definition: Type.h:3424
WhileStmt - This represents a 'while' stmt.
Definition: Stmt.h:2386
bool hasVarStorage() const
True if this WhileStmt has storage for a condition variable.
Definition: Stmt.h:2436
RetTy Visit(PTR(Attr) A)
Definition: AttrVisitor.h:31
A command that has zero or more word-like arguments (number of word-like arguments depends on command...
Definition: Comment.h:588
static const CommandInfo * getBuiltinCommandInfo(StringRef Name)
const CommandInfo * getCommandInfo(StringRef Name) const
RetTy visit(PTR(Comment) C, ParamTys... P)
Any part of the comment.
Definition: Comment.h:52
A full comment attached to a declaration, contains block content.
Definition: Comment.h:1077
An opening HTML tag with attributes.
Definition: Comment.h:411
A command with word-like arguments that is considered inline content.
Definition: Comment.h:302
Doxygen \param command.
Definition: Comment.h:694
Doxygen \tparam command, describes a template parameter.
Definition: Comment.h:782
A verbatim block command (e.
Definition: Comment.h:874
A line of text contained in a verbatim block.
Definition: Comment.h:846
A verbatim line command.
Definition: Comment.h:926
A static requirement that can be used in a requires-expression to check properties of types and expre...
Definition: ExprConcepts.h:146
RequirementKind getKind() const
Definition: ExprConcepts.h:173
bool containsUnexpandedParameterPack() const
Definition: ExprConcepts.h:193
RetTy Visit(PTR(Decl) D)
Definition: DeclVisitor.h:37
RetTy Visit(REF(TemplateArgument) TA, ParamTys... P)
@ kind_nullability
Indicates that the nullability of the type was spelled with a property attribute rather than a type q...
bool Ret(InterpState &S, CodePtr &PC, APValue &Result)
Definition: Interp.h:159
@ GNUAutoType
__auto_type (GNU extension)
@ DecltypeAuto
llvm::StringRef getAccessSpelling(AccessSpecifier AS)
Definition: Specifiers.h:383
@ RQ_None
No ref-qualifier was provided.
Definition: Type.h:1519
@ RQ_LValue
An lvalue ref-qualifier was provided (&).
Definition: Type.h:1522
@ RQ_RValue
An rvalue ref-qualifier was provided (&&).
Definition: Type.h:1525
Storage classes.
Definition: Specifiers.h:236
@ SC_None
Definition: Specifiers.h:238
@ C
Languages that the frontend can parse and compile.
@ SD_Thread
Thread storage duration.
Definition: Specifiers.h:314
@ SD_Static
Static storage duration.
Definition: Specifiers.h:315
@ SD_FullExpression
Full-expression storage duration (for temporaries).
Definition: Specifiers.h:312
@ SD_Automatic
Automatic storage duration (most local variables).
Definition: Specifiers.h:313
@ SD_Dynamic
Dynamic storage duration.
Definition: Specifiers.h:316
@ VK_PRValue
A pr-value expression (in the C++11 taxonomy) produces a temporary value.
Definition: Specifiers.h:123
@ VK_XValue
An x-value expression is a reference to an object with independent storage but which can be "moved",...
Definition: Specifiers.h:132
@ VK_LValue
An l-value expression is a reference to an object with independent storage.
Definition: Specifiers.h:127
const char * getTraitSpelling(ExpressionTrait T) LLVM_READONLY
Return the spelling of the type trait TT. Never null.
if(T->getSizeExpr()) TRY_TO(TraverseStmt(T -> getSizeExpr()))
@ Invariant
The parameter is invariant: must match exactly.
@ Contravariant
The parameter is contravariant, e.g., X<T> is a subtype of X when the type parameter is covariant and...
@ Covariant
The parameter is covariant, e.g., X<T> is a subtype of X when the type parameter is covariant and T i...
@ EST_DependentNoexcept
noexcept(expression), value-dependent
@ EST_DynamicNone
@ EST_Uninstantiated
not instantiated yet
@ EST_Unparsed
not parsed yet
@ EST_NoThrow
Microsoft __declspec(nothrow) extension.
@ EST_None
no exception specification
Microsoft throw(...) extension.
@ EST_BasicNoexcept
@ EST_NoexceptFalse
noexcept(expression), evals to 'false'
@ EST_Unevaluated
not evaluated yet, for special member function
@ EST_NoexceptTrue
noexcept(expression), evals to 'true'
@ EST_Dynamic
throw(T1, T2)
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
Definition: Specifiers.h:111
@ NOUR_Discarded
This name appears as a potential result of a discarded value expression.
Definition: Specifiers.h:171
@ NOUR_Unevaluated
This name appears in an unevaluated operand.
Definition: Specifiers.h:165
@ NOUR_None
This is an odr-use.
Definition: Specifiers.h:163
@ NOUR_Constant
This name appears as a potential result of an lvalue-to-rvalue conversion that is a constant expressi...
Definition: Specifiers.h:168
unsigned long uint64_t
ExceptionSpecificationType Type
The kind of exception specification this is.
Definition: Type.h:4094
ArrayRef< QualType > Exceptions
Explicitly-specified list of exception types.
Definition: Type.h:4097
Extra information about a function prototype.
Definition: Type.h:4118
ExceptionSpecInfo ExceptionSpec
Definition: Type.h:4124
A std::pair-like structure for storing a qualified type split into its local qualifiers and its local...
Definition: Type.h:669
Qualifiers Quals
The local qualifiers.
Definition: Type.h:674
Information about a single command.