Skip to content

Commit f5f5a9a

Browse files
Merge branch 'llvm:main' into select-case-hlfir-cmpchar
2 parents e994e69 + 7ca737d commit f5f5a9a

File tree

372 files changed

+36144
-36378
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

372 files changed

+36144
-36378
lines changed

.git-blame-ignore-revs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,3 +143,12 @@ a3a007ad5fa20abc90ead4e1030b481bf109b4cf
143143
b7e332d3f59f567b1999fbcc660d7837cba8e406
144144
6056f942abe83b05406df8b04e95ec37a3d160b5
145145
906295b8a31c8dac5aa845864c0bca9f02f86184
146+
147+
# [clang-tidy][NFC] Remove trailing whitespaces in documentation
148+
8f2b167de4a1268160c06512d08863a9e8f43290
149+
150+
# [clang-tidy][NFC] Enforce 80 characters limit in docs
151+
5edf70c41c5d69f3751b4199f642f4585599dade
152+
c73870dbe89a8219130e21a0b3f13df76d299352
153+
74c40293c309dbd142bf1f0ebfbfde6be8d30655
154+
a7ba8dcad76476478100c228a31d9c48391b1e03

clang-tools-extra/clang-doc/assets/class-template.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@
174174
<h2>Public Methods</h2>
175175
<div>
176176
{{#PublicFunctions}}
177-
{{>FunctionPartial}}
177+
{{>FunctionPartial}}
178178
{{/PublicFunctions}}
179179
</div>
180180
</section>

clang-tools-extra/clang-doc/assets/comment-template.mustache

Lines changed: 42 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -6,61 +6,61 @@
66
This file defines templates for generating comments
77
}}
88
{{#BriefComments}}
9-
<div>
10-
{{#.}}
11-
<p>{{TextComment}}</p>
12-
{{/.}}
13-
</div>
9+
<div>
10+
{{#.}}
11+
<p>{{TextComment}}</p>
12+
{{/.}}
13+
</div>
1414
{{/BriefComments}}
1515
{{#ParagraphComments}}
16-
<div>
17-
{{#.}}
18-
<p>{{TextComment}}</p>
19-
{{/.}}
20-
</div>
16+
<div>
17+
{{#.}}
18+
<p>{{TextComment}}</p>
19+
{{/.}}
20+
</div>
2121
{{/ParagraphComments}}
2222
{{#ParagraphComment}}
23-
{{#Children}}
24-
{{>Comments}}
25-
{{/Children}}
23+
{{#Children}}
24+
{{TextComment}}
25+
{{/Children}}
2626
{{/ParagraphComment}}
2727
{{#HasParamComments}}
28-
<h3>Parameters</h3>
29-
{{#ParamComments}}
30-
<div>
31-
<b>{{ParamName}}</b> {{#Explicit}}{{Direction}}{{/Explicit}} {{#Children}}{{>Comments}}{{/Children}}
32-
</div>
33-
{{/ParamComments}}
28+
<h3>Parameters</h3>
29+
{{#ParamComments}}
30+
<div>
31+
<b>{{ParamName}}</b> {{#Explicit}}{{Direction}}{{/Explicit}} {{#Children}}{{TextComment}}{{/Children}}
32+
</div>
33+
{{/ParamComments}}
3434
{{/HasParamComments}}
3535
{{#HasReturnComments}}
36-
<h3>Returns</h3>
37-
{{#ReturnComments}}
38-
{{#.}}
39-
<p>{{TextComment}}</p>
40-
{{/.}}
41-
{{/ReturnComments}}
36+
<h3>Returns</h3>
37+
{{#ReturnComments}}
38+
{{#.}}
39+
<p>{{TextComment}}</p>
40+
{{/.}}
41+
{{/ReturnComments}}
4242
{{/HasReturnComments}}
4343
{{#HasCodeComments}}
44-
<h3>Code</h3>
45-
{{#CodeComments}}
46-
<div>
47-
<pre class="code-block">
48-
<code>
49-
{{#.}}
44+
<h3>Code</h3>
45+
{{#CodeComments}}
46+
<div>
47+
<pre class="code-block">
48+
<code>
49+
{{#.}}
5050
{{.}}
51-
{{/.}}
52-
</code>
53-
</pre>
54-
</div>
55-
{{/CodeComments}}
51+
{{/.}}
52+
</code>
53+
</pre>
54+
</div>
55+
{{/CodeComments}}
5656
{{/HasCodeComments}}
5757
{{#HasThrowsComments}}
58-
<h3>Throws</h3>
59-
{{#ThrowsComments}}
60-
<div>
61-
<b>{{Exception}}</b> {{#Children}}{{TextComment}}{{/Children}}
62-
</div>
63-
{{/ThrowsComments}}
58+
<h3>Throws</h3>
59+
{{#ThrowsComments}}
60+
<div>
61+
<b>{{Exception}}</b> {{#Children}}{{TextComment}}{{/Children}}
62+
</div>
63+
{{/ThrowsComments}}
6464
{{/HasThrowsComments}}
6565
{{#BlockCommandComment}}
6666
<div class="block-command-comment__command">
@@ -74,8 +74,3 @@
7474
</div>
7575
</div>
7676
{{/BlockCommandComment}}
77-
{{#TextComment}}
78-
<div>
79-
<p>{{TextComment}}</p>
80-
</div>
81-
{{/TextComment}}

clang-tools-extra/clang-doc/assets/function-template.mustache

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,7 @@
88
<div class="delimiter-container">
99
<div id="{{USR}}">
1010
{{! Function Prototype }}
11-
<pre>
12-
<code class="language-cpp code-clang-doc">
13-
{{ReturnType.Name}} {{Name}} ({{#Params}}{{^End}}{{Type}} {{Name}}, {{/End}}{{#End}}{{Type}} {{Name}}{{/End}}{{/Params}})
14-
</code>
15-
</pre>
11+
<pre><code class="language-cpp code-clang-doc">{{ReturnType.Name}} {{Name}} ({{#Params}}{{^End}}{{Type}} {{Name}}, {{/End}}{{#End}}{{Type}} {{Name}}{{/End}}{{/Params}})</code></pre>
1612
{{! Function Comments }}
1713
{{#Description}}
1814
<div>

clang-tools-extra/clang-tidy/readability/DuplicateIncludeCheck.cpp

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@
77
//===----------------------------------------------------------------------===//
88

99
#include "DuplicateIncludeCheck.h"
10+
#include "../utils/OptionsUtils.h"
1011
#include "clang/Frontend/CompilerInstance.h"
1112
#include "clang/Lex/Preprocessor.h"
1213
#include "llvm/ADT/STLExtras.h"
1314
#include "llvm/ADT/SmallVector.h"
15+
#include "llvm/Support/Regex.h"
1416
#include <memory>
1517

1618
namespace clang::tidy::readability {
@@ -33,11 +35,8 @@ using FileList = SmallVector<StringRef>;
3335
class DuplicateIncludeCallbacks : public PPCallbacks {
3436
public:
3537
DuplicateIncludeCallbacks(DuplicateIncludeCheck &Check,
36-
const SourceManager &SM)
37-
: Check(Check), SM(SM) {
38-
// The main file doesn't participate in the FileChanged notification.
39-
Files.emplace_back();
40-
}
38+
const SourceManager &SM,
39+
llvm::ArrayRef<StringRef> IgnoredList);
4140

4241
void FileChanged(SourceLocation Loc, FileChangeReason Reason,
4342
SrcMgr::CharacteristicKind FileType,
@@ -62,10 +61,31 @@ class DuplicateIncludeCallbacks : public PPCallbacks {
6261
SmallVector<FileList> Files;
6362
DuplicateIncludeCheck &Check;
6463
const SourceManager &SM;
64+
SmallVector<llvm::Regex> AllowedRegexes;
6565
};
6666

6767
} // namespace
6868

69+
DuplicateIncludeCheck::DuplicateIncludeCheck(StringRef Name,
70+
ClangTidyContext *Context)
71+
: ClangTidyCheck(Name, Context),
72+
IgnoredFilesList(utils::options::parseStringList(
73+
Options.get("IgnoredFilesList", ""))) {}
74+
75+
DuplicateIncludeCallbacks::DuplicateIncludeCallbacks(
76+
DuplicateIncludeCheck &Check, const SourceManager &SM,
77+
llvm::ArrayRef<StringRef> IgnoredList)
78+
: Check(Check), SM(SM) {
79+
// The main file doesn't participate in the FileChanged notification.
80+
Files.emplace_back();
81+
82+
AllowedRegexes.reserve(IgnoredList.size());
83+
for (const StringRef &It : IgnoredList) {
84+
if (!It.empty())
85+
AllowedRegexes.emplace_back(It);
86+
}
87+
}
88+
6989
void DuplicateIncludeCallbacks::FileChanged(SourceLocation Loc,
7090
FileChangeReason Reason,
7191
SrcMgr::CharacteristicKind FileType,
@@ -78,14 +98,18 @@ void DuplicateIncludeCallbacks::FileChanged(SourceLocation Loc,
7898

7999
void DuplicateIncludeCallbacks::InclusionDirective(
80100
SourceLocation HashLoc, const Token &IncludeTok, StringRef FileName,
81-
bool IsAngled, CharSourceRange FilenameRange, OptionalFileEntryRef File,
101+
bool IsAngled, CharSourceRange FilenameRange, OptionalFileEntryRef /*File*/,
82102
StringRef SearchPath, StringRef RelativePath, const Module *SuggestedModule,
83103
bool ModuleImported, SrcMgr::CharacteristicKind FileType) {
84104
// Skip includes behind macros
85105
if (FilenameRange.getBegin().isMacroID() ||
86106
FilenameRange.getEnd().isMacroID())
87107
return;
88108
if (llvm::is_contained(Files.back(), FileName)) {
109+
if (llvm::any_of(AllowedRegexes, [&FileName](const llvm::Regex &R) {
110+
return R.match(FileName);
111+
}))
112+
return;
89113
// We want to delete the entire line, so make sure that [Start,End] covers
90114
// everything.
91115
const SourceLocation Start =
@@ -111,7 +135,13 @@ void DuplicateIncludeCallbacks::MacroUndefined(const Token &MacroNameTok,
111135

112136
void DuplicateIncludeCheck::registerPPCallbacks(
113137
const SourceManager &SM, Preprocessor *PP, Preprocessor *ModuleExpanderPP) {
114-
PP->addPPCallbacks(std::make_unique<DuplicateIncludeCallbacks>(*this, SM));
138+
PP->addPPCallbacks(
139+
std::make_unique<DuplicateIncludeCallbacks>(*this, SM, IgnoredFilesList));
140+
}
141+
142+
void DuplicateIncludeCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
143+
Options.store(Opts, "IgnoredFilesList",
144+
utils::options::serializeStringList(IgnoredFilesList));
115145
}
116146

117147
} // namespace clang::tidy::readability

clang-tools-extra/clang-tidy/readability/DuplicateIncludeCheck.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,16 @@ namespace clang::tidy::readability {
1919
/// directives between them are analyzed.
2020
class DuplicateIncludeCheck : public ClangTidyCheck {
2121
public:
22-
DuplicateIncludeCheck(StringRef Name, ClangTidyContext *Context)
23-
: ClangTidyCheck(Name, Context) {}
22+
DuplicateIncludeCheck(StringRef Name, ClangTidyContext *Context);
2423

2524
void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
2625
Preprocessor *ModuleExpanderPP) override;
26+
void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
27+
28+
private:
29+
// Semicolon-separated list of regexes or file names to ignore from duplicate
30+
// warnings.
31+
const std::vector<StringRef> IgnoredFilesList;
2732
};
2833

2934
} // namespace clang::tidy::readability

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,11 @@ Changes in existing checks
527527
ignoring default constructors with user provided arguments and adding
528528
detection in container's method except ``empty``.
529529

530+
- Improved :doc:`readability-duplicate-include
531+
<clang-tidy/checks/readability/duplicate-include>` check by adding
532+
the ``IgnoredFilesList`` option (semicolon-separated list of regexes or
533+
filenames) to allow intentional duplicates.
534+
530535
- Improved :doc:`readability-identifier-naming
531536
<clang-tidy/checks/readability/identifier-naming>` check by ignoring
532537
declarations and macros in system headers. The documentation is also improved

clang-tools-extra/docs/clang-tidy/checks/readability/duplicate-include.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,12 @@ Because of the intervening macro definitions, this code remains unchanged:
3333
#define NDEBUG
3434
#include "assertion.h"
3535
// ...code with assertions disabled
36+
37+
Options
38+
-------
39+
40+
.. option:: IgnoredFilesList
41+
42+
A semicolon-separated list of regular expressions or filenames that are
43+
allowed to be included multiple times without diagnostics. Matching is
44+
performed against the textual include name. Default is an empty string.

0 commit comments

Comments
 (0)