summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/Path.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Purge unused includes throughout libSupport.Benjamin Kramer2015-03-231-2/+0
| | | | | | NFC. llvm-svn: 232976
* Don't treat .foo as two path components in path::iteratorsBen Langmuir2015-03-101-7/+0
| | | | | | | We were treating '/.foo' as ['/', '.', 'foo'] instead of ['/', '.foo'], which lead to insanity. Same for '..'. llvm-svn: 231727
* Use read{16,32,64}{le,be}() instead of ↵Rui Ueyama2015-03-021-3/+3
| | | | | | *reinterpret_cast<u{little,big}{16,32,64}_t>(). llvm-svn: 231016
* Object: Handle Mach-O kext bundle filesJustin Bogner2015-02-251-0/+1
| | | | | | This particular subtype of Mach-O was missing. Add it. llvm-svn: 230567
* Revert "Change Path::filename_pos() to skip the drive letter."Zachary Turner2015-02-121-5/+2
| | | | | | | | This reverts commit 228874. For some reason users reported seeing Clang taking up 25+GB of memory and bringing down machines with this change. Reverting until we figure it out. llvm-svn: 228890
* Change Path::filename_pos() to skip the drive letter.Zachary Turner2015-02-111-2/+5
| | | | | | | | | For Windows, filename_pos() tries to find the filename by searching for separators after the last :. Instead, it should really check for the only location that a : is valid, which is in the second character, and search for separators after that. llvm-svn: 228874
* [Object][ELF] Test unknown type.Michael J. Spencer2015-01-231-1/+1
| | | | llvm-svn: 226943
* [cleanup] Re-sort all the #include lines in LLVM usingChandler Carruth2015-01-141-1/+1
| | | | | | | | | | | utils/sort_includes.py. I clearly haven't done this in a while, so more changed than usual. This even uncovered a missing include from the InstrProf library that I've added. No functionality changed here, just mechanical cleanup of the include order. llvm-svn: 225974
* Add missing implementation of 'sys::path::is_other' to the support library.Juergen Ributzka2014-12-181-0/+8
| | | | | | | The header claims that this function exists, but the linker wasn't too happy about it not being in the library. llvm-svn: 224527
* Support ELF files of unknown type.Michael J. Spencer2014-11-181-0/+3
| | | | llvm-svn: 222208
* llvm-readobj: Add support for dumping the DOS header in PE filesDavid Majnemer2014-11-051-3/+4
| | | | llvm-svn: 221333
* Fix identify_magic() with mach-o stub dylibs.Nick Kledzik2014-09-171-1/+1
| | | | | | 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-7/+15
| | | | | | | 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-3/+9
| | | | | | | 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/+5
| | | | | | | | | | | | | | | | 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
* Fix some cases where StringRef was being passed by const reference. Remove ↵Craig Topper2014-08-301-9/+9
| | | | | | const from some other StringRefs since its implicitly const already. llvm-svn: 216820
* Merge TempDir and system_temp_directory.Rafael Espindola2014-08-261-57/+1
| | | | | | | | | We had two functions for finding the temp or cache directory. Each had a different set of smarts about OS specific APIs. With this patch system_temp_directory becomes the only way to do it. llvm-svn: 216460
* Revert "Support/Path: remove raw delete"Dylan Noblesmith2014-08-261-2/+2
| | | | | | This reverts commit r216360. llvm-svn: 216428
* Support/Path: remove raw deleteDylan Noblesmith2014-08-251-2/+2
| | | | llvm-svn: 216360
* Fix the windows build.Rafael Espindola2014-08-081-1/+1
| | | | | | Sorry for the noise. llvm-svn: 215249
* Convert from Windows to Unix paths in sys::path::native.Rafael Espindola2014-08-081-1/+11
| | | | | | Part of pr20544. Test to follow in a second. llvm-svn: 215241
* Path: Stop claiming path::const_iterator is bidirectionalJustin Bogner2014-08-041-12/+27
| | | | | | | | | | | | | | | | | | | | | | 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
* Don't leak a file descriptor.Rafael Espindola2014-06-251-1/+1
| | | | llvm-svn: 211699
* Code cleanup.Logan Chien2014-06-251-1/+1
| | | | llvm-svn: 211697
* Support: Add llvm::sys::fs::copy_fileJustin Bogner2014-06-191-0/+34
| | | | | | A function to copy one file's contents to another. llvm-svn: 211302
* Finishing touch for the std::error_code transition.Rafael Espindola2014-06-131-3/+4
| | | | | | | | | | | 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 'using std::errro_code' from lib.Rafael Espindola2014-06-131-53/+53
| | | | llvm-svn: 210871
* 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
* Don't put generic_category in the llvm namespace.Rafael Espindola2014-06-121-1/+1
| | | | llvm-svn: 210737
* Implement get_magic with generic tools and inline it.Rafael Espindola2014-06-111-6/+10
| | | | llvm-svn: 210716
* Remove unused has_magic.Rafael Espindola2014-06-111-18/+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-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Use error_code() instead of error_code::succes()Rafael Espindola2014-05-311-13/+13
| | | | | | | There is no std::error_code::success, so this removes much of the noise in transitioning to std::error_code. llvm-svn: 209952
* Fix hardcoded slash to native path seperator which was exposed from ↵Yaron Keren2014-05-161-0/+6
| | | | | | | | llvm::sys::path. http://reviews.llvm.org/D3687 llvm-svn: 208980
* [C++11] Make use of 'nullptr' in the Support library.Craig Topper2014-04-071-1/+1
| | | | llvm-svn: 205697
* Remove dead and incorrect code.Rafael Espindola2014-03-201-14/+1
| | | | | | is_symlink was always false since it was using stat instead of lstat. llvm-svn: 204361
* Support: add support to identify WinCOFF/ARM objectsSaleem Abdulrasool2014-03-131-0/+1
| | | | | | | Add the Windows COFF ARM object file magic. This enables the LLVM tools to interact with COFF object files for Windows on ARM. llvm-svn: 203761
* Fix an inconsistency in treatment of trailing / in path::const_iteratorBen Langmuir2014-03-051-8/+5
| | | | | | | | | 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
* 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
* Share a createUniqueEntity implementation between unix and windows.Rafael Espindola2014-02-241-4/+71
| | | | | | | The only extra bit of functionality that had to be exposed for this be be implemented in Path.cpp is opening a file in rw mode. llvm-svn: 202005
* Simplify remove, create_directory and create_directories.Rafael Espindola2014-02-231-3/+3
| | | | | | | | | | | | | | | 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
* Use mkdir instead of stat+mkdir.Rafael Espindola2014-02-131-11/+18
| | | | | | | | | | | | | This is an optimistic version of create_diretories: it tries to create the directory first and looks at the parent only if that fails. Running strace on "mkdir -p" shows that it is pessimistic, calling mkdir on every element of the path. We could implement that if needed. In any case, with both strategies there is no reason to call stat, just check the return of mkdir. llvm-svn: 201347
* _CS_DARWIN_USER macros available on darwin>=9. Thanks, Dave Odell!David Fang2014-02-121-1/+2
| | | | llvm-svn: 201255
* Using the helper API for random number generation.Aaron Ballman2014-02-111-0/+1
| | | | llvm-svn: 201125
* Fix known typosAlp Toker2014-01-241-3/+3
| | | | | | | Sweep the codebase for common typos. Includes some changes to visible function names that were misspelt. llvm-svn: 200018
* Remove remove_all. A compiler has no need for recursively deleting a directory.Rafael Espindola2014-01-101-39/+0
| | | | llvm-svn: 198955
* Path: Recognize COFF import library file magic.Rui Ueyama2013-11-151-0/+4
| | | | | | | | | | | | Summary: Make identify_magic to recognize COFF import file. Reviewers: Bigcheese CC: llvm-commits Differential Revision: http://llvm-reviews.chandlerc.com/D2165 llvm-svn: 194852
* Recognize 0x0000 as a COFF file magic.Rui Ueyama2013-11-141-0/+3
| | | | | | | | | | | | | | | Summary: Some machine-type-neutral object files containing only undefined symbols actually do exist in the Windows standard library. Need to recognize them as COFF files. Reviewers: Bigcheese CC: llvm-commits Differential Revision: http://llvm-reviews.chandlerc.com/D2164 llvm-svn: 194734
* Fix a bug in Windows resource file detection.Rui Ueyama2013-10-161-1/+1
| | | | | | The magic bytes should not include the trailing NUL byte. llvm-svn: 192769
* Path: Recognize Windows compiled resource file.Rui Ueyama2013-10-151-0/+8
| | | | | | | | | | | | | | Some background: One can pass compiled resource files (.res files) directly to the linker on Windows. If a resource file is given, the linker will run "cvtres" command in background to convert the resource file to a COFF file to link it. What I'm trying to do with this patch is to make the linker to recognize the resource file by file magic, so that it can run cvtres command. Differential Revision: http://llvm-reviews.chandlerc.com/D1943 llvm-svn: 192742
OpenPOWER on IntegriCloud