Skip to content

Commit ebffad8

Browse files
committed
[clang-tools-extra] Use {} instead of std::nullopt to initialize empty ArrayRef
Follow up to llvm#109133.
1 parent 9e73159 commit ebffad8

8 files changed

+29
-29
lines changed

clang-tools-extra/clang-query/Query.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ bool MatchQuery::run(llvm::raw_ostream &OS, QuerySession &QS) const {
146146
TD.emitDiagnostic(
147147
FullSourceLoc(R.getBegin(), AST->getSourceManager()),
148148
DiagnosticsEngine::Note, "\"" + BI->first + "\" binds here",
149-
CharSourceRange::getTokenRange(R), std::nullopt);
149+
CharSourceRange::getTokenRange(R), {});
150150
}
151151
}
152152
if (QS.PrintOutput) {

clang-tools-extra/unittests/clang-tidy/ClangTidyTest.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ template <typename... CheckTypes>
8686
std::string
8787
runCheckOnCode(StringRef Code, std::vector<ClangTidyError> *Errors = nullptr,
8888
const Twine &Filename = "input.cc",
89-
ArrayRef<std::string> ExtraArgs = std::nullopt,
89+
ArrayRef<std::string> ExtraArgs = {},
9090
const ClangTidyOptions &ExtraOptions = ClangTidyOptions(),
9191
std::map<StringRef, StringRef> PathsToContent =
9292
std::map<StringRef, StringRef>()) {

clang-tools-extra/unittests/clang-tidy/IncludeCleanerTest.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ TEST(IncludeCleanerCheckTest, BasicUnusedIncludes) {
4949
std::vector<ClangTidyError> Errors;
5050
EXPECT_EQ(PostCode,
5151
runCheckOnCode<IncludeCleanerCheck>(
52-
PreCode, &Errors, "file.cpp", std::nullopt, ClangTidyOptions(),
52+
PreCode, &Errors, "file.cpp", {}, ClangTidyOptions(),
5353
{{"bar.h", "#pragma once"}, {"vector", "#pragma once"}}));
5454
}
5555

@@ -78,7 +78,7 @@ TEST(IncludeCleanerCheckTest, SuppressUnusedIncludes) {
7878
EXPECT_EQ(
7979
PostCode,
8080
runCheckOnCode<IncludeCleanerCheck>(
81-
PreCode, &Errors, "file.cpp", std::nullopt, Opts,
81+
PreCode, &Errors, "file.cpp", {}, Opts,
8282
{{"bar.h", "#pragma once"},
8383
{"vector", "#pragma once"},
8484
{"list", "#pragma once"},
@@ -105,7 +105,7 @@ int BazResult = baz();
105105
std::vector<ClangTidyError> Errors;
106106
EXPECT_EQ(PostCode,
107107
runCheckOnCode<IncludeCleanerCheck>(
108-
PreCode, &Errors, "file.cpp", std::nullopt, ClangTidyOptions(),
108+
PreCode, &Errors, "file.cpp", {}, ClangTidyOptions(),
109109
{{"bar.h", R"(#pragma once
110110
#include "baz.h"
111111
int bar();
@@ -125,7 +125,7 @@ int BarResult2 = $diag2^bar();)");
125125
{
126126
std::vector<ClangTidyError> Errors;
127127
runCheckOnCode<IncludeCleanerCheck>(Code.code(), &Errors, "file.cpp",
128-
std::nullopt, ClangTidyOptions(),
128+
{}, ClangTidyOptions(),
129129
{{"baz.h", R"(#pragma once
130130
#include "bar.h"
131131
)"},
@@ -142,7 +142,7 @@ int BarResult2 = $diag2^bar();)");
142142
ClangTidyOptions Opts;
143143
Opts.CheckOptions.insert({"DeduplicateFindings", "false"});
144144
runCheckOnCode<IncludeCleanerCheck>(Code.code(), &Errors, "file.cpp",
145-
std::nullopt, Opts,
145+
{}, Opts,
146146
{{"baz.h", R"(#pragma once
147147
#include "bar.h"
148148
)"},
@@ -176,7 +176,7 @@ std::vector x;
176176
llvm::Regex::escape(appendPathFileSystemIndependent({"foo", "qux.h"}))};
177177
std::vector<ClangTidyError> Errors;
178178
EXPECT_EQ(PreCode, runCheckOnCode<IncludeCleanerCheck>(
179-
PreCode, &Errors, "file.cpp", std::nullopt, Opts,
179+
PreCode, &Errors, "file.cpp", {}, Opts,
180180
{{"bar.h", R"(#pragma once
181181
#include "baz.h"
182182
#include "foo/qux.h"
@@ -217,7 +217,7 @@ int BazResult_1 = baz_1();
217217
std::vector<ClangTidyError> Errors;
218218
EXPECT_EQ(PostCode,
219219
runCheckOnCode<IncludeCleanerCheck>(
220-
PreCode, &Errors, "file.cpp", std::nullopt, ClangTidyOptions(),
220+
PreCode, &Errors, "file.cpp", {}, ClangTidyOptions(),
221221
{{"bar.h", R"(#pragma once
222222
#include "baz.h"
223223
int bar();
@@ -246,7 +246,7 @@ std::vector Vec;
246246
std::vector<ClangTidyError> Errors;
247247
EXPECT_EQ(PostCode,
248248
runCheckOnCode<IncludeCleanerCheck>(
249-
PreCode, &Errors, "file.cpp", std::nullopt, ClangTidyOptions(),
249+
PreCode, &Errors, "file.cpp", {}, ClangTidyOptions(),
250250
{{"string", R"(#pragma once
251251
namespace std { class string {}; }
252252
)"},
@@ -274,7 +274,7 @@ int FooBarResult = foobar();
274274
std::vector<ClangTidyError> Errors;
275275
EXPECT_EQ(PostCode,
276276
runCheckOnCode<IncludeCleanerCheck>(
277-
PreCode, &Errors, "file.cpp", std::nullopt, ClangTidyOptions(),
277+
PreCode, &Errors, "file.cpp", {}, ClangTidyOptions(),
278278
{{"bar.h", R"(#pragma once
279279
#include "private.h"
280280
int bar();
@@ -297,7 +297,7 @@ DECLARE(myfunc) {
297297
std::vector<ClangTidyError> Errors;
298298
EXPECT_EQ(PreCode,
299299
runCheckOnCode<IncludeCleanerCheck>(
300-
PreCode, &Errors, "file.cpp", std::nullopt, ClangTidyOptions(),
300+
PreCode, &Errors, "file.cpp", {}, ClangTidyOptions(),
301301
{{"foo.h",
302302
R"(#pragma once
303303
#define DECLARE(X) void X()
@@ -313,7 +313,7 @@ DECLARE {
313313

314314
EXPECT_EQ(PreCode,
315315
runCheckOnCode<IncludeCleanerCheck>(
316-
PreCode, &Errors, "file.cpp", std::nullopt, ClangTidyOptions(),
316+
PreCode, &Errors, "file.cpp", {}, ClangTidyOptions(),
317317
{{"foo.h",
318318
R"(#pragma once
319319
#define DECLARE void myfunc()

clang-tools-extra/unittests/clang-tidy/IncludeInserterTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ class ObjCGeneratedHeaderInserterCheck : public IncludeInserterCheckBase {
167167
template <typename Check>
168168
std::string runCheckOnCode(StringRef Code, StringRef Filename) {
169169
std::vector<ClangTidyError> Errors;
170-
return test::runCheckOnCode<Check>(Code, &Errors, Filename, std::nullopt,
170+
return test::runCheckOnCode<Check>(Code, &Errors, Filename, {},
171171
ClangTidyOptions(),
172172
{// Main file include
173173
{"clang_tidy/tests/"

clang-tools-extra/unittests/clang-tidy/NamespaceAliaserTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ std::string runChecker(StringRef Code, unsigned ExpectedWarningCount) {
5757
std::vector<ClangTidyError> errors;
5858

5959
std::string result =
60-
test::runCheckOnCode<Check>(Code, &errors, "foo.cc", std::nullopt,
60+
test::runCheckOnCode<Check>(Code, &errors, "foo.cc", {},
6161
ClangTidyOptions(), AdditionalFileContents);
6262

6363
EXPECT_EQ(ExpectedWarningCount, errors.size());

clang-tools-extra/unittests/clang-tidy/ReadabilityModuleTest.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ TEST(BracesAroundStatementsCheckTest, IfElseWithShortStatements) {
256256
" else if (1 == 2) return -2;\n"
257257
" else return -3;\n"
258258
"}",
259-
nullptr, "input.cc", std::nullopt, Options));
259+
nullptr, "input.cc", {}, Options));
260260

261261
// If the last else is an else-if, we also force it.
262262
EXPECT_EQ("int main() {\n"
@@ -269,7 +269,7 @@ TEST(BracesAroundStatementsCheckTest, IfElseWithShortStatements) {
269269
" if (false) return -1;\n"
270270
" else if (1 == 2) return -2;\n"
271271
"}",
272-
nullptr, "input.cc", std::nullopt, Options));
272+
nullptr, "input.cc", {}, Options));
273273
}
274274

275275
TEST(BracesAroundStatementsCheckTest, For) {
@@ -485,7 +485,7 @@ TEST(BracesAroundStatementsCheckTest, Macros) {
485485

486486
#define EXPECT_NO_CHANGES_WITH_OPTS(Check, Opts, Code) \
487487
EXPECT_EQ(Code, runCheckOnCode<Check>(Code, nullptr, "input.cc", \
488-
std::nullopt, Opts))
488+
{}, Opts))
489489
TEST(BracesAroundStatementsCheckTest, ImplicitCastInReturn) {
490490
ClangTidyOptions Opts;
491491
Opts.CheckOptions["test-check-0.ShortStatementLines"] = "1";

clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -260,11 +260,11 @@ TEST(TransformerClangTidyCheckTest, DisableByConfig) {
260260

261261
Options.CheckOptions["test-check-0.Skip"] = "true";
262262
EXPECT_EQ(Input, test::runCheckOnCode<ConfigurableCheck>(
263-
Input, nullptr, "input.cc", std::nullopt, Options));
263+
Input, nullptr, "input.cc", {}, Options));
264264

265265
Options.CheckOptions["test-check-0.Skip"] = "false";
266266
EXPECT_EQ(Expected, test::runCheckOnCode<ConfigurableCheck>(
267-
Input, nullptr, "input.cc", std::nullopt, Options));
267+
Input, nullptr, "input.cc", {}, Options));
268268
}
269269

270270
RewriteRuleWith<std::string> replaceCall(IncludeFormat Format) {
@@ -348,18 +348,18 @@ int h(int x) { return 5; })cc";
348348
Options.CheckOptions["test-check-0.IncludeStyle"] = "llvm";
349349
EXPECT_EQ(TreatsAsLibraryHeader, test::runCheckOnCode<IncludeOrderCheck>(
350350
Input, nullptr, "inputTest.cpp",
351-
std::nullopt, Options, PathsToContent));
351+
{}, Options, PathsToContent));
352352
EXPECT_EQ(TreatsAsNormalHeader, test::runCheckOnCode<IncludeOrderCheck>(
353353
Input, nullptr, "input_test.cpp",
354-
std::nullopt, Options, PathsToContent));
354+
{}, Options, PathsToContent));
355355

356356
Options.CheckOptions["test-check-0.IncludeStyle"] = "google";
357357
EXPECT_EQ(TreatsAsNormalHeader, test::runCheckOnCode<IncludeOrderCheck>(
358358
Input, nullptr, "inputTest.cc",
359-
std::nullopt, Options, PathsToContent));
359+
{}, Options, PathsToContent));
360360
EXPECT_EQ(TreatsAsLibraryHeader, test::runCheckOnCode<IncludeOrderCheck>(
361361
Input, nullptr, "input_test.cc",
362-
std::nullopt, Options, PathsToContent));
362+
{}, Options, PathsToContent));
363363
}
364364

365365
TEST(TransformerClangTidyCheckTest, AddIncludeObeysSortStyleGlobalOption) {
@@ -380,18 +380,18 @@ int h(int x) { return 5; })cc";
380380
Options.CheckOptions["IncludeStyle"] = "llvm";
381381
EXPECT_EQ(TreatsAsLibraryHeader, test::runCheckOnCode<IncludeOrderCheck>(
382382
Input, nullptr, "inputTest.cpp",
383-
std::nullopt, Options, PathsToContent));
383+
{}, Options, PathsToContent));
384384
EXPECT_EQ(TreatsAsNormalHeader, test::runCheckOnCode<IncludeOrderCheck>(
385385
Input, nullptr, "input_test.cpp",
386-
std::nullopt, Options, PathsToContent));
386+
{}, Options, PathsToContent));
387387

388388
Options.CheckOptions["IncludeStyle"] = "google";
389389
EXPECT_EQ(TreatsAsNormalHeader, test::runCheckOnCode<IncludeOrderCheck>(
390390
Input, nullptr, "inputTest.cc",
391-
std::nullopt, Options, PathsToContent));
391+
{}, Options, PathsToContent));
392392
EXPECT_EQ(TreatsAsLibraryHeader, test::runCheckOnCode<IncludeOrderCheck>(
393393
Input, nullptr, "input_test.cc",
394-
std::nullopt, Options, PathsToContent));
394+
{}, Options, PathsToContent));
395395
}
396396

397397
} // namespace

clang-tools-extra/unittests/clang-tidy/UsingInserterTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ std::string runChecker(StringRef Code, unsigned ExpectedWarningCount) {
6161
std::vector<ClangTidyError> errors;
6262

6363
std::string result =
64-
test::runCheckOnCode<Check>(Code, &errors, "foo.cc", std::nullopt,
64+
test::runCheckOnCode<Check>(Code, &errors, "foo.cc", {},
6565
ClangTidyOptions(), AdditionalFileContents);
6666

6767
EXPECT_EQ(ExpectedWarningCount, errors.size());

0 commit comments

Comments
 (0)