Skip to content

Commit

Permalink
Remove references to __FILE__ (KhronosGroup#5462)
Browse files Browse the repository at this point in the history
* 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 KhronosGroup#5416
  • Loading branch information
s-perron authored Nov 1, 2023
1 parent c87755b commit a08f648
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 92 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
27 changes: 7 additions & 20 deletions source/opt/log.h
Original file line number Diff line number Diff line change
Expand Up @@ -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>);
Expand All @@ -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:
Expand All @@ -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
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 a08f648

Please sign in to comment.