From f6cb66feab3439f41ca87cb307f69b49654883ab Mon Sep 17 00:00:00 2001 From: Tim Foley Date: Mon, 26 Jun 2017 10:52:31 -0700 Subject: Check for re-import at translation-unit level Previously the code checked for a duplicate `#import` using a data structure attached to the compile request, but this would fail for nested imports. It also wouldn't work for a combination of `#import` and `__import`. This change makes it so that we instead track a set of already-imported modules in the semantic checking visitor, which is instantiated once per translation unit. We also key this set on the actual module (AST) imported, rather than on path/name/whatever, so hopefully it will be robust to the same thing getting imported multiple ways. --- source/slang/preprocessor.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'source/slang/preprocessor.h') diff --git a/source/slang/preprocessor.h b/source/slang/preprocessor.h index ebeb810a0..d23b19773 100644 --- a/source/slang/preprocessor.h +++ b/source/slang/preprocessor.h @@ -7,9 +7,9 @@ namespace Slang { -class CompileRequest; class DiagnosticSink; class ProgramSyntaxNode; +class TranslationUnitRequest; enum class IncludeResult { @@ -35,9 +35,8 @@ TokenList preprocessSource( String const& fileName, DiagnosticSink* sink, IncludeHandler* includeHandler, - Dictionary defines, - ProgramSyntaxNode* syntax, - CompileRequest* compileRequest); + Dictionary defines, + TranslationUnitRequest* translationUnit); } // namespace Slang -- cgit v1.2.3