From d39041f2fc7c5734da8b5dede5caac23713e9236 Mon Sep 17 00:00:00 2001 From: Marshall Clow Date: Tue, 7 Aug 2012 17:58:49 +0000 Subject: [PATCH] Added code to let the user specify a compilation database on the command line llvm-svn: 161432 --- .../remove-cstr-calls/RemoveCStrCalls.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/clang-tools-extra/remove-cstr-calls/RemoveCStrCalls.cpp b/clang-tools-extra/remove-cstr-calls/RemoveCStrCalls.cpp index 963b28f889f9..c9b16e022589 100644 --- a/clang-tools-extra/remove-cstr-calls/RemoveCStrCalls.cpp +++ b/clang-tools-extra/remove-cstr-calls/RemoveCStrCalls.cpp @@ -176,13 +176,17 @@ cl::list SourcePaths( cl::desc(" [... ]"), cl::OneOrMore); -int main(int argc, char **argv) { - cl::ParseCommandLineOptions(argc, argv); - std::string ErrorMessage; +int main(int argc, const char **argv) { llvm::OwningPtr Compilations( - CompilationDatabase::loadFromDirectory(BuildPath, ErrorMessage)); - if (!Compilations) - llvm::report_fatal_error(ErrorMessage); + tooling::FixedCompilationDatabase::loadFromCommandLine(argc, argv)); + cl::ParseCommandLineOptions(argc, argv); + if (!Compilations) { + std::string ErrorMessage; + Compilations.reset( + CompilationDatabase::loadFromDirectory(BuildPath, ErrorMessage)); + if (!Compilations) + llvm::report_fatal_error(ErrorMessage); + } tooling::RefactoringTool Tool(*Compilations, SourcePaths); ast_matchers::MatchFinder Finder; FixCStrCall Callback(&Tool.getReplacements());