Skip to content

Commit

Permalink
Small cleanup changes: added missing dependency, fixed hdrs/srcs mima…
Browse files Browse the repository at this point in the history
…tched, changed throw to FATAL(). (#978)

* Small cleanup changes: added missing dependency, fixed hdrs/srcs mismatched, changed throw to FATAL().

* Replaced FATAL() with CHECK().
  • Loading branch information
pk19604014 authored Dec 9, 2021
1 parent 634148c commit 6808d7a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 15 deletions.
2 changes: 1 addition & 1 deletion common/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ cc_test(

cc_library(
name = "indirect_value",
srcs = ["indirect_value.h"],
hdrs = ["indirect_value.h"],
)

cc_test(
Expand Down
3 changes: 0 additions & 3 deletions toolchain/lexer/string_literal_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,6 @@ TEST_F(StringLiteralTest, StringLiteralBounds) {
}

TEST_F(StringLiteralTest, StringLiteralContents) {
// We use ""s strings to handle embedded nul characters below.
using std::operator""s;

std::pair<llvm::StringLiteral, llvm::StringLiteral> testcases[] = {
// Empty strings.
{R"("")", ""},
Expand Down
1 change: 1 addition & 0 deletions toolchain/parser/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ cc_library(
srcs = ["precedence.cpp"],
hdrs = ["precedence.h"],
deps = [
"//common:check",
"//toolchain/lexer:token_kind",
"@llvm-project//llvm:Support",
],
Expand Down
21 changes: 10 additions & 11 deletions toolchain/parser/precedence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

#include <utility>

#include "common/check.h"

namespace Carbon {

namespace {
Expand Down Expand Up @@ -120,9 +122,8 @@ struct OperatorPriorityTable {
for (int8_t a = 0; a != NumPrecedenceLevels; ++a) {
for (int8_t b = 0; b != NumPrecedenceLevels; ++b) {
if (table[a][b] == OperatorPriority::LeftFirst) {
if (table[b][a] == OperatorPriority::LeftFirst) {
throw "inconsistent lookup table entries";
}
CHECK(table[b][a] != OperatorPriority::LeftFirst)
<< "inconsistent lookup table entries";
table[b][a] = OperatorPriority::RightFirst;
}
}
Expand Down Expand Up @@ -164,16 +165,14 @@ struct OperatorPriorityTable {
constexpr void ConsistencyCheck() {
for (int8_t level = 0; level != NumPrecedenceLevels; ++level) {
if (level != Highest) {
if (table[Highest][level] != OperatorPriority::LeftFirst ||
table[level][Highest] != OperatorPriority::RightFirst) {
throw "Highest is not highest priority";
}
CHECK(table[Highest][level] == OperatorPriority::LeftFirst &&
table[level][Highest] == OperatorPriority::RightFirst)
<< "Highest is not highest priority";
}
if (level != Lowest) {
if (table[Lowest][level] != OperatorPriority::RightFirst ||
table[level][Lowest] != OperatorPriority::LeftFirst) {
throw "Lowest is not lowest priority";
}
CHECK(table[Lowest][level] == OperatorPriority::RightFirst &&
table[level][Lowest] == OperatorPriority::LeftFirst)
<< "Lowest is not lowest priority";
}
}
}
Expand Down

0 comments on commit 6808d7a

Please sign in to comment.