mirror of
https://github.com/KhronosGroup/SPIRV-Tools
synced 2024-11-22 03:30:06 +00:00
Remove references to __FILE__ (#5462)
* Remove references to __FILE__ Uses of `__FILE__` leak the directory structure of the machine used to build because it adds a string to the string table with the full path name. I've removed the uses that show up in the release builds. Fixes #5416
This commit is contained in:
parent
c87755bb9f
commit
a08f648c86
14
BUILD.bazel
14
BUILD.bazel
@ -456,7 +456,6 @@ cc_library(
|
||||
],
|
||||
exclude = [
|
||||
"test/cpp_interface_test.cpp",
|
||||
"test/log_test.cpp",
|
||||
"test/pch_test.cpp",
|
||||
],
|
||||
)]
|
||||
@ -487,19 +486,6 @@ cc_test(
|
||||
],
|
||||
)
|
||||
|
||||
cc_test(
|
||||
name = "base_log_test",
|
||||
size = "small",
|
||||
srcs = ["test/log_test.cpp"],
|
||||
copts = TEST_COPTS,
|
||||
linkstatic = 1,
|
||||
deps = [
|
||||
":spirv_tools_opt_internal",
|
||||
"@com_google_googletest//:gtest",
|
||||
"@com_google_googletest//:gtest_main",
|
||||
],
|
||||
)
|
||||
|
||||
cc_library(
|
||||
name = "link_test_lib",
|
||||
testonly = 1,
|
||||
|
@ -23,7 +23,7 @@
|
||||
#include "spirv-tools/libspirv.hpp"
|
||||
|
||||
// Asserts the given condition is true. Otherwise, sends a message to the
|
||||
// consumer and exits the problem with failure code. Accepts the following
|
||||
// consumer and exits the program with failure code. Accepts the following
|
||||
// formats:
|
||||
//
|
||||
// SPIRV_ASSERT(<message-consumer>, <condition-expression>);
|
||||
@ -36,7 +36,9 @@
|
||||
#if !defined(NDEBUG)
|
||||
#define SPIRV_ASSERT(consumer, ...) SPIRV_ASSERT_IMPL(consumer, __VA_ARGS__)
|
||||
#else
|
||||
#define SPIRV_ASSERT(consumer, ...)
|
||||
// Adding a use to avoid errors in the release build related to unused
|
||||
// consumers.
|
||||
#define SPIRV_ASSERT(consumer, ...) (void)(consumer)
|
||||
#endif
|
||||
|
||||
// Logs a debug message to the consumer. Accepts the following formats:
|
||||
@ -49,26 +51,11 @@
|
||||
#if !defined(NDEBUG) && defined(SPIRV_LOG_DEBUG)
|
||||
#define SPIRV_DEBUG(consumer, ...) SPIRV_DEBUG_IMPL(consumer, __VA_ARGS__)
|
||||
#else
|
||||
#define SPIRV_DEBUG(consumer, ...)
|
||||
// Adding a use to avoid errors in the release build related to unused
|
||||
// consumers.
|
||||
#define SPIRV_DEBUG(consumer, ...) (void)(consumer)
|
||||
#endif
|
||||
|
||||
// Logs an error message to the consumer saying the given feature is
|
||||
// unimplemented.
|
||||
#define SPIRV_UNIMPLEMENTED(consumer, feature) \
|
||||
do { \
|
||||
spvtools::Log(consumer, SPV_MSG_INTERNAL_ERROR, __FILE__, \
|
||||
{static_cast<size_t>(__LINE__), 0, 0}, \
|
||||
"unimplemented: " feature); \
|
||||
} while (0)
|
||||
|
||||
// Logs an error message to the consumer saying the code location
|
||||
// should be unreachable.
|
||||
#define SPIRV_UNREACHABLE(consumer) \
|
||||
do { \
|
||||
spvtools::Log(consumer, SPV_MSG_INTERNAL_ERROR, __FILE__, \
|
||||
{static_cast<size_t>(__LINE__), 0, 0}, "unreachable"); \
|
||||
} while (0)
|
||||
|
||||
// Helper macros for concatenating arguments.
|
||||
#define SPIRV_CONCATENATE(a, b) SPIRV_CONCATENATE_(a, b)
|
||||
#define SPIRV_CONCATENATE_(a, b) a##b
|
||||
|
@ -901,7 +901,7 @@ Type* TypeManager::RecordIfTypeDefinition(const Instruction& inst) {
|
||||
type = new HitObjectNV();
|
||||
break;
|
||||
default:
|
||||
SPIRV_UNIMPLEMENTED(consumer_, "unhandled type");
|
||||
assert(false && "Type not handled by the type manager.");
|
||||
break;
|
||||
}
|
||||
|
||||
@ -943,12 +943,10 @@ void TypeManager::AttachDecoration(const Instruction& inst, Type* type) {
|
||||
}
|
||||
if (Struct* st = type->AsStruct()) {
|
||||
st->AddMemberDecoration(index, std::move(data));
|
||||
} else {
|
||||
SPIRV_UNIMPLEMENTED(consumer_, "OpMemberDecorate non-struct type");
|
||||
}
|
||||
} break;
|
||||
default:
|
||||
SPIRV_UNREACHABLE(consumer_);
|
||||
assert(false && "Unexpected opcode for a decoration instruction.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -111,7 +111,6 @@ set(TEST_SOURCES
|
||||
hex_float_test.cpp
|
||||
immediate_int_test.cpp
|
||||
libspirv_macros_test.cpp
|
||||
log_test.cpp
|
||||
named_id_test.cpp
|
||||
name_mapper_test.cpp
|
||||
opcode_make_test.cpp
|
||||
|
@ -1,53 +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/opt/log.h"
|
||||
#include "gmock/gmock.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
namespace spvtools {
|
||||
namespace {
|
||||
|
||||
using ::testing::MatchesRegex;
|
||||
|
||||
TEST(Log, Unimplemented) {
|
||||
int invocation = 0;
|
||||
auto consumer = [&invocation](spv_message_level_t level, const char* source,
|
||||
const spv_position_t&, const char* message) {
|
||||
++invocation;
|
||||
EXPECT_EQ(SPV_MSG_INTERNAL_ERROR, level);
|
||||
EXPECT_THAT(source, MatchesRegex(".*log_test.cpp$"));
|
||||
EXPECT_STREQ("unimplemented: the-ultimite-feature", message);
|
||||
};
|
||||
|
||||
SPIRV_UNIMPLEMENTED(consumer, "the-ultimite-feature");
|
||||
EXPECT_EQ(1, invocation);
|
||||
}
|
||||
|
||||
TEST(Log, Unreachable) {
|
||||
int invocation = 0;
|
||||
auto consumer = [&invocation](spv_message_level_t level, const char* source,
|
||||
const spv_position_t&, const char* message) {
|
||||
++invocation;
|
||||
EXPECT_EQ(SPV_MSG_INTERNAL_ERROR, level);
|
||||
EXPECT_THAT(source, MatchesRegex(".*log_test.cpp$"));
|
||||
EXPECT_STREQ("unreachable", message);
|
||||
};
|
||||
|
||||
SPIRV_UNREACHABLE(consumer);
|
||||
EXPECT_EQ(1, invocation);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace spvtools
|
Loading…
Reference in New Issue
Block a user