Commit Graph

5597 Commits

Author SHA1 Message Date
Nathan Ridge cbcd07a481 [clangd] Add C++20 concepts support to TargetFinder
Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D73140
2020-01-23 15:12:21 -05:00
Nathan Ridge c6c5dbc824 [clangd] Add C++20 concepts support to findExplicitReferences() and semantic highlighting
Summary: Fixes https://github.com/clangd/clangd/issues/259

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D73124
2020-01-23 15:11:46 -05:00
Alexander Lanin 84c5f19637 Extend misc-misplaced-const to detect using declarations as well as typedef 2020-01-22 15:26:11 -05:00
Aaron Ballman e3b15ed376 Revert "Extend misc-misplaced-const to detect using declarations as well as typedef"
This reverts commit ecc7dae50c due to breaking bots:

http://lab.llvm.org:8011/builders/clang-x86_64-debian-fast/builds/22157
http://lab.llvm.org:8011/builders/clang-ppc64be-linux/builds/43297
2020-01-22 09:06:24 -05:00
Alexander Lanin ecc7dae50c Extend misc-misplaced-const to detect using declarations as well as typedef 2020-01-22 08:45:20 -05:00
Simon Pilgrim 201c646b2b Remove extra ';' to fix Wpedantic. NFCI. 2020-01-22 12:08:57 +00:00
Kadir Cetinkaya 9570f1e5a6
[clangd] Do not duplicate TemplatedDecls in findExplicitReferences
Reviewers: hokein

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D73101
2020-01-22 11:43:53 +01:00
Haojian Wu 5d4e899757 [clangd] Handle the missing injectedClassNameType in targetDecl.
Reviewers: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D73102
2020-01-22 10:13:39 +01:00
Saar Raz 5fdad8e3f8 [clang-tidy] Fix check for generic lambda invented template parameters
clang-tidy previously relied on there being no identifier for a TemplateTypeParmDecl for checking
whether 'decltype(x)' should be inserted, instead of checking whether or not it is implicit.

D65042 added new names for invented generic lambda template parameters, rendering that check incorrect.
2020-01-22 02:46:39 +02:00
Eric Fiselier 020ed6713d [clang-tidy] Fix check for Abseil internal namespace access
This change makes following modifications:
  * If reference originated from macro expansion, we report location inside of
    the macro instead of location where macro is referenced.
  * If for any reason deduced location is not correct we silently ignore it.

Patch by Gennadiy Rozental (rogeeff@google.com)
Reviewed as https://reviews.llvm.org/D72484
2020-01-21 15:21:53 -05:00
Kadir Cetinkaya 1fbb1d6df0
[clangd] Drop returntype/type when hovering over type-ish names
Summary:
Some names, e.g. constructor/destructor/conversions, already contain
the type info, no need to duplicate them in the hoverinfo.

Fixes https://github.com/clangd/clangd/issues/252

Reviewers: sammccall, ilya-biryukov

Subscribers: MaskRay, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D73110
2020-01-21 17:10:09 +01:00
Haojian Wu f651c402a2 [clangd] Capture the missing injected class names in findExplicitReferences.
Summary: Fixes https://github.com/clangd/clangd/issues/237.

Reviewers: kadircet, kbobyrev

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D73088
2020-01-21 15:09:23 +01:00
Adam Balogh fccd0da5ee [clang-tidy] New check: bugprone-misplaced-pointer-arithmetic-in-alloc
Finds cases where an integer expression is added to the result
of a memory allocation function instead of its argument.

Differential Revision: https://reviews.llvm.org/D71001
2020-01-21 14:38:15 +01:00
Kirill Bobyrev 38bdb94120
[clangd] Fix rename for explicit destructor calls
When triggering rename of the class name in the code with explicit destructor
calls, rename fails. Consider the following piece of code:

```
class Foo;

...

Foo f;
f.~/*...*/Foo();
```

`findExplicitReferences` will report two `ReferenceLoc` for destructor call:
one is comming from `MemberExpr` (i.e. destructor call itself) and would point
to the tilde:

```
f.~/*...*/Foo();
  ^
```

And the second one is pointing to the typename and is coming from `TypeLoc`.

```
f.~/*...*/Foo();
          ^
```

This causes rename to produce incorrect textual replacements. This patch
updates `MemberExpr` handler to detect destructor calls and prevents it
from reporting a duplicate reference.

Resolves: https://github.com/clangd/clangd/issues/236

Reviewers: kadircet, hokein

Differential Revision: https://reviews.llvm.org/D72638
2020-01-21 05:33:39 +01:00
Kadir Cetinkaya fb3d9153c0
[clangd] Fix DocumentOutline for concepts
Summary: Fixes https://github.com/clangd/clangd/issues/256

Reviewers: kbobyrev

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D73056
2020-01-20 20:20:27 +01:00
Nathan a42c3eb599 [clang-tidy] Add check for CERT-OOP57-CPP
Summary:
This is a very basic warning implementation of [[ https://wiki.sei.cmu.edu/confluence/display/cplusplus/OOP57-CPP.+Prefer+special+member+functions+and+overloaded+operators+to+C+Standard+Library+functions | Prefer special member functions and overloaded operators to C Standard Library functions ]]

It absolutely needs some fine tuning though.

Reviewers: alexfh, hokein, aaron.ballman, JonasToth

Reviewed By: aaron.ballman

Subscribers: merge_guards_bot, Eugene.Zelenko, mgorny, xazax.hun, cfe-commits

Tags: #clang, #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D72488
2020-01-20 17:09:03 +00:00
Haojian Wu 3de9a5db62 [clangd] Avoid redundant testcases in rename unittest, NFC.
Reviewers: kadircet

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D73035
2020-01-20 17:01:05 +01:00
Kadir Cetinkaya 1f946ee2fa
[clang][CodeComplete] Propogate printing policy to FunctionDecl
Summary:
Printing policy was not propogated to functiondecls when creating a
completion string which resulted in canonical template parameters like
`foo<type-parameter-0-0>`. This patch propogates printing policy to those as
well.

Fixes https://github.com/clangd/clangd/issues/76

Reviewers: ilya-biryukov

Subscribers: jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D72715
2020-01-20 12:20:20 +01:00
Haojian Wu 61b5634080 [clangd] Remove a stale FIXME, NFC. 2020-01-20 12:07:30 +01:00
Aaron Ballman 7f4e744b90 Another speculative fix for the Windows bots.
Hopefully fixes: http://45.33.8.238/win/6040/step_4.txt
2020-01-17 10:23:45 -05:00
Aaron Ballman bcda877b43 Fix a compile error to get bots back to green.
Fixes http://lab.llvm.org:8011/builders/clang-x64-windows-msvc/builds/13716
2020-01-17 09:56:04 -05:00
Nathan f9c46229e4 [clang-tidy] Disable Checks on If constexpr statements in template Instantiations for BugproneBranchClone and ReadabilityBracesAroundStatements
Summary: fixes [[ https://bugs.llvm.org/show_bug.cgi?id=32203 | readability-braces-around-statements broken for if constexpr]] and [[ https://bugs.llvm.org/show_bug.cgi?id=44229 | bugprone-branch-clone false positive with template functions and constexpr ]] by disabling the relevant checks on if constexpr statements while inside an instantiated template. This is due to how the else branch of an if constexpr statement is folded away to a null statement if the condition evaluates to false

Reviewers: alexfh, hokein, aaron.ballman, xazax.hun

Reviewed By: aaron.ballman, xazax.hun

Subscribers: rnkovacs, JonasToth, Jim, lebedev.ri, xazax.hun, cfe-commits

Tags: #clang-tools-extra, #clang

Differential Revision: https://reviews.llvm.org/D71980
2020-01-17 14:21:38 +00:00
Logan Smith 42a0355816 Add `bugprone-reserved-identifier`
This patch adds bugprone-reserved-identifier, which flags uses of __names _Like
::_this, which are reserved for the implementation. The check can optionally be
inverted, i.e. configured to flag any names that are _not_ reserved, which may
be useful for e.g. standard library implementors.
2020-01-17 08:44:21 -05:00
Simon Pilgrim 25afe91fd1 Fix Wparentheses warning. NFCI. 2020-01-17 11:26:25 +00:00
Kadir Cetinkaya 4df94d5b51
Revert "[clangd][test] Disable a particular testcase in FindExplicitReferencesTest when LLVM_ENABLE_EXPENSIVE_CHECKS"
This reverts commit 42b3c38903.

Should've been fixed by d54d71b67e
2020-01-17 08:51:13 +01:00
Jan Korous 42b3c38903 [clangd][test] Disable a particular testcase in FindExplicitReferencesTest when LLVM_ENABLE_EXPENSIVE_CHECKS
The test is failing on our CI bots.
Seems like the order of results for one target is undefined.

(post-commit review)
Differential Revision: https://reviews.llvm.org/D72883
2020-01-16 15:07:08 -08:00
Logan Smith d5c6b8407c Factor out renaming logic from readability-identifier-naming
Before this patch, readability-identifier-naming contained a significant amount
of logic for (a) checking the style of identifiers, followed by (b) renaming/
applying fix-its. This patch factors out (b) into a separate base class so that
it can be reused by other checks that want to do renaming. This also cleans up
readability-identifier-naming significantly, since now it only needs to be
concerned with the interesting details of (a).
2020-01-16 16:34:56 -05:00
Michael Liao 40514a7d7a [clangd] Add workaround for GCC5 host compilers. NFC. 2020-01-16 16:05:22 -05:00
Kadir Cetinkaya 0474fe465d
[clangd] Print underlying type for decltypes in hover
Summary: Fixes https://github.com/clangd/clangd/issues/249

Reviewers: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D72498
2020-01-16 19:56:54 +01:00
Kadir Cetinkaya a881fcafaa
[clangd] Make define outline code action visible
Summary: This got forgotten during the process.

Reviewers: sammccall, usaxena95

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D72840
2020-01-16 19:55:02 +01:00
Dmitri Gribenko cbaa32650a Removed an unused include from TypeLocVisitor.h 2020-01-16 15:57:44 +01:00
Kadir Cetinkaya d54d71b67e
[clangd] Make output order of allTargetDecls deterministic
Summary:
Makes use of insertion order to stabilize output for multiple decls.

Fixes https://bugs.llvm.org/show_bug.cgi?id=44564

Reviewers: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, mgrang, arphaman, usaxena95, cfe-commits, aemerson

Tags: #clang

Differential Revision: https://reviews.llvm.org/D72826
2020-01-16 14:47:28 +01:00
Kadir Cetinkaya b08e8353a8
[clangd] Dont display `<unknown>` kinds in hover board
Summary:
Currently when hovering over an `auto` or `decltype` that resolve to a
builtin-type, clangd would display `<unknown>` as the kind of the symbol.

Drop that to make rendering nicer.

Reviewers: usaxena95

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D72777
2020-01-16 11:47:00 +01:00
Yuanfang Chen 6e24c6037f Revert "[Support] make report_fatal_error `abort` instead of `exit`"
This reverts commit 647c3f4e47.

Got bots failure from sanitizer-windows and maybe others.
2020-01-15 17:52:25 -08:00
Yuanfang Chen 647c3f4e47 [Support] make report_fatal_error `abort` instead of `exit`
Summary:
This patch could be treated as a rebase of D33960. It also fixes PR35547.
A fix for `llvm/test/Other/close-stderr.ll` is proposed in D68164. Seems
the consensus is that the test is passing by chance and I'm not
sure how important it is for us. So it is removed like in D33960 for now.
The rest of the test fixes are just adding `--crash` flag to `not` tool.

** The reason it fixes PR35547 is

`exit` does cleanup including calling class destructor whereas `abort`
does not do any cleanup. In multithreading environment such as ThinLTO or JIT,
threads may share states which mostly are ManagedStatic<>. If faulting thread
tearing down a class when another thread is using it, there are chances of
memory corruption. This is bad 1. It will stop error reporting like pretty
stack printer; 2. The memory corruption is distracting and nondeterministic in
terms of error message, and corruption type (depending one the timing, it
could be double free, heap free after use, etc.).

Reviewers: rnk, chandlerc, zturner, sepavloff, MaskRay, espindola

Reviewed By: rnk, MaskRay

Subscribers: wuzish, jholewinski, qcolombet, dschuff, jyknight, emaste, sdardis, nemanjai, jvesely, nhaehnle, sbc100, arichardson, jgravelle-google, aheejin, kbarton, fedor.sergeev, asb, rbar, johnrusso, simoncook, apazos, sabuasal, niosHD, jrtc27, zzheng, edward-jones, atanasyan, rogfer01, MartinMosbeck, brucehoult, the_o, PkmX, jocewei, jsji, lenary, s.egerton, pzheng, cfe-commits, MaskRay, filcab, davide, MatzeB, mehdi_amini, hiraditya, steven_wu, dexonsmith, rupprecht, seiya, llvm-commits

Tags: #llvm, #clang

Differential Revision: https://reviews.llvm.org/D67847
2020-01-15 17:05:13 -08:00
Kadir Cetinkaya 041650da67
[clangd] Extract string literals in macro arguments to unbreak gcc buildbots 2020-01-15 17:59:10 +01:00
Kadir Cetinkaya 60adfb83cd
[clangd] Fix windows buildbots 2020-01-15 16:22:36 +01:00
Kadir Cetinkaya 44f9c7a820
[clangd] Rearrange type, returntype and parameters in hover card
Summary:
Moves type/returntype into its own line as it is more readable in cases
where the type is long.

Also gives parameter lists a heading, `Parameters:` to make them stand out.

Leaves the `right arrow` instead of `Returns: ` before Return Type to make
output more symmetric.

```
function foo

Returns: ret_type
Parameters:
- int x
```

vs

```
function foo

🡺 ret_type
Parameters:
- int x
```

Reviewers: sammccall, ilya-biryukov

Subscribers: MaskRay, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D72623
2020-01-15 15:55:46 +01:00
Kadir Cetinkaya d74a3d470c
[clangd] Add a ruler after header in hover
Reviewers: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D72622
2020-01-15 15:54:38 +01:00
Kadir Cetinkaya 4d14bfaa2c
[clangd] Show hower info for expressions
Summary:
This currently populates only the Name with the expression's type and
Value if expression is evaluatable.

Fixes https://github.com/clangd/clangd/issues/56

Reviewers: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D72500
2020-01-15 15:14:37 +01:00
Hans Wennborg 5852475e2c Bump the trunk major version to 11
and clear the release notes.
2020-01-15 13:38:01 +01:00
Nathan James 36fcbb838c Added readability-qualified-auto check
Adds a check that detects any auto variables that are deduced to a pointer or
a const pointer then adds in the const and asterisk according. Will also
check auto L value references that could be written as const. This relates
to the coding standard
https://llvm.org/docs/CodingStandards.html#beware-unnecessary-copies-with-auto
2020-01-14 14:06:46 -05:00
Malcolm Parsons 9738c757bd [clang-tidy] Match InitListExpr in modernize-use-default-member-init
Summary:
modernize-use-default-member-init wasn't warning about redundant initialisers
when the initialiser was an InitListExpr.  Add initListExpr to the matcher.

Fixes: PR44439

Reviewers: aaron.ballman, alexfh, JonasToth

Reviewed By: aaron.ballman

Subscribers: xazax.hun, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D72691
2020-01-14 15:19:37 +00:00
Malcolm Parsons 45924eb467 [clang-tidy] Ignore implicit casts in modernize-use-default-member-init
Summary:
Initialising a pointer from nullptr involves an implicit cast.
Ignore it after getting initialiser from InitListExpr.

Fixes: PR44440

Reviewers: aaron.ballman, alexfh, JonasToth

Reviewed By: JonasToth

Subscribers: xazax.hun, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D72630
2020-01-14 10:05:12 +00:00
Aaron Ballman c1b13a1b17 Fix a test case by adding -fno-delayed-template-parsing. 2020-01-13 16:02:31 -05:00
Kadir Cetinkaya f5465e74ef
[clangd] Include expression in DecltypeTypeLoc sourcerange while building SelectionTree
Summary:
Currently AST only contains the location for `decltype` keyword,
therefore we were skipping expressions inside decltype while building selection
tree.

This patch extends source range in such cases to contain the expression as well.
A proper fix would require changes to Sema and DecltypeTypeLoc to contain these
location information.

Fixes https://github.com/clangd/clangd/issues/250.

Reviewers: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D72594
2020-01-13 20:33:13 +01:00
Kadir Cetinkaya 15078d7202
[clangd] Render header of hover card as a heading
Reviewers: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D72625
2020-01-13 20:24:09 +01:00
Nathan James fb79ef5241 Fix readability-identifier-naming missing member variables
Fixes PR41122 (missing fixes for member variables in a destructor) and
PR29005 (does not rename class members in all locations).
2020-01-13 13:28:55 -05:00
Oliver Stannard b96ec492d3 [clangd] Remove raw string literals in macros
Older (but still supported) versions of GCC don't handle C++11 raw
string literals in macro parameters correctly.
2020-01-13 11:45:05 +00:00
Utkarsh Saxena 734aa1d133 [clangd] Publish xref for macros from Index and AST.
Summary:
With this patch the `findReferences` API will return Xref for macros.
If the symbol under the cursor is a macro then we collect the references to it from:
1. Main file by looking at the ParsedAST. (These were added to the ParsedAST in https://reviews.llvm.org/D70008)
2. Files other than the mainfile by looking at the:
	* static index (Added in https://reviews.llvm.org/D70489)
	* file index (Added in https://reviews.llvm.org/D71406)
This patch collects all the xref from the above places and outputs it in `findReferences` API.

Reviewers: kadircet

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D72395
2020-01-13 11:11:18 +01:00