1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 19:12:56 +02:00
Commit Graph

60 Commits

Author SHA1 Message Date
Rafael Espindola
c86cc04638 Use error_code() instead of error_code::succes()
There is no std::error_code::success, so this removes much of the noise
in transitioning to std::error_code.

llvm-svn: 209952
2014-05-31 01:37:45 +00:00
Yaron Keren
a414154d8e Fix hardcoded slash to native path seperator which was exposed from llvm::sys::path.
http://reviews.llvm.org/D3687

llvm-svn: 208980
2014-05-16 13:16:30 +00:00
Craig Topper
ee78063a54 [C++11] Make use of 'nullptr' in the Support library.
llvm-svn: 205697
2014-04-07 04:17:22 +00:00
Rafael Espindola
27241df819 Remove dead and incorrect code.
is_symlink was always false since it was using stat instead of lstat.

llvm-svn: 204361
2014-03-20 17:39:04 +00:00
Saleem Abdulrasool
e1749d42be Support: add support to identify WinCOFF/ARM objects
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
2014-03-13 07:02:35 +00:00
Ben Langmuir
e1c9edcf79 Fix an inconsistency in treatment of trailing / in path::const_iterator
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
2014-03-05 19:56:30 +00:00
Rafael Espindola
d89ca7eab7 Replace the F_Binary flag with a F_Text one.
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
2014-02-24 18:20:12 +00:00
Rafael Espindola
02877b8373 Share a createUniqueEntity implementation between unix and windows.
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
2014-02-24 03:07:41 +00:00
Rafael Espindola
65a11242a7 Simplify remove, create_directory and create_directories.
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
2014-02-23 13:56:14 +00:00
Rafael Espindola
83453b6625 Use mkdir instead of stat+mkdir.
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
2014-02-13 16:58:19 +00:00
David Fang
c12b9865cd _CS_DARWIN_USER macros available on darwin>=9. Thanks, Dave Odell!
llvm-svn: 201255
2014-02-12 21:02:12 +00:00
Aaron Ballman
142f8478ea Using the helper API for random number generation.
llvm-svn: 201125
2014-02-11 03:40:14 +00:00
Alp Toker
1c4b33e8e5 Fix known typos
Sweep the codebase for common typos. Includes some changes to visible function
names that were misspelt.

llvm-svn: 200018
2014-01-24 17:20:08 +00:00
Rafael Espindola
7c8a2f4a58 Remove remove_all. A compiler has no need for recursively deleting a directory.
llvm-svn: 198955
2014-01-10 20:36:42 +00:00
Rui Ueyama
30dec160ae Path: Recognize COFF import library file magic.
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
2013-11-15 21:22:02 +00:00
Rui Ueyama
caa74a04ef Recognize 0x0000 as a COFF file magic.
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
2013-11-14 22:09:08 +00:00
Rui Ueyama
f2a2b72f46 Fix a bug in Windows resource file detection.
The magic bytes should not include the trailing NUL byte.

llvm-svn: 192769
2013-10-16 03:29:49 +00:00
Rui Ueyama
a0789cb92a Path: Recognize Windows compiled resource file.
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
2013-10-15 22:45:38 +00:00
Benjamin Kramer
10412fd112 Path: Add an in-place version of path::native.
This reflects the common use case of nativizing a prepared path. The existing
version invokes undefined behavior if input = output, add an assert to catch
that case.

llvm-svn: 190510
2013-09-11 10:45:21 +00:00
Tareq A. Siraj
135d71f85d Fixes a bug when iterating on paths
This fixes the incorrect implementation of iterating on file/directory
paths.

Differential Review: http://llvm-reviews.chandlerc.com/D1277

llvm-svn: 188183
2013-08-12 17:10:49 +00:00
Rafael Espindola
2bf7932f99 Include st_dev to make the result of getUniqueID actually unique.
This will let us use getUniqueID instead of st_dev directly on clang.

llvm-svn: 187378
2013-07-29 21:26:49 +00:00
Rafael Espindola
28c7549697 Don't end a file name with a dot. It looks odd.
llvm-svn: 187124
2013-07-25 15:00:17 +00:00
Rafael Espindola
f40c5de45c Split openFileForWrite into windows and unix versions.
It is similar to 186511, but for creating files for writing.

llvm-svn: 186679
2013-07-19 15:02:03 +00:00
Rafael Espindola
a045716bb8 Split openFileForRead into Windows and Unix versions.
This has some advantages:

* Lets us use native, utf16 windows functions.
* Easy to produce good errors on windows about trying to use a
directory when we want a file.
* Simplifies the unix version a bit.

llvm-svn: 186511
2013-07-17 14:58:25 +00:00
Rafael Espindola
2a9326a78f Add a wrapper for open.
This centralizes the handling of O_BINARY and opens the way for hiding more
differences (like how open behaves with directories).

llvm-svn: 186447
2013-07-16 19:44:17 +00:00
Rafael Espindola
5d9e1a875f Remove unique_file now that it is unused.
llvm-svn: 185728
2013-07-05 21:19:35 +00:00
Rafael Espindola
66da97e093 Add a createUniqueFile function and switch llvm's users of unique_file.
This function is complementary to createTemporaryFile. It handles the case were
the unique file is *not* temporary: we will rename it in the end. Since we
will rename it, the file has to be in the same filesystem as the final
destination and we don't prepend the system temporary directory.

This has a small semantic difference from unique_file: the default mode is 0666.
This matches the behavior of most unix tools. For example, with this change
lld now produces files with the same permissions as ld. I will add a test
of this change when I port clang over to createUniqueFile (next commit).

llvm-svn: 185726
2013-07-05 21:01:08 +00:00
Rafael Espindola
b874aa69e3 Add a higher level createTemporaryFile function.
This function is inspired by clang's Driver::GetTemporaryPath. It hides the
pattern used for uniquing and requires simple file names that are always
placed in the system temporary directory.

llvm-svn: 185716
2013-07-05 19:56:49 +00:00
Rafael Espindola
2da320119c Improve comment.
llvm-svn: 185141
2013-06-28 10:55:41 +00:00
Rafael Espindola
8eae838533 Improvements to unique_file and createUniqueDirectory.
* Don't try to create parent directories in unique_file. It had two problem:
   * It violates the contract that it is atomic. If the directory creation
     success and the file creation fails, we would return an error but the
     file system was modified.
   * When creating a temporary file clang would have to first check if the
     parent directory existed or not to avoid creating one when it was not
     supposed to.

* More efficient implementations of createUniqueDirectory and the unique_file
  that produces only the file name. Now all 3 just call into a static
  function passing what they want (name, file or directory).

Clang also has to be updated, so tests might fail if a bot picks up this commit
and not the corresponding clang one.

llvm-svn: 185126
2013-06-28 03:48:47 +00:00
Rafael Espindola
4cfcd31f11 Don't ask for a mode when we are not keeping the file.
llvm-svn: 185123
2013-06-28 01:05:47 +00:00
Rafael Espindola
ac62522b9b Add a convenience createUniqueDirectory function.
There are a few valid situation where we care about the structure inside a
directory, but not about the directory itself. A simple example is for unit
testing directory traversal.

PathV1 had a function like this, add one to V2 and port existing users of the
created temp file and delete it hack to using it.

llvm-svn: 185059
2013-06-27 03:45:31 +00:00
Rafael Espindola
9edd4f6c46 Rename PathV2 to just Path now that it is the only one.
llvm-svn: 185015
2013-06-26 19:33:03 +00:00
Rafael Espindola
dc28d9e2d2 PathV1 is deprecated since the 18th of Dec 2010. Remove it.
llvm-svn: 184960
2013-06-26 16:24:35 +00:00
Rafael Espindola
24a81dcac4 Remove Path::isObjectFile.
llvm-svn: 184305
2013-06-19 14:25:38 +00:00
Rafael Espindola
7690460b6c Inline Path::isBitcodeFile into only use and remove it.
llvm-svn: 183840
2013-06-12 15:13:57 +00:00
Rafael Espindola
21dc9d4207 Remove Path::hasMagicNumber.
llvm-svn: 183838
2013-06-12 15:04:59 +00:00
Rafael Espindola
968c6bbebf Include PathV1.h in files that use it.
This is preparation for replacing Path.h with PathV2.h.

llvm-svn: 183782
2013-06-11 20:00:56 +00:00
Rafael Espindola
993b0c88c5 Remove Path::getDirname.
llvm-svn: 183780
2013-06-11 19:32:57 +00:00
Rafael Espindola
cd1368e1db Remove GetDLLSuffix.
llvm-svn: 183777
2013-06-11 19:18:05 +00:00
Rafael Espindola
30fee8bd79 Remove GetSystemLibraryPaths.
llvm-svn: 183770
2013-06-11 18:58:47 +00:00
Rafael Espindola
c5d8c2560a Remove unused FindLibrary function.
llvm-svn: 183764
2013-06-11 18:41:07 +00:00
Rafael Espindola
d506a5e174 Remove sys::identifyFileType.
llvm-svn: 183763
2013-06-11 18:18:02 +00:00
Rafael Espindola
64def1c6ed Pass a StringRef to sys::identifyFileType.
llvm-svn: 183669
2013-06-10 15:27:39 +00:00
Rafael Espindola
7f956c6000 Fix an out of bounds array access.
We were looking at Magic[5] without checking Length. Since this path would not
return unless Length >= 18 anyway, just move the >= 18 check up.

llvm-svn: 183666
2013-06-10 15:22:18 +00:00
Rafael Espindola
3db8a7c316 Update for current naming conventions.
I will change identifyFileType to use a StringRef in the next patch.

llvm-svn: 183664
2013-06-10 14:56:16 +00:00
Roman Divacky
a299a2efa5 Remove duplicate includes.
llvm-svn: 170902
2012-12-21 17:06:44 +00:00
Chandler Carruth
a490793037 Use the new script to sort the includes of every file under lib.
Sooooo many of these had incorrect or strange main module includes.
I have manually inspected all of these, and fixed the main module
include to be the nearest plausible thing I could find. If you own or
care about any of these source files, I encourage you to take some time
and check that these edits were sensible. I can't have broken anything
(I strictly added headers, and reordered them, never removed), but they
may not be the headers you'd really like to identify as containing the
API being implemented.

Many forward declarations and missing includes were added to a header
files to allow them to parse cleanly when included first. The main
module rule does in fact have its merits. =]

llvm-svn: 169131
2012-12-03 16:50:05 +00:00
Meador Inge
b8cf9886db PR13013: ELF Type identification fails for MSB type ELF files.
Fix 'sys::IdentifyFileType' to work with big and little endian byte orderings
when reading the ELF object file type.

Initial patch by Stefan Hepp.

llvm-svn: 159138
2012-06-25 14:48:43 +00:00
Michael J. Spencer
5cf93fd736 Support/FileSystem: Add file_magic and move a vew clients over to it.
llvm-svn: 146523
2011-12-13 23:17:12 +00:00