|
24 | 24 | __SYCL_INLINE_NAMESPACE(cl) {
|
25 | 25 | namespace sycl {
|
26 | 26 | namespace detail {
|
| 27 | + |
| 28 | +#if !defined(NDEBUG) && (_MSC_VER > 1929 || __has_builtin(__builtin_FILE)) |
| 29 | +#define __CODELOC_FILE_NAME __builtin_FILE() |
| 30 | +#else |
| 31 | +#define __CODELOC_FILE_NAME nullptr |
| 32 | +#endif |
| 33 | + |
| 34 | +#if _MSC_VER > 1929 || __has_builtin(__builtin_FUNCTION) |
| 35 | +#define __CODELOC_FUNCTION __builtin_FUNCTION() |
| 36 | +#else |
| 37 | +#define __CODELOC_FUNCTION nullptr |
| 38 | +#endif |
| 39 | + |
| 40 | +#if _MSC_VER > 1929 || __has_builtin(__builtin_LINE) |
| 41 | +#define __CODELOC_LINE __builtin_LINE() |
| 42 | +#else |
| 43 | +#define __CODELOC_LINE 0 |
| 44 | +#endif |
| 45 | + |
| 46 | +#if _MSC_VER > 1929 || __has_builtin(__builtin_LINE) |
| 47 | +#define __CODELOC_COLUMN __builtin_COLUMN() |
| 48 | +#else |
| 49 | +#define __CODELOC_COLUMN 0 |
| 50 | +#endif |
| 51 | + |
27 | 52 | // Data structure that captures the user code location information using the
|
28 | 53 | // builtin capabilities of the compiler
|
29 | 54 | struct code_location {
|
30 |
| -#ifdef _MSC_VER |
31 |
| - // Since MSVC does not support the required builtins, we |
32 |
| - // implement the version with "unknown"s which is handled |
33 |
| - // correctly by the instrumentation |
34 |
| - static constexpr code_location current(const char *fileName = nullptr, |
35 |
| - const char *funcName = nullptr, |
36 |
| - unsigned long lineNo = 0, |
37 |
| - unsigned long columnNo = 0) noexcept { |
38 |
| - return code_location(fileName, funcName, lineNo, columnNo); |
39 |
| - } |
40 |
| -#else |
41 |
| - // FIXME Having a nullptr for fileName here is a short-term solution to |
42 |
| - // workaround leak of full paths in builds |
43 | 55 | static constexpr code_location
|
44 |
| - current(const char *fileName = nullptr, |
45 |
| - const char *funcName = __builtin_FUNCTION(), |
46 |
| - unsigned long lineNo = __builtin_LINE(), |
47 |
| - unsigned long columnNo = 0) noexcept { |
| 56 | + current(const char *fileName = __CODELOC_FILE_NAME, |
| 57 | + const char *funcName = __CODELOC_FUNCTION, |
| 58 | + unsigned long lineNo = __CODELOC_LINE, |
| 59 | + unsigned long columnNo = __CODELOC_COLUMN) noexcept { |
48 | 60 | return code_location(fileName, funcName, lineNo, columnNo);
|
49 | 61 | }
|
50 |
| -#endif |
| 62 | + |
| 63 | +#undef __CODELOC_FILE_NAME |
| 64 | +#undef __CODELOC_FUNCTION |
| 65 | +#undef __CODELOC_LINE |
| 66 | +#undef __CODELOC_COLUMN |
51 | 67 |
|
52 | 68 | constexpr code_location(const char *file, const char *func, int line,
|
53 | 69 | int col) noexcept
|
|
0 commit comments