mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-02 22:02:51 +01:00
Run clang-tidy over toolchain (#969)
This commit is contained in:
@@ -57,9 +57,7 @@
|
||||
|
||||
#include "common/ostream.h"
|
||||
|
||||
namespace Carbon {
|
||||
namespace Testing {
|
||||
namespace Yaml {
|
||||
namespace Carbon::Testing::Yaml {
|
||||
|
||||
struct EmptyComparable {
|
||||
friend auto operator==(EmptyComparable, EmptyComparable) -> bool {
|
||||
@@ -144,8 +142,6 @@ MATCHER_P(Scalar, value,
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace Yaml
|
||||
} // namespace Testing
|
||||
} // namespace Carbon
|
||||
} // namespace Carbon::Testing::Yaml
|
||||
|
||||
#endif // TOOLCHAIN_COMMON_YAML_TEST_HELPERS_H_
|
||||
|
||||
@@ -18,8 +18,6 @@ using Testing::DiagnosticAt;
|
||||
using Testing::DiagnosticLevel;
|
||||
using Testing::DiagnosticMessage;
|
||||
using Testing::DiagnosticShortName;
|
||||
using ::testing::ElementsAre;
|
||||
using ::testing::Eq;
|
||||
|
||||
struct FakeDiagnostic {
|
||||
static constexpr llvm::StringLiteral ShortName = "fake-diagnostic";
|
||||
|
||||
@@ -9,8 +9,7 @@
|
||||
|
||||
#include "toolchain/diagnostics/diagnostic_emitter.h"
|
||||
|
||||
namespace Carbon {
|
||||
namespace Testing {
|
||||
namespace Carbon::Testing {
|
||||
|
||||
class MockDiagnosticConsumer : public DiagnosticConsumer {
|
||||
public:
|
||||
@@ -36,7 +35,7 @@ MATCHER_P2(DiagnosticAt, line, column, "") {
|
||||
return true;
|
||||
}
|
||||
|
||||
auto DiagnosticLevel(Diagnostic::Level level) -> auto {
|
||||
inline auto DiagnosticLevel(Diagnostic::Level level) -> auto {
|
||||
return testing::Field(&Diagnostic::level, level);
|
||||
}
|
||||
|
||||
@@ -52,7 +51,6 @@ auto DiagnosticShortName(Matcher&& inner_matcher) -> auto {
|
||||
std::forward<Matcher&&>(inner_matcher));
|
||||
}
|
||||
|
||||
} // namespace Testing
|
||||
} // namespace Carbon
|
||||
} // namespace Carbon::Testing
|
||||
|
||||
#endif // TOOLCHAIN_DIAGNOSTICS_MOCKS_H_
|
||||
|
||||
@@ -15,7 +15,7 @@ inline auto NullDiagnosticLocationTranslator()
|
||||
struct Translator : DiagnosticLocationTranslator<LocationT> {
|
||||
auto GetLocation(LocationT) -> Diagnostic::Location override { return {}; }
|
||||
};
|
||||
static Translator* translator = new Translator;
|
||||
static auto* translator = new Translator;
|
||||
return *translator;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,9 +16,7 @@ namespace Carbon {
|
||||
namespace {
|
||||
|
||||
using ::testing::ElementsAre;
|
||||
using ::testing::Eq;
|
||||
using ::testing::HasSubstr;
|
||||
using ::testing::NotNull;
|
||||
using ::testing::StrEq;
|
||||
namespace Yaml = Carbon::Testing::Yaml;
|
||||
|
||||
|
||||
@@ -31,7 +31,6 @@ using ::Carbon::Testing::HasTokens;
|
||||
using ::testing::ElementsAre;
|
||||
using ::testing::Eq;
|
||||
using ::testing::HasSubstr;
|
||||
using ::testing::NotNull;
|
||||
using ::testing::StrEq;
|
||||
namespace Yaml = Carbon::Testing::Yaml;
|
||||
|
||||
|
||||
@@ -28,9 +28,7 @@ using Carbon::Testing::MatchParseTreeNodes;
|
||||
using namespace Carbon::Testing::NodeMatchers;
|
||||
using ::testing::ElementsAre;
|
||||
using ::testing::Eq;
|
||||
using ::testing::HasSubstr;
|
||||
using ::testing::Ne;
|
||||
using ::testing::NotNull;
|
||||
using ::testing::StrEq;
|
||||
namespace Yaml = Carbon::Testing::Yaml;
|
||||
|
||||
@@ -1071,7 +1069,7 @@ TEST_F(ParseTreeTest, StructErrors) {
|
||||
DiagnosticMessage("Expected `,` or `}`.")},
|
||||
};
|
||||
|
||||
for (Testcase testcase : testcases) {
|
||||
for (const Testcase& testcase : testcases) {
|
||||
TokenizedBuffer tokens = GetTokenizedBuffer(testcase.input);
|
||||
Testing::MockDiagnosticConsumer consumer;
|
||||
EXPECT_CALL(consumer, HandleDiagnostic(testcase.diag_matcher));
|
||||
|
||||
@@ -505,7 +505,7 @@ auto ParseTree::Parser::ParseFunctionSignature() -> bool {
|
||||
auto params = ParseParenList(
|
||||
[&] { return ParseFunctionParameter(); },
|
||||
ParseNodeKind::ParameterListComma(),
|
||||
[&](TokenizedBuffer::Token open_paren, bool is_single_item,
|
||||
[&](TokenizedBuffer::Token open_paren, bool /*is_single_item*/,
|
||||
TokenizedBuffer::Token close_paren, bool has_errors) {
|
||||
AddLeafNode(ParseNodeKind::ParameterListEnd(), close_paren);
|
||||
return AddNode(ParseNodeKind::ParameterList(), open_paren, start,
|
||||
@@ -776,7 +776,7 @@ auto ParseTree::Parser::ParseBraceExpression() -> llvm::Optional<Node> {
|
||||
/*has_error=*/!designator || !type_or_value);
|
||||
},
|
||||
ParseNodeKind::StructComma(),
|
||||
[&](TokenizedBuffer::Token open_brace, bool is_single_item,
|
||||
[&](TokenizedBuffer::Token open_brace, bool /*is_single_item*/,
|
||||
TokenizedBuffer::Token close_brace, bool has_errors) {
|
||||
AddLeafNode(ParseNodeKind::StructEnd(), close_brace);
|
||||
return AddNode(kind == Type ? ParseNodeKind::StructTypeLiteral()
|
||||
@@ -850,7 +850,7 @@ auto ParseTree::Parser::ParseCallExpression(SubtreeStart start, bool has_errors)
|
||||
// ::= expression `,` expression-list
|
||||
return ParseParenList(
|
||||
[&] { return ParseExpression(); }, ParseNodeKind::CallExpressionComma(),
|
||||
[&](TokenizedBuffer::Token open_paren, bool is_single_item,
|
||||
[&](TokenizedBuffer::Token open_paren, bool /*is_single_item*/,
|
||||
TokenizedBuffer::Token close_paren, bool has_arg_errors) {
|
||||
AddLeafNode(ParseNodeKind::CallExpressionEnd(), close_paren);
|
||||
return AddNode(ParseNodeKind::CallExpression(), open_paren, start,
|
||||
@@ -1129,10 +1129,11 @@ auto ParseTree::Parser::ParseIfStatement() -> llvm::Optional<Node> {
|
||||
if (ConsumeAndAddLeafNodeIf(TokenKind::ElseKeyword(),
|
||||
ParseNodeKind::IfStatementElse())) {
|
||||
// 'else if' is permitted as a special case.
|
||||
if (NextTokenIs(TokenKind::IfKeyword()))
|
||||
if (NextTokenIs(TokenKind::IfKeyword())) {
|
||||
else_has_errors = !ParseIfStatement();
|
||||
else
|
||||
} else {
|
||||
else_has_errors = !ParseCodeBlock();
|
||||
}
|
||||
}
|
||||
return AddNode(ParseNodeKind::IfStatement(), if_token, start,
|
||||
/*has_error=*/!cond || !then_case || else_has_errors);
|
||||
|
||||
@@ -99,6 +99,7 @@ struct OperatorPriorityTable {
|
||||
bool changed = false;
|
||||
do {
|
||||
changed = false;
|
||||
// NOLINTNEXTLINE(modernize-loop-convert)
|
||||
for (int8_t a = 0; a != NumPrecedenceLevels; ++a) {
|
||||
for (int8_t b = 0; b != NumPrecedenceLevels; ++b) {
|
||||
if (table[a][b] == OperatorPriority::LeftFirst) {
|
||||
|
||||
Reference in New Issue
Block a user