Skip to content

Commit 8eb6ef0

Browse files
committed
Rebase, address comments
Created using spr 1.3.5
2 parents a9bc978 + 539991e commit 8eb6ef0

File tree

663 files changed

+125142
-8842
lines changed

Some content is hidden

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

663 files changed

+125142
-8842
lines changed

.clang-tidy

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
1-
Checks: '-*,clang-diagnostic-*,llvm-*,misc-*,-misc-const-correctness,-misc-unused-parameters,-misc-non-private-member-variables-in-classes,-misc-no-recursion,-misc-use-anonymous-namespace,readability-identifier-naming,-misc-include-cleaner'
1+
Checks: >
2+
-*,
3+
clang-diagnostic-*,
4+
llvm-*,
5+
misc-*,
6+
-misc-const-correctness,
7+
-misc-include-cleaner,
8+
-misc-no-recursion,
9+
-misc-non-private-member-variables-in-classes,
10+
-misc-unused-parameters,
11+
-misc-use-anonymous-namespace,
12+
readability-identifier-naming
13+
214
CheckOptions:
315
- key: readability-identifier-naming.ClassCase
416
value: CamelCase

.github/workflows/pr-code-format.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ jobs:
5555
- name: Install clang-format
5656
uses: aminya/setup-cpp@17c11551771948abc5752bbf3183482567c7caf0 # v1.1.1
5757
with:
58-
clangformat: 20.1.5
58+
clangformat: 20.1.8
5959

6060
- name: Setup Python env
6161
uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.0

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

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,17 @@ using namespace clang::ast_matchers;
1515

1616
namespace clang::tidy::readability {
1717

18+
NamedParameterCheck::NamedParameterCheck(StringRef Name,
19+
ClangTidyContext *Context)
20+
: ClangTidyCheck(Name, Context),
21+
InsertPlainNamesInForwardDecls(
22+
Options.get("InsertPlainNamesInForwardDecls", false)) {}
23+
24+
void NamedParameterCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
25+
Options.store(Opts, "InsertPlainNamesInForwardDecls",
26+
InsertPlainNamesInForwardDecls);
27+
}
28+
1829
void NamedParameterCheck::registerMatchers(ast_matchers::MatchFinder *Finder) {
1930
Finder->addMatcher(functionDecl().bind("decl"), this);
2031
}
@@ -84,7 +95,8 @@ void NamedParameterCheck::check(const MatchFinder::MatchResult &Result) {
8495

8596
for (auto P : UnnamedParams) {
8697
// Fallback to an unused marker.
87-
StringRef NewName = "unused";
98+
static constexpr StringRef FallbackName = "unused";
99+
StringRef NewName = FallbackName;
88100

89101
// If the method is overridden, try to copy the name from the base method
90102
// into the overrider.
@@ -105,12 +117,25 @@ void NamedParameterCheck::check(const MatchFinder::MatchResult &Result) {
105117
NewName = Name;
106118
}
107119

108-
// Now insert the comment. Note that getLocation() points to the place
120+
// Now insert the fix. Note that getLocation() points to the place
109121
// where the name would be, this allows us to also get complex cases like
110122
// function pointers right.
111123
const ParmVarDecl *Parm = P.first->getParamDecl(P.second);
112-
D << FixItHint::CreateInsertion(Parm->getLocation(),
113-
" /*" + NewName.str() + "*/");
124+
125+
// The fix depends on the InsertPlainNamesInForwardDecls option,
126+
// whether this is a forward declaration and whether the parameter has
127+
// a real name.
128+
const bool IsForwardDeclaration = (!Definition || Function != Definition);
129+
if (InsertPlainNamesInForwardDecls && IsForwardDeclaration &&
130+
NewName != FallbackName) {
131+
// For forward declarations with InsertPlainNamesInForwardDecls enabled,
132+
// insert the parameter name without comments.
133+
D << FixItHint::CreateInsertion(Parm->getLocation(),
134+
" " + NewName.str());
135+
} else {
136+
D << FixItHint::CreateInsertion(Parm->getLocation(),
137+
" /*" + NewName.str() + "*/");
138+
}
114139
}
115140
}
116141
}

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,16 @@ namespace clang::tidy::readability {
2626
/// Corresponding cpplint.py check name: 'readability/function'.
2727
class NamedParameterCheck : public ClangTidyCheck {
2828
public:
29-
NamedParameterCheck(StringRef Name, ClangTidyContext *Context)
30-
: ClangTidyCheck(Name, Context) {}
29+
NamedParameterCheck(StringRef Name, ClangTidyContext *Context);
3130
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
3231
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
32+
void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
3333
std::optional<TraversalKind> getCheckTraversalKind() const override {
3434
return TK_IgnoreUnlessSpelledInSource;
3535
}
36+
37+
private:
38+
const bool InsertPlainNamesInForwardDecls;
3639
};
3740

3841
} // namespace clang::tidy::readability

clang-tools-extra/clangd/ModulesBuilder.cpp

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,16 @@ class ReusablePrerequisiteModules : public PrerequisiteModules {
160160
RequiredModule->getModuleFilePath().str());
161161
}
162162

163+
std::string getAsString() const {
164+
std::string Result;
165+
llvm::raw_string_ostream OS(Result);
166+
for (const auto &ModuleFile : RequiredModules) {
167+
OS << "-fmodule-file=" << ModuleFile->getModuleName() << "="
168+
<< ModuleFile->getModuleFilePath() << " ";
169+
}
170+
return Result;
171+
}
172+
163173
bool canReuse(const CompilerInvocation &CI,
164174
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>) const override;
165175

@@ -296,8 +306,27 @@ buildModuleFile(llvm::StringRef ModuleName, PathRef ModuleUnitFileName,
296306
GenerateReducedModuleInterfaceAction Action;
297307
Clang->ExecuteAction(Action);
298308

299-
if (Clang->getDiagnostics().hasErrorOccurred())
300-
return llvm::createStringError("Compilation failed");
309+
if (Clang->getDiagnostics().hasErrorOccurred()) {
310+
std::string Cmds;
311+
for (const auto &Arg : Inputs.CompileCommand.CommandLine) {
312+
if (!Cmds.empty())
313+
Cmds += " ";
314+
Cmds += Arg;
315+
}
316+
317+
clangd::vlog("Failed to compile {0} with command: {1}.", ModuleUnitFileName,
318+
Cmds);
319+
320+
std::string BuiltModuleFilesStr = BuiltModuleFiles.getAsString();
321+
if (!BuiltModuleFilesStr.empty())
322+
clangd::vlog("The actual used module files built by clangd is {0}",
323+
BuiltModuleFilesStr);
324+
325+
return llvm::createStringError(
326+
llvm::formatv("Failed to compile {0}. Use '--log=verbose' to view "
327+
"detailed failure reasons.",
328+
ModuleUnitFileName));
329+
}
301330

302331
return ModuleFile{ModuleName, Inputs.CompileCommand.Output};
303332
}

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ Changes in existing checks
215215
- Improved :doc:`cppcoreguidelines-missing-std-forward
216216
<clang-tidy/checks/cppcoreguidelines/missing-std-forward>` check by adding a
217217
flag to specify the function used for forwarding instead of ``std::forward``.
218-
218+
219219
- Improved :doc:`cppcoreguidelines-pro-bounds-pointer-arithmetic
220220
<clang-tidy/checks/cppcoreguidelines/pro-bounds-pointer-arithmetic>` check by
221221
fixing false positives when calling indexing operators that do not perform
@@ -342,6 +342,11 @@ Changes in existing checks
342342
false negatives where math expressions are the operand of assignment operators
343343
or comparison operators.
344344

345+
- Improved :doc:`readability-named-parameter
346+
<clang-tidy/checks/readability/named-parameter>` check by adding the option
347+
`InsertPlainNamesInForwardDecls` to insert parameter names without comments
348+
for forward declarations only.
349+
345350
- Improved :doc:`readability-qualified-auto
346351
<clang-tidy/checks/readability/qualified-auto>` check by adding the option
347352
`AllowedTypes`, that excludes specified types from adding qualifiers.

clang-tools-extra/docs/clang-tidy/checks/readability/named-parameter.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,12 @@ If a parameter is not utilized, its name can be commented out in a function defi
2323
}
2424

2525
Corresponding cpplint.py check name: `readability/function`.
26+
27+
Options
28+
-------
29+
30+
.. option:: InsertPlainNamesInForwardDecls
31+
32+
If set to `true`, the check will insert parameter names without comments for
33+
forward declarations only. Otherwise, the check will insert parameter names
34+
as comments (e.g., ``/*param*/``). Default is `false`.

clang-tools-extra/test/clang-tidy/checkers/readability/named-parameter.cpp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,47 @@
11
// RUN: %check_clang_tidy %s readability-named-parameter %t
2+
// RUN: %check_clang_tidy -check-suffix=PLAIN-NAMES %s readability-named-parameter %t -- \
3+
// RUN: -config="{CheckOptions: [{key: readability-named-parameter.InsertPlainNamesInForwardDecls, value: true}]}"
24

35
void Method(char *) { /* */ }
46
// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: all parameters should be named in a function
57
// CHECK-FIXES: void Method(char * /*unused*/) { /* */ }
8+
// CHECK-MESSAGES-PLAIN-NAMES: :[[@LINE-3]]:19: warning: all parameters should be named in a function
9+
// CHECK-FIXES-PLAIN-NAMES: void Method(char * /*unused*/) { /* */ }
610
void Method2(char *) {}
711
// CHECK-MESSAGES: :[[@LINE-1]]:20: warning: all parameters should be named in a function
812
// CHECK-FIXES: void Method2(char * /*unused*/) {}
13+
// CHECK-MESSAGES-PLAIN-NAMES: :[[@LINE-3]]:20: warning: all parameters should be named in a function
14+
// CHECK-FIXES-PLAIN-NAMES: void Method2(char * /*unused*/) {}
915
void Method3(char *, void *) {}
1016
// CHECK-MESSAGES: :[[@LINE-1]]:20: warning: all parameters should be named in a function
1117
// CHECK-FIXES: void Method3(char * /*unused*/, void * /*unused*/) {}
18+
// CHECK-MESSAGES-PLAIN-NAMES: :[[@LINE-3]]:20: warning: all parameters should be named in a function
19+
// CHECK-FIXES-PLAIN-NAMES: void Method3(char * /*unused*/, void * /*unused*/) {}
1220
void Method4(char *, int /*unused*/) {}
1321
// CHECK-MESSAGES: :[[@LINE-1]]:20: warning: all parameters should be named in a function
1422
// CHECK-FIXES: void Method4(char * /*unused*/, int /*unused*/) {}
23+
// CHECK-MESSAGES-PLAIN-NAMES: :[[@LINE-3]]:20: warning: all parameters should be named in a function
24+
// CHECK-FIXES-PLAIN-NAMES: void Method4(char * /*unused*/, int /*unused*/) {}
1525
void operator delete[](void *) throw() {}
1626
// CHECK-MESSAGES: :[[@LINE-1]]:30: warning: all parameters should be named in a function
1727
// CHECK-FIXES: void operator delete[](void * /*unused*/) throw() {}
28+
// CHECK-MESSAGES-PLAIN-NAMES: :[[@LINE-3]]:30: warning: all parameters should be named in a function
29+
// CHECK-FIXES-PLAIN-NAMES: void operator delete[](void * /*unused*/) throw() {}
1830
int Method5(int) { return 0; }
1931
// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: all parameters should be named in a function
2032
// CHECK-FIXES: int Method5(int /*unused*/) { return 0; }
33+
// CHECK-MESSAGES-PLAIN-NAMES: :[[@LINE-3]]:16: warning: all parameters should be named in a function
34+
// CHECK-FIXES-PLAIN-NAMES: int Method5(int /*unused*/) { return 0; }
2135
void Method6(void (*)(void *)) {}
2236
// CHECK-MESSAGES: :[[@LINE-1]]:21: warning: all parameters should be named in a function
2337
// CHECK-FIXES: void Method6(void (* /*unused*/)(void *)) {}
38+
// CHECK-MESSAGES-PLAIN-NAMES: :[[@LINE-3]]:21: warning: all parameters should be named in a function
39+
// CHECK-FIXES-PLAIN-NAMES: void Method6(void (* /*unused*/)(void *)) {}
2440
template <typename T> void Method7(T) {}
2541
// CHECK-MESSAGES: :[[@LINE-1]]:37: warning: all parameters should be named in a function
2642
// CHECK-FIXES: template <typename T> void Method7(T /*unused*/) {}
43+
// CHECK-MESSAGES-PLAIN-NAMES: :[[@LINE-3]]:37: warning: all parameters should be named in a function
44+
// CHECK-FIXES-PLAIN-NAMES: template <typename T> void Method7(T /*unused*/) {}
2745

2846
// Don't warn in macros.
2947
#define M void MethodM(int) {}
@@ -55,6 +73,8 @@ struct Y {
5573
void foo(T) {}
5674
// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: all parameters should be named in a function
5775
// CHECK-FIXES: void foo(T /*unused*/) {}
76+
// CHECK-MESSAGES-PLAIN-NAMES: :[[@LINE-3]]:13: warning: all parameters should be named in a function
77+
// CHECK-FIXES-PLAIN-NAMES: void foo(T /*unused*/) {}
5878
};
5979

6080
Y<int> y;
@@ -69,19 +89,27 @@ struct Derived : public Base {
6989
void foo(int);
7090
// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: all parameters should be named in a function
7191
// CHECK-FIXES: void foo(int /*argname*/);
92+
// CHECK-MESSAGES-PLAIN-NAMES: :[[@LINE-3]]:15: warning: all parameters should be named in a function
93+
// CHECK-FIXES-PLAIN-NAMES: void foo(int argname);
7294
};
7395

7496
void FDef(int);
7597
// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: all parameters should be named in a function
7698
// CHECK-FIXES: void FDef(int /*n*/);
99+
// CHECK-MESSAGES-PLAIN-NAMES: :[[@LINE-3]]:14: warning: all parameters should be named in a function
100+
// CHECK-FIXES-PLAIN-NAMES: void FDef(int n);
77101
void FDef(int n) {}
78102

79103
void FDef2(int, int);
80104
// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: all parameters should be named in a function
81105
// CHECK-FIXES: void FDef2(int /*n*/, int /*unused*/);
106+
// CHECK-MESSAGES-PLAIN-NAMES: :[[@LINE-3]]:15: warning: all parameters should be named in a function
107+
// CHECK-FIXES-PLAIN-NAMES: void FDef2(int n, int /*unused*/);
82108
void FDef2(int n, int) {}
83109
// CHECK-MESSAGES: :[[@LINE-1]]:22: warning: all parameters should be named in a function
84110
// CHECK-FIXES: void FDef2(int n, int /*unused*/) {}
111+
// CHECK-MESSAGES-PLAIN-NAMES: :[[@LINE-3]]:22: warning: all parameters should be named in a function
112+
// CHECK-FIXES-PLAIN-NAMES: void FDef2(int n, int /*unused*/) {}
85113

86114
void FNoDef(int);
87115

@@ -91,18 +119,26 @@ Z the_z;
91119
Z &operator++(Z&) { return the_z; }
92120
// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: all parameters should be named in a function
93121
// CHECK-FIXES: Z &operator++(Z& /*unused*/) { return the_z; }
122+
// CHECK-MESSAGES-PLAIN-NAMES: :[[@LINE-3]]:17: warning: all parameters should be named in a function
123+
// CHECK-FIXES-PLAIN-NAMES: Z &operator++(Z& /*unused*/) { return the_z; }
94124

95125
Z &operator++(Z&, int) { return the_z; }
96126
// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: all parameters should be named in a function
97127
// CHECK-FIXES: Z &operator++(Z& /*unused*/, int) { return the_z; }
128+
// CHECK-MESSAGES-PLAIN-NAMES: :[[@LINE-3]]:17: warning: all parameters should be named in a function
129+
// CHECK-FIXES-PLAIN-NAMES: Z &operator++(Z& /*unused*/, int) { return the_z; }
98130

99131
Z &operator--(Z&) { return the_z; }
100132
// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: all parameters should be named in a function
101133
// CHECK-FIXES: Z &operator--(Z& /*unused*/) { return the_z; }
134+
// CHECK-MESSAGES-PLAIN-NAMES: :[[@LINE-3]]:17: warning: all parameters should be named in a function
135+
// CHECK-FIXES-PLAIN-NAMES: Z &operator--(Z& /*unused*/) { return the_z; }
102136

103137
Z &operator--(Z&, int) { return the_z; }
104138
// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: all parameters should be named in a function
105139
// CHECK-FIXES: Z &operator--(Z& /*unused*/, int) { return the_z; }
140+
// CHECK-MESSAGES-PLAIN-NAMES: :[[@LINE-3]]:17: warning: all parameters should be named in a function
141+
// CHECK-FIXES-PLAIN-NAMES: Z &operator--(Z& /*unused*/, int) { return the_z; }
106142

107143
namespace testing {
108144
namespace internal {

clang/docs/ClangFormatStyleOptions.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1554,9 +1554,9 @@ the configuration (without a prefix: ``Auto``).
15541554

15551555
.. code-block:: c++
15561556

1557-
#define A \
1558-
int aaaa; \
1559-
int b; \
1557+
#define A \
1558+
int aaaa; \
1559+
int b; \
15601560
int dddddddddd;
15611561

15621562

clang/docs/ReleaseNotes.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,15 @@ C23 Feature Support
312312
`WG14 N2975 <https://open-std.org/JTC1/SC22/WG14/www/docs/n2975.pdf>`_
313313
- Fixed a bug with handling the type operand form of ``typeof`` when it is used
314314
to specify a fixed underlying type for an enumeration. #GH146351
315+
- Fixed a rejects-valid bug where Clang would reject an enumeration with an
316+
``_Atomic`` underlying type. The underlying type is the non-atomic,
317+
unqualified version of the specified type. Due to the perhaps surprising lack
318+
of atomic behavior, this is diagnosed under
319+
``-Wunderlying-atomic-qualifier-ignored``, which defaults to an error. This
320+
can be downgraded with ``-Wno-underlying-atomic-qualifier-ignored`` or
321+
``-Wno-error=underlying-atomic-qualifier-ignored``. Clang now also diagnoses
322+
cv-qualifiers as being ignored, but that warning does not default to an error.
323+
It can be controlled by ``-Wunderlying-cv-qualifier-ignore``. (#GH147736)
315324

316325
C11 Feature Support
317326
^^^^^^^^^^^^^^^^^^^
@@ -895,6 +904,7 @@ Bug Fixes to C++ Support
895904
- Fixed a Clang regression in C++20 mode where unresolved dependent call expressions were created inside non-dependent contexts (#GH122892)
896905
- Clang now emits the ``-Wunused-variable`` warning when some structured bindings are unused
897906
and the ``[[maybe_unused]]`` attribute is not applied. (#GH125810)
907+
- Fixed ``static_cast`` not performing access or ambiguity checks when converting to an rvalue reference to a base class. (#GH121429)
898908
- Declarations using class template argument deduction with redundant
899909
parentheses around the declarator are no longer rejected. (#GH39811)
900910
- Fixed a crash caused by invalid declarations of ``std::initializer_list``. (#GH132256)
@@ -1075,6 +1085,8 @@ RISC-V Support
10751085
CUDA/HIP Language Changes
10761086
^^^^^^^^^^^^^^^^^^^^^^^^^
10771087

1088+
* Provide a __device__ version of std::__glibcxx_assert_fail() in a header wrapper.
1089+
10781090
CUDA Support
10791091
^^^^^^^^^^^^
10801092

0 commit comments

Comments
 (0)