summaryrefslogtreecommitdiffstats
path: root/clang/unittests
Commit message (Collapse)AuthorAgeFilesLines
* [Syntax] Merge overlapping top-level macros in TokenBufferSam McCall2020-06-101-4/+21
| | | | | | | | | | | | | | | | | | | Summary: Our previous definition of "top-level" was too informal, and didn't allow for overlapping macros that each directly produce expanded tokens. See D77507 for previous discussion. Fixes http://bugs.llvm.org/show_bug.cgi?id=45428 Reviewers: kadircet, vabridgers Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D77615 (cherry picked from commit d66afd6dde542dc373f87e07fe764c071fe20d76)
* [clang-format] [PR45357] Fix issue found with operator spacingmydeveloperday2020-05-071-1/+52
| | | | | | | | | | | | | | | | | | | Summary: This is a tentative fix for https://bugs.llvm.org/show_bug.cgi?id=45357 Spaces seem to be introduced between * and * due to changes brought in for {D69573} Reviewers: sylvestre.ledru, mitchell-stellar, sammccall, Abpostelnicu, krasimir, jbcoe Reviewed By: Abpostelnicu Subscribers: tstellar, hans, Abpostelnicu, cfe-commits Tags: #clang, #clang-format Differential Revision: https://reviews.llvm.org/D78879 (cherry picked from commit b01dca50085768f1f1a5ad21a685906d48c38816)
* clang-format: Fix pointer alignment for overloaded operators (PR45107)Hans Wennborg2020-05-071-0/+7
| | | | | | | | | | | | | | | | | | This fixes a regression from D69573 which broke the following example: $ echo 'operator C<T>*();' | bin/clang-format --style=Chromium operator C<T> *(); (There should be no space before the asterisk.) It seems the problem is in TokenAnnotator::spaceRequiredBetween(), which only looked at the token to the left of the * to see if it was a type or not. That code only handled simple types or identifiers, not templates or qualified types. This patch addresses that. Differential revision: https://reviews.llvm.org/D76850 (cherry picked from commit eb85e90350e93a64279139e7eca9ca40c8fbf5eb)
* clang-format: fix spacing in `operator const char*()`Krasimir Georgiev2020-03-021-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Revision a75f8d98d7ac9e557b238a229a9a2647c71feed1 fixed spacing for operators, but caused the const and non-const versions to diverge: ``` // With Style.PointerAlignment = FormatStyle::PAS_Left: struct A { operator char*() { return ""; } operator const char *() const { return ""; } }; ``` The code was checking if the type specifier was directly preceded by `operator`. However there could be comments and `const/volatile` in between. Reviewers: mprobst Reviewed By: mprobst Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D72911 (cherry picked from commit 33463cfba2be7c8d6c08e666123cc34f114a1f3e)
* [ASTMatchers] HasNameMatcher handles `extern "C"`Nathan James2020-02-271-0/+15
| | | | | | | | | | | | | | | | Summary: Fixes [[ https://bugs.llvm.org/show_bug.cgi?id=42193 | hasName AST matcher is confused by extern "C" in namespace. ]] Reviewers: klimek, aaron.ballman, gribozavr2 Reviewed By: aaron.ballman Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D75202 (cherry picked from commit 16cabf278fc8c14d415e677ce0bc40d46a6de30d)
* [clang-format] Expand the SpacesAroundConditions option to include catch ↵mydeveloperday2020-01-211-0/+1
| | | | | | | | | | | | | | statements Summary: This diff expands the SpacesAroundConditions option added in D68346 to include adding spaces to catch statements. Reviewed By: MyDeveloperDay Patch by: timwoj Differential Revision: https://reviews.llvm.org/D72793 (cherry picked from commit ea2be452542c81b04621e26c0d5e83be565f07e2)
* Removed PointerUnion3 and PointerUnion4 aliases in favor of the variadic ↵Dmitri Gribenko2020-01-141-1/+1
| | | | template
* [Syntax] Unset IsOriginal flag on nodes removed from the treeIlya Biryukov2020-01-141-0/+3
| | | | | | And add a corresponding test. Only nodes inside the TranslationUnit subtree can be marked as original, computeReplacements() relies on this.
* [Syntax] Mark synthesized nodes as modifiableIlya Biryukov2020-01-141-0/+18
| | | | | This was an oversight in the original patch. Also add corresponding tests.
* [clang] Remove raw string literals in macrosOliver Stannard2020-01-132-86/+96
| | | | | Older (but still supported) versions of GCC don't handle C++11 raw string literals in macro parameters correctly.
* Revert "[ASTMatchers] extract public matchers from const-analysis into own ↵Jonas Toth2020-01-111-166/+0
| | | | | | | | patch" This reverts commit 4c48ea68e491cb42f1b5d43ffba89f6a7f0dadc4. The powerpc buildbots had an internal compiler error after this patch. This requires some inspection.
* [ASTMatchers] extract public matchers from const-analysis into own patchJonas Toth2020-01-111-0/+166
| | | | | | | | | | | | | | | | | | | Summary: The analysis for const-ness of local variables required a view generally useful matchers that are extracted into its own patch. They are `decompositionDecl` and `forEachArgumentWithParamType`, that works for calls through function pointers as well. Reviewers: aaron.ballman Reviewed By: aaron.ballman Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D72505
* Implement new AST matcher hasAnyCapture to match on LambdaExpr captures.Reid2020-01-101-0/+20
| | | | Accepts child matchers cxxThisExpr to match on capture of this and also on varDecl.
* [ASTMatchers] Make test more clear about what it is verifyingStephen Kelly2020-01-101-2/+5
|
* [clang] Fix out-of-bounds memory access in ComputeLineNumbersJan Korous2020-01-101-0/+24
| | | | Differential Revision: https://reviews.llvm.org/D72409
* [NFC] format unittest for ExprMutAnalyzerJonas Toth2020-01-101-29/+24
| | | | | | This formatting is a preparation for review in https://reviews.llvm.org/D54943 to separate pure formatting changes from actual testing changes.
* Add a new AST matcher 'optionally'.Rihan Yang2020-01-081-0/+21
| | | | | | | | This matcher matches any node and at the same time executes all its inner matchers to produce any possbile result bindings. This is useful when a user wants certain supplementary information that's not always present along with the main match result.
* [clang-format] fix conflict between FormatStyle::BWACS_MultiLine and ↵Mitchell Balan2020-01-061-1/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | BeforeCatch/BeforeElse Summary: Found a bug introduced with BraceWrappingFlags AfterControlStatement MultiLine. This feature conflicts with the existing BeforeCatch and BeforeElse flags. For example, our team uses BeforeElse. if (foo || bar) { doSomething(); } else { doSomethingElse(); } If we enable MultiLine (which we'd really love to do) we expect it to work like this: if (foo || bar) { doSomething(); } else { doSomethingElse(); } What we actually get is: if (foo || bar) { doSomething(); } else { doSomethingElse(); } Reviewers: MyDeveloperDay, Bouska, mitchell-stellar Patch by: pastey Subscribers: Bouska, cfe-commits Tags: clang Differential Revision: https://reviews.llvm.org/D71939
* Clang-format previous commitStephen Kelly2020-01-051-3/+1
|
* Add missing testStephen Kelly2020-01-051-0/+12
|
* Allow using traverse() with bindingsStephen Kelly2020-01-051-0/+22
|
* [ParserTest] Move raw string literal out of macroDavid Green2020-01-051-3/+3
| | | | | Some combinations of gcc and ccache do not deal well with raw strings in macros. Moving the string out to attempt to fix the bots.
* [clang-format/java] format multiple qualified annotations on one declaration ↵Nico Weber2020-01-031-0/+8
| | | | | | | | | | | | | | | | | | | | | better Before: class Foo { @CommandLineFlags .Add @Features.foo public void test() {} } Now: class Foo { @Features.foo @CommandLineFlags.Add public void test() { } } See also https://crbug.com/1034115
* [Syntax] Build spanning SimpleDecalration for classes, structs, etcIlya Biryukov2020-01-031-18/+63
| | | | | | | When they are free-standing, e.g. `struct X;` or `struct X {};`. Although this complicates the common case (of free-standing class declarations), this ensures the less common case (e.g. `struct X {} a;`) are handled uniformly and produce similar syntax trees.
* Handle init statements in readability-else-after-returnNathan James2020-01-021-0/+29
| | | | | | | | | | Adds a new ASTMatcher condition called 'hasInitStatement()' that matches if, switch and range-for statements with an initializer. Reworked clang-tidy readability-else-after-return to handle variables in the if condition or init statements in c++17 ifs. Also checks if removing the else would affect object lifetimes in the else branch. Fixes PR44364.
* Implement additional traverse() overloadsStephen Kelly2019-12-311-0/+86
| | | | | | | | | | | | | | Summary: These overloads make it possible to wrap unless(), anyOf(), has() etc with the traverse matcher. Reviewers: aaron.ballman Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D71977
* Match code following lambdas when ignoring invisible nodesStephen Kelly2019-12-311-0/+6
| | | | | | | | | | Reviewers: aaron.ballman Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D71976
* Fix crash in getFullyQualifiedName for inline namespaceAlexey Bader2019-12-281-0/+11
| | | | | | | | | | | | | | Summary: The ICE happens when the most outer namespace is an inline namespace. Reviewers: bkramer, ilya-biryukov Reviewed By: ilya-biryukov Subscribers: ebevhan, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D71962
* Allow newlines in AST Matchers in clang-query filesStephen Kelly2019-12-271-23/+142
| | | | | | | | | | Reviewers: aaron.ballman Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D71842
* Revert "Allow newlines in AST Matchers in clang-query files" + 1Evgenii Stepanov2019-12-261-142/+23
| | | | | | | | | Revert "Fix -Wunused-lambda-capture warnings." This reverts commit 2369560f4a7720b19edfbf9de14ef061307ff773. This reverts commit 522ee29a4fb3814db604b585c8637247477ec057. clang/lib/ASTMatchers/Dynamic/Parser.cpp:610:13: warning: implicit conversion turns string literal into bool: 'const char [35]' to 'bool' [-Wstring-conversion] assert(!"Newline should never be found here");
* Allow newlines in AST Matchers in clang-query filesStephen Kelly2019-12-261-23/+142
| | | | | | | | | | Reviewers: aaron.ballman Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D71842
* Revert "Allow newlines in AST Matchers in clang-query files"Stephen Kelly2019-12-261-142/+23
| | | | This reverts commit 6a3ecf4dc7ec299394e71b3124df2b3a34ed4ac3.
* Allow newlines in AST Matchers in clang-query filesStephen Kelly2019-12-261-23/+142
| | | | | | | | | | Reviewers: aaron.ballman Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D71842
* [CFG] Fix an assertion failure with static initializersGabor Horvath2019-12-232-13/+38
| | | | | | | | | | | | | The CFGBlock::getLastCondition was not prepared for static initializer branches. This patch also revamps CFG unit tests. Earlier the lifetime of the AST was smaller than the CFG. So all the AST pointers within the CFG blocks were dangling. This was OK, since none of the tests dereferenced those pointers. This was, however, a timed bomb. There were patches in the past that were reverted partially due to this problem. Differential revision: https://reviews.llvm.org/D71791
* Customize simplified dumping and matching of LambdaExprStephen Kelly2019-12-212-0/+147
| | | | | | | | | | Reviewers: aaron.ballman Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D71680
* Revert "Customize simplified dumping and matching of LambdaExpr"Stephen Kelly2019-12-202-147/+0
| | | | This reverts commit 494b1318ca77927e919bbf9a61749a58553d738c.
* Customize simplified dumping and matching of LambdaExprStephen Kelly2019-12-202-0/+147
| | | | | | | | | | Reviewers: aaron.ballman Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D71680
* [clang-format] C# formatting a class with inheritance followed by an ↵mydeveloperday2019-12-201-0/+21
| | | | | | | | | | | | | | | | | | | attribute specifier assume its a braces initializer Summary: https://bugs.llvm.org/show_bug.cgi?id=44340 The rule that prevents `... {} [[....]]` being treated as a braced initializer for C++ causes problems for C# with attributes, causing it to be incorrectly classified and then messing up the subsequent formatting. (see bug for details of formatting) Reviewers: mitchell-stellar, klimek, sammccall Reviewed By: mitchell-stellar Subscribers: cfe-commits Tags: #clang-format, #clang Differential Revision: https://reviews.llvm.org/D71769
* [clang][Tooling] Prefer -x over -std when interpolatingKadir Cetinkaya2019-12-201-0/+4
| | | | | | | | | | | | | | | | | | | Summary: Currently interpolation logic prefers -std over -x. But the latter is a more strong signal, so this patch inverts the order and only makes use of -std if -x didn't exist. Fixes https://github.com/clangd/clangd/issues/185 Thanks @sammccall for tracking this down! Reviewers: sammccall Subscribers: ilya-biryukov, usaxena95, cfe-commits, sammccall Tags: #clang Differential Revision: https://reviews.llvm.org/D71727
* Add method to ignore invisible AST nodesStephen Kelly2019-12-183-0/+379
| | | | | | | | | | Reviewers: aaron.ballman Subscribers: mgorny, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70613
* Trim trailing whitespaceStephen Kelly2019-12-181-2/+2
|
* Output names in the AST in testsStephen Kelly2019-12-181-3/+13
|
* [Syntax] Use a hash table to search for tokens by their locationIlya Biryukov2019-12-181-0/+40
| | | | | | | | This is both more efficient and avoids corner cases in `SourceManager::isBeforeInTranslationUnit`. The change is trivial and clearly a performance improvement on the hot path of building the syntax tree, so sending without review.
* [Syntax] Uppercase the first letter of the test name. NFCIlya Biryukov2019-12-181-1/+1
| | | | To match naming style of other tests.
* [Syntax] Allow to mutate syntax treesIlya Biryukov2019-12-182-5/+121
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This patch adds facilities to mutate the syntax trees and produce corresponding text replacements. The public interface of the syntax library now includes facilities to: 1. perform type-safe modifications of syntax trees, 2. compute textual replacements to apply the modifications, 3. create syntax trees not backed by the source code. For each of the three, we only add a few example transformations in this patch to illustrate the idea, support for more kinds of nodes and transformations will be done in follow-up patches. The high-level mutation operations are implemented on top of operations that allow to arbitrarily change the trees. They are considered to be implementation details and are not available to the users of the library. Reviewers: sammccall, gribozavr2 Reviewed By: gribozavr2 Subscribers: merge_guards_bot, mgorny, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64573
* recommit: [ASTImporter] Friend class decl should not be visible in its contextGabor Marton2019-12-181-6/+44
| | | | | | | | | | | | | | | | | | | Summary: In the past we had to use DeclContext::makeDeclVisibleInContext to make friend declarations available for subsequent lookup calls and this way we could chain (redecl) the structurally equivalent decls. By doing this we created an AST that improperly made declarations visible in some contexts, so the AST was malformed. Since we use the importer specific lookup this is no longer necessary, because with that we can find every previous nodes. Reviewers: balazske, a_sidorin, a.sidorin, shafik Subscribers: rnkovacs, dkrupp, Szelethus, gamesh411, teemperor, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D71020
* Revert "[ASTImporter] Friend class decl should not be visible in its context"Nico Weber2019-12-171-44/+6
| | | | | This reverts commit 4becf68c6f17fe143539ceac954b21175914e1c1. Breaks building on Windows, see comments on D71020
* [ASTImporter] Friend class decl should not be visible in its contextGabor Marton2019-12-171-6/+44
| | | | | | | | | | | | | | | | | | | Summary: In the past we had to use DeclContext::makeDeclVisibleInContext to make friend declarations available for subsequent lookup calls and this way we could chain (redecl) the structurally equivalent decls. By doing this we created an AST that improperly made declarations visible in some contexts, so the AST was malformed. Since we use the importer specific lookup this is no longer necessary, because with that we can find every previous nodes. Reviewers: balazske, a_sidorin, a.sidorin, shafik Subscribers: rnkovacs, dkrupp, Szelethus, gamesh411, teemperor, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D71020
* [NFC] Fix typos in Clangd and ClangKirill Bobyrev2019-12-161-5/+5
| | | | | | Reviewed by: Jim Differential Revision: https://reviews.llvm.org/D71455
* [ASTImporter] Support functions with placeholder return types ...Gabor Marton2019-12-124-0/+195
| | | | | | | | | | | | | | | Summary: Support functions with placeholder return types even in cases when the type is declared in the body of the function. Example: auto f() { struct X{}; return X(); } Reviewers: balazske, a_sidorin, a.sidorin, shafik Subscribers: rnkovacs, dkrupp, Szelethus, gamesh411, teemperor, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70819
OpenPOWER on IntegriCloud