Skip to content

Commit f0200bc

Browse files
committed
Conditionalise the warnings on an environment variable.
We'll only generate warnings if SWIFT_DEBUG_FAILED_TYPE_LOOKUP is enabled. rdar://103950409
1 parent d9db40d commit f0200bc

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

stdlib/public/runtime/EnvironmentVariables.def

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,7 @@ VARIABLE(SWIFT_DEBUG_RUNTIME_EXCLUSIVITY_LOGGING, bool, false,
7878
VARIABLE(SWIFT_BINARY_COMPATIBILITY_VERSION, uint32_t, 0,
7979
"Set the binary compatibility level of the Swift Standard Library")
8080

81+
VARIABLE(SWIFT_DEBUG_FAILED_TYPE_LOOKUP, bool, false,
82+
"Enable warnings when we fail to look up a type by name.")
83+
8184
#undef VARIABLE

stdlib/public/runtime/MetadataLookup.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "swift/Runtime/Casting.h"
2626
#include "swift/Runtime/Concurrent.h"
2727
#include "swift/Runtime/Debug.h"
28+
#include "swift/Runtime/EnvironmentVariables.h"
2829
#include "swift/Runtime/HeapObject.h"
2930
#include "swift/Runtime/Metadata.h"
3031
#include "swift/Strings.h"
@@ -1951,7 +1952,8 @@ swift_getTypeByMangledNameInEnvironment(
19511952
[&substitutions](const Metadata *type, unsigned index) {
19521953
return substitutions.getWitnessTable(type, index);
19531954
});
1954-
if (result.isError()) {
1955+
if (result.isError()
1956+
&& runtime::environment::SWIFT_DEBUG_FAILED_TYPE_LOOKUP()) {
19551957
TypeLookupError *error = result.getError();
19561958
char *errorString = error->copyErrorString();
19571959
swift::warning(0, "failed type lookup for %.*s: %s\n",
@@ -1982,7 +1984,8 @@ swift_getTypeByMangledNameInEnvironmentInMetadataState(
19821984
[&substitutions](const Metadata *type, unsigned index) {
19831985
return substitutions.getWitnessTable(type, index);
19841986
});
1985-
if (result.isError()) {
1987+
if (result.isError()
1988+
&& runtime::environment::SWIFT_DEBUG_FAILED_TYPE_LOOKUP()) {
19861989
TypeLookupError *error = result.getError();
19871990
char *errorString = error->copyErrorString();
19881991
swift::warning(0, "failed type lookup for %.*s: %s\n",
@@ -2012,7 +2015,8 @@ swift_getTypeByMangledNameInContext(
20122015
[&substitutions](const Metadata *type, unsigned index) {
20132016
return substitutions.getWitnessTable(type, index);
20142017
});
2015-
if (result.isError()) {
2018+
if (result.isError()
2019+
&& runtime::environment::SWIFT_DEBUG_FAILED_TYPE_LOOKUP()) {
20162020
TypeLookupError *error = result.getError();
20172021
char *errorString = error->copyErrorString();
20182022
swift::warning(0, "failed type lookup for %.*s: %s\n",
@@ -2043,7 +2047,8 @@ swift_getTypeByMangledNameInContextInMetadataState(
20432047
[&substitutions](const Metadata *type, unsigned index) {
20442048
return substitutions.getWitnessTable(type, index);
20452049
});
2046-
if (result.isError()) {
2050+
if (result.isError()
2051+
&& runtime::environment::SWIFT_DEBUG_FAILED_TYPE_LOOKUP()) {
20472052
TypeLookupError *error = result.getError();
20482053
char *errorString = error->copyErrorString();
20492054
swift::warning(0, "failed type lookup for %.*s: %s\n",

0 commit comments

Comments
 (0)