mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-09-18 17:19:48 +00:00
Fixed: tint:1891 Change-Id: Ia3737c29b111d7b6e6b00fbd68da7f85a5a49bca Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/128301 Commit-Queue: Ben Clayton <bclayton@google.com> Reviewed-by: Dan Sinclair <dsinclair@chromium.org> Reviewed-by: James Price <jrprice@google.com> Kokoro: Kokoro <noreply+kokoro@google.com>
75 lines
2.6 KiB
C++
75 lines
2.6 KiB
C++
// Copyright 2023 The Tint Authors.
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
#include "src/tint/ast/diagnostic_rule_name.h"
|
|
|
|
#include <string>
|
|
|
|
#include "src/tint/program_builder.h"
|
|
|
|
TINT_INSTANTIATE_TYPEINFO(tint::ast::DiagnosticRuleName);
|
|
|
|
namespace tint::ast {
|
|
|
|
DiagnosticRuleName::DiagnosticRuleName(ProgramID pid,
|
|
NodeID nid,
|
|
const Source& src,
|
|
const Identifier* n)
|
|
: Base(pid, nid, src), name(n) {
|
|
TINT_ASSERT(AST, name != nullptr);
|
|
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(AST, name, program_id);
|
|
if (name) {
|
|
// It is invalid for a diagnostic rule name to be templated
|
|
TINT_ASSERT(AST, !name->Is<TemplatedIdentifier>());
|
|
}
|
|
}
|
|
|
|
DiagnosticRuleName::DiagnosticRuleName(ProgramID pid,
|
|
NodeID nid,
|
|
const Source& src,
|
|
const Identifier* c,
|
|
const Identifier* n)
|
|
: Base(pid, nid, src), category(c), name(n) {
|
|
TINT_ASSERT(AST, name != nullptr);
|
|
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(AST, name, program_id);
|
|
if (name) {
|
|
// It is invalid for a diagnostic rule name to be templated
|
|
TINT_ASSERT(AST, !name->Is<TemplatedIdentifier>());
|
|
}
|
|
if (category) {
|
|
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(AST, category, program_id);
|
|
// It is invalid for a diagnostic rule category to be templated
|
|
TINT_ASSERT(AST, !category->Is<TemplatedIdentifier>());
|
|
}
|
|
}
|
|
|
|
const DiagnosticRuleName* DiagnosticRuleName::Clone(CloneContext* ctx) const {
|
|
auto src = ctx->Clone(source);
|
|
auto n = ctx->Clone(name);
|
|
if (auto c = ctx->Clone(category)) {
|
|
return ctx->dst->create<DiagnosticRuleName>(src, c, n);
|
|
}
|
|
return ctx->dst->create<DiagnosticRuleName>(src, n);
|
|
}
|
|
|
|
std::string DiagnosticRuleName::String() const {
|
|
if (category) {
|
|
return category->symbol.Name() + "." + name->symbol.Name();
|
|
} else {
|
|
return name->symbol.Name();
|
|
}
|
|
}
|
|
|
|
} // namespace tint::ast
|