Index: cfe/trunk/include/clang/Driver/CC1Options.td =================================================================== --- cfe/trunk/include/clang/Driver/CC1Options.td +++ cfe/trunk/include/clang/Driver/CC1Options.td @@ -540,8 +540,6 @@ HelpText<"Build ASTs and then debug dump their name lookup tables">; def ast_view : Flag<["-"], "ast-view">, HelpText<"Build ASTs and view them with GraphViz">; -def print_decl_contexts : Flag<["-"], "print-decl-contexts">, - HelpText<"Print DeclContexts and their Decls">; def emit_module : Flag<["-"], "emit-module">, HelpText<"Generate pre-compiled module file from a module map">; def emit_module_interface : Flag<["-"], "emit-module-interface">, Index: cfe/trunk/include/clang/Frontend/ASTConsumers.h =================================================================== --- cfe/trunk/include/clang/Frontend/ASTConsumers.h +++ cfe/trunk/include/clang/Frontend/ASTConsumers.h @@ -50,10 +50,6 @@ // function declarations to stderr. std::unique_ptr CreateASTViewer(); -// DeclContext printer: prints out the DeclContext tree in human-readable form -// to stderr; this is intended for debugging. -std::unique_ptr CreateDeclContextPrinter(); - } // end clang namespace #endif Index: cfe/trunk/include/clang/Frontend/FrontendOptions.h =================================================================== --- cfe/trunk/include/clang/Frontend/FrontendOptions.h +++ cfe/trunk/include/clang/Frontend/FrontendOptions.h @@ -106,9 +106,6 @@ /// Run a plugin action, \see ActionName. PluginAction, - /// Print DeclContext and their Decls. - PrintDeclContext, - /// Print the "preamble" of the input file PrintPreamble, Index: cfe/trunk/lib/Frontend/ASTConsumers.cpp =================================================================== --- cfe/trunk/lib/Frontend/ASTConsumers.cpp +++ cfe/trunk/lib/Frontend/ASTConsumers.cpp @@ -193,342 +193,3 @@ std::unique_ptr clang::CreateASTViewer() { return llvm::make_unique(); } - -//===----------------------------------------------------------------------===// -/// 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(DC); - Out << *ND; - break; - } - case Decl::Enum: { - const EnumDecl* ED = cast(DC); - if (ED->isCompleteDefinition()) - Out << "[enum] "; - else - Out << " "; - Out << *ED; - break; - } - case Decl::Record: { - const RecordDecl* RD = cast(DC); - if (RD->isCompleteDefinition()) - Out << "[struct] "; - else - Out << " "; - Out << *RD; - break; - } - case Decl::CXXRecord: { - const CXXRecordDecl* RD = cast(DC); - if (RD->isCompleteDefinition()) - Out << "[class] "; - else - Out << " "; - 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(DC); - if (FD->doesThisDeclarationHaveABody()) - Out << "[function] "; - else - Out << " "; - 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(DC); - if (D->isOutOfLine()) - Out << "[c++ method] "; - else if (D->isImplicit()) - Out << "(c++ method) "; - else - Out << " "; - 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(DC); - if (D->isOutOfLine()) - Out << "[c++ ctor] "; - else if (D->isImplicit()) - Out << "(c++ ctor) "; - else - Out << " "; - 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(DC); - if (D->isOutOfLine()) - Out << "[c++ dtor] "; - else if (D->isImplicit()) - Out << "(c++ dtor) "; - else - Out << " "; - 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(DC); - if (D->isOutOfLine()) - Out << "[c++ conversion] "; - else if (D->isImplicit()) - Out << "(c++ conversion) "; - else - Out << " "; - 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(DC); - if (CTSD->isCompleteDefinition()) - Out << "[class template specialization] "; - else - Out << " "; - Out << *CTSD; - break; - } - - case Decl::ClassTemplatePartialSpecialization: { - const auto *CTPSD = cast(DC); - if (CTPSD->isCompleteDefinition()) - Out << "[class template partial specialization] "; - else - Out << " "; - 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(I); - PrintDeclContext(DC, Indentation+2); - break; - } - case Decl::IndirectField: - Out << " " << *cast(I) << '\n'; - break; - case Decl::Label: - Out << "