summaryrefslogtreecommitdiffstats
path: root/clang/lib/Tooling/JSONCompilationDatabase.cpp
diff options
context:
space:
mode:
authorKadir Cetinkaya <kadircet@google.com>2019-06-26 07:39:03 +0000
committerKadir Cetinkaya <kadircet@google.com>2019-06-26 07:39:03 +0000
commitc3a7302397746d669e5339ef25506b0429b23354 (patch)
treef008d7424779a9e10652a21710e770a2ba55ae02 /clang/lib/Tooling/JSONCompilationDatabase.cpp
parent5dff8ca26a90c749a7a9550764592980f30ab544 (diff)
downloadbcm5719-llvm-c3a7302397746d669e5339ef25506b0429b23354.tar.gz
bcm5719-llvm-c3a7302397746d669e5339ef25506b0429b23354.zip
[clang][Tooling] Infer target and mode from argv[0] when using JSONCompilationDatabase
Summary: Wraps JSON compilation database with a target and mode adding database wrapper. So that driver can correctly figure out which toolchain to use. Note that clients that wants to make use of this target discovery mechanism needs to link in TargetsInfos and initialize them at startup. Reviewers: ilya-biryukov Subscribers: mgorny, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63755 llvm-svn: 364386
Diffstat (limited to 'clang/lib/Tooling/JSONCompilationDatabase.cpp')
-rw-r--r--clang/lib/Tooling/JSONCompilationDatabase.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/clang/lib/Tooling/JSONCompilationDatabase.cpp b/clang/lib/Tooling/JSONCompilationDatabase.cpp
index 0ee9d174b44..76a82b0fd9b 100644
--- a/clang/lib/Tooling/JSONCompilationDatabase.cpp
+++ b/clang/lib/Tooling/JSONCompilationDatabase.cpp
@@ -14,7 +14,9 @@
#include "clang/Basic/LLVM.h"
#include "clang/Tooling/CompilationDatabase.h"
#include "clang/Tooling/CompilationDatabasePluginRegistry.h"
+#include "clang/Tooling/Tooling.h"
#include "llvm/ADT/Optional.h"
+#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
@@ -165,7 +167,9 @@ class JSONCompilationDatabasePlugin : public CompilationDatabasePlugin {
llvm::sys::path::append(JSONDatabasePath, "compile_commands.json");
auto Base = JSONCompilationDatabase::loadFromFile(
JSONDatabasePath, ErrorMessage, JSONCommandLineSyntax::AutoDetect);
- return Base ? inferMissingCompileCommands(std::move(Base)) : nullptr;
+ return Base ? inferTargetAndDriverMode(
+ inferMissingCompileCommands(std::move(Base)))
+ : nullptr;
}
};
OpenPOWER on IntegriCloud