diff --git a/src/inspector/inspector.cc b/src/inspector/inspector.cc index 7957c85aae..1564d379c7 100644 --- a/src/inspector/inspector.cc +++ b/src/inspector/inspector.cc @@ -46,9 +46,9 @@ namespace inspector { Inspector::Inspector(ast::Module& module, Namer* namer) : module_(module), namer_(namer), namer_is_owned_(false) {} -Inspector::Inspector(ast::Module& module) +Inspector::Inspector(const ast::Module& module) : module_(module), - namer_(new MangleNamer(&module)), + namer_(new MangleNamer(&module_)), namer_is_owned_(true) {} Inspector::~Inspector() { diff --git a/src/inspector/inspector.h b/src/inspector/inspector.h index 4a17b8ddd0..9ec0f0012b 100644 --- a/src/inspector/inspector.h +++ b/src/inspector/inspector.h @@ -77,7 +77,7 @@ class Inspector { Inspector(ast::Module& module, Namer* namer); /// Constructor /// @param module Shader module to extract information from. - explicit Inspector(ast::Module& module); + explicit Inspector(const ast::Module& module); ~Inspector(); /// @returns error messages from the Inspector diff --git a/src/namer.cc b/src/namer.cc index d5f304d9b1..9215b3904e 100644 --- a/src/namer.cc +++ b/src/namer.cc @@ -22,7 +22,7 @@ namespace tint { -Namer::Namer(ast::Module* mod) : module_(mod) {} +Namer::Namer(const ast::Module* mod) : module_(mod) {} Namer::~Namer() = default; @@ -46,7 +46,7 @@ std::string Namer::GenerateName(const std::string& prefix) { return name; } -MangleNamer::MangleNamer(ast::Module* mod) : Namer(mod) {} +MangleNamer::MangleNamer(const ast::Module* mod) : Namer(mod) {} MangleNamer::~MangleNamer() = default; @@ -54,7 +54,7 @@ std::string MangleNamer::NameFor(const Symbol& sym) { return sym.to_str(); } -UnsafeNamer::UnsafeNamer(ast::Module* mod) : Namer(mod) {} +UnsafeNamer::UnsafeNamer(const ast::Module* mod) : Namer(mod) {} UnsafeNamer::~UnsafeNamer() = default; diff --git a/src/namer.h b/src/namer.h index 7745cf07e4..e2b671a74f 100644 --- a/src/namer.h +++ b/src/namer.h @@ -28,7 +28,7 @@ class Namer { public: /// Constructor /// @param mod the module this namer works with - explicit Namer(ast::Module* mod); + explicit Namer(const ast::Module* mod); /// Destructor virtual ~Namer(); @@ -52,7 +52,7 @@ class Namer { bool IsUsed(const std::string& name); /// The module storing the symbol table - ast::Module* module_ = nullptr; + const ast::Module* module_ = nullptr; private: // The list of names taken by the remapper @@ -64,7 +64,7 @@ class MangleNamer : public Namer { public: /// Constructor /// @param mod the module to retrieve names from - explicit MangleNamer(ast::Module* mod); + explicit MangleNamer(const ast::Module* mod); /// Destructor ~MangleNamer() override; @@ -81,7 +81,7 @@ class UnsafeNamer : public Namer { public: /// Constructor /// @param mod the module to retrieve names from - explicit UnsafeNamer(ast::Module* mod); + explicit UnsafeNamer(const ast::Module* mod); /// Destructor ~UnsafeNamer() override; diff --git a/src/writer/test_namer.cc b/src/writer/test_namer.cc index 0ab1a7db69..1c131487e2 100644 --- a/src/writer/test_namer.cc +++ b/src/writer/test_namer.cc @@ -17,7 +17,7 @@ namespace tint { namespace writer { -TestNamer::TestNamer(ast::Module* mod) : Namer(mod) {} +TestNamer::TestNamer(const ast::Module* mod) : Namer(mod) {} TestNamer::~TestNamer() = default; diff --git a/src/writer/test_namer.h b/src/writer/test_namer.h index 44a7e684c7..da08c2c01b 100644 --- a/src/writer/test_namer.h +++ b/src/writer/test_namer.h @@ -27,7 +27,7 @@ class TestNamer : public Namer { public: /// Constructor /// @param mod the module to retrieve names from - explicit TestNamer(ast::Module* mod); + explicit TestNamer(const ast::Module* mod); /// Destructor ~TestNamer() override;