Remove the demangler.
The demangler is no longer used by the Tint executable, and nothing else calls it, so delete it. Change-Id: Ic47238e4a6126e5daacd81dfc6f5986524b648ba Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/127280 Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: Ben Clayton <bclayton@google.com> Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
This commit is contained in:
parent
c0398e4174
commit
c4cc6ec038
|
@ -13,7 +13,7 @@ tint (except for `base` which is a mix of things in `src/tint` and
|
||||||
|
|
|
|
||||||
V
|
V
|
||||||
+-----------------------------------------+
|
+-----------------------------------------+
|
||||||
| Val | Demangler | Inspector | Transform |
|
| Val | Inspector | Transform |
|
||||||
+-----------------------------------------+
|
+-----------------------------------------+
|
||||||
| |
|
| |
|
||||||
+--------------+------------------------------+
|
+--------------+------------------------------+
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
// TODO(tint:88): When implementing support for an install target, all of these
|
// TODO(tint:88): When implementing support for an install target, all of these
|
||||||
// headers will need to be moved to include/tint/.
|
// headers will need to be moved to include/tint/.
|
||||||
|
|
||||||
#include "src/tint/demangler.h"
|
|
||||||
#include "src/tint/diagnostic/printer.h"
|
#include "src/tint/diagnostic/printer.h"
|
||||||
#include "src/tint/inspector/inspector.h"
|
#include "src/tint/inspector/inspector.h"
|
||||||
#include "src/tint/reader/reader.h"
|
#include "src/tint/reader/reader.h"
|
||||||
|
|
|
@ -307,17 +307,6 @@ libtint_source_set("libtint_program_src") {
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
libtint_source_set("libtint_demangler_src") {
|
|
||||||
sources = [
|
|
||||||
"demangler.cc",
|
|
||||||
"demangler.h",
|
|
||||||
]
|
|
||||||
deps = [
|
|
||||||
":libtint_base_src",
|
|
||||||
":libtint_program_src",
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
libtint_source_set("libtint_initializer_src") {
|
libtint_source_set("libtint_initializer_src") {
|
||||||
sources = [ "tint.cc" ]
|
sources = [ "tint.cc" ]
|
||||||
}
|
}
|
||||||
|
@ -1095,7 +1084,6 @@ source_set("libtint") {
|
||||||
":libtint_ast_src",
|
":libtint_ast_src",
|
||||||
":libtint_base_src",
|
":libtint_base_src",
|
||||||
":libtint_constant_src",
|
":libtint_constant_src",
|
||||||
":libtint_demangler_src",
|
|
||||||
":libtint_initializer_src",
|
":libtint_initializer_src",
|
||||||
":libtint_inspector_src",
|
":libtint_inspector_src",
|
||||||
":libtint_program_src",
|
":libtint_program_src",
|
||||||
|
@ -2019,11 +2007,6 @@ if (tint_build_unittests) {
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
tint_unittests_source_set("tint_unittests_demangler_src") {
|
|
||||||
sources = [ "demangler_test.cc" ]
|
|
||||||
deps = [ ":libtint_demangler_src" ]
|
|
||||||
}
|
|
||||||
|
|
||||||
if (build_with_chromium) {
|
if (build_with_chromium) {
|
||||||
tint_unittests_source_set("tint_unittests_fuzzer_src") {
|
tint_unittests_source_set("tint_unittests_fuzzer_src") {
|
||||||
sources = [ "fuzzers/random_generator_test.cc" ]
|
sources = [ "fuzzers/random_generator_test.cc" ]
|
||||||
|
@ -2047,7 +2030,6 @@ if (tint_build_unittests) {
|
||||||
":tint_unittests_cmd_src",
|
":tint_unittests_cmd_src",
|
||||||
":tint_unittests_constant_src",
|
":tint_unittests_constant_src",
|
||||||
":tint_unittests_core_src",
|
":tint_unittests_core_src",
|
||||||
":tint_unittests_demangler_src",
|
|
||||||
":tint_unittests_diagnostic_src",
|
":tint_unittests_diagnostic_src",
|
||||||
":tint_unittests_inspector_src",
|
":tint_unittests_inspector_src",
|
||||||
":tint_unittests_resolver_src",
|
":tint_unittests_resolver_src",
|
||||||
|
|
|
@ -245,8 +245,6 @@ list(APPEND TINT_LIB_SRCS
|
||||||
constant/node.h
|
constant/node.h
|
||||||
constant/value.cc
|
constant/value.cc
|
||||||
constant/value.h
|
constant/value.h
|
||||||
demangler.cc
|
|
||||||
demangler.h
|
|
||||||
inspector/entry_point.cc
|
inspector/entry_point.cc
|
||||||
inspector/entry_point.h
|
inspector/entry_point.h
|
||||||
inspector/inspector.cc
|
inspector/inspector.cc
|
||||||
|
@ -892,7 +890,6 @@ if(TINT_BUILD_TESTS)
|
||||||
constant/scalar_test.cc
|
constant/scalar_test.cc
|
||||||
constant/splat_test.cc
|
constant/splat_test.cc
|
||||||
debug_test.cc
|
debug_test.cc
|
||||||
demangler_test.cc
|
|
||||||
diagnostic/diagnostic_test.cc
|
diagnostic/diagnostic_test.cc
|
||||||
diagnostic/formatter_test.cc
|
diagnostic/formatter_test.cc
|
||||||
diagnostic/printer_test.cc
|
diagnostic/printer_test.cc
|
||||||
|
|
|
@ -83,7 +83,6 @@ struct Options {
|
||||||
bool disable_workgroup_init = false;
|
bool disable_workgroup_init = false;
|
||||||
bool validate = false;
|
bool validate = false;
|
||||||
bool print_hash = false;
|
bool print_hash = false;
|
||||||
bool demangle = false;
|
|
||||||
bool dump_inspector_bindings = false;
|
bool dump_inspector_bindings = false;
|
||||||
bool enable_robustness = false;
|
bool enable_robustness = false;
|
||||||
|
|
||||||
|
@ -140,8 +139,6 @@ ${transforms} --parse-only -- Stop after parsing the input
|
||||||
inserting a module-scope directive to suppress any uniformity
|
inserting a module-scope directive to suppress any uniformity
|
||||||
violations that may be produced.
|
violations that may be produced.
|
||||||
--disable-workgroup-init -- Disable workgroup memory zero initialization.
|
--disable-workgroup-init -- Disable workgroup memory zero initialization.
|
||||||
--demangle -- Preserve original source names. Demangle them.
|
|
||||||
Affects AST dumping, and text-based output languages.
|
|
||||||
--dump-inspector-bindings -- Dump reflection data about bindins to stdout.
|
--dump-inspector-bindings -- Dump reflection data about bindins to stdout.
|
||||||
-h -- This help text
|
-h -- This help text
|
||||||
--hlsl-root-constant-binding-point <group>,<binding> -- Binding point for root constant.
|
--hlsl-root-constant-binding-point <group>,<binding> -- Binding point for root constant.
|
||||||
|
@ -349,8 +346,6 @@ bool ParseArgs(const std::vector<std::string>& args, Options* opts) {
|
||||||
#endif
|
#endif
|
||||||
} else if (arg == "--disable-workgroup-init") {
|
} else if (arg == "--disable-workgroup-init") {
|
||||||
opts->disable_workgroup_init = true;
|
opts->disable_workgroup_init = true;
|
||||||
} else if (arg == "--demangle") {
|
|
||||||
opts->demangle = true;
|
|
||||||
} else if (arg == "--dump-inspector-bindings") {
|
} else if (arg == "--dump-inspector-bindings") {
|
||||||
opts->dump_inspector_bindings = true;
|
opts->dump_inspector_bindings = true;
|
||||||
} else if (arg == "--validate") {
|
} else if (arg == "--validate") {
|
||||||
|
|
|
@ -1,62 +0,0 @@
|
||||||
// Copyright 2020 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/demangler.h"
|
|
||||||
|
|
||||||
#include "src/tint/program.h"
|
|
||||||
#include "src/tint/utils/string_stream.h"
|
|
||||||
|
|
||||||
namespace tint {
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
constexpr char kSymbol[] = "$";
|
|
||||||
constexpr size_t kSymbolLen = sizeof(kSymbol) - 1;
|
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
Demangler::Demangler() = default;
|
|
||||||
|
|
||||||
Demangler::~Demangler() = default;
|
|
||||||
|
|
||||||
std::string Demangler::Demangle(const SymbolTable& symbols, const std::string& str) const {
|
|
||||||
utils::StringStream out;
|
|
||||||
|
|
||||||
size_t pos = 0;
|
|
||||||
for (;;) {
|
|
||||||
auto idx = str.find(kSymbol, pos);
|
|
||||||
if (idx == std::string::npos) {
|
|
||||||
out << str.substr(pos);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
out << str.substr(pos, idx - pos);
|
|
||||||
|
|
||||||
auto start_idx = idx + kSymbolLen;
|
|
||||||
auto end_idx = start_idx;
|
|
||||||
while (str[end_idx] >= '0' && str[end_idx] <= '9') {
|
|
||||||
end_idx++;
|
|
||||||
}
|
|
||||||
auto len = end_idx - start_idx;
|
|
||||||
|
|
||||||
auto id = str.substr(start_idx, len);
|
|
||||||
Symbol sym(static_cast<uint32_t>(std::stoi(id)), symbols.ProgramID());
|
|
||||||
out << symbols.NameFor(sym);
|
|
||||||
|
|
||||||
pos = end_idx;
|
|
||||||
}
|
|
||||||
|
|
||||||
return out.str();
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace tint
|
|
|
@ -1,41 +0,0 @@
|
||||||
// Copyright 2020 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.
|
|
||||||
|
|
||||||
#ifndef SRC_TINT_DEMANGLER_H_
|
|
||||||
#define SRC_TINT_DEMANGLER_H_
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
namespace tint {
|
|
||||||
|
|
||||||
class SymbolTable;
|
|
||||||
|
|
||||||
/// Helper to demangle strings and replace symbols with original names
|
|
||||||
class Demangler {
|
|
||||||
public:
|
|
||||||
/// Constructor
|
|
||||||
Demangler();
|
|
||||||
/// Destructor
|
|
||||||
~Demangler();
|
|
||||||
|
|
||||||
/// Transforms given string and replaces any symbols with original names
|
|
||||||
/// @param symbols the symbol table
|
|
||||||
/// @param str the string to replace
|
|
||||||
/// @returns the string with any symbol replacements performed.
|
|
||||||
std::string Demangle(const SymbolTable& symbols, const std::string& str) const;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace tint
|
|
||||||
|
|
||||||
#endif // SRC_TINT_DEMANGLER_H_
|
|
|
@ -1,51 +0,0 @@
|
||||||
// Copyright 2020 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/demangler.h"
|
|
||||||
#include "src/tint/symbol_table.h"
|
|
||||||
|
|
||||||
#include "gtest/gtest.h"
|
|
||||||
|
|
||||||
namespace tint {
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
using DemanglerTest = testing::Test;
|
|
||||||
|
|
||||||
TEST_F(DemanglerTest, NoSymbols) {
|
|
||||||
SymbolTable t{ProgramID::New()};
|
|
||||||
t.Register("sym1");
|
|
||||||
|
|
||||||
Demangler d;
|
|
||||||
EXPECT_EQ("test str", d.Demangle(t, "test str"));
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_F(DemanglerTest, Symbol) {
|
|
||||||
SymbolTable t{ProgramID::New()};
|
|
||||||
t.Register("sym1");
|
|
||||||
|
|
||||||
Demangler d;
|
|
||||||
EXPECT_EQ("test sym1 str", d.Demangle(t, "test $1 str"));
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_F(DemanglerTest, MultipleSymbols) {
|
|
||||||
SymbolTable t{ProgramID::New()};
|
|
||||||
t.Register("sym1");
|
|
||||||
t.Register("sym2");
|
|
||||||
|
|
||||||
Demangler d;
|
|
||||||
EXPECT_EQ("test sym1 sym2 sym1 str", d.Demangle(t, "test $1 $2 $1 str"));
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace
|
|
||||||
} // namespace tint
|
|
|
@ -34,7 +34,6 @@ TINT_END_DISABLE_WARNING(OLD_STYLE_CAST);
|
||||||
TINT_END_DISABLE_WARNING(NEWLINE_EOF);
|
TINT_END_DISABLE_WARNING(NEWLINE_EOF);
|
||||||
|
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
#include "src/tint/demangler.h"
|
|
||||||
#include "src/tint/reader/spirv/fail_stream.h"
|
#include "src/tint/reader/spirv/fail_stream.h"
|
||||||
#include "src/tint/reader/spirv/function.h"
|
#include "src/tint/reader/spirv/function.h"
|
||||||
#include "src/tint/reader/spirv/namer.h"
|
#include "src/tint/reader/spirv/namer.h"
|
||||||
|
|
Loading…
Reference in New Issue