diff --git a/src/tint/ast/enable.cc b/src/tint/ast/enable.cc index acb669f8b2..a611cfbe19 100644 --- a/src/tint/ast/enable.cc +++ b/src/tint/ast/enable.cc @@ -34,7 +34,7 @@ Enable::ExtensionKind Enable::NameToKind(const std::string& name) { return Enable::ExtensionKind::kInternalExtensionForTesting; } - return Enable::ExtensionKind::kNotAnExtension; + return Enable::ExtensionKind::kNoExtension; } std::string Enable::KindToName(ExtensionKind kind) { @@ -47,8 +47,8 @@ std::string Enable::KindToName(ExtensionKind kind) { // The reserved internal extension for testing case ExtensionKind::kInternalExtensionForTesting: return "InternalExtensionForTesting"; - case ExtensionKind::kNotAnExtension: - // Return an empty string for kNotAnExtension + case ExtensionKind::kNoExtension: + // Return an empty string for kNoExtension return {}; // No default case, as this switch must cover all ExtensionKind values. } diff --git a/src/tint/ast/enable.h b/src/tint/ast/enable.h index c5d1bdd653..69622e0033 100644 --- a/src/tint/ast/enable.h +++ b/src/tint/ast/enable.h @@ -32,6 +32,10 @@ class Enable : public Castable { public: /// The enum class identifing each supported WGSL extension enum class ExtensionKind { + /// An internal reserved extension for test, named + /// "InternalExtensionForTesting". + kInternalExtensionForTesting, + /// An extension for the experimental feature /// "chromium_experimental_dp4a". /// See crbug.com/tint/1497 for more details @@ -39,28 +43,26 @@ class Enable : public Castable { /// A Chromium-specific extension for disabling uniformity analysis. kChromiumDisableUniformityAnalysis, - /// An internal reserved extension for test, named - /// "InternalExtensionForTesting" - kInternalExtensionForTesting = -2, - kNotAnExtension = -1, + /// Reserved for representing "No extension required" or "Not a valid extension". + kNoExtension, }; /// Convert a string of extension name into one of ExtensionKind enum value, - /// the result will be ExtensionKind::kNotAnExtension if the name is not a - /// known extension name. A extension node of kind kNotAnExtension must not + /// the result will be ExtensionKind::kNoExtension if the name is not a + /// known extension name. A extension node of kind kNoExtension must not /// exist in the AST tree, and using a unknown extension name in WGSL code /// should result in a shader-creation error. /// @param name string of the extension name /// @return the ExtensionKind enum value for the extension of given name, or - /// kNotAnExtension if no known extension has the given name + /// kNoExtension if no known extension has the given name static ExtensionKind NameToKind(const std::string& name); /// Convert the ExtensionKind enum value to corresponding extension name - /// string. If the given enum value is kNotAnExtension or don't have a known + /// string. If the given enum value is kNoExtension or don't have a known /// name, return an empty string instead. /// @param kind the ExtensionKind enum value /// @return string of the extension name corresponding to the given kind, or - /// an empty string if the given enum value is kNotAnExtension or don't have a + /// an empty string if the given enum value is kNoExtension or don't have a /// known corresponding name static std::string KindToName(ExtensionKind kind); diff --git a/src/tint/ast/enable_test.cc b/src/tint/ast/enable_test.cc index 9fde780a5e..208c85df89 100644 --- a/src/tint/ast/enable_test.cc +++ b/src/tint/ast/enable_test.cc @@ -39,20 +39,20 @@ TEST_F(AstExtensionTest, Creation_InvalidName) { EXPECT_EQ(ext->source.range.begin.column, 2u); EXPECT_EQ(ext->source.range.end.line, 20u); EXPECT_EQ(ext->source.range.end.column, 5u); - EXPECT_EQ(ext->kind, ast::Enable::ExtensionKind::kNotAnExtension); + EXPECT_EQ(ext->kind, ast::Enable::ExtensionKind::kNoExtension); } TEST_F(AstExtensionTest, NameToKind_InvalidName) { - EXPECT_EQ(ast::Enable::NameToKind(std::string()), ast::Enable::ExtensionKind::kNotAnExtension); + EXPECT_EQ(ast::Enable::NameToKind(std::string()), ast::Enable::ExtensionKind::kNoExtension); EXPECT_EQ(ast::Enable::NameToKind("__ImpossibleExtensionName"), - ast::Enable::ExtensionKind::kNotAnExtension); - EXPECT_EQ(ast::Enable::NameToKind("123"), ast::Enable::ExtensionKind::kNotAnExtension); + ast::Enable::ExtensionKind::kNoExtension); + EXPECT_EQ(ast::Enable::NameToKind("123"), ast::Enable::ExtensionKind::kNoExtension); } TEST_F(AstExtensionTest, KindToName) { EXPECT_EQ(ast::Enable::KindToName(ast::Enable::ExtensionKind::kInternalExtensionForTesting), "InternalExtensionForTesting"); - EXPECT_EQ(ast::Enable::KindToName(ast::Enable::ExtensionKind::kNotAnExtension), std::string()); + EXPECT_EQ(ast::Enable::KindToName(ast::Enable::ExtensionKind::kNoExtension), std::string()); } } // namespace diff --git a/src/tint/reader/wgsl/parser_impl.cc b/src/tint/reader/wgsl/parser_impl.cc index c0ea04bc3b..e684790dcd 100644 --- a/src/tint/reader/wgsl/parser_impl.cc +++ b/src/tint/reader/wgsl/parser_impl.cc @@ -358,7 +358,7 @@ Maybe ParserImpl::enable_directive() { return Failure::kErrored; } - if (ast::Enable::NameToKind(name.value) != ast::Enable::ExtensionKind::kNotAnExtension) { + if (ast::Enable::NameToKind(name.value) != ast::Enable::ExtensionKind::kNoExtension) { const ast::Enable* extension = create(name.source, name.value); builder_.AST().AddEnable(extension); } else { diff --git a/src/tint/resolver/validator.cc b/src/tint/resolver/validator.cc index f9b0ba7c68..7a66ec4f61 100644 --- a/src/tint/resolver/validator.cc +++ b/src/tint/resolver/validator.cc @@ -1525,7 +1525,7 @@ bool Validator::RequiredExtensionForBuiltinFunction(const sem::Call* call, } const auto extension = builtin->RequiredExtension(); - if (extension == ast::Enable::ExtensionKind::kNotAnExtension) { + if (extension == ast::Enable::ExtensionKind::kNoExtension) { return true; } diff --git a/src/tint/sem/builtin.cc b/src/tint/sem/builtin.cc index f102307c5c..faf451e01a 100644 --- a/src/tint/sem/builtin.cc +++ b/src/tint/sem/builtin.cc @@ -157,7 +157,7 @@ ast::Enable::ExtensionKind Builtin::RequiredExtension() const { if (IsDP4a()) { return ast::Enable::ExtensionKind::kChromiumExperimentalDP4a; } - return ast::Enable::ExtensionKind::kNotAnExtension; + return ast::Enable::ExtensionKind::kNoExtension; } } // namespace tint::sem diff --git a/src/tint/sem/builtin.h b/src/tint/sem/builtin.h index 5d340ce461..4752f1608d 100644 --- a/src/tint/sem/builtin.h +++ b/src/tint/sem/builtin.h @@ -144,7 +144,7 @@ class Builtin final : public Castable { bool HasSideEffects() const; /// @returns the required extension of this builtin function. Returns - /// ast::Enable::ExtensionKind::kNotAnExtension if no extension is required. + /// ast::Enable::ExtensionKind::kNoExtension if no extension is required. ast::Enable::ExtensionKind RequiredExtension() const; private: