aboutsummaryrefslogtreecommitdiff
path: root/tools/clang-check/ClangCheck.cpp
diff options
context:
space:
mode:
authorManuel Klimek <klimek@google.com>2012-07-10 13:10:51 +0000
committerManuel Klimek <klimek@google.com>2012-07-10 13:10:51 +0000
commit8fa2fb859a4cb8e67d9763225281d9b0aa9cb59f (patch)
treebaba2e136725c1e8cba0ce410db39759981af927 /tools/clang-check/ClangCheck.cpp
parent3f6d513d51a382371669f4d0b943fa830fffeef2 (diff)
Adds support for auto-detection of compilation databases
from a source file and changes clang-check to make use of this. This makes clang-check just work on in-tree builds, and allows easy setup via a symlink per source directory to make clang-check work without any extra configuration. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159990 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/clang-check/ClangCheck.cpp')
-rw-r--r--tools/clang-check/ClangCheck.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/tools/clang-check/ClangCheck.cpp b/tools/clang-check/ClangCheck.cpp
index d68e282949..ef4a3ace0c 100644
--- a/tools/clang-check/ClangCheck.cpp
+++ b/tools/clang-check/ClangCheck.cpp
@@ -42,8 +42,9 @@ using namespace clang::tooling;
using namespace llvm;
cl::opt<std::string> BuildPath(
- cl::Positional,
- cl::desc("<build-path>"));
+ "p",
+ cl::desc("<build-path>"),
+ cl::Optional);
cl::list<std::string> SourcePaths(
cl::Positional,
@@ -56,8 +57,13 @@ int main(int argc, const char **argv) {
cl::ParseCommandLineOptions(argc, argv);
if (!Compilations) {
std::string ErrorMessage;
- Compilations.reset(CompilationDatabase::loadFromDirectory(BuildPath,
- ErrorMessage));
+ if (!BuildPath.empty()) {
+ Compilations.reset(CompilationDatabase::loadFromDirectory(BuildPath,
+ ErrorMessage));
+ } else {
+ Compilations.reset(CompilationDatabase::autoDetectFromSource(
+ SourcePaths[0], ErrorMessage));
+ }
if (!Compilations)
llvm::report_fatal_error(ErrorMessage);
}