Changeset View
Changeset View
Standalone View
Standalone View
clang/lib/AST/TextNodeDumper.cpp
Show All 11 Lines | |||||
#include "clang/AST/TextNodeDumper.h" | #include "clang/AST/TextNodeDumper.h" | ||||
#include "clang/AST/APValue.h" | #include "clang/AST/APValue.h" | ||||
#include "clang/AST/DeclFriend.h" | #include "clang/AST/DeclFriend.h" | ||||
#include "clang/AST/DeclOpenMP.h" | #include "clang/AST/DeclOpenMP.h" | ||||
#include "clang/AST/DeclTemplate.h" | #include "clang/AST/DeclTemplate.h" | ||||
#include "clang/AST/LocInfoType.h" | #include "clang/AST/LocInfoType.h" | ||||
#include "clang/AST/Type.h" | #include "clang/AST/Type.h" | ||||
#include "clang/AST/TypeLocVisitor.h" | |||||
#include "clang/Basic/Module.h" | #include "clang/Basic/Module.h" | ||||
#include "clang/Basic/SourceManager.h" | #include "clang/Basic/SourceManager.h" | ||||
#include "clang/Basic/Specifiers.h" | #include "clang/Basic/Specifiers.h" | ||||
#include "clang/Basic/TypeTraits.h" | #include "clang/Basic/TypeTraits.h" | ||||
#include "llvm/ADT/StringExtras.h" | #include "llvm/ADT/StringExtras.h" | ||||
#include <algorithm> | #include <algorithm> | ||||
#include <utility> | #include <utility> | ||||
▲ Show 20 Lines • Show All 206 Lines • ▼ Show 20 Lines | |||||
void TextNodeDumper::Visit(QualType T) { | void TextNodeDumper::Visit(QualType T) { | ||||
OS << "QualType"; | OS << "QualType"; | ||||
dumpPointer(T.getAsOpaquePtr()); | dumpPointer(T.getAsOpaquePtr()); | ||||
OS << " "; | OS << " "; | ||||
dumpBareType(T, false); | dumpBareType(T, false); | ||||
OS << " " << T.split().Quals.getAsString(); | OS << " " << T.split().Quals.getAsString(); | ||||
} | } | ||||
void TextNodeDumper::Visit(TypeLoc TL) { | |||||
{ | |||||
ColorScope Color(OS, ShowColors, TypeColor); | |||||
OS << TL.getTypeLocClassName() << "TypeLoc"; | |||||
} | |||||
dumpSourceRange(TL.getSourceRange()); | |||||
OS << " "; | |||||
dumpBareType(TL.getType(), false); | |||||
TypeLocVisitor<TextNodeDumper>::Visit(TL); | |||||
} | |||||
void TextNodeDumper::Visit(const Decl *D) { | void TextNodeDumper::Visit(const Decl *D) { | ||||
if (!D) { | if (!D) { | ||||
ColorScope Color(OS, ShowColors, NullColor); | ColorScope Color(OS, ShowColors, NullColor); | ||||
OS << "<<<NULL>>>"; | OS << "<<<NULL>>>"; | ||||
return; | return; | ||||
} | } | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 1,367 Lines • ▼ Show 20 Lines | void TextNodeDumper::VisitObjCInterfaceType(const ObjCInterfaceType *T) { | ||||
dumpDeclRef(T->getDecl()); | dumpDeclRef(T->getDecl()); | ||||
} | } | ||||
void TextNodeDumper::VisitPackExpansionType(const PackExpansionType *T) { | void TextNodeDumper::VisitPackExpansionType(const PackExpansionType *T) { | ||||
if (auto N = T->getNumExpansions()) | if (auto N = T->getNumExpansions()) | ||||
OS << " expansions " << *N; | OS << " expansions " << *N; | ||||
} | } | ||||
void TextNodeDumper::VisitQualifiedTypeLoc(QualifiedTypeLoc TL) { | |||||
OS << " " << TL.getType().split().Quals.getAsString(); | |||||
} | |||||
void TextNodeDumper::VisitRValueReferenceTypeLoc(ReferenceTypeLoc TL) { | |||||
VisitReferenceType(cast<ReferenceType>(TL.getType().getTypePtr())); | |||||
aaron.ballman: These uses of `dyn_cast` can all be switched to `cast` instead because we already know the type… | |||||
} | |||||
void TextNodeDumper::VisitArrayTypeLoc(ArrayTypeLoc TL) { | |||||
if (Context) | |||||
VisitArrayType(Context->getAsArrayType(TL.getType())); | |||||
} | |||||
void TextNodeDumper::VisitConstantArrayTypeLoc(ConstantArrayTypeLoc TL) { | |||||
if (Context) | |||||
This one is actually not quite right. You need to go through the ASTContext to get to an array type. This should use ASTContext::getAsConstantArrayType() instead. aaron.ballman: This one is actually not quite right. You need to go through the `ASTContext` to get to an… | |||||
VisitConstantArrayType(Context->getAsConstantArrayType(TL.getType())); | |||||
} | |||||
void TextNodeDumper::VisitVariableArrayTypeLoc(VariableArrayTypeLoc TL) { | |||||
if (Context) | |||||
Similarly, ASTContext::getAsVariableArrayType() aaron.ballman: Similarly, `ASTContext::getAsVariableArrayType()` | |||||
VisitVariableArrayType(Context->getAsVariableArrayType(TL.getType())); | |||||
} | |||||
void TextNodeDumper::VisitDependentSizedArrayTypeLoc( | |||||
DependentSizedArrayTypeLoc TL) { | |||||
if (Context) | |||||
ASTContext::getAsDependentSizedArrayType() aaron.ballman: `ASTContext::getAsDependentSizedArrayType()` | |||||
VisitDependentSizedArrayType( | |||||
Context->getAsDependentSizedArrayType(TL.getType())); | |||||
} | |||||
void TextNodeDumper::VisitDependentSizedExtVectorTypeLoc( | |||||
DependentSizedExtVectorTypeLoc TL) { | |||||
VisitDependentSizedExtVectorType( | |||||
cast<DependentSizedExtVectorType>(TL.getType().getTypePtr())); | |||||
} | |||||
void TextNodeDumper::VisitVectorTypeLoc(VectorTypeLoc TL) { | |||||
VisitVectorType(cast<VectorType>(TL.getType().getTypePtr())); | |||||
} | |||||
void TextNodeDumper::VisitFunctionTypeLoc(FunctionTypeLoc TL) { | |||||
VisitFunctionType(cast<FunctionType>(TL.getType().getTypePtr())); | |||||
} | |||||
void TextNodeDumper::VisitFunctionProtoTypeLoc(FunctionProtoTypeLoc TL) { | |||||
VisitFunctionProtoType(cast<FunctionProtoType>(TL.getType().getTypePtr())); | |||||
} | |||||
void TextNodeDumper::VisitUnresolvedUsingTypeLoc(UnresolvedUsingTypeLoc TL) { | |||||
VisitUnresolvedUsingType( | |||||
cast<UnresolvedUsingType>(TL.getType().getTypePtr())); | |||||
} | |||||
void TextNodeDumper::VisitUsingTypeLoc(UsingTypeLoc TL) { | |||||
VisitUsingType(cast<UsingType>(TL.getType().getTypePtr())); | |||||
} | |||||
void TextNodeDumper::VisitTypedefTypeLoc(TypedefTypeLoc TL) { | |||||
VisitTypedefType(cast<TypedefType>(TL.getType().getTypePtr())); | |||||
} | |||||
void TextNodeDumper::VisitUnaryTransformTypeLoc(UnaryTransformTypeLoc TL) { | |||||
VisitUnaryTransformType(cast<UnaryTransformType>(TL.getType().getTypePtr())); | |||||
} | |||||
void TextNodeDumper::VisitTagTypeLoc(TagTypeLoc TL) { | |||||
VisitTagType(cast<TagType>(TL.getType().getTypePtr())); | |||||
} | |||||
void TextNodeDumper::VisitTemplateTypeParmTypeLoc(TemplateTypeParmTypeLoc TL) { | |||||
VisitTemplateTypeParmType( | |||||
cast<TemplateTypeParmType>(TL.getType().getTypePtr())); | |||||
} | |||||
void TextNodeDumper::VisitSubstTemplateTypeParmTypeLoc( | |||||
SubstTemplateTypeParmTypeLoc TL) { | |||||
VisitSubstTemplateTypeParmType( | |||||
cast<SubstTemplateTypeParmType>(TL.getType().getTypePtr())); | |||||
} | |||||
void TextNodeDumper::VisitAutoTypeLoc(AutoTypeLoc TL) { | |||||
VisitAutoType(cast<AutoType>(TL.getType().getTypePtr())); | |||||
} | |||||
void TextNodeDumper::VisitDeducedTemplateSpecializationTypeLoc( | |||||
DeducedTemplateSpecializationTypeLoc TL) { | |||||
VisitDeducedTemplateSpecializationType( | |||||
cast<DeducedTemplateSpecializationType>(TL.getType().getTypePtr())); | |||||
} | |||||
void TextNodeDumper::VisitTemplateSpecializationTypeLoc( | |||||
TemplateSpecializationTypeLoc TL) { | |||||
VisitTemplateSpecializationType( | |||||
cast<TemplateSpecializationType>(TL.getType().getTypePtr())); | |||||
} | |||||
void TextNodeDumper::VisitInjectedClassNameTypeLoc( | |||||
InjectedClassNameTypeLoc TL) { | |||||
VisitInjectedClassNameType( | |||||
cast<InjectedClassNameType>(TL.getType().getTypePtr())); | |||||
} | |||||
void TextNodeDumper::VisitObjCInterfaceTypeLoc(ObjCInterfaceTypeLoc TL) { | |||||
VisitObjCInterfaceType(cast<ObjCInterfaceType>(TL.getType().getTypePtr())); | |||||
} | |||||
void TextNodeDumper::VisitPackExpansionTypeLoc(PackExpansionTypeLoc TL) { | |||||
VisitPackExpansionType(cast<PackExpansionType>(TL.getType().getTypePtr())); | |||||
} | |||||
void TextNodeDumper::VisitLabelDecl(const LabelDecl *D) { dumpName(D); } | void TextNodeDumper::VisitLabelDecl(const LabelDecl *D) { dumpName(D); } | ||||
void TextNodeDumper::VisitTypedefDecl(const TypedefDecl *D) { | void TextNodeDumper::VisitTypedefDecl(const TypedefDecl *D) { | ||||
dumpName(D); | dumpName(D); | ||||
dumpType(D->getUnderlyingType()); | dumpType(D->getUnderlyingType()); | ||||
if (D->isModulePrivate()) | if (D->isModulePrivate()) | ||||
OS << " __module_private__"; | OS << " __module_private__"; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 770 Lines • Show Last 20 Lines |
These uses of dyn_cast can all be switched to cast instead because we already know the type we're going to find.