set(LLVM_LINK_COMPONENTS
+ ${LLVM_TARGETS_TO_BUILD}
Core
Support
)
LINK_LIBS
clangAST
clangBasic
+ clangCodeGen
clangDriver
clangFrontend
clangFrontendTool
//===----------------------------------------------------------------------===//
#include "clang/Tooling/DependencyScanning/DependencyScanningService.h"
+#include "llvm/Support/TargetSelect.h"
using namespace clang;
using namespace tooling;
ScanningMode Mode, ScanningOutputFormat Format, bool ReuseFileManager,
bool SkipExcludedPPRanges)
: Mode(Mode), Format(Format), ReuseFileManager(ReuseFileManager),
- SkipExcludedPPRanges(SkipExcludedPPRanges) {}
+ SkipExcludedPPRanges(SkipExcludedPPRanges) {
+ // Initialize targets for object file support.
+ llvm::InitializeAllTargets();
+ llvm::InitializeAllTargetMCs();
+ llvm::InitializeAllAsmPrinters();
+ llvm::InitializeAllAsmParsers();
+}
//===----------------------------------------------------------------------===//
#include "clang/Tooling/DependencyScanning/DependencyScanningWorker.h"
+#include "clang/CodeGen/ObjectFilePCHContainerOperations.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Frontend/CompilerInvocation.h"
#include "clang/Frontend/FrontendActions.h"
DependencyScanningService &Service)
: Format(Service.getFormat()) {
DiagOpts = new DiagnosticOptions();
+
PCHContainerOps = std::make_shared<PCHContainerOperations>();
+ PCHContainerOps->registerReader(
+ std::make_unique<ObjectFilePCHContainerReader>());
+ // We don't need to write object files, but the current PCH implementation
+ // requires the writer to be registered as well.
+ PCHContainerOps->registerWriter(
+ std::make_unique<ObjectFilePCHContainerWriter>());
+
RealFS = llvm::vfs::createPhysicalFileSystem();
if (Service.canSkipExcludedPPRanges())
PPSkipMappings =
--- /dev/null
+[
+ {
+ "directory": "DIR",
+ "command": "clang -fsyntax-only DIR/tu.c -fmodules -gmodules -fimplicit-module-maps -fmodules-cache-path=DIR/cache -include DIR/pch.h -o DIR/tu.o",
+ "file": "DIR/tu.c"
+ }
+]
--- /dev/null
+// mod_tu.h
--- /dev/null
+module ModTU {
+ header "mod_tu.h"
+}
--- /dev/null
+// tu.c
+
+#include "mod_tu.h"
--- /dev/null
+// RUN: rm -rf %t && mkdir %t
+// RUN: cp %S/Inputs/modules-pch/* %t
+
+// Explicitly build the PCH:
+//
+// RUN: %clang -x c-header %t/pch.h -fmodules -gmodules -fimplicit-module-maps \
+// RUN: -fmodules-cache-path=%t/cache -o %t/pch.h.gch
+
+// Scan dependencies of the TU:
+//
+// RUN: sed "s|DIR|%/t|g" %S/Inputs/modules-pch/cdb_tu.json > %t/cdb_tu.json
+// RUN: clang-scan-deps -compilation-database %t/cdb_tu.json -format experimental-full \
+// RUN: -generate-modules-path-args -module-files-dir %t/build