Skip to content

Only print the last component of the filename #74715

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions lib/Basic/Assertions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,20 @@ int CONDITIONAL_ASSERT_Global_enable_flag =
#ifdef NDEBUG
0; // Default to `off` in release builds
#else
0; // TODO: Default to `on` in debug builds
1; // Default to `on` in debug builds
#endif

void ASSERT_failure(const char *expr, const char *filename, int line, const char *func) {
// Format here matches that used by `assert` on macOS:
// Find the last component of `filename`
// Needed on Windows MSVC, which lacks __FILE_NAME__
// so we have to use __FILE__ instead:
for (const char *p = filename; *p != '\0'; p++) {
if ((p[0] == '/' || p[0] == '\\')
&& p[1] != '/' && p[1] != '\\' && p[1] != '\0') {
filename = p + 1;
}
}

llvm::errs()
<< "Assertion failed: "
<< "(" << expr << "), "
Expand Down