Skip to content

Commit d3c6d36

Browse files
committed
Fixup Use-of-Temporary
The Optional parameter here was being copied instead of being taken by const reference. The expectation is that we call this function and extract the data from a ModuleDepGraphNode node, but instead we were extracting a copy which would promptly blow up. Thanks ASAN!
1 parent b0f0587 commit d3c6d36

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

include/swift/Driver/FineGrainedDependencyDriverGraph.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ class ModuleDepGraph {
466466
void printPath(raw_ostream &out, const driver::Job *node) const;
467467

468468
/// Get a printable filename, given a node's swiftDeps.
469-
StringRef getProvidingFilename(Optional<std::string> swiftDeps) const;
469+
StringRef getProvidingFilename(const Optional<std::string> &swiftDeps) const;
470470

471471
/// Print one node on the dependency path.
472472
static void printOneNodeOfPath(raw_ostream &out, const DependencyKey &key,

lib/Driver/FineGrainedDependencyDriverGraph.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -749,7 +749,7 @@ void ModuleDepGraph::printPath(raw_ostream &out,
749749
}
750750

751751
StringRef ModuleDepGraph::getProvidingFilename(
752-
const Optional<std::string> swiftDeps) const {
752+
const Optional<std::string> &swiftDeps) const {
753753
if (!swiftDeps)
754754
return "<unknown";
755755
auto ext = llvm::sys::path::extension(*swiftDeps);

0 commit comments

Comments
 (0)