diff options
Diffstat (limited to 'clang/lib/AST/JSONNodeDumper.cpp')
-rw-r--r-- | clang/lib/AST/JSONNodeDumper.cpp | 71 |
1 files changed, 62 insertions, 9 deletions
diff --git a/clang/lib/AST/JSONNodeDumper.cpp b/clang/lib/AST/JSONNodeDumper.cpp index 7b99546bbe2d..f09f9d38759f 100644 --- a/clang/lib/AST/JSONNodeDumper.cpp +++ b/clang/lib/AST/JSONNodeDumper.cpp @@ -59,7 +59,9 @@ void JSONNodeDumper::Visit(const Stmt *S) { switch (E->getValueKind()) { case VK_LValue: Category = "lvalue"; break; case VK_XValue: Category = "xvalue"; break; - case VK_RValue: Category = "rvalue"; break; + case VK_PRValue: + Category = "prvalue"; + break; } JOS.attribute("valueCategory", Category); } @@ -183,6 +185,35 @@ void JSONNodeDumper::Visit(const GenericSelectionExpr::ConstAssociation &A) { attributeOnlyIfTrue("selected", A.isSelected()); } +void JSONNodeDumper::Visit(const concepts::Requirement *R) { + if (!R) + return; + + switch (R->getKind()) { + case concepts::Requirement::RK_Type: + JOS.attribute("kind", "TypeRequirement"); + break; + case concepts::Requirement::RK_Simple: + JOS.attribute("kind", "SimpleRequirement"); + break; + case concepts::Requirement::RK_Compound: + JOS.attribute("kind", "CompoundRequirement"); + break; + case concepts::Requirement::RK_Nested: + JOS.attribute("kind", "NestedRequirement"); + break; + } + + if (auto *ER = dyn_cast<concepts::ExprRequirement>(R)) + attributeOnlyIfTrue("noexcept", ER->hasNoexceptRequirement()); + + attributeOnlyIfTrue("isDependent", R->isDependent()); + if (!R->isDependent()) + JOS.attribute("satisfied", R->isSatisfied()); + attributeOnlyIfTrue("containsUnexpandedPack", + R->containsUnexpandedParameterPack()); +} + void JSONNodeDumper::Visit(const APValue &Value, QualType Ty) { std::string Str; llvm::raw_string_ostream OS(Str); @@ -711,9 +742,13 @@ void JSONNodeDumper::VisitMemberPointerType(const MemberPointerType *MPT) { void JSONNodeDumper::VisitNamedDecl(const NamedDecl *ND) { if (ND && ND->getDeclName()) { JOS.attribute("name", ND->getNameAsString()); - std::string MangledName = ASTNameGen.getName(ND); - if (!MangledName.empty()) - JOS.attribute("mangledName", MangledName); + // FIXME: There are likely other contexts in which it makes no sense to ask + // for a mangled name. + if (!isa<RequiresExprBodyDecl>(ND->getDeclContext())) { + std::string MangledName = ASTNameGen.getName(ND); + if (!MangledName.empty()) + JOS.attribute("mangledName", MangledName); + } } } @@ -756,6 +791,10 @@ void JSONNodeDumper::VisitUsingDecl(const UsingDecl *UD) { JOS.attribute("name", Name); } +void JSONNodeDumper::VisitUsingEnumDecl(const UsingEnumDecl *UED) { + JOS.attribute("target", createBareDeclRef(UED->getEnumDecl())); +} + void JSONNodeDumper::VisitUsingShadowDecl(const UsingShadowDecl *USD) { JOS.attribute("target", createBareDeclRef(USD->getTargetDecl())); } @@ -887,9 +926,10 @@ void JSONNodeDumper::VisitTemplateTemplateParmDecl( if (D->hasDefaultArgument()) JOS.attributeObject("defaultArg", [=] { + const auto *InheritedFrom = D->getDefaultArgStorage().getInheritedFrom(); Visit(D->getDefaultArgument().getArgument(), - D->getDefaultArgStorage().getInheritedFrom()->getSourceRange(), - D->getDefaultArgStorage().getInheritedFrom(), + InheritedFrom ? InheritedFrom->getSourceRange() : SourceLocation{}, + InheritedFrom, D->defaultArgumentWasInherited() ? "inherited from" : "previous"); }); } @@ -1163,6 +1203,12 @@ void JSONNodeDumper::VisitDeclRefExpr(const DeclRefExpr *DRE) { } } +void JSONNodeDumper::VisitSYCLUniqueStableNameExpr( + const SYCLUniqueStableNameExpr *E) { + JOS.attribute("typeSourceInfo", + createQualType(E->getTypeSourceInfo()->getType())); +} + void JSONNodeDumper::VisitPredefinedExpr(const PredefinedExpr *PE) { JOS.attribute("name", PredefinedExpr::getIdentKindName(PE->getIdentKind())); } @@ -1402,10 +1448,16 @@ void JSONNodeDumper::VisitCXXDependentScopeMemberExpr( } } +void JSONNodeDumper::VisitRequiresExpr(const RequiresExpr *RE) { + if (!RE->isValueDependent()) + JOS.attribute("satisfied", RE->isSatisfied()); +} + void JSONNodeDumper::VisitIntegerLiteral(const IntegerLiteral *IL) { - JOS.attribute("value", - IL->getValue().toString( - /*Radix=*/10, IL->getType()->isSignedIntegerType())); + llvm::SmallString<16> Buffer; + IL->getValue().toString(Buffer, + /*Radix=*/10, IL->getType()->isSignedIntegerType()); + JOS.attribute("value", Buffer); } void JSONNodeDumper::VisitCharacterLiteral(const CharacterLiteral *CL) { // FIXME: This should probably print the character literal as a string, @@ -1450,6 +1502,7 @@ void JSONNodeDumper::VisitCaseStmt(const CaseStmt *CS) { void JSONNodeDumper::VisitLabelStmt(const LabelStmt *LS) { JOS.attribute("name", LS->getName()); JOS.attribute("declId", createPointerRepresentation(LS->getDecl())); + attributeOnlyIfTrue("sideEntry", LS->isSideEntry()); } void JSONNodeDumper::VisitGotoStmt(const GotoStmt *GS) { JOS.attribute("targetLabelDeclId", |