From da0d295d6c8b6fb03245dea0583437c198890349 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Thu, 22 Apr 2021 09:32:25 -0400 Subject: C++ extractor improvements (#1803) * #include an absolute path didn't work - because paths were taken to always be relative. * Split of NodeTree. Split out FileUtil. Split out MacroWriter. * Rename slang-cpp-extractor-main.cpp -> cpp-extractor-main.cpp * First pass at extractor unit-tests * Initial parsing of enum. * Ability to disable/enable parsing of scope types. * Initial support for typedef. * Added operator== != to ArrayVIew. Added test for splitting to unit tests. * Improve comment in StringUtil. * Fix comment. * Fix typo. --- source/compiler-core/slang-diagnostic-sink.cpp | 17 +++++++++++++++++ source/compiler-core/slang-diagnostic-sink.h | 16 ++++++++-------- 2 files changed, 25 insertions(+), 8 deletions(-) (limited to 'source/compiler-core') diff --git a/source/compiler-core/slang-diagnostic-sink.cpp b/source/compiler-core/slang-diagnostic-sink.cpp index 2adf31f69..727c322a5 100644 --- a/source/compiler-core/slang-diagnostic-sink.cpp +++ b/source/compiler-core/slang-diagnostic-sink.cpp @@ -385,6 +385,23 @@ static void formatDiagnostic( } } +void DiagnosticSink::init(SourceManager* sourceManager, SourceLocationLexer sourceLocationLexer) +{ + m_errorCount = 0; + m_internalErrorLocsNoted = 0; + + m_flags = 0; + + m_sourceManager = sourceManager; + m_sourceLocationLexer = sourceLocationLexer; + + // If we have a source location lexer, we'll by default enable source location output + if (sourceLocationLexer) + { + setFlag(Flag::SourceLocationLine); + } +} + void DiagnosticSink::diagnoseImpl(SourceLoc const& pos, DiagnosticInfo const& info, int argCount, DiagnosticArg const* const* args) { StringBuilder sb; diff --git a/source/compiler-core/slang-diagnostic-sink.h b/source/compiler-core/slang-diagnostic-sink.h index 84001e6f5..347ff761c 100644 --- a/source/compiler-core/slang-diagnostic-sink.h +++ b/source/compiler-core/slang-diagnostic-sink.h @@ -217,16 +217,16 @@ public: /// character caret at location SourceLocationLexer getSourceLocationLexer() const { return m_sourceLocationLexer; } + /// Initialize state. + void init(SourceManager* sourceManager, SourceLocationLexer sourceLocationLexer); + /// Ctor - DiagnosticSink(SourceManager* sourceManager, SourceLocationLexer sourceLocationLexer) - : m_sourceManager(sourceManager), - m_sourceLocationLexer(sourceLocationLexer) + DiagnosticSink(SourceManager* sourceManager, SourceLocationLexer sourceLocationLexer) { init(sourceManager, sourceLocationLexer); } + /// Default Ctor + DiagnosticSink(): + m_sourceManager(nullptr), + m_sourceLocationLexer (nullptr) { - // If we have a source location lexer, we'll by default enable source location output - if (sourceLocationLexer) - { - setFlag(Flag::SourceLocationLine); - } } // Public members -- cgit v1.2.3