[torque] Add lint rules for redundant clauses
This change adds two simple lint rules to prevent including 'generates' or 'constexpr' clauses in cases where they have no impact on behavior. Bug: v8:7793 Change-Id: Ib1d8fde39ca26735ff9cb7892f01e464619c2090 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2590515 Reviewed-by: Tobias Tebbi <tebbi@chromium.org> Commit-Queue: Seth Brenith <seth.brenith@microsoft.com> Cr-Commit-Position: refs/heads/master@{#71831}
This commit is contained in:
parent
eafc0eee95
commit
a14107f73d
@ -17,7 +17,7 @@ namespace constructor {
|
||||
|
||||
extern builtin FastNewObject(Context, JSFunction, JSReceiver): JSObject;
|
||||
|
||||
extern enum AllocationSiteMode constexpr 'AllocationSiteMode' {
|
||||
extern enum AllocationSiteMode {
|
||||
DONT_TRACK_ALLOCATION_SITE,
|
||||
TRACK_ALLOCATION_SITE
|
||||
}
|
||||
|
@ -2,8 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
extern enum IterationKind extends uint31
|
||||
constexpr 'IterationKind' { kKeys, kValues, kEntries }
|
||||
extern enum IterationKind extends uint31 { kKeys, kValues, kEntries }
|
||||
|
||||
extern class JSArrayIterator extends JSObject {
|
||||
iterated_object: JSReceiver;
|
||||
|
@ -1281,6 +1281,9 @@ base::Optional<ParseResult> MakeEnumDeclaration(
|
||||
NamingConventionError("Type", name, "UpperCamelCase");
|
||||
}
|
||||
|
||||
if (constexpr_generates_opt && *constexpr_generates_opt == name) {
|
||||
Lint("Unnecessary 'constexpr' clause for enum ", name);
|
||||
}
|
||||
auto constexpr_generates =
|
||||
constexpr_generates_opt ? *constexpr_generates_opt : name;
|
||||
const bool generate_nonconstexpr = base_type_expression.has_value();
|
||||
|
@ -300,7 +300,12 @@ const ClassType* TypeVisitor::ComputeType(
|
||||
if (flags & ClassFlag::kExtern) {
|
||||
if (decl->generates) {
|
||||
bool enforce_tnode_type = true;
|
||||
generates = ComputeGeneratesType(decl->generates, enforce_tnode_type);
|
||||
std::string explicit_generates =
|
||||
ComputeGeneratesType(decl->generates, enforce_tnode_type);
|
||||
if (explicit_generates == generates) {
|
||||
Lint("Unnecessary 'generates' clause for class ", decl->name->value);
|
||||
}
|
||||
generates = explicit_generates;
|
||||
}
|
||||
if (flags & ClassFlag::kExport) {
|
||||
Error("cannot export a class that is marked extern");
|
||||
|
Loading…
Reference in New Issue
Block a user