summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoraidanfnv <aidanf@nvidia.com>2025-04-07 07:01:50 -0700
committerGitHub <noreply@github.com>2025-04-07 14:01:50 +0000
commit9972a5269f87618e237cd927b859636322596a76 (patch)
tree0cde247d105eb170989f1d3517029859aaab3039
parentedb7289383538c3356ca2d5f7c37f41821bbf252 (diff)
Return non-escaped strings from user-defined attributes (#6735)
Fixes #6624 This commit changes the behavior of getArgumentValueString() to return the string's value, instead of returning the string's token, as that token also contains the surrounding quotation marks. This commit also modifies the relevant unit test accordingly, to not check for the surrounding quotations.
-rw-r--r--source/slang/slang-reflection-api.cpp4
-rw-r--r--tools/slang-unit-test/unit-test-attribute-reflection.cpp2
2 files changed, 3 insertions, 3 deletions
diff --git a/source/slang/slang-reflection-api.cpp b/source/slang/slang-reflection-api.cpp
index 5dfa9d55a..065c2c3f6 100644
--- a/source/slang/slang-reflection-api.cpp
+++ b/source/slang/slang-reflection-api.cpp
@@ -378,8 +378,8 @@ SLANG_API const char* spReflectionUserAttribute_GetArgumentValueString(
if (auto cexpr = as<StringLiteralExpr>(userAttr->args[index]))
{
if (bufLen)
- *bufLen = cexpr->token.getContentLength();
- return cexpr->token.getContent().begin();
+ *bufLen = cexpr->value.getLength();
+ return cexpr->value.getBuffer();
}
return nullptr;
}
diff --git a/tools/slang-unit-test/unit-test-attribute-reflection.cpp b/tools/slang-unit-test/unit-test-attribute-reflection.cpp
index 7a4758677..d0ef59f9e 100644
--- a/tools/slang-unit-test/unit-test-attribute-reflection.cpp
+++ b/tools/slang-unit-test/unit-test-attribute-reflection.cpp
@@ -66,7 +66,7 @@ SLANG_UNIT_TEST(attributeReflection)
size_t size = 0;
auto guid = comAttribute->getArgumentValueString(0, &size);
UnownedStringSlice stringSlice = UnownedStringSlice(guid, size);
- SLANG_CHECK(stringSlice == "\"042BE50B-CB01-4DBB-8367-3A9CDCBE2F49\"");
+ SLANG_CHECK(stringSlice == "042BE50B-CB01-4DBB-8367-3A9CDCBE2F49");
auto testType = reflection->findTypeByName("TS");
SLANG_CHECK(testType != nullptr);