mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-05-15 11:51:22 +00:00
Cleanup doc and lint warnings.
This CL fixes up several documentation and linter warnings. Change-Id: Ic367ba1937f20dfe47a8c8e4035c17e8a3d0f2e8 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17880 Reviewed-by: Ryan Harrison <rharrison@chromium.org>
This commit is contained in:
parent
33d34650e8
commit
f26d9a8f26
@ -246,7 +246,7 @@ int main(int argc, const char** argv) {
|
|||||||
std::cout << kUsage << std::endl;
|
std::cout << kUsage << std::endl;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (options.input_filename == "") {
|
if (options.input_filename.empty()) {
|
||||||
std::cerr << "Input file missing" << std::endl;
|
std::cerr << "Input file missing" << std::endl;
|
||||||
std::cout << kUsage << std::endl;
|
std::cout << kUsage << std::endl;
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -19,7 +19,10 @@
|
|||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
|
|
||||||
|
/// Context object for Tint. Holds various global resources used through
|
||||||
|
/// the system.
|
||||||
struct Context {
|
struct Context {
|
||||||
|
/// Manager to hold all of the various type objects
|
||||||
TypeManager* type_mgr = nullptr;
|
TypeManager* type_mgr = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
#include "src/context.h"
|
#include "src/context.h"
|
||||||
@ -26,18 +27,24 @@ namespace tint {
|
|||||||
namespace reader {
|
namespace reader {
|
||||||
namespace spirv {
|
namespace spirv {
|
||||||
|
|
||||||
|
/// SPIR-V Parser test class
|
||||||
class SpvParserTest : public testing::Test {
|
class SpvParserTest : public testing::Test {
|
||||||
public:
|
public:
|
||||||
SpvParserTest() = default;
|
SpvParserTest() = default;
|
||||||
~SpvParserTest() = default;
|
~SpvParserTest() = default;
|
||||||
|
|
||||||
|
/// Sets up the test helper
|
||||||
void SetUp() { ctx_.type_mgr = &tm_; }
|
void SetUp() { ctx_.type_mgr = &tm_; }
|
||||||
|
|
||||||
|
/// Tears down the test helper
|
||||||
void TearDown() {
|
void TearDown() {
|
||||||
impl_ = nullptr;
|
impl_ = nullptr;
|
||||||
ctx_.type_mgr = nullptr;
|
ctx_.type_mgr = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Retrieves the parser from the helper
|
||||||
|
/// @param input the string to parse
|
||||||
|
/// @returns the parser implementation
|
||||||
ParserImpl* parser(const std::vector<uint32_t>& input) {
|
ParserImpl* parser(const std::vector<uint32_t>& input) {
|
||||||
impl_ = std::make_unique<ParserImpl>(ctx_, input);
|
impl_ = std::make_unique<ParserImpl>(ctx_, input);
|
||||||
return impl_.get();
|
return impl_.get();
|
||||||
@ -53,4 +60,4 @@ class SpvParserTest : public testing::Test {
|
|||||||
} // namespace reader
|
} // namespace reader
|
||||||
} // namespace tint
|
} // namespace tint
|
||||||
|
|
||||||
#endif // SRC_READER_WGSL_PARSER_IMPL_TEST_HELPER_H_
|
#endif // SRC_READER_SPIRV_PARSER_IMPL_TEST_HELPER_H_
|
||||||
|
@ -372,7 +372,7 @@ std::unique_ptr<ast::Variable> ParserImpl::global_constant_decl() {
|
|||||||
std::tie(name, type) = variable_ident_decl();
|
std::tie(name, type) = variable_ident_decl();
|
||||||
if (has_error())
|
if (has_error())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
if (name == "" || type == nullptr) {
|
if (name.empty() || type == nullptr) {
|
||||||
set_error(peek(), "error parsing constant variable identifier");
|
set_error(peek(), "error parsing constant variable identifier");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@ -593,7 +593,7 @@ std::unique_ptr<ast::Variable> ParserImpl::variable_decl() {
|
|||||||
std::tie(name, type) = variable_ident_decl();
|
std::tie(name, type) = variable_ident_decl();
|
||||||
if (has_error())
|
if (has_error())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
if (name == "" || type == nullptr) {
|
if (name.empty() || type == nullptr) {
|
||||||
set_error(peek(), "invalid identifier declaration");
|
set_error(peek(), "invalid identifier declaration");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@ -1102,7 +1102,7 @@ std::unique_ptr<ast::StructMember> ParserImpl::struct_member() {
|
|||||||
std::tie(name, type) = variable_ident_decl();
|
std::tie(name, type) = variable_ident_decl();
|
||||||
if (has_error())
|
if (has_error())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
if (name == "" || type == nullptr) {
|
if (name.empty() || type == nullptr) {
|
||||||
set_error(peek(), "invalid identifier declaration");
|
set_error(peek(), "invalid identifier declaration");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@ -1283,7 +1283,7 @@ std::vector<std::unique_ptr<ast::Variable>> ParserImpl::param_list() {
|
|||||||
std::tie(name, type) = variable_ident_decl();
|
std::tie(name, type) = variable_ident_decl();
|
||||||
if (has_error())
|
if (has_error())
|
||||||
return {};
|
return {};
|
||||||
if (name == "" || type == nullptr)
|
if (name.empty() || type == nullptr)
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
@ -1300,7 +1300,7 @@ std::vector<std::unique_ptr<ast::Variable>> ParserImpl::param_list() {
|
|||||||
std::tie(name, type) = variable_ident_decl();
|
std::tie(name, type) = variable_ident_decl();
|
||||||
if (has_error())
|
if (has_error())
|
||||||
return {};
|
return {};
|
||||||
if (name == "" || type == nullptr) {
|
if (name.empty() || type == nullptr) {
|
||||||
set_error(t, "found , but no variable declaration");
|
set_error(t, "found , but no variable declaration");
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
@ -1683,7 +1683,7 @@ std::unique_ptr<ast::VariableStatement> ParserImpl::variable_stmt() {
|
|||||||
std::tie(name, type) = variable_ident_decl();
|
std::tie(name, type) = variable_ident_decl();
|
||||||
if (has_error())
|
if (has_error())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
if (name == "" || type == nullptr) {
|
if (name.empty() || type == nullptr) {
|
||||||
set_error(peek(), "unable to parse variable declaration");
|
set_error(peek(), "unable to parse variable declaration");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -26,23 +26,31 @@ namespace tint {
|
|||||||
namespace reader {
|
namespace reader {
|
||||||
namespace wgsl {
|
namespace wgsl {
|
||||||
|
|
||||||
|
/// WGSL Parser test class
|
||||||
class ParserImplTest : public testing::Test {
|
class ParserImplTest : public testing::Test {
|
||||||
public:
|
public:
|
||||||
|
/// Constructor
|
||||||
ParserImplTest() = default;
|
ParserImplTest() = default;
|
||||||
~ParserImplTest() = default;
|
~ParserImplTest() = default;
|
||||||
|
|
||||||
|
/// Sets up the test helper
|
||||||
void SetUp() { ctx_.type_mgr = &tm_; }
|
void SetUp() { ctx_.type_mgr = &tm_; }
|
||||||
|
|
||||||
|
/// Tears down the test helper
|
||||||
void TearDown() {
|
void TearDown() {
|
||||||
impl_ = nullptr;
|
impl_ = nullptr;
|
||||||
ctx_.type_mgr = nullptr;
|
ctx_.type_mgr = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Retrieves the parser from the helper
|
||||||
|
/// @param str the string to parse
|
||||||
|
/// @returns the parser implementation
|
||||||
ParserImpl* parser(const std::string& str) {
|
ParserImpl* parser(const std::string& str) {
|
||||||
impl_ = std::make_unique<ParserImpl>(ctx_, str);
|
impl_ = std::make_unique<ParserImpl>(ctx_, str);
|
||||||
return impl_.get();
|
return impl_.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @returns the type manager
|
||||||
TypeManager* tm() { return &tm_; }
|
TypeManager* tm() { return &tm_; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -66,6 +66,7 @@ class Builder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Retrives the id for the given function name
|
/// Retrives the id for the given function name
|
||||||
|
/// @param name the function name to search for
|
||||||
/// @returns the id for the given name or 0 on failure
|
/// @returns the id for the given name or 0 on failure
|
||||||
uint32_t id_for_func_name(const std::string& name) {
|
uint32_t id_for_func_name(const std::string& name) {
|
||||||
if (func_name_to_id_.count(name) == 0) {
|
if (func_name_to_id_.count(name) == 0) {
|
||||||
|
@ -15,8 +15,10 @@
|
|||||||
#ifndef SRC_WRITER_WGSL_GENERATOR_IMPL_H_
|
#ifndef SRC_WRITER_WGSL_GENERATOR_IMPL_H_
|
||||||
#define SRC_WRITER_WGSL_GENERATOR_IMPL_H_
|
#define SRC_WRITER_WGSL_GENERATOR_IMPL_H_
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "src/ast/array_accessor_expression.h"
|
#include "src/ast/array_accessor_expression.h"
|
||||||
#include "src/ast/const_initializer_expression.h"
|
#include "src/ast/const_initializer_expression.h"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user