Commit Graph

10532 Commits

Author SHA1 Message Date
Erick Velez
441b967ad9 [clang-doc] fix names of conversions for template parameters (#140856)
Fixes #59812

The names of conversion functions of template type parameters were being
emitted as "type-parameter-N-M". Now we check if the conversion type is
a TemplateTypeParmType and reconstruct the source name.
2025-05-23 19:35:32 +00:00
Paul Kirth
524ef164a7 [clang-doc] Avoid reading files in unit tests (#141269)
In #138062 it was brought up that this was an anti-pattern. We'll need
to Migrate all of the mustache unittests that need to read template 
files to lit tests, and disable them until tool support lands.
2025-05-23 11:47:20 -07:00
Daan De Meyer
5ff175233e [clang-tools-extra] Add include mappings for <sys/uio.h> (#141216) 2025-05-23 16:40:28 +02:00
Kazu Hirata
05674b21fe [clang-tidy] Use std:::string::find with std::string_view (NFC) (#141188)
std::string::rfind accepts anything that can be converted to
std::string_view starting in C++17.  Since StringRef can be converted
to std::string_view, we do not need to create a temporary instance of
std::string here.
2025-05-22 23:50:55 -07:00
Erick Velez
8268794cc5 [clang-doc] Precommit test for correct conversion function names (#141168) 2025-05-23 02:05:52 +00:00
Jie Fu
34e63be925 [clang-doc] Prevent copying loop variables (NFC)
/llvm-project/clang-tools-extra/clang-doc/HTMLMustacheGenerator.cpp:86:19:
error: loop variable '[Name, FileName]' creates a copy from type 'std::pair<llvm::StringRef, llvm::StringRef> const' [-Werror,-Wrange-loop-construct]
  for (const auto [Name, FileName] : Partials)
                  ^
/llvm-project/clang-tools-extra/clang-doc/HTMLMustacheGenerator.cpp:86:8:
note: use reference type 'std::pair<llvm::StringRef, llvm::StringRef> const &' to prevent copying
  for (const auto [Name, FileName] : Partials)
       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                  &
1 error generated.
2025-05-23 09:00:19 +08:00
Paul Kirth
97dee78eb3 [clang-doc] Add helpers for Template config (#138062)
This patch adds or fills in some helper functions related to template
setup when initializing the mustache backend. It was split from #133161.

Co-authored-by: Peter Chou <peter.chou@mail.utoronto.ca>
2025-05-22 14:20:08 -07:00
Jan Svoboda
656d9ba934 [clang] Fix LogDiagnosticPrinter.h and ClangTidyPlugin.cpp after 9e306ad4 (#141131) 2025-05-22 13:39:54 -07:00
Jan Svoboda
13e1a2cb22 Reapply "[clang] Remove intrusive reference count from DiagnosticOptions (#139584)"
This reverts commit e2a885537f. Build failures were fixed right away and reverting the original commit without the fixes breaks the build again.
2025-05-22 12:52:03 -07:00
Kazu Hirata
e2a885537f Revert "[clang] Remove intrusive reference count from DiagnosticOptions (#139584)"
This reverts commit 9e306ad460.

Multiple builtbot failures have been reported:
https://github.com/llvm/llvm-project/pull/139584
2025-05-22 12:44:20 -07:00
Jan Svoboda
b544853fc3 [clang] Fix VirtualFileHelper.h after 9e306ad4 2025-05-22 12:42:35 -07:00
Jan Svoboda
9e306ad460 [clang] Remove intrusive reference count from DiagnosticOptions (#139584)
The `DiagnosticOptions` class is currently intrusively
reference-counted, which makes reasoning about its lifetime very
difficult in some cases. For example, `CompilerInvocation` owns the
`DiagnosticOptions` instance (wrapped in `llvm::IntrusiveRefCntPtr`) and
only exposes an accessor returning `DiagnosticOptions &`. One would
think this gives `CompilerInvocation` exclusive ownership of the object,
but that's not the case:

```c++
void shareOwnership(CompilerInvocation &CI) {
  llvm::IntrusiveRefCntPtr<DiagnosticOptions> CoOwner = &CI.getDiagnosticOptions();
  // ...
}
```

This is a perfectly valid pattern that is being actually used in the
codebase.

I would like to ensure the ownership of `DiagnosticOptions` by
`CompilerInvocation` is guaranteed to be exclusive. This can be
leveraged for a copy-on-write optimization later on. This PR changes
usages of `DiagnosticOptions` across `clang`, `clang-tools-extra` and
`lldb` to not be intrusively reference-counted.
2025-05-22 12:33:52 -07:00
Daan De Meyer
dabc84c890 [clang-tools-extra] Add include mappings for getopt.h (#140726) 2025-05-21 16:41:44 +02:00
Daan De Meyer
c46a394df9 [clang-tidy] Add UnusedIncludes/MissingIncludes options to misc-include-cleaner (#140600)
These mimick the same options from clangd and allow using the check to
only check for unused includes or missing includes.
2025-05-21 16:41:04 +02:00
Daan De Meyer
32946ddd2e [clang-include-cleaner] Make cleanup attr report expr location (#140233)
Instead of reporting the location of the attribute, let's report the
location of the function reference that's passed to the cleanup
attribute as the first argument. This is required as the attribute might
be coming from a macro which means clang-include-cleaner skips the use
as it gets attributed to the header file declaringt the macro and not to
the main file.

To make this work, we have to add a fake argument to the CleanupAttr
constructor so we can pass in the original Expr alongside the function
declaration.

Fixes #140212
2025-05-21 16:40:30 +02:00
Baranov Victor
64dcf78935 [clang-tidy][NFC] Refactor modernize-pass-by-value check code and tests (#140753)
- Deleted unused includes
- Deleted useless braces
- Modernized tests to use `CHECK-MESSAGES-NOT` and `CHECK-FIXES-NOT` for
better readability and maintainability
2025-05-21 10:34:45 +02:00
Kazu Hirata
5bd3c44b79 [clang-tools-extra] Remove redundant control flow statements (NFC) (#140846) 2025-05-21 00:29:17 -07:00
Jan Svoboda
72b2219b3e Revert "[clang][modules] Timestamp-less validation API (#139987)"
This reverts commit 7a242387c9. Even after 175f8a44, the Modules/fmodules-validate-once-per-build-session.c test is not fixed on the clang-armv8-quick build bot. (Failure occurs on line 114.)
2025-05-19 12:57:54 -07:00
Carlos Galvez
322d0197f5 [clang-tidy] Do not flag strerror in concurrency-mt-unsafe (#140520)
The docs of the check state:

> Glibc’s list is compiled from GNU web documentation with a search for
MT-Safe tag

And strerror fulfills exactly that:
https://www.gnu.org/software/libc/manual/html_node/Error-Messages.html

> Function: char * strerror (int errnum)
> Preliminary: | MT-Safe | AS-Unsafe heap i18n | AC-Unsafe mem | See
POSIX Safety Concepts.

So concurrency-mt-unsafe should not flag it.

Fixes #140515

---------

Co-authored-by: Carlos Gálvez <carlos.galvez@zenseact.com>
Co-authored-by: EugeneZelenko <eugene.zelenko@gmail.com>
2025-05-19 21:27:37 +02:00
Jan Svoboda
7a242387c9 Reland "[clang][modules] Timestamp-less validation API (#139987)"
This reverts commit 18b885f66b, effectively reapplying #139987. This commit fixes unit tests (for example ASTUnitTest.SaveLoadPreservesLangOptionsInPrintingPolicy) where the `ASTUnit::ModCache` pointer dereferenced within `ASTUnit::serialize()` was null. This commit makes sure each factory function does initialize `ASTUnit::ModCache`.
2025-05-19 10:40:55 -07:00
Kazu Hirata
9384e8e63c [clang-tools-extra] Use llvm::max_element (NFC) (#140458) 2025-05-18 09:46:39 -07:00
Kazu Hirata
04c73adfe2 [clang-tools-extra] Use llvm::is_contained (NFC) (#140456) 2025-05-18 09:46:15 -07:00
Kazu Hirata
1a40edf2c0 [clang-tools-extra] Use llvm::find_if (NFC) (#140411) 2025-05-17 17:01:37 -07:00
Kazu Hirata
c0ca030782 [clang-include-fixer] Remove an unused "using" decl (NFC) (#140354)
We do use MappingTraits in this file, but all uses are inside the
llvm::yaml namespace, so we don't rely on the "using" decl.
2025-05-17 17:00:40 -07:00
Balázs Kéri
d84b97ebb3 [clang-tidy] Add check bugprone-misleading-setter-of-reference (#132242) 2025-05-17 10:26:13 +02:00
Paul Kirth
6a0e626af5 [clang-doc] Add HTMLMustacheGenerator methods (#138061)
Split from #133161. This patch fills in the implementation for a number
of the MustacheHTMLGenerator methods. Many of these APIs are just
stubbed out, and will have their implementation filled in by later
patches.

Co-authored-by: Peter Chou <peter.chou@mail.utoronto.ca>
2025-05-16 17:30:45 -07:00
Kazu Hirata
589e7abea5 [clang-tidy] Use std::binary_search (NFC) (#140263) 2025-05-16 09:06:17 -07:00
Kazu Hirata
ab1fea49e2 [clang-tools-extra] Use llvm::replace (NFC) (#140200) 2025-05-16 07:30:46 -07:00
Zahira Ammarguellat
38e0f983ad [CLANGD] [NFC] Fix proposed by static analyzer. (#140116)
This fixes an issue reported by the sanitizer with the following error
message:
`copy_constructor_call: IndexOpts` is passed by value as a parameter to`
clang::index::IndexingOptions::IndexingOptions` instead of being moved.
2025-05-16 07:56:36 -04:00
Qinkun Bao
18b885f66b Revert "[clang][modules] Timestamp-less validation API" (#139987)
Reverts llvm/llvm-project#138983
2025-05-14 21:02:57 -04:00
Jan Svoboda
960afcc90e [clang][modules] Timestamp-less validation API (#138983)
Timestamps are an implementation detail of the cross-process module
cache implementation. This PR hides it from the `ModuleCache` API, which
simplifies the in-process implementation.
2025-05-14 14:31:23 -07:00
Kazu Hirata
ac583df03b [include-cleaner] Use heterogeneous lookups (NFC) (#139685)
Heterogenous lookups allow us to call find with StringRef, avoiding a
temporary heap allocation of std::string.
2025-05-13 07:13:25 -07:00
Daan De Meyer
cdbc297ef5 include-cleaner: Report function decls from __cleanup__ as used (#138669) 2025-05-13 10:22:32 +02:00
Kazu Hirata
75e0865837 [clang-tools-extra] Use llvm::unique (NFC) (#139663) 2025-05-12 23:24:24 -07:00
Paul Kirth
3bdfa6f3e8 [clang-doc] Add HTMLMustacheGenerator.cpp (#138060)
Split from #133161. This patch adds HTMLMustacheGenerator.cpp, and
the most basic class defintion for the generator. Future patches will
add functionality.

Co-authored-by: Peter Chou <peter.chou@mail.utoronto.ca>
2025-05-12 18:54:04 -07:00
Noustaa
bfd2ef7659 [clangd] Add CodePatterns config option under Completion (#137613)
Allows enabling/disabling code pattern & snippet suggestions
during code completion.

Resolves https://github.com/clangd/clangd/discussions/1867
2025-05-12 14:22:27 -04:00
Kazu Hirata
841d2e59bb [clangd] Use StringRef::consume_back_insensitive (NFC) (#139456) 2025-05-11 09:45:16 -07:00
Kazu Hirata
066bc49f76 [modularize] Use std::tie to implement operator< (NFC) (#139410) 2025-05-10 20:01:28 -07:00
Kazu Hirata
8e9da213ea [clang-tidy] Use StringRef::consume_back (NFC) (#139412) 2025-05-10 16:05:45 -07:00
Bart Louwers
89273e9d17 [NFC][clang-tidy][docs] Fix spelling error for bugprone-crtp-constructor-accessibility (#139307) 2025-05-10 17:07:37 -04:00
Kazu Hirata
e0dfc49852 [modularize] Use a range-based for loop (NFC) (#139398) 2025-05-10 11:03:27 -07:00
Kazu Hirata
0c83a0b7f4 [modularize] Use default member initialization for Location (NFC) (#139384) 2025-05-10 09:45:56 -07:00
Kazu Hirata
4b6762b0d4 [clang-tools-extra] Remove unused local variables (NFC) (#139382) 2025-05-10 09:30:54 -07:00
Aaron Ballman
7548cec16f [www][docs] Remove last mentions of IRC (#139076)
It's the end of an era. The IRC channel was previously where the
community gathered to discuss technical topics but is now a ghost town
where the primary activity is moderators (me) kickbanning the same
individual dozens of times a day for CoC violations and the secondary
activity is telling the occasional person to come to Discord for help.
The number of people engaging on IRC for the community's intended
purposes seems to be roughly one person a month.

So this removes all remaining mentions of IRC from our documentation so
that it no longer appears to be an "official" channel for communicating
with the community. It also removes IRC handles from the various
maintainers lists, since those would stand out as confusing
anachronisms.

The IRC channel topic already recommends people come to the Discord
server. There is no way to "shut down" an IRC channel such that it no
longer exists, so the channel will continue to exist on OFTC, but will
be unmoderated.

(This was previously discussed in https://discourse.llvm.org/c/llvm/5
but some mentions persisted.)
2025-05-08 09:40:33 -04:00
Paul Kirth
59a73bdbc4 [clang-doc] Add missing comment for Base (#138053) 2025-05-07 16:24:27 -07:00
Paul Kirth
83e1f34c1c [clang-doc][NFC] Add TODO for future work (#138052) 2025-05-07 16:24:02 -07:00
Yanzuo Liu
b7db2e1fc0 [Clang-Tidy][NFC] Simplify check cppcoreguidelines-missing-std-forward (#138504)
Remove `CaptureInCopy` because the cases handled by it are covered by
`CaptureByRefExplicit`.
2025-05-07 21:39:31 +02:00
Paul Kirth
22d10f0a50 [clang-doc] Add Mustache template assets (#138059)
This patch adds the various assets used with the HTML Mustache backend.
This includes templates for a variety of different language constructs,
as well as the CSS. Split from #133161.

Co-authored-by: Peter Chou <peter.chou@mail.utoronto.ca>
2025-05-06 20:31:54 -07:00
Kazu Hirata
5d305b618f [clang-tools-extra] Remove redundant calls to std::unique_ptr<T>::get (NFC) (#138774) 2025-05-06 20:16:54 -07:00
Paul Kirth
796652dfc1 [clang-doc] Track Descriptions and TypeDeclaration for types (#138058)
Split from #133161. This patch allows Typedefs to now track both their
declarations and full descriptions. Subsequent patches will leverage the
additional fields in the representation.

Co-authored-by: Peter Chou <peter.chou@mail.utoronto.ca>
2025-05-06 20:16:17 -07:00