Commit Graph

7678 Commits

Author SHA1 Message Date
David Goldman f98bf92b62 Reland "[clangd] Properly compute framework-style include spelling"
Roll forward of https://reviews.llvm.org/D117056 with a fix. Proper
initialization of `IsPrivateHeader` was missing, causing failures
on Linux.
2022-02-07 11:21:23 -05:00
Balázs Kéri 29fc5e0245 [clang-tidy] Fixed a compile warning (NFC).
Fixed a "override" related warning in SharedPtrArrayMismatchCheck.h.
Related to differential revision: https://reviews.llvm.org/D117306
2022-02-07 14:56:27 +01:00
Balázs Kéri c63522e6ba [clang-tidy] Add new check 'shared-ptr-array-mismatch'.
Reviewed By: LegalizeAdulthood

Differential Revision: https://reviews.llvm.org/D117306
2022-02-07 12:57:58 +01:00
David Goldman fb7ddd0628 Revert "[clangd] Properly compute framework-style include spelling"
This reverts commit 4dfd11324e
due to the failures on Linux CI:
https://lab.llvm.org/buildbot/#/builders/188/builds/9296
2022-02-04 18:02:32 -05:00
David Goldman 6abb70c2d0 Attempt forward fix after 4dfd113
If this doesn't work will just revert the change,
can't seem to repro on macOS.
2022-02-04 17:47:38 -05:00
David Goldman 4dfd11324e [clangd] Properly compute framework-style include spelling
With this change, clangd now computes framework-style includes
for framework headers at indexing time.

Differential Revision: https://reviews.llvm.org/D117056
2022-02-04 16:40:56 -05:00
Kadir Cetinkaya 0447ec2fb0
[clang-tidy] Fix LLVM include order check policy
Clang-format LLVM style has a custom include category for gtest/ and
gmock/ headers between regular includes and angled includes. Do the same here.

Fixes https://github.com/llvm/llvm-project/issues/53525.

Differential Revision: https://reviews.llvm.org/D118913
2022-02-03 17:32:43 +01:00
Kirill Bobyrev 089d9c50b2
[clangd] IncludeCleaner: Decrease API dependency on clangd
Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D118882
2022-02-03 14:40:53 +01:00
Christian Kühnel 2f8da95e07 [clangd][nfc] cleanup of remaining clang-tidy findings
There were some left-overs (or new things) from the previous patches.

This will get us down to 0 open findings except:
clang-tidy is complaining in some files about
`warning: #includes are not sorted properly [llvm-include-order]`
however, clang-format does revert these changes.
It looks like clang-tidy and clang-format disagree there.

Not sure how we can fix that...

Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D118698
2022-02-03 12:05:25 +00:00
Haojian Wu c39969ef25 [clangd] NFC, remove an unused local varaiable. 2022-02-03 12:52:24 +01:00
Tom Stellard a2601c9887 Bump the trunk major version to 15 2022-02-01 23:54:52 -08:00
Tom Stellard e80c52986e [docs] Remove hard-coded version numbers from sphinx configs
This updates all the non-runtime project release notes to use the
version number from CMake instead of the hard-coded version numbers
in conf.py.

It also hides warnings about pre-releases when the git suffix
is dropped from the LLVM version in CMake.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D112181
2022-02-01 23:14:12 -08:00
Jameson Nash 84f137a590 Reland "enable plugins for clang-tidy"
This reverts commit ab3b89855c but
disables the new test if the user has disabled support for building it.
2022-02-01 17:37:24 -05:00
Sam McCall 7af1a2ed81 [clangd] Fix handling of co_await in go-to-type 2022-02-01 16:01:53 +01:00
Sam McCall e9cba78653 [clangd] Group and extend release notes 2022-02-01 15:51:57 +01:00
Christian Kühnel 8edfc2f814 [clangd] Cleanup of readability-identifier-naming
Auto-generated patch based on clang-tidy readability-identifier-naming.
Only some manual cleanup for `extern "C"` declarations and a GTest change was required.

I'm not sure if this cleanup is actually very useful. It cleans up clang-tidy findings to the number of warnings from clang-tidy should be lower.  Since it was easy to do and required only little cleanup I thought I'd upload it for discussion.

One pattern that keeps recurring: Test **matchers** are also supposed to start with a lowercase letter as per LLVM convention. However GTest naming convention for matchers start with upper case. I would propose to keep stay consistent with the GTest convention there. However that would imply a lot of `//NOLINT` throughout these files.

To re-product this patch run:
```
run-clang-tidy -checks="-*,readability-identifier-naming" -fix -format ./clang-tools-extra/clangd
```

To convert the macro names, I was using this script with some manual cleanup afterwards:
https://gist.github.com/ChristianKuehnel/a01cc4362b07c58281554ab46235a077

Differential Revision: https://reviews.llvm.org/D115634
2022-02-01 13:31:52 +00:00
Sam McCall 1ed0b0e657 Tweak formatting & wording in clangd release notes 2022-01-31 19:02:54 +01:00
Simon Pilgrim 1307f66d17 [clang-tidy] getLambdaProperties - use cast<> instead of dyn_cast<> to avoid dereference of nullptr
The pointers are dereferenced immediately, so assert the cast is correct instead of returning nullptr
2022-01-31 17:25:16 +00:00
Kadir Cetinkaya 236458ef02
[cte] Add release notes for clangd-14
Differential Revision: https://reviews.llvm.org/D118592
2022-01-31 16:32:25 +01:00
Benjamin Kramer e07823ad72 [clang-tidy] Make header compile standalone. NFC. 2022-01-31 11:18:00 +01:00
Balázs Kéri b088237f08 [clang-tidy] bugprone-signal-handler improvements: display call chain
Display notes for a possible call chain if an unsafe function is found to be
called (maybe indirectly) from a signal handler.
The call chain displayed this way includes probably not the first calls of
the functions, but it is a valid possible (in non path-sensitive way) one.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D118224
2022-01-31 10:35:23 +01:00
Petr Hosek ab3b89855c Revert "enable plugins for clang-tidy"
This reverts commit 36892727e4 which
breaks the build when LLVM_INSTALL_TOOLCHAIN_ONLY is enabled with:

  CMake Error at cmake/modules/AddLLVM.cmake:683 (add_dependencies):
  The dependency target "clang-tidy-headers" of target "CTTestTidyModule"
  does not exist.
2022-01-31 00:55:43 -08:00
Kazu Hirata 2f18b02de7 [clang-tools-extra] Remove unused forward declarations (NFC) 2022-01-30 16:05:00 -08:00
Richard 9948020682 [clang-tidy] Organize the release notes a little better
- Sort new checks by check name
- Sort changes to existing checks by check name
- Add docs for changes to readability-simplify-boolean-expr
- Move check changes from "Improvements to clang-tidy" to
  "Changes in existing checks" section

Differential Revision: https://reviews.llvm.org/D118519
2022-01-29 20:32:25 -07:00
Jameson Nash 36892727e4 enable plugins for clang-tidy
Fixes #32739

Differential Revision: https://reviews.llvm.org/D111100
2022-01-29 14:21:19 -05:00
Sam McCall 93cf9640fa Add 'clangd' prefix to remote index proto targets
Some pieces of build infrastructure (shlib, debian package) classify
targets based on whether they begin with "clang".
2022-01-29 02:20:52 +01:00
Richard 99217fa8a0 [clang-tidy] Recognize labelled statements when simplifying boolean exprs
Inside a switch the caseStmt() and defaultStmt() have a nested statement
associated with them.  Similarly, labelStmt() has a nested statement.
These statements were being missed when looking for a compound-if of the
form "if (x) return true; return false;" when the if is nested under one
of these labelling constructs.

Enhance the matchers to look for these nested statements using some
private matcher hasSubstatement() traversal matcher on case, default
and label statements.  Add the private matcher hasSubstatementSequence()
to match the compound "if (x) return true; return false;" pattern.

- Add unit tests for private matchers and corresponding test
  infrastructure
- Add corresponding test file readability-simplify-bool-expr-case.cpp.
- Fix variable name copy/paste error in readability-simplify-bool-expr.cpp.
- Drop the asserts, which were used only for debugging matchers.
- Run clang-format on the whole check.
- Move local functions out of anonymous namespace and declare state, per
  LLVM style guide
- Declare labels constexpr
- Declare visitor arguments as pointer to const
- Drop braces around simple control statements per LLVM style guide
- Prefer explicit arguments over default arguments to methods

Differential Revision: https://reviews.llvm.org/D56303

Fixes #27078
2022-01-28 16:09:46 -07:00
Haojian Wu 15dfe7a3f1 [clangd] Fix a typo , => ; in hovertest.
I somehow missed it.
2022-01-27 22:19:09 +01:00
Haojian Wu 0cf75aac42 [clangd] Enable hover on character literal.
In the initial hover expression patch (https://reviews.llvm.org/D72500), we
disabled all literals.

There is some value on running hover on character literals (e.g. see the
int value of the char).

Differential Revision: https://reviews.llvm.org/D117864
2022-01-27 21:22:03 +01:00
Haojian Wu 4cb1686bfe [clangd] Fix a selection tree crash for unmatched-bracket code.
Fixes https://github.com/clangd/clangd/issues/999

Differential Revision: https://reviews.llvm.org/D118322
2022-01-27 21:21:40 +01:00
Richard 8ce99dadb0 [clang-tidy] Add more documentation about check development (NFC)
- Mention pp-trace
- CMake configuration
- Overriding registerPPCallbacks
- Overriding isLanguageVersionSupported
- Check development tips
  - Guide to useful documentation
  - Using the Transformer library
  - Developing your check incrementally
  - Creating private matchers
  - Unit testing helper code
  - Making your check robust
  - Documenting your check
- Describe the Inputs test folder

Differential Revision: https://reviews.llvm.org/D117939
2022-01-27 09:44:09 -07:00
MuAlphaOmegaEpsilon ccce1a03c9 Don't trigger unused-parameter warnings on naked functions
This commit checks if a function is marked with the naked attribute
and, if it is, will silence the emission of any unused-parameter
warning.

Inside a naked function only the usage of basic ASM instructions is
expected. In this context the parameters can actually be used by
fetching them according to the underlying ABI. Since parameters might
be used through ASM instructions, the linter and the compiler will have
a hard time understanding if one of those is unused or not, therefore
no unused-parameter warning should ever be triggered whenever a
function is marked naked.
2022-01-27 11:40:08 -05:00
Kadir Cetinkaya c4e68953f6
[clangd][Hover] Suppress initializers with many tokens
This results in excessive memory usage and eats a lot of screen estate.
Especially in the cases with lots of nested macro calls.

This patch tries to remedy it before the release cut by suppressing the
initializers. For better UX we should probably update the expression printer to
truncate those (behind some policy).

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

Differential Revision: https://reviews.llvm.org/D118260
2022-01-27 13:01:55 +01:00
Evgeny Shulgin 836950c4e6 [clang-tidy] Fix nested namespaces in `readability-static-definition-in-anonymous-namespace` check
The check previously inspected only the immediate parent namespace.
`static` in a named namespace within an unnamed namespace is still
redundant.
We will use `Decl::isInAnonymousNamespace()` method that traverses the
namespaces hierarchy recursively.

Differential Revision: https://reviews.llvm.org/D118010
2022-01-26 21:54:17 -07:00
Sam McCall 33c3ef2fbe [CodeCompletion][clangd] Clean __uglified parameter names in completion & hover
Underscore-uglified identifiers are used in standard library implementations to
guard against collisions with macros, and they hurt readability considerably.
(Consider `push_back(Tp_ &&__value)` vs `push_back(Tp value)`.
When we're describing an interface, the exact names of parameters are not
critical so we can drop these prefixes.

This patch adds a new PrintingPolicy flag that can applies this stripping
when recursively printing pieces of AST.
We set it in code completion/signature help, and in clangd's hover display.
All three features also do a bit of manual poking at names, so fix up those too.

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

Differential Revision: https://reviews.llvm.org/D116387
2022-01-26 15:51:17 +01:00
Salman Javed c283c8dfb5 Rewrite Doxygen comment to resolve -Wdocumentation warning (NFC)
Comment change only, no functional change intended.
Example of warning:
https://lab.llvm.org/buildbot/#/builders/188/builds/8696/steps/4/logs/warnings__2_
2022-01-27 02:21:05 +13:00
Salman Javed 5da7c04003 Re-land "Cache the locations of NOLINTBEGIN/END blocks" with fix for build bot 2022-01-27 01:03:27 +13:00
Salman Javed 8e29d19b8d Revert "[clang-tidy] Cache the locations of NOLINTBEGIN/END blocks"
Build warning here:
https://lab.llvm.org/buildbot/#/builders/57/builds/14322
2022-01-27 00:52:44 +13:00
Salman Javed 19eaad94c4 [clang-tidy] Cache the locations of NOLINTBEGIN/END blocks
Support for NOLINT(BEGIN/END) blocks (implemented in D108560) is
currently costly. This patch aims to improve the performance with the
following changes:

- The use of tokenized NOLINTs instead of a series of repetitive ad-hoc
string operations (`find()`, `split()`, `slice()`, regex matching etc).
- The caching of NOLINT(BEGIN/END) block locations. Determining these
locations each time a new diagnostic is raised is wasteful as it
requires reading and parsing the entire source file.

Move NOLINT-specific code from `ClangTidyDiagnosticConsumer` to new
purpose-built class `NoLintDirectiveHandler`.

Differential Revision: https://reviews.llvm.org/D116085
2022-01-27 00:12:16 +13:00
Richard f0726ae0f9 Refactor: Extract Class MessagePrefix (NFC)
The work is the same, the only difference is the prefix
of the strings we look for in the reference files.
2022-01-25 23:19:33 -07:00
Sam McCall ce94432702 [clangd] Add designator inlay hints for initializer lists.
These make the init lists appear as if designated initialization was used.

Example:
  ExpectedHint{"param: ", "arg"}
becomes
  ExpectedHint{.Label="param: ", .RangeName="arg"}

Differential Revision: https://reviews.llvm.org/D116786
2022-01-26 00:35:29 +01:00
Zinovy Nis 19d7a0b47b [clang-tidy] [bugprone-assert-side-effect] Ignore list for functions/methods
A semicolon-separated list of the names of functions or methods to be considered as not having side-effects was added for bugprone-assert-side-effect. It can be used to exclude methods like iterator::begin/end from being considered as having side-effects.

Differential Revision: https://reviews.llvm.org/D116478
2022-01-25 21:04:07 +03:00
Balázs Kéri 9d8c3ad94f [clang-tidy] Change code of SignalHandlerCheck (NFC).
Using clang::CallGraph to get the called functions.
This makes a better foundation to improve support for
C++ and print the call chain.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D118016
2022-01-25 15:52:38 +01:00
Jim Lin f3314e3747 [clang-tidy] Pop Files only if FileChangeReason is ExitFile
enum FileChangeReason has four possible type EnterFile, ExitFile,
SystemHeaderPragma and RenameFile,
It should pop the back element of Files only if FileChangeReason is ExitFile.
2022-01-25 22:46:12 +08:00
Christian Kühnel c0e3c893aa [NFC][clangd] cleaning up llvm-qualified-auto
This is a cleanup of all llvm-qualified-auto findings.
This patch was created by automatically applying the fixes from
clang-tidy.

Differential Revision: https://reviews.llvm.org/D113898
2022-01-25 13:26:33 +00:00
Richard 810f13f0eb [clang-tools-extra] Fix documentation build (NFC) 2022-01-24 20:19:03 -07:00
Yuanfang Chen 3b64ab574d [NFC][clangd] Use table to collect option aliases
* Suppress a lot of `-Wtautological-compare` warning
* Speed up file build a little bit

Reviewed By: kadircet

Differential Revision: https://reviews.llvm.org/D98110
2022-01-24 14:27:14 -08:00
serge-sans-paille a0d5e938fe Add missing include llvm/ADT/STLExtras 2022-01-24 14:41:24 +01:00
Adrian Vogelsgesang 3696c70e67 [clang-tidy] Add `readability-container-contains` check
This commit introduces a new check `readability-container-contains` which finds
usages of `container.count()` and `container.find() != container.end()` and
instead recommends the `container.contains()` method introduced in C++20.

For containers which permit multiple entries per key (`multimap`, `multiset`,
...), `contains` is more efficient than `count` because `count` has to do
unnecessary additional work.

While this this performance difference does not exist for containers with only
a single entry per key (`map`, `unordered_map`, ...), `contains` still conveys
the intent better.

Reviewed By: xazax.hun, whisperity

Differential Revision: http://reviews.llvm.org/D112646
2022-01-24 12:57:18 +01:00
Kazu Hirata ee591a64a7 [clang] Forward-declare DynTypedNode (NFC)
This patch adds a forward declaraiton of DynTypedNode.

DumpAST.h is relying on the forward declaration of DynTypedNode in
ASTContext.h, which is undesirable.
2022-01-23 13:28:04 -08:00