summaryrefslogtreecommitdiffstats
path: root/clang/unittests/Tooling
Commit message (Collapse)AuthorAgeFilesLines
...
* Removed the 'id' AST matcher, which is superseded by '.bind()'Dmitri Gribenko2019-08-201-18/+18
| | | | | | | | | | | | | | | | | Summary: The 'id' matcher is not even included in the AST Matchers Reference document, so I don't expect there to be a significant number of users. There's no reason to provide two ways to do the exact same thing that only have a minor syntactic difference. Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D66462 llvm-svn: 369380
* [Clang] Migrate llvm::make_unique to std::make_uniqueJonas Devlieghere2019-08-147-18/+18
| | | | | | | | | | 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
* Removed ToolExecutor::isSingleProcess, it is not used by anythingDmitri Gribenko2019-08-141-2/+0
| | | | | | | | | | Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D66212 llvm-svn: 368832
* [libTooling] In Transformer, generalize `applyFirst` to admit rules with ↵Yitzhak Mandelbaum2019-08-131-46/+80
| | | | | | | | | | | | | | | | | | | | | 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
* [AST] No longer visiting CXXMethodDecl bodies created by compiler when ↵Johan Vikstrom2019-08-092-0/+59
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | method was default created. Summary: Clang generates function bodies and puts them in the AST for default methods if it is defaulted outside the class definition. ` struct A { A &operator=(A &&O); }; A &A::operator=(A &&O) = default; ` This will generate a function body for the `A &A::operator=(A &&O)` and put it in the AST. This body should not be visited if implicit code is not visited as it is implicit. This was causing SemanticHighlighting in clangd to generate duplicate tokens and putting them in weird places. Reviewers: hokein, ilya-biryukov, gribozavr Subscribers: mgorny, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D65938 llvm-svn: 368402
* [Syntax] Do not add a node for 'eof' into the treeIlya Biryukov2019-08-061-9/+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
* [AST] Fix buildbot failure because of raw string inside macro from 367839.Johan Vikstrom2019-08-051-1/+1
| | | | llvm-svn: 367892
* [AST] Fix RecursiveASTVisitorTest multiline string literal. NFCDavid Green2019-08-051-3/+3
| | | | | | | | Some compiler, notably older gccs (< 8) can have trouble with multiline raw string literals inside macros. This just moves the code outsize the macro, to attempt to appease the bots. llvm-svn: 367885
* [AST] Fix RecursiveASTVisitor visiting implicit constructor initializers.Johan Vikstrom2019-08-052-0/+58
| | | | | | | | | | | | | | Summary: RecursiveASTVisitor was visiting implcit constructor initializers. This caused semantic highlighting in clangd to emit error logs. Fixes this by checking if the constructor is written or if the visitor should visit implicit decls. Reviewers: hokein, ilya-biryukov Subscribers: kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D65735 llvm-svn: 367839
* [clang] Adopt new FileManager error-returning APIsHarlan Haskins2019-08-012-9/+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
* [Preprocessor] Always discard body of #define if we failed to parse itIlya Biryukov2019-08-011-0/+15
| | | | | | | | | | | | | | | | | | | | Summary: Preivously we would only discard it if we failed to parse parameter lists. If we do not consume the body, parser sees tokens inside directive. In turn, this leads to spurious diagnostics and a crash in TokenBuffer, see the added tests. Reviewers: sammccall Reviewed By: sammccall Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D65517 llvm-svn: 367530
* [AST] Treat semantic form of InitListExpr as implicit code in traversalsIlya Biryukov2019-07-221-1/+18
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: In particular, do not traverse the semantic form if shouldVisitImplicitCode() returns false. This simplifies the common case of traversals, avoiding the need to worry about some expressions being traversed twice. No tests break after the change, the change would allow to simplify at least one of the usages, i.e. r366070 which had to handle this in clangd. Reviewers: gribozavr Reviewed By: gribozavr Subscribers: kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64762 llvm-svn: 366672
* Disallow most calling convention attributes on PS4Sunil Srivastava2019-07-191-0/+2
| | | | | | | | PS4 now only allows "cdecl", and its equivalent on PS4, "sysv_abi". Differential Revision: https://reviews.llvm.org/D64780 llvm-svn: 366617
* [LibTooling] Relax Transformer to allow rewriting macro expansionsYitzhak Mandelbaum2019-07-181-22/+102
| | | | | | | | | | | | | | | | | | | | Summary: Currently, Transformer rejects any changes to source locations inside macro expansions. This change relaxes that constraint to allow rewrites when the entirety of the expansion is replaced, since that can be mapped to replacing the entirety of the expansion range in the file source. This change makes Transformer consistent with the handling of edit ranges in `clang::edit::Commit` (which is used, for example, for applying `FixItHint`s from diagnostics). Reviewers: ilya-biryukov Subscribers: gribozavr, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64518 llvm-svn: 366473
* [LibTooling] Add function to translate and validate source range for editingYitzhak Mandelbaum2019-07-181-2/+108
| | | | | | | | | | | | | | | | | Summary: Adds the function `getRangeForEdit` to validate that a given source range is editable and, if needed, translate it into a range in the source file (for example, if it's sourced in macro expansions). Reviewers: ilya-biryukov Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64924 llvm-svn: 366469
* Re-land [JSONCompilationDatabase] Strip distcc/ccache/gomacc wrappers from ↵Sam McCall2019-07-121-0/+27
| | | | | | | | parsed commands. Use //net/dir like other test cases for windows compatibility llvm-svn: 365975
* Revert "[JSONCompilationDatabase] Strip distcc/ccache/gomacc wrappers from ↵Russell Gallop2019-07-121-24/+0
| | | | | | | | | | parsed commands." New test is failing on Windows bot This reverts commit 9c0391b36a76f8e3949588de3f44b7314c2318bf. llvm-svn: 365906
* [JSONCompilationDatabase] Strip distcc/ccache/gomacc wrappers from parsed ↵Sam McCall2019-07-121-0/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | commands. Summary: It's common to use compiler wrappers by setting CC="gomacc clang++". This results in both args appearing in compile_commands.json, and clang's driver can't handle this. This patch attempts to recognize this pattern (by looking for well-known wrappers) and dropping argv0 in this case. It conservatively ignores other cases for now: - wrappers with unknown names - wrappers that accept -flags - wrappers where the compiler to use is implied (usually cc or gcc) This is done at the JSONCompilationDatabase level rather than somewhere more fundamental, as (hopefully) this isn't a general conceptual problem, but a messy aspect of the nature of the ecosystem around compile_commands.json. i.e. compilation databases more tightly tied to the build system should not have this problem. Reviewers: phosek, klimek Subscribers: llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D64297 llvm-svn: 365887
* [test] Delete trailing spaces from YAML testsFangrui Song2019-07-124-16/+16
| | | | llvm-svn: 365873
* [Syntax] Move roles into a separate enumIlya Biryukov2019-07-091-4/+4
| | | | | | To align with reviewer's suggestions. llvm-svn: 365479
* Reland r365355: [Syntax] Introduce syntax treesIlya Biryukov2019-07-092-0/+161
| | | | | | With a fix to a PS4 buildbot crash. llvm-svn: 365466
* Revert rL365355 : [Syntax] Introduce syntax treesSimon Pilgrim2019-07-092-161/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: A tooling-focused alternative to the AST. This commit focuses on the memory-management strategy and the structure of the AST. More to follow later: - Operations to mutate the syntax trees and corresponding textual replacements. - Mapping between clang AST nodes and syntax tree nodes. - More node types corresponding to the language constructs. Reviewers: sammccall Reviewed By: sammccall Subscribers: llvm-commits, mgorny, cfe-commits Tags: #clang, #llvm Differential Revision: https://reviews.llvm.org/D61637 ........ Fixes buildbots which were crashing on SyntaxTests.exe llvm-svn: 365465
* [Syntax] Introduce syntax treesIlya Biryukov2019-07-082-0/+161
| | | | | | | | | | | | | | | | | | | | | | | | Summary: A tooling-focused alternative to the AST. This commit focuses on the memory-management strategy and the structure of the AST. More to follow later: - Operations to mutate the syntax trees and corresponding textual replacements. - Mapping between clang AST nodes and syntax tree nodes. - More node types corresponding to the language constructs. Reviewers: sammccall Reviewed By: sammccall Subscribers: llvm-commits, mgorny, cfe-commits Tags: #clang, #llvm Differential Revision: https://reviews.llvm.org/D61637 llvm-svn: 365355
* cmake: Add CLANG_LINK_CLANG_DYLIB optionTom Stellard2019-07-032-4/+11
| | | | | | | | | | | | | | | | Summary: Setting CLANG_LINK_CLANG_DYLIB=ON causes clang tools to link against libclang_shared.so instead of the individual component libraries. Reviewers: mgorny, beanz, smeenai, phosek, sylvestre.ledru Subscribers: arphaman, cfe-commits, llvm-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63503 llvm-svn: 365092
* [clang-tidy] Fix the YAML created for checks like modernize-pass-by-valueIvan Donchevskii2019-07-031-0/+24
| | | | | | | | | | | Currently this check generates the replacement with the newline in the end. The proper way to export it to YAML is to have two \n\n instead of one. Without this fix clients should reinterpret the replacement as "#include <utility> " instead of "#include <utility>\n" Differential Revision: https://reviews.llvm.org/D63482 llvm-svn: 365017
* [LibTooling] Extend `RewriteRule` with support for adding includes.Yitzhak Mandelbaum2019-07-021-0/+36
| | | | | | | | | | | | | | | | | | Summary: This revision allows users to specify the insertion of an included directive (at the top of the file being rewritten) as part of a rewrite rule. These directives are bundled with `RewriteRule` cases, so that different cases can potentially result in different include actions. Reviewers: ilya-biryukov, gribozavr Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63892 llvm-svn: 364917
* [clang][ArgumentAdjusters] Do not add fsyntax-only if already existsKadir Cetinkaya2019-07-021-0/+27
| | | | | | | | | | | | Reviewers: hokein Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64063 llvm-svn: 364904
* [clang][Tooling] Fix windows build-bots after rL364386Kadir Cetinkaya2019-06-261-2/+2
| | | | llvm-svn: 364396
* [clang][Tooling] Infer target and mode from argv[0] when using ↵Kadir Cetinkaya2019-06-261-3/+33
| | | | | | | | | | | | | | | | | | | | | 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
* [Syntax] Do not glue multiple empty PP expansions to a single mappingIlya Biryukov2019-06-241-1/+4
| | | | | | | | | | | | | | | | | | | | | Summary: This change makes sure we have a single mapping for each macro expansion, even if the result of expansion was empty. To achieve that, we take information from PPCallbacks::MacroExpands into account. Previously we relied only on source locations of expanded tokens. Reviewers: sammccall Reviewed By: sammccall Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62953 llvm-svn: 364236
* [clang][test] Add missing LambdaTemplateParams test and migrate from getLocStartJordan Rupprecht2019-06-192-3/+4
| | | | | | These were removed a long time ago in r341573, but this test was missed because it was not in cmake llvm-svn: 363848
* [Syntax] Fix a crash when dumping empty token bufferIlya Biryukov2019-06-191-0/+8
| | | | llvm-svn: 363801
* [Syntax] Add a helper to find expansion by its first spelled tokenIlya Biryukov2019-06-181-0/+78
| | | | | | | | | | | | | | | | Summary: Used in clangd for a code tweak that expands a macro. Reviewers: sammccall Reviewed By: sammccall Subscribers: kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62954 llvm-svn: 363698
* [LibTooling] Add insert/remove convenience functions for creating `ASTEdit`s.Yitzhak Mandelbaum2019-06-061-0/+58
| | | | | | | | | | | | | | Summary: `change()` is an all purpose function; the revision adds simple shortcuts for the specific operations of inserting (before/after) or removing source. Reviewers: ilya-biryukov Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62621 llvm-svn: 362707
* [cmake] Remove duplicate TestingSupport library for linkingPengxuan Zheng2019-06-051-1/+0
| | | | | | | | | | | | Summary: This patch cleans up a duplicate use of TestingSupport library. Subscribers: mgorny, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62924 llvm-svn: 362637
* [Syntax] Do not depend on llvm targets for Syntax tests. NFCIlya Biryukov2019-06-041-1/+0
| | | | | | They are not required and only slow down the build. llvm-svn: 362530
* [LibTooling] Add `before` and `after` selectors for selecting point-ranges ↵Yitzhak Mandelbaum2019-05-291-3/+54
| | | | | | | | | | | | | | | | | | | | relative to nodes. Summary: The `before` and `after` selectors allow users to specify a zero-length range -- a point -- at the relevant location in an AST-node's source. Point ranges can be useful, for example, to insert a change using an API that takes a range to be modified (e.g. `tooling::change()`). Reviewers: ilya-biryukov Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62419 llvm-svn: 361955
* Add missing newline at end of fileDuncan P. N. Exon Smith2019-05-251-1/+1
| | | | llvm-svn: 361708
* Rename clangToolingRefactor to clangToolingRefactoring for consistency with ↵Nico Weber2019-05-251-1/+1
| | | | | | | | | | its directory See "[cfe-dev] The name of clang/lib/Tooling/Refactoring". Differential Revision: https://reviews.llvm.org/D62420 llvm-svn: 361684
* [LibTooling] Add Explanation parameter to `makeRule`.Yitzhak Mandelbaum2019-05-241-2/+1
| | | | | | | | | | | | | | | | | Summary: Conceptually, a single-case RewriteRule has a matcher, edit(s) and an (optional) explanation. `makeRule` previously only took the matcher and edit(s). This change adds (optional) support for the explanation. Reviewers: ilya-biryukov Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62390 llvm-svn: 361643
* Fix unresolved symbols when linking tools/clang/unittests/Tooling/ToolingTestsThomas Lively2019-05-231-0/+1
| | | | | | | | | | | | | | | | | | | Summary: Add correct cmake dependencies so that `ToolingTests` link successfully. Patch by Guanzhong Chen Reviewers: tlively, aheejin Reviewed By: tlively Subscribers: mgorny, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62333 llvm-svn: 361536
* [LibTooling] Update Stencil to use RangeSelectorYitzhak Mandelbaum2019-05-221-22/+23
| | | | | | | | | | | | | | | | | | | Add support for creating a `StencilPart` from any `RangeSelector`, which broadens the scope of `Stencil`. Correspondingly, deprecate Stencil's specialized combinators `node` and `sNode` in favor of using the new `selection` combinator directly (with the appropriate range selector). Reviewers: sbenza Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62160 llvm-svn: 361413
* [LibTooling] Update Transformer to use RangeSelector instead of NodePart enum.Yitzhak Mandelbaum2019-05-221-23/+22
| | | | | | | | | | | | | | | | | Transformer provides an enum to indicate the range of source text to be edited. That support is now redundant with the new (and more general) RangeSelector library, so we remove the custom enum support in favor of supporting any RangeSelector. Reviewers: ilya-biryukov Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62149 llvm-svn: 361392
* Reland r361148 with a fix to the buildbot failure.Ilya Biryukov2019-05-223-0/+677
| | | | | | | Reverted in r361377. Also reland the '.gn' files (reverted in r361389). llvm-svn: 361391
* Revert r361148 "[Syntax] Introduce TokenBuffer, start clangToolingSyntax ↵Russell Gallop2019-05-223-677/+0
| | | | | | | | | | | | library" Also reverted r361264 "[Syntax] Rename TokensTest to SyntaxTests. NFC" which built on it. This is because there were hitting an assert on bots http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast llvm-svn: 361377
* [LibTooling] Address post-commit feedback for r361152Yitzhak Mandelbaum2019-05-211-2/+1
| | | | | | | | | | | | | | Fixes a redundant dependency and moves another to its proper place. Reviewers: thakis Subscribers: mgorny, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62201 llvm-svn: 361285
* [Syntax] Rename TokensTest to SyntaxTests. NFCIlya Biryukov2019-05-211-2/+2
| | | | | | | To be more consistent with conventions used in the codebase. The new name will be a better fit when more bits of the syntax library land. llvm-svn: 361264
* Try to fix build with older gccs after r361152Nico Weber2019-05-211-2/+3
| | | | | | Also merge the cmake change there to the gn build. llvm-svn: 361209
* Renamed `apply` to `select` to avoid ADL conflict with `std::apply`Dmitri Gribenko2019-05-201-37/+37
| | | | | | | | | | | | | | | | Summary: `std::apply` in C++14 and above is defined with two unrestricted arguments, and it wins overload resolution in this case. Reviewers: ilya-biryukov Subscribers: cfe-commits, ymandel Tags: #clang Differential Revision: https://reviews.llvm.org/D62150 llvm-svn: 361170
* [LibTooling] Fix build break in test after r361152.Yitzhak Mandelbaum2019-05-201-1/+2
| | | | | | r361152 broke gcc builds. llvm-svn: 361160
OpenPOWER on IntegriCloud