aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/AST/TextNodeDumper.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/AST/TextNodeDumper.cpp')
-rw-r--r--clang/lib/AST/TextNodeDumper.cpp245
1 files changed, 216 insertions, 29 deletions
diff --git a/clang/lib/AST/TextNodeDumper.cpp b/clang/lib/AST/TextNodeDumper.cpp
index a174faa6635e..e8274fcd5cfe 100644
--- a/clang/lib/AST/TextNodeDumper.cpp
+++ b/clang/lib/AST/TextNodeDumper.cpp
@@ -16,6 +16,7 @@
#include "clang/AST/DeclOpenMP.h"
#include "clang/AST/DeclTemplate.h"
#include "clang/AST/LocInfoType.h"
+#include "clang/AST/NestedNameSpecifier.h"
#include "clang/AST/Type.h"
#include "clang/Basic/Module.h"
#include "clang/Basic/SourceManager.h"
@@ -300,6 +301,17 @@ void TextNodeDumper::Visit(const Decl *D) {
}
}
+ switch (D->getFriendObjectKind()) {
+ case Decl::FOK_None:
+ break;
+ case Decl::FOK_Declared:
+ OS << " friend";
+ break;
+ case Decl::FOK_Undeclared:
+ OS << " friend_undeclared";
+ break;
+ }
+
ConstDeclVisitor<TextNodeDumper>::Visit(D);
}
@@ -360,6 +372,20 @@ void TextNodeDumper::Visit(const GenericSelectionExpr::ConstAssociation &A) {
OS << " selected";
}
+void TextNodeDumper::Visit(const ConceptReference *R) {
+ if (!R) {
+ ColorScope Color(OS, ShowColors, NullColor);
+ OS << "<<<NULL>>> ConceptReference";
+ return;
+ }
+
+ OS << "ConceptReference";
+ dumpPointer(R);
+ dumpSourceRange(R->getSourceRange());
+ OS << ' ';
+ dumpBareDeclRef(R->getNamedConcept());
+}
+
void TextNodeDumper::Visit(const concepts::Requirement *R) {
if (!R) {
ColorScope Color(OS, ShowColors, NullColor);
@@ -666,13 +692,18 @@ void TextNodeDumper::dumpBareType(QualType T, bool Desugar) {
ColorScope Color(OS, ShowColors, TypeColor);
SplitQualType T_split = T.split();
- OS << "'" << QualType::getAsString(T_split, PrintPolicy) << "'";
+ std::string T_str = QualType::getAsString(T_split, PrintPolicy);
+ OS << "'" << T_str << "'";
if (Desugar && !T.isNull()) {
- // If the type is sugared, also dump a (shallow) desugared type.
+ // If the type is sugared, also dump a (shallow) desugared type when
+ // it is visibly different.
SplitQualType D_split = T.getSplitDesugaredType();
- if (T_split != D_split)
- OS << ":'" << QualType::getAsString(D_split, PrintPolicy) << "'";
+ if (T_split != D_split) {
+ std::string D_str = QualType::getAsString(D_split, PrintPolicy);
+ if (T_str != D_str)
+ OS << ":'" << QualType::getAsString(D_split, PrintPolicy) << "'";
+ }
}
}
@@ -734,6 +765,66 @@ void TextNodeDumper::dumpCleanupObject(
llvm_unreachable("unexpected cleanup type");
}
+void clang::TextNodeDumper::dumpTemplateSpecializationKind(
+ TemplateSpecializationKind TSK) {
+ switch (TSK) {
+ case TSK_Undeclared:
+ break;
+ case TSK_ImplicitInstantiation:
+ OS << " implicit_instantiation";
+ break;
+ case TSK_ExplicitSpecialization:
+ OS << " explicit_specialization";
+ break;
+ case TSK_ExplicitInstantiationDeclaration:
+ OS << " explicit_instantiation_declaration";
+ break;
+ case TSK_ExplicitInstantiationDefinition:
+ OS << " explicit_instantiation_definition";
+ break;
+ }
+}
+
+void clang::TextNodeDumper::dumpNestedNameSpecifier(const NestedNameSpecifier *NNS) {
+ if (!NNS)
+ return;
+
+ AddChild([=] {
+ OS << "NestedNameSpecifier";
+
+ switch (NNS->getKind()) {
+ case NestedNameSpecifier::Identifier:
+ OS << " Identifier";
+ OS << " '" << NNS->getAsIdentifier()->getName() << "'";
+ break;
+ case NestedNameSpecifier::Namespace:
+ OS << " "; // "Namespace" is printed as the decl kind.
+ dumpBareDeclRef(NNS->getAsNamespace());
+ break;
+ case NestedNameSpecifier::NamespaceAlias:
+ OS << " "; // "NamespaceAlias" is printed as the decl kind.
+ dumpBareDeclRef(NNS->getAsNamespaceAlias());
+ break;
+ case NestedNameSpecifier::TypeSpec:
+ OS << " TypeSpec";
+ dumpType(QualType(NNS->getAsType(), 0));
+ break;
+ case NestedNameSpecifier::TypeSpecWithTemplate:
+ OS << " TypeSpecWithTemplate";
+ dumpType(QualType(NNS->getAsType(), 0));
+ break;
+ case NestedNameSpecifier::Global:
+ OS << " Global";
+ break;
+ case NestedNameSpecifier::Super:
+ OS << " Super";
+ break;
+ }
+
+ dumpNestedNameSpecifier(NNS->getPrefix());
+ });
+}
+
void TextNodeDumper::dumpDeclRef(const Decl *D, StringRef Label) {
if (!D)
return;
@@ -771,19 +862,19 @@ void TextNodeDumper::visitInlineCommandComment(
const comments::InlineCommandComment *C, const comments::FullComment *) {
OS << " Name=\"" << getCommandName(C->getCommandID()) << "\"";
switch (C->getRenderKind()) {
- case comments::InlineCommandComment::RenderNormal:
+ case comments::InlineCommandRenderKind::Normal:
OS << " RenderNormal";
break;
- case comments::InlineCommandComment::RenderBold:
+ case comments::InlineCommandRenderKind::Bold:
OS << " RenderBold";
break;
- case comments::InlineCommandComment::RenderMonospaced:
+ case comments::InlineCommandRenderKind::Monospaced:
OS << " RenderMonospaced";
break;
- case comments::InlineCommandComment::RenderEmphasized:
+ case comments::InlineCommandRenderKind::Emphasized:
OS << " RenderEmphasized";
break;
- case comments::InlineCommandComment::RenderAnchor:
+ case comments::InlineCommandRenderKind::Anchor:
OS << " RenderAnchor";
break;
}
@@ -995,6 +1086,14 @@ void TextNodeDumper::VisitCaseStmt(const CaseStmt *Node) {
OS << " gnu_range";
}
+void clang::TextNodeDumper::VisitReturnStmt(const ReturnStmt *Node) {
+ if (const VarDecl *Cand = Node->getNRVOCandidate()) {
+ OS << " nrvo_candidate(";
+ dumpBareDeclRef(Cand);
+ OS << ")";
+ }
+}
+
void TextNodeDumper::VisitConstantExpr(const ConstantExpr *Node) {
if (Node->hasAPValueResult())
AddChild("value",
@@ -1037,6 +1136,7 @@ void TextNodeDumper::VisitImplicitCastExpr(const ImplicitCastExpr *Node) {
void TextNodeDumper::VisitDeclRefExpr(const DeclRefExpr *Node) {
OS << " ";
dumpBareDeclRef(Node->getDecl());
+ dumpNestedNameSpecifier(Node->getQualifier());
if (Node->getDecl() != Node->getFoundDecl()) {
OS << " (";
dumpBareDeclRef(Node->getFoundDecl());
@@ -1048,10 +1148,18 @@ void TextNodeDumper::VisitDeclRefExpr(const DeclRefExpr *Node) {
case NOUR_Constant: OS << " non_odr_use_constant"; break;
case NOUR_Discarded: OS << " non_odr_use_discarded"; break;
}
+ if (Node->refersToEnclosingVariableOrCapture())
+ OS << " refers_to_enclosing_variable_or_capture";
if (Node->isImmediateEscalating())
OS << " immediate-escalating";
}
+void clang::TextNodeDumper::VisitDependentScopeDeclRefExpr(
+ const DependentScopeDeclRefExpr *Node) {
+
+ dumpNestedNameSpecifier(Node->getQualifier());
+}
+
void TextNodeDumper::VisitUnresolvedLookupExpr(
const UnresolvedLookupExpr *Node) {
OS << " (";
@@ -1146,6 +1254,7 @@ void TextNodeDumper::VisitUnaryExprOrTypeTraitExpr(
void TextNodeDumper::VisitMemberExpr(const MemberExpr *Node) {
OS << " " << (Node->isArrow() ? "->" : ".") << *Node->getMemberDecl();
dumpPointer(Node->getMemberDecl());
+ dumpNestedNameSpecifier(Node->getQualifier());
switch (Node->isNonOdrUse()) {
case NOUR_None: break;
case NOUR_Unevaluated: OS << " non_odr_use_unevaluated"; break;
@@ -1440,12 +1549,12 @@ void TextNodeDumper::VisitRValueReferenceType(const ReferenceType *T) {
void TextNodeDumper::VisitArrayType(const ArrayType *T) {
switch (T->getSizeModifier()) {
- case ArrayType::Normal:
+ case ArraySizeModifier::Normal:
break;
- case ArrayType::Static:
+ case ArraySizeModifier::Static:
OS << " static";
break;
- case ArrayType::Star:
+ case ArraySizeModifier::Star:
OS << " *";
break;
}
@@ -1478,30 +1587,30 @@ void TextNodeDumper::VisitDependentSizedExtVectorType(
void TextNodeDumper::VisitVectorType(const VectorType *T) {
switch (T->getVectorKind()) {
- case VectorType::GenericVector:
+ case VectorKind::Generic:
break;
- case VectorType::AltiVecVector:
+ case VectorKind::AltiVecVector:
OS << " altivec";
break;
- case VectorType::AltiVecPixel:
+ case VectorKind::AltiVecPixel:
OS << " altivec pixel";
break;
- case VectorType::AltiVecBool:
+ case VectorKind::AltiVecBool:
OS << " altivec bool";
break;
- case VectorType::NeonVector:
+ case VectorKind::Neon:
OS << " neon";
break;
- case VectorType::NeonPolyVector:
+ case VectorKind::NeonPoly:
OS << " neon poly";
break;
- case VectorType::SveFixedLengthDataVector:
+ case VectorKind::SveFixedLengthData:
OS << " fixed-length sve data vector";
break;
- case VectorType::SveFixedLengthPredicateVector:
+ case VectorKind::SveFixedLengthPredicate:
OS << " fixed-length sve predicate vector";
break;
- case VectorType::RVVFixedLengthDataVector:
+ case VectorKind::RVVFixedLengthData:
OS << " fixed-length rvv data vector";
break;
}
@@ -1541,7 +1650,64 @@ void TextNodeDumper::VisitFunctionProtoType(const FunctionProtoType *T) {
OS << " &&";
break;
}
- // FIXME: Exception specification.
+
+ switch (EPI.ExceptionSpec.Type) {
+ case EST_None:
+ break;
+ case EST_DynamicNone:
+ OS << " exceptionspec_dynamic_none";
+ break;
+ case EST_Dynamic:
+ OS << " exceptionspec_dynamic";
+ break;
+ case EST_MSAny:
+ OS << " exceptionspec_ms_any";
+ break;
+ case EST_NoThrow:
+ OS << " exceptionspec_nothrow";
+ break;
+ case EST_BasicNoexcept:
+ OS << " exceptionspec_basic_noexcept";
+ break;
+ case EST_DependentNoexcept:
+ OS << " exceptionspec_dependent_noexcept";
+ break;
+ case EST_NoexceptFalse:
+ OS << " exceptionspec_noexcept_false";
+ break;
+ case EST_NoexceptTrue:
+ OS << " exceptionspec_noexcept_true";
+ break;
+ case EST_Unevaluated:
+ OS << " exceptionspec_unevaluated";
+ break;
+ case EST_Uninstantiated:
+ OS << " exceptionspec_uninstantiated";
+ break;
+ case EST_Unparsed:
+ OS << " exceptionspec_unparsed";
+ break;
+ }
+ if (!EPI.ExceptionSpec.Exceptions.empty()) {
+ AddChild([=] {
+ OS << "Exceptions:";
+ for (unsigned I = 0, N = EPI.ExceptionSpec.Exceptions.size(); I != N;
+ ++I) {
+ if (I)
+ OS << ",";
+ dumpType(EPI.ExceptionSpec.Exceptions[I]);
+ }
+ });
+ }
+ if (EPI.ExceptionSpec.NoexceptExpr) {
+ AddChild([=] {
+ OS << "NoexceptExpr: ";
+ Visit(EPI.ExceptionSpec.NoexceptExpr);
+ });
+ }
+ dumpDeclRef(EPI.ExceptionSpec.SourceDecl, "ExceptionSourceDecl");
+ dumpDeclRef(EPI.ExceptionSpec.SourceTemplate, "ExceptionSourceTemplate");
+
// FIXME: Consumed parameters.
VisitFunctionType(T);
}
@@ -1687,6 +1853,7 @@ void TextNodeDumper::VisitIndirectFieldDecl(const IndirectFieldDecl *D) {
void TextNodeDumper::VisitFunctionDecl(const FunctionDecl *D) {
dumpName(D);
dumpType(D->getType());
+ dumpTemplateSpecializationKind(D->getTemplateSpecializationKind());
StorageClass SC = D->getStorageClass();
if (SC != SC_None)
@@ -1739,8 +1906,7 @@ void TextNodeDumper::VisitFunctionDecl(const FunctionDecl *D) {
auto Overrides = MD->overridden_methods();
OS << "Overrides: [ ";
dumpOverride(*Overrides.begin());
- for (const auto *Override :
- llvm::make_range(Overrides.begin() + 1, Overrides.end())) {
+ for (const auto *Override : llvm::drop_begin(Overrides)) {
OS << ", ";
dumpOverride(Override);
}
@@ -1758,6 +1924,11 @@ void TextNodeDumper::VisitFunctionDecl(const FunctionDecl *D) {
// ParmVarDecls yet.
if (!D->param_empty() && !D->param_begin())
OS << " <<<NULL params x " << D->getNumParams() << ">>>";
+
+ if (const auto *Instance = D->getInstantiatedFromMemberFunction()) {
+ OS << " instantiated_from";
+ dumpPointer(Instance);
+ }
}
void TextNodeDumper::VisitLifetimeExtendedTemporaryDecl(
@@ -1781,8 +1952,14 @@ void TextNodeDumper::VisitFieldDecl(const FieldDecl *D) {
}
void TextNodeDumper::VisitVarDecl(const VarDecl *D) {
+ dumpNestedNameSpecifier(D->getQualifier());
dumpName(D);
+ if (const auto *P = dyn_cast<ParmVarDecl>(D);
+ P && P->isExplicitObjectParameter())
+ OS << " this";
+
dumpType(D->getType());
+ dumpTemplateSpecializationKind(D->getTemplateSpecializationKind());
StorageClass SC = D->getStorageClass();
if (SC != SC_None)
OS << ' ' << VarDecl::getStorageClassSpecifierString(SC);
@@ -1901,13 +2078,13 @@ void TextNodeDumper::VisitOMPDeclareReductionDecl(
OS << " initializer";
dumpPointer(Initializer);
switch (D->getInitializerKind()) {
- case OMPDeclareReductionDecl::DirectInit:
+ case OMPDeclareReductionInitKind::Direct:
OS << " omp_priv = ";
break;
- case OMPDeclareReductionDecl::CopyInit:
+ case OMPDeclareReductionInitKind::Copy:
OS << " omp_priv ()";
break;
- case OMPDeclareReductionDecl::CallInit:
+ case OMPDeclareReductionInitKind::Call:
break;
}
}
@@ -1971,6 +2148,15 @@ void TextNodeDumper::VisitTypeAliasTemplateDecl(
void TextNodeDumper::VisitCXXRecordDecl(const CXXRecordDecl *D) {
VisitRecordDecl(D);
+ if (const auto *Instance = D->getInstantiatedFromMemberClass()) {
+ OS << " instantiated_from";
+ dumpPointer(Instance);
+ }
+ if (const auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(D))
+ dumpTemplateSpecializationKind(CTSD->getSpecializationKind());
+
+ dumpNestedNameSpecifier(D->getQualifier());
+
if (!D->isCompleteDefinition())
return;
@@ -2170,6 +2356,7 @@ void TextNodeDumper::VisitUsingDecl(const UsingDecl *D) {
if (D->getQualifier())
D->getQualifier()->print(OS, D->getASTContext().getPrintingPolicy());
OS << D->getDeclName();
+ dumpNestedNameSpecifier(D->getQualifier());
}
void TextNodeDumper::VisitUsingEnumDecl(const UsingEnumDecl *D) {
@@ -2226,10 +2413,10 @@ void TextNodeDumper::VisitConstructorUsingShadowDecl(
void TextNodeDumper::VisitLinkageSpecDecl(const LinkageSpecDecl *D) {
switch (D->getLanguage()) {
- case LinkageSpecDecl::lang_c:
+ case LinkageSpecLanguageIDs::C:
OS << " C";
break;
- case LinkageSpecDecl::lang_cxx:
+ case LinkageSpecLanguageIDs::CXX:
OS << " C++";
break;
}