Skip to content

Commit

Permalink
Fix Driver initialization order issue preventing symbol paths from be…
Browse files Browse the repository at this point in the history
…ing printed in diagnostics
  • Loading branch information
MikePopoloski committed Jan 26, 2025
1 parent 78492f2 commit f8042bf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 7 additions & 0 deletions include/slang/driver/Driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
//------------------------------------------------------------------------------
#pragma once

#include "slang/ast/Compilation.h"
#include "slang/diagnostics/DiagnosticEngine.h"
#include "slang/driver/SourceLoader.h"
#include "slang/text/SourceManager.h"
Expand Down Expand Up @@ -59,6 +60,12 @@ namespace slang::driver {
/// @endcode
///
class SLANG_EXPORT Driver {
private:
// This exists to ensure we get a Compilation object created prior to anything else,
// such as the DiagnosticEngine, which wants a Compilation to register callbacks
// for printing symbol paths.
ast::Compilation defaultComp;

public:
/// The command line object that will be used to parse
/// arguments if the @a parseCommandLine method is called.
Expand Down
4 changes: 0 additions & 4 deletions source/driver/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

#include <fmt/color.h>

#include "slang/ast/Compilation.h"
#include "slang/ast/symbols/CompilationUnitSymbols.h"
#include "slang/ast/symbols/InstanceSymbols.h"
#include "slang/diagnostics/DeclarationsDiags.h"
Expand Down Expand Up @@ -39,9 +38,6 @@ using namespace parsing;
using namespace syntax;

Driver::Driver() : diagEngine(sourceManager), sourceLoader(sourceManager) {
// Construct a compilation object here before the TextDiagnosticClient
// to ensure that static formatter callbacks are registered.
Compilation compilation;
textDiagClient = std::make_shared<TextDiagnosticClient>();
diagEngine.addClient(textDiagClient);
}
Expand Down

0 comments on commit f8042bf

Please sign in to comment.