From a83c17c28f4a570e18678f6031834487534f120d Mon Sep 17 00:00:00 2001
From: Nico Weber <nicolasweber@gmx.de>
Date: Sat, 14 May 2011 21:20:23 +0000
Subject: [PATCH] Let clang-check actually use the Directory entry in the json
 file.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131367 91177308-0d34-0410-b5e6-96231b3b80d8
---
 examples/Tooling/ClangCheck.cpp              | 6 ++++++
 lib/Tooling/JsonCompileCommandLineDatabase.h | 2 +-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/examples/Tooling/ClangCheck.cpp b/examples/Tooling/ClangCheck.cpp
index 0dfa53d44e6..db24ec31ecc 100644
--- a/examples/Tooling/ClangCheck.cpp
+++ b/examples/Tooling/ClangCheck.cpp
@@ -93,6 +93,12 @@ int main(int argc, char **argv) {
         clang::tooling::FindCompileArgsInJsonDatabase(
             File.str(), JsonDatabase->getBuffer(), ErrorMessage);
     if (!LookupResult.CommandLine.empty()) {
+      if (LookupResult.Directory.size()) {
+        // FIXME: What should happen if CommandLine includes -working-directory
+        // as well?
+        LookupResult.CommandLine.push_back(
+            "-working-directory=" + LookupResult.Directory);
+      }
       if (!clang::tooling::RunToolWithFlags(
                new clang::SyntaxOnlyAction,
                LookupResult.CommandLine.size(),
diff --git a/lib/Tooling/JsonCompileCommandLineDatabase.h b/lib/Tooling/JsonCompileCommandLineDatabase.h
index 9e776d60010..ea7cf0e6e15 100644
--- a/lib/Tooling/JsonCompileCommandLineDatabase.h
+++ b/lib/Tooling/JsonCompileCommandLineDatabase.h
@@ -78,7 +78,7 @@ class JsonCompileCommandLineParser {
                                CompileCommandHandler *CommandHandler);
 
   /// \brief Parses the specified input. Returns true if no parsing errors were
-  /// foudn.
+  /// found.
   bool Parse();
 
   /// \brief Returns an error message if Parse() returned false previously.
-- 
GitLab