Update ASTPrinting of lifetime dependence

This commit is contained in:
Meghana Gupta
2024-07-09 00:01:05 -07:00
parent 815d7a67f5
commit 2b28da6dd7
4 changed files with 78 additions and 36 deletions

View File

@@ -364,6 +364,22 @@ public:
return printedClangDecl.insert(d).second;
}
void printLifetimeDependence(
std::optional<LifetimeDependenceInfo> lifetimeDependence) {
if (!lifetimeDependence.has_value()) {
return;
}
*this << lifetimeDependence->getString();
}
void printLifetimeDependenceAt(
ArrayRef<LifetimeDependenceInfo> lifetimeDependencies, unsigned index) {
if (auto lifetimeDependence =
getLifetimeDependenceFor(lifetimeDependencies, index)) {
printLifetimeDependence(*lifetimeDependence);
}
}
private:
virtual void anchor();
};

View File

@@ -3792,6 +3792,10 @@ public:
targetIndex);
}
std::optional<LifetimeDependenceInfo> getLifetimeDependenceForResult() const {
return getLifetimeDependenceFor(getNumParams());
}
void Profile(llvm::FoldingSetNodeID &ID) {
std::optional<ExtInfo> info = std::nullopt;
if (hasExtInfo())
@@ -4465,8 +4469,12 @@ public:
SWIFT_DEBUG_DUMP;
void print(llvm::raw_ostream &out,
const PrintOptions &options = PrintOptions()) const;
void print(ASTPrinter &Printer, const PrintOptions &Options) const;
const PrintOptions &options = PrintOptions(),
std::optional<LifetimeDependenceInfo> lifetimeDependence =
std::nullopt) const;
void print(ASTPrinter &Printer, const PrintOptions &Options,
std::optional<LifetimeDependenceInfo> lifetimeDependence =
std::nullopt) const;
friend llvm::raw_ostream &operator<<(llvm::raw_ostream &out,
SILParameterInfo type) {
type.print(out);
@@ -5363,6 +5371,16 @@ public:
NumLifetimeDependencies};
}
std::optional<LifetimeDependenceInfo>
getLifetimeDependenceFor(unsigned targetIndex) const {
return swift::getLifetimeDependenceFor(getLifetimeDependencies(),
targetIndex);
}
std::optional<LifetimeDependenceInfo> getLifetimeDependenceForResult() const {
return getLifetimeDependenceFor(getNumParameters());
}
/// Returns true if the function type stores a Clang type that cannot
/// be derived from its Swift type. Returns false otherwise, including if
/// the function type is not @convention(c) or @convention(block).