summaryrefslogtreecommitdiffstats
path: root/clang/unittests/ASTMatchers
Commit message (Collapse)AuthorAgeFilesLines
...
* Add objcCategoryImplDecl matcherDave Lee2017-10-261-1/+7
| | | | | | | | | | | | | | | | | Summary: Add `objcCategoryImplDecl` which matches ObjC category definitions (`@implementation`). This matcher complements `objcCategoryDecl` (`@interface`) which was added in D30854. Reviewers: aaron.ballman, malcolm.parsons, alexshap Reviewed By: aaron.ballman Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D39293 llvm-svn: 316670
* Add objcImplementationDecl matcherDave Lee2017-09-101-0/+3
| | | | | | | | | | | | | | | | | | | | | Summary: Add the `objcImplementationDecl` matcher. See related: D30854 Tested with: ``` ./tools/clang/unittests/ASTMatchers/ASTMatchersTests ``` Reviewers: aaron.ballman, compnerd, alexshap Reviewed By: aaron.ballman Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D37643 llvm-svn: 312889
* PR19668, PR23034: Fix handling of move constructors and deleted copyRichard Smith2017-08-161-20/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | constructors when deciding whether classes should be passed indirectly. This fixes ABI differences between Clang and GCC: * Previously, Clang ignored the move constructor when making this determination. It now takes the move constructor into account, per https://github.com/itanium-cxx-abi/cxx-abi/pull/17 (this change may seem recent, but the ABI change was agreed on the Itanium C++ ABI list a long time ago). * Previously, Clang's behavior when the copy constructor was deleted was unstable -- depending on whether the lazy declaration of the copy constructor had been triggered, you might get different behavior. We now eagerly declare the copy constructor whenever its deletedness is unclear, and ignore deleted copy/move constructors when looking for a trivial such constructor. This also fixes an ABI difference between Clang and MSVC: * If the copy constructor would be implicitly deleted (but has not been lazily declared yet), for instance because the class has an rvalue reference member, we would pass it directly. We now pass such a class indirectly, matching MSVC. Based on a patch by Vassil Vassilev, which was based on a patch by Bernd Schmidt, which was based on a patch by Reid Kleckner! This is a re-commit of r310401, which was reverted in r310464 due to ARM failures (which should now be fixed). llvm-svn: 310983
* Revert "PR19668, PR23034: Fix handling of move constructors and deleted copy ↵Diana Picus2017-08-091-29/+20
| | | | | | | | | constructors when deciding whether classes should be passed indirectly." This reverts commit r310401 because it seems to have broken some ARM bot(s). llvm-svn: 310464
* PR19668, PR23034: Fix handling of move constructors and deleted copyRichard Smith2017-08-081-20/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | constructors when deciding whether classes should be passed indirectly. This fixes ABI differences between Clang and GCC: * Previously, Clang ignored the move constructor when making this determination. It now takes the move constructor into account, per https://github.com/itanium-cxx-abi/cxx-abi/pull/17 (this change may seem recent, but the ABI change was agreed on the Itanium C++ ABI list a long time ago). * Previously, Clang's behavior when the copy constructor was deleted was unstable -- depending on whether the lazy declaration of the copy constructor had been triggered, you might get different behavior. We now eagerly declare the copy constructor whenever its deletedness is unclear, and ignore deleted copy/move constructors when looking for a trivial such constructor. This also fixes an ABI difference between Clang and MSVC: * If the copy constructor would be implicitly deleted (but has not been lazily declared yet), for instance because the class has an rvalue reference member, we would pass it directly. We now pass such a class indirectly, matching MSVC. llvm-svn: 310401
* [ASTMatcher] Add handling for DeducedType to HasDeclarationMatcherFlorian Gross2017-08-041-0/+4
| | | | | | | | | | | | | | | | | HasDeclarationMatcher did not handle DeducedType, it always returned false for deduced types. So with code like this: struct X{}; auto x = X{}; This did no longer match: varDecl(hasType(recordDecl(hasName("X")))) Because HasDeclarationMatcher didn't resolve the DeducedType of x. Differential Revision: https://reviews.llvm.org/D36308 llvm-svn: 310095
* Unify and simplify the behavior of the hasDeclaration matcher.Manuel Klimek2017-08-021-2/+33
| | | | | | | | | | | | | | | | | | | | | | | | | Originally, we weren't able to match on Type nodes themselves (only QualType), so the hasDeclaration matcher was initially written to give what we thought are reasonable results for QualType matches. When we chagned the matchers to allow matching on Type nodes, it turned out that the hasDeclaration matcher was by chance written templated enough to now allow hasDeclaration to also match on (some) Type nodes. This patch change the hasDeclaration matcher to: a) work the same on Type and QualType nodes, b) be completely explicit about what nodes we can match instead of just allowing anything with a getDecl() to match, c) explicitly control desugaring only one level in very specific instances. d) adds hasSpecializedTemplate and tagType matchers to allow migrating existing use cases that now need more explicit matchers Note: This patch breaks clang-tools-extra. The corresponding patch there is approved and will land in a subsequent patch. Differential Revision: https://reviews.llvm.org/D27104 llvm-svn: 309809
* [ASTMatchers] Allow forField to match indirect fields.Malcolm Parsons2017-08-011-2/+6
| | | | | | | | This is needed for PR32966. Reviewed by alexfh. llvm-svn: 309667
* Use EXPECT_TRUE rather than EXPECT_EQ(true, ...) to clean up the code and ↵Eric Christopher2017-07-141-2/+2
| | | | | | silence a null conversion warning. llvm-svn: 307989
* [ASTMatchers][NFC] integerLiteral(): Mention negative integers inClement Courbet2017-07-111-0/+6
| | | | | | | | | | | | | | documentation. Trying to match integerLiteral(-1) will silently fail, because an numeric literal is always positive. - Update the documentation to explain how to match negative numeric literals. - Add a unit test. Differential Revision: https://reviews.llvm.org/D35196 llvm-svn: 307663
* Added braces to work around gcc warning in googletest: suggest explicit ↵Galina Kistanova2017-06-151-3/+6
| | | | | | braces to avoid ambiguous 'else'. NFC. llvm-svn: 305507
* [ASTMatchers] temporary disable tests with floating suffixPeter Wu2017-06-081-0/+3
| | | | | | | | r305022 assumed that floatLiteral(equals(1.2)) would also match 1.2f and 1.2l, but apparently that is not the case. Until it is clear how to match, temporary disable the test to fix CI. llvm-svn: 305025
* [ASTMatchers] Add clang-query support for equals matcherPeter Wu2017-06-081-0/+40
| | | | | | | | | | | | | Summary: This allows the clang-query tool to use matchers like "integerLiteral(equals(32))". For this to work, an overloaded function is added for each possible parameter type. Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D33094 llvm-svn: 305022
* [ASTMatchers] Add support for floatLiteralsPeter Wu2017-06-082-2/+30
| | | | | | | | | | | | | Summary: Needed to support something like "floatLiteral(equals(1.0))". The parser for floating point numbers is kept simple, so instead of ".1" you have to use "0.1". Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D33135 llvm-svn: 305021
* [ASTMatchers] Add support for boolean literalsPeter Wu2017-06-082-0/+21
| | | | | | | | | | | | | Summary: Recognize boolean literals for future extensions ("equals(true)"). Note that a specific VariantValue constructor is added to resolve ambiguity (like "Value = 5") between unsigned and bool. Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D33093 llvm-svn: 305020
* Add cxxStdInitializerListExpr AST matcherJakub Kuderski2017-05-051-0/+23
| | | | | | | | | | | | | | | | | Summary: This adds a new ASTMatcher for CXXStdInitializerListExprs that matches C++ initializer list expressions. The primary motivation is to use it to fix [[ https://bugs.llvm.org/show_bug.cgi?id=32896 | PR32896 ]] (review here [[ https://reviews.llvm.org/D32767 | D32767 ]]). Reviewers: alexfh, Prazek, aaron.ballman Reviewed By: alexfh, aaron.ballman Subscribers: malcolm.parsons, cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D32810 llvm-svn: 302287
* [ASTMatchers] add typeAliasTemplateDecl matcher.Eric Liu2017-03-281-0/+16
| | | | | | | | | | | | Reviewers: hokein, aaron.ballman Reviewed By: aaron.ballman Subscribers: aaron.ballman, cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D28671 llvm-svn: 298912
* Add AST matchers for ObjCProtocolDecl, ObjCCategoryDecl, ObjCMethodDecl, ↵Aaron Ballman2017-03-152-13/+65
| | | | | | | | ObjCIvarDecl, and ObjCPropertyDecl. Patch by Dave Lee. llvm-svn: 297882
* [gtest] The way EXPECT_TEST now works after upgrading gtest triggers anChandler Carruth2017-01-041-3/+6
| | | | | | | | ODR use. These traits don't have a definition as they're intended to be used strictly at compile time. Change the tests to use static_assert to move the entire thing into compile-time. llvm-svn: 291036
* DR1315: a non-type template argument in a partial specialization is permittedRichard Smith2016-12-281-2/+2
| | | | | | | | | | to make reference to template parameters. This is only a partial implementation; we retain the restriction that the argument must not be type-dependent, since it's unclear how that would work given the existence of other language rules requiring an exact type match in this context, even for type-dependent cases (a question has been raised on the core reflector). llvm-svn: 290647
* [ASTMatchers] Add hasInClassInitializer traversal matcher for FieldDecl.Malcolm Parsons2016-12-241-0/+10
| | | | | | | | | | | | | | | Summary: I needed to know whether a FieldDecl had an in-class initializer for D26453. I used a narrowing matcher there, but a traversal matcher might be generally useful. Reviewers: sbenza, bkramer, klimek, aaron.ballman Subscribers: aaron.ballman, Prazek, cfe-commits Differential Revision: https://reviews.llvm.org/D28034 llvm-svn: 290492
* [ASTMatcher] Add hasReplacementType matcher for SubstTemplateTypeParmTypeMalcolm Parsons2016-12-081-0/+17
| | | | | | | | | | | | Summary: Needed for https://reviews.llvm.org/D27166 Reviewers: sbenza, bkramer, klimek Subscribers: aemerson, cfe-commits Differential Revision: https://reviews.llvm.org/D27447 llvm-svn: 289042
* DR616, and part of P0135R1: member access (or pointer-to-member access) on aRichard Smith2016-12-031-1/+1
| | | | | | | temporary produces an xvalue, not a prvalue. Support this by materializing the temporary prior to performing the member access. llvm-svn: 288563
* Adds hasUnqualifiedDesugaredType to allow matching through type sugar.Manuel Klimek2016-12-011-0/+9
| | | | | | Differential Revision: https://reviews.llvm.org/D27207 llvm-svn: 288366
* [ASTMatcher] Add CXXNewExpr support to hasDeclarationMalcolm Parsons2016-10-311-0/+6
| | | | | | | | | | Reviewers: sbenza, lukasza, aaron.ballman, klimek Subscribers: lukasza, sbenza, cfe-commits Differential Revision: https://reviews.llvm.org/D26032 llvm-svn: 285644
* [ASTMatcher] Clarify isStaticStorageClass and hasStaticStorageDuration ↵Haojian Wu2016-09-271-1/+4
| | | | | | | | | | | | documents. Reviewers: aaron.ballman Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D24928 llvm-svn: 282474
* Complete support for the cxxCtorInitializer() AST matcher so that it can be ↵Aaron Ballman2016-09-261-0/+5
| | | | | | used as a top-level matcher. llvm-svn: 282417
* [ASTMatcher] Add isStaticStorageClass matcher for varDecl and functionDecl.Haojian Wu2016-09-261-0/+8
| | | | | | | | | | Reviewers: klimek Subscribers: cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D24821 llvm-svn: 282415
* Traversing template paramter lists of DeclaratorDecls and/or TagDecls.Nico Weber2016-09-131-0/+83
| | | | | | | | | | | | | | The unit tests in this patch demonstrate the need to traverse template parameter lists of DeclaratorDecls (e.g. VarDecls, CXXMethodDecls) and TagDecls (e.g. EnumDecls, RecordDecls). Fixes PR29042. https://reviews.llvm.org/D24268 Patch from Lukasz Łukasz Anforowicz <lukasza@chromium.org>! llvm-svn: 281345
* Add an AST matcher for external formal linkage.Aaron Ballman2016-08-171-0/+16
| | | | | | Patch by Visoiu Mistrih llvm-svn: 278926
* [ASTMatchers] Add matchers canReferToDecl() and hasUnderlyingDecl()Martin Bohme2016-08-091-0/+34
| | | | | | | | | | | | Summary: Required for D22220 Reviewers: sbenza, klimek, aaron.ballman, alexfh Subscribers: alexfh, klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D23004 llvm-svn: 278123
* Make isExternC work on VarDecls too.Benjamin Kramer2016-08-041-0/+6
| | | | llvm-svn: 277712
* [CUDA] Do not allow using NVPTX target for host compilation.Artem Belevich2016-08-021-1/+1
| | | | | | Differential Revision: https://reviews.llvm.org/D23042 llvm-svn: 277537
* [ASTMatcher] Add templateName matcher.Haojian Wu2016-07-291-0/+8
| | | | | | | | | | Reviewers: klimek Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D22963 llvm-svn: 277155
* [ASTMatcher] Add hasTemplateArgument/hasAnyTemplateArgument support in ↵Haojian Wu2016-07-291-0/+13
| | | | | | | | | | | | functionDecl. Reviewers: klimek Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D22957 llvm-svn: 277142
* [NFC] Header cleanupMehdi Amini2016-07-181-1/+0
| | | | | | | | | | Summary: Removed unused headers, replaced some headers with forward class declarations Patch by: Eugene <claprix@yandex.ru> Differential Revision: https://reviews.llvm.org/D20100 llvm-svn: 275882
* [ASTMatchers] isSignedInteger() and isUnsignedInteger()Clement Courbet2016-07-121-0/+12
| | | | | | | | Complementary to isInteger(), these match signed and unsigned integers respectively. Review: http://reviews.llvm.org/D21989 llvm-svn: 275157
* Add AST matchers for handling bit-fields and narrowing based on their width.Aaron Ballman2016-07-061-0/+8
| | | | llvm-svn: 274652
* [ASTMatchers] New forEachOverriden matcher.Clement Courbet2016-07-051-0/+44
| | | | | | Matches methods overridden by the given method. llvm-svn: 274531
* Fix ASTMatchersNodeTest to work on Windows.Justin Lebar2016-06-301-7/+5
| | | | | | | | | | | It was failing because it had an explicit check for whether we're on Windows. There are a few other similar explicit checks in this file which I didn't remove because they serve as reasonable documentation that the test doesn't work with a Windows triple. llvm-svn: 274269
* Don't instantiate a full host toolchain in ASTMatchersTest.Justin Lebar2016-06-301-15/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This test was stat()'ing large swaths of /usr/lib hundreds of times, as every invocation of matchesConditionally*() created a new Linux toolchain. In addition to being slow, perf indicated this was causing substantial contention in the kernel. Something is...interesting in the kernel, as without this patch I sometimes see ~11m spent in the kernel, and sometimes ~5m. This corresponds to bimodal ninja check-clang times of ~30s and ~20s. It's not clear to me exactly what causes the bimodality. In any case, this change makes this test run in 2.5s, down from 17s, and it seems to cause us to get the 20s ninja check-clang time unconditionally. Reviewers: chandlerc Subscribers: cfe-commits, klimek Differential Revision: http://reviews.llvm.org/D21810 llvm-svn: 274257
* [ASTMatcher] Add a node matcher for EnumType.Haojian Wu2016-06-301-0/+7
| | | | | | | | | | Reviewers: aaron.ballman Subscribers: cfe-commits, klimek Differential Revision: http://reviews.llvm.org/D21860 llvm-svn: 274217
* [ASTMatchers] Add isLambda() matcher.Samuel Benzaquen2016-06-281-0/+6
| | | | llvm-svn: 274015
* IgnoringImplicit matcher.Cong Liu2016-06-241-0/+10
| | | | llvm-svn: 273659
* Re-commit "[Temporary] Add an ExprWithCleanups for each C++ ↵Tim Shen2016-06-211-2/+2
| | | | | | | | | | MaterializeTemporaryExpr." Since D21243 fixes relative clang-tidy tests. This reverts commit a71d9fbd41e99def9159af2b01ef6509394eaeed. llvm-svn: 273312
* Revert "[ASTMatchers] New forEachOverriden matcher."Chandler Carruth2016-06-111-44/+0
| | | | | | | This reverts commit r272386. It doesn't compile with MSVC and those bots have been red the entire day as a consequence. llvm-svn: 272453
* [ASTMatchers] New forEachOverriden matcher.Clement Courbet2016-06-101-0/+44
| | | | | | Matches methods overridden by the given method. llvm-svn: 272386
* Revert "[Temporary] Add an ExprWithCleanups for each C++ ↵Tim Shen2016-06-091-2/+2
| | | | | | | | | MaterializeTemporaryExpr." This reverts r272296, since there are clang-tidy failures that appear to be caused by this change. llvm-svn: 272310
* [Temporary] Add an ExprWithCleanups for each C++ MaterializeTemporaryExpr.Tim Shen2016-06-091-2/+2
| | | | | | | | | | | These ExprWithCleanups are added for holding a RunCleanupsScope not for destructor calls; rather, they are for lifetime marks. This requires ExprWithCleanups to keep a bit to indicate whether it have cleanups with side effects (e.g. dtor calls). Differential Revision: http://reviews.llvm.org/D20498 llvm-svn: 272296
* Prune away some unused using decls. NFC.Benjamin Kramer2016-06-081-3/+0
| | | | | | Found by clang's misc-unused-using-decls. llvm-svn: 272156
OpenPOWER on IntegriCloud