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

697 Commits

Author SHA1 Message Date
Taewook Oh
0442d2071f In openFileForRead, attempt to fetch the actual name of the file on disk -- including case -- so that clang can later warn about non-portable #include and #import directives.
Differential Revision: http://reviews.llvm.org/D19842

Patch by Eric Niebler

llvm-svn: 271704
2016-06-03 18:38:39 +00:00
Dylan McKay
bc118e3e83 Add tests to Support/MathExtras
In r271380, I added several functions to get the minimum/maximum values
of n-width integers.

This just adds tests for them.

llvm-svn: 271505
2016-06-02 09:00:53 +00:00
Lang Hames
ddc9000626 [Support] Rename unconvertibleErrorCode to inconvertibleErrorCode.
Based on a totally scientific, 30 second google search "in-" appears to be the
preferred prefix.

llvm-svn: 270950
2016-05-27 01:54:25 +00:00
Lang Hames
776aaf18f4 [Support] Add a StringError convenience class to Error.h
StringError can be used to represent Errors that aren't recoverable based on
the error type, but that have a useful error message that can be reported to
the user or logged.

llvm-svn: 270948
2016-05-27 01:37:32 +00:00
Teresa Johnson
8a51792cf4 [ThinLTO] Option to control path of distributed backend files
Summary:
Add support to control where files for a distributed backend (the
individual index files and optional imports files) are created.

This is invoked with a new thinlto-prefix-replace option in the gold
plugin and llvm-lto. If specified, expects a string of the form
"oldprefix:newprefix", and instead of generating these files in the
same directory path as the corresponding bitcode file, will use a path
formed by replacing the bitcode file's path prefix matching oldprefix
with newprefix.

Also add a new replace_path_prefix helper to Path.h in libSupport.

Depends on D19636.

Reviewers: joker.eph

Subscribers: llvm-commits, joker.eph

Differential Revision: http://reviews.llvm.org/D19644

llvm-svn: 269771
2016-05-17 14:45:30 +00:00
Bruno Cardoso Lopes
8b294ba100 [Support][Unittests] Add unittest for recursive_directory_iterator::level()
llvm-svn: 269488
2016-05-13 21:31:32 +00:00
Vedant Kumar
a650a4c26e [Support] Add a free toString function for Error
toString() consumes an Error and returns a string representation of its
contents. This commit also adds a message() method to ErrorInfoBase for
convenience.

Differential Revision: http://reviews.llvm.org/D19883

llvm-svn: 268465
2016-05-03 23:32:31 +00:00
Nico Weber
635064e42f Use gcc's rules for parsing gcc-style response files
In gcc, \ escapes every character in response files. It is true that this makes
it harder to mention Windows files in rsp files, but not doing this means clang
disagrees with gcc, and also disagrees with the shell (on non-Windows) which
rsp file quoting is supposed to match. clang isn't free to choose what to do
here.

In general, the idea for response files is to take bits of your command line
and write them to a file unchanged, and have things work the same way. Since
the command line would've been interpreted by the shell, things in the rsp file
need to be subject to the same shell quoting rules.

People who want to put Windows-style paths in their response files either need
to do any of:
* escape their backslashes
* or use clang-cl which uses cl.exe/cmd.exe quoting rules
* pass --rsp-quoting=windows to clang to tell it to use
  cl.exe/cmd.exe quoting rules for response files.

Fixes PR27464.
http://reviews.llvm.org/D19417

llvm-svn: 267556
2016-04-26 13:53:56 +00:00
Lang Hames
ed38574ae4 [Support] Fix latent bugs in Expected and ExitOnError that were preventing them
from working with reference types.

llvm-svn: 267448
2016-04-25 19:21:57 +00:00
Nico Weber
992481bdd0 Unbreak building unit tests on Windows after r266595.
llvm-svn: 266614
2016-04-18 13:54:50 +00:00
Mehdi Amini
9ff867f98c [NFC] Header cleanup
Removed some unused headers, replaced some headers with forward class declarations.

Found using simple scripts like this one:
clear && ack --cpp -l '#include "llvm/ADT/IndexedMap.h"' | xargs grep -L 'IndexedMap[<]' | xargs grep -n --color=auto 'IndexedMap'

Patch by Eugene Kosov <claprix@yandex.ru>

Differential Revision: http://reviews.llvm.org/D19219

From: Mehdi Amini <mehdi.amini@apple.com>
llvm-svn: 266595
2016-04-18 09:17:29 +00:00
Duncan P. N. Exon Smith
5f366e4aa0 Revert "Fix Clang-tidy modernize-deprecated-headers warnings in remaining files; other minor fixes."
This reverts commit r265454 since it broke the build.  E.g.:

  http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-incremental_build/22413/

llvm-svn: 265459
2016-04-05 20:45:04 +00:00
Eugene Zelenko
a612bac11f Fix Clang-tidy modernize-deprecated-headers warnings in remaining files; other minor fixes.
Some Include What You Use suggestions were used too.

Use anonymous namespaces in source files.

Differential revision: http://reviews.llvm.org/D18778

llvm-svn: 265454
2016-04-05 20:19:49 +00:00
Lang Hames
9e445cd6a2 [Support] Add a checked flag to Expected<T>, require checks before access or
destruction.

This makes the Expected<T> class behave like Error, even when in success mode.
Expected<T> values must be checked to see whether they contain an error prior
to being dereferenced, assigned to, or destructed.

llvm-svn: 265446
2016-04-05 19:57:03 +00:00
Etienne Bergeron
159be8f3fc [Support] Fix an invalid character escaping in string literal (unittest).
Summary:
A character within a string literal is not escaped correctly.
In this case, there is no semantic change because the invalid character turn out to be NUL anyway.

note: "\0x12" is equivalent to {0, 'x', '1', '2'} and not { 12 }.

This issue was found by clang-tidy.

Reviewers: rnk

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D18747

llvm-svn: 265376
2016-04-05 01:46:26 +00:00
Mehdi Amini
1d8f86057d Add support for computing SHA1 in LLVM
Provide a class to generate a SHA1 from a sequence of bytes, and
a convenience raw_ostream adaptor.
This will be used to provide a "build-id" by hashing the Module
block when writing bitcode. ThinLTO will use this information for
incremental build.

Reapply r265094 which was reverted in r265102 because it broke
MSVC bots (constexpr is not supported).

http://reviews.llvm.org/D16325

From: Mehdi Amini <mehdi.amini@apple.com>
llvm-svn: 265107
2016-04-01 04:30:16 +00:00
Mehdi Amini
b50dad82a8 Revert "Add support for computing SHA1 in LLVM"
This reverts commit r265096, r265095, and r265094.
Windows build is broken, and the validation does not pass.

From: Mehdi Amini <mehdi.amini@apple.com>
llvm-svn: 265102
2016-04-01 03:03:21 +00:00
Mehdi Amini
3a10299c7a Add support for computing SHA1 in LLVM
Provide a class to generate a SHA1 from a sequence of bytes, and
a convenience raw_ostream adaptor.
This will be used to provide a "build-id" by hashing the Module
block when writing bitcode. ThinLTO will use this information for
incremental build.

From: Mehdi Amini <mehdi.amini@apple.com>
llvm-svn: 265094
2016-04-01 01:29:54 +00:00
Duncan P. N. Exon Smith
a6ffc80357 Support: Implement StreamingMemoryObject::getPointer
The implementation is fairly obvious.  This is preparation for using
some blobs in bitcode.

For clarity (and perhaps future-proofing?), I moved the call to
JumpToBit in BitstreamCursor::readRecord ahead of calling
MemoryObject::getPointer, since JumpToBit can theoretically (a) read
bytes, which (b) invalidates the blob pointer.

This isn't strictly necessary the two memory objects we have:

  - The return of RawMemoryObject::getPointer is valid until the memory
    object is destroyed.

  - StreamingMemoryObject::getPointer is valid until the next chunk is
    read from the stream.  Since the JumpToBit call is only going ahead
    to a word boundary, we'll never load another chunk.

However, reordering makes it clear by inspection that the blob returned
by BitstreamCursor::readRecord will be valid.

I added some tests for StreamingMemoryObject::getPointer and
BitstreamCursor::readRecord.

llvm-svn: 264549
2016-03-27 23:00:59 +00:00
Duncan P. N. Exon Smith
7eb2cc2c0b Support: Move StreamingMemoryObject{,Test}.cpp, NFC
Change the filename to indicate this is a test, rename the tests, move
them into an anonymous namespace, and rename some variables.  All to
match our usual style before making further changes.

llvm-svn: 264548
2016-03-27 22:55:19 +00:00
Lang Hames
a11110fd25 [Support] Switch to RAII helper for error-as-out-parameter idiom.
As discussed on the llvm-commits thread for r264467.

llvm-svn: 264479
2016-03-25 23:54:32 +00:00
Lang Hames
6c897febd8 [Support] Add Error::errorForOutParameter helper.
This helper method creates a pre-checked Error suitable for use as an out
parameter in a constructor. This avoids the need to have the constructor
check a known-good error before assigning to it.

llvm-svn: 264467
2016-03-25 21:56:35 +00:00
Reid Kleckner
57ae7f9db2 Try to fix ODR violation of ErrorInfo::ID
This implements my suggestion to Lang.

llvm-svn: 264360
2016-03-24 23:49:34 +00:00
NAKAMURA Takumi
5fba946e7d ErrorTest.cpp: Move instantiations out of anonymous namespace. gcc didn't complain.
llvm-svn: 264297
2016-03-24 15:40:46 +00:00
NAKAMURA Takumi
9a58a11846 Define ErrorInfo::ID explicitly.
llvm-svn: 264293
2016-03-24 15:26:43 +00:00
NAKAMURA Takumi
2d8ab09777 ErrorTest.cpp: Fix an expression, possibly typo.
llvm-svn: 264290
2016-03-24 15:19:22 +00:00
Lang Hames
fc3b132a68 [Support] Add conversions between Expected<T> and ErrorOr<T>.
More utilities to help with std::error_code -> Error transitions.

llvm-svn: 264238
2016-03-24 02:00:10 +00:00
Lang Hames
34b790d0e7 [Support] Make all Errors convertible to std::error_code.
This is a temporary crutch to enable code that currently uses std::error_code
to be incrementally moved over to Error. Requiring all Error instances be
convertible enables clients to call errorToErrorCode on any error (not just
ECErrors created by conversion *from* an error_code).

This patch also moves code for Error from ErrorHandling.cpp into a new
Error.cpp file.

llvm-svn: 264221
2016-03-23 23:57:28 +00:00
Lang Hames
aee22c683f [Support] Refactor Error unit tests to avoid duplicating work.
Suggested by Dave Blaikie in review for r263749. Thanks Dave!

llvm-svn: 263768
2016-03-18 00:12:37 +00:00
Lang Hames
034e76c90d [Support] Add ExitOnError utility to support tools that use the exit-on-error
idiom.

Most LLVM tool code exits immediately when an error is encountered and prints an
error message to stderr. The ExitOnError class supports this by providing two
call operators - one for Errors, and one for Expected<T>s. Calls to code that
can return Errors (or Expected<T>s) can use these calls to bail out on error,
and otherwise continue as if the operation had succeeded. E.g.

Error foo();
Expected<int> bar();

int main(int argc, char *argv[]) {
  ExitOnError ExitOnErr;

  ExitOnErr.setBanner(std::string("Error in ") + argv[0] + ":");

  // Exit if foo returns an error. No need to manually check error return.
  ExitOnErr(foo());

  // Exit if bar returns an error, otherwise unwrap the contained int and
  // continue.
  int X = ExitOnErr(bar());

  // ...

  return 0;
}

llvm-svn: 263749
2016-03-17 21:28:49 +00:00
Lang Hames
ffbf7496e2 [Support] Make Error::isA<T>() works on success values.
llvm-svn: 263745
2016-03-17 20:35:00 +00:00
Lang Hames
99892f21dc [Support] Update Error unit test to remove implementation specific behaviour.
llvm-svn: 263610
2016-03-16 01:20:54 +00:00
Lang Hames
69d7550bd6 [Support] Add the 'Error' class for structured error handling.
This patch introduces the Error classs for lightweight, structured,
recoverable error handling. It includes utilities for creating, manipulating
and handling errors. The scheme is similar to exceptions, in that errors are
described with user-defined types. Unlike exceptions however, errors are
represented as ordinary return types in the API (similar to the way
std::error_code is used).

For usage notes see the LLVM programmer's manual, and the Error.h header.
Usage examples can be found in unittests/Support/ErrorTest.cpp.

Many thanks to David Blaikie, Mehdi Amini, Kevin Enderby and others on the
llvm-dev and llvm-commits lists for lots of discussion and review.

llvm-svn: 263609
2016-03-16 01:02:46 +00:00
NAKAMURA Takumi
ca1eed7aa6 MathExtrasTest.cpp: Use EXPECT_DOUBLE_EQ here, instead of EXPECT_FLOAT_EQ.
llvm-svn: 263508
2016-03-14 23:11:28 +00:00
Marianne Mailhot-Sarrasin
eb1485c31e More UTF string conversion wrappers
Added new string conversion wrappers that convert between `std::string` (of UTF-8 bytes) and `std::wstring`, which is particularly useful for Win32 interop. Also fixed a missing string conversion for `getenv` on Win32, using these new wrappers.
The motivation behind this is to provide the support functions required for LLDB to work properly on Windows with non-ASCII data; however, the functions are not LLDB specific.

Patch by cameron314

Differential Revision: http://reviews.llvm.org/D17549

llvm-svn: 263247
2016-03-11 15:59:32 +00:00
Saleem Abdulrasool
2c4c7d140a unitests: add some ARM TargetParser tests
The ARM TargetParser would construct invalid StringRefs.  This would cause
asserts to trigger.  Add some tests in LLVM to ensure that we dont regress on
this in the future.  Although there is a test for this in clang, this ensures
that the changes would get caught in the same repository.

llvm-svn: 262790
2016-03-06 04:50:55 +00:00
Rafael Espindola
c165498992 Refactor duplicated code for linking with pthread.
llvm-svn: 262344
2016-03-01 15:54:40 +00:00
Chandler Carruth
1895f07cd4 [Support] Add a fancy helper function to get a static name for a type.
This extracts the type name from __PRETTY_FUNCTION__ for compilers that
support it (I've opted Clang, GCC, and ICC into this as I've tested that
they work) and from __FUNCSIG__ which is very similar on MSVC. The
routine falls back gracefully on a stub "UNKNOWN_TYPE" string with
compilers or formats it doesn't understand.

This should be enough for a lot of common cases in LLVM where the real
goal is just to log or print a type name as a debugging aid, and save
a ton of boilerplate in the process. Notably, I'm planning to use this
to remove all the getName() boiler plate from the new pass manager.

The design and implementation is based on a bunch of advice and
discussion with Richard Smith and experimenting with most versions of
Clang and GCC. David Majnemer also provided excellent advice on how best
to do this with MSVC. Richard also checked that ICC does something
reasonable and I'll watch the build bots for other compilers. It'd be
great if someone could contribute logic for xlC and/or other toolchains.

Differential Revision: http://reviews.llvm.org/D17565

llvm-svn: 261819
2016-02-25 03:58:21 +00:00
Reid Kleckner
109dc763a3 Fix a -Wsign-compare in Support Path unittests
llvm-svn: 260418
2016-02-10 19:29:01 +00:00
Reid Kleckner
b554ce57f4 Silence some MSVC warnings about zero extending unsigned to void*
llvm-svn: 260413
2016-02-10 19:11:15 +00:00
Nick Lewycky
6c9fb2428f Use std::forward to make ErrorOr<T> constructible from a value that has a user-defined conversion to T. No functionality change intended.
llvm-svn: 260196
2016-02-09 04:47:58 +00:00
Richard Smith
b4e9da2037 Remove TrailingObjects::operator delete. It's still suffering from
compiler-specific issues. Instead, repeat an 'operator delete' definition in
each derived class that is actually deleted, and give up on the static type
safety of an error when sized delete is accidentally used on a type derived
from TrailingObjects.

llvm-svn: 260190
2016-02-09 02:09:16 +00:00
Richard Smith
2b282a4b56 Re-commit r259942 (reverted in r260053) with a different workaround for the MSVC bug.
This fixes undefined behavior in C++14 due to the size of the object being
deleted being different from sizeof(dynamic type) when it is allocated with
trailing objects.

MSVC seems to have several bugs around using-declarations changing the access
of a member inherited from a base class, so use forwarding functions instead of
using-declarations to make TrailingObjects::operator delete accessible where
desired.

llvm-svn: 260180
2016-02-09 01:03:42 +00:00
Nico Weber
54e14a897a Revert 259942, r259943, r259948.
The Windows bots have been failing for the last two days, with:

FAILED: C:\PROGRA~2\MICROS~1.0\VC\bin\amd64\cl.exe -c LLVMContextImpl.cpp
D:\buildslave\clang-x64-ninja-win7\llvm\lib\IR\LLVMContextImpl.cpp(137) :
    error C2248: 'llvm::TrailingObjects<llvm::AttributeSetImpl,
                                        llvm::IndexAttrPair>::operator delete' :
        cannot access private member declared in class 'llvm::AttributeSetImpl'
    TrailingObjects.h(298) : see declaration of
        'llvm::TrailingObjects<llvm::AttributeSetImpl,
                               llvm::IndexAttrPair>::operator delete'
    AttributeImpl.h(213) : see declaration of 'llvm::AttributeSetImpl'

llvm-svn: 260053
2016-02-07 20:09:18 +00:00
Richard Smith
2127c4d2a2 More workarounds for undefined behavior exposed when compiling in C++14 with
-fsized-deallocation. Disable sized deallocation for all objects derived from
TrailingObjects, as we expect the storage allocated for these objects to be
larger than the size of their dynamic type.

llvm-svn: 259942
2016-02-05 22:32:52 +00:00
Reid Kleckner
0bfde8fac7 [unittests] Move TargetRegistry test from Support to MC
This removes the dependency from SupportTests to all of the LLVM
backends, and makes it link faster.

llvm-svn: 259705
2016-02-03 21:41:24 +00:00
Reid Kleckner
d66cb7f668 Silence -Wsign-conversion issue in ProgramTest.cpp
Unfortunately, ProgramInfo::ProcessId is signed on Unix and unsigned on
Windows, breaking the standard fix of using '0U' in the gtest
expectation.

llvm-svn: 259704
2016-02-03 21:41:12 +00:00
Elena Demikhovsky
532f2e9d69 Fixed compilation issue.
llvm-svn: 259087
2016-01-28 20:36:46 +00:00
Kevin Enderby
1a3115548c Fix identify_magic() to check that a file that starts with MH_MAGIC is
at least as big as the mach header to be identified as a Mach-O file and
make sure smaller files are not identified as a Mach-O files but as
unknown files. Also fix identify_magic() so it looks at all 4 bytes of
the filetype field when determining the type of the Mach-O file.
Then fix the macho-invalid-header test case to check that it is an
unknown file and make sure it does not get the error for
object_error::parse_failed.  And also update the unit tests.

llvm-svn: 258883
2016-01-26 23:43:37 +00:00
Chris Bieneman
1b8d4f74aa Remove autoconf support
Summary:
This patch is provided in preparation for removing autoconf on 1/26. The proposal to remove autoconf on 1/26 was discussed on the llvm-dev thread here: http://lists.llvm.org/pipermail/llvm-dev/2016-January/093875.html

"I felt a great disturbance in the [build system], as if millions of [makefiles] suddenly cried out in terror and were suddenly silenced. I fear something [amazing] has happened."
- Obi Wan Kenobi

Reviewers: chandlerc, grosbach, bob.wilson, tstellarAMD, echristo, whitequark

Subscribers: chfast, simoncook, emaste, jholewinski, tberghammer, jfb, danalbert, srhines, arsenm, dschuff, jyknight, dsanders, joker.eph, llvm-commits

Differential Revision: http://reviews.llvm.org/D16471

llvm-svn: 258861
2016-01-26 21:29:08 +00:00