clang 18.0.0git
Go to the documentation of this file.
2#include "clang/AST/Type.h"
5#include "clang/Lex/Lexer.h"
6#include "llvm/ADT/StringExtras.h"
7#include <optional>
9using namespace clang;
11void JSONNodeDumper::addPreviousDeclaration(const Decl *D) {
12 switch (D->getKind()) {
13#define DECL(DERIVED, BASE) \
14 case Decl::DERIVED: \
15 return writePreviousDeclImpl(cast<DERIVED##Decl>(D));
17#include "clang/AST/"
19#undef DECL
20 }
21 llvm_unreachable("Decl that isn't part of!");
25 const char *AttrName = nullptr;
26 switch (A->getKind()) {
27#define ATTR(X) \
28 case attr::X: \
29 AttrName = #X"Attr"; \
30 break;
31#include "clang/Basic/"
32#undef ATTR
33 }
34 JOS.attribute("id", createPointerRepresentation(A));
35 JOS.attribute("kind", AttrName);
36 JOS.attributeObject("range", [A, this] { writeSourceRange(A->getRange()); });
37 attributeOnlyIfTrue("inherited", A->isInherited());
38 attributeOnlyIfTrue("implicit", A->isImplicit());
40 // FIXME: it would be useful for us to output the spelling kind as well as
41 // the actual spelling. This would allow us to distinguish between the
42 // various attribute syntaxes, but we don't currently track that information
43 // within the AST.
44 //JOS.attribute("spelling", A->getSpelling());
50 if (!S)
51 return;
53 JOS.attribute("id", createPointerRepresentation(S));
54 JOS.attribute("kind", S->getStmtClassName());
55 JOS.attributeObject("range",
56 [S, this] { writeSourceRange(S->getSourceRange()); });
58 if (const auto *E = dyn_cast<Expr>(S)) {
59 JOS.attribute("type", createQualType(E->getType()));
60 const char *Category = nullptr;
61 switch (E->getValueKind()) {
62 case VK_LValue: Category = "lvalue"; break;
63 case VK_XValue: Category = "xvalue"; break;
64 case VK_PRValue:
65 Category = "prvalue";
66 break;
67 }
68 JOS.attribute("valueCategory", Category);
69 }
74 JOS.attribute("id", createPointerRepresentation(T));
76 if (!T)
77 return;
79 JOS.attribute("kind", (llvm::Twine(T->getTypeClassName()) + "Type").str());
80 JOS.attribute("type", createQualType(QualType(T, 0), /*Desugar*/ false));
81 attributeOnlyIfTrue("containsErrors", T->containsErrors());
82 attributeOnlyIfTrue("isDependent", T->isDependentType());
83 attributeOnlyIfTrue("isInstantiationDependent",
85 attributeOnlyIfTrue("isVariablyModified", T->isVariablyModifiedType());
86 attributeOnlyIfTrue("containsUnexpandedPack",
88 attributeOnlyIfTrue("isImported", T->isFromAST());
93 JOS.attribute("id", createPointerRepresentation(T.getAsOpaquePtr()));
94 JOS.attribute("kind", "QualType");
95 JOS.attribute("type", createQualType(T));
96 JOS.attribute("qualifiers", T.split().Quals.getAsString());
100 JOS.attribute("id", createPointerRepresentation(D));
102 if (!D)
103 return;
105 JOS.attribute("kind", (llvm::Twine(D->getDeclKindName()) + "Decl").str());
106 JOS.attributeObject("loc",
107 [D, this] { writeSourceLocation(D->getLocation()); });
108 JOS.attributeObject("range",
109 [D, this] { writeSourceRange(D->getSourceRange()); });
110 attributeOnlyIfTrue("isImplicit", D->isImplicit());
111 attributeOnlyIfTrue("isInvalid", D->isInvalidDecl());
113 if (D->isUsed())
114 JOS.attribute("isUsed", true);
115 else if (D->isThisDeclarationReferenced())
116 JOS.attribute("isReferenced", true);
118 if (const auto *ND = dyn_cast<NamedDecl>(D))
119 attributeOnlyIfTrue("isHidden", !ND->isUnconditionallyVisible());
121 if (D->getLexicalDeclContext() != D->getDeclContext()) {
122 // Because of multiple inheritance, a DeclContext pointer does not produce
123 // the same pointer representation as a Decl pointer that references the
124 // same AST Node.
125 const auto *ParentDeclContextDecl = dyn_cast<Decl>(D->getDeclContext());
126 JOS.attribute("parentDeclContextId",
127 createPointerRepresentation(ParentDeclContextDecl));
128 }
130 addPreviousDeclaration(D);
135 const comments::FullComment *FC) {
136 if (!C)
137 return;
139 JOS.attribute("id", createPointerRepresentation(C));
140 JOS.attribute("kind", C->getCommentKindName());
141 JOS.attributeObject("loc",
142 [C, this] { writeSourceLocation(C->getLocation()); });
143 JOS.attributeObject("range",
144 [C, this] { writeSourceRange(C->getSourceRange()); });
150 const Decl *From, StringRef Label) {
151 JOS.attribute("kind", "TemplateArgument");
152 if (R.isValid())
153 JOS.attributeObject("range", [R, this] { writeSourceRange(R); });
155 if (From)
156 JOS.attribute(Label.empty() ? "fromDecl" : Label, createBareDeclRef(From));
162 JOS.attribute("kind", "CXXCtorInitializer");
163 if (Init->isAnyMemberInitializer())
164 JOS.attribute("anyInit", createBareDeclRef(Init->getAnyMember()));
165 else if (Init->isBaseInitializer())
166 JOS.attribute("baseInit",
167 createQualType(QualType(Init->getBaseClass(), 0)));
168 else if (Init->isDelegatingInitializer())
169 JOS.attribute("delegatingInit",
170 createQualType(Init->getTypeSourceInfo()->getType()));
171 else
172 llvm_unreachable("Unknown initializer type");
178 JOS.attribute("kind", "Capture");
179 attributeOnlyIfTrue("byref", C.isByRef());
180 attributeOnlyIfTrue("nested", C.isNested());
181 if (C.getVariable())
182 JOS.attribute("var", createBareDeclRef(C.getVariable()));
186 JOS.attribute("associationKind", A.getTypeSourceInfo() ? "case" : "default");
187 attributeOnlyIfTrue("selected", A.isSelected());
191 if (!R)
192 return;
194 switch (R->getKind()) {
196 JOS.attribute("kind", "TypeRequirement");
197 break;
199 JOS.attribute("kind", "SimpleRequirement");
200 break;
202 JOS.attribute("kind", "CompoundRequirement");
203 break;
205 JOS.attribute("kind", "NestedRequirement");
206 break;
207 }
209 if (auto *ER = dyn_cast<concepts::ExprRequirement>(R))
210 attributeOnlyIfTrue("noexcept", ER->hasNoexceptRequirement());
212 attributeOnlyIfTrue("isDependent", R->isDependent());
213 if (!R->isDependent())
214 JOS.attribute("satisfied", R->isSatisfied());
215 attributeOnlyIfTrue("containsUnexpandedPack",
220 std::string Str;
221 llvm::raw_string_ostream OS(Str);
222 Value.printPretty(OS, Ctx, Ty);
223 JOS.attribute("value", OS.str());
226void JSONNodeDumper::writeIncludeStack(PresumedLoc Loc, bool JustFirst) {
227 if (Loc.isInvalid())
228 return;
230 JOS.attributeBegin("includedFrom");
231 JOS.objectBegin();
233 if (!JustFirst) {
234 // Walk the stack recursively, then print out the presumed location.
235 writeIncludeStack(SM.getPresumedLoc(Loc.getIncludeLoc()));
236 }
238 JOS.attribute("file", Loc.getFilename());
239 JOS.objectEnd();
240 JOS.attributeEnd();
243void JSONNodeDumper::writeBareSourceLocation(SourceLocation Loc,
244 bool IsSpelling) {
245 PresumedLoc Presumed = SM.getPresumedLoc(Loc);
246 unsigned ActualLine = IsSpelling ? SM.getSpellingLineNumber(Loc)
247 : SM.getExpansionLineNumber(Loc);
248 StringRef ActualFile = SM.getBufferName(Loc);
250 if (Presumed.isValid()) {
251 JOS.attribute("offset", SM.getDecomposedLoc(Loc).second);
252 if (LastLocFilename != ActualFile) {
253 JOS.attribute("file", ActualFile);
254 JOS.attribute("line", ActualLine);
255 } else if (LastLocLine != ActualLine)
256 JOS.attribute("line", ActualLine);
258 StringRef PresumedFile = Presumed.getFilename();
259 if (PresumedFile != ActualFile && LastLocPresumedFilename != PresumedFile)
260 JOS.attribute("presumedFile", PresumedFile);
262 unsigned PresumedLine = Presumed.getLine();
263 if (ActualLine != PresumedLine && LastLocPresumedLine != PresumedLine)
264 JOS.attribute("presumedLine", PresumedLine);
266 JOS.attribute("col", Presumed.getColumn());
267 JOS.attribute("tokLen",
268 Lexer::MeasureTokenLength(Loc, SM, Ctx.getLangOpts()));
269 LastLocFilename = ActualFile;
270 LastLocPresumedFilename = PresumedFile;
271 LastLocPresumedLine = PresumedLine;
272 LastLocLine = ActualLine;
274 // Orthogonal to the file, line, and column de-duplication is whether the
275 // given location was a result of an include. If so, print where the
276 // include location came from.
277 writeIncludeStack(SM.getPresumedLoc(Presumed.getIncludeLoc()),
278 /*JustFirst*/ true);
279 }
282void JSONNodeDumper::writeSourceLocation(SourceLocation Loc) {
283 SourceLocation Spelling = SM.getSpellingLoc(Loc);
284 SourceLocation Expansion = SM.getExpansionLoc(Loc);
286 if (Expansion != Spelling) {
287 // If the expansion and the spelling are different, output subobjects
288 // describing both locations.
289 JOS.attributeObject("spellingLoc", [Spelling, this] {
290 writeBareSourceLocation(Spelling, /*IsSpelling*/ true);
291 });
292 JOS.attributeObject("expansionLoc", [Expansion, Loc, this] {
293 writeBareSourceLocation(Expansion, /*IsSpelling*/ false);
294 // If there is a macro expansion, add extra information if the interesting
295 // bit is the macro arg expansion.
296 if (SM.isMacroArgExpansion(Loc))
297 JOS.attribute("isMacroArgExpansion", true);
298 });
299 } else
300 writeBareSourceLocation(Spelling, /*IsSpelling*/ true);
303void JSONNodeDumper::writeSourceRange(SourceRange R) {
304 JOS.attributeObject("begin",
305 [R, this] { writeSourceLocation(R.getBegin()); });
306 JOS.attributeObject("end", [R, this] { writeSourceLocation(R.getEnd()); });
309std::string JSONNodeDumper::createPointerRepresentation(const void *Ptr) {
310 // Because JSON stores integer values as signed 64-bit integers, trying to
311 // represent them as such makes for very ugly pointer values in the resulting
312 // output. Instead, we convert the value to hex and treat it as a string.
313 return "0x" + llvm::utohexstr(reinterpret_cast<uint64_t>(Ptr), true);
316llvm::json::Object JSONNodeDumper::createQualType(QualType QT, bool Desugar) {
317 SplitQualType SQT = QT.split();
318 llvm::json::Object Ret{{"qualType", QualType::getAsString(SQT, PrintPolicy)}};
320 if (Desugar && !QT.isNull()) {
322 if (DSQT != SQT)
323 Ret["desugaredQualType"] = QualType::getAsString(DSQT, PrintPolicy);
324 if (const auto *TT = QT->getAs<TypedefType>())
325 Ret["typeAliasDeclId"] = createPointerRepresentation(TT->getDecl());
326 }
327 return Ret;
330void JSONNodeDumper::writeBareDeclRef(const Decl *D) {
331 JOS.attribute("id", createPointerRepresentation(D));
332 if (!D)
333 return;
335 JOS.attribute("kind", (llvm::Twine(D->getDeclKindName()) + "Decl").str());
336 if (const auto *ND = dyn_cast<NamedDecl>(D))
337 JOS.attribute("name", ND->getDeclName().getAsString());
338 if (const auto *VD = dyn_cast<ValueDecl>(D))
339 JOS.attribute("type", createQualType(VD->getType()));
342llvm::json::Object JSONNodeDumper::createBareDeclRef(const Decl *D) {
343 llvm::json::Object Ret{{"id", createPointerRepresentation(D)}};
344 if (!D)
345 return Ret;
347 Ret["kind"] = (llvm::Twine(D->getDeclKindName()) + "Decl").str();
348 if (const auto *ND = dyn_cast<NamedDecl>(D))
349 Ret["name"] = ND->getDeclName().getAsString();
350 if (const auto *VD = dyn_cast<ValueDecl>(D))
351 Ret["type"] = createQualType(VD->getType());
352 return Ret;
355llvm::json::Array JSONNodeDumper::createCastPath(const CastExpr *C) {
356 llvm::json::Array Ret;
357 if (C->path_empty())
358 return Ret;
360 for (auto I = C->path_begin(), E = C->path_end(); I != E; ++I) {
361 const CXXBaseSpecifier *Base = *I;
362 const auto *RD =
363 cast<CXXRecordDecl>(Base->getType()->castAs<RecordType>()->getDecl());
365 llvm::json::Object Val{{"name", RD->getName()}};
366 if (Base->isVirtual())
367 Val["isVirtual"] = true;
368 Ret.push_back(std::move(Val));
369 }
370 return Ret;
373#define FIELD2(Name, Flag) if (RD->Flag()) Ret[Name] = true
374#define FIELD1(Flag) FIELD2(#Flag, Flag)
376static llvm::json::Object
378 llvm::json::Object Ret;
380 FIELD2("exists", hasDefaultConstructor);
381 FIELD2("trivial", hasTrivialDefaultConstructor);
382 FIELD2("nonTrivial", hasNonTrivialDefaultConstructor);
383 FIELD2("userProvided", hasUserProvidedDefaultConstructor);
384 FIELD2("isConstexpr", hasConstexprDefaultConstructor);
385 FIELD2("needsImplicit", needsImplicitDefaultConstructor);
386 FIELD2("defaultedIsConstexpr", defaultedDefaultConstructorIsConstexpr);
388 return Ret;
391static llvm::json::Object
393 llvm::json::Object Ret;
395 FIELD2("simple", hasSimpleCopyConstructor);
396 FIELD2("trivial", hasTrivialCopyConstructor);
397 FIELD2("nonTrivial", hasNonTrivialCopyConstructor);
398 FIELD2("userDeclared", hasUserDeclaredCopyConstructor);
399 FIELD2("hasConstParam", hasCopyConstructorWithConstParam);
400 FIELD2("implicitHasConstParam", implicitCopyConstructorHasConstParam);
401 FIELD2("needsImplicit", needsImplicitCopyConstructor);
402 FIELD2("needsOverloadResolution", needsOverloadResolutionForCopyConstructor);
404 FIELD2("defaultedIsDeleted", defaultedCopyConstructorIsDeleted);
406 return Ret;
409static llvm::json::Object
411 llvm::json::Object Ret;
413 FIELD2("exists", hasMoveConstructor);
414 FIELD2("simple", hasSimpleMoveConstructor);
415 FIELD2("trivial", hasTrivialMoveConstructor);
416 FIELD2("nonTrivial", hasNonTrivialMoveConstructor);
417 FIELD2("userDeclared", hasUserDeclaredMoveConstructor);
418 FIELD2("needsImplicit", needsImplicitMoveConstructor);
419 FIELD2("needsOverloadResolution", needsOverloadResolutionForMoveConstructor);
421 FIELD2("defaultedIsDeleted", defaultedMoveConstructorIsDeleted);
423 return Ret;
426static llvm::json::Object
428 llvm::json::Object Ret;
430 FIELD2("simple", hasSimpleCopyAssignment);
431 FIELD2("trivial", hasTrivialCopyAssignment);
432 FIELD2("nonTrivial", hasNonTrivialCopyAssignment);
433 FIELD2("hasConstParam", hasCopyAssignmentWithConstParam);
434 FIELD2("implicitHasConstParam", implicitCopyAssignmentHasConstParam);
435 FIELD2("userDeclared", hasUserDeclaredCopyAssignment);
436 FIELD2("needsImplicit", needsImplicitCopyAssignment);
437 FIELD2("needsOverloadResolution", needsOverloadResolutionForCopyAssignment);
439 return Ret;
442static llvm::json::Object
444 llvm::json::Object Ret;
446 FIELD2("exists", hasMoveAssignment);
447 FIELD2("simple", hasSimpleMoveAssignment);
448 FIELD2("trivial", hasTrivialMoveAssignment);
449 FIELD2("nonTrivial", hasNonTrivialMoveAssignment);
450 FIELD2("userDeclared", hasUserDeclaredMoveAssignment);
451 FIELD2("needsImplicit", needsImplicitMoveAssignment);
452 FIELD2("needsOverloadResolution", needsOverloadResolutionForMoveAssignment);
454 return Ret;
457static llvm::json::Object
459 llvm::json::Object Ret;
461 FIELD2("simple", hasSimpleDestructor);
462 FIELD2("irrelevant", hasIrrelevantDestructor);
463 FIELD2("trivial", hasTrivialDestructor);
464 FIELD2("nonTrivial", hasNonTrivialDestructor);
465 FIELD2("userDeclared", hasUserDeclaredDestructor);
466 FIELD2("needsImplicit", needsImplicitDestructor);
467 FIELD2("needsOverloadResolution", needsOverloadResolutionForDestructor);
469 FIELD2("defaultedIsDeleted", defaultedDestructorIsDeleted);
471 return Ret;
475JSONNodeDumper::createCXXRecordDefinitionData(const CXXRecordDecl *RD) {
476 llvm::json::Object Ret;
478 // This data is common to all C++ classes.
479 FIELD1(isGenericLambda);
480 FIELD1(isLambda);
481 FIELD1(isEmpty);
482 FIELD1(isAggregate);
483 FIELD1(isStandardLayout);
484 FIELD1(isTriviallyCopyable);
485 FIELD1(isPOD);
487 FIELD1(isPolymorphic);
488 FIELD1(isAbstract);
489 FIELD1(isLiteral);
491 FIELD1(hasUserDeclaredConstructor);
492 FIELD1(hasConstexprNonCopyMoveConstructor);
493 FIELD1(hasMutableFields);
494 FIELD1(hasVariantMembers);
495 FIELD2("canConstDefaultInit", allowConstDefaultInit);
497 Ret["defaultCtor"] = createDefaultConstructorDefinitionData(RD);
500 Ret["copyAssign"] = createCopyAssignmentDefinitionData(RD);
501 Ret["moveAssign"] = createMoveAssignmentDefinitionData(RD);
504 return Ret;
507#undef FIELD1
508#undef FIELD2
510std::string JSONNodeDumper::createAccessSpecifier(AccessSpecifier AS) {
511 const auto AccessSpelling = getAccessSpelling(AS);
512 if (AccessSpelling.empty())
513 return "none";
514 return AccessSpelling.str();
518JSONNodeDumper::createCXXBaseSpecifier(const CXXBaseSpecifier &BS) {
519 llvm::json::Object Ret;
521 Ret["type"] = createQualType(BS.getType());
522 Ret["access"] = createAccessSpecifier(BS.getAccessSpecifier());
523 Ret["writtenAccess"] =
524 createAccessSpecifier(BS.getAccessSpecifierAsWritten());
525 if (BS.isVirtual())
526 Ret["isVirtual"] = true;
527 if (BS.isPackExpansion())
528 Ret["isPackExpansion"] = true;
530 return Ret;
533void JSONNodeDumper::VisitAliasAttr(const AliasAttr *AA) {
534 JOS.attribute("aliasee", AA->getAliasee());
537void JSONNodeDumper::VisitCleanupAttr(const CleanupAttr *CA) {
538 JOS.attribute("cleanup_function", createBareDeclRef(CA->getFunctionDecl()));
541void JSONNodeDumper::VisitDeprecatedAttr(const DeprecatedAttr *DA) {
542 if (!DA->getMessage().empty())
543 JOS.attribute("message", DA->getMessage());
544 if (!DA->getReplacement().empty())
545 JOS.attribute("replacement", DA->getReplacement());
548void JSONNodeDumper::VisitUnavailableAttr(const UnavailableAttr *UA) {
549 if (!UA->getMessage().empty())
550 JOS.attribute("message", UA->getMessage());
553void JSONNodeDumper::VisitSectionAttr(const SectionAttr *SA) {
554 JOS.attribute("section_name", SA->getName());
557void JSONNodeDumper::VisitVisibilityAttr(const VisibilityAttr *VA) {
558 JOS.attribute("visibility", VisibilityAttr::ConvertVisibilityTypeToStr(
559 VA->getVisibility()));
562void JSONNodeDumper::VisitTLSModelAttr(const TLSModelAttr *TA) {
563 JOS.attribute("tls_model", TA->getModel());
567 JOS.attribute("decl", createBareDeclRef(TT->getDecl()));
568 if (!TT->typeMatchesDecl())
569 JOS.attribute("type", createQualType(TT->desugar()));
573 JOS.attribute("decl", createBareDeclRef(TT->getFoundDecl()));
574 if (!TT->typeMatchesDecl())
575 JOS.attribute("type", createQualType(TT->desugar()));
580 attributeOnlyIfTrue("noreturn", E.getNoReturn());
581 attributeOnlyIfTrue("producesResult", E.getProducesResult());
582 if (E.getHasRegParm())
583 JOS.attribute("regParm", E.getRegParm());
584 JOS.attribute("cc", FunctionType::getNameForCallConv(E.getCC()));
589 attributeOnlyIfTrue("trailingReturn", E.HasTrailingReturn);
590 attributeOnlyIfTrue("const", T->isConst());
591 attributeOnlyIfTrue("volatile", T->isVolatile());
592 attributeOnlyIfTrue("restrict", T->isRestrict());
593 attributeOnlyIfTrue("variadic", E.Variadic);
594 switch (E.RefQualifier) {
595 case RQ_LValue: JOS.attribute("refQualifier", "&"); break;
596 case RQ_RValue: JOS.attribute("refQualifier", "&&"); break;
597 case RQ_None: break;
598 }
599 switch (E.ExceptionSpec.Type) {
600 case EST_DynamicNone:
601 case EST_Dynamic: {
602 JOS.attribute("exceptionSpec", "throw");
603 llvm::json::Array Types;
605 Types.push_back(createQualType(QT));
606 JOS.attribute("exceptionTypes", std::move(Types));
607 } break;
608 case EST_MSAny:
609 JOS.attribute("exceptionSpec", "throw");
610 JOS.attribute("throwsAny", true);
611 break;
613 JOS.attribute("exceptionSpec", "noexcept");
614 break;
615 case EST_NoexceptTrue:
617 JOS.attribute("exceptionSpec", "noexcept");
618 JOS.attribute("conditionEvaluatesTo",
620 //JOS.attributeWithCall("exceptionSpecExpr",
621 // [this, E]() { Visit(E.ExceptionSpec.NoexceptExpr); });
622 break;
623 case EST_NoThrow:
624 JOS.attribute("exceptionSpec", "nothrow");
625 break;
626 // FIXME: I cannot find a way to trigger these cases while dumping the AST. I
627 // suspect you can only run into them when executing an AST dump from within
628 // the debugger, which is not a use case we worry about for the JSON dumping
629 // feature.
631 case EST_Unevaluated:
633 case EST_Unparsed:
634 case EST_None: break;
635 }
640 attributeOnlyIfTrue("spelledAsLValue", RT->isSpelledAsLValue());
644 switch (AT->getSizeModifier()) {
645 case ArrayType::Star:
646 JOS.attribute("sizeModifier", "*");
647 break;
649 JOS.attribute("sizeModifier", "static");
650 break;
652 break;
653 }
655 std::string Str = AT->getIndexTypeQualifiers().getAsString();
656 if (!Str.empty())
657 JOS.attribute("indexTypeQualifiers", Str);
661 // FIXME: this should use ZExt instead of SExt, but JSON doesn't allow a
662 // narrowing conversion to int64_t so it cannot be expressed.
663 JOS.attribute("size", CAT->getSize().getSExtValue());
664 VisitArrayType(CAT);
668 const DependentSizedExtVectorType *VT) {
669 JOS.attributeObject(
670 "attrLoc", [VT, this] { writeSourceLocation(VT->getAttributeLoc()); });
674 JOS.attribute("numElements", VT->getNumElements());
675 switch (VT->getVectorKind()) {
677 break;
679 JOS.attribute("vectorKind", "altivec");
680 break;
682 JOS.attribute("vectorKind", "altivec pixel");
683 break;
685 JOS.attribute("vectorKind", "altivec bool");
686 break;
688 JOS.attribute("vectorKind", "neon");
689 break;
691 JOS.attribute("vectorKind", "neon poly");
692 break;
694 JOS.attribute("vectorKind", "fixed-length sve data vector");
695 break;
697 JOS.attribute("vectorKind", "fixed-length sve predicate vector");
698 break;
700 JOS.attribute("vectorKind", "fixed-length rvv data vector");
701 break;
702 }
706 JOS.attribute("decl", createBareDeclRef(UUT->getDecl()));
710 switch (UTT->getUTTKind()) {
711#define TRANSFORM_TYPE_TRAIT_DEF(Enum, Trait) \
712 case UnaryTransformType::Enum: \
713 JOS.attribute("transformKind", #Trait); \
714 break;
715#include "clang/Basic/TransformTypeTraits.def"
716 }
720 JOS.attribute("decl", createBareDeclRef(TT->getDecl()));
724 const TemplateTypeParmType *TTPT) {
725 JOS.attribute("depth", TTPT->getDepth());
726 JOS.attribute("index", TTPT->getIndex());
727 attributeOnlyIfTrue("isPack", TTPT->isParameterPack());
728 JOS.attribute("decl", createBareDeclRef(TTPT->getDecl()));
732 const SubstTemplateTypeParmType *STTPT) {
733 JOS.attribute("index", STTPT->getIndex());
734 if (auto PackIndex = STTPT->getPackIndex())
735 JOS.attribute("pack_index", *PackIndex);
740 JOS.attribute("index", T->getIndex());
744 JOS.attribute("undeduced", !AT->isDeduced());
745 switch (AT->getKeyword()) {
747 JOS.attribute("typeKeyword", "auto");
748 break;
750 JOS.attribute("typeKeyword", "decltype(auto)");
751 break;
753 JOS.attribute("typeKeyword", "__auto_type");
754 break;
755 }
759 const TemplateSpecializationType *TST) {
760 attributeOnlyIfTrue("isAlias", TST->isTypeAlias());
762 std::string Str;
763 llvm::raw_string_ostream OS(Str);
764 TST->getTemplateName().print(OS, PrintPolicy);
765 JOS.attribute("templateName", OS.str());
769 const InjectedClassNameType *ICNT) {
770 JOS.attribute("decl", createBareDeclRef(ICNT->getDecl()));
774 JOS.attribute("decl", createBareDeclRef(OIT->getDecl()));
778 if (std::optional<unsigned> N = PET->getNumExpansions())
779 JOS.attribute("numExpansions", *N);
783 if (const NestedNameSpecifier *NNS = ET->getQualifier()) {
784 std::string Str;
785 llvm::raw_string_ostream OS(Str);
786 NNS->print(OS, PrintPolicy, /*ResolveTemplateArgs*/ true);
787 JOS.attribute("qualifier", OS.str());
788 }
789 if (const TagDecl *TD = ET->getOwnedTagDecl())
790 JOS.attribute("ownedTagDecl", createBareDeclRef(TD));
794 JOS.attribute("macroName", MQT->getMacroIdentifier()->getName());
798 attributeOnlyIfTrue("isData", MPT->isMemberDataPointer());
799 attributeOnlyIfTrue("isFunction", MPT->isMemberFunctionPointer());
803 if (ND && ND->getDeclName()) {
804 JOS.attribute("name", ND->getNameAsString());
805 // FIXME: There are likely other contexts in which it makes no sense to ask
806 // for a mangled name.
807 if (isa<RequiresExprBodyDecl>(ND->getDeclContext()))
808 return;
810 // If the declaration is dependent or is in a dependent context, then the
811 // mangling is unlikely to be meaningful (and in some cases may cause
812 // "don't know how to mangle this" assertion failures.
813 if (ND->isTemplated())
814 return;
816 // Mangled names are not meaningful for locals, and may not be well-defined
817 // in the case of VLAs.
818 auto *VD = dyn_cast<VarDecl>(ND);
819 if (VD && VD->hasLocalStorage())
820 return;
822 std::string MangledName = ASTNameGen.getName(ND);
823 if (!MangledName.empty())
824 JOS.attribute("mangledName", MangledName);
825 }
829 VisitNamedDecl(TD);
830 JOS.attribute("type", createQualType(TD->getUnderlyingType()));
834 VisitNamedDecl(TAD);
835 JOS.attribute("type", createQualType(TAD->getUnderlyingType()));
839 VisitNamedDecl(ND);
840 attributeOnlyIfTrue("isInline", ND->isInline());
841 attributeOnlyIfTrue("isNested", ND->isNested());
842 if (!ND->isOriginalNamespace())
843 JOS.attribute("originalNamespace",
844 createBareDeclRef(ND->getOriginalNamespace()));
848 JOS.attribute("nominatedNamespace",
849 createBareDeclRef(UDD->getNominatedNamespace()));
853 VisitNamedDecl(NAD);
854 JOS.attribute("aliasedNamespace",
855 createBareDeclRef(NAD->getAliasedNamespace()));
859 std::string Name;
860 if (const NestedNameSpecifier *NNS = UD->getQualifier()) {
861 llvm::raw_string_ostream SOS(Name);
862 NNS->print(SOS, UD->getASTContext().getPrintingPolicy());
863 }
864 Name += UD->getNameAsString();
865 JOS.attribute("name", Name);
869 JOS.attribute("target", createBareDeclRef(UED->getEnumDecl()));
873 JOS.attribute("target", createBareDeclRef(USD->getTargetDecl()));
877 VisitNamedDecl(VD);
878 JOS.attribute("type", createQualType(VD->getType()));
880 StorageClass SC = VD->getStorageClass();
881 if (SC != SC_None)
882 JOS.attribute("storageClass", VarDecl::getStorageClassSpecifierString(SC));
883 switch (VD->getTLSKind()) {
884 case VarDecl::TLS_Dynamic: JOS.attribute("tls", "dynamic"); break;
885 case VarDecl::TLS_Static: JOS.attribute("tls", "static"); break;
886 case VarDecl::TLS_None: break;
887 }
888 attributeOnlyIfTrue("nrvo", VD->isNRVOVariable());
889 attributeOnlyIfTrue("inline", VD->isInline());
890 attributeOnlyIfTrue("constexpr", VD->isConstexpr());
891 attributeOnlyIfTrue("modulePrivate", VD->isModulePrivate());
892 if (VD->hasInit()) {
893 switch (VD->getInitStyle()) {
894 case VarDecl::CInit: JOS.attribute("init", "c"); break;
895 case VarDecl::CallInit: JOS.attribute("init", "call"); break;
896 case VarDecl::ListInit: JOS.attribute("init", "list"); break;
898 JOS.attribute("init", "paren-list");
899 break;
900 }
901 }
902 attributeOnlyIfTrue("isParameterPack", VD->isParameterPack());
906 VisitNamedDecl(FD);
907 JOS.attribute("type", createQualType(FD->getType()));
908 attributeOnlyIfTrue("mutable", FD->isMutable());
909 attributeOnlyIfTrue("modulePrivate", FD->isModulePrivate());
910 attributeOnlyIfTrue("isBitfield", FD->isBitField());
911 attributeOnlyIfTrue("hasInClassInitializer", FD->hasInClassInitializer());
915 VisitNamedDecl(FD);
916 JOS.attribute("type", createQualType(FD->getType()));
917 StorageClass SC = FD->getStorageClass();
918 if (SC != SC_None)
919 JOS.attribute("storageClass", VarDecl::getStorageClassSpecifierString(SC));
920 attributeOnlyIfTrue("inline", FD->isInlineSpecified());
921 attributeOnlyIfTrue("virtual", FD->isVirtualAsWritten());
922 attributeOnlyIfTrue("pure", FD->isPure());
923 attributeOnlyIfTrue("explicitlyDeleted", FD->isDeletedAsWritten());
924 attributeOnlyIfTrue("constexpr", FD->isConstexpr());
925 attributeOnlyIfTrue("variadic", FD->isVariadic());
926 attributeOnlyIfTrue("immediate", FD->isImmediateFunction());
928 if (FD->isDefaulted())
929 JOS.attribute("explicitlyDefaulted",
930 FD->isDeleted() ? "deleted" : "default");
934 VisitNamedDecl(ED);
935 if (ED->isFixed())
936 JOS.attribute("fixedUnderlyingType", createQualType(ED->getIntegerType()));
937 if (ED->isScoped())
938 JOS.attribute("scopedEnumTag",
939 ED->isScopedUsingClassTag() ? "class" : "struct");
942 VisitNamedDecl(ECD);
943 JOS.attribute("type", createQualType(ECD->getType()));
947 VisitNamedDecl(RD);
948 JOS.attribute("tagUsed", RD->getKindName());
949 attributeOnlyIfTrue("completeDefinition", RD->isCompleteDefinition());
952 VisitRecordDecl(RD);
954 // All other information requires a complete definition.
955 if (!RD->isCompleteDefinition())
956 return;
958 JOS.attribute("definitionData", createCXXRecordDefinitionData(RD));
959 if (RD->getNumBases()) {
960 JOS.attributeArray("bases", [this, RD] {
961 for (const auto &Spec : RD->bases())
962 JOS.value(createCXXBaseSpecifier(Spec));
963 });
964 }
969 JOS.attribute("bufferKind", D->isCBuffer() ? "cbuffer" : "tbuffer");
974 JOS.attribute("tagUsed", D->wasDeclaredWithTypename() ? "typename" : "class");
975 JOS.attribute("depth", D->getDepth());
976 JOS.attribute("index", D->getIndex());
977 attributeOnlyIfTrue("isParameterPack", D->isParameterPack());
979 if (D->hasDefaultArgument())
980 JOS.attributeObject("defaultArg", [=] {
983 D->defaultArgumentWasInherited() ? "inherited from" : "previous");
984 });
988 const NonTypeTemplateParmDecl *D) {
990 JOS.attribute("type", createQualType(D->getType()));
991 JOS.attribute("depth", D->getDepth());
992 JOS.attribute("index", D->getIndex());
993 attributeOnlyIfTrue("isParameterPack", D->isParameterPack());
995 if (D->hasDefaultArgument())
996 JOS.attributeObject("defaultArg", [=] {
999 D->defaultArgumentWasInherited() ? "inherited from" : "previous");
1000 });
1004 const TemplateTemplateParmDecl *D) {
1005 VisitNamedDecl(D);
1006 JOS.attribute("depth", D->getDepth());
1007 JOS.attribute("index", D->getIndex());
1008 attributeOnlyIfTrue("isParameterPack", D->isParameterPack());
1010 if (D->hasDefaultArgument())
1011 JOS.attributeObject("defaultArg", [=] {
1012 const auto *InheritedFrom = D->getDefaultArgStorage().getInheritedFrom();
1014 InheritedFrom ? InheritedFrom->getSourceRange() : SourceLocation{},
1015 InheritedFrom,
1016 D->defaultArgumentWasInherited() ? "inherited from" : "previous");
1017 });
1021 StringRef Lang;
1022 switch (LSD->getLanguage()) {
1023 case LinkageSpecDecl::lang_c: Lang = "C"; break;
1024 case LinkageSpecDecl::lang_cxx: Lang = "C++"; break;
1025 }
1026 JOS.attribute("language", Lang);
1027 attributeOnlyIfTrue("hasBraces", LSD->hasBraces());
1031 JOS.attribute("access", createAccessSpecifier(ASD->getAccess()));
1035 if (const TypeSourceInfo *T = FD->getFriendType())
1036 JOS.attribute("type", createQualType(T->getType()));
1040 VisitNamedDecl(D);
1041 JOS.attribute("type", createQualType(D->getType()));
1042 attributeOnlyIfTrue("synthesized", D->getSynthesize());
1043 switch (D->getAccessControl()) {
1044 case ObjCIvarDecl::None: JOS.attribute("access", "none"); break;
1045 case ObjCIvarDecl::Private: JOS.attribute("access", "private"); break;
1046 case ObjCIvarDecl::Protected: JOS.attribute("access", "protected"); break;
1047 case ObjCIvarDecl::Public: JOS.attribute("access", "public"); break;
1048 case ObjCIvarDecl::Package: JOS.attribute("access", "package"); break;
1049 }
1053 VisitNamedDecl(D);
1054 JOS.attribute("returnType", createQualType(D->getReturnType()));
1055 JOS.attribute("instance", D->isInstanceMethod());
1056 attributeOnlyIfTrue("variadic", D->isVariadic());
1060 VisitNamedDecl(D);
1061 JOS.attribute("type", createQualType(D->getUnderlyingType()));
1062 attributeOnlyIfTrue("bounded", D->hasExplicitBound());
1063 switch (D->getVariance()) {
1065 break;
1067 JOS.attribute("variance", "covariant");
1068 break;
1070 JOS.attribute("variance", "contravariant");
1071 break;
1072 }
1076 VisitNamedDecl(D);
1077 JOS.attribute("interface", createBareDeclRef(D->getClassInterface()));
1078 JOS.attribute("implementation", createBareDeclRef(D->getImplementation()));
1080 llvm::json::Array Protocols;
1081 for (const auto* P : D->protocols())
1082 Protocols.push_back(createBareDeclRef(P));
1083 if (!Protocols.empty())
1084 JOS.attribute("protocols", std::move(Protocols));
1088 VisitNamedDecl(D);
1089 JOS.attribute("interface", createBareDeclRef(D->getClassInterface()));
1090 JOS.attribute("categoryDecl", createBareDeclRef(D->getCategoryDecl()));
1094 VisitNamedDecl(D);
1096 llvm::json::Array Protocols;
1097 for (const auto *P : D->protocols())
1098 Protocols.push_back(createBareDeclRef(P));
1099 if (!Protocols.empty())
1100 JOS.attribute("protocols", std::move(Protocols));
1104 VisitNamedDecl(D);
1105 JOS.attribute("super", createBareDeclRef(D->getSuperClass()));
1106 JOS.attribute("implementation", createBareDeclRef(D->getImplementation()));
1108 llvm::json::Array Protocols;
1109 for (const auto* P : D->protocols())
1110 Protocols.push_back(createBareDeclRef(P));
1111 if (!Protocols.empty())
1112 JOS.attribute("protocols", std::move(Protocols));
1116 const ObjCImplementationDecl *D) {
1117 VisitNamedDecl(D);
1118 JOS.attribute("super", createBareDeclRef(D->getSuperClass()));
1119 JOS.attribute("interface", createBareDeclRef(D->getClassInterface()));
1123 const ObjCCompatibleAliasDecl *D) {
1124 VisitNamedDecl(D);
1125 JOS.attribute("interface", createBareDeclRef(D->getClassInterface()));
1129 VisitNamedDecl(D);
1130 JOS.attribute("type", createQualType(D->getType()));
1132 switch (D->getPropertyImplementation()) {
1133 case ObjCPropertyDecl::None: break;
1134 case ObjCPropertyDecl::Required: JOS.attribute("control", "required"); break;
1135 case ObjCPropertyDecl::Optional: JOS.attribute("control", "optional"); break;
1136 }
1141 JOS.attribute("getter", createBareDeclRef(D->getGetterMethodDecl()));
1143 JOS.attribute("setter", createBareDeclRef(D->getSetterMethodDecl()));
1144 attributeOnlyIfTrue("readonly",
1146 attributeOnlyIfTrue("assign", Attrs & ObjCPropertyAttribute::kind_assign);
1147 attributeOnlyIfTrue("readwrite",
1149 attributeOnlyIfTrue("retain", Attrs & ObjCPropertyAttribute::kind_retain);
1150 attributeOnlyIfTrue("copy", Attrs & ObjCPropertyAttribute::kind_copy);
1151 attributeOnlyIfTrue("nonatomic",
1153 attributeOnlyIfTrue("atomic", Attrs & ObjCPropertyAttribute::kind_atomic);
1154 attributeOnlyIfTrue("weak", Attrs & ObjCPropertyAttribute::kind_weak);
1155 attributeOnlyIfTrue("strong", Attrs & ObjCPropertyAttribute::kind_strong);
1156 attributeOnlyIfTrue("unsafe_unretained",
1158 attributeOnlyIfTrue("class", Attrs & ObjCPropertyAttribute::kind_class);
1159 attributeOnlyIfTrue("direct", Attrs & ObjCPropertyAttribute::kind_direct);
1160 attributeOnlyIfTrue("nullability",
1162 attributeOnlyIfTrue("null_resettable",
1164 }
1169 JOS.attribute("implKind", D->getPropertyImplementation() ==
1171 ? "synthesize"
1172 : "dynamic");
1173 JOS.attribute("propertyDecl", createBareDeclRef(D->getPropertyDecl()));
1174 JOS.attribute("ivarDecl", createBareDeclRef(D->getPropertyIvarDecl()));
1178 attributeOnlyIfTrue("variadic", D->isVariadic());
1179 attributeOnlyIfTrue("capturesThis", D->capturesCXXThis());
1183 JOS.attribute("name", AE->getOpAsString());
1187 JOS.attribute("encodedType", createQualType(OEE->getEncodedType()));
1191 std::string Str;
1192 llvm::raw_string_ostream OS(Str);
1194 OME->getSelector().print(OS);
1195 JOS.attribute("selector", OS.str());
1197 switch (OME->getReceiverKind()) {
1199 JOS.attribute("receiverKind", "instance");
1200 break;
1202 JOS.attribute("receiverKind", "class");
1203 JOS.attribute("classType", createQualType(OME->getClassReceiver()));
1204 break;
1206 JOS.attribute("receiverKind", "super (instance)");
1207 JOS.attribute("superType", createQualType(OME->getSuperType()));
1208 break;
1210 JOS.attribute("receiverKind", "super (class)");
1211 JOS.attribute("superType", createQualType(OME->getSuperType()));
1212 break;
1213 }
1215 QualType CallReturnTy = OME->getCallReturnType(Ctx);
1216 if (OME->getType() != CallReturnTy)
1217 JOS.attribute("callReturnType", createQualType(CallReturnTy));
1221 if (const ObjCMethodDecl *MD = OBE->getBoxingMethod()) {
1222 std::string Str;
1223 llvm::raw_string_ostream OS(Str);
1225 MD->getSelector().print(OS);
1226 JOS.attribute("selector", OS.str());
1227 }
1231 std::string Str;
1232 llvm::raw_string_ostream OS(Str);
1234 OSE->getSelector().print(OS);
1235 JOS.attribute("selector", OS.str());
1239 JOS.attribute("protocol", createBareDeclRef(OPE->getProtocol()));
1243 if (OPRE->isImplicitProperty()) {
1244 JOS.attribute("propertyKind", "implicit");
1245 if (const ObjCMethodDecl *MD = OPRE->getImplicitPropertyGetter())
1246 JOS.attribute("getter", createBareDeclRef(MD));
1247 if (const ObjCMethodDecl *MD = OPRE->getImplicitPropertySetter())
1248 JOS.attribute("setter", createBareDeclRef(MD));
1249 } else {
1250 JOS.attribute("propertyKind", "explicit");
1251 JOS.attribute("property", createBareDeclRef(OPRE->getExplicitProperty()));
1252 }
1254 attributeOnlyIfTrue("isSuperReceiver", OPRE->isSuperReceiver());
1255 attributeOnlyIfTrue("isMessagingGetter", OPRE->isMessagingGetter());
1256 attributeOnlyIfTrue("isMessagingSetter", OPRE->isMessagingSetter());
1260 const ObjCSubscriptRefExpr *OSRE) {
1261 JOS.attribute("subscriptKind",
1262 OSRE->isArraySubscriptRefExpr() ? "array" : "dictionary");
1264 if (const ObjCMethodDecl *MD = OSRE->getAtIndexMethodDecl())
1265 JOS.attribute("getter", createBareDeclRef(MD));
1266 if (const ObjCMethodDecl *MD = OSRE->setAtIndexMethodDecl())
1267 JOS.attribute("setter", createBareDeclRef(MD));
1271 JOS.attribute("decl", createBareDeclRef(OIRE->getDecl()));
1272 attributeOnlyIfTrue("isFreeIvar", OIRE->isFreeIvar());
1273 JOS.attribute("isArrow", OIRE->isArrow());
1277 JOS.attribute("value", OBLE->getValue() ? "__objc_yes" : "__objc_no");
1281 JOS.attribute("referencedDecl", createBareDeclRef(DRE->getDecl()));
1282 if (DRE->getDecl() != DRE->getFoundDecl())
1283 JOS.attribute("foundReferencedDecl",
1284 createBareDeclRef(DRE->getFoundDecl()));
1285 switch (DRE->isNonOdrUse()) {
1286 case NOUR_None: break;
1287 case NOUR_Unevaluated: JOS.attribute("nonOdrUseReason", "unevaluated"); break;
1288 case NOUR_Constant: JOS.attribute("nonOdrUseReason", "constant"); break;
1289 case NOUR_Discarded: JOS.attribute("nonOdrUseReason", "discarded"); break;
1290 }
1291 attributeOnlyIfTrue("isImmediateEscalating", DRE->isImmediateEscalating());
1295 const SYCLUniqueStableNameExpr *E) {
1296 JOS.attribute("typeSourceInfo",
1297 createQualType(E->getTypeSourceInfo()->getType()));
1301 JOS.attribute("name", PredefinedExpr::getIdentKindName(PE->getIdentKind()));
1305 JOS.attribute("isPostfix", UO->isPostfix());
1306 JOS.attribute("opcode", UnaryOperator::getOpcodeStr(UO->getOpcode()));
1307 if (!UO->canOverflow())
1308 JOS.attribute("canOverflow", false);
1312 JOS.attribute("opcode", BinaryOperator::getOpcodeStr(BO->getOpcode()));
1316 const CompoundAssignOperator *CAO) {
1318 JOS.attribute("computeLHSType", createQualType(CAO->getComputationLHSType()));
1319 JOS.attribute("computeResultType",
1320 createQualType(CAO->getComputationResultType()));
1324 // Note, we always write this Boolean field because the information it conveys
1325 // is critical to understanding the AST node.
1326 ValueDecl *VD = ME->getMemberDecl();
1327 JOS.attribute("name", VD && VD->getDeclName() ? VD->getNameAsString() : "");
1328 JOS.attribute("isArrow", ME->isArrow());
1329 JOS.attribute("referencedMemberDecl", createPointerRepresentation(VD));
1330 switch (ME->isNonOdrUse()) {
1331 case NOUR_None: break;
1332 case NOUR_Unevaluated: JOS.attribute("nonOdrUseReason", "unevaluated"); break;
1333 case NOUR_Constant: JOS.attribute("nonOdrUseReason", "constant"); break;
1334 case NOUR_Discarded: JOS.attribute("nonOdrUseReason", "discarded"); break;
1335 }
1339 attributeOnlyIfTrue("isGlobal", NE->isGlobalNew());
1340 attributeOnlyIfTrue("isArray", NE->isArray());
1341 attributeOnlyIfTrue("isPlacement", NE->getNumPlacementArgs() != 0);
1342 switch (NE->getInitializationStyle()) {
1343 case CXXNewExpr::NoInit: break;
1344 case CXXNewExpr::CallInit: JOS.attribute("initStyle", "call"); break;
1345 case CXXNewExpr::ListInit: JOS.attribute("initStyle", "list"); break;
1346 }
1347 if (const FunctionDecl *FD = NE->getOperatorNew())
1348 JOS.attribute("operatorNewDecl", createBareDeclRef(FD));
1349 if (const FunctionDecl *FD = NE->getOperatorDelete())
1350 JOS.attribute("operatorDeleteDecl", createBareDeclRef(FD));
1353 attributeOnlyIfTrue("isGlobal", DE->isGlobalDelete());
1354 attributeOnlyIfTrue("isArray", DE->isArrayForm());
1355 attributeOnlyIfTrue("isArrayAsWritten", DE->isArrayFormAsWritten());
1356 if (const FunctionDecl *FD = DE->getOperatorDelete())
1357 JOS.attribute("operatorDeleteDecl", createBareDeclRef(FD));
1361 attributeOnlyIfTrue("implicit", TE->isImplicit());
1365 JOS.attribute("castKind", CE->getCastKindName());
1366 llvm::json::Array Path = createCastPath(CE);
1367 if (!Path.empty())
1368 JOS.attribute("path", std::move(Path));
1369 // FIXME: This may not be useful information as it can be obtusely gleaned
1370 // from the inner[] array.
1371 if (const NamedDecl *ND = CE->getConversionFunction())
1372 JOS.attribute("conversionFunc", createBareDeclRef(ND));
1376 VisitCastExpr(ICE);
1377 attributeOnlyIfTrue("isPartOfExplicitCast", ICE->isPartOfExplicitCast());
1381 attributeOnlyIfTrue("adl", CE->usesADL());
1385 const UnaryExprOrTypeTraitExpr *TTE) {
1386 JOS.attribute("name", getTraitSpelling(TTE->getKind()));
1387 if (TTE->isArgumentType())
1388 JOS.attribute("argType", createQualType(TTE->getArgumentType()));
1392 VisitNamedDecl(SOPE->getPack());
1396 const UnresolvedLookupExpr *ULE) {
1397 JOS.attribute("usesADL", ULE->requiresADL());
1398 JOS.attribute("name", ULE->getName().getAsString());
1400 JOS.attributeArray("lookups", [this, ULE] {
1401 for (const NamedDecl *D : ULE->decls())
1402 JOS.value(createBareDeclRef(D));
1403 });
1407 JOS.attribute("name", ALE->getLabel()->getName());
1408 JOS.attribute("labelDeclId", createPointerRepresentation(ALE->getLabel()));
1412 if (CTE->isTypeOperand()) {
1413 QualType Adjusted = CTE->getTypeOperand(Ctx);
1414 QualType Unadjusted = CTE->getTypeOperandSourceInfo()->getType();
1415 JOS.attribute("typeArg", createQualType(Unadjusted));
1416 if (Adjusted != Unadjusted)
1417 JOS.attribute("adjustedTypeArg", createQualType(Adjusted));
1418 }
1423 Visit(CE->getAPValueResult(), CE->getType());
1427 if (const FieldDecl *FD = ILE->getInitializedFieldInUnion())
1428 JOS.attribute("field", createBareDeclRef(FD));
1432 const GenericSelectionExpr *GSE) {
1433 attributeOnlyIfTrue("resultDependent", GSE->isResultDependent());
1437 const CXXUnresolvedConstructExpr *UCE) {
1438 if (UCE->getType() != UCE->getTypeAsWritten())
1439 JOS.attribute("typeAsWritten", createQualType(UCE->getTypeAsWritten()));
1440 attributeOnlyIfTrue("list", UCE->isListInitialization());
1444 CXXConstructorDecl *Ctor = CE->getConstructor();
1445 JOS.attribute("ctorType", createQualType(Ctor->getType()));
1446 attributeOnlyIfTrue("elidable", CE->isElidable());
1447 attributeOnlyIfTrue("list", CE->isListInitialization());
1448 attributeOnlyIfTrue("initializer_list", CE->isStdInitListInitialization());
1449 attributeOnlyIfTrue("zeroing", CE->requiresZeroInitialization());
1450 attributeOnlyIfTrue("hadMultipleCandidates", CE->hadMultipleCandidates());
1451 attributeOnlyIfTrue("isImmediateEscalating", CE->isImmediateEscalating());
1453 switch (CE->getConstructionKind()) {
1455 JOS.attribute("constructionKind", "complete");
1456 break;
1458 JOS.attribute("constructionKind", "delegating");
1459 break;
1461 JOS.attribute("constructionKind", "non-virtual base");
1462 break;
1464 JOS.attribute("constructionKind", "virtual base");
1465 break;
1466 }
1470 attributeOnlyIfTrue("cleanupsHaveSideEffects",
1472 if (EWC->getNumObjects()) {
1473 JOS.attributeArray("cleanups", [this, EWC] {
1474 for (const ExprWithCleanups::CleanupObject &CO : EWC->getObjects())
1475 if (auto *BD = CO.dyn_cast<BlockDecl *>()) {
1476 JOS.value(createBareDeclRef(BD));
1477 } else if (auto *CLE = CO.dyn_cast<CompoundLiteralExpr *>()) {
1478 llvm::json::Object Obj;
1479 Obj["id"] = createPointerRepresentation(CLE);
1480 Obj["kind"] = CLE->getStmtClassName();
1481 JOS.value(std::move(Obj));
1482 } else {
1483 llvm_unreachable("unexpected cleanup object type");
1484 }
1485 });
1486 }
1490 const CXXBindTemporaryExpr *BTE) {
1491 const CXXTemporary *Temp = BTE->getTemporary();
1492 JOS.attribute("temp", createPointerRepresentation(Temp));
1493 if (const CXXDestructorDecl *Dtor = Temp->getDestructor())
1494 JOS.attribute("dtor", createBareDeclRef(Dtor));
1498 const MaterializeTemporaryExpr *MTE) {
1499 if (const ValueDecl *VD = MTE->getExtendingDecl())
1500 JOS.attribute("extendingDecl", createBareDeclRef(VD));
1502 switch (MTE->getStorageDuration()) {
1503 case SD_Automatic:
1504 JOS.attribute("storageDuration", "automatic");
1505 break;
1506 case SD_Dynamic:
1507 JOS.attribute("storageDuration", "dynamic");
1508 break;
1509 case SD_FullExpression:
1510 JOS.attribute("storageDuration", "full expression");
1511 break;
1512 case SD_Static:
1513 JOS.attribute("storageDuration", "static");
1514 break;
1515 case SD_Thread:
1516 JOS.attribute("storageDuration", "thread");
1517 break;
1518 }
1520 attributeOnlyIfTrue("boundToLValueRef", MTE->isBoundToLvalueReference());
1524 const CXXDependentScopeMemberExpr *DSME) {
1525 JOS.attribute("isArrow", DSME->isArrow());
1526 JOS.attribute("member", DSME->getMember().getAsString());
1527 attributeOnlyIfTrue("hasTemplateKeyword", DSME->hasTemplateKeyword());
1528 attributeOnlyIfTrue("hasExplicitTemplateArgs",
1529 DSME->hasExplicitTemplateArgs());
1531 if (DSME->getNumTemplateArgs()) {
1532 JOS.attributeArray("explicitTemplateArgs", [DSME, this] {
1533 for (const TemplateArgumentLoc &TAL : DSME->template_arguments())
1534 JOS.object(
1535 [&TAL, this] { Visit(TAL.getArgument(), TAL.getSourceRange()); });
1536 });
1537 }
1541 if (!RE->isValueDependent())
1542 JOS.attribute("satisfied", RE->isSatisfied());
1546 llvm::SmallString<16> Buffer;
1547 IL->getValue().toString(Buffer,
1548 /*Radix=*/10, IL->getType()->isSignedIntegerType());
1549 JOS.attribute("value", Buffer);
1552 // FIXME: This should probably print the character literal as a string,
1553 // rather than as a numerical value. It would be nice if the behavior matched
1554 // what we do to print a string literal; right now, it is impossible to tell
1555 // the difference between 'a' and L'a' in C from the JSON output.
1556 JOS.attribute("value", CL->getValue());
1559 JOS.attribute("value", FPL->getValueAsString(/*Radix=*/10));
1562 llvm::SmallString<16> Buffer;
1563 FL->getValue().toString(Buffer);
1564 JOS.attribute("value", Buffer);
1567 std::string Buffer;
1568 llvm::raw_string_ostream SS(Buffer);
1569 SL->outputString(SS);
1570 JOS.attribute("value", SS.str());
1573 JOS.attribute("value", BLE->getValue());
1577 attributeOnlyIfTrue("hasInit", IS->hasInitStorage());
1578 attributeOnlyIfTrue("hasVar", IS->hasVarStorage());
1579 attributeOnlyIfTrue("hasElse", IS->hasElseStorage());
1580 attributeOnlyIfTrue("isConstexpr", IS->isConstexpr());
1581 attributeOnlyIfTrue("isConsteval", IS->isConsteval());
1582 attributeOnlyIfTrue("constevalIsNegated", IS->isNegatedConsteval());
1586 attributeOnlyIfTrue("hasInit", SS->hasInitStorage());
1587 attributeOnlyIfTrue("hasVar", SS->hasVarStorage());
1590 attributeOnlyIfTrue("isGNURange", CS->caseStmtIsGNURange());
1594 JOS.attribute("name", LS->getName());
1595 JOS.attribute("declId", createPointerRepresentation(LS->getDecl()));
1596 attributeOnlyIfTrue("sideEntry", LS->isSideEntry());
1599 JOS.attribute("targetLabelDeclId",
1600 createPointerRepresentation(GS->getLabel()));
1604 attributeOnlyIfTrue("hasVar", WS->hasVarStorage());
1608 // FIXME: it would be nice for the ASTNodeTraverser would handle the catch
1609 // parameter the same way for C++ and ObjC rather. In this case, C++ gets a
1610 // null child node and ObjC gets no child node.
1611 attributeOnlyIfTrue("isCatchAll", OACS->getCatchParamDecl() == nullptr);
1615 JOS.attribute("isNull", true);
1618 JOS.attribute("type", createQualType(TA.getAsType()));
1621 const TemplateArgument &TA) {
1622 JOS.attribute("decl", createBareDeclRef(TA.getAsDecl()));
1625 JOS.attribute("isNullptr", true);
1628 JOS.attribute("value", TA.getAsIntegral().getSExtValue());
1631 // FIXME: cannot just call dump() on the argument, as that doesn't specify
1632 // the output format.
1635 const TemplateArgument &TA) {
1636 // FIXME: cannot just call dump() on the argument, as that doesn't specify
1637 // the output format.
1640 const TemplateArgument &TA) {
1641 JOS.attribute("isExpr", true);
1644 JOS.attribute("isPack", true);
1647StringRef JSONNodeDumper::getCommentCommandName(unsigned CommandID) const {
1648 if (Traits)
1649 return Traits->getCommandInfo(CommandID)->Name;
1650 if (const comments::CommandInfo *Info =
1652 return Info->Name;
1653 return "<invalid>";
1657 const comments::FullComment *) {
1658 JOS.attribute("text", C->getText());
1663 JOS.attribute("name", getCommentCommandName(C->getCommandID()));
1665 switch (C->getRenderKind()) {
1667 JOS.attribute("renderKind", "normal");
1668 break;
1670 JOS.attribute("renderKind", "bold");
1671 break;
1673 JOS.attribute("renderKind", "emphasized");
1674 break;
1676 JOS.attribute("renderKind", "monospaced");
1677 break;
1679 JOS.attribute("renderKind", "anchor");
1680 break;
1681 }
1683 llvm::json::Array Args;
1684 for (unsigned I = 0, E = C->getNumArgs(); I < E; ++I)
1685 Args.push_back(C->getArgText(I));
1687 if (!Args.empty())
1688 JOS.attribute("args", std::move(Args));
1693 JOS.attribute("name", C->getTagName());
1694 attributeOnlyIfTrue("selfClosing", C->isSelfClosing());
1695 attributeOnlyIfTrue("malformed", C->isMalformed());
1697 llvm::json::Array Attrs;
1698 for (unsigned I = 0, E = C->getNumAttrs(); I < E; ++I)
1699 Attrs.push_back(
1700 {{"name", C->getAttr(I).Name}, {"value", C->getAttr(I).Value}});
1702 if (!Attrs.empty())
1703 JOS.attribute("attrs", std::move(Attrs));
1708 JOS.attribute("name", C->getTagName());
1713 JOS.attribute("name", getCommentCommandName(C->getCommandID()));
1715 llvm::json::Array Args;
1716 for (unsigned I = 0, E = C->getNumArgs(); I < E; ++I)
1717 Args.push_back(C->getArgText(I));
1719 if (!Args.empty())
1720 JOS.attribute("args", std::move(Args));
1725 switch (C->getDirection()) {
1727 JOS.attribute("direction", "in");
1728 break;
1730 JOS.attribute("direction", "out");
1731 break;
1733 JOS.attribute("direction", "in,out");
1734 break;
1735 }
1736 attributeOnlyIfTrue("explicit", C->isDirectionExplicit());
1738 if (C->hasParamName())
1739 JOS.attribute("param", C->isParamIndexValid() ? C->getParamName(FC)
1740 : C->getParamNameAsWritten());
1742 if (C->isParamIndexValid() && !C->isVarArgParam())
1743 JOS.attribute("paramIdx", C->getParamIndex());
1748 if (C->hasParamName())
1749 JOS.attribute("param", C->isPositionValid() ? C->getParamName(FC)
1750 : C->getParamNameAsWritten());
1751 if (C->isPositionValid()) {
1752 llvm::json::Array Positions;
1753 for (unsigned I = 0, E = C->getDepth(); I < E; ++I)
1754 Positions.push_back(C->getIndex(I));
1756 if (!Positions.empty())
1757 JOS.attribute("positions", std::move(Positions));
1758 }
1763 JOS.attribute("name", getCommentCommandName(C->getCommandID()));
1764 JOS.attribute("closeName", C->getCloseName());
1769 const comments::FullComment *) {
1770 JOS.attribute("text", C->getText());
1775 JOS.attribute("text", C->getText());
1778llvm::json::Object JSONNodeDumper::createFPOptions(FPOptionsOverride FPO) {
1779 llvm::json::Object Ret;
1781 if (FPO.has##NAME##Override()) \
1782 Ret.try_emplace(#NAME, static_cast<unsigned>(FPO.get##NAME##Override()));
1783#include "clang/Basic/FPOptions.def"
1784 return Ret;
1788 VisitStmt(S);
1789 if (S->hasStoredFPFeatures())
1790 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:2939
#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:1501
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:761
const clang::PrintingPolicy & getPrintingPolicy() const
Definition: ASTContext.h:683
std::string getName(const Decl *D)
Definition: Mangle.cpp:597
Represents an access specifier followed by colon ':'.
Definition: DeclCXX.h:86
AddrLabelExpr - The GNU address of label extension, representing &&label.
Definition: Expr.h:4332
LabelDecl * getLabel() const
Definition: Expr.h:4355
Represents an array type, per C99 - Array Declarators.
Definition: Type.h:3083
ArraySizeModifier getSizeModifier() const
Definition: Type.h:3106
Qualifiers getIndexTypeQualifiers() const
Definition: Type.h:3110
AtomicExpr - Variadic atomic builtins: __atomic_exchange, __atomic_fetch_*, __atomic_load,...
Definition: Expr.h:6418
StringRef getOpAsString() const
Definition: Expr.h:6483
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:5365
AutoTypeKeyword getKeyword() const
Definition: Type.h:5396
A builtin binary operation expression such as "x + y" or "x <= y".
Definition: Expr.h:3834
StringRef getOpcodeStr() const
Definition: Expr.h:3899
Opcode getOpcode() const
Definition: Expr.h:3878
A class which contains all the information about a particular captured value.
Definition: Decl.h:4385
Represents a block literal declaration, which is like an unnamed FunctionDecl.
Definition: Decl.h:4379
bool capturesCXXThis() const
Definition: Decl.h:4511
bool isVariadic() const
Definition: Decl.h:4454
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:1475
CXXTemporary * getTemporary()
Definition: ExprCXX.h:1493
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:1523
bool isElidable() const
Whether this construction is elidable.
Definition: ExprCXX.h:1601
bool hadMultipleCandidates() const
Whether the referred constructor was resolved from an overloaded set having size greater than 1.
Definition: ExprCXX.h:1606
bool isStdInitListInitialization() const
Whether this constructor call was written as list-initialization, but was interpreted as forming a st...
Definition: ExprCXX.h:1625
bool isImmediateEscalating() const
Definition: ExprCXX.h:1689
bool requiresZeroInitialization() const
Whether this construction first requires zero-initialization before the initializer is called.
Definition: ExprCXX.h:1634
ConstructionKind getConstructionKind() const
Determine whether this constructor is actually constructing a base class (rather than a complete obje...
Definition: ExprCXX.h:1643
CXXConstructorDecl * getConstructor() const
Get the constructor that this expression will (ultimately) call.
Definition: ExprCXX.h:1595
bool isListInitialization() const
Whether this constructor call was written as list-initialization.
Definition: ExprCXX.h:1614
Represents a C++ constructor within a class.
Definition: DeclCXX.h:2491
Represents a C++ base or member initializer.
Definition: DeclCXX.h:2259
Represents a delete expression for memory deallocation and destructor calls, e.g.
Definition: ExprCXX.h:2486
FunctionDecl * getOperatorDelete() const
Definition: ExprCXX.h:2525
bool isArrayForm() const
Definition: ExprCXX.h:2512
bool isGlobalDelete() const
Definition: ExprCXX.h:2511
bool isArrayFormAsWritten() const
Definition: ExprCXX.h:2513
Represents a C++ member access expression where the actual member referenced could not be resolved be...
Definition: ExprCXX.h:3642
bool isArrow() const
Determine whether this member expression used the '->' operator; otherwise, it used the '.
Definition: ExprCXX.h:3745
unsigned getNumTemplateArgs() const
Retrieve the number of template arguments provided as part of this template-id.
Definition: ExprCXX.h:3840
bool hasExplicitTemplateArgs() const
Determines whether this member expression actually had a C++ template argument list explicitly specif...
Definition: ExprCXX.h:3819
DeclarationName getMember() const
Retrieve the name of the member that this expression refers to.
Definition: ExprCXX.h:3784
bool hasTemplateKeyword() const
Determines whether the member name was preceded by the template keyword.
Definition: ExprCXX.h:3815
ArrayRef< TemplateArgumentLoc > template_arguments() const
Definition: ExprCXX.h:3847
Represents a C++ destructor within a class.
Definition: DeclCXX.h:2755
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)".
Definition: ExprCXX.h:2212
@ ListInit
New-expression has a C++11 list-initializer.
Definition: ExprCXX.h:2270
@ CallInit
New-expression has a C++98 paren-delimited initializer.
Definition: ExprCXX.h:2267
@ NoInit
New-expression has no initializer as written.
Definition: ExprCXX.h:2264
Represents a C++ struct/union/class.
Definition: DeclCXX.h:254
base_class_range bases()
Definition: DeclCXX.h:606
unsigned getNumBases() const
Retrieves the number of base classes of this class.
Definition: DeclCXX.h:600
bool needsOverloadResolutionForMoveConstructor() const
Determine whether we need to eagerly declare a defaulted move constructor for this class.
Definition: DeclCXX.h:893
bool needsOverloadResolutionForDestructor() const
Determine whether we need to eagerly declare a destructor for this class.
Definition: DeclCXX.h:1004
bool needsOverloadResolutionForCopyConstructor() const
Determine whether we need to eagerly declare a defaulted copy constructor for this class.
Definition: DeclCXX.h:803
Represents a C++ temporary.
Definition: ExprCXX.h:1443
const CXXDestructorDecl * getDestructor() const
Definition: ExprCXX.h:1454
Represents the this expression in C++.
Definition: ExprCXX.h:1148
bool isImplicit() const
Definition: ExprCXX.h:1170
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:3516
bool isListInitialization() const
Determine whether this expression models list-initialization.
Definition: ExprCXX.h:3571
QualType getTypeAsWritten() const
Retrieve the type that is being constructed, as specified in the source code.
Definition: ExprCXX.h:3550
CallExpr - Represents a function call (C99, C++ []).
Definition: Expr.h:2832
bool usesADL() const
Definition: Expr.h:2992
CaseStmt - Represent a case statement.
Definition: Stmt.h:1622
bool caseStmtIsGNURange() const
True if this case statement is of the form case LHS ... RHS, which is a GNU extension.
Definition: Stmt.h:1689
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
Definition: Expr.h:3502
NamedDecl * getConversionFunction() const
If this cast applies a user-defined conversion, retrieve the conversion function that it invokes.
Definition: Expr.cpp:2019
static const char * getCastKindName(CastKind CK)
Definition: Expr.cpp:1968
unsigned getValue() const
Definition: Expr.h:1641
CompoundAssignOperator - For compound assignments (e.g.
Definition: Expr.h:4082
QualType getComputationLHSType() const
Definition: Expr.h:4116
QualType getComputationResultType() const
Definition: Expr.h:4119
CompoundLiteralExpr - [C99].
Definition: Expr.h:3432
CompoundStmt - This represents a group of statements like { stmt stmt }.
Definition: Stmt.h:1429
Represents the canonical version of C arrays with a specified constant size.
Definition: Type.h:3131
const llvm::APInt & getSize() const
Definition: Type.h:3152
ConstantExpr - An expression that occurs in a constant context and optionally the result of evaluatin...
Definition: Expr.h:1049
APValue getAPValueResult() const
Definition: Expr.cpp:465
APValue::ValueKind getResultAPValueKind() const
Definition: Expr.h:1119
A reference to a declared variable, function, enum, etc.
Definition: Expr.h:1242
NamedDecl * getFoundDecl()
Get the NamedDecl through which this reference occurred.
Definition: Expr.h:1347
ValueDecl * getDecl()
Definition: Expr.h:1310
NonOdrUseReason isNonOdrUse() const
Is this expression a non-odr-use reference, and if so, why?
Definition: Expr.h:1434
bool isImmediateEscalating() const
Definition: Expr.h:1444
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:83
ASTContext & getASTContext() const LLVM_READONLY
Definition: DeclBase.cpp:429
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
Definition: DeclBase.h:576
bool isTemplated() const
Determine whether this declaration is a templated entity (whether it is.
Definition: DeclBase.cpp:263
bool isInvalidDecl() const
Definition: DeclBase.h:571
SourceLocation getLocation() const
Definition: DeclBase.h:432
const char * getDeclKindName() const
Definition: DeclBase.cpp:124
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:458
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:886
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:5353
const ParmDecl * getInheritedFrom() const
Get the parameter from which we inherit the default argument, if any.
Definition: DeclTemplate.h:361
Represents an extended vector type where either the type or size is dependent.
Definition: Type.h:3391
SourceLocation getAttributeLoc() const
Definition: Type.h:3408
Represents a type that was referred to using an elaborated type keyword, e.g., struct S,...
Definition: Type.h:5757
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:5805
NestedNameSpecifier * getQualifier() const
Retrieve the qualification on this type.
Definition: Type.h:5792
An instance of this object exists for each enum constant that is defined.
Definition: Decl.h:3197
Represents an enum.
Definition: Decl.h:3758
bool isScoped() const
Returns true if this is a C++11 scoped enumeration.
Definition: Decl.h:3963
bool isScopedUsingClassTag() const
Returns true if this is a C++11 scoped enumeration.
Definition: Decl.h:3966
bool isFixed() const
Returns true if this is an Objective-C, C++11, or Microsoft-style enumeration with a fixed underlying...
Definition: Decl.h:3972
QualType getIntegerType() const
Return the integer type this enum decl corresponds to.
Definition: Decl.h:3918
Represents an expression – generally a full-expression – that introduces cleanups to be run at the en...
Definition: ExprCXX.h:3433
bool cleanupsHaveSideEffects() const
Definition: ExprCXX.h:3468
ArrayRef< CleanupObject > getObjects() const
Definition: ExprCXX.h:3457
unsigned getNumObjects() const
Definition: ExprCXX.h:3461
llvm::PointerUnion< BlockDecl *, CompoundLiteralExpr * > CleanupObject
The type of objects that are kept in the cleanup.
Definition: ExprCXX.h:3439
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:820
Represents a member of a struct/union/class.
Definition: Decl.h:2962
bool isMutable() const
Determines whether this field is mutable (C++ only).
Definition: Decl.h:3047
bool isBitField() const
Determines whether this field is a bitfield.
Definition: Decl.h:3050
bool hasInClassInitializer() const
Determine whether this member has a C++11 default member initializer.
Definition: Decl.h:3120
std::string getValueAsString(unsigned Radix) const
Definition: Expr.cpp:1035
llvm::APFloat getValue() const
Definition: Expr.h:1676
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:1919
bool isPure() const
Whether this virtual function is pure, i.e.
Definition: Decl.h:2257
bool isImmediateFunction() const
Definition: Decl.cpp:3226
bool isVariadic() const
Whether this function is variadic.
Definition: Decl.cpp:3062
bool isDeleted() const
Whether this function has been deleted.
Definition: Decl.h:2437
StorageClass getStorageClass() const
Returns the storage class as written in the source.
Definition: Decl.h:2700
bool isConstexpr() const
Whether this is a (C++11) constexpr function or constexpr constructor.
Definition: Decl.h:2367
bool isDeletedAsWritten() const
Definition: Decl.h:2441
bool isDefaulted() const
Whether this function is defaulted.
Definition: Decl.h:2282
bool isVirtualAsWritten() const
Whether this function is marked as virtual explicitly.
Definition: Decl.h:2248
bool isInlineSpecified() const
Determine whether the "inline" keyword was specified for this function.
Definition: Decl.h:2711
Represents a prototype with parameter type info, e.g.
Definition: Type.h:4117
ExtProtoInfo getExtProtoInfo() const
Definition: Type.h:4345
A class which abstracts out some details necessary for making a call.
Definition: Type.h:3862
CallingConv getCC() const
Definition: Type.h:3924
unsigned getRegParm() const
Definition: Type.h:3917
bool getHasRegParm() const
Definition: Type.h:3915
bool getNoReturn() const
Definition: Type.h:3910
bool getProducesResult() const
Definition: Type.h:3911
FunctionType - C99 - Function Declarators.
Definition: Type.h:3751
ExtInfo getExtInfo() const
Definition: Type.h:4047
static StringRef getNameForCallConv(CallingConv CC)
Definition: Type.cpp:3354
bool isConst() const
Definition: Type.h:4053
bool isRestrict() const
Definition: Type.h:4055
bool isVolatile() const
Definition: Type.h:4054
Represents a C11 generic selection.
Definition: Expr.h:5707
AssociationTy< true > ConstAssociation
Definition: Expr.h:5938
bool isResultDependent() const
Whether this generic selection is result-dependent.
Definition: Expr.h:5958
GotoStmt - This represents a direct goto.
Definition: Stmt.h:2683
LabelDecl * getLabel() const
Definition: Stmt.h:2696
HLSLBufferDecl - Represent a cbuffer or tbuffer declaration.
Definition: Decl.h:4825
bool isCBuffer() const
Definition: Decl.h:4853
StringRef getName() const
Return the actual identifier string.
IfStmt - This represents an if/then/else.
Definition: Stmt.h:1959
bool hasElseStorage() const
True if this IfStmt has storage for an else statement.
Definition: Stmt.h:2034
bool hasVarStorage() const
True if this IfStmt has storage for a variable declaration.
Definition: Stmt.h:2031
bool isConstexpr() const
Definition: Stmt.h:2152
bool hasInitStorage() const
True if this IfStmt has the storage for an init statement.
Definition: Stmt.h:2028
bool isNegatedConsteval() const
Definition: Stmt.h:2148
bool isConsteval() const
Definition: Stmt.h:2139
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
Definition: Expr.h:3649
bool isPartOfExplicitCast() const
Definition: Expr.h:3680
Describes an C or C++ initializer list.
Definition: Expr.h:4830
FieldDecl * getInitializedFieldInUnion()
If this initializes a union, specifies which field in the union to initialize.
Definition: Expr.h:4949
The injected class name of a C++ class template or class template partial specialization.
Definition: Type.h:5607
CXXRecordDecl * getDecl() const
Definition: Type.cpp:3861
void VisitObjCSubscriptRefExpr(const ObjCSubscriptRefExpr *OSRE)
void VisitObjCInterfaceDecl(const ObjCInterfaceDecl *D)
void VisitUnresolvedLookupExpr(const UnresolvedLookupExpr *ULE)
void VisitCleanupAttr(const CleanupAttr *CA)
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 VisitDeprecatedAttr(const DeprecatedAttr *DA)
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 VisitVisibilityAttr(const VisibilityAttr *VA)
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 VisitAtomicExpr(const AtomicExpr *AE)
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 VisitUnavailableAttr(const UnavailableAttr *UA)
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 VisitAliasAttr(const AliasAttr *AA)
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 VisitSectionAttr(const SectionAttr *SA)
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 VisitTLSModelAttr(const TLSModelAttr *TA)
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:1852
LabelDecl * getDecl() const
Definition: Stmt.h:1870
bool isSideEntry() const
Definition: Stmt.h:1891
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:2884
LanguageIDs getLanguage() const
Return the language specified by this linkage specification.
Definition: DeclCXX.h:2913
bool hasBraces() const
Determines whether this linkage specification had braces in its syntactic form.
Definition: DeclCXX.h:2922
Sugar type that represents a type that was qualified by a qualifier written as a macro invocation.
Definition: Type.h:4688
const IdentifierInfo * getMacroIdentifier() const
Definition: Type.h:4703
Represents a prvalue temporary that is written into memory so that a reference can bind to it.
Definition: ExprCXX.h:4577
StorageDuration getStorageDuration() const
Retrieve the storage duration for the materialized temporary.
Definition: ExprCXX.h:4602
bool isBoundToLvalueReference() const
Determine whether this materialized temporary is bound to an lvalue reference; otherwise,...
Definition: ExprCXX.h:4646
ValueDecl * getExtendingDecl()
Get the declaration which triggered the lifetime-extension of this temporary, if any.
Definition: ExprCXX.h:4627
MemberExpr - [C99] Structure and Union Members.
Definition: Expr.h:3195
ValueDecl * getMemberDecl() const
Retrieve the member declaration to which this expression refers.
Definition: Expr.h:3274
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:3415
bool isArrow() const
Definition: Expr.h:3375
A pointer to member type per C++ 8.3.3 - Pointers to members.
Definition: Type.h:3031
bool isMemberFunctionPointer() const
Returns true if the member type (i.e.
Definition: Type.h:3051
bool isMemberDataPointer() const
Returns true if the member type (i.e.
Definition: Type.h:3057
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:3074
NamedDecl * getAliasedNamespace() const
Retrieve the namespace that this alias refers to, which may either be a NamespaceDecl or a NamespaceA...
Definition: DeclCXX.h:3169
Represent a C++ namespace.
Definition: Decl.h:544
bool isOriginalNamespace() const
Return true if this declaration is an original (first) declaration of the namespace.
Definition: DeclCXX.cpp:2943
bool isInline() const
Returns true if this is an inline namespace declaration.
Definition: Decl.h:607
NamespaceDecl * getOriginalNamespace()
Get the original (first) namespace declaration.
Definition: DeclCXX.cpp:2929
bool isNested() const
Returns true if this is a nested namespace declaration.
Definition: Decl.h:624
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:6339
ObjCInterfaceDecl * getDecl() const
Get the declaration of this interface.
Definition: Type.cpp:853
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:3065
DeclarationName getName() const
Gets the name looked up.
Definition: ExprCXX.h:3076
Represents a pack expansion of types.
Definition: Type.h:5956
std::optional< unsigned > getNumExpansions() const
Retrieve the number of expansions that this pack expansion will generate, if known.
Definition: Type.h:5981
[C99] - A predefined identifier such as func.
Definition: Expr.h:1985
StringRef getIdentKindName() const
Definition: Expr.h:2057
IdentKind getIdentKind() const
Definition: Expr.h:2035
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:1088
SplitQualType split() const
Divides a QualType into its unqualified type and a set of local qualifiers.
Definition: Type.h:6768
std::string getAsString() const
void * getAsOpaquePtr() const
Definition: Type.h:783
std::string getAsString() const
Represents a struct/union/class.
Definition: Decl.h:4036
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Definition: Type.h:4933
RecordDecl * getDecl() const
Definition: Type.h:4943
Base for LValueReferenceType and RValueReferenceType.
Definition: Type.h:2951
bool isSpelledAsLValue() const
Definition: Type.h:2964
C++2a [expr.prim.req]: A requires-expression provides a concise way to express requirements on templa...
Definition: ExprConcepts.h:507
bool isSatisfied() const
Whether or not the requires clause is satisfied.
Definition: ExprConcepts.h:559
TypeSourceInfo * getTypeSourceInfo()
Definition: Expr.h:2103
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:4217
NamedDecl * getPack() const
Retrieve the parameter pack.
Definition: ExprCXX.h:4286
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:1793
void outputString(raw_ostream &OS) const
Definition: Expr.cpp:1236
Represents the result of substituting a set of types for a template type parameter pack.
Definition: Type.h:5273
unsigned getIndex() const
Returns the index of the replaced parameter in the associated declaration.
Definition: Type.h:5299
Represents the result of substituting a type for a template type parameter.
Definition: Type.h:5203
std::optional< unsigned > getPackIndex() const
Definition: Type.h:5233
unsigned getIndex() const
Returns the index of the replaced parameter in the associated declaration.
Definition: Type.h:5231
SwitchStmt - This represents a 'switch' stmt.
Definition: Stmt.h:2209
bool hasVarStorage() const
True if this SwitchStmt has storage for a condition variable.
Definition: Stmt.h:2270
bool hasInitStorage() const
True if this SwitchStmt has storage for an init statement.
Definition: Stmt.h:2267
Represents the declaration of a struct/union/class/enum.
Definition: Decl.h:3477
StringRef getKindName() const
Definition: Decl.h:3668
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
Definition: Decl.h:3580
TagDecl * getDecl() const
Definition: Type.cpp:3763
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:5475
TemplateName getTemplateName() const
Retrieve the name of the template that we are specializing.
Definition: Type.h:5541
bool isTypeAlias() const
Determine if this template specialization type is for a type alias template that has been substituted...
Definition: Type.h:5534
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:5166
bool isParameterPack() const
Definition: Type.h:5164
unsigned getIndex() const
Definition: Type.h:5163
unsigned getDepth() const
Definition: Type.h:5162
Represents the declaration of a typedef-name via a C++11 alias-declaration.
Definition: Decl.h:3449
A container of type source information.
Definition: Type.h:6718
QualType getType() const
Return the type wrapped by this type source info.
Definition: Type.h:6729
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:1597
bool isSignedIntegerType() const
Return true if this is an integer type that is signed, according to C99 6.2.5p4 [char,...
Definition: Type.cpp:2087
bool isInstantiationDependentType() const
Determine whether this type is an instantiation-dependent type, meaning that the type involves a temp...
Definition: Type.h:2373
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
Definition: Type.h:2365
bool containsUnexpandedParameterPack() const
Whether this type is or contains an unexpanded parameter pack, used to support C++0x variadic templat...
Definition: Type.h:2037
const char * getTypeClassName() const
Definition: Type.cpp:3145
bool containsErrors() const
Whether this type is an error type.
Definition: Type.h:2359
bool isVariablyModifiedType() const
Whether this type is a variably-modified type (C99 6.7.5).
Definition: Type.h:2383
bool isFromAST() const
Whether this type comes from an AST file.
Definition: Type.h:2020
const T * getAs() const
Member-template getAs<specific type>'.
Definition: Type.h:7523
Represents the declaration of a typedef-name via the 'typedef' type specifier.
Definition: Decl.h:3429
QualType getUnderlyingType() const
Definition: Decl.h:3382
TypedefNameDecl * getDecl() const
Definition: Type.h:4663
QualType desugar() const
Definition: Type.cpp:3640
bool typeMatchesDecl() const
Definition: Type.h:4671
UnaryExprOrTypeTraitExpr - expression with either a type or (unevaluated) expression operand.
Definition: Expr.h:2580
QualType getArgumentType() const
Definition: Expr.h:2623
bool isArgumentType() const
Definition: Expr.h:2622
UnaryExprOrTypeTrait getKind() const
Definition: Expr.h:2612
UnaryOperator - This represents the unary-expression's (except sizeof and alignof),...
Definition: Expr.h:2195
static bool isPostfix(Opcode Op)
isPostfix - Return true if this is a postfix operation, like x++.
Definition: Expr.h:2269
Opcode getOpcode() const
Definition: Expr.h:2235
static StringRef getOpcodeStr(Opcode Op)
getOpcodeStr - Turn an Opcode enum value into the punctuation char it corresponds to,...
Definition: Expr.cpp:1420
bool canOverflow() const
Returns true if the unary operator can cause an overflow.
Definition: Expr.h:2253
A unary type transform, which is a type constructed from another.
Definition: Type.h:4850
UTTKind getUTTKind() const
Definition: Type.h:4879
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
Definition: ExprCXX.h:3164
bool requiresADL() const
True if this declaration should be extended by argument-dependent lookup.
Definition: ExprCXX.h:3228
Represents the dependent type named by a dependently-scoped typename using declaration,...
Definition: Type.h:4589
UnresolvedUsingTypenameDecl * getDecl() const
Definition: Type.h:4600
Represents a C++ using-declaration.
Definition: DeclCXX.h:3466
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies the name.
Definition: DeclCXX.h:3503
Represents C++ using-directive.
Definition: DeclCXX.h:2969
NamespaceDecl * getNominatedNamespace()
Returns the namespace nominated by this using-directive.
Definition: DeclCXX.cpp:2892
Represents a C++ using-enum-declaration.
Definition: DeclCXX.h:3666
EnumDecl * getEnumDecl() const
Definition: DeclCXX.h:3710
Represents a shadow declaration implicitly introduced into a scope by a (resolved) using-declaration ...
Definition: DeclCXX.h:3274
NamedDecl * getTargetDecl() const
Gets the underlying declaration which has been brought into the local scope.
Definition: DeclCXX.h:3338
QualType desugar() const
Definition: Type.h:4635
UsingShadowDecl * getFoundDecl() const
Definition: Type.h:4629
bool typeMatchesDecl() const
Definition: Type.h:4638
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition: Decl.h:703
QualType getType() const
Definition: Decl.h:714
Represents a variable declaration or definition.
Definition: Decl.h:915
bool isConstexpr() const
Whether this variable is (C++11) constexpr.
Definition: Decl.h:1521
TLSKind getTLSKind() const
Definition: Decl.cpp:2147
bool hasInit() const
Definition: Decl.cpp:2378
InitializationStyle getInitStyle() const
The style of initialization for this declaration.
Definition: Decl.h:1418
static const char * getStorageClassSpecifierString(StorageClass SC)
Return the string used to specify the storage class SC.
Definition: Decl.cpp:2100
@ ListInit
Direct list-initialization (C++11)
Definition: Decl.h:926
@ CInit
C-style initialization with assignment.
Definition: Decl.h:920
@ ParenListInit
Parenthesized list-initialization (C++20)
Definition: Decl.h:929
@ CallInit
Call-style initialization (C++98)
Definition: Decl.h:923
bool isNRVOVariable() const
Determine whether this local variable can be used with the named return value optimization (NRVO).
Definition: Decl.h:1464
bool isInline() const
Whether this variable is (C++1z) inline.
Definition: Decl.h:1503
@ TLS_Static
TLS with a known-constant initializer.
Definition: Decl.h:938
@ TLS_Dynamic
TLS with a dynamic initializer.
Definition: Decl.h:941
@ TLS_None
Not a TLS variable.
Definition: Decl.h:935
StorageClass getStorageClass() const
Returns the storage class as written in the source.
Definition: Decl.h:1127
bool isParameterPack() const
Determine whether this variable is actually a function parameter pack or init-capture pack.
Definition: Decl.cpp:2636
Represents a GCC generic vector type.
Definition: Type.h:3431
unsigned getNumElements() const
Definition: Type.h:3476
@ AltiVecBool
is AltiVec 'vector bool ...'
Definition: Type.h:3444
@ RVVFixedLengthDataVector
is RISC-V RVV fixed-length data vector
Definition: Type.h:3459
@ SveFixedLengthPredicateVector
is AArch64 SVE fixed-length predicate vector
Definition: Type.h:3456
@ NeonPolyVector
is ARM Neon polynomial vector
Definition: Type.h:3450
@ GenericVector
not a target-specific vector type
Definition: Type.h:3435
@ AltiVecPixel
is AltiVec 'vector Pixel'
Definition: Type.h:3441
@ SveFixedLengthDataVector
is AArch64 SVE fixed-length data vector
Definition: Type.h:3453
@ AltiVecVector
is AltiVec vector
Definition: Type.h:3438
@ NeonVector
is ARM Neon vector
Definition: Type.h:3447
VectorKind getVectorKind() const
Definition: Type.h:3481
WhileStmt - This represents a 'while' stmt.
Definition: Stmt.h:2405
bool hasVarStorage() const
True if this WhileStmt has storage for a condition variable.
Definition: Stmt.h:2455
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:168
RequirementKind getKind() const
Definition: ExprConcepts.h:195
bool containsUnexpandedParameterPack() const
Definition: ExprConcepts.h:215
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:202
@ GNUAutoType
__auto_type (GNU extension)
@ DecltypeAuto
llvm::StringRef getAccessSpelling(AccessSpecifier AS)
Definition: Specifiers.h:388
@ RQ_None
No ref-qualifier was provided.
Definition: Type.h:1550
@ RQ_LValue
An lvalue ref-qualifier was provided (&).
Definition: Type.h:1553
@ RQ_RValue
An rvalue ref-qualifier was provided (&&).
Definition: Type.h:1556
Storage classes.
Definition: Specifiers.h:239
@ SC_None
Definition: Specifiers.h:241
@ C
Languages that the frontend can parse and compile.
@ SD_Thread
Thread storage duration.
Definition: Specifiers.h:317
@ SD_Static
Static storage duration.
Definition: Specifiers.h:318
@ SD_FullExpression
Full-expression storage duration (for temporaries).
Definition: Specifiers.h:315
@ SD_Automatic
Automatic storage duration (most local variables).
Definition: Specifiers.h:316
@ SD_Dynamic
Dynamic storage duration.
Definition: Specifiers.h:319
@ VK_PRValue
A pr-value expression (in the C++11 taxonomy) produces a temporary value.
Definition: Specifiers.h:126
@ VK_XValue
An x-value expression is a reference to an object with independent storage but which can be "moved",...
Definition: Specifiers.h:135
@ VK_LValue
An l-value expression is a reference to an object with independent storage.
Definition: Specifiers.h:130
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:114
@ NOUR_Discarded
This name appears as a potential result of a discarded value expression.
Definition: Specifiers.h:174
@ NOUR_Unevaluated
This name appears in an unevaluated operand.
Definition: Specifiers.h:168
@ NOUR_None
This is an odr-use.
Definition: Specifiers.h:166
@ NOUR_Constant
This name appears as a potential result of an lvalue-to-rvalue conversion that is a constant expressi...
Definition: Specifiers.h:171
unsigned long uint64_t
ExceptionSpecificationType Type
The kind of exception specification this is.
Definition: Type.h:4170
ArrayRef< QualType > Exceptions
Explicitly-specified list of exception types.
Definition: Type.h:4173
Extra information about a function prototype.
Definition: Type.h:4194
ExceptionSpecInfo ExceptionSpec
Definition: Type.h:4201
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.