diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2023-04-24 12:43:48 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-04-24 12:43:48 -0400 |
| commit | fbe37ea6d90f7bfe18506b042657c6e533eaf9b2 (patch) | |
| tree | 3ba92ecef38e5e4518bfb31e982573fbfe5fa661 /source/slang | |
| parent | cef7a478de583cdd4825d642f055a90948b833bc (diff) | |
Fix issue with Obfuscated hash (#2834)
* #include an absolute path didn't work - because paths were taken to always be relative.
* Remove legacy container writing.
Test using module without source map.
* Change hashing for obfuscated source map such that takes into account different line endings.
Diffstat (limited to 'source/slang')
| -rw-r--r-- | source/slang/slang-ir-obfuscate-loc.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/source/slang/slang-ir-obfuscate-loc.cpp b/source/slang/slang-ir-obfuscate-loc.cpp index 7bb4bef7d..ecc16d2b2 100644 --- a/source/slang/slang-ir-obfuscate-loc.cpp +++ b/source/slang/slang-ir-obfuscate-loc.cpp @@ -130,9 +130,18 @@ SlangResult obfuscateModuleLocs(IRModule* module, SourceManager* sourceManager) hash = combineHash(hash, nameHash); } - // We combine the *offset* which is stable + // We *can't* just use the offset to produce the hash, because the source might have + // different line endings on different platforms (in particular linux/unix-like and windows). + // So we hash the line number/line offset to work around + const auto offset = sourceView->getRange().getOffset(curLoc); - hash = combineHash(hash, getHashCode(offset)); + + const auto sourceFile = sourceView->getSourceFile(); + const auto lineIndex = sourceFile->calcLineIndexFromOffset(offset); + const auto lineOffset = sourceFile->calcColumnOffset(lineIndex, offset); + + hash = combineHash(hash, getHashCode(lineIndex)); + hash = combineHash(hash, getHashCode(lineOffset)); } } } |
