summaryrefslogtreecommitdiff
path: root/llvm/lib/Support/FileCollector.cpp
AgeCommit message (Collapse)Author
2024-09-20Revert "[SystemZ][z/OS] Propagate IsText parameter to open text files as ↵Abhina Sreeskantharajan
text (#107906)" This reverts commit edf3b277a5f2ebe144827ed47463c22743cac5f9.
2024-09-20Revert "[SystemZ][z/OS] Propagate IsText flag continuation"Abhina Sreeskantharajan
This reverts commit 3b3accb598ec87a6a30b0e18ded06071030bb78f.
2024-09-19[SystemZ][z/OS] Propagate IsText flag continuationAbhina Sreeskantharajan
2024-09-19[SystemZ][z/OS] Propagate IsText parameter to open text files as text (#107906)Abhina Sree
This patch adds an IsText parameter to the following functions openFileForRead, getBufferForFile, getBufferForFileImpl and determines whether a file is text by querying the file tag on z/OS. The default is set to OF_Text instead of OF_None, this change in value does not affect any other platforms other than z/OS.
2024-05-04[Support] Use StringRef::operator== instead of StringRef::equals (NFC) (#91042)Kazu Hirata
I'm planning to remove StringRef::equals in favor of StringRef::operator==. - StringRef::operator== outnumbers StringRef::equals by a factor of 25 under llvm/ in terms of their usage. - The elimination of StringRef::equals brings StringRef closer to std::string_view, which has operator== but not equals. - S == "foo" is more readable than S.equals("foo"), especially for !Long.Expression.equals("str") vs Long.Expression != "str".
2024-04-12[llvm][vfs] NFCI: Remove `const` from `VFS::getRealPath()`Jan Svoboda
This is an NFC change split from https://github.com/llvm/llvm-project/pull/68645.
2024-01-17[Support] Use SmallString::operator std::string (NFC)Kazu Hirata
2022-11-14[dsymutil] Fix assertion in the Reproducer/FileCollector when TMPDIR is emptyJonas Devlieghere
Fix a assertion in dsymutil coming from the Reproducer/FileCollector. When TMPDIR is empty, the root becomes a relative path, triggering an assertion when adding a relative path to the VFS mapping. This patch fixes the issue by resolving the relative path and also moves the assertion up to make it easier to diagnose these issues in the future. rdar://102170986 Differential revision: https://reviews.llvm.org/D137959
2022-11-14Revert "[dsymutil] Fix assertion in the Reproducer/FileCollector when TMPDIR ↵Jonas Devlieghere
is empty" This reverts commit 68efb4772c0d0e60cbfb09ea619b58d80c31ff0f because the test fails on some of the buildbots.
2022-11-14[dsymutil] Fix assertion in the Reproducer/FileCollector when TMPDIR is emptyJonas Devlieghere
Fix a assertion in dsymutil coming from the Reproducer/FileCollector. When TMPDIR is empty, the root becomes a relative path, triggering an assertion when adding a relative path to the VFS mapping. This patch fixes the issue by resolving the relative path and also moves the assertion up to make it easier to diagnose these issues in the future. rdar://102170986 Differential revision: https://reviews.llvm.org/D137959
2021-04-06[SystemZ][z/OS][Windows] Add new OF_TextWithCRLF flag and use this flag ↵Abhina Sreeskantharajan
instead of OF_Text Problem: On SystemZ we need to open text files in text mode. On Windows, files opened in text mode adds a CRLF '\r\n' which may not be desirable. Solution: This patch adds two new flags - OF_CRLF which indicates that CRLF translation is used. - OF_TextWithCRLF = OF_Text | OF_CRLF indicates that the file is text and uses CRLF translation. Developers should now use either the OF_Text or OF_TextWithCRLF for text files and OF_None for binary files. If the developer doesn't want carriage returns on Windows, they should use OF_Text, if they do want carriage returns on Windows, they should use OF_TextWithCRLF. So this is the behaviour per platform with my patch: z/OS: OF_None: open in binary mode OF_Text : open in text mode OF_TextWithCRLF: open in text mode Windows: OF_None: open file with no carriage return OF_Text: open file with no carriage return OF_TextWithCRLF: open file with carriage return The Major change is in llvm/lib/Support/Windows/Path.inc to only set text mode if the OF_CRLF is set. ``` if (Flags & OF_CRLF) CrtOpenFlags |= _O_TEXT; ``` These following files are the ones that still use OF_Text which I left unchanged. I modified all these except raw_ostream.cpp in recent patches so I know these were previously in Binary mode on Windows. ./llvm/lib/Support/raw_ostream.cpp ./llvm/lib/TableGen/Main.cpp ./llvm/tools/dsymutil/DwarfLinkerForBinary.cpp ./llvm/unittests/Support/Path.cpp ./clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp ./clang/lib/Frontend/CompilerInstance.cpp ./clang/lib/Driver/Driver.cpp ./clang/lib/Driver/ToolChains/Clang.cpp Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D99426
2021-02-16[FileCollector] Fix that the file system case-sensitivity check was invertedRaphael Isemann
real_path returns an `std::error_code` which evaluates to `true` in case an error happens and `false` if not. This code was checking the inverse, so case-insensitive file systems ended up being detected as case sensitive. Tested using an LLDB reproducer test as we anyway need a real file system and also some matching logic to detect whether the respective file system is case-sensitive (which the test is doing via some Python checks that we can't really emulate with the usual FileCheck logic). Fixes rdar://67003004 Reviewed By: JDevlieghere Differential Revision: https://reviews.llvm.org/D96795
2021-01-25Support: Remove duplicated code in {File,clang::ModulesDependency}Collector, NFCDuncan P. N. Exon Smith
Refactor the duplicated canonicalize-path logic in `FileCollector` and `ModulesDependencyCollector` into a new utility called `PathCanonicalizer` that's shared. This popped up when tracking down a bug common to both in https://reviews.llvm.org/D95202. As drive-bys, update a few names and comments to better reflect the effect of the code, delay removal of `..`s to avoid an unnecessary extra string copy, and leave behind a couple of FIXMEs for future consideration. Differential Revision: https://reviews.llvm.org/D95279
2021-01-22ADT: Use 'using' to inherit assign and append in SmallStringDuncan P. N. Exon Smith
Rather than reimplement, use a `using` declaration to bring in `SmallVectorImpl<char>`'s assign and append implementations in `SmallString`. The `SmallString` versions were missing reference invalidation assertions from `SmallVector`. This patch also fixes a bug in `llvm::FileCollector::addFileImpl`, which was a copy/paste from `clang::ModuleDependencyCollector::copyToRoot`, both caught by the no-longer-skipped assertions. As a drive-by, this also sinks the `const SmallVectorImpl&` versions of these methods down into `SmallVectorImpl`, since I imagine they'd be useful elsewhere. Differential Revision: https://reviews.llvm.org/D95202
2020-10-19[FileCollector] Move interface into FileCollectorBase (NFC)Jonas Devlieghere
For the reproducers in LLDB we want to switch to an "immediate mode" FileCollector that writes every file encountered straight to disk so we can generate the actual mapping out-of-process. This patch moves the interface into a separate base class. Differential revision: https://reviews.llvm.org/D89742
2020-08-17[llvm] Don't create the directory hierarchy in the FileCollector...Jonas Devlieghere
... if the collected file doesn't exists. This fixes the situation where LLDB can't create a file when capturing a reproducer because the parent path doesn't exist, but can during replay because the file collector created the directory hierarchy even though the file doesn't exist. This is covered by the lldb reproducer test suite.
2020-06-27FileCollector.h - reduce Twine.h include to forward declaration. NFC.Simon Pilgrim
2020-04-29[FileCollector] move Root creationJan Korous
If we don't handle the errors we can't rely on the directory being created early anyway. Differential Revision: https://reviews.llvm.org/D78959
2020-04-28[FileCollector] Lock Mutex in copyFilesJan Korous
We should synchronize reading of VFSWriter's data with the rest of the methods. Differential revision: https://reviews.llvm.org/D78956
2020-03-30Re-land "[FileCollector] Add a method to add a whole directory and it contents."Jonas Devlieghere
Extend the FileCollector's API with addDirectory which adds a directory and its contents to the VFS mapping. Differential revision: https://reviews.llvm.org/D76671
2020-03-27Revert "[FileCollector] Add a method to add a whole directory and it contents."Jonas Devlieghere
This reverts commit 8913769e353a171ba01fa8ce9d598e979b620be9 because the unit test is failing on the Windows bot.
2020-03-27[FileCollector] Add a method to add a whole directory and it contents.Jonas Devlieghere
Extend the FileCollector's API with addDirectory which adds a directory and its contents to the VFS mapping. Differential revision: https://reviews.llvm.org/D76671
2020-01-28Make llvm::StringRef to std::string conversions explicit.Benjamin Kramer
This is how it should've been and brings it more in line with std::string_view. There should be no functional change here. This is mostly mechanical from a custom clang-tidy check, with a lot of manual fixups. It uncovers a lot of minor inefficiencies. This doesn't actually modify StringRef yet, I'll do that in a follow-up.
2019-08-05Rename F_{None,Text,Append} to OF_{None,Text,Append}. NFCFangrui Song
F_{None,Text,Append} are kept for compatibility since r334221. llvm-svn: 367800
2019-07-29[FileCollector] Add a VFS that records FS accesses using the FileCollectorAlex Lorenz
This patch adds a VFS that can be overlaid on top of another VFS to record file system accesses using the FileCollector. This can help to gather files that are needed for reproducers. Differential Revision: https://reviews.llvm.org/D65411 llvm-svn: 367278
2019-07-25[FileCollector] add support for recording empty directoriesAlex Lorenz
The file collector class is useful for constructing reproducers by creating a snapshot of the files that are accessed. Sometimes it might also be important to construct directories that don't necessarily have files, but are still accessed by some tool that we want to make a reproducer for. This is useful for instance for modeling the behavior of Clang's header search, which scans through a number of directories it doesn't actually access when looking for framework headers. This commit extends the file collector to allow it to work with paths that are just directories, by constructing them as the files are copied over. Differential Revision: https://reviews.llvm.org/D65297 llvm-svn: 367061
2019-07-25[FileCollector] Change coding style from LLDB to LLVM (NFC)Jonas Devlieghere
This patch changes the coding style of the FileCollector from the LLDB to the LLVM coding style. Alex recently lifted it into LLVM and I volunteered to do the conversion. llvm-svn: 366966
2019-07-24[Support] move FileCollector from LLDB to llvm/SupportAlex Lorenz
The file collector class is useful for creating reproducers, not just for LLDB, but for other tools as well in LLVM/Clang. Differential Revision: https://reviews.llvm.org/D65237 llvm-svn: 366956