2012-07-16 20:46:48 +08:00
|
|
|
//===- tools/clang-check/ClangCheck.cpp - Clang check tool ----------------===//
|
2012-04-04 20:07:46 +08:00
|
|
|
//
|
|
|
|
// 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-check tool that runs the
|
|
|
|
// clang::SyntaxOnlyAction over a number of translation units.
|
|
|
|
//
|
2012-07-16 20:46:48 +08:00
|
|
|
// 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.
|
|
|
|
//
|
2012-04-04 20:07:46 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "llvm/Support/CommandLine.h"
|
|
|
|
#include "clang/Frontend/FrontendActions.h"
|
2012-07-16 20:46:48 +08:00
|
|
|
#include "clang/Tooling/CommandLineClangTool.h"
|
2012-04-04 20:07:46 +08:00
|
|
|
#include "clang/Tooling/Tooling.h"
|
|
|
|
|
|
|
|
using namespace clang::tooling;
|
|
|
|
using namespace llvm;
|
|
|
|
|
2012-07-16 20:46:48 +08:00
|
|
|
static const char *MoreHelpText =
|
|
|
|
"\tFor example, to run clang-check on all files in a subtree of the\n"
|
|
|
|
"\tsource tree, use:\n"
|
2012-07-12 22:34:23 +08:00
|
|
|
"\n"
|
2012-07-16 20:46:48 +08:00
|
|
|
"\t find path/in/subtree -name '*.cpp'|xargs clang-check\n"
|
2012-07-12 22:34:23 +08:00
|
|
|
"\n"
|
2012-07-16 20:46:48 +08:00
|
|
|
"\tor using a specific build path:\n"
|
2012-07-12 22:34:23 +08:00
|
|
|
"\n"
|
2012-07-16 20:46:48 +08:00
|
|
|
"\t find path/in/subtree -name '*.cpp'|xargs clang-check -p build/path\n"
|
2012-07-12 22:34:23 +08:00
|
|
|
"\n"
|
2012-07-16 20:46:48 +08:00
|
|
|
"\tNote, that path/in/subtree and current directory should follow the\n"
|
|
|
|
"\trules described above.\n"
|
|
|
|
"\n";
|
2012-07-12 22:34:23 +08:00
|
|
|
|
2012-04-18 15:41:50 +08:00
|
|
|
int main(int argc, const char **argv) {
|
2012-07-16 20:46:48 +08:00
|
|
|
CommandLineClangTool Tool;
|
|
|
|
cl::extrahelp MoreHelp(MoreHelpText);
|
|
|
|
Tool.initialize(argc, argv);
|
2012-04-04 20:07:46 +08:00
|
|
|
return Tool.run(newFrontendActionFactory<clang::SyntaxOnlyAction>());
|
|
|
|
}
|