forked from OSchip/llvm-project
Allow specifying file names and extra arguments when running clang-tidy unit tests.
Will become useful soon. llvm-svn: 215438
This commit is contained in:
parent
39c70bbf56
commit
6318f7614f
|
@ -41,22 +41,26 @@ private:
|
|||
|
||||
template <typename T>
|
||||
std::string runCheckOnCode(StringRef Code,
|
||||
std::vector<ClangTidyError> *Errors = nullptr) {
|
||||
std::vector<ClangTidyError> *Errors = nullptr,
|
||||
const Twine &Filename = "input.cc",
|
||||
ArrayRef<std::string> ExtraArgs = None) {
|
||||
T Check;
|
||||
ClangTidyContext Context(
|
||||
new DefaultOptionsProvider(ClangTidyGlobalOptions(), ClangTidyOptions()));
|
||||
ClangTidyDiagnosticConsumer DiagConsumer(Context);
|
||||
Check.setContext(&Context);
|
||||
std::vector<std::string> ArgCXX11(1, "-std=c++11");
|
||||
ArgCXX11.insert(ArgCXX11.end(), ExtraArgs.begin(), ExtraArgs.end());
|
||||
|
||||
if (!tooling::runToolOnCodeWithArgs(new TestPPAction(Check, &Context), Code,
|
||||
ArgCXX11))
|
||||
ArgCXX11, Filename))
|
||||
return "";
|
||||
ast_matchers::MatchFinder Finder;
|
||||
Check.registerMatchers(&Finder);
|
||||
std::unique_ptr<tooling::FrontendActionFactory> Factory(
|
||||
tooling::newFrontendActionFactory(&Finder));
|
||||
if (!tooling::runToolOnCodeWithArgs(Factory->create(), Code, ArgCXX11))
|
||||
if (!tooling::runToolOnCodeWithArgs(Factory->create(), Code, ArgCXX11,
|
||||
Filename))
|
||||
return "";
|
||||
DiagConsumer.finish();
|
||||
tooling::Replacements Fixes;
|
||||
|
|
Loading…
Reference in New Issue