Removed standalone clang-ast-dump tool.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160772 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Alexander Kornienko 2012-07-26 01:44:18 +00:00
Родитель 9dc5167e40
Коммит 77b1ae5656
7 изменённых файлов: 3 добавлений и 197 удалений

Просмотреть файл

@ -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()

Просмотреть файл

@ -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: <CXXMethod ptr="0x{{[0-9a-f]+}}" name="theMethod" prototype="true">
// CHECK: <ParmVar ptr="0x{{[0-9a-f]+}}" name="x" initstyle="c">
// CHECK: (CompoundStmt
// CHECK-NEXT: (ReturnStmt
// CHECK-NEXT: (BinaryOperator
namespace test_namespace {
class TheClass {
public:
int theMethod(int x) {
return x + x;
}
};
}

Просмотреть файл

@ -5,4 +5,3 @@ add_subdirectory(c-arcmt-test)
add_subdirectory(diagtool)
add_subdirectory(driver)
add_subdirectory(clang-check)
add_subdirectory(clang-ast-dump)

Просмотреть файл

@ -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

Просмотреть файл

@ -1,8 +0,0 @@
add_clang_executable(clang-ast-dump
ClangASTDump.cpp
)
target_link_libraries(clang-ast-dump
clangTooling
clangBasic
)

Просмотреть файл

@ -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<std::string> FilterString(
"f",
cl::desc("Filter string"),
cl::Optional);
cl::opt<bool> ListAll(
"l",
cl::desc("List all filterable nodes"),
cl::init(false),
cl::Optional);
static const char *MoreHelpText =
"-f <filter-string> 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<SelectiveDumpVisitor> {
typedef RecursiveASTVisitor<SelectiveDumpVisitor> 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<NamedDecl>(D))
return cast<NamedDecl>(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));
}

Просмотреть файл

@ -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