aboutsummaryrefslogtreecommitdiff
path: root/flang/lib/Parser/source.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'flang/lib/Parser/source.cpp')
-rw-r--r--flang/lib/Parser/source.cpp10
1 files changed, 4 insertions, 6 deletions
diff --git a/flang/lib/Parser/source.cpp b/flang/lib/Parser/source.cpp
index 11cd591..3fbbf78 100644
--- a/flang/lib/Parser/source.cpp
+++ b/flang/lib/Parser/source.cpp
@@ -56,9 +56,9 @@ std::string DirectoryName(std::string path) {
return pathBuf.str().str();
}
-std::string LocateSourceFile(
- std::string name, const std::vector<std::string> &searchPath) {
- if (name.empty() || name == "-" || llvm::sys::path::is_absolute(name)) {
+std::optional<std::string> LocateSourceFile(
+ std::string name, const std::list<std::string> &searchPath) {
+ if (name == "-" || llvm::sys::path::is_absolute(name)) {
return name;
}
for (const std::string &dir : searchPath) {
@@ -70,7 +70,7 @@ std::string LocateSourceFile(
return path.str().str();
}
}
- return name;
+ return std::nullopt;
}
std::size_t RemoveCarriageReturns(llvm::MutableArrayRef<char> buf) {
@@ -123,7 +123,6 @@ bool SourceFile::Open(std::string path, llvm::raw_ostream &error) {
bool SourceFile::ReadStandardInput(llvm::raw_ostream &error) {
Close();
path_ = "standard input";
-
auto buf_or = llvm::MemoryBuffer::getSTDIN();
if (!buf_or) {
auto err = buf_or.getError();
@@ -146,7 +145,6 @@ void SourceFile::ReadFile() {
auto tmp_buf{llvm::WritableMemoryBuffer::getNewUninitMemBuffer(
content().size() + 1)};
llvm::copy(content(), tmp_buf->getBufferStart());
- Close();
buf_ = std::move(tmp_buf);
}
buf_end_++;