Skip to content

Commit d84a919

Browse files
authored
Merge pull request swiftlang#74715 from tbkka/tbkka-assertions-3
Only print the last component of the filename
2 parents bbc02a5 + 55663f6 commit d84a919

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

lib/Basic/Assertions.cpp

+11-2
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,20 @@ int CONDITIONAL_ASSERT_Global_enable_flag =
3333
#ifdef NDEBUG
3434
0; // Default to `off` in release builds
3535
#else
36-
0; // TODO: Default to `on` in debug builds
36+
1; // Default to `on` in debug builds
3737
#endif
3838

3939
void ASSERT_failure(const char *expr, const char *filename, int line, const char *func) {
40-
// Format here matches that used by `assert` on macOS:
40+
// Find the last component of `filename`
41+
// Needed on Windows MSVC, which lacks __FILE_NAME__
42+
// so we have to use __FILE__ instead:
43+
for (const char *p = filename; *p != '\0'; p++) {
44+
if ((p[0] == '/' || p[0] == '\\')
45+
&& p[1] != '/' && p[1] != '\\' && p[1] != '\0') {
46+
filename = p + 1;
47+
}
48+
}
49+
4150
llvm::errs()
4251
<< "Assertion failed: "
4352
<< "(" << expr << "), "

0 commit comments

Comments
 (0)