File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed
llvm/include/llvm/Support Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -29,7 +29,15 @@ namespace llvm {
2929#define DEBUGLOG_WITH_STREAM_AND_TYPE (STREAM, TYPE ) \
3030 for (bool _c = (::llvm::DebugFlag && ::llvm::isCurrentDebugType(TYPE)); _c; \
3131 _c = false ) \
32- ::llvm::impl::LogWithNewline (TYPE, __FILE__, __LINE__, (STREAM))
32+ ::llvm::impl::LogWithNewline ( \
33+ TYPE, \
34+ [] { \
35+ /* Force constexpr eval */ \
36+ constexpr const char *filename = \
37+ ::llvm::impl::LogWithNewline::getFileName (__FILE__); \
38+ return filename; \
39+ }(), \
40+ __LINE__, (STREAM))
3341
3442namespace impl {
3543class LogWithNewline {
@@ -51,6 +59,16 @@ class LogWithNewline {
5159 LogWithNewline (const LogWithNewline &) = delete ;
5260 LogWithNewline &operator =(const LogWithNewline &) = delete ;
5361 LogWithNewline &operator =(LogWithNewline &&) = delete ;
62+ static constexpr const char *getFileName (const char *path) {
63+ // Remove the path prefix from the file name.
64+ const char *filename = path;
65+ for (const char *p = path; *p != ' \0 ' ; ++p) {
66+ if (*p == ' /' || *p == ' \\ ' ) {
67+ filename = p + 1 ;
68+ }
69+ }
70+ return filename;
71+ }
5472
5573private:
5674 raw_ostream &os;
You can’t perform that action at this time.
0 commit comments