summaryrefslogtreecommitdiffstats
path: root/clang/lib/Tooling
Commit message (Collapse)AuthorAgeFilesLines
...
* [clang-scan-deps] Add basic support for modules.Michael Spencer2019-10-241-4/+38
| | | | | | | | | | | | | | | | | | | | This fixes two issues that prevent simple uses of modules from working. * We would previously minimize _every_ file opened by clang, even module maps and module pcm files. Now we only minimize files with known extensions. It would be better if we knew which files clang intended to open as a source file, but this works for now. * We previously cached every lookup, even failed lookups. This is a problem because clang stats the module cache directory before building a module and creating that directory. If we cache that failure then the subsequent pcm load doesn't see the module cache and fails. Overall this still leaves us building minmized modules on disk during scanning. This will need to be improved eventually for performance, but this is correct, and works for now. Differential Revision: https://reviews.llvm.org/D68835
* Refactor DependencyScanningTool to its own fileKousik Kumar2019-10-222-0/+72
| | | | | | | | | | | | | | | | | 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
* Prune Pass.h include from DataLayout.h. NFCIBjorn Pettersson2019-10-211-0/+1
| | | | | | | | | | | | | | | | | | | Summary: Reduce include dependencies by no longer including Pass.h from DataLayout.h. That include seemed irrelevant to DataLayout, as well as being irrelevant to several users of DataLayout. Reviewers: rnk Reviewed By: rnk Subscribers: mehdi_amini, hiraditya, cfe-commits, llvm-commits Tags: #clang, #llvm Differential Revision: https://reviews.llvm.org/D69261 llvm-svn: 375436
* [tooling] Relax an assert when multiple GPU targets are specified.Michael Liao2019-10-181-1/+1
| | | | llvm-svn: 375245
* Revert "Include sanitize blacklist and other extra deps as part of scan-deps ↵Kousik Kumar2019-10-171-2/+0
| | | | | | | | | | | | | | | | | | output" This test is failing on Windows bots, revert for now (will check the right fix and retry the patch). Summary: This reverts commit 962ca076e51c25a7a08f4e0d329c65328a635bdb. Reviewers: Bigcheese, jkorous, arphaman Subscribers: dexonsmith, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D69079 llvm-svn: 375079
* Include sanitize blacklist and other extra deps as part of scan-deps outputKousik Kumar2019-10-171-0/+2
| | | | | | | | | | | | | | | | | Summary: Clang's -M mode includes these extra dependencies in its output and clang-scan-deps should have equivalent behavior, so adding these extradeps to output just like how its being done for ".d" file generation mode. Reviewers: arphaman, dexonsmith, Bigcheese, jkorous Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D69017 llvm-svn: 375074
* [libTooling] Put all Transformer declarations in a single namespace.Yitzhak Mandelbaum2019-10-164-59/+63
| | | | | | | | | | | | | | | | Summary: This revision introduces a new namespace, `clang::transformer`, to hold the declarations for the Transformer library. Reviewers: gribozavr Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D68876 llvm-svn: 374962
* [libTooling] Move `RewriteRule` abstraction into its own header and impl.Yitzhak Mandelbaum2019-10-113-167/+182
| | | | | | | | | | | | | | | | | | | Summary: Move the `RewriteRule` class and related declarations into its own set of files (header, implementation). Only the `Transformer` class is left in the Transformer-named files. This change clarifies the distinction between the `RewriteRule` class, which is essential to the Transformer library, and the `Transformer` class, which is only one possible `RewriteRule` interpreter (compare to `TransformerClangTidyCheck`, a clang-tidy based interpreter). Reviewers: gribozavr Subscribers: jfb, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D68795 llvm-svn: 374558
* [libTooling] Change Stencil equality to use `toString()`Yitzhak Mandelbaum2019-10-111-55/+3
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: Removes the `isEqual` method from StencilPartInterface and modifies equality to use the string representation returned by the `toString` method for comparison. This means the `run` and `selection` stencils return true by default, and clients should be cautious in relying on equality operator for comparison of stencils containing parts generated by these functions. It also means we no longer need the custom RTTI support (typeId() and down_cast()), so it has been removed. Patch by Harshal T. Lehri. Reviewers: gribozavr Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D68825 llvm-svn: 374552
* [tooling] Fix assertion on MacOSX.Michael Liao2019-10-101-1/+6
| | | | llvm-svn: 374478
* [tooling] Teach Tooling to understand compilation with offloading.Michael Liao2019-10-101-1/+23
| | | | | | | | | | | | | | | | Summary: - So far, we only recognize the host compilation with offloading and skip the offloading part. Reviewers: tra, yaxunl Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D68660 llvm-svn: 374470
* [ScanDeps] clang-format, 80 cols.Michael J. Spencer2019-10-101-4/+7
| | | | llvm-svn: 374439
* In openFileForRead don't cache erroneous entries if the error relates to ↵Kousik Kumar2019-10-101-35/+20
| | | | | | | | | | | | | | | | | | | | them being directories. Add tests. Summary: It seems that when the CachingFileSystem is first given a file to open that is actually a directory, it incorrectly caches that path to be errenous and throws an error when subsequently a directory open call is made for the same path. This change makes it so that we do NOT cache a path if it turns out we asked for a file when its a directory. Reviewers: arphaman Subscribers: dexonsmith, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D68193 llvm-svn: 374366
* [libTooling] Move Transformer files to their own directory/library.Yitzhak Mandelbaum2019-10-108-16/+29
| | | | | | | | | | | | | | | | | | | Summary: The Transformer library has been growing inside of lib/Tooling/Refactoring. However, it's not really related to anything else in that directory. This revision moves all Transformer-related files into their own include & lib directories. A followup revision will (temporarily) add forwarding headers to help any users migrate their code to the new location. Reviewers: gribozavr Subscribers: mgorny, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D68637 llvm-svn: 374271
* [libTooling] Add `toString` method to the Stencil classYitzhak Mandelbaum2019-10-071-0/+51
| | | | | | | | | | | | | | | | | Summary: `toString` generates a string representation of the stencil. Patch by Harshal T. Lehri. Reviewers: gribozavr Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D68574 llvm-svn: 373916
* [clang-rename] Fix a crash when renaming a class without definition.Haojian Wu2019-10-041-0/+4
| | | | | | | | | | | | Reviewers: sammccall Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D68459 llvm-svn: 373748
* [libTooling] Add various Stencil combinators for expressions.Yitzhak Mandelbaum2019-10-031-1/+62
| | | | | | | | | | | | | | | | | | | Summary: This revision adds three new Stencil combinators: * `expression`, which idiomatically constructs the source for an expression, including wrapping the expression's source in parentheses if needed. * `deref`, which constructs an idiomatic dereferencing expression. * `addressOf`, which constructs an idiomatic address-taking expression. Reviewers: gribozavr Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D68315 llvm-svn: 373593
* [Stencil] Hide implementaion detai. NFC.Benjamin Kramer2019-10-021-1/+1
| | | | llvm-svn: 373504
* [libTooling] Transformer: refine `SourceLocation` specified as anchor of ↵Yitzhak Mandelbaum2019-09-271-12/+21
| | | | | | | | | | | | | | | | | | | | | | | changes. Summary: Every change triggered by a rewrite rule is anchored at a particular location in the source code. This patch refines how that location is chosen and defines it as an explicit function so it can be shared by other Transformer implementations. This patch was inspired by a bug found by a clang tidy, wherein two changes were anchored at the same location (the expansion loc of the macro) resulting in the discarding of the second change. Reviewers: gribozavr Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D66652 llvm-svn: 373093
* [libTooling] Add `run` combinator to Stencils.Yitzhak Mandelbaum2019-09-261-0/+22
| | | | | | | | | | | | | | | | Summary: This revision adds `run`, a StencilPart that runs a user-defined function that computes a result over `MatchFinder::MatchResult`. Reviewers: gribozavr Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D67969 llvm-svn: 372936
* [clang-format] Modified SortIncludes and IncludeCategories to priority for ↵Paul Hoad2019-09-252-0/+15
| | | | | | | | | | | | | | | | | | | | | | | | | sorting #includes within the Group Category. Summary: This new Style rule is made as a part of adding support for NetBSD KNF in clang-format. NetBSD have it's own priority of includes which should be followed while formatting NetBSD code. This style sorts the Cpp Includes according to the priorities of NetBSD, as mentioned in the [Style Guide](http://cvsweb.netbsd.org/bsdweb.cgi/src/share/misc/style?rev=HEAD&content-type=text/x-cvsweb-markup) The working of this Style rule shown below: **Configuration:** This revision introduces a new field under IncludeCategories named `SortPriority` which defines the priority of ordering the `#includes` and the `Priority` will define the categories for grouping the `#include blocks`. Reviewers: cfe-commits, mgorny, christos, MyDeveloperDay Reviewed By: MyDeveloperDay Subscribers: lebedev.ri, rdwampler, christos, mgorny, krytarowski Patch By: Manikishan Tags: #clang, #clang-format Differential Revision: https://reviews.llvm.org/D64695 llvm-svn: 372919
* [libTooling] Introduce the MatchConsumer abstractionYitzhak Mandelbaum2019-09-251-8/+0
| | | | | | | | | | | | | | | | | Summary: This revision introduces a separate (small) library for the `MatchConsumer` abstraction: computations over AST match results. This abstraction is central to the Transformer framework, and there deserves being defined explicitly. Reviewers: gribozavr Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D67961 llvm-svn: 372870
* [libTooling] Add `access` and `ifBound` combinators to Stencil library.Yitzhak Mandelbaum2019-09-231-17/+77
| | | | | | | | | | | | | | | | | | | | Summary: This revision add the `access` and `ifBound` combinators to the Stencil library: * `access` -- constructs an idiomatic expression for accessing a member (a `MemberExpr`). * `ifBound` -- chooses between two `StencilParts` based on the whether an id is bound in the match (corresponds to the combinator of the same name in RangeSelector). Reviewers: gribozavr Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D67633 llvm-svn: 372605
* [libTooling] Introduce new library of source-code builders.Yitzhak Mandelbaum2019-09-232-0/+161
| | | | | | | | | | | | | | | | | Summary: Introduces facilities for easily building source-code strings, including idiomatic use of parentheses and the address-of, dereference and member-access operators (dot and arrow) and queries about need for parentheses. Reviewers: gribozavr Subscribers: mgorny, cfe-commits, ilya-biryukov Tags: #clang Differential Revision: https://reviews.llvm.org/D67632 llvm-svn: 372595
* [clang-scan-deps] strip the --serialize-diagnostics argumentAlex Lorenz2019-09-211-0/+16
| | | | | | | This ensures that clang-scan-deps won't write out diagnostics when scanning dependencies. llvm-svn: 372444
* [libTooling] Add `ifBound`, `elseBranch` RangeSelector combinators.Yitzhak Mandelbaum2019-09-201-0/+24
| | | | | | | | | | | | | | | | | | Summary: Adds two new combinators and corresponding tests to the RangeSelector library. * `ifBound` -- conditional evaluation of range-selectors, based on whether a given node id is bound in the match. * `elseBranch` -- selects the source range of the else and its statement. Reviewers: gribozavr Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D67621 llvm-svn: 372410
* [clang-scan-deps] Fix for headers having the same name as a directoryAlex Lorenz2019-09-131-0/+3
| | | | | | | | | | | | Scan deps tool crashes when called on a C++ file, containing an include that has the same name as a directory. The tool crashes since it finds foo/dir and tries to read that as a file and fails. Patch by: kousikk (Kousik Kumar) Differential Revision: https://reviews.llvm.org/D67091 llvm-svn: 371903
* [clang-scan-deps] remove dots and dots dots from the reported file ↵Alex Lorenz2019-09-121-2/+6
| | | | | | | | | | dependency paths This resolves differences observed on LLVM + Clang when running the comparison between canonical dependencies (full preprocessing, no file manager reused), and dependencies obtained when the file manager was reused between the full preprocessing invocations. llvm-svn: 371751
* [clang-scan-deps] cast Result to ErrorOr<unique_ptr<vfs::File>> explicitly ↵Alex Lorenz2019-09-111-1/+2
| | | | | | to avoid s390x-linux buildbot failure llvm-svn: 371664
* [clang-scan-deps] add skip excluded conditional preprocessor block ↵Alex Lorenz2019-09-113-11/+50
| | | | | | | | | | | | | | | 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
* [Driver] Use shared singleton instance of DriverOptTableIlya Biryukov2019-09-042-6/+5
| | | | | | | | | | | | | | | | | | | | | Summary: This significantly reduces the time required to run clangd tests, by ~10%. Should also have an effect on other tests that run command-line parsing multiple times inside a single invocation. Reviewers: gribozavr, sammccall Reviewed By: sammccall Subscribers: kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D67163 llvm-svn: 370908
* [clang-scan-deps] NFC, remove outdated implementation commentAlex Lorenz2019-08-301-1/+0
| | | | | | | | There's no need to purge symlinked entries in the FileManager, as the new FileEntryRef API allows us to compute dependencies more accurately when the FileManager is reused. llvm-svn: 370493
* [Tooling] Migrated APIs that take ownership of objects to unique_ptrDmitri Gribenko2019-08-301-15/+14
| | | | | | | | | | Subscribers: jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D66960 llvm-svn: 370451
* [clang-scan-deps] NFC, refactor the DependencyScanningWorker to use a consumerAlex Lorenz2019-08-301-35/+39
| | | | | | | | | | | 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-293-5/+12
| | | | | | | | | | | | | | | | 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
* Changed FrontendActionFactory::create to return a std::unique_ptrDmitri Gribenko2019-08-291-5/+10
| | | | | | | | | | Subscribers: jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D66947 llvm-svn: 370379
* ArrayRef'ized CompilerInvocation::CreateFromArgsDmitri Gribenko2019-08-271-3/+1
| | | | | | | | | | Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D66797 llvm-svn: 370122
* [Syntax] Added function to get macro expansion tokens to TokenBuffer.Johan Vikstrom2019-08-201-0/+15
| | | | | | | | | | | | | | | | Summary: Returns the first token in every mapping where the token is an identifier. This API is required to be able to highlight macro expansions in clangd. Reviewers: hokein, ilya-biryukov Subscribers: kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D66470 llvm-svn: 369385
* [Tooling] Add a hack to work around issues with matcher binding in r368681.David L. Jones2019-08-151-2/+4
| | | | | | | | | | | | | | | | | | | | | | The change in r368681 contains a (probably unintentional) behavioral change for rewrite rules with a single matcher. Previously, the single matcher would not need to be bound (`joinCaseMatchers` returned it directly), even though a final DynTypeMatcher was created and bound by `buildMatcher`. With the new change, a single matcher will be bound, in addition to the final binding (which is now in `buildMatchers`, but happens roughly at the same point in the overall flow). This patch simply duplicates the "final matcher" trick: it creates an extra DynTypedMatcher for each rewrite rule case matcher, and unconditionally makes it bindable. This is probably not the right long-term fix, but it does allow existing code to continue to work with this interface. Subscribers: cfe-commits, gribozavr, ymandel Tags: #clang Differential Revision: https://reviews.llvm.org/D66273 llvm-svn: 368958
* [Clang] Migrate llvm::make_unique to std::make_uniqueJonas Devlieghere2019-08-1416-28/+28
| | | | | | | | | | 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
* [libTooling] Fix code to avoid unused-function warning after r368681.Yitzhak Mandelbaum2019-08-141-0/+2
| | | | llvm-svn: 368862
* [Tooling] Added DeclStmtClass to ExtractionSemicolonPolicyShaurya Gupta2019-08-141-0/+1
| | | | | | | Since the DeclStmt range includes the semicolon, it doesn't need a semicolon at the end during extraction llvm-svn: 368850
* [Refactor] Moving SourceExtraction header from lib to includeShaurya Gupta2019-08-133-53/+2
| | | | | | | | | | | | | | | Summary: - Moved the SourceExtraction header from lib to include so that it can be used in clangd. Reviewers: arphaman Subscribers: ilya-biryukov, dexonsmith, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D65878 llvm-svn: 368743
* [libTooling] In Transformer, generalize `applyFirst` to admit rules with ↵Yitzhak Mandelbaum2019-08-131-60/+47
| | | | | | | | | | | | | | | | | | | | | incompatible matchers. Summary: This patch removes an (artificial) limitation of `applyFirst`, which requires that all of the rules' matchers can be grouped together in a single `anyOf()`. This change generalizes the code to group the matchers into separate `anyOf`s based on compatibility. Correspondingly, `buildMatcher` is changed to `buildMatchers`, to allow for returning a set of matchers rather than just one. Reviewers: gribozavr Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D65877 llvm-svn: 368681
* [Extract] Fixed SemicolonExtractionPolicy for SwitchStmt and SwitchCaseShaurya Gupta2019-08-081-1/+4
| | | | | | | | | | | | Reviewers: arphaman, sammccall Subscribers: dexonsmith, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D65883 llvm-svn: 368267
* [Tooling] Expose ExecutorConcurrency option.Diego Astiazaran2019-08-071-1/+1
| | | | | | | | D65628 requires a flag to specify the number of threads for a clang-doc step. It would be good to use ExecutorConcurrency after exposing it instead of creating a new one that has the same purpose. Differential Revision: https://reviews.llvm.org/D65833 llvm-svn: 368196
* [clang-scan-deps] Implementation of dependency scanner over minimized sourcesAlex Lorenz2019-08-064-13/+279
| | | | | | | | | | | | | | | | | | | 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
* [Syntax] Do not add a node for 'eof' into the treeIlya Biryukov2019-08-061-4/+8
| | | | | | | | | | | | | | | | | | Summary: While useful as a sentinel value when iterating over tokens, having 'eof' in the tree, seems to do more harm than good. Reviewers: sammccall Reviewed By: sammccall Subscribers: javed.absar, kristof.beyls, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64576 llvm-svn: 368062
* Move LangStandard*, InputKind::Language to BasicRainer Orth2019-08-051-15/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch is a prerequisite for using LangStandard from Driver in https://reviews.llvm.org/D64793. It moves LangStandard* and InputKind::Language to Basic. It is mostly mechanical, with only a few changes of note: - enum Language has been changed into enum class Language : uint8_t to avoid a clash between OpenCL in enum Language and OpenCL in enum LangFeatures and not to increase the size of class InputKind. - Now that getLangStandardForName, which is currently unused, also checks both canonical and alias names, I've introduced a helper getLangKind which factors out a code pattern already used 3 times. The patch has been tested on x86_64-pc-solaris2.11, sparcv9-sun-solaris2.11, and x86_64-pc-linux-gnu. There's a companion patch for lldb which uses LangStandard.h (https://reviews.llvm.org/D65717). While polly includes isl which in turn uses InputKind::C, that part of the code isn't even built inside the llvm tree. I've posted a patch to allow for both InputKind::C and Language::C upstream (https://groups.google.com/forum/#!topic/isl-development/6oEvNWOSQFE). Differential Revision: https://reviews.llvm.org/D65562 llvm-svn: 367864
* [clang] Adopt new FileManager error-returning APIsHarlan Haskins2019-08-012-6/+10
| | | | | | | Update the callers of FileManager::getFile and FileManager::getDirectory to handle the new llvm::ErrorOr-returning methods. Signed-off-by: Harlan Haskins <harlan@apple.com> llvm-svn: 367616
OpenPOWER on IntegriCloud