@@ -26,25 +26,27 @@ namespace llvm {
2626// << "] " << "Bitset contains: " << Bitset << "\n");
2727#define LDBG () DEBUGLOG_WITH_STREAM_AND_TYPE(llvm::dbgs(), DEBUG_TYPE)
2828
29+ #if defined(__SHORT_FILE__)
2930#define DEBUGLOG_WITH_STREAM_AND_TYPE (STREAM, TYPE ) \
3031 for (bool _c = (::llvm::DebugFlag && ::llvm::isCurrentDebugType(TYPE)); _c; \
3132 _c = false ) \
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))
33+ ::llvm::impl::LogWithNewline (TYPE, __SHORT_FILE__, __LINE__, (STREAM))
34+ #else
35+ #define DEBUGLOG_WITH_STREAM_AND_TYPE (STREAM, TYPE ) \
36+ for (bool _c = (::llvm::DebugFlag && ::llvm::isCurrentDebugType(TYPE)); _c; \
37+ _c = false ) \
38+ ::llvm::impl::LogWithNewline (TYPE, __FILE__, __LINE__, (STREAM))
39+ #endif
4140
4241namespace impl {
4342class LogWithNewline {
4443public:
4544 LogWithNewline (const char *debug_type, const char *file, int line,
4645 raw_ostream &os)
4746 : os(os) {
47+ #if !defined(__SHORT_FILE__)
48+ file = ::llvm::impl::LogWithNewline::getShortFileName (file);
49+ #endif
4850 if (debug_type)
4951 os << " [" << debug_type << " ] " ;
5052 os << file << " :" << line << " " ;
@@ -59,7 +61,7 @@ class LogWithNewline {
5961 LogWithNewline (const LogWithNewline &) = delete ;
6062 LogWithNewline &operator =(const LogWithNewline &) = delete ;
6163 LogWithNewline &operator =(LogWithNewline &&) = delete ;
62- static constexpr const char *getFileName (const char *path) {
64+ static constexpr const char *getShortFileName (const char *path) {
6365 // Remove the path prefix from the file name.
6466 const char *filename = path;
6567 for (const char *p = path; *p != ' \0 ' ; ++p) {
0 commit comments