summaryrefslogtreecommitdiffstats
path: root/clang/lib/Frontend/ASTConsumers.cpp
diff options
context:
space:
mode:
authorFangrui Song <maskray@google.com>2018-10-03 03:50:44 +0000
committerFangrui Song <maskray@google.com>2018-10-03 03:50:44 +0000
commit65ebd13f4185681b572b4ccd62d6dff33eec511c (patch)
tree4c68d50c25da8a45fb00507239cb13af54a83163 /clang/lib/Frontend/ASTConsumers.cpp
parent3d76d3605989238c839c5510b1adc6d013b3db47 (diff)
downloadbcm5719-llvm-65ebd13f4185681b572b4ccd62d6dff33eec511c.tar.gz
bcm5719-llvm-65ebd13f4185681b572b4ccd62d6dff33eec511c.zip
[Frontend] Delete -print-decl-contexts
Summary: Its job is covered by -ast-dump. The option is rarely used and lacks many AST nodes which will lead to llvm_unreachable() crash. Reviewers: rsmith, arphaman Reviewed By: rsmith Subscribers: jfb, cfe-commits Differential Revision: https://reviews.llvm.org/D52529 llvm-svn: 343660
Diffstat (limited to 'clang/lib/Frontend/ASTConsumers.cpp')
-rw-r--r--clang/lib/Frontend/ASTConsumers.cpp339
1 files changed, 0 insertions, 339 deletions
diff --git a/clang/lib/Frontend/ASTConsumers.cpp b/clang/lib/Frontend/ASTConsumers.cpp
index 6e2c87db296..28834a2de8a 100644
--- a/clang/lib/Frontend/ASTConsumers.cpp
+++ b/clang/lib/Frontend/ASTConsumers.cpp
@@ -193,342 +193,3 @@ void ASTViewer::HandleTopLevelSingleDecl(Decl *D) {
std::unique_ptr<ASTConsumer> clang::CreateASTViewer() {
return llvm::make_unique<ASTViewer>();
}
-
-//===----------------------------------------------------------------------===//
-/// DeclContextPrinter - Decl and DeclContext Visualization
-
-namespace {
-
-class DeclContextPrinter : public ASTConsumer {
- raw_ostream& Out;
-public:
- DeclContextPrinter() : Out(llvm::errs()) {}
-
- void HandleTranslationUnit(ASTContext &C) override {
- PrintDeclContext(C.getTranslationUnitDecl(), 4);
- }
-
- void PrintDeclContext(const DeclContext* DC, unsigned Indentation);
-};
-} // end anonymous namespace
-
-void DeclContextPrinter::PrintDeclContext(const DeclContext* DC,
- unsigned Indentation) {
- // Print DeclContext name.
- switch (DC->getDeclKind()) {
- case Decl::TranslationUnit:
- Out << "[translation unit] " << DC;
- break;
- case Decl::Namespace: {
- Out << "[namespace] ";
- const NamespaceDecl* ND = cast<NamespaceDecl>(DC);
- Out << *ND;
- break;
- }
- case Decl::Enum: {
- const EnumDecl* ED = cast<EnumDecl>(DC);
- if (ED->isCompleteDefinition())
- Out << "[enum] ";
- else
- Out << "<enum> ";
- Out << *ED;
- break;
- }
- case Decl::Record: {
- const RecordDecl* RD = cast<RecordDecl>(DC);
- if (RD->isCompleteDefinition())
- Out << "[struct] ";
- else
- Out << "<struct> ";
- Out << *RD;
- break;
- }
- case Decl::CXXRecord: {
- const CXXRecordDecl* RD = cast<CXXRecordDecl>(DC);
- if (RD->isCompleteDefinition())
- Out << "[class] ";
- else
- Out << "<class> ";
- Out << *RD << ' ' << DC;
- break;
- }
- case Decl::ObjCMethod:
- Out << "[objc method]";
- break;
- case Decl::ObjCInterface:
- Out << "[objc interface]";
- break;
- case Decl::ObjCCategory:
- Out << "[objc category]";
- break;
- case Decl::ObjCProtocol:
- Out << "[objc protocol]";
- break;
- case Decl::ObjCImplementation:
- Out << "[objc implementation]";
- break;
- case Decl::ObjCCategoryImpl:
- Out << "[objc categoryimpl]";
- break;
- case Decl::LinkageSpec:
- Out << "[linkage spec]";
- break;
- case Decl::Block:
- Out << "[block]";
- break;
- case Decl::Function: {
- const FunctionDecl* FD = cast<FunctionDecl>(DC);
- if (FD->doesThisDeclarationHaveABody())
- Out << "[function] ";
- else
- Out << "<function> ";
- Out << *FD;
- // Print the parameters.
- Out << "(";
- bool PrintComma = false;
- for (auto I : FD->parameters()) {
- if (PrintComma)
- Out << ", ";
- else
- PrintComma = true;
- Out << *I;
- }
- Out << ")";
- break;
- }
- case Decl::CXXMethod: {
- const CXXMethodDecl* D = cast<CXXMethodDecl>(DC);
- if (D->isOutOfLine())
- Out << "[c++ method] ";
- else if (D->isImplicit())
- Out << "(c++ method) ";
- else
- Out << "<c++ method> ";
- Out << *D;
- // Print the parameters.
- Out << "(";
- bool PrintComma = false;
- for (ParmVarDecl *Parameter : D->parameters()) {
- if (PrintComma)
- Out << ", ";
- else
- PrintComma = true;
- Out << *Parameter;
- }
- Out << ")";
-
- // Check the semantic DeclContext.
- const DeclContext* SemaDC = D->getDeclContext();
- const DeclContext* LexicalDC = D->getLexicalDeclContext();
- if (SemaDC != LexicalDC)
- Out << " [[" << SemaDC << "]]";
-
- break;
- }
- case Decl::CXXConstructor: {
- const CXXConstructorDecl* D = cast<CXXConstructorDecl>(DC);
- if (D->isOutOfLine())
- Out << "[c++ ctor] ";
- else if (D->isImplicit())
- Out << "(c++ ctor) ";
- else
- Out << "<c++ ctor> ";
- Out << *D;
- // Print the parameters.
- Out << "(";
- bool PrintComma = false;
- for (ParmVarDecl *Parameter : D->parameters()) {
- if (PrintComma)
- Out << ", ";
- else
- PrintComma = true;
- Out << *Parameter;
- }
- Out << ")";
-
- // Check the semantic DC.
- const DeclContext* SemaDC = D->getDeclContext();
- const DeclContext* LexicalDC = D->getLexicalDeclContext();
- if (SemaDC != LexicalDC)
- Out << " [[" << SemaDC << "]]";
- break;
- }
- case Decl::CXXDestructor: {
- const CXXDestructorDecl* D = cast<CXXDestructorDecl>(DC);
- if (D->isOutOfLine())
- Out << "[c++ dtor] ";
- else if (D->isImplicit())
- Out << "(c++ dtor) ";
- else
- Out << "<c++ dtor> ";
- Out << *D;
- // Check the semantic DC.
- const DeclContext* SemaDC = D->getDeclContext();
- const DeclContext* LexicalDC = D->getLexicalDeclContext();
- if (SemaDC != LexicalDC)
- Out << " [[" << SemaDC << "]]";
- break;
- }
- case Decl::CXXConversion: {
- const CXXConversionDecl* D = cast<CXXConversionDecl>(DC);
- if (D->isOutOfLine())
- Out << "[c++ conversion] ";
- else if (D->isImplicit())
- Out << "(c++ conversion) ";
- else
- Out << "<c++ conversion> ";
- Out << *D;
- // Check the semantic DC.
- const DeclContext* SemaDC = D->getDeclContext();
- const DeclContext* LexicalDC = D->getLexicalDeclContext();
- if (SemaDC != LexicalDC)
- Out << " [[" << SemaDC << "]]";
- break;
- }
-
- case Decl::ClassTemplateSpecialization: {
- const auto *CTSD = cast<ClassTemplateSpecializationDecl>(DC);
- if (CTSD->isCompleteDefinition())
- Out << "[class template specialization] ";
- else
- Out << "<class template specialization> ";
- Out << *CTSD;
- break;
- }
-
- case Decl::ClassTemplatePartialSpecialization: {
- const auto *CTPSD = cast<ClassTemplatePartialSpecializationDecl>(DC);
- if (CTPSD->isCompleteDefinition())
- Out << "[class template partial specialization] ";
- else
- Out << "<class template partial specialization> ";
- Out << *CTPSD;
- break;
- }
-
- default:
- llvm_unreachable("a decl that inherits DeclContext isn't handled");
- }
-
- Out << "\n";
-
- // Print decls in the DeclContext.
- for (auto *I : DC->decls()) {
- for (unsigned i = 0; i < Indentation; ++i)
- Out << " ";
-
- Decl::Kind DK = I->getKind();
- switch (DK) {
- case Decl::Namespace:
- case Decl::Enum:
- case Decl::Record:
- case Decl::CXXRecord:
- case Decl::ObjCMethod:
- case Decl::ObjCInterface:
- case Decl::ObjCCategory:
- case Decl::ObjCProtocol:
- case Decl::ObjCImplementation:
- case Decl::ObjCCategoryImpl:
- case Decl::LinkageSpec:
- case Decl::Block:
- case Decl::Function:
- case Decl::CXXMethod:
- case Decl::CXXConstructor:
- case Decl::CXXDestructor:
- case Decl::CXXConversion:
- case Decl::ClassTemplateSpecialization:
- case Decl::ClassTemplatePartialSpecialization: {
- DeclContext* DC = cast<DeclContext>(I);
- PrintDeclContext(DC, Indentation+2);
- break;
- }
- case Decl::IndirectField:
- Out << "<IndirectField> " << *cast<IndirectFieldDecl>(I) << '\n';
- break;
- case Decl::Label:
- Out << "<Label> " << *cast<LabelDecl>(I) << '\n';
- break;
- case Decl::Field:
- Out << "<field> " << *cast<FieldDecl>(I) << '\n';
- break;
- case Decl::Typedef:
- case Decl::TypeAlias:
- Out << "<typedef> " << *cast<TypedefNameDecl>(I) << '\n';
- break;
- case Decl::EnumConstant:
- Out << "<enum constant> " << *cast<EnumConstantDecl>(I) << '\n';
- break;
- case Decl::Var:
- Out << "<var> " << *cast<VarDecl>(I) << '\n';
- break;
- case Decl::ImplicitParam:
- Out << "<implicit parameter> " << *cast<ImplicitParamDecl>(I) << '\n';
- break;
- case Decl::ParmVar:
- Out << "<parameter> " << *cast<ParmVarDecl>(I) << '\n';
- break;
- case Decl::ObjCProperty:
- Out << "<objc property> " << *cast<ObjCPropertyDecl>(I) << '\n';
- break;
- case Decl::FunctionTemplate:
- Out << "<function template> " << *cast<FunctionTemplateDecl>(I) << '\n';
- break;
- case Decl::TypeAliasTemplate:
- Out << "<type alias template> " << *cast<TypeAliasTemplateDecl>(I)
- << '\n';
- break;
- case Decl::FileScopeAsm:
- Out << "<file-scope asm>\n";
- break;
- case Decl::UsingDirective:
- Out << "<using directive>\n";
- break;
- case Decl::NamespaceAlias:
- Out << "<namespace alias> " << *cast<NamespaceAliasDecl>(I) << '\n';
- break;
- case Decl::ClassTemplate:
- Out << "<class template> " << *cast<ClassTemplateDecl>(I) << '\n';
- break;
- case Decl::OMPThreadPrivate: {
- Out << "<omp threadprivate> " << '"' << I << "\"\n";
- break;
- }
- case Decl::Friend: {
- Out << "<friend>";
- if (const NamedDecl *ND = cast<FriendDecl>(I)->getFriendDecl())
- Out << ' ' << *ND;
- Out << "\n";
- break;
- }
- case Decl::Using:
- Out << "<using> " << *cast<UsingDecl>(I) << "\n";
- break;
- case Decl::UsingShadow:
- Out << "<using shadow> " << *cast<UsingShadowDecl>(I) << "\n";
- break;
- case Decl::UnresolvedUsingValue:
- Out << "<unresolved using value> " << *cast<UnresolvedUsingValueDecl>(I)
- << "\n";
- break;
- case Decl::Empty:
- Out << "<empty>\n";
- break;
- case Decl::AccessSpec:
- Out << "<access specifier>\n";
- break;
- case Decl::VarTemplate:
- Out << "<var template> " << *cast<VarTemplateDecl>(I) << "\n";
- break;
- case Decl::StaticAssert:
- Out << "<static assert>\n";
- break;
-
- default:
- Out << "DeclKind: " << DK << '"' << I << "\"\n";
- llvm_unreachable("decl unhandled");
- }
- }
-}
-std::unique_ptr<ASTConsumer> clang::CreateDeclContextPrinter() {
- return llvm::make_unique<DeclContextPrinter>();
-}
OpenPOWER on IntegriCloud