aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/AST/JSONNodeDumper.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard@metafoo.co.uk>2021-06-30 14:05:34 -0700
committerRichard Smith <richard@metafoo.co.uk>2021-06-30 14:27:19 -0700
commitef227b32b63c53ca81ebd410c7fbd5af8fc22ec5 (patch)
tree21ccf7e8def97a1b01b7f5a2cd00f6c0f29d64bc /clang/lib/AST/JSONNodeDumper.cpp
parentd86b0073cf283849ef9beaa94efe13fef1a0a615 (diff)
downloadllvm-ef227b32b63c53ca81ebd410c7fbd5af8fc22ec5.zip
llvm-ef227b32b63c53ca81ebd410c7fbd5af8fc22ec5.tar.gz
llvm-ef227b32b63c53ca81ebd410c7fbd5af8fc22ec5.tar.bz2
Add dumping support for RequiresExpr.
In passing, fix an ast-print bug that inserted a spurious extra `;` after a concept definition.
Diffstat (limited to 'clang/lib/AST/JSONNodeDumper.cpp')
-rw-r--r--clang/lib/AST/JSONNodeDumper.cpp44
1 files changed, 41 insertions, 3 deletions
diff --git a/clang/lib/AST/JSONNodeDumper.cpp b/clang/lib/AST/JSONNodeDumper.cpp
index e3b1209..f09f9d3 100644
--- a/clang/lib/AST/JSONNodeDumper.cpp
+++ b/clang/lib/AST/JSONNodeDumper.cpp
@@ -185,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);
@@ -713,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);
+ }
}
}
@@ -1415,6 +1448,11 @@ void JSONNodeDumper::VisitCXXDependentScopeMemberExpr(
}
}
+void JSONNodeDumper::VisitRequiresExpr(const RequiresExpr *RE) {
+ if (!RE->isValueDependent())
+ JOS.attribute("satisfied", RE->isSatisfied());
+}
+
void JSONNodeDumper::VisitIntegerLiteral(const IntegerLiteral *IL) {
llvm::SmallString<16> Buffer;
IL->getValue().toString(Buffer,