Skip to content

Commit

Permalink
Run clang-tidy over toolchain (#969)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonmeow authored Dec 6, 2021
1 parent beea60d commit 5f0da88
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 25 deletions.
8 changes: 2 additions & 6 deletions toolchain/common/yaml_test_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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_
2 changes: 0 additions & 2 deletions toolchain/diagnostics/diagnostic_emitter_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
8 changes: 3 additions & 5 deletions toolchain/diagnostics/mocks.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@

#include "toolchain/diagnostics/diagnostic_emitter.h"

namespace Carbon {
namespace Testing {
namespace Carbon::Testing {

class MockDiagnosticConsumer : public DiagnosticConsumer {
public:
Expand All @@ -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);
}

Expand All @@ -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_
2 changes: 1 addition & 1 deletion toolchain/diagnostics/null_diagnostics.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 0 additions & 2 deletions toolchain/driver/driver_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
1 change: 0 additions & 1 deletion toolchain/lexer/tokenized_buffer_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 1 addition & 3 deletions toolchain/parser/parse_tree_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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));
Expand Down
11 changes: 6 additions & 5 deletions toolchain/parser/parser_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions toolchain/parser/precedence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 5f0da88

Please sign in to comment.