summaryrefslogtreecommitdiffstats
path: root/clang/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
commit65fd0e1fd3c7fe24bb09e654d228c9584c2fa6ff (patch)
treec6a6969bd885beb99cae9776826065fdfda3f8bb /clang/tools/clang-check/ClangCheck.cpp
parent1dc44dcedd0bc93e267bcc5357fc2925942ca20e (diff)
downloadbcm5719-llvm-65fd0e1fd3c7fe24bb09e654d228c9584c2fa6ff.tar.gz
bcm5719-llvm-65fd0e1fd3c7fe24bb09e654d228c9584c2fa6ff.zip
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. llvm-svn: 159990
Diffstat (limited to 'clang/tools/clang-check/ClangCheck.cpp')
-rw-r--r--clang/tools/clang-check/ClangCheck.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/clang/tools/clang-check/ClangCheck.cpp b/clang/tools/clang-check/ClangCheck.cpp
index d68e282949c..ef4a3ace0c3 100644
--- a/clang/tools/clang-check/ClangCheck.cpp
+++ b/clang/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);
}
OpenPOWER on IntegriCloud