[flang-commits] [flang] [flang] Represent use statement in fir. (PR #168106)
Kareem Ergawy via flang-commits
flang-commits at lists.llvm.org
Wed Dec 17 22:17:15 PST 2025
================
@@ -222,6 +222,75 @@ static mlir::FlatSymbolRefAttr gatherComponentInit(
return mlir::FlatSymbolRefAttr::get(mlirContext, name);
}
+/// Emit fir.use_stmt operations for USE statements in the given scope
+static void
+emitUseStatementsFromScope(Fortran::lower::AbstractConverter &converter,
+ mlir::OpBuilder &builder, mlir::Location loc,
+ const Fortran::semantics::Scope &scope) {
+ mlir::MLIRContext *context = builder.getContext();
+
+ for (const auto &preservedStmt : scope.preservedUseStmts()) {
+
+ auto getMangledName = [&](const std::string &localName) -> std::string {
+ Fortran::parser::CharBlock charBlock{localName.data(), localName.size()};
+ const auto *sym = scope.FindSymbol(charBlock);
+ if (!sym)
+ return "";
----------------
ergawy wrote:
Sorry for missing this first time, can explain why in this and below cases it's fine to return an empty string rather than emitting a todo, error, or some kind of warning?
https://github.com/llvm/llvm-project/pull/168106
More information about the flang-commits
mailing list