summaryrefslogtreecommitdiffstats
path: root/clang/tools/clang-scan-deps/ClangScanDeps.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Revert "[clang][clang-scan-deps] Aggregate the full dependency information."Michael Spencer2019-12-111-208/+7
| | | | | | This reverts commit f978ea498309adaebab8fbf1cd6e520e7e0e11f1. It broke clang-ppc64be-linux, but not sure why yet.
* [clang][clang-scan-deps] Aggregate the full dependency information.Michael Spencer2019-12-111-7/+208
| | | | Differential Revision: https://reviews.llvm.org/D70268
* Add support to find out resource dir and add it as compilation argsKousik Kumar2019-11-221-1/+74
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: If -resource-dir is not specified as part of the compilation command, then by default clang-scan-deps picks up a directory relative to its own path as resource-directory. This is probably not the right behavior - since resource directory should be picked relative to the path of the clang-compiler in the compilation command. This patch adds support for it along with a cache to store the resource-dir paths based on compiler paths. Notes: 1. "-resource-dir" is a behavior that's specific to clang, gcc does not have that flag. That's why if I'm not able to find a resource-dir, I quietly ignore it. 2. Should I also use the mtime of the compiler in the cache? I think its not strictly necessary since we assume the filesystem is immutable. 3. From my testing, this does not regress performance. 4. Will try to get this tested on Windows. But basically the problem that this patch is trying to solve is, clients might not always want to specify "-resource-dir" in their compile commands, so scan-deps must auto-infer it correctly. Reviewers: arphaman, Bigcheese, jkorous, dexonsmith, klimek Reviewed By: Bigcheese Subscribers: MaskRay, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D69122
* Remove Support/Options.h, it is unusedReid Kleckner2019-11-151-1/+1
| | | | | | | | | | | | | | | | | It was added in 2014 in 732e0aa9fb84f1 with one use in Scalarizer.cpp. That one use was then removed when porting to the new pass manager in 2018 in b6f76002d9158628e78. While the RFC and the desire to get off of static initializers for cl::opt all still stand, this code is now dead, and I think we should delete this code until someone is ready to do the migration. There were many clients of CommandLine.h that were it transitively through LLVMContext.h, so I cleaned that up in 4c1a1d3cf97e1ede466. Reviewers: beanz Differential Revision: https://reviews.llvm.org/D70280
* [clang][ScanDeps] Fix issue with multiple commands with the same input.Michael Spencer2019-10-311-14/+33
| | | | | | | | | | | | | | | | | | | Previously, given a CompilationDatabase with two commands for the same source file we would report that file twice with the union of the dependencies for each command both times. This was due to the way `ClangTool` runs actions given an input source file (see the comment in `DependencyScanningTool.cpp`). This commit adds a `SingleCommandCompilationDatabase` that is created with each `CompileCommand` in the original CDB, which is then used for each `ClangTool` invocation. This gives us a single run of `DependencyScanningAction` per `CompileCommand`. I looked at using `AllTUsToolExecutor` which is a parallel tool executor, but I'm not sure it's suitable for `clang-scan-deps` as it does a lot more sharing of state than `AllTUsToolExecutor` expects. Differential Revision: https://reviews.llvm.org/D69643
* [clang][clang-scan-deps] Add support for extracting full module dependencies.Michael Spencer2019-10-301-1/+12
| | | | | | | | | | | This is a recommit of d8a4ef0e685c with the nondeterminism fixed. This adds experimental support for extracting a Clang module dependency graph from a compilation database. The output format is experimental and will change. It is currently a concatenation of JSON outputs for each compilation. Future patches will change this to deduplicate modules between compilations. Differential Revision: https://reviews.llvm.org/D69420
* Revert "[clang][clang-scan-deps] Add support for extracting full module ↵Michael Spencer2019-10-301-12/+1
| | | | | | | | dependencies." This reverts commit d8a4ef0e685cec1fc73d4953b48220b649d05b40. This commit broke some of the bots. I believe it's due to nondeterminism. Will fix and recommit.
* [clang][clang-scan-deps] Add support for extracting full module dependencies.Michael Spencer2019-10-301-1/+12
| | | | | | | | | This adds experimental support for extracting a Clang module dependency graph from a compilation database. The output format is experimental and will change. It is currently a concatenation of JSON outputs for each compilation. Future patches will change this to deduplicate modules between compilations. Differential Revision: https://reviews.llvm.org/D69420
* Refactor DependencyScanningTool to its own fileKousik Kumar2019-10-221-98/+27
| | | | | | | | | | | | | | | | | Summary: There's no behavior change - just moving DependencyScanningTool to its own file since this tool can be reused across both clang-scan-deps binary and an interface exposed as part of libClang APIs. Reviewers: arphaman, jkorous, Bigcheese, dexonsmith Subscribers: mgorny, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D69186 llvm-svn: 375483
* [clang-scan-deps] strip the --serialize-diagnostics argumentAlex Lorenz2019-09-211-0/+2
| | | | | | | This ensures that clang-scan-deps won't write out diagnostics when scanning dependencies. llvm-svn: 372444
* [clang-scan-deps] Add verbose modeJan Korous2019-09-171-2/+9
| | | | | | | | When running in the default mode we don't print anything other than actual output to stdout to make automated processing easier. Differential Revision: https://reviews.llvm.org/D67522 llvm-svn: 372174
* [clang-scan-deps] Add -M to work around -MT issue after r371918Fangrui Song2019-09-141-0/+1
| | | | | | | | | | | gcc will complain if -MT is used but neither -M nor -MM is specified: > cc1: error: to generate dependencies you must specify either -M or -MM r371918 changed our behavior to match GCC, but apparently clang-scan-deps is not happy. llvm-svn: 371920
* NFC, add missing cl::cat option category to clang-scan-deps options to ↵Alex Lorenz2019-09-121-2/+3
| | | | | | ensure they show up in -help llvm-svn: 371759
* [clang-scan-deps] Add dependency targetsJan Korous2019-09-121-1/+43
| | | | | | Differential Revision: https://reviews.llvm.org/D67475 llvm-svn: 371697
* [clang-scan-deps] add skip excluded conditional preprocessor block ↵Alex Lorenz2019-09-111-1/+10
| | | | | | | | | | | | | | | preprocessing optimization This commit adds an optimization to clang-scan-deps and clang's preprocessor that skips excluded preprocessor blocks by bumping the lexer pointer, and not lexing the tokens until reaching appropriate #else/#endif directive. The skip positions and lexer offsets are computed when the file is minimized, directly from the minimized tokens. On an 18-core iMacPro with macOS Catalina Beta I got 10-15% speed-up from this optimization when running clang-scan-deps on the compilation database for a recent LLVM and Clang (3511 files). Differential Revision: https://reviews.llvm.org/D67127 llvm-svn: 371656
* [clang-scan-deps] NFC, refactor the DependencyScanningWorker to use a consumerAlex Lorenz2019-08-301-1/+57
| | | | | | | | | | | to report the dependencies to the client This will allow the scanner to report modular dependencies to the consumer. This will also allow the scanner to accept regular cc1 clang invocations, e.g. in an implementation of a libclang C API for clang-scan-deps, that I will add follow-up patches for in the future. llvm-svn: 370425
* [clang-scan-deps] reuse the file manager across invocations ofAlex Lorenz2019-08-291-1/+6
| | | | | | | | | | | | | | | | the dependency scanner on a single worker thread This behavior can be controlled using the new `-reuse-filemanager` clang-scan-deps option. By default the file manager is reused. The added test/ClangScanDeps/symlink.cpp is able to pass with the reused filemanager after the related FileEntryRef changes landed earlier. The test test/ClangScanDeps/subframework_header_dir_symlink.m still fails when the file manager is reused (I run the FileCheck with not to make it PASS). I will address this in a follow-up patch that improves the DirectoryEntry name modelling in the FileManager. llvm-svn: 370420
* [Clang] Migrate llvm::make_unique to std::make_uniqueJonas Devlieghere2019-08-141-2/+2
| | | | | | | | | | Now that we've moved to C++14, we no longer need the llvm::make_unique implementation from STLExtras.h. This patch is a mechanical replacement of (hopefully) all the llvm::make_unique instances across the monorepo. Differential revision: https://reviews.llvm.org/D66259 llvm-svn: 368942
* clang-scan-deps: do not spawn threads when LLVM_ENABLE_THREADS is disabledAlex Lorenz2019-08-131-19/+28
| | | | llvm-svn: 368640
* [clang-scan-deps] Implementation of dependency scanner over minimized sourcesAlex Lorenz2019-08-061-3/+21
| | | | | | | | | | | | | | | | | | | This commit implements the fast dependency scanning mode in clang-scan-deps: the preprocessing is done on files that are minimized using the dependency directives source minimizer. A shared file system cache is used to ensure that the file system requests and source minimization is performed only once. The cache assumes that the underlying filesystem won't change during the course of the scan (or if it will, it will not affect the output), and it can't be evicted. This means that the service and workers can be used for a single run of a dependency scanner, and can't be reused across multiple, incremental runs. This is something that we'll most likely support in the future though. Note that the driver still utilizes the underlying real filesystem. This commit is also still missing the fast skipped PP block skipping optimization that I mentioned at EuroLLVM talk. Additionally, the file manager is still not reused by the threads as well. Differential Revision: https://reviews.llvm.org/D63907 llvm-svn: 368086
* [clang-scan-deps] use `-Wno-error` when scanning for dependenciesAlex Lorenz2019-07-031-0/+1
| | | | | | | | | Warnings can be promoted to errors. But that shouldn't prevent us from getting the dependencies! Differential Revision: https://reviews.llvm.org/D64149 llvm-svn: 365065
* [clang-scan-deps] Introduce the DependencyScanning library with theAlex Lorenz2019-06-261-114/+22
| | | | | | | | | | | | | thread worker code and better error handling This commit extracts out the code that will powers the fast scanning worker into a new file in a new DependencyScanning library. The error and output handling is improved so that the clients can gather errors/results from the worker directly. Differential Revision: https://reviews.llvm.org/D63681 llvm-svn: 364474
* [clang-scan-deps] print the dependencies to stdoutAlex Lorenz2019-06-211-7/+58
| | | | | | | | and remove the need to use -MD options in the CDB Differential Revision: https://reviews.llvm.org/D63579 llvm-svn: 364088
* [clang-scan-deps] Include <mutex> in ClangScanDeps.cpp to ensure itAlex Lorenz2019-06-121-0/+1
| | | | | | builds on all platforms llvm-svn: 363208
* NFC, Update the ClangScanDeps.cpp file's license commentAlex Lorenz2019-06-121-5/+4
| | | | | | | The file ClangScanDeps.cpp from r363204 had the old outdated LLVM license comment at the top of the file that I committed by accident. llvm-svn: 363207
* [clang-scan-deps] initial outline of the tool that runs preprocessor to findAlex Lorenz2019-06-121-0/+218
dependencies over a JSON compilation database This commit introduces an outline for the clang-scan-deps tool that will be used to implement fast dependency discovery phase using implicit modules for explicit module builds. The initial version of the tool works by computing non-modular header dependencies for files in the compilation database without any optimizations (i.e. without source minimization from r362459). The tool spawns a number of worker threads to run the clang compiler workers in parallel. The immediate goal for clang-scan-deps is to create a ClangScanDeps library which will be used to build up this tool to use the source minimization and caching multi-threaded filesystem to implement the optimized non-incremental dependency scanning phase for a non-modular build. This will allow us to do benchmarks and comparisons for performance that the minimization and caching give us Differential Revision: https://reviews.llvm.org/D60233 llvm-svn: 363204
OpenPOWER on IntegriCloud