diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2020-06-02 14:05:35 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-06-02 14:05:35 -0400 |
| commit | f87b6327879ce425531bc1d83f3053c36773d27e (patch) | |
| tree | 189de0738ece2d935564cb5fc389a075a1f3194f | |
| parent | 926a0c51071f6cf5718c77958cc801030ce9d404 (diff) | |
Make stdlib path just be the filename. (#1364)
* Made bad-operaor-call available on all targets.
Fix the line filename to not inclue path, to avoid paths being absolute and therefores value be host environment dependent (causing tests to fail).
* Disable on linux because theres still a problem on gcc x86 where the file path is different.
* Fix to some typos in bad-operator-call.slang
* Fix diagnostic for bad-operator-call.slang
| -rw-r--r-- | source/slang/slang-stdlib.cpp | 40 | ||||
| -rw-r--r-- | tests/diagnostics/bad-operator-call.slang | 1 | ||||
| -rw-r--r-- | tests/diagnostics/bad-operator-call.slang.expected | 94 |
3 files changed, 66 insertions, 69 deletions
diff --git a/source/slang/slang-stdlib.cpp b/source/slang/slang-stdlib.cpp index 1f59b1686..a310ba748 100644 --- a/source/slang/slang-stdlib.cpp +++ b/source/slang/slang-stdlib.cpp @@ -4,6 +4,8 @@ #include "slang-ir.h" #include "slang-syntax.h" +#include "../core/slang-string-util.h" + #define STRINGIZE(x) STRINGIZE2(x) #define STRINGIZE2(x) #x #define LINE_STRING STRINGIZE(__LINE__) @@ -15,23 +17,13 @@ namespace Slang if(stdlibPath.getLength() != 0) return stdlibPath; - StringBuilder pathBuilder; - for( auto cc = __FILE__; *cc; ++cc ) - { - switch( *cc ) - { - case '\n': - case '\t': - case '\\': - pathBuilder << "\\"; - ; // fall-thru - default: - pathBuilder << *cc; - break; - } - } - stdlibPath = pathBuilder.ProduceString(); + // Make sure we have a line of text from __FILE__, that we'll extract the filename from + List<UnownedStringSlice> lines; + StringUtil::calcLines(UnownedStringSlice::fromLiteral(__FILE__), lines); + SLANG_ASSERT(lines.getCount() > 0 && lines[0].getLength() > 0); + // Make the path just the filename to remove issues around path being included on different targets + stdlibPath = Path::getFileName(lines[0]); return stdlibPath; } @@ -226,6 +218,13 @@ namespace Slang { kIROp_Leq, "<=", "__BuiltinArithmeticType", ARITHMETIC_MASK | BOOL_RESULT }, }; + // Both the following functions use these macros. + // NOTE! They require a variable named path to emit the #line correctly if in source file. +#define SLANG_RAW(TEXT) sb << TEXT; +#define SLANG_SPLICE(EXPR) sb << (EXPR); + +#define EMIT_LINE_DIRECTIVE() sb << "#line " << (__LINE__+1) << " \"" << path << "\"\n" + String Session::getCoreLibraryCode() { if (coreLibraryCode.getLength() > 0) @@ -233,12 +232,7 @@ namespace Slang StringBuilder sb; - String path = getStdlibPath(); - -#define SLANG_RAW(TEXT) sb << TEXT; -#define SLANG_SPLICE(EXPR) sb << (EXPR); - -#define EMIT_LINE_DIRECTIVE() sb << "#line " << (__LINE__+1) << " \"" << path << "\"\n" + const String path = getStdlibPath(); #include "core.meta.slang.h" @@ -251,6 +245,8 @@ namespace Slang if (hlslLibraryCode.getLength() > 0) return hlslLibraryCode; + const String path = getStdlibPath(); + StringBuilder sb; #include "hlsl.meta.slang.h" diff --git a/tests/diagnostics/bad-operator-call.slang b/tests/diagnostics/bad-operator-call.slang index 449d2dbc1..1455d1cc3 100644 --- a/tests/diagnostics/bad-operator-call.slang +++ b/tests/diagnostics/bad-operator-call.slang @@ -1,4 +1,5 @@ // bad-operator-call.slang + //DIAGNOSTIC_TEST(windows):SIMPLE: // Test that bad calls to operators produce reasonable diagnostic messages. diff --git a/tests/diagnostics/bad-operator-call.slang.expected b/tests/diagnostics/bad-operator-call.slang.expected index fd85fdbfc..1aac5cbef 100644 --- a/tests/diagnostics/bad-operator-call.slang.expected +++ b/tests/diagnostics/bad-operator-call.slang.expected @@ -1,52 +1,52 @@ result code = -1 standard error = { -tests/diagnostics/bad-operator-call.slang(17): error 39999: no overload for '+=' applicable to arguments of type (int, S) -core.meta.slang(1745): note 39999: candidate: func +=<T, R:int, C:int>(matrix<T,R,C>, T) -> matrix<T,R,C> -core.meta.slang(1737): note 39999: candidate: func +=<T, R:int, C:int>(matrix<T,R,C>, matrix<T,R,C>) -> matrix<T,R,C> -core.meta.slang(1729): note 39999: candidate: func +=<T, N:int>(vector<T,N>, T) -> vector<T,N> -core.meta.slang(1721): note 39999: candidate: func +=<T, N:int>(vector<T,N>, vector<T,N>) -> vector<T,N> -core.meta.slang(1713): note 39999: candidate: func +=<T>(T, T) -> T -tests/diagnostics/bad-operator-call.slang(19): error 39999: no overload for '+' applicable to arguments of type (int, S) -core.meta.slang(1635): note 39999: candidate: func +(uint64_t, uint64_t) -> uint64_t -core.meta.slang(1628): note 39999: candidate: func +(uint, uint) -> uint -core.meta.slang(1621): note 39999: candidate: func +(uint16_t, uint16_t) -> uint16_t -core.meta.slang(1614): note 39999: candidate: func +(uint8_t, uint8_t) -> uint8_t -core.meta.slang(1607): note 39999: candidate: func +(double, double) -> double -core.meta.slang(1600): note 39999: candidate: func +(float, float) -> float -core.meta.slang(1593): note 39999: candidate: func +(half, half) -> half -core.meta.slang(1586): note 39999: candidate: func +(int64_t, int64_t) -> int64_t -core.meta.slang(1579): note 39999: candidate: func +(int, int) -> int -core.meta.slang(1572): note 39999: candidate: func +(int16_t, int16_t) -> int16_t -tests/diagnostics/bad-operator-call.slang(19): note 39999: 1 more overload candidates -tests/diagnostics/bad-operator-call.slang(21): error 39999: no overload for '~' applicable to arguments of type (S) -slang-stdlib.cpp(1646): note 39999: candidate: func ~(uint64_t) -> uint64_t -slang-stdlib.cpp(1643): note 39999: candidate: func ~(uint) -> uint -slang-stdlib.cpp(1640): note 39999: candidate: func ~(uint16_t) -> uint16_t -slang-stdlib.cpp(1637): note 39999: candidate: func ~(uint8_t) -> uint8_t -slang-stdlib.cpp(1634): note 39999: candidate: func ~(int64_t) -> int64_t -slang-stdlib.cpp(1631): note 39999: candidate: func ~(int) -> int -slang-stdlib.cpp(1628): note 39999: candidate: func ~(int16_t) -> int16_t -slang-stdlib.cpp(1625): note 39999: candidate: func ~(int8_t) -> int8_t -tests/diagnostics/bad-operator-call.slang(26): error 30047: argument passed to parameter '0' must be l-value. -tests/diagnostics/bad-operator-call.slang(26): note 30048: argument was implicitly cast from 'int' to 'vector<int,4>', and Slang does not support using an implicit cast as an l-value -tests/diagnostics/bad-operator-call.slang(30): error 39999: no overload for '+=' applicable to arguments of type (vector<float,3>, vector<int,4>) -core.meta.slang(1745): note 39999: candidate: func +=<T, R:int, C:int>(matrix<T,R,C>, T) -> matrix<T,R,C> -core.meta.slang(1737): note 39999: candidate: func +=<T, R:int, C:int>(matrix<T,R,C>, matrix<T,R,C>) -> matrix<T,R,C> -core.meta.slang(1729): note 39999: candidate: func +=<T, N:int>(vector<T,N>, T) -> vector<T,N> -core.meta.slang(1721): note 39999: candidate: func +=<T, N:int>(vector<T,N>, vector<T,N>) -> vector<T,N> -core.meta.slang(1713): note 39999: candidate: func +=<T>(T, T) -> T -tests/diagnostics/bad-operator-call.slang(32): error 39999: no overload for '+' applicable to arguments of type (vector<int,4>, vector<float,3>) -core.meta.slang(1640): note 39999: candidate: func +<4>(vector<uint64_t,4>, uint64_t) -> vector<uint64_t,4> -core.meta.slang(1638): note 39999: candidate: func +<3>(uint64_t, vector<uint64_t,3>) -> vector<uint64_t,3> -core.meta.slang(1635): note 39999: candidate: func +(uint64_t, uint64_t) -> uint64_t -core.meta.slang(1633): note 39999: candidate: func +<4>(vector<uint,4>, uint) -> vector<uint,4> -core.meta.slang(1631): note 39999: candidate: func +<3>(uint, vector<uint,3>) -> vector<uint,3> -core.meta.slang(1628): note 39999: candidate: func +(uint, uint) -> uint -core.meta.slang(1626): note 39999: candidate: func +<4>(vector<uint16_t,4>, uint16_t) -> vector<uint16_t,4> -core.meta.slang(1624): note 39999: candidate: func +<3>(uint16_t, vector<uint16_t,3>) -> vector<uint16_t,3> -core.meta.slang(1621): note 39999: candidate: func +(uint16_t, uint16_t) -> uint16_t -core.meta.slang(1619): note 39999: candidate: func +<4>(vector<uint8_t,4>, uint8_t) -> vector<uint8_t,4> -tests/diagnostics/bad-operator-call.slang(32): note 39999: 23 more overload candidates +tests/diagnostics/bad-operator-call.slang(18): error 39999: no overload for '+=' applicable to arguments of type (int, S) +core.meta.slang(1762): note 39999: candidate: func +=<T, R:int, C:int>(matrix<T,R,C>, T) -> matrix<T,R,C> +core.meta.slang(1754): note 39999: candidate: func +=<T, R:int, C:int>(matrix<T,R,C>, matrix<T,R,C>) -> matrix<T,R,C> +core.meta.slang(1746): note 39999: candidate: func +=<T, N:int>(vector<T,N>, T) -> vector<T,N> +core.meta.slang(1738): note 39999: candidate: func +=<T, N:int>(vector<T,N>, vector<T,N>) -> vector<T,N> +core.meta.slang(1730): note 39999: candidate: func +=<T>(T, T) -> T +tests/diagnostics/bad-operator-call.slang(20): error 39999: no overload for '+' applicable to arguments of type (int, S) +core.meta.slang(1652): note 39999: candidate: func +(uint64_t, uint64_t) -> uint64_t +core.meta.slang(1645): note 39999: candidate: func +(uint, uint) -> uint +core.meta.slang(1638): note 39999: candidate: func +(uint16_t, uint16_t) -> uint16_t +core.meta.slang(1631): note 39999: candidate: func +(uint8_t, uint8_t) -> uint8_t +core.meta.slang(1624): note 39999: candidate: func +(double, double) -> double +core.meta.slang(1617): note 39999: candidate: func +(float, float) -> float +core.meta.slang(1610): note 39999: candidate: func +(half, half) -> half +core.meta.slang(1603): note 39999: candidate: func +(int64_t, int64_t) -> int64_t +core.meta.slang(1596): note 39999: candidate: func +(int, int) -> int +core.meta.slang(1589): note 39999: candidate: func +(int16_t, int16_t) -> int16_t +tests/diagnostics/bad-operator-call.slang(20): note 39999: 1 more overload candidates +tests/diagnostics/bad-operator-call.slang(22): error 39999: no overload for '~' applicable to arguments of type (S) +slang-stdlib.cpp(1644): note 39999: candidate: func ~(uint64_t) -> uint64_t +slang-stdlib.cpp(1641): note 39999: candidate: func ~(uint) -> uint +slang-stdlib.cpp(1638): note 39999: candidate: func ~(uint16_t) -> uint16_t +slang-stdlib.cpp(1635): note 39999: candidate: func ~(uint8_t) -> uint8_t +slang-stdlib.cpp(1632): note 39999: candidate: func ~(int64_t) -> int64_t +slang-stdlib.cpp(1629): note 39999: candidate: func ~(int) -> int +slang-stdlib.cpp(1626): note 39999: candidate: func ~(int16_t) -> int16_t +slang-stdlib.cpp(1623): note 39999: candidate: func ~(int8_t) -> int8_t +tests/diagnostics/bad-operator-call.slang(27): error 30047: argument passed to parameter '0' must be l-value. +tests/diagnostics/bad-operator-call.slang(27): note 30048: argument was implicitly cast from 'int' to 'vector<int,4>', and Slang does not support using an implicit cast as an l-value +tests/diagnostics/bad-operator-call.slang(31): error 39999: no overload for '+=' applicable to arguments of type (vector<float,3>, vector<int,4>) +core.meta.slang(1762): note 39999: candidate: func +=<T, R:int, C:int>(matrix<T,R,C>, T) -> matrix<T,R,C> +core.meta.slang(1754): note 39999: candidate: func +=<T, R:int, C:int>(matrix<T,R,C>, matrix<T,R,C>) -> matrix<T,R,C> +core.meta.slang(1746): note 39999: candidate: func +=<T, N:int>(vector<T,N>, T) -> vector<T,N> +core.meta.slang(1738): note 39999: candidate: func +=<T, N:int>(vector<T,N>, vector<T,N>) -> vector<T,N> +core.meta.slang(1730): note 39999: candidate: func +=<T>(T, T) -> T +tests/diagnostics/bad-operator-call.slang(33): error 39999: no overload for '+' applicable to arguments of type (vector<int,4>, vector<float,3>) +core.meta.slang(1657): note 39999: candidate: func +<4>(vector<uint64_t,4>, uint64_t) -> vector<uint64_t,4> +core.meta.slang(1655): note 39999: candidate: func +<3>(uint64_t, vector<uint64_t,3>) -> vector<uint64_t,3> +core.meta.slang(1652): note 39999: candidate: func +(uint64_t, uint64_t) -> uint64_t +core.meta.slang(1650): note 39999: candidate: func +<4>(vector<uint,4>, uint) -> vector<uint,4> +core.meta.slang(1648): note 39999: candidate: func +<3>(uint, vector<uint,3>) -> vector<uint,3> +core.meta.slang(1645): note 39999: candidate: func +(uint, uint) -> uint +core.meta.slang(1643): note 39999: candidate: func +<4>(vector<uint16_t,4>, uint16_t) -> vector<uint16_t,4> +core.meta.slang(1641): note 39999: candidate: func +<3>(uint16_t, vector<uint16_t,3>) -> vector<uint16_t,3> +core.meta.slang(1638): note 39999: candidate: func +(uint16_t, uint16_t) -> uint16_t +core.meta.slang(1636): note 39999: candidate: func +<4>(vector<uint8_t,4>, uint8_t) -> vector<uint8_t,4> +tests/diagnostics/bad-operator-call.slang(33): note 39999: 23 more overload candidates } standard output = { } |
