mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-11-28 16:11:29 +00:00
[flang] Don't propagate PRIVATE into submodule module files
Module files for submodules should not contain PRIVATE attributes, since everything in them is local to the parent module and accessible to all descendant submodules. Differential Revision: https://reviews.llvm.org/D139160
This commit is contained in:
parent
d2a6114f27
commit
4b7428e151
@ -53,9 +53,6 @@ static void PutBound(llvm::raw_ostream &, const Bound &);
|
||||
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 @@ static std::string ModFileName(const SourceName &name,
|
||||
// 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 @@ void ModFileWriter::PutSymbol(
|
||||
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 @@ void ModFileWriter::PutGeneric(const Symbol &symbol) {
|
||||
}
|
||||
}
|
||||
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 @@ void ModFileWriter::PutUse(const Symbol &symbol) {
|
||||
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::PutObjectEntity(
|
||||
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 @@ void ModFileWriter::PutEntity(llvm::raw_ostream &os, const Symbol &symbol,
|
||||
|
||||
// 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);
|
||||
|
@ -51,6 +51,7 @@ private:
|
||||
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 @@ private:
|
||||
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 {
|
||||
|
Loading…
Reference in New Issue
Block a user