[clang-tools-extra] [clang-tools-extra] Use {} instead of std::nullopt to initialize empty ArrayRef (PR #109400)
Jay Foad via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 20 03:41:25 PDT 2024
https://github.com/jayfoad updated https://github.com/llvm/llvm-project/pull/109400
>From ebffad800626acbdb06c74633c0950e24df755c8 Mon Sep 17 00:00:00 2001
From: Jay Foad <jay.foad at amd.com>
Date: Fri, 20 Sep 2024 11:16:23 +0100
Subject: [PATCH 1/2] [clang-tools-extra] Use {} instead of std::nullopt to
initialize empty ArrayRef
Follow up to #109133.
---
clang-tools-extra/clang-query/Query.cpp | 2 +-
.../unittests/clang-tidy/ClangTidyTest.h | 2 +-
.../clang-tidy/IncludeCleanerTest.cpp | 22 +++++++++----------
.../clang-tidy/IncludeInserterTest.cpp | 2 +-
.../clang-tidy/NamespaceAliaserTest.cpp | 2 +-
.../clang-tidy/ReadabilityModuleTest.cpp | 6 ++---
.../TransformerClangTidyCheckTest.cpp | 20 ++++++++---------
.../clang-tidy/UsingInserterTest.cpp | 2 +-
8 files changed, 29 insertions(+), 29 deletions(-)
diff --git a/clang-tools-extra/clang-query/Query.cpp b/clang-tools-extra/clang-query/Query.cpp
index 93f4104d39db8c..282d136aff721a 100644
--- a/clang-tools-extra/clang-query/Query.cpp
+++ b/clang-tools-extra/clang-query/Query.cpp
@@ -146,7 +146,7 @@ bool MatchQuery::run(llvm::raw_ostream &OS, QuerySession &QS) const {
TD.emitDiagnostic(
FullSourceLoc(R.getBegin(), AST->getSourceManager()),
DiagnosticsEngine::Note, "\"" + BI->first + "\" binds here",
- CharSourceRange::getTokenRange(R), std::nullopt);
+ CharSourceRange::getTokenRange(R), {});
}
}
if (QS.PrintOutput) {
diff --git a/clang-tools-extra/unittests/clang-tidy/ClangTidyTest.h b/clang-tools-extra/unittests/clang-tidy/ClangTidyTest.h
index 078054c5194c54..e511eb6e49e8df 100644
--- a/clang-tools-extra/unittests/clang-tidy/ClangTidyTest.h
+++ b/clang-tools-extra/unittests/clang-tidy/ClangTidyTest.h
@@ -86,7 +86,7 @@ template <typename... CheckTypes>
std::string
runCheckOnCode(StringRef Code, std::vector<ClangTidyError> *Errors = nullptr,
const Twine &Filename = "input.cc",
- ArrayRef<std::string> ExtraArgs = std::nullopt,
+ ArrayRef<std::string> ExtraArgs = {},
const ClangTidyOptions &ExtraOptions = ClangTidyOptions(),
std::map<StringRef, StringRef> PathsToContent =
std::map<StringRef, StringRef>()) {
diff --git a/clang-tools-extra/unittests/clang-tidy/IncludeCleanerTest.cpp b/clang-tools-extra/unittests/clang-tidy/IncludeCleanerTest.cpp
index 8da1051a860a8c..7344c73aa47dab 100644
--- a/clang-tools-extra/unittests/clang-tidy/IncludeCleanerTest.cpp
+++ b/clang-tools-extra/unittests/clang-tidy/IncludeCleanerTest.cpp
@@ -49,7 +49,7 @@ TEST(IncludeCleanerCheckTest, BasicUnusedIncludes) {
std::vector<ClangTidyError> Errors;
EXPECT_EQ(PostCode,
runCheckOnCode<IncludeCleanerCheck>(
- PreCode, &Errors, "file.cpp", std::nullopt, ClangTidyOptions(),
+ PreCode, &Errors, "file.cpp", {}, ClangTidyOptions(),
{{"bar.h", "#pragma once"}, {"vector", "#pragma once"}}));
}
@@ -78,7 +78,7 @@ TEST(IncludeCleanerCheckTest, SuppressUnusedIncludes) {
EXPECT_EQ(
PostCode,
runCheckOnCode<IncludeCleanerCheck>(
- PreCode, &Errors, "file.cpp", std::nullopt, Opts,
+ PreCode, &Errors, "file.cpp", {}, Opts,
{{"bar.h", "#pragma once"},
{"vector", "#pragma once"},
{"list", "#pragma once"},
@@ -105,7 +105,7 @@ int BazResult = baz();
std::vector<ClangTidyError> Errors;
EXPECT_EQ(PostCode,
runCheckOnCode<IncludeCleanerCheck>(
- PreCode, &Errors, "file.cpp", std::nullopt, ClangTidyOptions(),
+ PreCode, &Errors, "file.cpp", {}, ClangTidyOptions(),
{{"bar.h", R"(#pragma once
#include "baz.h"
int bar();
@@ -125,7 +125,7 @@ int BarResult2 = $diag2^bar();)");
{
std::vector<ClangTidyError> Errors;
runCheckOnCode<IncludeCleanerCheck>(Code.code(), &Errors, "file.cpp",
- std::nullopt, ClangTidyOptions(),
+ {}, ClangTidyOptions(),
{{"baz.h", R"(#pragma once
#include "bar.h"
)"},
@@ -142,7 +142,7 @@ int BarResult2 = $diag2^bar();)");
ClangTidyOptions Opts;
Opts.CheckOptions.insert({"DeduplicateFindings", "false"});
runCheckOnCode<IncludeCleanerCheck>(Code.code(), &Errors, "file.cpp",
- std::nullopt, Opts,
+ {}, Opts,
{{"baz.h", R"(#pragma once
#include "bar.h"
)"},
@@ -176,7 +176,7 @@ std::vector x;
llvm::Regex::escape(appendPathFileSystemIndependent({"foo", "qux.h"}))};
std::vector<ClangTidyError> Errors;
EXPECT_EQ(PreCode, runCheckOnCode<IncludeCleanerCheck>(
- PreCode, &Errors, "file.cpp", std::nullopt, Opts,
+ PreCode, &Errors, "file.cpp", {}, Opts,
{{"bar.h", R"(#pragma once
#include "baz.h"
#include "foo/qux.h"
@@ -217,7 +217,7 @@ int BazResult_1 = baz_1();
std::vector<ClangTidyError> Errors;
EXPECT_EQ(PostCode,
runCheckOnCode<IncludeCleanerCheck>(
- PreCode, &Errors, "file.cpp", std::nullopt, ClangTidyOptions(),
+ PreCode, &Errors, "file.cpp", {}, ClangTidyOptions(),
{{"bar.h", R"(#pragma once
#include "baz.h"
int bar();
@@ -246,7 +246,7 @@ std::vector Vec;
std::vector<ClangTidyError> Errors;
EXPECT_EQ(PostCode,
runCheckOnCode<IncludeCleanerCheck>(
- PreCode, &Errors, "file.cpp", std::nullopt, ClangTidyOptions(),
+ PreCode, &Errors, "file.cpp", {}, ClangTidyOptions(),
{{"string", R"(#pragma once
namespace std { class string {}; }
)"},
@@ -274,7 +274,7 @@ int FooBarResult = foobar();
std::vector<ClangTidyError> Errors;
EXPECT_EQ(PostCode,
runCheckOnCode<IncludeCleanerCheck>(
- PreCode, &Errors, "file.cpp", std::nullopt, ClangTidyOptions(),
+ PreCode, &Errors, "file.cpp", {}, ClangTidyOptions(),
{{"bar.h", R"(#pragma once
#include "private.h"
int bar();
@@ -297,7 +297,7 @@ DECLARE(myfunc) {
std::vector<ClangTidyError> Errors;
EXPECT_EQ(PreCode,
runCheckOnCode<IncludeCleanerCheck>(
- PreCode, &Errors, "file.cpp", std::nullopt, ClangTidyOptions(),
+ PreCode, &Errors, "file.cpp", {}, ClangTidyOptions(),
{{"foo.h",
R"(#pragma once
#define DECLARE(X) void X()
@@ -313,7 +313,7 @@ DECLARE {
EXPECT_EQ(PreCode,
runCheckOnCode<IncludeCleanerCheck>(
- PreCode, &Errors, "file.cpp", std::nullopt, ClangTidyOptions(),
+ PreCode, &Errors, "file.cpp", {}, ClangTidyOptions(),
{{"foo.h",
R"(#pragma once
#define DECLARE void myfunc()
diff --git a/clang-tools-extra/unittests/clang-tidy/IncludeInserterTest.cpp b/clang-tools-extra/unittests/clang-tidy/IncludeInserterTest.cpp
index 71496dd03f9bd8..d01ba9814b8a10 100644
--- a/clang-tools-extra/unittests/clang-tidy/IncludeInserterTest.cpp
+++ b/clang-tools-extra/unittests/clang-tidy/IncludeInserterTest.cpp
@@ -167,7 +167,7 @@ class ObjCGeneratedHeaderInserterCheck : public IncludeInserterCheckBase {
template <typename Check>
std::string runCheckOnCode(StringRef Code, StringRef Filename) {
std::vector<ClangTidyError> Errors;
- return test::runCheckOnCode<Check>(Code, &Errors, Filename, std::nullopt,
+ return test::runCheckOnCode<Check>(Code, &Errors, Filename, {},
ClangTidyOptions(),
{// Main file include
{"clang_tidy/tests/"
diff --git a/clang-tools-extra/unittests/clang-tidy/NamespaceAliaserTest.cpp b/clang-tools-extra/unittests/clang-tidy/NamespaceAliaserTest.cpp
index dfe04c175b791a..8b5ebcdd5c0399 100644
--- a/clang-tools-extra/unittests/clang-tidy/NamespaceAliaserTest.cpp
+++ b/clang-tools-extra/unittests/clang-tidy/NamespaceAliaserTest.cpp
@@ -57,7 +57,7 @@ std::string runChecker(StringRef Code, unsigned ExpectedWarningCount) {
std::vector<ClangTidyError> errors;
std::string result =
- test::runCheckOnCode<Check>(Code, &errors, "foo.cc", std::nullopt,
+ test::runCheckOnCode<Check>(Code, &errors, "foo.cc", {},
ClangTidyOptions(), AdditionalFileContents);
EXPECT_EQ(ExpectedWarningCount, errors.size());
diff --git a/clang-tools-extra/unittests/clang-tidy/ReadabilityModuleTest.cpp b/clang-tools-extra/unittests/clang-tidy/ReadabilityModuleTest.cpp
index ec53f52466afda..f80fba7f17bbac 100644
--- a/clang-tools-extra/unittests/clang-tidy/ReadabilityModuleTest.cpp
+++ b/clang-tools-extra/unittests/clang-tidy/ReadabilityModuleTest.cpp
@@ -256,7 +256,7 @@ TEST(BracesAroundStatementsCheckTest, IfElseWithShortStatements) {
" else if (1 == 2) return -2;\n"
" else return -3;\n"
"}",
- nullptr, "input.cc", std::nullopt, Options));
+ nullptr, "input.cc", {}, Options));
// If the last else is an else-if, we also force it.
EXPECT_EQ("int main() {\n"
@@ -269,7 +269,7 @@ TEST(BracesAroundStatementsCheckTest, IfElseWithShortStatements) {
" if (false) return -1;\n"
" else if (1 == 2) return -2;\n"
"}",
- nullptr, "input.cc", std::nullopt, Options));
+ nullptr, "input.cc", {}, Options));
}
TEST(BracesAroundStatementsCheckTest, For) {
@@ -485,7 +485,7 @@ TEST(BracesAroundStatementsCheckTest, Macros) {
#define EXPECT_NO_CHANGES_WITH_OPTS(Check, Opts, Code) \
EXPECT_EQ(Code, runCheckOnCode<Check>(Code, nullptr, "input.cc", \
- std::nullopt, Opts))
+ {}, Opts))
TEST(BracesAroundStatementsCheckTest, ImplicitCastInReturn) {
ClangTidyOptions Opts;
Opts.CheckOptions["test-check-0.ShortStatementLines"] = "1";
diff --git a/clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp b/clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp
index 42d40d32bfa51e..bf8ceaac717c7f 100644
--- a/clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp
+++ b/clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp
@@ -260,11 +260,11 @@ TEST(TransformerClangTidyCheckTest, DisableByConfig) {
Options.CheckOptions["test-check-0.Skip"] = "true";
EXPECT_EQ(Input, test::runCheckOnCode<ConfigurableCheck>(
- Input, nullptr, "input.cc", std::nullopt, Options));
+ Input, nullptr, "input.cc", {}, Options));
Options.CheckOptions["test-check-0.Skip"] = "false";
EXPECT_EQ(Expected, test::runCheckOnCode<ConfigurableCheck>(
- Input, nullptr, "input.cc", std::nullopt, Options));
+ Input, nullptr, "input.cc", {}, Options));
}
RewriteRuleWith<std::string> replaceCall(IncludeFormat Format) {
@@ -348,18 +348,18 @@ int h(int x) { return 5; })cc";
Options.CheckOptions["test-check-0.IncludeStyle"] = "llvm";
EXPECT_EQ(TreatsAsLibraryHeader, test::runCheckOnCode<IncludeOrderCheck>(
Input, nullptr, "inputTest.cpp",
- std::nullopt, Options, PathsToContent));
+ {}, Options, PathsToContent));
EXPECT_EQ(TreatsAsNormalHeader, test::runCheckOnCode<IncludeOrderCheck>(
Input, nullptr, "input_test.cpp",
- std::nullopt, Options, PathsToContent));
+ {}, Options, PathsToContent));
Options.CheckOptions["test-check-0.IncludeStyle"] = "google";
EXPECT_EQ(TreatsAsNormalHeader, test::runCheckOnCode<IncludeOrderCheck>(
Input, nullptr, "inputTest.cc",
- std::nullopt, Options, PathsToContent));
+ {}, Options, PathsToContent));
EXPECT_EQ(TreatsAsLibraryHeader, test::runCheckOnCode<IncludeOrderCheck>(
Input, nullptr, "input_test.cc",
- std::nullopt, Options, PathsToContent));
+ {}, Options, PathsToContent));
}
TEST(TransformerClangTidyCheckTest, AddIncludeObeysSortStyleGlobalOption) {
@@ -380,18 +380,18 @@ int h(int x) { return 5; })cc";
Options.CheckOptions["IncludeStyle"] = "llvm";
EXPECT_EQ(TreatsAsLibraryHeader, test::runCheckOnCode<IncludeOrderCheck>(
Input, nullptr, "inputTest.cpp",
- std::nullopt, Options, PathsToContent));
+ {}, Options, PathsToContent));
EXPECT_EQ(TreatsAsNormalHeader, test::runCheckOnCode<IncludeOrderCheck>(
Input, nullptr, "input_test.cpp",
- std::nullopt, Options, PathsToContent));
+ {}, Options, PathsToContent));
Options.CheckOptions["IncludeStyle"] = "google";
EXPECT_EQ(TreatsAsNormalHeader, test::runCheckOnCode<IncludeOrderCheck>(
Input, nullptr, "inputTest.cc",
- std::nullopt, Options, PathsToContent));
+ {}, Options, PathsToContent));
EXPECT_EQ(TreatsAsLibraryHeader, test::runCheckOnCode<IncludeOrderCheck>(
Input, nullptr, "input_test.cc",
- std::nullopt, Options, PathsToContent));
+ {}, Options, PathsToContent));
}
} // namespace
diff --git a/clang-tools-extra/unittests/clang-tidy/UsingInserterTest.cpp b/clang-tools-extra/unittests/clang-tidy/UsingInserterTest.cpp
index 717d2bed15fd1f..5c0356c953ada7 100644
--- a/clang-tools-extra/unittests/clang-tidy/UsingInserterTest.cpp
+++ b/clang-tools-extra/unittests/clang-tidy/UsingInserterTest.cpp
@@ -61,7 +61,7 @@ std::string runChecker(StringRef Code, unsigned ExpectedWarningCount) {
std::vector<ClangTidyError> errors;
std::string result =
- test::runCheckOnCode<Check>(Code, &errors, "foo.cc", std::nullopt,
+ test::runCheckOnCode<Check>(Code, &errors, "foo.cc", {},
ClangTidyOptions(), AdditionalFileContents);
EXPECT_EQ(ExpectedWarningCount, errors.size());
>From 49165b5da6c488452928a590ab21609710df5168 Mon Sep 17 00:00:00 2001
From: Jay Foad <jay.foad at amd.com>
Date: Fri, 20 Sep 2024 11:41:11 +0100
Subject: [PATCH 2/2] clang-format
---
.../clang-tidy/IncludeCleanerTest.cpp | 62 +++++++++----------
.../clang-tidy/NamespaceAliaserTest.cpp | 5 +-
.../clang-tidy/ReadabilityModuleTest.cpp | 3 +-
.../TransformerClangTidyCheckTest.cpp | 48 +++++++-------
.../clang-tidy/UsingInserterTest.cpp | 5 +-
5 files changed, 57 insertions(+), 66 deletions(-)
diff --git a/clang-tools-extra/unittests/clang-tidy/IncludeCleanerTest.cpp b/clang-tools-extra/unittests/clang-tidy/IncludeCleanerTest.cpp
index 7344c73aa47dab..d400cf6fe2d576 100644
--- a/clang-tools-extra/unittests/clang-tidy/IncludeCleanerTest.cpp
+++ b/clang-tools-extra/unittests/clang-tidy/IncludeCleanerTest.cpp
@@ -103,14 +103,13 @@ int BazResult = baz();
)";
std::vector<ClangTidyError> Errors;
- EXPECT_EQ(PostCode,
- runCheckOnCode<IncludeCleanerCheck>(
- PreCode, &Errors, "file.cpp", {}, ClangTidyOptions(),
- {{"bar.h", R"(#pragma once
+ EXPECT_EQ(PostCode, runCheckOnCode<IncludeCleanerCheck>(
+ PreCode, &Errors, "file.cpp", {}, ClangTidyOptions(),
+ {{"bar.h", R"(#pragma once
#include "baz.h"
int bar();
)"},
- {"baz.h", R"(#pragma once
+ {"baz.h", R"(#pragma once
int baz();
)"}}));
}
@@ -124,8 +123,8 @@ int BarResult2 = $diag2^bar();)");
{
std::vector<ClangTidyError> Errors;
- runCheckOnCode<IncludeCleanerCheck>(Code.code(), &Errors, "file.cpp",
- {}, ClangTidyOptions(),
+ runCheckOnCode<IncludeCleanerCheck>(Code.code(), &Errors, "file.cpp", {},
+ ClangTidyOptions(),
{{"baz.h", R"(#pragma once
#include "bar.h"
)"},
@@ -141,8 +140,8 @@ int BarResult2 = $diag2^bar();)");
std::vector<ClangTidyError> Errors;
ClangTidyOptions Opts;
Opts.CheckOptions.insert({"DeduplicateFindings", "false"});
- runCheckOnCode<IncludeCleanerCheck>(Code.code(), &Errors, "file.cpp",
- {}, Opts,
+ runCheckOnCode<IncludeCleanerCheck>(Code.code(), &Errors, "file.cpp", {},
+ Opts,
{{"baz.h", R"(#pragma once
#include "bar.h"
)"},
@@ -215,14 +214,13 @@ int BazResult_1 = baz_1();
)";
std::vector<ClangTidyError> Errors;
- EXPECT_EQ(PostCode,
- runCheckOnCode<IncludeCleanerCheck>(
- PreCode, &Errors, "file.cpp", {}, ClangTidyOptions(),
- {{"bar.h", R"(#pragma once
+ EXPECT_EQ(PostCode, runCheckOnCode<IncludeCleanerCheck>(
+ PreCode, &Errors, "file.cpp", {}, ClangTidyOptions(),
+ {{"bar.h", R"(#pragma once
#include "baz.h"
int bar();
)"},
- {"baz.h", R"(#pragma once
+ {"baz.h", R"(#pragma once
int baz_0();
int baz_1();
)"}}));
@@ -244,13 +242,12 @@ std::vector Vec;
)";
std::vector<ClangTidyError> Errors;
- EXPECT_EQ(PostCode,
- runCheckOnCode<IncludeCleanerCheck>(
- PreCode, &Errors, "file.cpp", {}, ClangTidyOptions(),
- {{"string", R"(#pragma once
+ EXPECT_EQ(PostCode, runCheckOnCode<IncludeCleanerCheck>(
+ PreCode, &Errors, "file.cpp", {}, ClangTidyOptions(),
+ {{"string", R"(#pragma once
namespace std { class string {}; }
)"},
- {"vector", R"(#pragma once
+ {"vector", R"(#pragma once
#include <string>
namespace std { class vector {}; }
)"}}));
@@ -272,14 +269,13 @@ int FooBarResult = foobar();
)";
std::vector<ClangTidyError> Errors;
- EXPECT_EQ(PostCode,
- runCheckOnCode<IncludeCleanerCheck>(
- PreCode, &Errors, "file.cpp", {}, ClangTidyOptions(),
- {{"bar.h", R"(#pragma once
+ EXPECT_EQ(PostCode, runCheckOnCode<IncludeCleanerCheck>(
+ PreCode, &Errors, "file.cpp", {}, ClangTidyOptions(),
+ {{"bar.h", R"(#pragma once
#include "private.h"
int bar();
)"},
- {"private.h", R"(#pragma once
+ {"private.h", R"(#pragma once
// IWYU pragma: private, include "public.h"
int foobar();
)"}}));
@@ -295,11 +291,10 @@ DECLARE(myfunc) {
)";
std::vector<ClangTidyError> Errors;
- EXPECT_EQ(PreCode,
- runCheckOnCode<IncludeCleanerCheck>(
- PreCode, &Errors, "file.cpp", {}, ClangTidyOptions(),
- {{"foo.h",
- R"(#pragma once
+ EXPECT_EQ(PreCode, runCheckOnCode<IncludeCleanerCheck>(
+ PreCode, &Errors, "file.cpp", {}, ClangTidyOptions(),
+ {{"foo.h",
+ R"(#pragma once
#define DECLARE(X) void X()
)"}}));
@@ -311,11 +306,10 @@ DECLARE {
}
)";
- EXPECT_EQ(PreCode,
- runCheckOnCode<IncludeCleanerCheck>(
- PreCode, &Errors, "file.cpp", {}, ClangTidyOptions(),
- {{"foo.h",
- R"(#pragma once
+ EXPECT_EQ(PreCode, runCheckOnCode<IncludeCleanerCheck>(
+ PreCode, &Errors, "file.cpp", {}, ClangTidyOptions(),
+ {{"foo.h",
+ R"(#pragma once
#define DECLARE void myfunc()
)"}}));
}
diff --git a/clang-tools-extra/unittests/clang-tidy/NamespaceAliaserTest.cpp b/clang-tools-extra/unittests/clang-tidy/NamespaceAliaserTest.cpp
index 8b5ebcdd5c0399..fe5fdfa54c7606 100644
--- a/clang-tools-extra/unittests/clang-tidy/NamespaceAliaserTest.cpp
+++ b/clang-tools-extra/unittests/clang-tidy/NamespaceAliaserTest.cpp
@@ -56,9 +56,8 @@ std::string runChecker(StringRef Code, unsigned ExpectedWarningCount) {
"}"}};
std::vector<ClangTidyError> errors;
- std::string result =
- test::runCheckOnCode<Check>(Code, &errors, "foo.cc", {},
- ClangTidyOptions(), AdditionalFileContents);
+ std::string result = test::runCheckOnCode<Check>(
+ Code, &errors, "foo.cc", {}, ClangTidyOptions(), AdditionalFileContents);
EXPECT_EQ(ExpectedWarningCount, errors.size());
return result;
diff --git a/clang-tools-extra/unittests/clang-tidy/ReadabilityModuleTest.cpp b/clang-tools-extra/unittests/clang-tidy/ReadabilityModuleTest.cpp
index f80fba7f17bbac..72f21aeae2c640 100644
--- a/clang-tools-extra/unittests/clang-tidy/ReadabilityModuleTest.cpp
+++ b/clang-tools-extra/unittests/clang-tidy/ReadabilityModuleTest.cpp
@@ -484,8 +484,7 @@ TEST(BracesAroundStatementsCheckTest, Macros) {
}
#define EXPECT_NO_CHANGES_WITH_OPTS(Check, Opts, Code) \
- EXPECT_EQ(Code, runCheckOnCode<Check>(Code, nullptr, "input.cc", \
- {}, Opts))
+ EXPECT_EQ(Code, runCheckOnCode<Check>(Code, nullptr, "input.cc", {}, Opts))
TEST(BracesAroundStatementsCheckTest, ImplicitCastInReturn) {
ClangTidyOptions Opts;
Opts.CheckOptions["test-check-0.ShortStatementLines"] = "1";
diff --git a/clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp b/clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp
index bf8ceaac717c7f..fc43f2579e8e28 100644
--- a/clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp
+++ b/clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp
@@ -346,20 +346,20 @@ int h(int x) { return 5; })cc";
ClangTidyOptions Options;
std::map<StringRef, StringRef> PathsToContent = {{"input.h", "\n"}};
Options.CheckOptions["test-check-0.IncludeStyle"] = "llvm";
- EXPECT_EQ(TreatsAsLibraryHeader, test::runCheckOnCode<IncludeOrderCheck>(
- Input, nullptr, "inputTest.cpp",
- {}, Options, PathsToContent));
- EXPECT_EQ(TreatsAsNormalHeader, test::runCheckOnCode<IncludeOrderCheck>(
- Input, nullptr, "input_test.cpp",
- {}, Options, PathsToContent));
+ EXPECT_EQ(TreatsAsLibraryHeader,
+ test::runCheckOnCode<IncludeOrderCheck>(
+ Input, nullptr, "inputTest.cpp", {}, Options, PathsToContent));
+ EXPECT_EQ(TreatsAsNormalHeader,
+ test::runCheckOnCode<IncludeOrderCheck>(
+ Input, nullptr, "input_test.cpp", {}, Options, PathsToContent));
Options.CheckOptions["test-check-0.IncludeStyle"] = "google";
- EXPECT_EQ(TreatsAsNormalHeader, test::runCheckOnCode<IncludeOrderCheck>(
- Input, nullptr, "inputTest.cc",
- {}, Options, PathsToContent));
- EXPECT_EQ(TreatsAsLibraryHeader, test::runCheckOnCode<IncludeOrderCheck>(
- Input, nullptr, "input_test.cc",
- {}, Options, PathsToContent));
+ EXPECT_EQ(TreatsAsNormalHeader,
+ test::runCheckOnCode<IncludeOrderCheck>(
+ Input, nullptr, "inputTest.cc", {}, Options, PathsToContent));
+ EXPECT_EQ(TreatsAsLibraryHeader,
+ test::runCheckOnCode<IncludeOrderCheck>(
+ Input, nullptr, "input_test.cc", {}, Options, PathsToContent));
}
TEST(TransformerClangTidyCheckTest, AddIncludeObeysSortStyleGlobalOption) {
@@ -378,20 +378,20 @@ int h(int x) { return 5; })cc";
ClangTidyOptions Options;
std::map<StringRef, StringRef> PathsToContent = {{"input.h", "\n"}};
Options.CheckOptions["IncludeStyle"] = "llvm";
- EXPECT_EQ(TreatsAsLibraryHeader, test::runCheckOnCode<IncludeOrderCheck>(
- Input, nullptr, "inputTest.cpp",
- {}, Options, PathsToContent));
- EXPECT_EQ(TreatsAsNormalHeader, test::runCheckOnCode<IncludeOrderCheck>(
- Input, nullptr, "input_test.cpp",
- {}, Options, PathsToContent));
+ EXPECT_EQ(TreatsAsLibraryHeader,
+ test::runCheckOnCode<IncludeOrderCheck>(
+ Input, nullptr, "inputTest.cpp", {}, Options, PathsToContent));
+ EXPECT_EQ(TreatsAsNormalHeader,
+ test::runCheckOnCode<IncludeOrderCheck>(
+ Input, nullptr, "input_test.cpp", {}, Options, PathsToContent));
Options.CheckOptions["IncludeStyle"] = "google";
- EXPECT_EQ(TreatsAsNormalHeader, test::runCheckOnCode<IncludeOrderCheck>(
- Input, nullptr, "inputTest.cc",
- {}, Options, PathsToContent));
- EXPECT_EQ(TreatsAsLibraryHeader, test::runCheckOnCode<IncludeOrderCheck>(
- Input, nullptr, "input_test.cc",
- {}, Options, PathsToContent));
+ EXPECT_EQ(TreatsAsNormalHeader,
+ test::runCheckOnCode<IncludeOrderCheck>(
+ Input, nullptr, "inputTest.cc", {}, Options, PathsToContent));
+ EXPECT_EQ(TreatsAsLibraryHeader,
+ test::runCheckOnCode<IncludeOrderCheck>(
+ Input, nullptr, "input_test.cc", {}, Options, PathsToContent));
}
} // namespace
diff --git a/clang-tools-extra/unittests/clang-tidy/UsingInserterTest.cpp b/clang-tools-extra/unittests/clang-tidy/UsingInserterTest.cpp
index 5c0356c953ada7..69b73c303e0280 100644
--- a/clang-tools-extra/unittests/clang-tidy/UsingInserterTest.cpp
+++ b/clang-tools-extra/unittests/clang-tidy/UsingInserterTest.cpp
@@ -60,9 +60,8 @@ std::string runChecker(StringRef Code, unsigned ExpectedWarningCount) {
"}"}};
std::vector<ClangTidyError> errors;
- std::string result =
- test::runCheckOnCode<Check>(Code, &errors, "foo.cc", {},
- ClangTidyOptions(), AdditionalFileContents);
+ std::string result = test::runCheckOnCode<Check>(
+ Code, &errors, "foo.cc", {}, ClangTidyOptions(), AdditionalFileContents);
EXPECT_EQ(ExpectedWarningCount, errors.size());
return result;
More information about the cfe-commits
mailing list