diff options
author | Aaron Ballman <aaron@aaronballman.com> | 2019-06-21 13:22:35 +0000 |
---|---|---|
committer | Aaron Ballman <aaron@aaronballman.com> | 2019-06-21 13:22:35 +0000 |
commit | c07cfce23ad2d173620a64ad08bb974bb8c6ebff (patch) | |
tree | c46b94df208dcd41c5fea099519ede9de63925f5 /clang/lib/AST/JSONNodeDumper.cpp | |
parent | 8805829289202e282f931e1ab9af60c5fecb2712 (diff) | |
download | llvm-c07cfce23ad2d173620a64ad08bb974bb8c6ebff.zip llvm-c07cfce23ad2d173620a64ad08bb974bb8c6ebff.tar.gz llvm-c07cfce23ad2d173620a64ad08bb974bb8c6ebff.tar.bz2 |
Print information about various type nodes when dumping the AST to JSON.
llvm-svn: 364043
Diffstat (limited to 'clang/lib/AST/JSONNodeDumper.cpp')
-rw-r--r-- | clang/lib/AST/JSONNodeDumper.cpp | 119 |
1 files changed, 119 insertions, 0 deletions
diff --git a/clang/lib/AST/JSONNodeDumper.cpp b/clang/lib/AST/JSONNodeDumper.cpp index f73a37a..fd856965 100644 --- a/clang/lib/AST/JSONNodeDumper.cpp +++ b/clang/lib/AST/JSONNodeDumper.cpp @@ -492,6 +492,125 @@ void JSONNodeDumper::VisitFunctionProtoType(const FunctionProtoType *T) { VisitFunctionType(T); } +void JSONNodeDumper::VisitRValueReferenceType(const ReferenceType *RT) { + attributeOnlyIfTrue("spelledAsLValue", RT->isSpelledAsLValue()); +} + +void JSONNodeDumper::VisitArrayType(const ArrayType *AT) { + switch (AT->getSizeModifier()) { + case ArrayType::Star: + JOS.attribute("sizeModifier", "*"); + break; + case ArrayType::Static: + JOS.attribute("sizeModifier", "static"); + break; + case ArrayType::Normal: + break; + } + + std::string Str = AT->getIndexTypeQualifiers().getAsString(); + if (!Str.empty()) + JOS.attribute("indexTypeQualifiers", Str); +} + +void JSONNodeDumper::VisitConstantArrayType(const ConstantArrayType *CAT) { + // FIXME: this should use ZExt instead of SExt, but JSON doesn't allow a + // narrowing conversion to int64_t so it cannot be expressed. + JOS.attribute("size", CAT->getSize().getSExtValue()); + VisitArrayType(CAT); +} + +void JSONNodeDumper::VisitDependentSizedExtVectorType( + const DependentSizedExtVectorType *VT) { + JOS.attribute("attrLoc", createSourceLocation(VT->getAttributeLoc())); +} + +void JSONNodeDumper::VisitVectorType(const VectorType *VT) { + JOS.attribute("numElements", VT->getNumElements()); + switch (VT->getVectorKind()) { + case VectorType::GenericVector: + break; + case VectorType::AltiVecVector: + JOS.attribute("vectorKind", "altivec"); + break; + case VectorType::AltiVecPixel: + JOS.attribute("vectorKind", "altivec pixel"); + break; + case VectorType::AltiVecBool: + JOS.attribute("vectorKind", "altivec bool"); + break; + case VectorType::NeonVector: + JOS.attribute("vectorKind", "neon"); + break; + case VectorType::NeonPolyVector: + JOS.attribute("vectorKind", "neon poly"); + break; + } +} + +void JSONNodeDumper::VisitUnresolvedUsingType(const UnresolvedUsingType *UUT) { + JOS.attribute("decl", createBareDeclRef(UUT->getDecl())); +} + +void JSONNodeDumper::VisitUnaryTransformType(const UnaryTransformType *UTT) { + switch (UTT->getUTTKind()) { + case UnaryTransformType::EnumUnderlyingType: + JOS.attribute("transformKind", "underlying_type"); + break; + } +} + +void JSONNodeDumper::VisitTagType(const TagType *TT) { + JOS.attribute("decl", createBareDeclRef(TT->getDecl())); +} + +void JSONNodeDumper::VisitTemplateTypeParmType( + const TemplateTypeParmType *TTPT) { + JOS.attribute("depth", TTPT->getDepth()); + JOS.attribute("index", TTPT->getIndex()); + attributeOnlyIfTrue("isPack", TTPT->isParameterPack()); + JOS.attribute("decl", createBareDeclRef(TTPT->getDecl())); +} + +void JSONNodeDumper::VisitAutoType(const AutoType *AT) { + JOS.attribute("undeduced", !AT->isDeduced()); + switch (AT->getKeyword()) { + case AutoTypeKeyword::Auto: + JOS.attribute("typeKeyword", "auto"); + break; + case AutoTypeKeyword::DecltypeAuto: + JOS.attribute("typeKeyword", "decltype(auto)"); + break; + case AutoTypeKeyword::GNUAutoType: + JOS.attribute("typeKeyword", "__auto_type"); + break; + } +} + +void JSONNodeDumper::VisitTemplateSpecializationType( + const TemplateSpecializationType *TST) { + attributeOnlyIfTrue("isAlias", TST->isTypeAlias()); + + std::string Str; + llvm::raw_string_ostream OS(Str); + TST->getTemplateName().print(OS, PrintPolicy); + JOS.attribute("templateName", OS.str()); +} + +void JSONNodeDumper::VisitInjectedClassNameType( + const InjectedClassNameType *ICNT) { + JOS.attribute("decl", createBareDeclRef(ICNT->getDecl())); +} + +void JSONNodeDumper::VisitObjCInterfaceType(const ObjCInterfaceType *OIT) { + JOS.attribute("decl", createBareDeclRef(OIT->getDecl())); +} + +void JSONNodeDumper::VisitPackExpansionType(const PackExpansionType *PET) { + if (llvm::Optional<unsigned> N = PET->getNumExpansions()) + JOS.attribute("numExpansions", *N); +} + void JSONNodeDumper::VisitNamedDecl(const NamedDecl *ND) { if (ND && ND->getDeclName()) JOS.attribute("name", ND->getNameAsString()); |