summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/Support/Path.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* [Support] Extend sys::path with user_cache_directory function.Pawel Bylica2015-11-021-0/+29
| | | | | | | | | | | | | | | | | | | | Summary: The new function sys::path::user_cache_directory tries to discover a directory suitable for cache storage for current system user. On Windows and Darwin it returns a path to system-specific user cache directory. On Linux it follows XDG Base Directory Specification, what is: - use non-empty $XDG_CACHE_HOME env var, - use $HOME/.cache. Reviewers: chapuni, aaron.ballman, rafael Subscribers: rafael, aaron.ballman, llvm-commits Differential Revision: http://reviews.llvm.org/D13801 llvm-svn: 251784
* Fix path::home_directory() unit test.Pawel Bylica2015-10-161-8/+12
| | | | | | It turns out that constructing std::string from null pointer is not the very best idea. llvm-svn: 250506
* SupportTests::HomeDirectory: Don't try tests when $HOME is undefined.NAKAMURA Takumi2015-10-161-6/+9
| | | | | | Lit sanitizes env vars. $HOME is not exported in Lit tests. llvm-svn: 250505
* Reformat.NAKAMURA Takumi2015-10-161-1/+1
| | | | llvm-svn: 250504
* Use Windows Vista API to get the user's home directoryPawel Bylica2015-10-161-9/+13
| | | | | | | | | | | | Summary: This patch replaces usage of deprecated SHGetFolderPathW with SHGetKnownFolderPath. The usage of SHGetKnownFolderPath is wrapped to allow queries for other "known" folders in the near future. Reviewers: aaron.ballman, gbedwell Subscribers: chapuni, llvm-commits Differential Revision: http://reviews.llvm.org/D13753 llvm-svn: 250501
* Make test resilient against windows path separators.Benjamin Kramer2015-10-051-0/+1
| | | | llvm-svn: 249320
* [Support] Add a version of fs::make_absolute with a custom CWD.Benjamin Kramer2015-10-051-0/+4
| | | | | | This will be used soon from clang. llvm-svn: 249309
* [ADT] Switch a bunch of places in LLVM that were doing single-characterChandler Carruth2015-09-101-4/+4
| | | | | | | splits to actually use the single character split routine which does less work, and in a debug build is *substantially* faster. llvm-svn: 247245
* Move twice-repeated clang path operation into a new function.Douglas Katzman2015-09-021-0/+10
| | | | | | And make it more robust in the edge case of exactly "./" as input. llvm-svn: 246711
* Thread premissions through sys::fs::create_director{y|ies}Frederic Riss2015-08-061-0/+24
| | | | llvm-svn: 244268
* llvm/unittests/Support/Path.cpp: Use <windows.h> instead of <Windows.h>.NAKAMURA Takumi2015-06-161-1/+1
| | | | llvm-svn: 239804
* Use 'override/final' instead of 'virtual' for overridden methodsAlexander Kornienko2015-04-111-4/+2
| | | | | | | | | | | | | | The patch is generated using clang-tidy misc-use-override check. This command was used: tools/clang/tools/extra/clang-tidy/tool/run-clang-tidy.py \ -checks='-*,misc-use-override' -header-filter='llvm|clang' \ -j=32 -fix -format http://reviews.llvm.org/D8925 llvm-svn: 234679
* Don't treat .foo as two path components in path::iteratorsBen Langmuir2015-03-101-0/+43
| | | | | | | We were treating '/.foo' as ['/', '.', 'foo'] instead of ['/', '.foo'], which lead to insanity. Same for '..'. llvm-svn: 231727
* Object: Handle Mach-O kext bundle filesJustin Bogner2015-02-251-0/+2
| | | | | | This particular subtype of Mach-O was missing. Add it. llvm-svn: 230567
* Move the resize file feature from mapped_file_region to the only user.Rafael Espindola2014-12-121-3/+6
| | | | | | This removes a duplicated stat on every file that llvm-ar looks at. llvm-svn: 224138
* Pass a FD to resise_file and add a testcase.Rafael Espindola2014-12-121-0/+10
| | | | | | I will add a real use in another commit. llvm-svn: 224136
* Remove a convoluted way of calling close by moving the call to the only caller.Rafael Espindola2014-12-111-12/+3
| | | | | | As a bonus we can actually check the return value. llvm-svn: 224046
* Remove dead code. NFC.Rafael Espindola2014-12-111-10/+7
| | | | llvm-svn: 224029
* Fixing some sign comparison warnings from MSVC; NFC.Aaron Ballman2014-11-131-3/+3
| | | | llvm-svn: 221887
* Drop a few unneeded ctor calls (missed code review comment).Paul Robinson2014-11-131-4/+4
| | | | llvm-svn: 221845
* Improve long path name support on Windows.Paul Robinson2014-11-131-2/+59
| | | | | | | | | | Windows normally limits the length of an absolute path name to 260 characters; directories can have lower limits. These limits increase to about 32K if you use absolute paths with the special '\\?\' prefix. Teach Support\Windows\Path.inc to use that prefix as needed. TODO: Other parts of Support could also learn to use this prefix. llvm-svn: 221841
* Fix identify_magic() with mach-o stub dylibs.Nick Kledzik2014-09-171-0/+3
| | | | | | The wrong value was returned and the unittest did not cover the stub dylib case. llvm-svn: 217933
* Support: Use llvm::COFF::BigObjMagicRui Ueyama2014-09-111-1/+1
| | | | | | | Use llvm::COFF::BigObjMagic insetad of the string literal. Also checks the version number. llvm-svn: 217633
* Support: improve identify_magic to recognize COFF bigobjRui Ueyama2014-09-111-0/+3
| | | | | | | identify_magic recognized a COFF bigobj as an import library file. This patch fixes that. llvm-svn: 217627
* Misc cleanups to the FileSytem api.Rafael Espindola2014-09-111-5/+4
| | | | | | | | | | | | | | | | The main difference is the removal of std::error_code exists(const Twine &path, bool &result); It was an horribly redundant interface since a file not existing is also a valid error_code. Now we have an access function that returns just an error_code. This is the only function that has to be implemented for Unix and Windows. The functions can_write, exists and can_execute an now just wrappers. One still has to be very careful using these function to avoid introducing race conditions (Time of check to time of use). llvm-svn: 217625
* Use simpler version of sys::fs::exists. NFC.Rafael Espindola2014-09-111-3/+2
| | | | llvm-svn: 217618
* Fix Path unittests on Windows after raw_fd_ostream changesReid Kleckner2014-08-261-7/+7
| | | | llvm-svn: 216422
* Modernize raw_fd_ostream's constructor a bit.Rafael Espindola2014-08-251-6/+6
| | | | | | | | | | Take a StringRef instead of a "const char *". Take a "std::error_code &" instead of a "std::string &" for error. A create static method would be even better, but this patch is already a bit too big. llvm-svn: 216393
* Fix expected windows result.Rafael Espindola2014-08-091-1/+1
| | | | llvm-svn: 215267
* Remove dead code. Fixes pr20544.Rafael Espindola2014-08-081-6/+6
| | | | llvm-svn: 215243
* Path: Stop claiming path::const_iterator is bidirectionalJustin Bogner2014-08-041-3/+3
| | | | | | | | | | | | | | | | | | | | | | path::const_iterator claims that it's a bidirectional iterator, but it doesn't satisfy all of the contracts for a bidirectional iterator. For example, n3376 24.2.5 p6 says "If a and b are both dereferenceable, then a == b if and only if *a and *b are bound to the same object", but this doesn't work with how we stash and recreate Components. This means that our use of reverse_iterator on this type is invalid and leads to many of the valgrind errors we're hitting, as explained by Tilmann Scheller here: http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20140728/228654.html Instead, we admit that path::const_iterator is only an input_iterator, and implement a second input_iterator for path::reverse_iterator (by changing const_iterator::operator-- to reverse_iterator::operator++). All of the uses of this just traverse once over the path in one direction or the other anyway. llvm-svn: 214737
* unittests: Actually test reverse iterators in Path testsJustin Bogner2014-07-161-5/+5
| | | | | | | | | | | | | | | | | | | | This re-enables some #if 0'd code (since 2010) in the Path unittests and makes at least a weak effort at testing sys::path's rbegin/rend. This change was inspired by some test failures near uses of rbegin and rend here: http://lab.llvm.org:8011/builders/clang-x86_64-linux-vg/builds/3209 The "valgrind was whining" comment looked promising in terms of a simpler to debug case of the same errors. However, it appears that the valgrind complaints the comment was referring to are distinct from the ones in the frontend, since this updated test isn't complaining for me under valgrind. In any case, the disabled tests weren't helping anybody. llvm-svn: 213125
* These should be EXPECT_TRUE, not EXPECT_FALSE. Amends r212415.Aaron Ballman2014-07-061-2/+2
| | | | llvm-svn: 212419
* Fixing compile errors related to changes with MemoryBuffer::getFile.Aaron Ballman2014-07-061-6/+6
| | | | llvm-svn: 212415
* Finishing touch for the std::error_code transition.Rafael Espindola2014-06-131-4/+5
| | | | | | | | | | | While std::error_code itself seems to work OK in all platforms, there are few annoying differences with regards to the std::errc enumeration. This patch adds a simple llvm enumeration, which will hopefully avoid build breakages in other platforms and surprises as we get more uses of std::error_code. llvm-svn: 210920
* Remove the last uses of 'using std::error_code'Rafael Espindola2014-06-131-14/+14
| | | | | | This finishes the transition to std::error_code. llvm-svn: 210877
* Don't use 'using std::error_code' in include/llvm.Rafael Espindola2014-06-121-0/+1
| | | | | | This should make sure that most new uses use the std prefix. llvm-svn: 210835
* Remove unused has_magic.Rafael Espindola2014-06-111-3/+0
| | | | | | | This will allow inlining get_magic, which should in turn fix one of the mingw build problems after the switch to std::error_code. llvm-svn: 210712
* Use std::error_code instead of llvm::error_code.Rafael Espindola2014-06-111-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The idea of this patch is to turn llvm/Support/system_error.h into a transitional header that just brings in the erorr_code api to the llvm namespace. I will remove it shortly afterwards. The cases where the general idea needed some tweaking: * std::errc is a namespace in msvc, so we cannot use "using std::errc". I could add an #ifdef, but there were not that many uses, so I just added std:: to them in this patch. * Template specialization had to be moved to the std namespace in this patch set already. * The msvc implementation of default_error_condition doesn't seem to provide the same transformations as we need. Not too surprising since the standard doesn't actually say what "equivalent" means. I fixed the problem by keeping our old mapping and using it at error_code construction time. Despite these shortcomings I think this is still a good thing. Some reasons: * The different implementations of system_error might improve over time. * It removes 925 lines of code from llvm already. * It removes 6313 bytes from the text segment of the clang binary when it is built with gcc and 2816 bytes when building with clang and libstdc++. llvm-svn: 210687
* Remove windows_error.Rafael Espindola2014-06-111-1/+5
| | | | | | | | | | MSVC doesn't seem to provide any is_error_code_enum enumeration for the windows errors. Fortunately very few places in llvm have to handle raw windows errors, so we can just construct the corresponding error_code directly. llvm-svn: 210631
* support: add a utility function to normalise path separatorsSaleem Abdulrasool2014-03-111-0/+37
| | | | | | | | Add a utility function to convert the Windows path separator to Unix style path separators. This is used by a subsequent change in clang to enable the use of Windows SDK headers on Linux. llvm-svn: 203611
* Cleanup the interface for creating soft or hard links.Rafael Espindola2014-03-111-2/+2
| | | | | | | | | | | | Before this patch the unix code for creating hardlinks was unused. The code for creating symbolic links was implemented in lib/Support/LockFileManager.cpp and the code for creating hard links in lib/Support/*/Path.inc. The only use we have for these is in LockFileManager.cpp and it can use both soft and hard links. Just have a create_link function that creates one or the other depending on the platform. llvm-svn: 203596
* Replace OwningPtr<T> with std::unique_ptr<T>.Ahmed Charles2014-03-061-2/+2
| | | | | | | | | | This compiles with no changes to clang/lld/lldb with MSVC and includes overloads to various functions which are used by those projects and llvm which have OwningPtr's as parameters. This should allow out of tree projects some time to move. There are also no changes to libs/Target, which should help out of tree targets have time to move, if necessary. llvm-svn: 203083
* Fix an inconsistency in treatment of trailing / in path::const_iteratorBen Langmuir2014-03-051-0/+29
| | | | | | | | | When using a //net/ path, we were transforming the trailing / into a '.' when the path was just the root path and we were iterating backwards. Forwards iteration and other kinds of root path (C:\, /) were already correct. llvm-svn: 202999
* [C++11] Switch all uses of the llvm_move macro to use std::moveChandler Carruth2014-03-021-1/+1
| | | | | | directly, and remove the macro. llvm-svn: 202612
* [C++11] Remove uses of LLVM_HAS_RVALUE_REFERENCES from the unittests.Chandler Carruth2014-03-011-2/+0
| | | | llvm-svn: 202583
* Replace the F_Binary flag with a F_Text one.Rafael Espindola2014-02-241-3/+3
| | | | | | | | | After this I will set the default back to F_None. The advantage is that before this patch forgetting to set F_Binary would corrupt a file on windows. Forgetting to set F_Text produces one that cannot be read in notepad, which is a better failure mode :-) llvm-svn: 202052
* Fix windows unittest I missed in the raw_fd_ostream constructor change.Rafael Espindola2014-02-241-1/+1
| | | | llvm-svn: 202050
* Simplify remove, create_directory and create_directories.Rafael Espindola2014-02-231-17/+24
| | | | | | | | | | | | | | | Before this patch they would take an boolean argument to say if the path already existed. This was redundant with the returned error_code which is able to represent that. This allowed for callers to incorrectly check only the existed flag instead of first checking the error code. Instead, pass in a boolean flag to say if the previous (non-)existence should be an error or not. Callers of the of the old simple versions are not affected. They still ignore the previous (non-)existence as they did before. llvm-svn: 201979
* Introduce llvm::sys::path::home_directory.Peter Collingbourne2014-01-311-0/+13
| | | | | | | | | This will be used by the line editor library to derive a default path to the history file. Differential Revision: http://llvm-reviews.chandlerc.com/D2199 llvm-svn: 200594
OpenPOWER on IntegriCloud