From 50676c741e10ffe6f710c5de86387eaacd274a9a Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Tue, 26 Jan 2021 16:04:44 -0500 Subject: Obfuscation naming issue fix (#1676) * #include an absolute path didn't work - because paths were taken to always be relative. * Work around for issue with obfuscation (and lack of name hints) leading to names in output not being correctly uniquified. * Improve appendChar Remove unrequired memory juggling to scrub names. * Remove test code. * Small fixes in comments and method called. * Remove linkage decoration on functions that are specialized. * Obfuscation naming with specialization test. * Fix instruction deletion. Co-authored-by: Tim Foley --- source/core/slang-string.cpp | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'source/core/slang-string.cpp') diff --git a/source/core/slang-string.cpp b/source/core/slang-string.cpp index 6d06eb1c6..4b1ec4c84 100644 --- a/source/core/slang-string.cpp +++ b/source/core/slang-string.cpp @@ -362,15 +362,25 @@ namespace Slang } } - void String::append(char chr) + void String::appendChar(char c) { - append(&chr, &chr + 1); - } + const auto oldLength = getLength(); + const auto newLength = oldLength + 1; + + ensureUniqueStorageWithCapacity(newLength); + // Since there must be space for at least one character, m_buffer cannot be nullptr + SLANG_ASSERT(m_buffer); + char* data = m_buffer->getData(); + data[oldLength] = c; + data[newLength] = 0; - void String::appendChar(char chr) + m_buffer->length = newLength; + } + + void String::append(char chr) { - append(&chr, &chr + 1); + appendChar(chr); } void String::append(String const& str) -- cgit v1.2.3