[flang-dev] RFC: Porting SourceFile to using LLVM file handling facilities

David Truby via flang-dev flang-dev at lists.llvm.org
Wed Jan 29 08:03:41 PST 2020


Hi All,

I’ve been looking at SourceFile as the main user of posix file handling functions and how this could be ported to use LLVM’s file handling facilities. I noticed that we are mmapping for sufficiently large files and just reading small ones, which seems like a good fit for the llvm::MemoryBuffer class (which does the same thing).
Does this seem like a sensible route to take to anyone that might be more familiar with the code than me?

One thing that I noticed however is that the input file is being rewritten (in memory) to remove carriage returns. Does someone more familiar with the preprocessor or parser than me know if this is because we can’t handle carriage returns later? If so, how difficult would it to be to add handling for them (just treating them as whitespace seems appropriate)?
I think we should avoid rewriting the input file if possible as it requires reading the whole thing one more time than is strictly necessary.

Thanks
David Truby


More information about the flang-dev mailing list