From ecac0c76a93bd123d5a5a86473716ad166f8c5d6 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Thu, 4 Jun 2020 17:15:38 -0400 Subject: Add a ASTBuilder to a Module (#1369) Only construct on valid ASTBuilder (was being called on nullptr on occassion) --- source/slang/slang-ast-builder.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'source/slang/slang-ast-builder.cpp') diff --git a/source/slang/slang-ast-builder.cpp b/source/slang/slang-ast-builder.cpp index 316390353..67ce80120 100644 --- a/source/slang/slang-ast-builder.cpp +++ b/source/slang/slang-ast-builder.cpp @@ -21,18 +21,20 @@ void SharedASTBuilder::init(Session* session) m_session = session; // We just want as a place to store allocations of shared types - RefPtr astBuilder(new ASTBuilder); - - astBuilder->m_sharedASTBuilder = this; + { + RefPtr astBuilder(new ASTBuilder); + astBuilder->m_sharedASTBuilder = this; + m_astBuilder = astBuilder.detach(); + } + // Clear the built in types memset(m_builtinTypes, 0, sizeof(m_builtinTypes)); + // Create common shared types m_errorType = m_astBuilder->create(); m_initializerListType = m_astBuilder->create(); m_overloadedType = m_astBuilder->create(); - m_astBuilder = astBuilder.detach(); - // We can just iterate over the class pointers. // NOTE! That this adds the names of the abstract classes too(!) for (Index i = 0; i < Index(ASTNodeType::CountOf); ++i) -- cgit v1.2.3