From ae4d7ac9c885d56c98c1a19af9c330de37883ad1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrzej=20Warzy=C5=84ski?= Date: Wed, 29 Nov 2023 21:20:43 +0000 Subject: [flang][driver][nfc] Move the definition of SemanticsContext (#73669) Moves the defintion of `SemanticsContext` within the Flang driver. Rather than in `CompilerInvocation`, semantic context fits better within `CompilerInstance` that encapsulates the objects that are required to run the frontend. `CompilerInvocation` is better suited for objects encapsulating compiler configuration (e.g. set-up resulting from user input or host set-up). --- flang/lib/Frontend/CompilerInvocation.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'flang/lib/Frontend/CompilerInvocation.cpp') diff --git a/flang/lib/Frontend/CompilerInvocation.cpp b/flang/lib/Frontend/CompilerInvocation.cpp index 30e53ce..e7730d5 100644 --- a/flang/lib/Frontend/CompilerInvocation.cpp +++ b/flang/lib/Frontend/CompilerInvocation.cpp @@ -1344,11 +1344,12 @@ void CompilerInvocation::setFortranOpts() { fortranOptions.features.WarnOnAllUsage(); } -void CompilerInvocation::setSemanticsOpts( +std::unique_ptr +CompilerInvocation::getSemanticsCtx( Fortran::parser::AllCookedSources &allCookedSources) { auto &fortranOptions = getFortranOpts(); - semanticsContext = std::make_unique( + auto semanticsContext = std::make_unique( getDefaultKinds(), fortranOptions.features, allCookedSources); semanticsContext->set_moduleDirectory(getModuleDir()) @@ -1372,6 +1373,8 @@ void CompilerInvocation::setSemanticsOpts( if (targetTriple.isPPC()) semanticsContext->targetCharacteristics().set_isPPC(true); + + return semanticsContext; } /// Set \p loweringOptions controlling lowering behavior based -- cgit v1.1