As per point 3 in [1]: ``` Accessor member functions are named with the non-public data member's name, less the trailing underscore. Mutator member functions are named set_... ``` Originally we just followed the LLVM's style, which is incompatible with Flang. This patch renames the accessors and mutators accordingly. `getDiagnostics` and `GetDiagnostics` are replaced with one accessor: `diagnostics`. `SetDiagnostics` was neither implemented nor used, so it's deleted. [1] https://github.com/llvm/llvm-project/blob/master/flang/docs/C++style.md#naming Differential Revision: https://reviews.llvm.org/D90300
62 lines
1.9 KiB
C++
62 lines
1.9 KiB
C++
//===--- FrontendAction.cpp -----------------------------------------------===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "flang/Frontend/FrontendAction.h"
|
|
#include "flang/Frontend/CompilerInstance.h"
|
|
#include "flang/Frontend/FrontendActions.h"
|
|
#include "llvm/Support/Errc.h"
|
|
|
|
using namespace Fortran::frontend;
|
|
|
|
void FrontendAction::set_currentInput(const FrontendInputFile ¤tInput) {
|
|
this->currentInput_ = currentInput;
|
|
}
|
|
|
|
// Call this method if BeginSourceFile fails.
|
|
// Deallocate compiler instance, input and output descriptors
|
|
static void BeginSourceFileCleanUp(FrontendAction &fa, CompilerInstance &ci) {
|
|
ci.ClearOutputFiles(/*EraseFiles=*/true);
|
|
fa.set_currentInput(FrontendInputFile());
|
|
fa.set_instance(nullptr);
|
|
}
|
|
|
|
bool FrontendAction::BeginSourceFile(
|
|
CompilerInstance &ci, const FrontendInputFile &realInput) {
|
|
|
|
FrontendInputFile input(realInput);
|
|
assert(!instance_ && "Already processing a source file!");
|
|
assert(!realInput.IsEmpty() && "Unexpected empty filename!");
|
|
set_currentInput(realInput);
|
|
set_instance(&ci);
|
|
if (!ci.HasAllSources()) {
|
|
BeginSourceFileCleanUp(*this, ci);
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
bool FrontendAction::ShouldEraseOutputFiles() {
|
|
return instance().diagnostics().hasErrorOccurred();
|
|
}
|
|
|
|
llvm::Error FrontendAction::Execute() {
|
|
ExecuteAction();
|
|
return llvm::Error::success();
|
|
}
|
|
|
|
void FrontendAction::EndSourceFile() {
|
|
CompilerInstance &ci = instance();
|
|
|
|
// Cleanup the output streams, and erase the output files if instructed by the
|
|
// FrontendAction.
|
|
ci.ClearOutputFiles(/*EraseFiles=*/ShouldEraseOutputFiles());
|
|
|
|
set_instance(nullptr);
|
|
set_currentInput(FrontendInputFile());
|
|
}
|