[torque] Add naming convention check for struct names
R=sigurds@chromium.org Bug: v8:7793 Change-Id: Id0ba3a7b9f168e661ca786a0f1e18cd58c9210aa Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1593073 Reviewed-by: Sigurd Schneider <sigurds@chromium.org> Commit-Queue: Simon Zünd <szuend@chromium.org> Cr-Commit-Position: refs/heads/master@{#61147}
This commit is contained in:
parent
444ee7bda4
commit
6b9af6b7cf
@ -616,6 +616,9 @@ base::Optional<ParseResult> MakeSpecializationDeclaration(
|
||||
base::Optional<ParseResult> MakeStructDeclaration(
|
||||
ParseResultIterator* child_results) {
|
||||
auto name = child_results->NextAs<Identifier*>();
|
||||
if (!IsValidTypeName(name->value)) {
|
||||
NamingConventionError("Struct", name->value, "UpperCamelCase");
|
||||
}
|
||||
auto methods = child_results->NextAs<std::vector<Declaration*>>();
|
||||
auto fields = child_results->NextAs<std::vector<StructFieldExpression>>();
|
||||
Declaration* result =
|
||||
|
@ -11,6 +11,19 @@ namespace v8 {
|
||||
namespace internal {
|
||||
namespace torque {
|
||||
|
||||
namespace {
|
||||
|
||||
TorqueCompilerResult TestCompileTorque(const std::string& source) {
|
||||
TorqueCompilerOptions options;
|
||||
options.output_directory = "";
|
||||
options.verbose = false;
|
||||
options.collect_language_server_data = false;
|
||||
|
||||
return CompileTorque(source, options);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
TEST(Torque, StackDeleteRange) {
|
||||
Stack<int> stack = {1, 2, 3, 4, 5, 6, 7};
|
||||
stack.DeleteRange(StackRange{BottomOffset{2}, BottomOffset{4}});
|
||||
@ -27,12 +40,21 @@ TEST(Torque, TypeNamingConventionLintError) {
|
||||
type foo generates 'TNode<Foo>';
|
||||
)";
|
||||
|
||||
TorqueCompilerOptions options;
|
||||
options.output_directory = "";
|
||||
options.verbose = false;
|
||||
options.collect_language_server_data = false;
|
||||
const TorqueCompilerResult result = TestCompileTorque(source);
|
||||
|
||||
const TorqueCompilerResult result = CompileTorque(source, options);
|
||||
ASSERT_EQ(result.lint_errors.size(), static_cast<size_t>(1));
|
||||
EXPECT_THAT(result.lint_errors[0].message, HasSubstr("\"foo\""));
|
||||
}
|
||||
|
||||
TEST(Torque, StructNamingConventionLintError) {
|
||||
const std::string source = R"(
|
||||
type void;
|
||||
type never;
|
||||
|
||||
struct foo {}
|
||||
)";
|
||||
|
||||
const TorqueCompilerResult result = TestCompileTorque(source);
|
||||
|
||||
ASSERT_EQ(result.lint_errors.size(), static_cast<size_t>(1));
|
||||
EXPECT_THAT(result.lint_errors[0].message, HasSubstr("\"foo\""));
|
||||
|
Loading…
Reference in New Issue
Block a user