diff options
author | peter klausler <pklausler@nvidia.com> | 2021-01-26 13:57:44 -0800 |
---|---|---|
committer | peter klausler <pklausler@nvidia.com> | 2021-01-27 15:41:29 -0800 |
commit | 6110e7716cd0000fdeb2a7edfbec7c9991f1a08a (patch) | |
tree | 0569a4747572fb74859b5299bcc8ab20ad0e107e /flang/lib/Parser/source.cpp | |
parent | 764a7a2155c6747ec8d0b38d8edbb65960eae874 (diff) | |
download | llvm-6110e7716cd0000fdeb2a7edfbec7c9991f1a08a.zip llvm-6110e7716cd0000fdeb2a7edfbec7c9991f1a08a.tar.gz llvm-6110e7716cd0000fdeb2a7edfbec7c9991f1a08a.tar.bz2 |
[flang] Search for #include "file" in right directory (take 2)
Make the #include "file" preprocessing directive begin its
search in the same directory as the file containing the directive,
as other preprocessors and our Fortran INCLUDE statement do.
Avoid current working directory for all source files except the original.
Resolve tests.
Differential Revision: https://reviews.llvm.org/D95481
Diffstat (limited to 'flang/lib/Parser/source.cpp')
-rw-r--r-- | flang/lib/Parser/source.cpp | 10 |
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_++; |