Please use GitHub pull requests for new patches. Avoid migrating existing patches. Phabricator shutdown timeline
Changeset View
Changeset View
Standalone View
Standalone View
flang/lib/Frontend/FrontendActions.cpp
Show All 15 Lines | |||||
#include "flang/Parser/parsing.h" | #include "flang/Parser/parsing.h" | ||||
#include "flang/Parser/provenance.h" | #include "flang/Parser/provenance.h" | ||||
#include "flang/Parser/source.h" | #include "flang/Parser/source.h" | ||||
#include "flang/Parser/unparse.h" | #include "flang/Parser/unparse.h" | ||||
#include "flang/Semantics/runtime-type-info.h" | #include "flang/Semantics/runtime-type-info.h" | ||||
#include "flang/Semantics/semantics.h" | #include "flang/Semantics/semantics.h" | ||||
#include "flang/Semantics/unparse-with-symbols.h" | #include "flang/Semantics/unparse-with-symbols.h" | ||||
#include "llvm/ADT/StringRef.h" | #include "llvm/ADT/StringRef.h" | ||||
#include "llvm/Support/ErrorHandling.h" | |||||
#include <clang/Basic/Diagnostic.h> | #include <clang/Basic/Diagnostic.h> | ||||
#include <memory> | #include <memory> | ||||
using namespace Fortran::frontend; | using namespace Fortran::frontend; | ||||
/// Report fatal semantic errors if present. | /// Report fatal semantic errors if present. | ||||
/// | /// | ||||
/// \param semantics The semantics instance | /// \param semantics The semantics instance | ||||
▲ Show 20 Lines • Show All 334 Lines • ▼ Show 20 Lines | |||||
void DebugDumpParsingLogAction::ExecuteAction() { | void DebugDumpParsingLogAction::ExecuteAction() { | ||||
CompilerInstance &ci = this->instance(); | CompilerInstance &ci = this->instance(); | ||||
ci.parsing().Parse(llvm::errs()); | ci.parsing().Parse(llvm::errs()); | ||||
ci.parsing().DumpParsingLog(llvm::outs()); | ci.parsing().DumpParsingLog(llvm::outs()); | ||||
} | } | ||||
void GetDefinitionAction::ExecuteAction() { | |||||
// Report and exit if fatal semantic errors are present | |||||
if (reportFatalSemanticErrors(semantics(), this->instance().diagnostics(), | |||||
GetCurrentFileOrBufferName())) | |||||
return; | |||||
CompilerInstance &ci = this->instance(); | |||||
parser::AllCookedSources &cs = ci.allCookedSources(); | |||||
unsigned diagID = ci.diagnostics().getCustomDiagID( | |||||
clang::DiagnosticsEngine::Error, "Symbol not found"); | |||||
auto gdv = ci.invocation().frontendOpts().getDefVals_; | |||||
auto charBlock{cs.GetCharBlockFromLineAndColumns( | |||||
gdv.line, gdv.startColumn, gdv.endColumn)}; | |||||
if (!charBlock) { | |||||
ci.diagnostics().Report(diagID); | |||||
return; | |||||
} | |||||
llvm::outs() << "String range: >" << charBlock->ToString() << "<\n"; | |||||
auto *symbol{ci.invocation() | |||||
.semanticsContext() | |||||
.FindScope(*charBlock) | |||||
.FindSymbol(*charBlock)}; | |||||
if (!symbol) { | |||||
ci.diagnostics().Report(diagID); | |||||
return; | |||||
} | |||||
llvm::outs() << "Found symbol name: " << symbol->name().ToString() << "\n"; | |||||
auto sourceInfo{cs.GetSourcePositionRange(symbol->name())}; | |||||
if (!sourceInfo) { | |||||
llvm_unreachable( | |||||
"Failed to obtain SourcePosition." | |||||
"TODO: Please, write a test and replace this with a diagnostic!"); | |||||
return; | |||||
} | |||||
llvm::outs() << "Found symbol name: " << symbol->name().ToString() << "\n"; | |||||
llvm::outs() << symbol->name().ToString() << ": " | |||||
<< sourceInfo->first.file.path() << ", " | |||||
<< sourceInfo->first.line << ", " << sourceInfo->first.column | |||||
<< "-" << sourceInfo->second.column << "\n"; | |||||
} | |||||
void GetSymbolsSourcesAction::ExecuteAction() { | void GetSymbolsSourcesAction::ExecuteAction() { | ||||
// Report and exit if fatal semantic errors are present | // Report and exit if fatal semantic errors are present | ||||
if (reportFatalSemanticErrors(semantics(), this->instance().diagnostics(), | if (reportFatalSemanticErrors(semantics(), this->instance().diagnostics(), | ||||
GetCurrentFileOrBufferName())) | GetCurrentFileOrBufferName())) | ||||
return; | return; | ||||
semantics().DumpSymbolsSources(llvm::outs()); | semantics().DumpSymbolsSources(llvm::outs()); | ||||
} | } | ||||
void EmitObjAction::ExecuteAction() { | void EmitObjAction::ExecuteAction() { | ||||
CompilerInstance &ci = this->instance(); | CompilerInstance &ci = this->instance(); | ||||
unsigned DiagID = ci.diagnostics().getCustomDiagID( | unsigned DiagID = ci.diagnostics().getCustomDiagID( | ||||
clang::DiagnosticsEngine::Error, "code-generation is not available yet"); | clang::DiagnosticsEngine::Error, "code-generation is not available yet"); | ||||
ci.diagnostics().Report(DiagID); | ci.diagnostics().Report(DiagID); | ||||
} | } |