From 77b1ae5656cc6ca41bf02831b37fae2d9b27c2a4 Mon Sep 17 00:00:00 2001 From: Alexander Kornienko Date: Thu, 26 Jul 2012 01:44:18 +0000 Subject: [PATCH] Removed standalone clang-ast-dump tool. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160772 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/CMakeLists.txt | 4 +- test/Tooling/clang-ast-dump.cpp | 21 ---- tools/CMakeLists.txt | 1 - tools/Makefile | 2 +- tools/clang-ast-dump/CMakeLists.txt | 8 -- tools/clang-ast-dump/ClangASTDump.cpp | 141 -------------------------- tools/clang-ast-dump/Makefile | 23 ----- 7 files changed, 3 insertions(+), 197 deletions(-) delete mode 100644 test/Tooling/clang-ast-dump.cpp delete mode 100644 tools/clang-ast-dump/CMakeLists.txt delete mode 100644 tools/clang-ast-dump/ClangASTDump.cpp delete mode 100644 tools/clang-ast-dump/Makefile diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 86f0be52da..8184c3d363 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -31,7 +31,7 @@ if( NOT CLANG_BUILT_STANDALONE ) set(CLANG_TEST_DEPS clang clang-headers c-index-test diagtool arcmt-test c-arcmt-test - clang-check clang-ast-dump + clang-check llvm-dis llc opt FileCheck count not ) set(CLANG_TEST_PARAMS @@ -80,7 +80,7 @@ else() COMMENT "Running Clang regression tests" DEPENDS clang clang-headers c-index-test diagtool arcmt-test c-arcmt-test - clang-check clang-ast-dump + clang-check ) set_target_properties(check-clang PROPERTIES FOLDER "Clang tests") endif() diff --git a/test/Tooling/clang-ast-dump.cpp b/test/Tooling/clang-ast-dump.cpp deleted file mode 100644 index 3847bc6fad..0000000000 --- a/test/Tooling/clang-ast-dump.cpp +++ /dev/null @@ -1,21 +0,0 @@ -// RUN: clang-ast-dump "%s" -f test_namespace::TheClass::theMethod -- -c 2>&1 | FileCheck %s - -// FIXME: Does this run regardless of +Asserts? -// REQUIRES: asserts - -// CHECK: -// CHECK: -// CHECK: (CompoundStmt -// CHECK-NEXT: (ReturnStmt -// CHECK-NEXT: (BinaryOperator - -namespace test_namespace { - -class TheClass { -public: - int theMethod(int x) { - return x + x; - } -}; - -} diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 2e3c842263..ab4748d1b9 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -5,4 +5,3 @@ add_subdirectory(c-arcmt-test) add_subdirectory(diagtool) add_subdirectory(driver) add_subdirectory(clang-check) -add_subdirectory(clang-ast-dump) diff --git a/tools/Makefile b/tools/Makefile index 95c1e4821d..5059ade930 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -9,7 +9,7 @@ CLANG_LEVEL := .. DIRS := driver libclang c-index-test arcmt-test c-arcmt-test diagtool \ - clang-check clang-ast-dump + clang-check include $(CLANG_LEVEL)/../../Makefile.config diff --git a/tools/clang-ast-dump/CMakeLists.txt b/tools/clang-ast-dump/CMakeLists.txt deleted file mode 100644 index 7f73341010..0000000000 --- a/tools/clang-ast-dump/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -add_clang_executable(clang-ast-dump - ClangASTDump.cpp - ) - -target_link_libraries(clang-ast-dump - clangTooling - clangBasic - ) diff --git a/tools/clang-ast-dump/ClangASTDump.cpp b/tools/clang-ast-dump/ClangASTDump.cpp deleted file mode 100644 index 2b86fd6d29..0000000000 --- a/tools/clang-ast-dump/ClangASTDump.cpp +++ /dev/null @@ -1,141 +0,0 @@ -//===- tools/clang-ast-dump/ClangASTDump.cpp - Clang AST Dump tool --------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file implements a clang-ast-dump tool that dumps specified parts -// of an AST of a number of translation units. -// -// Run with '-help' for details. -// -// This tool uses the Clang Tooling infrastructure, see -// http://clang.llvm.org/docs/HowToSetupToolingForLLVM.html -// for details on setting it up with LLVM source tree. -// -//===----------------------------------------------------------------------===// - -#include "llvm/Support/CommandLine.h" -#include "clang/AST/ASTContext.h" -#include "clang/AST/ASTConsumer.h" -#include "clang/AST/RecursiveASTVisitor.h" -#include "clang/Frontend/FrontendActions.h" -#include "clang/Tooling/CommandLineClangTool.h" -#include "clang/Tooling/Tooling.h" - -using namespace clang::tooling; -using namespace llvm; - -cl::opt FilterString( - "f", - cl::desc("Filter string"), - cl::Optional); - -cl::opt ListAll( - "l", - cl::desc("List all filterable nodes"), - cl::init(false), - cl::Optional); - -static const char *MoreHelpText = - "-f can be used to dump only AST declaration nodes having\n" - "\ta certain substring in a qualified name.\n" - "\n" - "-l \tlists qualified names of all filterable declaration nodes.\n" - "\n"; - -namespace { - -using namespace clang; - -class SelectiveDumpVisitor : - public RecursiveASTVisitor { - typedef RecursiveASTVisitor base; -public: - SelectiveDumpVisitor(const std::string &FilterString, bool ListAll) - : FilterString(FilterString), ListAll(ListAll) {} - - ASTConsumer* newASTConsumer() { - return new DumpConsumer(this); - } - - bool shouldWalkTypesOfTypeLocs() const { return false; } - - void Run(TranslationUnitDecl *D) { - if (ListAll) { - llvm::outs().changeColor(llvm::raw_ostream::BLUE) << - "Listing all filterable nodes:\n"; - llvm::outs().resetColor(); - TraverseDecl(D); - return; - } - - if (FilterString.empty()) { - llvm::outs().changeColor(llvm::raw_ostream::BLUE) << - "Dumping translation unit:\n"; - llvm::outs().resetColor(); - D->dumpXML(llvm::outs()); - return; - } - - TraverseDecl(D); - } - - bool TraverseDecl(Decl *D) { - if (ListAll) { - std::string Name = getName(D); - if (!Name.empty()) - llvm::outs() << Name << "\n"; - return base::TraverseDecl(D); - } - - if (filterMatches(D)) { - llvm::outs().changeColor(llvm::raw_ostream::BLUE) << - "Dumping " << getName(D) << ":\n"; - llvm::outs().resetColor(); - D->dumpXML(llvm::outs()); - return true; - } - return base::TraverseDecl(D); - } - -private: - std::string getName(Decl *D) { - if (isa(D)) - return cast(D)->getQualifiedNameAsString(); - return ""; - } - bool filterMatches(Decl *D) { - return getName(D).find(FilterString) != std::string::npos; - } - - class DumpConsumer : public ASTConsumer { - public: - DumpConsumer(SelectiveDumpVisitor *Visitor) : Visitor(Visitor) {} - - virtual void HandleTranslationUnit(ASTContext &Context) { - Visitor->Context = &Context; - Visitor->Run(Context.getTranslationUnitDecl()); - } - - private: - SelectiveDumpVisitor *Visitor; - }; - - ASTContext *Context; - std::string FilterString; - bool ListAll; -}; - -} // namespace - -int main(int argc, const char **argv) { - CommandLineClangTool Tool; - cl::extrahelp MoreHelp(MoreHelpText); - Tool.initialize(argc, argv); - SelectiveDumpVisitor Dumper(FilterString, ListAll); - return Tool.run(newFrontendActionFactory(&Dumper)); -} diff --git a/tools/clang-ast-dump/Makefile b/tools/clang-ast-dump/Makefile deleted file mode 100644 index 74a0511a07..0000000000 --- a/tools/clang-ast-dump/Makefile +++ /dev/null @@ -1,23 +0,0 @@ -##===- tools/clang-check/Makefile --------------------------*- Makefile -*-===## -# -# The LLVM Compiler Infrastructure -# -# This file is distributed under the University of Illinois Open Source -# License. See LICENSE.TXT for details. -# -##===----------------------------------------------------------------------===## - -CLANG_LEVEL := ../.. - -TOOLNAME = clang-ast-dump -NO_INSTALL = 1 - -# No plugins, optimize startup time. -TOOL_NO_EXPORTS = 1 - -LINK_COMPONENTS := support mc -USEDLIBS = clangFrontend.a clangSerialization.a clangDriver.a \ - clangTooling.a clangParse.a clangSema.a clangAnalysis.a \ - clangEdit.a clangAST.a clangLex.a clangBasic.a - -include $(CLANG_LEVEL)/Makefile -- 2.40.0