Skip to content

Commit ce8572c

Browse files
authored
Merge branch 'main' into uses_allocator_syntax
2 parents 03420e3 + 33a583d commit ce8572c

File tree

1,027 files changed

+117583
-52205
lines changed

Some content is hidden

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

1,027 files changed

+117583
-52205
lines changed

.ci/monolithic-windows.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ start-group "ninja"
5656
# Targets are not escaped as they are passed as separate arguments.
5757
ninja -C "${BUILD_DIR}" -k 0 ${targets} |& tee ninja.log
5858

59-
start-group "ninja runtimes"
60-
61-
ninja -C "${BUILD_DIR}" -k 0 ${runtimes_targets} |& tee ninja_runtimes.log
59+
if [[ "${runtime_targets}" != "" ]]; then
60+
start-group "ninja runtimes"
61+
62+
ninja -C "${BUILD_DIR}" -k 0 ${runtimes_targets} |& tee ninja_runtimes.log
63+
fi

clang-tools-extra/clang-tidy/modernize/ReplaceAutoPtrCheck.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class ReplaceAutoPtrCheck : public ClangTidyCheck {
4242
public:
4343
ReplaceAutoPtrCheck(StringRef Name, ClangTidyContext *Context);
4444
bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
45-
return LangOpts.CPlusPlus;
45+
return LangOpts.CPlusPlus11;
4646
}
4747
void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
4848
void registerMatchers(ast_matchers::MatchFinder *Finder) override;

clang-tools-extra/clang-tidy/modernize/UseAutoCheck.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class UseAutoCheck : public ClangTidyCheck {
1717
public:
1818
UseAutoCheck(StringRef Name, ClangTidyContext *Context);
1919
bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
20-
return LangOpts.CPlusPlus;
20+
return LangOpts.CPlusPlus11;
2121
}
2222
void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
2323
void registerMatchers(ast_matchers::MatchFinder *Finder) override;

clang-tools-extra/clang-tidy/modernize/UseEqualsDeleteCheck.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class UseEqualsDeleteCheck : public ClangTidyCheck {
2323
public:
2424
UseEqualsDeleteCheck(StringRef Name, ClangTidyContext *Context);
2525
bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
26-
return LangOpts.CPlusPlus;
26+
return LangOpts.CPlusPlus11;
2727
}
2828
void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
2929
void registerMatchers(ast_matchers::MatchFinder *Finder) override;

clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ class UseNullptrCheck : public ClangTidyCheck {
1717
public:
1818
UseNullptrCheck(StringRef Name, ClangTidyContext *Context);
1919
bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
20-
// FIXME this should be CPlusPlus11 but that causes test cases to
21-
// erroneously fail.
22-
return LangOpts.CPlusPlus || LangOpts.C23;
20+
return LangOpts.CPlusPlus11 || LangOpts.C23;
2321
}
2422
void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
2523
void registerMatchers(ast_matchers::MatchFinder *Finder) override;

clang-tools-extra/test/clang-tidy/check_clang_tidy.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -391,9 +391,7 @@ def parse_arguments() -> Tuple[argparse.Namespace, List[str]]:
391391
args, extra_args = parser.parse_known_args()
392392
if args.std is None:
393393
_, extension = os.path.splitext(args.assume_filename or args.input_file_name)
394-
args.std = [
395-
"c++11-or-later" if extension in [".cpp", ".hpp", ".mm"] else "c99-or-later"
396-
]
394+
args.std = ["c99-or-later" if extension in [".c", ".m"] else "c++11-or-later"]
397395

398396
return (args, extra_args)
399397

clang-tools-extra/test/clang-tidy/checkers/modernize/use-nullptr-basic.cpp

Lines changed: 31 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
// RUN: %check_clang_tidy -std=c++98 %s modernize-use-nullptr %t -- -- -Wno-non-literal-null-conversion
2-
//
3-
// Some parts of the test (e.g. assignment of `const int` to `int *`) fail in
4-
// C++11, so we need to run the test in C++98 mode.
5-
//
6-
// FIXME: Make the test work in all language modes.
1+
// RUN: %check_clang_tidy %s modernize-use-nullptr %t -- -- -fno-delayed-template-parsing
72

83
const unsigned int g_null = 0;
94
#define NULL 0
@@ -23,26 +18,19 @@ void test_assignment() {
2318
p2 = p1;
2419
// CHECK-FIXES: p2 = p1;
2520

26-
const int null = 0;
27-
int *p3 = null;
28-
// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use nullptr
29-
// CHECK-FIXES: int *p3 = nullptr;
30-
21+
int *p3;
3122
p3 = NULL;
3223
// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use nullptr
3324
// CHECK-FIXES: p3 = nullptr;
3425

3526
int *p4 = p3;
3627
// CHECK-FIXES: int *p4 = p3;
3728

38-
p4 = null;
39-
// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use nullptr
40-
// CHECK-FIXES: p4 = nullptr;
41-
4229
int i1 = 0;
4330

4431
int i2 = NULL;
4532

33+
const int null = 0;
4634
int i3 = null;
4735

4836
int *p5, *p6, *p7;
@@ -70,47 +58,13 @@ int *Foo::m_p2 = NULL;
7058
// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: use nullptr
7159
// CHECK-FIXES: int *Foo::m_p2 = nullptr;
7260

73-
template <typename T>
74-
struct Bar {
75-
Bar(T *p) : m_p(p) {
76-
m_p = static_cast<T*>(NULL);
77-
// CHECK-MESSAGES: :[[@LINE-1]]:27: warning: use nullptr
78-
// CHECK-FIXES: m_p = static_cast<T*>(nullptr);
79-
80-
m_p = static_cast<T*>(reinterpret_cast<int*>((void*)NULL));
81-
// CHECK-MESSAGES: :[[@LINE-1]]:27: warning: use nullptr
82-
// CHECK-FIXES: m_p = static_cast<T*>(nullptr);
83-
84-
m_p = static_cast<T*>(p ? p : static_cast<void*>(g_null));
85-
// CHECK-MESSAGES: :[[@LINE-1]]:54: warning: use nullptr
86-
// CHECK-FIXES: m_p = static_cast<T*>(p ? p : static_cast<void*>(nullptr));
87-
88-
T *p2 = static_cast<T*>(reinterpret_cast<int*>((void*)NULL));
89-
// CHECK-MESSAGES: :[[@LINE-1]]:29: warning: use nullptr
90-
// CHECK-FIXES: T *p2 = static_cast<T*>(nullptr);
91-
92-
m_p = NULL;
93-
// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: use nullptr
94-
// CHECK-FIXES: m_p = nullptr;
95-
96-
int i = static_cast<int>(0.f);
97-
T *i2 = static_cast<int>(0.f);
98-
// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use nullptr
99-
// CHECK-FIXES: T *i2 = nullptr;
100-
}
101-
102-
T *m_p;
103-
};
104-
10561
struct Baz {
10662
Baz() : i(0) {}
10763
int i;
10864
};
10965

11066
void test_cxx_cases() {
111-
Foo f(g_null);
112-
// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: use nullptr
113-
// CHECK-FIXES: Foo f(nullptr);
67+
Foo f;
11468

11569
f.bar(NULL);
11670
// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: use nullptr
@@ -122,10 +76,6 @@ void test_cxx_cases() {
12276
// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use nullptr
12377
// CHECK-FIXES: f.m_p1 = nullptr;
12478

125-
Bar<int> b(g_null);
126-
// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: use nullptr
127-
// CHECK-FIXES: Bar<int> b(nullptr);
128-
12979
Baz b2;
13080
int Baz::*memptr(0);
13181
// CHECK-MESSAGES: :[[@LINE-1]]:20: warning: use nullptr
@@ -144,10 +94,6 @@ void test_function_default_param2(void *p = NULL);
14494
// CHECK-MESSAGES: :[[@LINE-1]]:45: warning: use nullptr
14595
// CHECK-FIXES: void test_function_default_param2(void *p = nullptr);
14696

147-
void test_function_default_param3(void *p = g_null);
148-
// CHECK-MESSAGES: :[[@LINE-1]]:45: warning: use nullptr
149-
// CHECK-FIXES: void test_function_default_param3(void *p = nullptr);
150-
15197
void test_function(int *p) {}
15298

15399
void test_function_no_ptr_param(int i) {}
@@ -161,10 +107,6 @@ void test_function_call() {
161107
// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: use nullptr
162108
// CHECK-FIXES: test_function(nullptr);
163109

164-
test_function(g_null);
165-
// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: use nullptr
166-
// CHECK-FIXES: test_function(nullptr);
167-
168110
test_function_no_ptr_param(0);
169111
}
170112

@@ -180,51 +122,33 @@ void *test_function_return2() {
180122
// CHECK-FIXES: return nullptr;
181123
}
182124

183-
long *test_function_return3() {
184-
return g_null;
185-
// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use nullptr
186-
// CHECK-FIXES: return nullptr;
187-
}
188-
189-
int test_function_return4() {
125+
int test_function_return3() {
190126
return 0;
191127
}
192128

193-
int test_function_return5() {
129+
int test_function_return4() {
194130
return NULL;
195131
}
196132

197-
int test_function_return6() {
133+
int test_function_return5() {
198134
return g_null;
199135
}
200136

201-
int *test_function_return_cast1() {
202-
return(int)0;
203-
// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: use nullptr
204-
// CHECK-FIXES: return nullptr;
205-
}
206-
207-
int *test_function_return_cast2() {
137+
int *test_function_return_cast() {
208138
#define RET return
209-
RET(int)0;
210-
// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: use nullptr
139+
RET 0;
140+
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use nullptr
211141
// CHECK-FIXES: RET nullptr;
212142
#undef RET
213143
}
214144

215145
// Test parentheses expressions resulting in a nullptr.
216-
int *test_parentheses_expression1() {
146+
int *test_parentheses_expression() {
217147
return(0);
218148
// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use nullptr
219149
// CHECK-FIXES: return(nullptr);
220150
}
221151

222-
int *test_parentheses_expression2() {
223-
return(int(0.f));
224-
// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use nullptr
225-
// CHECK-FIXES: return(nullptr);
226-
}
227-
228152
int *test_nested_parentheses_expression() {
229153
return((((0))));
230154
// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use nullptr
@@ -244,7 +168,7 @@ void *test_parentheses_explicit_cast_sequence1() {
244168
}
245169

246170
void *test_parentheses_explicit_cast_sequence2() {
247-
return(static_cast<void*>(reinterpret_cast<int*>((float*)int(0.f))));
171+
return(static_cast<void*>(reinterpret_cast<int*>((float*)(0))));
248172
// CHECK-MESSAGES: :[[@LINE-1]]:29: warning: use nullptr
249173
// CHECK-FIXES: return(static_cast<void*>(nullptr));
250174
}
@@ -313,19 +237,13 @@ void test_const_pointers() {
313237
const int *const_p2 = NULL;
314238
// CHECK-MESSAGES: :[[@LINE-1]]:25: warning: use nullptr
315239
// CHECK-FIXES: const int *const_p2 = nullptr;
316-
const int *const_p3 = (int)0;
317-
// CHECK-MESSAGES: :[[@LINE-1]]:25: warning: use nullptr
318-
// CHECK-FIXES: const int *const_p3 = nullptr;
319-
const int *const_p4 = (int)0.0f;
320-
// CHECK-MESSAGES: :[[@LINE-1]]:25: warning: use nullptr
321-
// CHECK-FIXES: const int *const_p4 = nullptr;
322-
const int *const_p5 = (int*)0;
240+
const int *const_p3 = (int*)0;
323241
// CHECK-MESSAGES: :[[@LINE-1]]:31: warning: use nullptr
324-
// CHECK-FIXES: const int *const_p5 = (int*)nullptr;
242+
// CHECK-FIXES: const int *const_p3 = (int*)nullptr;
325243
int *t;
326-
const int *const_p6 = static_cast<int*>(t ? t : static_cast<int*>(0));
244+
const int *const_p4 = static_cast<int*>(t ? t : static_cast<int*>(0));
327245
// CHECK-MESSAGES: :[[@LINE-1]]:69: warning: use nullptr
328-
// CHECK-FIXES: const int *const_p6 = static_cast<int*>(t ? t : static_cast<int*>(nullptr));
246+
// CHECK-FIXES: const int *const_p4 = static_cast<int*>(t ? t : static_cast<int*>(nullptr));
329247
}
330248

331249
void test_nested_implicit_cast_expr() {
@@ -348,7 +266,21 @@ void test_nested_implicit_cast_expr() {
348266
template<typename T>
349267
class A {
350268
public:
351-
A(T *p = NULL) {}
269+
A(T *p = NULL) {
270+
Ptr = static_cast<T*>(NULL);
271+
272+
Ptr = static_cast<T*>(reinterpret_cast<int*>((void*)NULL));
273+
// CHECK-MESSAGES: :[[@LINE-1]]:27: warning: use nullptr
274+
// CHECK-FIXES: Ptr = static_cast<T*>(nullptr);
275+
// FIXME: a better fix-it is: Ptr = nullptr;
276+
277+
T *p2 = static_cast<T*>(reinterpret_cast<int*>((void*)NULL));
278+
// CHECK-MESSAGES: :[[@LINE-1]]:29: warning: use nullptr
279+
// CHECK-FIXES: T *p2 = static_cast<T*>(nullptr);
280+
// FIXME: a better fix-it is: T *p2 = nullptr;
281+
282+
Ptr = NULL;
283+
}
352284

353285
void f() {
354286
Ptr = NULL;

0 commit comments

Comments
 (0)