Lines Matching +full:resource +full:- +full:files

1 //===- Tooling.cpp - Running clang standalone tools -----------------------===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
12 //===----------------------------------------------------------------------===//
63 #define DEBUG_TYPE "clang-tooling"
83 CompilerDriver->setTitle("clang_based_tool"); in newDriver()
89 const driver::JobList &Jobs = Compilation->getJobs(); in ignoreExtraCC1Commands()
90 const driver::ActionList &Actions = Compilation->getActions(); in ignoreExtraCC1Commands()
95 // injected -fsyntax-only or not. Try to handle both cases here. in ignoreExtraCC1Commands()
98 if (StringRef(Job.getExecutable()) == "clang-offload-bundler") in ignoreExtraCC1Commands()
105 A = *A->input_begin(); in ignoreExtraCC1Commands()
107 // Offload compilation has 2 top-level actions, one (at the front) is in ignoreExtraCC1Commands()
110 // tooling will consider host-compilation only. For tooling on device in ignoreExtraCC1Commands()
112 // `--cuda-device-only`, needs specifying. in ignoreExtraCC1Commands()
119 isa<driver::CompileJobAction>(*Actions.front()->input_begin()))); in ignoreExtraCC1Commands()
135 const driver::JobList &Jobs = Compilation->getJobs(); in getCC1Arguments()
150 // If there are no jobs for source files, try checking again for a single job in getCC1Arguments()
162 Diagnostics->Report(diag::err_fe_expected_compiler_job) in getCC1Arguments()
167 return &CC1Jobs[0]->getArguments(); in getCC1Arguments()
178 Invocation->getFrontendOpts().DisableFree = false; in newInvocation()
179 Invocation->getCodeGenOpts().DisableFree = false; in newInvocation()
188 "clang-tool", std::move(PCHContainerOps)); in runToolOnCode()
200 Args.push_back("-fsyntax-only"); in getSyntaxOnlyToolArgs()
218 llvm::IntrusiveRefCntPtr<FileManager> Files( in runToolOnCodeWithArgs() local
223 std::move(ToolAction), Files.get(), std::move(PCHContainerOps)); in runToolOnCodeWithArgs()
237 OverlayFileSystem->pushOverlay(InMemoryFileSystem); in runToolOnCodeWithArgs()
240 InMemoryFileSystem->addFile(FileName, 0, in runToolOnCodeWithArgs()
245 InMemoryFileSystem->addFile( in runToolOnCodeWithArgs()
276 // --target=X in addTargetAndModeForProgramName()
279 // -target X in addTargetAndModeForProgramName()
283 // --driver-mode=X in addTargetAndModeForProgramName()
354 FileManager *Files, std::shared_ptr<PCHContainerOperations> PCHContainerOps) in ToolInvocation() argument
356 Files(Files), PCHContainerOps(std::move(PCHContainerOps)) {} in ToolInvocation()
360 std::unique_ptr<FrontendAction> FAction, FileManager *Files, in ToolInvocation() argument
364 OwnsAction(true), Files(Files), in ToolInvocation()
378 // Parse diagnostic options from the driver command-line only if none were in run()
381 DiagnosticOptions *DiagOpts = this->DiagOpts; in run()
391 // Although `Diagnostics` are used only for command-line parsing, the custom in run()
393 SourceManager SrcMgr(*Diagnostics, *Files); in run()
394 Diagnostics->setSourceManager(&SrcMgr); in run()
397 if (CommandLine.size() >= 2 && CommandLine[1] == "-cc1") { in run()
401 if (Diagnostics->hasErrorOccurred()) in run()
403 return Action->runInvocation(std::move(Invocation), Files, in run()
408 newDriver(&*Diagnostics, BinaryName, &Files->getVirtualFileSystem())); in run()
413 if (!Files->getFileSystemOpts().WorkingDir.empty()) in run()
414 Driver->setCheckInputsExist(false); in run()
416 Driver->BuildCompilation(llvm::ArrayRef(Argv))); in run()
433 // Show the invocation, with -v. in runInvocation()
434 if (Invocation->getHeaderSearchOpts().Verbose) { in runInvocation()
436 Compilation->getJobs().Print(llvm::errs(), "\n", true); in runInvocation()
440 return Action->runInvocation(std::move(Invocation), Files, in runInvocation()
445 std::shared_ptr<CompilerInvocation> Invocation, FileManager *Files, in runInvocation() argument
451 Compiler.setFileManager(Files); in runInvocation()
463 Compiler.createSourceManager(*Files); in runInvocation()
467 Files->clearStatCache(); in runInvocation()
475 IntrusiveRefCntPtr<FileManager> Files) in ClangTool() argument
480 Files(Files ? Files in ClangTool()
482 OverlayFileSystem->pushOverlay(InMemoryFileSystem); in ClangTool()
486 if (Files) in ClangTool()
487 Files->setVirtualFileSystem(OverlayFileSystem); in ClangTool()
506 // Allow users to override the resource dir. in injectResourceDir()
508 if (Arg.starts_with("-resource-dir")) in injectResourceDir()
511 // If there's no override in place add our resource dir. in injectResourceDir()
513 ("-resource-dir=" + CompilerInvocation::GetResourcesPath(Argv0, MainAddr)) in injectResourceDir()
518 // Exists solely for the purpose of lookup of the resource path. in run()
522 // First insert all absolute paths into the in-memory VFS. These are global in run()
527 InMemoryFileSystem->addFile( in run()
550 if (auto CWD = OverlayFileSystem->getCurrentWorkingDirectory()) { in run()
582 if (OverlayFileSystem->setCurrentWorkingDirectory( in run()
587 // Now fill the in-memory VFS with the relative file mappings so it will in run()
593 InMemoryFileSystem->addFile( in run()
602 // Add the resource dir based on the binary of this tool. argv[0] in the in run()
605 // builtin headers in the resource dir need to match the exact clang in run()
609 // pass in made-up names here. Make sure this works on other platforms. in run()
619 ToolInvocation Invocation(std::move(CommandLine), Action, Files.get(), in run()
634 OverlayFileSystem->setCurrentWorkingDirectory(InitialWorkingDir)) in run()
650 FileManager *Files, in runInvocation() argument
655 CompilerInstance::createDiagnostics(&Invocation->getDiagnosticOpts(), in runInvocation()
658 Files); in runInvocation()
675 this->PrintErrorMessage = PrintErrorMessage; in setPrintErrorMessage()
685 "clang-tool", std::move(PCHContainerOps)); in buildASTFromCode()
699 OverlayFileSystem->pushOverlay(InMemoryFileSystem); in buildASTFromCodeWithArgs()
700 llvm::IntrusiveRefCntPtr<FileManager> Files( in buildASTFromCodeWithArgs() local
705 &Action, Files.get(), std::move(PCHContainerOps)); in buildASTFromCodeWithArgs()
708 InMemoryFileSystem->addFile(FileName, 0, in buildASTFromCodeWithArgs()
711 InMemoryFileSystem->addFile( in buildASTFromCodeWithArgs()