summaryrefslogtreecommitdiffstats
path: root/clang/unittests/Tooling/RecursiveASTVisitorTests
Commit message (Collapse)AuthorAgeFilesLines
* [Tooling] Move raw string literal out of a macro call. NFCIlya Biryukov2019-12-121-4/+7
| | | | Should fix buildbots with some older gcc versions.
* Reland "[AST] Traverse the class type loc inside the member type loc.""Haojian Wu2019-12-091-0/+55
| | | | | | | | | | | | Summary: added a unittest which causes "TL.getClassTInfo" is null. Reviewers: ilya-biryukov Subscribers: mgorny, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D71186
* Revert "[AST] Traverse the class type loc inside the member type loc."Sterling Augustine2019-12-051-47/+0
| | | | | | | This reverts commit 7f93cb62280a73e3e899d49c45be8bfbac634b7d. The assertion at RecursiveASTVisitor.h:1169 fails when passed a TypeLocNode. Not sure if the correct fix is to use getTypeLocClass or something else.
* [AST] Traverse the class type loc inside the member type loc.Haojian Wu2019-12-051-0/+47
| | | | | | | | | | | | | | | Summary: We are missing this currently. This would fix https://github.com/clangd/clangd/issues/216. Reviewers: ilya-biryukov Subscribers: mgorny, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70849
* [AST] No longer visiting CXXMethodDecl bodies created by compiler when ↵Johan Vikstrom2019-08-091-0/+58
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* [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-051-0/+57
| | | | | | | | | | | | | | 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
* [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
* [clang][test] Add missing LambdaTemplateParams test and migrate from getLocStartJordan Rupprecht2019-06-191-3/+3
| | | | | | These were removed a long time ago in r341573, but this test was missed because it was not in cmake llvm-svn: 363848
* [c++20] Implement P0428R2 - Familiar template syntax for generic lambdasHamza Sood2019-05-041-0/+53
| | | | | | Differential Revision: https://reviews.llvm.org/D36527 llvm-svn: 359967
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-1919-76/+57
| | | | | | | | | | | | | | | | | to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
* [AST] Fix double-traversal of code in top-level lambdas in RAV(implicit = yes).Sam McCall2019-01-141-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | Summary: Prior to r351069, lambda classes were traversed or not depending on the {Function, Class, Namespace, TU} DeclContext containing them. If it was a function (common case) they were not traversed. If it was a namespace or TU (top-level lambda) they were traversed as part of that DeclContext traversal. r351069 "fixed" RAV to traverse these as part of the LambdaExpr, which is the right place. But top-level lambdas are now traversed twice. We fix that as blocks and block captures were apparently fixed in the past. Maybe it would be nicer to avoid adding the lambda classes to the DeclContext in the first place, but I can't work out the implications of that. Reviewers: bkramer, klimek Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D56665 llvm-svn: 351075
* [AST] RecursiveASTVisitor visits lambda classes when implicit visitation is on.Sam McCall2019-01-141-14/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This fixes ASTContext's parent map for nodes in such classes (e.g. operator()). https://bugs.llvm.org/show_bug.cgi?id=39949 This also changes the observed shape of the AST for implicit RAVs. - this includes AST MatchFinder: cxxRecordDecl() now matches lambda classes, functionDecl() matches the call operator, and the parent chain is body -> call operator -> lambda class -> lambdaexpr rather than body -> lambdaexpr. - this appears not to matter for the ASTImporterLookupTable builder - this doesn't matter for the other RAVs in-tree. In order to do this, we remove the TraverseLambdaBody hook. The problem is it's hard/weird to ensure this hook is called when traversing via the implicit class. There were just two users of this hook in-tree, who use it to skip bodies. I replaced these with explicitly traversing the captures only. Another approach would be recording the bodies when the lambda is visited, and then recognizing them later. I'd be open to suggestion on how to preserve this hook, instead. Reviewers: aaron.ballman, JonasToth Subscribers: cfe-commits, rsmith, jdennett Differential Revision: https://reviews.llvm.org/D56444 llvm-svn: 351047
* [AST] Allow limiting the scope of common AST traversals (getParents, RAV).Sam McCall2018-11-141-0/+51
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The goal is to allow analyses such as clang-tidy checks to run on a subset of the AST, e.g. "only on main-file decls" for interactive tools. Today, these become "problematically global" by running RecursiveASTVisitors rooted at the TUDecl, or by navigating up via ASTContext::getParent(). The scope is restricted using a set of top-level-decls that RecursiveASTVisitors should be rooted at. This also applies to the visitor that populates the parent map, and so the top-level-decls are considered to have no parents. This patch makes the traversal scope a mutable property of ASTContext. The more obvious way to do this is to pass the top-level decls to relevant functions directly, but this has some problems: - it's error-prone: accidentally mixing restricted and unrestricted scopes is a performance trap. Interleaving multiple analyses is common (many clang-tidy checks run matchers or RAVs from matcher callbacks) - it doesn't map well to the actual use cases, where we really do want *all* traversals to be restricted. - it involves a lot of plumbing in parts of the code that don't care about traversals. This approach was tried out in D54259 and D54261, I wanted to like it but it feels pretty awful in practice. Caveats: to get scope-limiting behavior of RecursiveASTVisitors, callers have to call the new TraverseAST(Ctx) function instead of TraverseDecl(TU). I think this is an improvement to the API regardless. Reviewers: klimek, ioeric Subscribers: mgorny, cfe-commits Differential Revision: https://reviews.llvm.org/D54309 llvm-svn: 346847
* [Sema] Remove location from implicit capture init exprVedant Kumar2018-09-131-5/+5
| | | | | | | | | | | | | | | | | | A lambda's closure is initialized when the lambda is declared. For implicit captures, the initialization code emitted from EmitLambdaExpr references source locations *within the lambda body* in the function containing the lambda. This results in a poor debugging experience: we step to the line containing the lambda, then into lambda, out again, over and over, until every capture's field is initialized. To improve stepping behavior, assign the starting location of the lambda to expressions which initialize an implicit capture within it. rdar://39807527 Differential Revision: https://reviews.llvm.org/D50927 llvm-svn: 342194
* Port getLocStart -> getBeginLocStephen Kelly2018-08-096-6/+6
| | | | | | | | | | Reviewers: teemperor! Subscribers: jholewinski, whisperity, jfb, cfe-commits Differential Revision: https://reviews.llvm.org/D50350 llvm-svn: 339385
* [UnitTests] NFC/build-perf: Break up nontrivial compile jobsDavid Zarzycki2018-04-1918-0/+935
RecursiveASTVisitorTest.cpp is one of the longest compile jobs and a build bottleneck on many-core machines. This patch breaks that file and some peer files up into smaller files to increase build concurrency and overall rebuild performance. llvm-svn: 330353
OpenPOWER on IntegriCloud