Commit Graph

7887 Commits

Author SHA1 Message Date
Martin Storsjö 9a3eeae321 [clang-tidy] Fix the condition for building CTTestTidyModule
This is the correct intended condition; the problematic case where
we don't want to try to build the plugin is "WIN32 AND LLVM_LINK_LLVM_DYLIB"
and thus the negation is "NOT WIN32 OR NOT LLVM_LINK_LLVM_DYLIB".

Differential Revision: https://reviews.llvm.org/D121687
2022-03-25 21:22:46 +02:00
Sam McCall 57ee624d79 [cmake] Provide CURRENT_TOOLS_DIR centrally, replacing CLANG_TOOLS_DIR
CLANG_TOOLS_DIR holds the the current bin/ directory, maybe with a %(build_mode)
placeholder. It is used to add the just-built binaries to $PATH for lit tests.
In most cases it equals LLVM_TOOLS_DIR, which is used for the same purpose.
But for a standalone build of clang, CLANG_TOOLS_DIR points at the build tree
and LLVM_TOOLS_DIR points at the provided LLVM binaries.

Currently CLANG_TOOLS_DIR is set in clang/test/, clang-tools-extra/test/, and
other things always built with clang. This is a few cryptic lines of CMake in
each place. Meanwhile LLVM_TOOLS_DIR is provided by configure_site_lit_cfg().

This patch moves CLANG_TOOLS_DIR to configure_site_lit_cfg() and renames it:
 - there's nothing clang-specific about the value
 - it will also replace LLD_TOOLS_DIR, LLDB_TOOLS_DIR etc (not in this patch)

It also defines CURRENT_LIBS_DIR. While I removed the last usage of
CLANG_LIBS_DIR in e4cab4e24d, there are LLD_LIBS_DIR usages etc that
may be live, and I'd like to mechanically update them in a followup patch.

Differential Revision: https://reviews.llvm.org/D121763
2022-03-25 20:22:01 +01:00
Douglas Yung cef52105bd Revert "[clang-tidy] Add modernize-macro-to-enum check"
This reverts commit 39b80c8380.

This change was causing build failures on several build bots:
- https://lab.llvm.org/buildbot/#/builders/139/builds/19210
- https://lab.llvm.org/buildbot/#/builders/93/builds/7956
2022-03-25 11:53:42 -07:00
Nathan James b97f26083b Reland "[ASTMatchers] Output currently processing match and nodes on crash"
This reverts commit cff34ccb60.

This relands commit d89f9e963e
2022-03-25 17:53:58 +00:00
Richard 39b80c8380 [clang-tidy] Add modernize-macro-to-enum check
This check performs basic analysis of macros and replaces them
with an anonymous unscoped enum.  Using an unscoped anonymous enum
ensures that everywhere the macro token was used previously, the
enumerator name may be safely used.

Potential macros for replacement must meet the following constraints:
- Macros must expand only to integral literal tokens.  The unary
  operators plus, minus and tilde are recognized to allow for positive,
  negative and bitwise negated integers.
- Macros must be defined on sequential source file lines, or with
  only comment lines in between macro definitions.
- Macros must all be defined in the same source file.
- Macros must not be defined within a conditional compilation block.
- Macros must not be defined adjacent to other preprocessor directives.
- Macros must not be used in preprocessor conditions

Each cluster of macros meeting the above constraints is presumed to
be a set of values suitable for replacement by an anonymous enum.
From there, a developer can give the anonymous enum a name and
continue refactoring to a scoped enum if desired.  Comments on the
same line as a macro definition or between subsequent macro definitions
are preserved in the output.  No formatting is assumed in the provided
replacements.

The check cppcoreguidelines-macro-to-enum is an alias for this check.

Fixes #27408

Differential Revision: https://reviews.llvm.org/D117522
2022-03-25 09:45:55 -06:00
Sam McCall 72864d9bfe [pseudo] Use box-drawing chars to prettify debug dumps. NFC 2022-03-25 14:17:38 +01:00
Kadir Cetinkaya 50f4f32b56
[clangd] Retain main file fixes attached to diags from preamble
Clangd ignores fixits if the diagnsotics is outside the main file (e.g.
a note on a declaration from a header), but the fix might still be inside the
main file (e.g. change the function call).

This patch changes the logic to retain fixes that touch main file, if the
diagnostic owning them is still inside main file, even if they are attached to a
note outside the main file.

Differential Revision: https://reviews.llvm.org/D122315
2022-03-24 15:19:25 +01:00
Haojian Wu 62d5f254cc [pseudo] Introduce parse forest.
Parse forest is the output of the GLR parser, it is a tree-like DAG
which presents all possible parse trees without duplicating subparse structures.

This is a patch split from https://reviews.llvm.org/D121150.

Differential Revision: https://reviews.llvm.org/D122139
2022-03-24 14:47:17 +01:00
Haojian Wu f383b88d82 [pseudo] Sort nonterminals based on their reduction order.
Reductions need to be performed in a careful order in GLR parser, to
make sure we gather all alternatives before creating an ambigous forest
node.

This patch encodes the nonterminal order into the rule id, so that we
can efficiently to determinal ordering of reductions in GLR parser.

This patch also abstracts to a TestGrammar, which is shared among tests.

This is a part of the GLR parser, https://reviews.llvm.org/D121368,
https://reviews.llvm.org/D121150

Differential Revision: https://reviews.llvm.org/D122303
2022-03-24 14:30:12 +01:00
Sam McCall 31dc248ffc [clangd] Fix IncludeFixer test on windows
Actual functionality doesn't seem to work with (default)
-fms-compatibility. Not sure why yet...
2022-03-23 18:57:08 +01:00
Sam McCall 2da5c5781e [clangd] Add inlay hints for auto-typed parameters with one instantiation.
This takes a similar approach as b9b6938183, and shares some code.
The code sharing is limited as inlay hints wants to deduce the type of the
variable rather than the type of the `auto` per-se.

It drops support (in both places) for multiple instantiations yielding the same
type, as this is pretty rare and hard to build a nice API around.

Differential Revision: https://reviews.llvm.org/D120258
2022-03-23 17:26:25 +01:00
Sam McCall b857a5092c [clangd] Support include-fixer inside macro arguments.
Motivating case: EXPECT_EQ(42, missingFunction(bar));

Differential Revision: https://reviews.llvm.org/D120619
2022-03-23 17:12:33 +01:00
Danny Mösch a749e3295d Replace links to archived mailing lists by links to Discourse forums 2022-03-23 10:10:20 -04:00
Fabian Wolff 07675b0b38 [clang-tidy] Fix false positives in `misc-redundant-expression` check
Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D122111
2022-03-23 00:32:45 +01:00
Haojian Wu 1579090141 Reland "[pseudo] Split greatergreater token."
It was reverted, because the test had a lift-time issue.
Reland f66d3758bd with a fix.
2022-03-22 10:27:52 +01:00
Martin Storsjö 3e7a8aab75 [clang-tidy] Don't try to build CTTestTidyModule for Windows with dylibs
In MinGW mode, it's possible to build LLVM/Clang with
LLVM_LINK_LLVM_DYLIB (which implicitly enables plugins too). Other
existing ways of building plugins on Windows is to build with
LLVM_EXPORT_SYMBOLS_FOR_PLUGINS, where each executable exports its
symbols.

With LLVM_LINK_LLVM_DYLIB, we can't generally skip building plugins
even if they are set up with PLUGIN_TOOL, as some plugins (e.g.
under clang/examples) set up that way do build properly (as
they manually call clang_target_link_libraries, which links in the
libclang-cpp.dll dylib).

For CTTestTidyModule, there's no corresponding dylib that would
provide the same exports.

Differential Revision: https://reviews.llvm.org/D121687
2022-03-22 11:08:32 +02:00
Nathan James cff34ccb60 Revert "[ASTMatchers] Output currently processing match and nodes on crash"
This reverts commit d89f9e963e.
2022-03-21 22:29:22 +00:00
Eric Li 9edeceaece [libTooling] Generalize string explanation as templated metadata
Change RewriteRule from holding an `Explanation` to being able to generate
arbitrary metadata. Where TransformerClangTidyCheck was interested in a string
description for the diagnostic, other tools may be interested in richer metadata
at a higher level of abstraction than at the edit level (which is currently
available as ASTEdit::Metadata).

Reviewed By: ymandel

Differential Revision: https://reviews.llvm.org/D120360
2022-03-21 20:39:35 +00:00
Nathan James d89f9e963e
[ASTMatchers] Output currently processing match and nodes on crash
Create a PrettyStackTraceEvent that will dump the current `MatchCallback` id as well as the `BoundNodes` if the 'run' method of a `MatchCallback` results in a crash.
The purpose of this is sometimes clang-tidy checks can crash in the `check` method. And in a large codebase with alot of checks enabled and in a release build, it can be near impossible to figure out which check as well as the source code that caused the crash. Without that information a reproducer is very hard to create.
This is a more generalised version of D118520 which has a nicer integration and should be useful to clients other than clang-tidy.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D120185
2022-03-21 19:13:36 +00:00
Yitzhak Mandelbaum 8351726e6d Revert "[libTooling] Generalize string explanation as templated metadata"
This reverts commit 18440547d3. Causing failures
in some build modes.

e.g. https://lab.llvm.org/buildbot/#/builders/217/builds/1886
2022-03-21 19:06:59 +00:00
Eric Li 18440547d3 [libTooling] Generalize string explanation as templated metadata
Change RewriteRule from holding an `Explanation` to being able to generate
arbitrary metadata. Where TransformerClangTidyCheck was interested in a string
description for the diagnostic, other tools may be interested in richer metadata
at a higher level of abstraction than at the edit level (which is currently
available as ASTEdit::Metadata).

Reviewed By: ymandel

Differential Revision: https://reviews.llvm.org/D120360
2022-03-21 18:45:39 +00:00
Sam McCall 46dbd19afb [clangd] Fix nullptr crash in AddUsing tweak on catch(...)
Fixes https://github.com/clangd/clangd/issues/1072
2022-03-21 18:56:45 +01:00
Adam Czachorowski 6009d0d580 [clangd] Track time spent in filesystem ops during preamble builds
In some deployments, for example when running on FUSE or using some
network-based VFS implementation, the filesystem operations might add up
to a significant fraction of preamble build time. This change allows us
to track time spent in FS operations to better understand the problem.

Differential Revision: https://reviews.llvm.org/D121712
2022-03-21 18:33:01 +01:00
Kadir Cetinkaya 164a10dcf2
[clangd] Test against path insensitivity
Differential Revision: https://reviews.llvm.org/D121286
2022-03-21 17:27:05 +01:00
Sam McCall 1f92f44ec9 [pseudo] fix typo'd test assertions 2022-03-21 14:05:21 +01:00
Evgeny Shulgin fc354d3752 [clang-tidy] Skip parentheses in `readability-make-member-function-const`
The checker should ignore parentheses when looking whether the
function should be marked as `const`.

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

Reviewed By: mgehre-amd, njames93

Differential Revision: https://reviews.llvm.org/D122075
2022-03-21 14:18:17 +03:00
Zequan Wu 217f267efe Revert "[pseudo] Split greatergreater token."
This reverts commit f66d3758bd.

It breaks windows bot.
2022-03-18 10:15:48 -07:00
David Goldman 8522a01e84 Attempt forward fix for Linux buildbots for D116385 2022-03-17 12:49:16 -04:00
David Goldman 1af5fbd5c6 [clangd] Code action for creating an ObjC initializer
The code action creates an initializer for the selected
ivars/properties, defaulting to all if only the interface/implementation
container is selected.

We add it based on the position of the first non initializer that we
see, and default to adding it where the @end token is.

We also use the ObjC parameter form of (nullable id) instead of
(id _Nullable) if the property has the nullable attribute.

Differential Revision: https://reviews.llvm.org/D116385
2022-03-17 11:31:14 -04:00
Haojian Wu 30de15e100 [pseudo] Tweak some docs, NFC
Consitently use the "nonterminal", "pseudoparser" terms.
2022-03-17 13:58:42 +01:00
Haojian Wu eb265e3ba2 [clangd] Re-enable clang-tidy's nolint blocks
The previous inefficient implementation is polished.

Reviewed By: kadircet

Differential Revision: https://reviews.llvm.org/D119701
2022-03-17 13:48:55 +01:00
Haojian Wu f66d3758bd [pseudo] Split greatergreater token.
For a >> token (a right shift operator, or a nested template?), the clang
lexer always returns a single greatergreater token, as a result,
the grammar-based GLR parser never try to parse the nested template
case.

We derive a token stream by always splitting the >> token, so that the
GLR parser is able to pursue both options during parsing (usually 1
path fails).

Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D121678
2022-03-17 13:46:58 +01:00
Shreyas Atre 9e1f4f1398 [clang-tidy][run-clang-tidy.py] Add --config-file=<string> option
Link to the GitHub Issue: https://github.com/llvm/llvm-project/issues/53745

Added config_path variable within the python script which makes the
required call to the clang-tidy binary with --config-file option.
If the config_path is None then config will be used. No error is raised
if both are given but silently chooses config_path over config
2022-03-17 07:30:28 -04:00
Evgeny Shulgin 6043520c20 [clang-tidy] Don't check decltype return types in `readability-const-return-type`
The checker removes `const`s that are superfluos and badly affect
readability. `decltype(auto)`/`decltype(expr)` are often const-qualified, but
have no effect on readability and usually can't stop being const-qualified
without significant code change.

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

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D119470
2022-03-17 14:27:09 +03:00
Haojian Wu 5a624956ce [pseudo] Fix some naming-style violations. 2022-03-17 09:47:24 +01:00
Nathan Ridge 606ba8a68f [clangd] Handle more than two conflicting semantic tokens in resolveConflict()
Fixes https://github.com/clangd/clangd/issues/1057

Differential Revision: https://reviews.llvm.org/D121775
2022-03-16 12:53:04 -04:00
Haojian Wu e5b1b9edb8 [pseudo] Cleanup the leftover header guards after the movement, NFC. 2022-03-16 16:25:18 +01:00
Sam McCall e4cab4e24d [lit] Remove clang_libs_dir
Seems to have been added accidentally in 58db03a116 and then
copied into clangd by me (but not actually needed).
2022-03-16 03:03:02 +01:00
Sam McCall 89cd86bbc5 Reapply [pseudo] Move pseudoparser from clang to clang-tools-extra"
This reverts commit 049f4e4eab.

The problem was a stray dependency in CLANG_TEST_DEPS which caused cmake
to fail if clang-pseudo wasn't built. This is now removed.
2022-03-16 01:10:55 +01:00
Sam McCall 049f4e4eab Revert "[pseudo] Move pseudoparser from clang to clang-tools-extra"
This reverts commit b97856c4cf.

Breaks a bunch of bots:
https://lab.llvm.org/buildbot/#/builders/193/builds/8513
2022-03-16 01:06:24 +01:00
Sam McCall b97856c4cf [pseudo] Move pseudoparser from clang to clang-tools-extra
This should make clearer that:
 - it's not part of clang proper
 - there's no expectation to update it along with clang (beyond green tests)
 - clang should not depend on it

This is intended to be expose a library, so unlike other tools has a split
between include/ and lib/.

The main renames are:
  clang/lib/Tooling/Syntax/Pseudo/*           => clang-tools-extra/pseudo/lib/*
  clang/include/clang/Tooling/Syntax/Pseudo/* => clang-tools-extra/pseudo/include/clang-pseudo/*
  clang/tools/clang/pseudo/*                  => clang-tools-extra/pseudo/tool/*
  clang/test/Syntax/*                         => clang-tools-extra/pseudo/test/*
  clang/unittests/Tooling/Syntax/Pseudo/*     => clang-tools-extra/pseudo/unittests/*
  #include "clang/Tooling/Syntax/Pseudo/*"    => #include "clang-pseudo/*"
  namespace clang::syntax::pseudo             => namespace clang::pseudo
  check-clang                                 => check-clang-pseudo
  clangToolingSyntaxPseudo                    => clangPseudo
The clang-pseudo and ClangPseudoTests binaries are not renamed.

See discussion around:
https://discourse.llvm.org/t/rfc-a-c-pseudo-parser-for-tooling/59217/50

Differential Revision: https://reviews.llvm.org/D121233
2022-03-16 00:14:11 +01:00
Sam McCall 2b69eb4a7d [clang-tools-extra] Reuse llvm_config.use_clang() to set up test environment
This replaces a bunch of duplicate logic to set up environment variables
and a few substitutions.

It does a little more than we were doing previously:
 - searching for clang and setting up substitutions for it
 - setting up some substitutions for target triples, which are
   potentially useful but not actually used

clangd has been happily using this for its tests for a while.

Differential Revision: https://reviews.llvm.org/D121422
2022-03-15 22:14:24 +01:00
Sam McCall fa1019fa18 [lit] add lit_config.substitute to interpolate lit_config.params
A version of this logic appears in ~every lit.site.cfg.in (28 copies total).
This patch just removes two, but I'll update the rest of llvm-project next.

Differential Revision: https://reviews.llvm.org/D121427
2022-03-15 22:09:43 +01:00
Danny Mösch 2b21fc5520 Allow newline characters as separators for checks in Clang-Tidy configurations
This is a fix for #53737. In addition to commas, newline characters are
considered as separators of checks.
2022-03-15 14:30:13 -04:00
Fangrui Song 407c721ceb [Support] Change zlib::compress to return void
With a sufficiently large output buffer, the only failure is Z_MEM_ERROR.
Check it and call the noreturn report_bad_alloc_error if applicable.
resize_for_overwrite may call report_bad_alloc_error as well.

Now that there is no other error type, we can replace the return type with void
and simplify call sites.

Reviewed By: ikudrin

Differential Revision: https://reviews.llvm.org/D121512
2022-03-14 11:38:04 -07:00
Keith Smiley 5da83eeb91 clang-tidy: discover binaries in build dir
This changes the clang-tidy script to discover binaries you've built
locally without having to pass them.

Differential Revision: https://reviews.llvm.org/D100692
2022-03-14 09:04:36 -07:00
Balazs Benics 665879b9e7 [clang-tidy][docs] Fix wrong url in DontModifyStdNamespaceCheck
It was probably a copy-paste mistake.
The check was added as `cert-dcl58-cpp`, so the doc should point there.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D121373
2022-03-13 17:51:00 +01:00
Balazs Benics d321f09926 [clang-tidy][docs][NFC] Update URL and docs of PostfixOperatorCheck
The docs URL was dangling, and the docs suggested that it has no fixits,
but it actually had.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D121372
2022-03-13 17:51:00 +01:00
Balazs Benics 200e7a8470 [clang-tidy][docs][NFC] Refer to the CERT rule in bugprone-shared-ptr-array-mismatch docs
Document the connection between this checker and the corresponding CERT
rule.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D121214
2022-03-13 17:51:00 +01:00
Petr Hosek 0c0f6cfb7b [CMake] Rename TARGET_TRIPLE to LLVM_TARGET_TRIPLE
This clarifies that this is an LLVM specific variable and avoids
potential conflicts with other projects.

Differential Revision: https://reviews.llvm.org/D119918
2022-03-11 15:43:01 -08:00
Richard 602ea53cb7 [clang-tidy] Refactor: Prefer single quoted strings over double quoted strings [NFC] 2022-03-11 15:08:24 -07:00
Sam McCall 7f0df31ee3 [clang-tools-extra] Don't consider python below LLVM_MINIMUM_PYTHON_VERSION. NFC 2022-03-10 23:57:27 +01:00
Sam McCall 2d58ba200a [clang-tools-extra] Remove unused lit features/substitutions. NFCI 2022-03-10 23:28:43 +01:00
Sam McCall 6ed2f8902b Fix reference to execute_external leftover in 69924ccf7a 2022-03-10 23:20:03 +01:00
Sam McCall 69924ccf7a Remove redundant lit config already handled in llvm_config. NFCI
This logic duplicates lit.llvm.initialize, which we're already calling
(in lit.site.cfg.py.in).
The equivalent logic was removed from clang in d4401d354a but
never cleaned up here.
2022-03-10 23:11:01 +01:00
Yevgeny Rouban c8a35727fe [clangd] Make dexp command line options sticky
Preparing for the cl::opt reset fix proposed on D115433 this
patch fixes the dexp tool to preserve its three command line
options (IndexLocation, ExecCommand, ProjectRoot) from reset
that is done before parsing query options.

Tags: #clang
2022-03-09 13:00:25 +07:00
Yevgeny Rouban 81f8df0c83 [clangd] Make dexp command line options sticky
Preparing for the cl::opt reset fix proposed on D115433 this
patch fixes the dexp tool to preserve its three command line
options (IndexLocation, ExecCommand, ProjectRoot) from reset
that is done before parsing query options.

Tags: #clang
2022-03-09 12:59:49 +07:00
Kirill Bobyrev d5106c8f97
[clangd] NFC: Cleanup IncludeCleaner API
Make a further improvement to decrease verbosity of the API: ASTContext
provides SourceManager access.

Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D119842
2022-03-08 13:43:25 +01:00
Richard de29719af2 [clang-tools-extra] Document clang tidy unit tests target
Differential Revision: https://reviews.llvm.org/D121019
2022-03-07 08:24:08 -07:00
Balazs Benics e86324f800 [clang-tidy][NFC] Document bugprone-narrowing-conversions check alias 2022-03-04 16:47:11 +01:00
Jun Zhang ac616fbb05
[Clang-tidy] Check the existence of ElaboratedType's qualifiers
The ElaboratedType can have no qualifiers, so we should check it before
use.

Fix #issue53874(https://github.com/llvm/llvm-project/issues/53874)

Differential Revision: https://reviews.llvm.org/D119949
2022-03-01 23:52:44 +08:00
Sockke ba54ebeb5e [clang-tidy] Fix `readability-const-return-type` for pure virtual function.
It cannot match a `pure virtual function`. This patch fixes this behavior.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D116439
2022-03-01 20:55:28 +08:00
Whisperity 9485091827 [NFC][clang-tidy][docs] Remove mention of backported fix of `readability-suspicious-call-argument` from `ReleaseNotes`
Commit 416e689ecd introduced a fix to
`readability-suspicious-call-argument` which added an entry to the
Release Notes, but the same change was backported to **14.0** in commit
e89602b7b2ec12f20f2618cefb864c2b22d0048a.

Hence, this change is not a new thing of the to-be 15.0 release.
2022-03-01 12:06:59 +01:00
Jorge Gorbe Moya de9611befe [NFC] Don't pass temporary LangOptions to Lexer
Since https://reviews.llvm.org/D120334, passing a temporary LangOptions
object to Lexer results in stack-use-after-scope.
2022-02-28 12:53:59 -08:00
Sam McCall 42cb812da7 [clangd] Test fixes missing from 257559ed9 2022-02-26 21:38:25 +01:00
Sam McCall 257559ed9a [clangd] Function return type hints: support lambdas, don't duplicate "->"
While here, fix an ugliness:
  auto foo()->auto { return 42; }
This (silly) code gains a "-> int" hint. While correct and useful, it renders as
  auto foo()->int->auto { return 42; }
which is confusing enough to do more harm than good I think.

Differential Revision: https://reviews.llvm.org/D120416
2022-02-26 21:28:09 +01:00
Sam McCall 671eab254a [clangd] Support IncludeFixer or base specifiers 2022-02-26 15:45:59 +01:00
Sam McCall b09c12c4b9 [clangd] Fix wrong included header. NFC 2022-02-26 14:21:52 +01:00
Sam McCall e63d7bdc28 [clangd] Fix include-cleaner false-positive bug
For TemplateSpecializationType, we were checking the node's newness
twice, so it always failed the second test.

Fixes https://github.com/clangd/clangd/issues/1036
2022-02-26 14:11:48 +01:00
Benjamin Kramer 6c72a97c0e [clangd] Qualify calls to std::move to silence -Wunqualified-std-cast-call. NFC. 2022-02-26 13:36:14 +01:00
Benjamin Kramer dfed8f556d [clangd] Add a missing include. NFC. 2022-02-26 13:23:06 +01:00
Sam McCall 4d006520b8 [clangd] Clean up unused includes. NFCI
Add includes where needed to fix build.
Haven't systematically added used headers, so there is still accidental
dependency on transitive includes.
2022-02-26 12:00:16 +01:00
Whisperity 416e689ecd [clang-tidy] Fix `readability-suspicious-call-argument` crash for arguments without name-like identifier
As originally reported by @steakhal in
http://github.com/llvm/llvm-project/issues/54074, the name extraction logic of
`readability-suspicious-call-argument` crashes if the argument passed to a
function was a function call to a non-trivially named entity (e.g. an operator).

Fixed this crash case by ignoring such constructs and considering them as having
no name.

Reviewed By: aaron.ballman, steakhal

Differential Revision: http://reviews.llvm.org/D120555
2022-02-25 16:24:27 +01:00
Aaron Ballman 27d39e4da0 Use function prototypes when appropriate; NFC
This prepares the clang-tools-extra project for -Wstrict-prototypes
being enabled by default.
2022-02-25 09:08:27 -05:00
Sockke 6cbf15e9b5 [clang-tidy] Fix `readability-non-const-parameter` for parameter referenced by an lvalue
The checker missed a check for a case when the parameter is referenced by an lvalue and this could cause build breakages.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D117090
2022-02-25 14:53:11 +08:00
Sven van Haastregt ba18c360b2 [clang-tidy] Remove opencl-c.h inclusion from tests
After D120254 some clang-tidy tests started failing on release builds.

clang-tidy has been using the `-fdeclare-opencl-builtins` functionality
since this became the default in clang, so there is no need to include
`opencl-c.h`.

Differential Revision: https://reviews.llvm.org/D120470
2022-02-24 16:28:52 +00:00
Nathan James 79353f940c
[clang-tidy][NFC] Remove Tristate from CachedGlobList
The tristate is a little redundant as we can determine if the item was already in the cache based on the return from try_emplace.

Reviewed By: salman-javed-nz

Differential Revision: https://reviews.llvm.org/D120196
2022-02-23 08:35:31 +00:00
Sam McCall b9b6938183 [clangd] Treat 'auto' params as deduced if there's a single instantiation.
This makes hover/go-to-definition/expand-auto etc work for auto params in many
common cases.
This includes when a generic lambda is passed to a function accepting
std::function. (The tests don't use this case, it requires a lot of setup).

Note that this doesn't affect the AST of the function body itself, cause its
nodes not to be dependent, improve code completion etc.
(These sort of improvements seem possible, in a similar "if there's a single
instantiation, traverse it instead of the primary template" way).

Fixes https://github.com/clangd/clangd/issues/493
Fixes https://github.com/clangd/clangd/issues/1015

Differential Revision: https://reviews.llvm.org/D119537
2022-02-21 13:24:11 +01:00
Kesavan Yogeswaran c57b8ca721
[clang-tidy] Provide fine control of color in run-clang-tidy
D90110 modified the behavior of `run-clang-tidy` to always pass the
`--use-color` option to clang-tidy, which enabled colored diagnostics
output regardless of TTY status or .clang-tidy settings. This left the
user with no option to disable the colored output.

This presents an issue when trying to parse the output of run-clang-tidy
programmaticall, as the output is polluted with ANSI escape characters.

This PR fixes this issue in two ways:
1. It restores the default behavior of `run-clang-tidy` to let
   `clang-tidy` decide whether to color output. This allows the user to
   configure color via the `UseColor` option in a .clang-tidy file.
2. It adds mutually exclusive, optional `-use-color` and `-no-use-color`
   argument flags that let the user explicitly set the color option via
   the invocation.

After this change the default behavior of `run-clang-tidy` when no
.clang-tidy file is available is now to show no color, presumably
because `clang-tidy` detects that the output is being piped and defaults
to not showing colored output. This seems like an acceptable tradeoff
to respect .clang-tidy configurations, as users can still use the
`-use-color` option to explicitly enable color.

Fixes #49441 (50097 in Bugzilla)

Reviewed By: njames93

Differential Revision: https://reviews.llvm.org/D119562
2022-02-20 22:00:28 +00:00
Benjamin Kramer 3a1d6a361c [clangd] Remove uuidof warning. Clang never emits this one. 2022-02-20 14:44:47 +01:00
David Goldman 54a962bbfe [clangd] Use `ObjCProtocolLoc` for generalized ObjC protocol support
This removes clangd's existing workaround in favor of proper support
via the newly added `ObjCProtocolLoc`. This improves support by
allowing clangd to properly identify which protocol is selected
now that `ObjCProtocolLoc` gets its own ASTNode.

Differential Revision: https://reviews.llvm.org/D119366
2022-02-18 15:24:00 -05:00
Simon Pilgrim 9415fbbbcf [clangd] getHover - pass FormatStyle argument by const reference
Reported by coverity
2022-02-18 17:27:45 +00:00
Sam McCall 47b749e5be [clangd] Tweak --query-driver to ignore slash direction on windows
See https://github.com/clangd/clangd/issues/1022

Differential Revision: https://reviews.llvm.org/D120115
2022-02-18 18:06:36 +01:00
Simon Pilgrim 707157f248 Revert rGc24e197aaad5333717a27f6e4346f97da84821ed "[clangd] getHover - pass FormatStyle argument by const reference"
There are a number of buildbot build failures on non MSVC compilers
2022-02-18 14:59:57 +00:00
Simon Pilgrim c24e197aaa [clangd] getHover - pass FormatStyle argument by const reference
Reported by coverity
2022-02-18 14:45:51 +00:00
Simon Pilgrim 535e7b09c1 [clangd] lookupSiblingsWithinContext - remove unnecessary nullptr check
The DC pointer is always dereferenced after the loop
2022-02-18 11:12:53 +00:00
Brad Smith f374c8ddf2 [clangd] Fix building SerializationTests unit test on OpenBSD
This fixes building the unit tests on OpenBSD. OpenBSD does not support RLIMIT_AS.

Reviewed By: kadircet

Differential Revision: https://reviews.llvm.org/D119989
2022-02-17 12:17:12 -05:00
Simon Pilgrim 1c502c63cb [clang-doc] SerializeIndex - pass Index param by constant reference
Silence coverity warnings about unnecessary copies
2022-02-17 13:28:02 +00:00
Christopher Di Bella d7b1c840ba [clangd][NFC] includes missing headers
`Shutdown.h` was transitively depending on two headers, but this isn't
allowed under a modules build, so they're now explicitly included.

Differential Revision: https://reviews.llvm.org/D119806
2022-02-15 17:44:47 +00:00
Jan Svoboda 7a124f4859 [clang][lex] Remove `PPCallbacks::FileNotFound()`
The purpose of the `FileNotFound` preprocessor callback was to add the ability to recover from failed header lookups. This was to support downstream project.

However, injecting additional search path while performing header search can invalidate currently used iterators/references to `DirectoryLookup` in `Preprocessor` and `HeaderSearch`.

The downstream project ended up maintaining a separate patch to further tweak the functionality. Since we don't have any upstream users nor open source downstream users, I'd like to remove this callback for good to prevent future misuse. I doubt there are any actual downstream users, since the functionality is definitely broken at the moment.

Reviewed By: ahoppen

Differential Revision: https://reviews.llvm.org/D119708
2022-02-15 09:48:25 +01:00
Evgeny Shulgin fc84ebfff3 [clang-tidy] Ignore variable template partial specializations in `misc-definitions-in-headers`
Variable template partial specializations are inline and can't lead
to ODR-violations. The checker now ignores them.

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

Reviewed By: hokein

Differential Revision: https://reviews.llvm.org/D119098
2022-02-14 11:38:27 +01:00
Simon Pilgrim 5d1e3ed3e2 [clang-tidy] SimplifyBooleanExprCheck - use cast<> instead of dyn_cast<> to avoid dereference of nullptr
The IfStmt pointer is always referenced inside the replaceCompoundReturnWithCondition call, so assert the cast is correct instead of returning nullptr
2022-02-12 19:59:30 +00:00
Simon Pilgrim 7ad94bd74b [clang-tidy] ContainerSizeEmptyCheck::check - simplify isa<> and dyn_cast<> repeated calls
Just use dyn_cast<> to determine literal + container values from the binop
2022-02-12 11:31:27 +00:00
Simon Pilgrim 2188e61691 [clang-doc] populateParentNamespaces - use cast<> instead of dyn_cast<> to avoid dereference of nullptr
The pointer is referenced immediately, so assert the cast is correct instead of returning nullptr

It's only later iterations of the loop where the getParent() call might return nullptr
2022-02-12 11:28:50 +00:00
Simon Pilgrim 869c066ca8 [clang-tidy] RedundantControlFlowCheck::issueDiagnostic - use cast<> instead of dyn_cast<> to avoid dereference of nullptr
The pointer is referenced immediately, so assert the cast is correct instead of returning nullptr
2022-02-12 11:05:59 +00:00
Simon Pilgrim 9acba5206a [clang-tidy] FunctionASTVisitor::TraverseStmt - use cast<> instead of dyn_cast<> to avoid dereference of nullptr
The pointer is referenced immediately, so assert the cast is correct instead of returning nullptr
2022-02-12 11:04:20 +00:00
Simon Pilgrim ed5d659038 [clang-tidy] NoexceptMoveConstructorCheck::check - use castAs<> instead of getAs<> to avoid dereference of nullptr
The pointer is referenced immediately, so assert the cast is correct instead of returning nullptr
2022-02-12 10:57:09 +00:00
Simon Pilgrim 99acc0dc64 [clang-tidy] UseNoexceptCheck::check - use cast<> instead of dyn_cast<> to avoid dereference of nullptr
The pointer is referenced immediately, so assert the cast is correct instead of returning nullptr
2022-02-12 10:51:48 +00:00
Simon Pilgrim 003e038264 [clang-tidy] getOutermostNamespace - remove redundant nullptr check
The pointer is always dereferenced
2022-02-12 10:49:54 +00:00
Simon Pilgrim 5bc13f9d94 [clang-tidy] ProBoundsConstantArrayIndexCheck::check - use cast<> instead of dyn_cast<> to avoid dereference of nullptr
The pointer is referenced immediately, so assert the cast is correct instead of returning nullptr
2022-02-12 10:43:21 +00:00
Simon Pilgrim 389bee71ea [clang-tidy] checkOverridingFunctionReturnType - use castAs<> instead of getAs<> to avoid dereference of nullptr
The pointers are referenced immediately, so assert the cast is correct instead of returning nullptr
2022-02-12 10:41:43 +00:00
Kirill Bobyrev 100ec80ab5 [clang-tidy] Add early exit for defaulted FunctionDecls
This prevents matching of defaulted comparison operators.

Resolves: https://github.com/llvm/llvm-project/issues/53355

Author: Febbe (Fabian Keßler)
2022-02-10 20:29:26 +01:00
Christian Kandeler bd6c6974f5
clangd: Set a diagnostic on a code action resulting from a tweak
... if there is a match.
This is needed to that clients can can make a connection between a
diagnostic and an associated quickfix-tweak.
Ideally, quickfix-kind tweak code actions would be provided inline along
with the non-tweak fixes, but this doesn't seem easily achievable.

Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D118976
2022-02-10 15:58:12 +01:00
Greg Miller d038faea46 [clang-tidy] add option performance-move-const-arg.CheckMoveToConstRef
This option allows callers to disable the warning from
https://clang.llvm.org/extra/clang-tidy/checks/performance-move-const-arg.html
that would warn on the following

```
void f(const string &s);
string s;
f(std::move(s));  // ALLOWED if performance-move-const-arg.CheckMoveToConstRef=false
```

The reason people might want to disable this check, is because it allows
callers to use `std::move()` or not based on local reasoning about the
argument, and without having to care about how the function `f` accepts
the argument. Indeed, `f` might accept the argument by const-ref today,
but change to by-value tomorrow, and if the caller had moved the
argument that they were finished with, the code would work as
efficiently as possible regardless of how `f` accepted the parameter.

Reviewed By: ymandel

Differential Revision: https://reviews.llvm.org/D119370
2022-02-10 13:31:07 +00:00
Yuanfang Chen 4f30a52696 NFC: fix GCC warning -Wcast-qual 2022-02-09 18:03:25 -08:00
Jameson Nash 76cad51ba7 replace clang LLVM_ENABLE_PLUGINS -> CLANG_PLUGIN_SUPPORT in tests
Ensure CLANG_PLUGIN_SUPPORT is compatible with llvm_add_library.
Fixes an issue noted in D111100.

Differential Revision: https://reviews.llvm.org/D119199
2022-02-09 17:31:34 -05:00
Kirill Bobyrev 46a6f5ae14 [clangd] NFC: Move stdlib headers handling to Clang
This will allow moving the IncludeCleaner library essentials to Clang
and decoupling them from the majority of clangd.

The patch itself just moves the code, it doesn't change existing
functionality.

Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D119130
2022-02-09 11:05:39 +01:00
Corentin Jabot c151225096 [C++2b] Implement multidimentional subscript operator
Implement P2128R6 in C++23 mode.

Unlike GCC's implementation, this doesn't try to recover when a user
meant to use a comma expression.

Because the syntax changes meaning in C++23, the patch is *NOT*
implemented as an extension. Instead, declaring an array with not
exactly 1 parameter is an error in older languages modes. There is an
off-by-default extension warning in C++23 mode.

Unlike the standard, we supports default arguments;

Ie, we assume, based on conversations in WG21, that the proposed
resolution to CWG2507 will be accepted.

We allow arrays OpenMP sections and C++23 multidimensional array to
coexist:

[a , b] multi dimensional array
[a : b] open mp section
[a, b: c] // error

The rest of the patch is relatively straight forward: we take care to
support an arbitrary number of arguments everywhere.
2022-02-08 12:10:47 -05:00
Jesko Appelfeller 0851970af5 Make run-clang-tidy.py print the configured checks correctly
The test invocation at the start of run-clang-tidy.py (line 257) prints
all enabled checks - meaning either the default set or anything
configured via the -checks option. If any checks were (un-)configured
via the -config option, these are not printed. This is confusing to the
user, since the list of checks that are printed may be different from
the list of checks that are used by the non-testing calls to clang-tidy,
where the -config option is passed correctly.

This patch adds the -config option to the test invocation of clang-tidy
at the start of the script. This means that checks (un-)configured via
the -config option (rather than the -checks option) are applied
correctly, when printing the list of enabled checks.
2022-02-08 08:32:04 -05:00
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