[flang-commits] [PATCH] D139160: [flang] Don't propagate PRIVATE into submodule module files
Peter Klausler via Phabricator via flang-commits
flang-commits at lists.llvm.org
Sun Dec 4 17:00:36 PST 2022
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4b7428e1516e: [flang] Don't propagate PRIVATE into submodule module files (authored by klausler).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D139160/new/
https://reviews.llvm.org/D139160
Files:
flang/lib/Semantics/mod-file.cpp
flang/lib/Semantics/mod-file.h
Index: flang/lib/Semantics/mod-file.h
===================================================================
--- flang/lib/Semantics/mod-file.h
+++ flang/lib/Semantics/mod-file.h
@@ -51,6 +51,7 @@
useExtraAttrsBuf_}; // attrs added to used entity
llvm::raw_string_ostream decls_{declsBuf_};
llvm::raw_string_ostream contains_{containsBuf_};
+ bool isSubmodule_{false};
void WriteAll(const Scope &);
void WriteOne(const Scope &);
@@ -72,6 +73,9 @@
void PutGeneric(const Symbol &);
void PutUse(const Symbol &);
void PutUseExtraAttr(Attr, const Symbol &, const Symbol &);
+ llvm::raw_ostream &PutAttrs(llvm::raw_ostream &, Attrs,
+ const std::string * = nullptr, std::string before = ","s,
+ std::string after = ""s) const;
};
class ModFileReader {
Index: flang/lib/Semantics/mod-file.cpp
===================================================================
--- flang/lib/Semantics/mod-file.cpp
+++ flang/lib/Semantics/mod-file.cpp
@@ -53,9 +53,6 @@
static void PutShapeSpec(llvm::raw_ostream &, const ShapeSpec &);
static void PutShape(
llvm::raw_ostream &, const ArraySpec &, char open, char close);
-llvm::raw_ostream &PutAttrs(llvm::raw_ostream &, Attrs,
- const std::string * = nullptr, std::string before = ","s,
- std::string after = ""s);
static llvm::raw_ostream &PutAttr(llvm::raw_ostream &, Attr);
static llvm::raw_ostream &PutType(llvm::raw_ostream &, const DeclTypeSpec &);
@@ -132,6 +129,7 @@
// Write the module file for symbol, which must be a module or submodule.
void ModFileWriter::Write(const Symbol &symbol) {
auto *ancestor{symbol.get<ModuleDetails>().ancestor()};
+ isSubmodule_ = ancestor != nullptr;
auto ancestorName{ancestor ? ancestor->GetName().value().ToString() : ""s};
auto path{context_.moduleDirectory() + '/' +
ModFileName(symbol.name(), ancestorName, context_.moduleFileSuffix())};
@@ -310,6 +308,9 @@
sep = ',';
}
decls_ << '\n';
+ if (!isSubmodule_ && symbol.attrs().test(Attr::PRIVATE)) {
+ decls_ << "private::" << symbol.name() << '\n';
+ }
},
[&](const CommonBlockDetails &x) {
decls_ << "common/" << symbol.name();
@@ -519,7 +520,7 @@
}
}
decls_ << "end interface\n";
- if (symbol.attrs().test(Attr::PRIVATE)) {
+ if (!isSubmodule_ && symbol.attrs().test(Attr::PRIVATE)) {
PutGenericName(decls_ << "private::", symbol) << '\n';
}
}
@@ -543,7 +544,7 @@
uses_ << '\n';
PutUseExtraAttr(Attr::VOLATILE, symbol, use);
PutUseExtraAttr(Attr::ASYNCHRONOUS, symbol, use);
- if (symbol.attrs().test(Attr::PRIVATE)) {
+ if (!isSubmodule_ && symbol.attrs().test(Attr::PRIVATE)) {
PutGenericName(useExtraAttrs_ << "private::", symbol) << '\n';
}
}
@@ -686,7 +687,7 @@
void ModFileWriter::PutProcEntity(llvm::raw_ostream &os, const Symbol &symbol) {
if (symbol.attrs().test(Attr::INTRINSIC)) {
os << "intrinsic::" << symbol.name() << '\n';
- if (symbol.attrs().test(Attr::PRIVATE)) {
+ if (!isSubmodule_ && symbol.attrs().test(Attr::PRIVATE)) {
os << "private::" << symbol.name() << '\n';
}
return;
@@ -777,10 +778,13 @@
// Put out each attribute to os, surrounded by `before` and `after` and
// mapped to lower case.
-llvm::raw_ostream &PutAttrs(llvm::raw_ostream &os, Attrs attrs,
- const std::string *bindName, std::string before, std::string after) {
+llvm::raw_ostream &ModFileWriter::PutAttrs(llvm::raw_ostream &os, Attrs attrs,
+ const std::string *bindName, std::string before, std::string after) const {
attrs.set(Attr::PUBLIC, false); // no need to write PUBLIC
attrs.set(Attr::EXTERNAL, false); // no need to write EXTERNAL
+ if (isSubmodule_) {
+ attrs.set(Attr::PRIVATE, false);
+ }
if (bindName) {
os << before << "bind(c, name=\"" << *bindName << "\")" << after;
attrs.set(Attr::BIND_C, false);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D139160.479953.patch
Type: text/x-patch
Size: 3933 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20221205/31424759/attachment.bin>
More information about the flang-commits
mailing list