Skip to content

Commit

Permalink
Remove references to __FILE__
Browse files Browse the repository at this point in the history
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. Since the existing uses were not really needed, I am simply
removing all of them.

Fixes KhronosGroup#5416
  • Loading branch information
s-perron committed Nov 1, 2023
1 parent c87755b commit 212dd92
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 153 deletions.
14 changes: 0 additions & 14 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,6 @@ cc_library(
],
exclude = [
"test/cpp_interface_test.cpp",
"test/log_test.cpp",
"test/pch_test.cpp",
],
)]
Expand Down Expand Up @@ -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,
Expand Down
81 changes: 0 additions & 81 deletions source/opt/log.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,23 +52,6 @@
#define SPIRV_DEBUG(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
Expand Down Expand Up @@ -155,70 +138,6 @@ inline void Errorf(const MessageConsumer& consumer, const char* source,
PP_EXPAND(SPIRV_CONCATENATE(SPIRV_DEBUG_, PP_NARGS(__VA_ARGS__))( \
consumer, __VA_ARGS__))

#define SPIRV_ASSERT_1(consumer, condition) \
do { \
if (!(condition)) { \
spvtools::Log(consumer, SPV_MSG_INTERNAL_ERROR, __FILE__, \
{static_cast<size_t>(__LINE__), 0, 0}, \
"assertion failed: " #condition); \
std::exit(EXIT_FAILURE); \
} \
} while (0)

#define SPIRV_ASSERT_2(consumer, condition, message) \
do { \
if (!(condition)) { \
spvtools::Log(consumer, SPV_MSG_INTERNAL_ERROR, __FILE__, \
{static_cast<size_t>(__LINE__), 0, 0}, \
"assertion failed: " message); \
std::exit(EXIT_FAILURE); \
} \
} while (0)

#define SPIRV_ASSERT_more(consumer, condition, format, ...) \
do { \
if (!(condition)) { \
spvtools::Logf(consumer, SPV_MSG_INTERNAL_ERROR, __FILE__, \
{static_cast<size_t>(__LINE__), 0, 0}, \
"assertion failed: " format, __VA_ARGS__); \
std::exit(EXIT_FAILURE); \
} \
} while (0)

#define SPIRV_ASSERT_3(consumer, condition, format, ...) \
SPIRV_ASSERT_more(consumer, condition, format, __VA_ARGS__)

#define SPIRV_ASSERT_4(consumer, condition, format, ...) \
SPIRV_ASSERT_more(consumer, condition, format, __VA_ARGS__)

#define SPIRV_ASSERT_5(consumer, condition, format, ...) \
SPIRV_ASSERT_more(consumer, condition, format, __VA_ARGS__)

#define SPIRV_DEBUG_1(consumer, message) \
do { \
spvtools::Log(consumer, SPV_MSG_DEBUG, __FILE__, \
{static_cast<size_t>(__LINE__), 0, 0}, message); \
} while (0)

#define SPIRV_DEBUG_more(consumer, format, ...) \
do { \
spvtools::Logf(consumer, SPV_MSG_DEBUG, __FILE__, \
{static_cast<size_t>(__LINE__), 0, 0}, format, \
__VA_ARGS__); \
} while (0)

#define SPIRV_DEBUG_2(consumer, format, ...) \
SPIRV_DEBUG_more(consumer, format, __VA_ARGS__)

#define SPIRV_DEBUG_3(consumer, format, ...) \
SPIRV_DEBUG_more(consumer, format, __VA_ARGS__)

#define SPIRV_DEBUG_4(consumer, format, ...) \
SPIRV_DEBUG_more(consumer, format, __VA_ARGS__)

#define SPIRV_DEBUG_5(consumer, format, ...) \
SPIRV_DEBUG_more(consumer, format, __VA_ARGS__)

// Macros for counting the number of arguments passed in.
#define PP_NARGS(...) PP_EXPAND(PP_ARG_N(__VA_ARGS__, 5, 4, 3, 2, 1, 0))
#define PP_ARG_N(_1, _2, _3, _4, _5, N, ...) N
Expand Down
6 changes: 2 additions & 4 deletions source/opt/type_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}
}
Expand Down
1 change: 0 additions & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
53 changes: 0 additions & 53 deletions test/log_test.cpp

This file was deleted.

0 comments on commit 212dd92

Please sign in to comment.