From 941f07040a505f1f673c96da959bde839c629aba Mon Sep 17 00:00:00 2001 From: Yong He Date: Wed, 11 Dec 2024 13:34:54 -0800 Subject: Fix attribute reflection. (#5823) * Fix attribute reflection. * Fix. * Fix. --- source/slang/slang-reflection-api.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'source/slang/slang-reflection-api.cpp') diff --git a/source/slang/slang-reflection-api.cpp b/source/slang/slang-reflection-api.cpp index 93e495194..d7f793d05 100644 --- a/source/slang/slang-reflection-api.cpp +++ b/source/slang/slang-reflection-api.cpp @@ -23,11 +23,11 @@ namespace Slang // Conversion routines to help with strongly-typed reflection API -static inline UserDefinedAttribute* convert(SlangReflectionUserAttribute* attrib) +static inline Attribute* convert(SlangReflectionUserAttribute* attrib) { - return (UserDefinedAttribute*)attrib; + return (Attribute*)attrib; } -static inline SlangReflectionUserAttribute* convert(UserDefinedAttribute* attrib) +static inline SlangReflectionUserAttribute* convert(Attribute* attrib) { return (SlangReflectionUserAttribute*)attrib; } @@ -154,7 +154,9 @@ static SlangReflectionUserAttribute* findUserAttributeByName( const char* name) { auto nameObj = session->tryGetNameObj(name); - for (auto x : decl->getModifiersOfType()) + if (!nameObj) + return nullptr; + for (auto x : decl->getModifiersOfType()) { if (x->keywordName == nameObj) return (SlangReflectionUserAttribute*)(x); -- cgit v1.2.3