Skip to content

Commit 2d3f00f

Browse files
committed
Add method to initialize the memory layout
Signed-off-by: Roberto Raggi <[email protected]>
1 parent ce207ed commit 2d3f00f

File tree

5 files changed

+11
-1
lines changed

5 files changed

+11
-1
lines changed

src/frontend/cxx/frontend.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ void Frontend::Private::prepare() {
367367
toolchain_ = std::move(windowsToolchain);
368368
}
369369

370-
unit_->control()->setMemoryLayout(toolchain_->memoryLayout());
370+
toolchain_->initMemoryLayout();
371371
}
372372

373373
void Frontend::Private::preparePreprocessor() {

src/parser/cxx/preprocessor.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2937,6 +2937,8 @@ Preprocessor::Preprocessor(Control* control,
29372937

29382938
Preprocessor::~Preprocessor() = default;
29392939

2940+
auto Preprocessor::control() const -> Control* { return d->control_; }
2941+
29402942
auto Preprocessor::diagnosticsClient() const -> DiagnosticsClient* {
29412943
return d->diagnosticsClient_;
29422944
}

src/parser/cxx/preprocessor.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ class Preprocessor {
5656
explicit Preprocessor(Control* control, DiagnosticsClient* diagnosticsClient);
5757
~Preprocessor();
5858

59+
[[nodiscard]] auto control() const -> Control*;
60+
5961
[[nodiscard]] auto diagnosticsClient() const -> DiagnosticsClient*;
6062

6163
[[nodiscard]] auto language() const -> LanguageKind;

src/parser/cxx/toolchain.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <cxx/toolchain.h>
2222

2323
// cxx
24+
#include <cxx/control.h>
2425
#include <cxx/memory_layout.h>
2526
#include <cxx/preprocessor.h>
2627

@@ -45,6 +46,10 @@ void Toolchain::defineMacro(const std::string& name,
4546
preprocessor_->defineMacro(name, definition);
4647
}
4748

49+
void Toolchain::initMemoryLayout() {
50+
preprocessor_->control()->setMemoryLayout(memoryLayout_.get());
51+
}
52+
4853
void Toolchain::addSystemIncludePath(std::string path) {
4954
preprocessor_->addSystemIncludePath(std::move(path));
5055
}

src/parser/cxx/toolchain.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ class Toolchain {
4646

4747
void setMemoryLayout(std::unique_ptr<MemoryLayout> memoryLayout);
4848

49+
virtual void initMemoryLayout();
4950
virtual void addSystemIncludePaths() = 0;
5051
virtual void addSystemCppIncludePaths() = 0;
5152
virtual void addPredefinedMacros() = 0;

0 commit comments

Comments
 (0)