mirror of
https://gitee.com/openharmony/third_party_spirv-tools
synced 2024-11-26 17:10:52 +00:00
Remove source/message.h (#1838)
The code in source/message was only used in a single set of tests to format the output results. This CL changes the test to verify the message instead of all the error values and removes the source/message code.
This commit is contained in:
parent
1963a2dbda
commit
ef678672fb
1
BUILD.gn
1
BUILD.gn
@ -301,7 +301,6 @@ static_library("spvtools") {
|
||||
"source/instruction.h",
|
||||
"source/libspirv.cpp",
|
||||
"source/macro.h",
|
||||
"source/message.cpp",
|
||||
"source/name_mapper.cpp",
|
||||
"source/name_mapper.h",
|
||||
"source/opcode.cpp",
|
||||
|
@ -266,7 +266,6 @@ set(SPIRV_SOURCES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/extensions.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/id_descriptor.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/libspirv.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/message.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/name_mapper.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/opcode.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/operand.cpp
|
||||
|
@ -58,14 +58,14 @@ spv_result_t spvDiagnosticPrint(const spv_diagnostic diagnostic) {
|
||||
<< diagnostic->position.column + 1 << ": " << diagnostic->error
|
||||
<< "\n";
|
||||
return SPV_SUCCESS;
|
||||
} else {
|
||||
// NOTE: Assume this is a binary position
|
||||
std::cerr << "error: ";
|
||||
if (diagnostic->position.index > 0)
|
||||
std::cerr << diagnostic->position.index << ": ";
|
||||
std::cerr << diagnostic->error << "\n";
|
||||
return SPV_SUCCESS;
|
||||
}
|
||||
|
||||
// NOTE: Assume this is a binary position
|
||||
std::cerr << "error: ";
|
||||
if (diagnostic->position.index > 0)
|
||||
std::cerr << diagnostic->position.index << ": ";
|
||||
std::cerr << diagnostic->error << "\n";
|
||||
return SPV_SUCCESS;
|
||||
}
|
||||
|
||||
namespace spvtools {
|
||||
|
@ -1,54 +0,0 @@
|
||||
// Copyright (c) 2016 Google Inc.
|
||||
//
|
||||
// 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 "source/message.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
namespace spvtools {
|
||||
|
||||
std::string StringifyMessage(spv_message_level_t level, const char* source,
|
||||
const spv_position_t& position,
|
||||
const char* message) {
|
||||
const char* level_string = nullptr;
|
||||
switch (level) {
|
||||
case SPV_MSG_FATAL:
|
||||
level_string = "fatal";
|
||||
break;
|
||||
case SPV_MSG_INTERNAL_ERROR:
|
||||
level_string = "internal error";
|
||||
break;
|
||||
case SPV_MSG_ERROR:
|
||||
level_string = "error";
|
||||
break;
|
||||
case SPV_MSG_WARNING:
|
||||
level_string = "warning";
|
||||
break;
|
||||
case SPV_MSG_INFO:
|
||||
level_string = "info";
|
||||
break;
|
||||
case SPV_MSG_DEBUG:
|
||||
level_string = "debug";
|
||||
break;
|
||||
}
|
||||
std::ostringstream oss;
|
||||
oss << level_string << ": ";
|
||||
if (source) oss << source << ":";
|
||||
oss << position.line << ":" << position.column << ":";
|
||||
oss << position.index << ": ";
|
||||
if (message) oss << message;
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
} // namespace spvtools
|
@ -1,33 +0,0 @@
|
||||
// Copyright (c) 2016 Google Inc.
|
||||
//
|
||||
// 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 SOURCE_MESSAGE_H_
|
||||
#define SOURCE_MESSAGE_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "spirv-tools/libspirv.h"
|
||||
|
||||
namespace spvtools {
|
||||
|
||||
// A helper function to compose and return a string from the message in the
|
||||
// following format:
|
||||
// "<level>: <source>:<line>:<column>:<index>: <message>"
|
||||
std::string StringifyMessage(spv_message_level_t level, const char* source,
|
||||
const spv_position_t& position,
|
||||
const char* message);
|
||||
|
||||
} // namespace spvtools
|
||||
|
||||
#endif // SOURCE_MESSAGE_H_
|
@ -18,7 +18,6 @@
|
||||
#include "source/latest_version_spirv_header.h"
|
||||
|
||||
#include "source/extensions.h"
|
||||
#include "source/message.h"
|
||||
#include "spirv-tools/libspirv.hpp"
|
||||
|
||||
typedef struct spv_opcode_desc_t {
|
||||
|
@ -33,7 +33,6 @@
|
||||
#include "source/diagnostic.h"
|
||||
#include "source/ext_inst.h"
|
||||
#include "source/instruction.h"
|
||||
#include "source/message.h"
|
||||
#include "source/opcode.h"
|
||||
#include "source/operand.h"
|
||||
#include "source/spirv_constant.h"
|
||||
|
@ -25,7 +25,6 @@
|
||||
|
||||
#include "source/diagnostic.h"
|
||||
#include "source/instruction.h"
|
||||
#include "source/message.h"
|
||||
#include "source/text.h"
|
||||
#include "spirv-tools/libspirv.h"
|
||||
|
||||
|
@ -21,7 +21,6 @@
|
||||
#include <vector>
|
||||
|
||||
#include "source/instruction.h"
|
||||
#include "source/message.h"
|
||||
#include "source/table.h"
|
||||
#include "spirv-tools/libspirv.h"
|
||||
|
||||
|
@ -27,7 +27,6 @@
|
||||
|
||||
#include "source/diagnostic.h"
|
||||
#include "source/instruction.h"
|
||||
#include "source/message.h"
|
||||
#include "source/opcode.h"
|
||||
#include "source/operand.h"
|
||||
#include "source/spirv_validator_options.h"
|
||||
|
@ -20,7 +20,6 @@
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
#include "source/latest_version_opencl_std_header.h"
|
||||
#include "source/message.h"
|
||||
#include "source/table.h"
|
||||
#include "test/test_fixture.h"
|
||||
#include "test/unit_spirv.h"
|
||||
|
@ -13,7 +13,6 @@
|
||||
// limitations under the License.
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "source/message.h"
|
||||
#include "source/table.h"
|
||||
#include "spirv-tools/libspirv.h"
|
||||
|
||||
|
@ -15,7 +15,6 @@
|
||||
#include "source/opt/log.h"
|
||||
#include "gmock/gmock.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "source/message.h"
|
||||
|
||||
namespace spvtools {
|
||||
namespace {
|
||||
|
@ -20,7 +20,6 @@
|
||||
#include <vector>
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "source/message.h"
|
||||
#include "source/opt/build_module.h"
|
||||
#include "source/opt/ir_context.h"
|
||||
#include "spirv-tools/libspirv.hpp"
|
||||
@ -321,11 +320,12 @@ TEST(IrBuilder, KeepModuleProcessedInRightPlace) {
|
||||
// Checks the given |error_message| is reported when trying to build a module
|
||||
// from the given |assembly|.
|
||||
void DoErrorMessageCheck(const std::string& assembly,
|
||||
const std::string& error_message) {
|
||||
auto consumer = [error_message](spv_message_level_t level, const char* source,
|
||||
const spv_position_t& position,
|
||||
const char* m) {
|
||||
EXPECT_EQ(error_message, StringifyMessage(level, source, position, m));
|
||||
const std::string& error_message, uint32_t line_num) {
|
||||
auto consumer = [error_message, line_num](spv_message_level_t, const char*,
|
||||
const spv_position_t& position,
|
||||
const char* m) {
|
||||
EXPECT_EQ(error_message, m);
|
||||
EXPECT_EQ(line_num, position.line);
|
||||
};
|
||||
|
||||
SpirvTools t(SPV_ENV_UNIVERSAL_1_1);
|
||||
@ -336,13 +336,12 @@ void DoErrorMessageCheck(const std::string& assembly,
|
||||
|
||||
TEST(IrBuilder, FunctionInsideFunction) {
|
||||
DoErrorMessageCheck("%2 = OpFunction %1 None %3\n%5 = OpFunction %4 None %6",
|
||||
"error: <instruction>:2:0:0: function inside function");
|
||||
"function inside function", 2);
|
||||
}
|
||||
|
||||
TEST(IrBuilder, MismatchOpFunctionEnd) {
|
||||
DoErrorMessageCheck("OpFunctionEnd",
|
||||
"error: <instruction>:1:0:0: OpFunctionEnd without "
|
||||
"corresponding OpFunction");
|
||||
"OpFunctionEnd without corresponding OpFunction", 1);
|
||||
}
|
||||
|
||||
TEST(IrBuilder, OpFunctionEndInsideBasicBlock) {
|
||||
@ -350,12 +349,12 @@ TEST(IrBuilder, OpFunctionEndInsideBasicBlock) {
|
||||
"%2 = OpFunction %1 None %3\n"
|
||||
"%4 = OpLabel\n"
|
||||
"OpFunctionEnd",
|
||||
"error: <instruction>:3:0:0: OpFunctionEnd inside basic block");
|
||||
"OpFunctionEnd inside basic block", 3);
|
||||
}
|
||||
|
||||
TEST(IrBuilder, BasicBlockOutsideFunction) {
|
||||
DoErrorMessageCheck("OpCapability Shader\n%1 = OpLabel",
|
||||
"error: <instruction>:2:0:0: OpLabel outside function");
|
||||
"OpLabel outside function", 2);
|
||||
}
|
||||
|
||||
TEST(IrBuilder, OpLabelInsideBasicBlock) {
|
||||
@ -363,26 +362,23 @@ TEST(IrBuilder, OpLabelInsideBasicBlock) {
|
||||
"%2 = OpFunction %1 None %3\n"
|
||||
"%4 = OpLabel\n"
|
||||
"%5 = OpLabel",
|
||||
"error: <instruction>:3:0:0: OpLabel inside basic block");
|
||||
"OpLabel inside basic block", 3);
|
||||
}
|
||||
|
||||
TEST(IrBuilder, TerminatorOutsideFunction) {
|
||||
DoErrorMessageCheck(
|
||||
"OpReturn",
|
||||
"error: <instruction>:1:0:0: terminator instruction outside function");
|
||||
DoErrorMessageCheck("OpReturn", "terminator instruction outside function", 1);
|
||||
}
|
||||
|
||||
TEST(IrBuilder, TerminatorOutsideBasicBlock) {
|
||||
DoErrorMessageCheck("%2 = OpFunction %1 None %3\nOpReturn",
|
||||
"error: <instruction>:2:0:0: terminator instruction "
|
||||
"outside basic block");
|
||||
"terminator instruction outside basic block", 2);
|
||||
}
|
||||
|
||||
TEST(IrBuilder, NotAllowedInstAppearingInFunction) {
|
||||
DoErrorMessageCheck("%2 = OpFunction %1 None %3\n%5 = OpVariable %4 Function",
|
||||
"error: <instruction>:2:0:0: Non-OpFunctionParameter "
|
||||
"(opcode: 59) found inside function but outside basic "
|
||||
"block");
|
||||
"Non-OpFunctionParameter (opcode: 59) found inside "
|
||||
"function but outside basic block",
|
||||
2);
|
||||
}
|
||||
|
||||
TEST(IrBuilder, UniqueIds) {
|
||||
|
@ -19,7 +19,6 @@
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "source/message.h"
|
||||
#include "source/opt/build_module.h"
|
||||
#include "source/opt/module.h"
|
||||
#include "spirv-tools/libspirv.hpp"
|
||||
|
@ -17,7 +17,6 @@
|
||||
#include <vector>
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
#include "source/message.h"
|
||||
#include "test/test_fixture.h"
|
||||
#include "test/unit_spirv.h"
|
||||
|
||||
|
@ -22,7 +22,6 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "source/message.h"
|
||||
#include "source/opt/log.h"
|
||||
#include "source/opt/loop_peeling.h"
|
||||
#include "source/opt/set_spec_constant_default_value_pass.h"
|
||||
|
Loading…
Reference in New Issue
Block a user