summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-ast-base.cpp
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2023-09-26 15:40:22 -0400
committerGitHub <noreply@github.com>2023-09-26 12:40:22 -0700
commita18dca27392b257ba2cc58ceabdf15471f34ee25 (patch)
treee76ed8fa4fbdc3f9fa3e0ea4f1b45bde64b57eab /source/slang/slang-ast-base.cpp
parent6c991942ac4ec2e2abf6abe73a2429183172af84 (diff)
Fix for epoch/ASTBuilder* nullptr issue (#3240)
* Fix issue with failing tests tests/serialization/serialized-module-test.slang tests/serialization/extern/extern-test.slang * Fix issue with session destruction order on Session. * Improve comment.
Diffstat (limited to 'source/slang/slang-ast-base.cpp')
-rw-r--r--source/slang/slang-ast-base.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/source/slang/slang-ast-base.cpp b/source/slang/slang-ast-base.cpp
index 7fa0a8886..60be7a563 100644
--- a/source/slang/slang-ast-base.cpp
+++ b/source/slang/slang-ast-base.cpp
@@ -22,11 +22,14 @@ void NodeBase::_initDebug(ASTNodeType inAstNodeType, ASTBuilder* inAstBuilder)
}
DeclRefBase* Decl::getDefaultDeclRef()
{
- auto astBuilder = getCurrentASTBuilder();
- if (astBuilder && astBuilder->getEpoch() != m_defaultDeclRefEpoch || !m_defaultDeclRef)
+ if (auto astBuilder = getCurrentASTBuilder())
{
- m_defaultDeclRef = astBuilder->getOrCreate<DirectDeclRef>(this);
- m_defaultDeclRefEpoch = astBuilder->getEpoch();
+ const Index currentEpoch = astBuilder->getEpoch();
+ if (currentEpoch != m_defaultDeclRefEpoch || !m_defaultDeclRef)
+ {
+ m_defaultDeclRef = astBuilder->getOrCreate<DirectDeclRef>(this);
+ m_defaultDeclRefEpoch = currentEpoch;
+ }
}
return m_defaultDeclRef;
}