Commit Graph

7985 Commits

Author SHA1 Message Date
Haojian Wu 94552f0216 [pseudo] Build inc files when cxx.bnf changes.
Add the cxx.bnf file as a dependency of custom gen commands, so that the
inc files can be rebuilt when cxx.bnf changes.
2022-06-01 13:48:09 +02:00
Endre Fülöp e290fcef11 [clang-tidy] Extend cert-oop57-cpp to check non-zero memset values
Clang Tidy check cert-oop57-cpp now checks for arbitrary-valued
arguments in memset expressions containing non-trivially
default-constructible instances. Previously it only checked literal 0 values.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D126186
2022-06-01 08:23:23 +02:00
Endre Fülöp 1c459a20ea Revert "[clang-tidy] Extend cert-oop57-cpp to check non-zero memset values"
Revert to fix a ReleaseNote issue.

This reverts commit d33f199910.
2022-06-01 08:21:16 +02:00
Endre Fülöp d33f199910 [clang-tidy] Extend cert-oop57-cpp to check non-zero memset values
Clang Tidy check cert-oop57-cpp now checks for arbitrary-valued
arguments in memset expressions containing non-trivially
default-constructible instances. Previously it only checked literal 0 values.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D126186
2022-06-01 08:15:03 +02:00
Yuki Okushi 5c14940394
[clangd] Remove a test with a duplicate of FileCacheTests
FIXME says it should be removed so followed it.

Differential Revision: https://reviews.llvm.org/D126608
2022-06-01 08:15:54 +09:00
Sam McCall 218393f44e Revert "[clangd] Fix hover crashing on integral or enumeral casts"
This reverts commit ce5ebf0b91.

Fails on bots e.g. https://buildkite-cloud.s3.amazonaws.com/logs-by-pipeline/f8ab115f-a384-49e8-a048-0f71ab03c5d0/0181020b-0737-40e5-a05a-ab198347d8ad/0181020b-ecbe-4ac6-ad23-e04c17217893.log?response-content-disposition=inline&response-content-type=text%2Fplain&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=ASIAQPCP3C7LT7IGTS76%2F20220531%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20220531T202904Z&X-Amz-Expires=600&X-Amz-Security-Token=IQoJb3JpZ2luX2Vj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7NRmG8HwtP40iTCjflOHIxkJ1%2FnVNqkeyIznUu6zOr589zIjNqFCm74jOfWjj2%2FO8WU4pc%2FRqeBuGzzpQkAIGGxCwsmd3WG8Z8pyMoJomij7c4LO6ep4O0OUESxbXHcIfzUfR6ajPsKFKS9lb&X-Amz-SignedHeaders=host&X-Amz-Signature=96a132be6f99b5cd5cf29f3226115e480508079047bc8639d69c672f1fe9f0c1
2022-05-31 22:30:20 +02:00
Georg Kotheimer ce5ebf0b91 [clangd] Fix hover crashing on integral or enumeral casts
When pretty printing the value of an expression, we cannot infer from
the type of the expression the type of the constant that the expression
evaluates to, as the expression might contain a type cast.
2022-05-31 22:05:23 +02:00
Sam McCall 9d991da60d [pseudo] Respect LLVM_USE_HOST_TOOLS
This is the intended way to request that build-time tools be built in a
distinct configuration.

This is set implicitly by LLVM_OPTIMIZED_TABLEGEN, which may be
surprising, but if undesired this should be fixed elsewhere.

Should fix crbug.com/1330304
2022-05-31 20:47:57 +02:00
David Goldman c797952d4f [clangd] Minor fixes to ExtractVariableTests missed in D124486 2022-05-31 11:34:35 -04:00
David Goldman ae67984ca6 [clangd] ExtractVariable support for C and Objective-C
- Use the expression's type for non-C++ as the variable type. This works
  well, but might not preserve the typedefs due to type
  canonicalization.

- Improve support for Objective-C property references which are
  represented using `ObjCPropertyRefExpr` and `BuiltinType::PseudoObject`.

Differential Revision: https://reviews.llvm.org/D124486
2022-05-31 11:14:51 -04:00
Haojian Wu a5ddd4a238 [pseudo] Remove an unnecessary nullable check diagnostic in the bnf
grammar, NFC.

This diagnostic has been handled in eliminateOptional.
2022-05-30 09:04:47 +02:00
Chuanqi Xu a544710cd4 [Driver] Enable to use C++20 standalne by -fcxx-modules
This patch allows user to use C++20 module by -fcxx-modules. Previously,
we could only use it under -std=c++20. Given that user could use C++20
coroutine standalonel by -fcoroutines-ts. It makes sense to offer an
option to use C++20 modules without enabling C++20.

Reviewed By: iains, MaskRay

Differential Revision: https://reviews.llvm.org/D120540
2022-05-30 14:19:56 +08:00
Sockke 3f3a235aa2 [clang-apply-replacements] Added an option to ignore insert conflict.
If two different texts are inserted at the same offset, clang-apply-replacements prints the conflict error and discards all fixes. This patch adds support for adjusting conflict offset and keeps running to continually fix them.

https://godbolt.org/z/P938EGoxj doesn't have any fixes when I run run-clang-tidy.py to generate a YAML file with clang-tidy and fix them with clang-apply-replacements. The YAML file has two different header texts insertions at the same offset, unlike clang-tidy with '-fix', clang-apply-replacements does not adjust for this conflict.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D123924
2022-05-30 13:02:25 +08:00
Sockke c98b3a8cd9 Fix `performance-unnecessary-value-param` for template specialization
The checker missed a check for parameter type of primary template of specialization template and this could cause build breakages.

Reviewed By: aaron.ballman, flx

Differential Revision: https://reviews.llvm.org/D116593
2022-05-30 09:55:53 +08:00
Shoaib Meenai 4baae166ce [pseudo] Fix pseudo-gen usage when cross-compiling
Use the LLVM build system's cross-compilation support for the tool, so
that the build works for both host and cross-compilation scenarios.

Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D126397
2022-05-25 11:08:21 -07:00
Nico Weber 788463e72a [pseudo-gen] Add -o flag, make --grammar required
Virtually all LLVM tools accept a `-o` flag, so add one. This will make it
possible to possibly add a --write-if-changed flag later. It also makes it
so that the file isn't partially written if the tool oesn't run successfully.

Marking --grammar as `Required` allows removing some manual
verification code for it.

Differential Revision: https://reviews.llvm.org/D126373
2022-05-25 09:11:42 -04:00
Nathan James 09ef6da8dc
[clang-tidy] Update docs for SimplifyDeMorganRelaxed
Forgot to add this to f3c1d28176
2022-05-25 13:12:20 +01:00
Nathan James f3c1d28176
[clang-tidy] Extend SimplifyBooleanExpr demorgan support.
Adds an option SimplifyDemorganRelaxed which, when enabled, will transform negated conjunctions or disjunctions when neither operand is a negation.
Default value is `false`.

Reviewed By: LegalizeAdulthood

Differential Revision: https://reviews.llvm.org/D126162
2022-05-25 13:09:00 +01:00
Haojian Wu f1df6515e3 [pseudo] Add missing dependency, fix shared library build. 2022-05-25 12:38:23 +02:00
Haojian Wu cd2292ef82 [pseudo] A basic implementation of compiling cxx grammar at build time.
The main idea is to compile the cxx grammar at build time, and construct
the core pieces (Grammar, LRTable) of the pseudoparse based on the compiled
data sources.

This is a tiny implementation, which is good for start:

- defines how the public API should look like;
- integrates the cxx grammar compilation workflow with the cmake system.
- onlynonterminal symbols of the C++ grammar are compiled, anything
  else are still doing the real compilation work at runtime, we can opt-in more
  bits in the future;
- splits the monolithic clangPsuedo library for better layering;

Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D125667
2022-05-25 11:26:06 +02:00
Salman Javed 9ff4f2dfea [clang-tidy] Fix #55134 (regression introduced by 5da7c04)
5da7c04 introduced a regression in the NOLINT macro checking loop, replacing the
call to `getImmediateExpansionRange().getBegin()` with
`getImmediateMacroCallerLoc()`, which has similar but subtly different
behaviour.

The consequence is that NOLINTs cannot suppress diagnostics when they are
attached to a token that came from a macro **argument**, rather than elsewhere
in the macro expansion.

Revert to pre-patch behaviour and add test cases to cover this issue.

Differential Revision: https://reviews.llvm.org/D126138
2022-05-25 11:30:58 +12:00
Nathan Ridge 175833ed6f [clangd] Handle '--' in QueryDriverDatabase
Fixes https://github.com/clangd/clangd/issues/1100,
a regression from D116721.

Differential Revision: https://reviews.llvm.org/D126274
2022-05-24 13:10:41 -04:00
Sam McCall 0360b9f159 [pseudo] (trivial) bracket-matching
Error-tolerant bracket matching enables our error-tolerant parsing strategies.
The implementation here is *not* yet error tolerant: this patch sets up the APIs
and plumbing, and describes the planned approach.

Differential Revision: https://reviews.llvm.org/D125911
2022-05-24 15:13:36 +02:00
usama hameed 63ecb7dcc8 bugfix in InfiniteLoopCheck to not print warnings for unevaluated loops
Added a separate check for unevaluated statements. Updated InfiniteLoopCheck to use new check

Differential Revision: https://reviews.llvm.org/D126246
2022-05-23 20:18:49 -07:00
usama hameed 602682225a bugfix in InfiniteLoopCheck to not print warnings for unevaluated loops
Differential Revision: https://reviews.llvm.org/D126034
2022-05-23 20:18:48 -07:00
Richard 89e663c4f8 [clang-tidy] Improve add_new_check.py to recognize more checks
When looking for whether or not a check provides fixits, the script
examines the implementation of the check.  Some checks are not
implemented in source files that correspond one-to-one with the check
name, e.g. cert-dcl21-cpp.  So if we can't find the check implementation
directly from the check name, open up the corresponding module file and
look for the class name that is registered with the check.  Then consult
the file corresponding to the class name.

Some checks are derived from a base class that implements fixits.  So if
we can't find fixits in the implementation file for a check, scrape out
the name of it's base class.  If it's not ClangTidyCheck, then consult
the base class implementation to look for fixit support.

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

Fixes #55630
2022-05-23 09:47:54 -06:00
Nathan James 9d0d24eec4
[clang-tidy] Fix not updating storeOptions after af77b1d990 2022-05-22 10:28:52 +01:00
Nathan James af77b1d990
[clang-tidy] add support for Demorgan conversions to readability-simplify-bool-expr
Adds support for recognising and converting boolean expressions that can be simplified using De Morgans Law.

This is a different implementation to D124650.

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

Reviewed By: LegalizeAdulthood

Differential Revision: https://reviews.llvm.org/D124806
2022-05-22 09:28:43 +01:00
Balazs Benics ecf5924eb4 [clang-tidy] Add a useful note about -std=c++11-or-later
I and @whisperity spent some time debugging a LIT test case using the
`-std=c++11-or-later` `check_clang_tidy.py` flag when the test had
fixits.

It turns out if the test wants to report a diagnostic into a header
file AND into the test file as well, one needs to first copy the header
somewhere under the build directory.
It needs to be copied since `clang-tidy` sorts the reports into
alphabetical order, thus to have a deterministic order relative to the
diagnostic in the header AND the diagnostic in the test cpp file.

There is more to this story.

The `-std=c++11-or-later` turns out executes the test with multiple
`-std=XX` version substitution, and each execution will also have the
`-fix` tidy parameter. This means that the freshly copied header file I
stated in the previous paragraph gets fixed up and the very next tidy
execution will fail miserably.

Following @whisperity's advice, I'm leaving a reminder about such
//shared// state in the related doc comment.

Reviewed By: LegalizeAdulthood

Differential Revision: https://reviews.llvm.org/D125771
2022-05-21 22:16:55 +02:00
Balazs Benics 6fa82e344c [clang-tidy] modernize-deprecated-headers should ignore system headers
The end-user has no way of 'fixing' bugs in the system library anyway.
Let's suppress these as well.

Reviewed By: LegalizeAdulthood

Differential Revision: https://reviews.llvm.org/D125770
2022-05-20 21:41:25 +02:00
Balazs Benics 0606467ea1 [clang-tidy] Introduce the WarnIntoHeaders option to modernize-deprecated-headers
Unfortunately, we must restrict the checker to warn for deprecated headers
only if the header is included directly from a c++ source file.

For header files, we cannot know if the project has a C source file
that also directly/indirectly includes the offending header file
otherwise. Thus, it's better to be on the safe side and suppress those
reports.

One can opt-in the old behavior, emitting diagnostics into header files,
if one explicitly sets the WarnIntoHeaders=true, in which case nothing
will be changed.

Reviewed By: LegalizeAdulthood

Differential Revision: https://reviews.llvm.org/D125769
2022-05-20 21:41:25 +02:00
Balazs Benics 665bfbb98d Reland "[clang-tidy] modernize-deprecated-headers check should respect extern "C" blocks""
This partially reverts commit e8cae48702.
Changes since that commit:
 - Use `SourceManager::isBeforeInTranslationUnit` instead of the fancy
   decomposed decl logarithmic search.
 - Add a test for including a system header containing a deprecated
   include.
 - Add `REQUIRES: system-linux` clause to the test.

Reviewed By: LegalizeAdulthood, whisperity

Differential Revision: https://reviews.llvm.org/D125209
2022-05-20 21:12:39 +02:00
Sam McCall 1fef69da0b
Avoid uninitialized Diag.ID (which we pass but never read) 2022-05-20 20:29:47 +02:00
David Goldman 322e2a3b40 [clangd][ObjC] Filter ObjC method completions on the remaining selector
Previously, clangd would filter completions only on the first part of
the selector (first typed chunk) instead of all remaining selector
fragments (all typed chunks).

Differential Revision: https://reviews.llvm.org/D124637
2022-05-20 11:49:16 -04:00
Sam McCall edc7a08145 [clangd] Provide links to clang-tidy and include-cleaner diagnostic docs
LSP supports Diagnostic.codeInformation since 3.16.
In VSCode, this turns the code (e.g. "unused-includes" or "bugprone-foo") into
a clickable link that opens the docs in a web browser.

Differential Revision: https://reviews.llvm.org/D126065
2022-05-20 16:33:48 +02:00
Haojian Wu 5b0022a9df [clangd] Support UnresolvedUsingTypeLoc AST node in FindTarget.
to make features like hover, go-to-def work when the cursor is on the
UnresolvedUsingTypeLoc.

Differential Revision: https://reviews.llvm.org/D125684
2022-05-20 14:54:17 +02:00
Utkarsh Saxena 5bbf6ad5b6 Add an option to fill container for ref
This allows index implementations to fill container details when required specially when computing containerID is expensive.

Differential Revision: https://reviews.llvm.org/D125925
2022-05-19 16:05:38 +02:00
Kirill Bobyrev 4f5a4215bf
[clangd] Update the test after diagnostic message change 2022-05-19 12:03:31 +02:00
Kirill Bobyrev 43c0f90dd6
[clangd] NFC: Clarify the Include Cleaner warning 2022-05-19 11:59:00 +02:00
Sam McCall 4f35ca59d0 [clangd] Suppress warning: control reaches end of function 2022-05-19 08:26:13 +02:00
Sam McCall cd387e43bf [pseudo] Squash some warnings. NFC
Explicitly sizing Kind enum suggests that too-large values are allowed,
and that putting it in a bitfield is dangerous.

GCC doesn't like condition ? integer : enum.
2022-05-19 08:20:12 +02:00
Sam McCall 07c6635901 [clang-tidy] Fix logic of assertion 2022-05-19 08:13:23 +02:00
Sam McCall 03ea140b3a Reland(3) "[clangd] Indexing of standard library"
Tracked down the crash, which was argument-evaluation-order UB
in the wrapping indexStandardLibrary().
Sorry for the churn!

This reverts commit 77533ea443.
2022-05-19 08:13:23 +02:00
Nathan James 35660247dd
[clang-tidy] Fix readability-simplify-boolean-expr when Ifs have an init statement or condition variable
Fixes https://github.com/llvm/llvm-project/issues/55553.

Reviewed By: LegalizeAdulthood

Differential Revision: https://reviews.llvm.org/D125874
2022-05-18 20:47:37 +01:00
Nathan James 4739176fd3
[clang-tidy] Fix readability-simplify-boolean-expr crash with implicit cast in return.
Fixes https://github.com/llvm/llvm-project/issues/55557

Reviewed By: LegalizeAdulthood

Differential Revision: https://reviews.llvm.org/D125877
2022-05-18 17:38:44 +01:00
Sam McCall 77533ea443 Revert "Reland(2) "[clangd] Indexing of standard library""
This reverts commit ca875539f7.
2022-05-18 17:38:45 +02:00
Sam McCall ca875539f7 Reland(2) "[clangd] Indexing of standard library"
This reverts commit 6aabf60f2f.
2022-05-18 15:30:37 +02:00
Sam McCall 79ca4ed3e7 [pseudo] Design notes from discussion today. NFC 2022-05-18 00:08:47 +02:00
Sam McCall 6aabf60f2f Revert "Reland "[clangd] Indexing of standard library""
This reverts commit ccdb56ac10.

Still seeing windows failures on GN bots: http://45.33.8.238/win/58316/step_9.txt

Unfortunately I can't debug these at all - it's a bare unsymbolized
stacktrace, and I can't reproduce the failure.
2022-05-17 21:33:48 +02:00
Sam McCall ccdb56ac10 Reland "[clangd] Indexing of standard library"
This reverts commit 76ddbb1ca7.
2022-05-17 21:02:23 +02:00