aboutsummaryrefslogtreecommitdiff
path: root/flang/lib/Parser/source.cpp
AgeCommit message (Collapse)AuthorFilesLines
2024-03-01[flang] Use module file hashes for more checking and disambiguation (#80354)Peter Klausler1-0/+18
f18's module files are Fortran with a leading header comment containing the module file format version and a hash of the following contents. This hash is currently used only to protect module files against corruption and truncation. Extend the use of these hashes to catch or avoid some error cases. When one module file depends upon another, note its hash in additional module file header comments. This allows the compiler to detect when the module dependency is on a module file that has been updated. Further, it allows the compiler to find the right module file dependency when the same module file name appears in multiple directories on the module search path. The order in which module files are written, when multiple modules appear in a source file, is such that every dependency is written before the module(s) that depend upon it, so that their hashes are known. A warning is emitted when a module file is not the first hit on the module file search path. Further work is needed to add a compiler option that emits (larger) stand-alone module files that incorporate copies of their dependencies rather than relying on search paths. This will be desirable for application libraries that want to ship only "top-level" module files without needing to include their dependencies. Another future work item would be to admit multiple modules in the same compilation with the same name if they have distinct hashes.
2023-12-13[flang] Use StringRef::{starts,ends}_with (NFC)Kazu Hirata1-1/+1
This patch replaces uses of StringRef::{starts,ends}with with StringRef::{starts,ends}_with for consistency with std::{string,string_view}::{starts,ends}_with in C++20. I'm planning to deprecate and eventually remove StringRef::{starts,ends}with.
2023-06-29[flang] Honor #line and related preprocessing directivesPeter Klausler1-19/+50
Extend the SourceFile class to take account of #line directives when computing source file positions for error messages. Adjust the output of #line directives to -E output so that they reflect any #line directives that were in the input. Differential Revision: https://reviews.llvm.org/D153910
2021-01-27[flang] Search for #include "file" in right directory (take 2)peter klausler1-6/+4
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
2021-01-26Revert "[flang] Search for #include "file" in right directory"Andrzej Warzynski1-4/+6
This reverts commit d987b61b1dce9948801ac37704477e7c257100b1. As pointed out in https://reviews.llvm.org/D95388, the reverted commit causes build failures in the following Flang buildbots: * http://lab.llvm.org:8011/#/builders/32/builds/2642 * http://lab.llvm.org:8011/#/builders/33/builds/2131 * http://lab.llvm.org:8011/#/builders/135/builds/1473 * http://lab.llvm.org:8011/#/builders/66/builds/1559 * http://lab.llvm.org:8011/#/builders/134/builds/1409 * http://lab.llvm.org:8011/#/builders/132/builds/1817 I'm guessing that the patch was only tested with `FLANG_BUILD_NEW_DRIVER=Off` (i.e. the default). The builders listed above set `FLANG_BUILD_NEW_DRIVER` to `On`. Although fixing the build is relatively easy, the reverted patch modifies the behaviour of the frontend, which breaks driver tests. In particular, in https://reviews.llvm.org/D93453 support for `-I` was added that depends on the current behaviour. The reverted patch changes that behaviour. Either the tests have to be updated or the change fine-tuned.
2021-01-25[flang] Search for #include "file" in right directorypeter klausler1-6/+4
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 after the original. Differential Revision: https://reviews.llvm.org/D95388
2020-10-23[flang][windows] Support platform-specific path separator.Michael Kruse1-5/+8
Remove the assumption that the path separator is `/`. Use functions from `llvm::sys::path` instead. Reviewed By: isuruf, klausler Differential Revision: https://reviews.llvm.org/D89369
2020-07-14[flang] Refine CR handlingpeter klausler1-2/+11
We need to retain carriage return characters in source files that are not parts of multi-byte line endings; they are significant in CHARACTER literal constants. Reviewed By: tskeith Differential Revision: https://reviews.llvm.org/D83808
2020-04-27[flang] Fix handling of files without terminating newlines.David Truby1-5/+12
Reviewers: sscalpone Subscribers: llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D78578
2020-03-28[flang] Reformat with latest clang-format and .clang-formatTim Keith1-1/+1
Original-commit: flang-compiler/f18@9fe84f45d7fd685051004678d6b5775dcc4c6f8f Reviewed-on: https://github.com/flang-compiler/f18/pull/1094
2020-03-24[flang] Replace manual mmap with llvm::MemoryBufferDavid Truby1-165/+49
The previous code had handling for cases when too many file descriptors may be opened; this is not necessary with MemoryBuffer as the file descriptors are closed after the mapping occurs. MemoryBuffer also internally handles the case where a file is small and therefore an mmap is bad for performance; such files are simply copied to memory after being opened. Many places elsewhere in the code assume that the buffer is not empty, and the old file opening code handles this by replacing an empty file with a buffer containing a single newline. That behavior is now kept in the new MemoryBuffer based code. Original-commit: flang-compiler/f18@d34df8435127d847867e2c0bb157def9f20f4202 Reviewed-on: https://github.com/flang-compiler/f18/pull/1032
2020-03-19[flang] [LLVMify F18] Replace the use std::ostream with LLVM streams ↵Caroline Concatto1-8/+12
llvm::ostream This patch replaces the occurrence of std::ostream by llvm::raw_ostream. In LLVM Coding Standards[1] "All new code should use raw_ostream instead of ostream".[1] As a consequence, this patch also replaces the use of: std::stringstream by llvm::raw_string_ostream or llvm::raw_ostream* std::ofstream by llvm::raw_fd_ostream std::endl by '\n' and flush()[2] std::cout by llvm::outs() and std::cerr by llvm::errs() It also replaces std::strerro by llvm::sys::StrError** , but NOT in Fortran runtime libraries *std::stringstream were replaced by llvm::raw_ostream in all methods that used std::stringstream as a parameter. Moreover, it removes the pointers to these streams. [1]https://llvm.org/docs/CodingStandards.html [2]https://releases.llvm.org/2.5/docs/CodingStandards.html#ll_avoidendl Signed-off-by: Caroline Concatto <caroline.concatto@arm.com> Running clang-format-7 Signed-off-by: Caroline Concatto <caroline.concatto@arm.com> Removing residue of ostream library Signed-off-by: Caroline Concatto <caroline.concatto@arm.com> Original-commit: flang-compiler/f18@a3507d44b8911e6024033aa583c1dc54e0eb89fd Reviewed-on: https://github.com/flang-compiler/f18/pull/1047
2020-03-11[flang] Use hash table for UnitMap, avoid C++ STL binary dependencepeter klausler1-1/+1
Scan FORMAT strings locally to avoid C++ binary runtime dependence when computing deepest parenthesis nesting Remove a dependency on ostream from runtime Remove remaining direct external references from runtime to C++ library binaries Remove runtime dependences on lib/common SetPos() and SetRec() Instantiate templates for input Begin input; rearrange locking, deal with CLOSE races View() Update error message in test to agree with compiler change First cut at real input More robust I/O runtime error handling Debugging of REAL input Add iostat.{h,cpp} Rename runtime/numeric-* to runtime/edit-* Move templates around, templatize integer output editing Move LOGICAL and CHARACTER output from io-api.cpp to edit-output.cpp Change pointer argument to reference More list-directed input Complex list-directed input Use enum class Direction rather than bool for templates Catch up with changes to master Undo reformatting of Lower code Use record number instead of subscripts for internal unit Unformatted sequential backspace Testing and debugging Dodge bogus GCC warning Add <cstddef> for std::size_t to fix CI build Address review comments Original-commit: flang-compiler/f18@50406b349609efdde76e48bf2caa039d031dd1c4 Reviewed-on: https://github.com/flang-compiler/f18/pull/1053
2020-02-25[flang] [LLVMify F18] Compiler module folders should have capitalised names ↵CarolineConcatto1-0/+265
(flang-compiler/f18#980) This patch renames the modules in f18 to use a capital letter in the module name Signed-off-by: Caroline Concatto <caroline.concatto@arm.com> Original-commit: flang-compiler/f18@d2eb7a1c443d1539ef12b6f027074a0eb15b1ea0 Reviewed-on: https://github.com/flang-compiler/f18/pull/980