summaryrefslogtreecommitdiffstats
path: root/clang/unittests
Commit message (Collapse)AuthorAgeFilesLines
...
* [CMake] Use PRIVATE in target_link_libraries for executablesShoaib Meenai2017-12-0517-0/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We currently use target_link_libraries without an explicit scope specifier (INTERFACE, PRIVATE or PUBLIC) when linking executables. Dependencies added in this way apply to both the target and its dependencies, i.e. they become part of the executable's link interface and are transitive. Transitive dependencies generally don't make sense for executables, since you wouldn't normally be linking against an executable. This also causes issues for generating install export files when using LLVM_DISTRIBUTION_COMPONENTS. For example, clang has a lot of LLVM library dependencies, which are currently added as interface dependencies. If clang is in the distribution components but the LLVM libraries it depends on aren't (which is a perfectly legitimate use case if the LLVM libraries are being built static and there are therefore no run-time dependencies on them), CMake will complain about the LLVM libraries not being in export set when attempting to generate the install export file for clang. This is reasonable behavior on CMake's part, and the right thing is for LLVM's build system to explicitly use PRIVATE dependencies for executables. Unfortunately, CMake doesn't allow you to mix and match the keyword and non-keyword target_link_libraries signatures for a single target; i.e., if a single call to target_link_libraries for a particular target uses one of the INTERFACE, PRIVATE, or PUBLIC keywords, all other calls must also be updated to use those keywords. This means we must do this change in a single shot. I also fully expect to have missed some instances; I tested by enabling all the projects in the monorepo (except dragonegg), and configuring both with and without shared libraries, on both Darwin and Linux, but I'm planning to rely on the buildbots for other configurations (since it should be pretty easy to fix those). Even after this change, we still have a lot of target_link_libraries calls that don't specify a scope keyword, mostly for shared libraries. I'm thinking about addressing those in a follow-up, but that's a separate change IMO. Differential Revision: https://reviews.llvm.org/D40823 llvm-svn: 319840
* Fix bug where we wouldn't break columns over the limit.Manuel Klimek2017-12-041-0/+9
| | | | | | | | | | | | | | | | Before, we would not break: int a = foo(/* trailing */); when the end of /* trailing */ was exactly the column limit; the reason is that block comments can have an unbreakable tail length - in this case 2, for the trailing ");"; we would unconditionally account that when calculating the column state at the end of the token, but not correctly add it into the remaining column length before, as we do for string literals. The fix is to correctly account the trailing unbreakable sequence length into our formatting decisions for block comments. Line comments cannot have a trailing unbreakable sequence, so no change is needed for them. llvm-svn: 319642
* [ASTImporter] Add unit tests for UsingDecl and UsingShadowDeclAleksei Sidorin2017-12-031-0/+41
| | | | | | | | Patch by Kareem Khazem! Differential Revision: https://reviews.llvm.org/D27181 llvm-svn: 319632
* Better trade-off for excess characters vs. staying within the column limits.Manuel Klimek2017-12-011-6/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When we break a long line like: Column limit: 21 | // foo foo foo foo foo foo foo foo foo foo foo foo The local decision when to allow protruding vs. breaking can lead to this outcome (2 excess characters, 2 breaks): // foo foo foo foo foo // foo foo foo foo foo // foo foo While strictly staying within the column limit leads to this strictly better outcome (fully below the column limit, 2 breaks): // foo foo foo foo // foo foo foo foo // foo foo foo foo To get an optimal solution, we would need to consider all combinations of excess characters vs. breaking for all lines, but that would lead to a significant increase in the search space of the algorithm for little gain. Instead, we blindly try both approches and·select the one that leads to the overall lower penalty. Differential Revision: https://reviews.llvm.org/D40605 llvm-svn: 319541
* clang-format: [JS] do not wrap after async/await.Martin Probst2017-11-301-0/+5
| | | | | | | | | | | | | | Summary: Otherwise automatic semicolon insertion can trigger, i.e. wrapping produces invalid syntax. Reviewers: djasper Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D40642 llvm-svn: 319415
* Add the hasDefinition() AST matcher to match class declarations that also ↵Aaron Ballman2017-11-291-0/+21
| | | | | | | | have a definition. Patch by Julie Hockett. llvm-svn: 319360
* Restructure how we break tokens.Manuel Klimek2017-11-292-36/+115
| | | | | | | | | | | | | | | | | This fixes some bugs in the reflowing logic and splits out the concerns of reflowing from BreakableToken. Things to do after this patch: - Refactor the breakProtrudingToken function possibly into a class, so we can split it up into methods that operate on the common state. - Optimize whitespace compression when reflowing by using the next possible split point instead of the latest possible split point. - Retry different strategies for reflowing (strictly staying below the column limit vs. allowing excess characters if possible). Differential Revision: https://reviews.llvm.org/D40310 llvm-svn: 319314
* [clang-format] Add option to group multiple #include blocks when sorting ↵Krasimir Georgiev2017-11-271-0/+182
| | | | | | | | | | | | | | | | | | | | includes Summary: This patch allows grouping multiple #include blocks together and sort all includes as one big block. Additionally, sorted includes can be regrouped after sorting based on configured categories. Contributed by @KrzysztofKapusta! Reviewers: krasimir Reviewed By: krasimir Subscribers: cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D40288 llvm-svn: 319024
* [ASTImporter] Support importing CXXPseudoDestructorExprAleksei Sidorin2017-11-271-0/+16
| | | | | | | | Patch by Peter Szecsi! Differential Revision: https://reviews.llvm.org/D38843 llvm-svn: 319015
* [ASTImporter] Support TypeTraitExprAleksei Sidorin2017-11-261-0/+41
| | | | | | | | Patch by Takafumi Kubota! Differential Revision: https://reviews.llvm.org/D39722 llvm-svn: 318998
* clang-format: [JS] do not collapse short classes.Martin Probst2017-11-251-4/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: clang-format does not collapse short records, interfaces, unions, etc., but fails to do so if the record is preceded by certain modifiers (export, default, abstract, declare). This change skips over all modifiers, and thus handles all record definitions uniformly. Before: export class Foo { bar: string; } class Baz { bam: string; } After: export class Foo { bar: string; } class Baz { bam: string; } Reviewers: djasper Subscribers: klimek Differential Revision: https://reviews.llvm.org/D40430 llvm-svn: 318976
* clang-format: [JS] handle semis in generic types.Martin Probst2017-11-251-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: TypeScript generic type arguments can contain object (literal) types, which in turn can contain semicolons: const x: Array<{a: number; b: string;} = []; Previously, clang-format would incorrectly categorize the braced list as a block and terminate the line at the openening `{`, and then format the entire expression badly. With this change, clang-format recognizes `<` preceding a `{` as introducing a type expression. In JS, `<` comparison with an object literal can never be true, so the chance of introducing false positives here is very low. Reviewers: djasper Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D40424 llvm-svn: 318975
* clang-format: [JS] handle `for` as object label.Martin Probst2017-11-251-0/+5
| | | | | | | | | | | | Summary: Previously, clang-format would fail formatting `{for: 1}`. Reviewers: djasper Subscribers: klimek Differential Revision: https://reviews.llvm.org/D40441 llvm-svn: 318974
* clang-format: [JS] disable ASI on decorators.Martin Probst2017-11-251-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Automatic Semicolon Insertion in clang-format tries to guess if a line wrap should insert an implicit semicolong. The previous heuristic would not trigger ASI if a token was immediately preceded by an `@` sign: function foo(@Bar // <-- does not trigger due to preceding @ baz) {} However decorators can have arbitrary parameters: function foo(@Bar(param, param, param) // <-- precending @ missed baz) {} While it would be possible to precisely find the matching `@`, just conversatively disabling ASI for the entire line is simpler, while also not regressing ASI substatially. Reviewers: djasper Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D40410 llvm-svn: 318973
* [clang-format] Deduplicate using declarationsKrasimir Georgiev2017-11-241-4/+19
| | | | | | | | | | | | | | Summary: This deduplicated equivalent using declarations within a block. Reviewers: bkramer Reviewed By: bkramer Subscribers: cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D40435 llvm-svn: 318960
* clang-format: [JS] do not break in ArrayType[].Martin Probst2017-11-241-0/+2
| | | | | | | | | | | | | | | | | | | | | | | Summary: Wrapping between the type name and the array type indicator creates invalid syntax in TypeScript. Before: const xIsALongIdent: YJustBarelyFitsLinex []; // illegal syntax. After: const xIsALongIdent: YJustBarelyFitsLinex[]; Reviewers: djasper Subscribers: klimek Differential Revision: https://reviews.llvm.org/D40436 llvm-svn: 318959
* clang-format: [JS] do not wrap before yield.Martin Probst2017-11-241-0/+1
| | | | | | | | | | | | Summary: The same rules apply as for `return`. Reviewers: djasper Subscribers: klimek Differential Revision: https://reviews.llvm.org/D40431 llvm-svn: 318958
* clang-format: [JS] space between ! assert and in.Martin Probst2017-11-241-0/+1
| | | | | | | | | | | | | | | | Summary: Before: x = y!in z; After: x = y! in z; Reviewers: djasper Subscribers: klimek Differential Revision: https://reviews.llvm.org/D40433 llvm-svn: 318957
* clang-format: [JS] handle destructuring `of`.Martin Probst2017-11-241-0/+4
| | | | | | | | | | | | | | | | | | | | | Summary: Previously, clang-format would drop a space character between `of` and then following (non-identifier) token if the preceding token was part of a destructuring assignment (`}` or `]`). Before: for (const [a, b] of[]) {} After: for (const [a, b] of []) {} Reviewers: djasper Subscribers: klimek Differential Revision: https://reviews.llvm.org/D40411 llvm-svn: 318942
* [ASTMatchers] Matchers for new[] operatorsAdam Balogh2017-11-231-0/+10
| | | | | | | | Two new matchers for `CXXNewExpr` are added which may be useful e.g. in `clang-tidy` checkers. One of them is `isArray` which matches `new[]` but not plain `new`. The other one, `hasArraySize` matches `new[]` for a given size. llvm-svn: 318909
* Do not perform the analysis based warning if the warnings are ignoredOlivier Goffart2017-11-231-0/+26
| | | | | | | | | | | | | This saves some cycles when compiling with "-w". (Also fix a potential crash on invalid code for tools that tries to recover from some errors, because analysis might compute the CFG which crashes if the code contains invalid declaration. This does not happen normally with because we also don't perform these analysis if there was an error.) Differential Revision: https://reviews.llvm.org/D40242 llvm-svn: 318900
* [DeclPrinter] Allow printing fully qualified name of function declarationSerge Pavlov2017-11-231-4/+47
| | | | | | | | | | | When requesting a tooltip for a function call in an IDE, the fully qualified name helps to remove ambiguity in the function signature. Patch by Nikolai Kosjar! Differential Revision: https://reviews.llvm.org/D40013 llvm-svn: 318896
* Add an AST matcher for hasDefaultArgument() to match on parameter ↵Aaron Ballman2017-11-211-0/+7
| | | | | | | | declarations that have a default value. Patch by Julie Hockett. llvm-svn: 318794
* Revert r318669/318694Erich Keane2017-11-201-1/+0
| | | | | | Broke some libclang tests, so reverting for now. llvm-svn: 318698
* For Linux/gnu compatibility, preinclude <stdc-predef.h> if the file is availableErich Keane2017-11-201-0/+1
| | | | | | | | | | | | | | | | | | | | | | As reported in llvm bugzilla 32377. Here’s a patch to add preinclude of stdc-predef.h. The gcc documentation says “On GNU/Linux, <stdc-predef.h> is pre-included.” See https://gcc.gnu.org/gcc-4.8/porting_to.html; The preinclude is inhibited with –ffreestanding. Basically I fixed the failing test cases by adding –ffreestanding which inhibits this behavior. I fixed all the failing tests, including some in extra/test, there's a separate patch for that which is linked here Patch By: mibintc Differential Revision: https://reviews.llvm.org/D34158 llvm-svn: 318669
* clang-format: remove trailing lines in lamdas and arrow functions.Martin Probst2017-11-172-3/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: clang-format already removes empty lines at the beginning & end of blocks: int x() { foo(); // lines before and after will be removed. } However because lamdas and arrow functions are parsed as expressions, the existing logic to remove empty lines in UnwrappedLineFormatter doesn't handle them. This change special cases arrow functions in ContinuationIndenter to remove empty lines: x = []() { foo(); // lines before and after will now be removed. }; Reviewers: djasper Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D40178 llvm-svn: 318537
* Fix skipping of flags in getClangStripDependencyFileAdjusterDave Lee2017-11-171-0/+31
| | | | | | | | | | | | | | | | | | Summary: The ArgumentsAdjuster returned from `getClangStripDependencyFileAdjuster` will skip dependency flags, and also their associated values for those flags that take an argument. This change corrects the handling of the `-MD` and `-MMD` flags, which do not take an argument. Reviewers: saugustine, klimek, alexshap Reviewed By: alexshap Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D40024 llvm-svn: 318529
* Implement more accurate penalty & trade-offs while breaking protruding tokens.Manuel Klimek2017-11-172-21/+154
| | | | | | | | For each line that we break in a protruding token, compute whether the penalty of breaking is actually larger than the penalty of the excess characters. Only break if that is the case. llvm-svn: 318515
* [VirtualFileSystem] Support creating directories then adding files insideBen Hamilton2017-11-161-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: In https://reviews.llvm.org/D39572 , I added support for specifying `Type` when invoking `InMemoryFileSystem::addFile()`. However, I didn't account for the fact that when `Type` is `directory_file`, we need to construct an `InMemoryDirectory`, not an `InMemoryFile`, or else clients cannot create files inside that directory. This diff fixes the bug and adds a test. Test Plan: New test added. Ran test with: % make -j12 check-clang-tools Reviewers: bkramer, hokein Reviewed By: bkramer Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D40140 llvm-svn: 318445
* [DeclPrinter] Honor TerseOutput for constructorsAlex Lorenz2017-11-161-16/+44
| | | | | | | | Patch by Nikolai Kosjar! Differential Revision: https://reviews.llvm.org/D39957 llvm-svn: 318365
* [refactor][selection] canonicalize decl ref callee to the call exprAlex Lorenz2017-11-141-0/+26
| | | | | | | We would like to extract the full call when just the callee function is selected llvm-svn: 318215
* [refactor][selection] canonicalize member expr callee to the fullAlex Lorenz2017-11-141-0/+52
| | | | | | | | member call expression We would like to extract the full call when just the callee is selected. llvm-svn: 318205
* Make isDefinition matcher support ObjCMethodDeclDave Lee2017-11-141-0/+8
| | | | | | | | | | | | | | | | | Summary: Allow the `isDefinition()` matcher to apply to `ObjCMethodDecl` nodes, in addition to those it already supports. For whatever reason, `ObjCMethodDecl` does not inherit from `FunctionDecl` and so this is specialization is necessary. Reviewers: aaron.ballman, malcolm.parsons, alexshap Reviewed By: aaron.ballman Subscribers: cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D39948 llvm-svn: 318152
* [ASTImporter] TypeAliasTemplate and PackExpansion importing capabilityGabor Horvath2017-11-141-0/+40
| | | | | | | | Patch by: Zoltan Gera! Differential Revision: https://reviews.llvm.org/D39247 llvm-svn: 318147
* Refactor ContinuationIndenter's breakProtrudingToken logic.Manuel Klimek2017-11-142-3/+15
| | | | | | | | | | | Create more orthogonal pieces. The restructuring made it easy to try out several alternatives to D33589, and while none of the alternatives turned out to be the right solution, the underlying simplification of the structure is helpful. Differential Revision: https://reviews.llvm.org/D39900 llvm-svn: 318141
* Add ObjC exception statement AST matchersDave Lee2017-11-111-0/+23
| | | | | | | | | | | | | | Summary: Add AST matchers for Objective-C @throw, @try, @catch and @finally. Reviewers: aaron.ballman, malcolm.parsons, alexshap, compnerd Reviewed By: aaron.ballman Subscribers: cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D39940 llvm-svn: 317992
* [clang-format] Handle leading comments in using declarationDaniel Jasper2017-11-101-0/+7
| | | | | | | | | | This fixes clang-format internal assertion for the following code: /* override */ using std::string; Patch by Igor Sugak. Thank you. llvm-svn: 317901
* [clang-format] Support python-style comments in text protosKrasimir Georgiev2017-11-101-0/+85
| | | | | | | | | | | | | | Summary: This patch adds support for python-style comments in text protos. Reviewers: djasper Reviewed By: djasper Subscribers: bkramer, cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D39806 llvm-svn: 317886
* [VirtualFileSystem] InMemoryFileSystem::addFile(): Type and PermsBen Hamilton2017-11-091-0/+69
| | | | | | | | | | | | | | | | | | | | | | | Summary: This implements a FIXME in InMemoryFileSystem::addFile(), allowing clients to specify User, Group, Type, and/or Perms when creating a file in an in-memory filesystem. New tests included. Ran tests with: % ninja BasicTests && ./tools/clang/unittests/Basic/BasicTests Fixes PR#35172 (https://bugs.llvm.org/show_bug.cgi?id=35172) Reviewers: bkramer, hokein Reviewed By: bkramer, hokein Subscribers: alexfh Differential Revision: https://reviews.llvm.org/D39572 llvm-svn: 317800
* [clang-format] Sort using declarations by splitting on '::'Krasimir Georgiev2017-11-091-10/+61
| | | | | | | | | | | | | | Summary: This patch improves using declarations sorting. Reviewers: bkramer Reviewed By: bkramer Subscribers: cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D39786 llvm-svn: 317794
* Moved QualTypeNames.h from Tooling to AST.Ilya Biryukov2017-11-081-1/+1
| | | | | | | | | | | | | | | | | Summary: For code reuse in SemaCodeComplete. Note that the tests for QualTypeNames are still in Tooling as they use Tooling's common testing code. Reviewers: rsmith, saugustine, rnk, klimek, bkramer Reviewed By: rnk Subscribers: cfe-commits, mgorny Differential Revision: https://reviews.llvm.org/D39224 llvm-svn: 317676
* [clang-format] Handle unary operator overload with arguments and specifiersDaniel Jasper2017-11-061-0/+1
| | | | | | | | | | | | Before: int operator++(int)noexcept; After: int operator++(int) noexcept; Patch by Igor Sugak. Thank you! llvm-svn: 317473
* [Tooling] Test internal::createExecutorFromCommandLineArgsImpl instead of ↵Eric Liu2017-11-061-8/+8
| | | | | | the wrapper. llvm-svn: 317466
* [Tooling] Fix linking of StandaloneToolExecutorPlugin.Eric Liu2017-11-031-7/+0
| | | | llvm-svn: 317332
* [clang-format] Sort using-declarations case sensitively with a special case ↵Krasimir Georgiev2017-11-031-43/+12
| | | | | | | | | | | | | | | | | | | | for '_' Summary: This makes clang-format sort using declarations case-sensitive with the exception that '_' comes just before 'A'. This is better than the current case insensitive version, because it groups uppercase names in the same namespace together. Reviewers: bkramer Reviewed By: bkramer Subscribers: cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D39549 llvm-svn: 317325
* [refactor][selection] canonicalize selected string literal to objcAlex Lorenz2017-11-021-0/+32
| | | | | | string literal when possible llvm-svn: 317224
* [refactor][selection] code ranges can be selected in objc methodsAlex Lorenz2017-11-011-0/+76
| | | | llvm-svn: 317054
* [refactor] select the entire DeclStmt if one ifs decls is selectedAlex Lorenz2017-10-311-0/+56
| | | | llvm-svn: 316971
* [clang-format] Handle CRLF correctly when formatting escaped newlinesKrasimir Georgiev2017-10-301-4/+30
| | | | | | | | | | Subscribers: klimek Differential Revision: https://reviews.llvm.org/D39420 Contributed by @peterbudai! llvm-svn: 316910
* [clang-format] Format raw string literalsKrasimir Georgiev2017-10-303-0/+748
| | | | | | | | | | | | | | | Summary: This patch adds raw string literal formatting. Reviewers: djasper, klimek Reviewed By: klimek Subscribers: klimek, mgorny Differential Revision: https://reviews.llvm.org/D35943 llvm-svn: 316903
OpenPOWER on IntegriCloud