Commit Graph

69180 Commits

Author SHA1 Message Date
Axel Naumann 19520027da Improve const-correctness.
llvm-svn: 306291
2017-06-26 15:06:40 +00:00
Petar Jovanovic c02bda3c16 [mips] Enable IAS by default for Android 64-bit MIPS target (N64)
IAS is already used for MIPS64 in majority of Android projects.
Android MIPS64 uses N64 ABI. Set IAS as a default now.

Differential Revision: https://reviews.llvm.org/D34514

llvm-svn: 306280
2017-06-26 09:58:01 +00:00
Richard Smith c0de2f2b89 Testcase missed from r306075.
llvm-svn: 306270
2017-06-26 04:41:22 +00:00
Sylvestre Ledru 69f49ce83c clang-format - Also reference the list of style option of clang-format in Libformat
llvm-svn: 306266
2017-06-26 03:19:05 +00:00
Sylvestre Ledru 94a21041e7 Fix a typo
llvm-svn: 306261
2017-06-26 02:45:08 +00:00
Yuka Takahashi a4a87802ed [bash-autocompletion] Delete space after flags which has '=' prefix
Summary:
This is patch for bash completion for clang project.
We don't need space when completing options like "-stdlib=".

Differential Revision: https://reviews.llvm.org/D34594

llvm-svn: 306258
2017-06-26 00:35:36 +00:00
Ed Schouten 4dabea22d3 Add support for Ananas platform
Ananas is a home-brew operating system, mainly for amd64 machines. After
using GCC for quite some time, it has switched to clang and never looked
back - yet, having to manually patch things is annoying, so it'd be much
nicer if this was in the official tree.

More information:

https://github.com/zhmu/ananas/
https://rink.nu/projects/ananas.html

Submitted by:	Rink Springer
Differential Revision:	https://reviews.llvm.org/D32936

llvm-svn: 306239
2017-06-25 08:29:09 +00:00
Vedant Kumar 4b2f8a4b87 Add a warning to a group
Add warn_drv_object_size_disabled_O0 to the invalid command line
argument group. This should fix some bot failures:

  lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/13241/steps/test/logs/stdio

llvm-svn: 306183
2017-06-23 23:34:32 +00:00
Vedant Kumar 7aacb659da [ubsan] Disable the object size check at -O0
This check currently isn't able to diagnose any issues at -O0, not is it
likely to [1]. Disabling the check at -O0 leads to substantial compile
time and binary size savings.

[1] [cfe-dev] Disabling ubsan's object size check at -O0

Differential Revision: https://reviews.llvm.org/D34563

llvm-svn: 306181
2017-06-23 23:15:24 +00:00
Reid Kleckner 33d501f7d1 Revert "[MS] Don't statically initialize dllimport member function pointers"
This reverts commit r306137. It has problems on code like this:

  struct __declspec(dllimport) Foo {
    int a;
    int get_a() { return a; }
  };
  template <int (Foo::*Getter)()> struct HasValue {
    int operator()(Foo *p) { return (p->*Getter)(); }
  };
  int main() {
    Foo f;
    f.a = 3;
    int x = HasValue<&Foo::get_a>()(&f);
  }

llvm-svn: 306175
2017-06-23 22:39:01 +00:00
Vedant Kumar c34d343f15 [ubsan] Improve diagnostics for return value checks (clang)
This patch makes ubsan's nonnull return value diagnostics more precise,
which makes the diagnostics more useful when there are multiple return
statements in a function. Example:

1 |__attribute__((returns_nonnull)) char *foo() {
2 |  if (...) {
3 |    return expr_which_might_evaluate_to_null();
4 |  } else {
5 |    return another_expr_which_might_evaluate_to_null();
6 |  }
7 |} // <- The current diagnostic always points here!

runtime error: Null returned from Line 7, Column 2!
With this patch, the diagnostic would point to either Line 3, Column 5
or Line 5, Column 5.

This is done by emitting source location metadata for each return
statement in a sanitized function. The runtime is passed a pointer to
the appropriate metadata so that it can prepare and deduplicate reports.

Compiler-rt patch (with more tests): https://reviews.llvm.org/D34298

Differential Revision: https://reviews.llvm.org/D34299

llvm-svn: 306163
2017-06-23 21:32:38 +00:00
Vadzim Dambrouski 00b396c0a0 [MSP430] Fix data layout string.
Summary:
Change data layout string so it would be compatible with MSP430 EABI.

Depends on D34561

Reviewers: asl, awygle

Reviewed By: asl

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D34562

llvm-svn: 306161
2017-06-23 21:12:56 +00:00
Erich Keane 4c2fc126c8 Add test for 306149, warn on throw from noexcept
llvm-svn: 306156
2017-06-23 20:30:33 +00:00
Erich Keane 89fe9c269a Emit warning when throw exception in destruct or dealloc functions which has a
(possible implicit) noexcept specifier

Throwing in the destructor is not good (C++11 change try to not allow see below).
 But in reality, those codes are exist.
C++11 [class.dtor]p3:

A declaration of a destructor that does not have an exception-specification is 
implicitly considered to have the same exception specification as an implicit 
declaration.

With this change, the application worked before may now run into runtime 
termination. My goal here is to emit a warning to provide only possible info to 
where the code may need to be changed.

First there is no way, in compile time to identify the “throw” really throw out 
of the function. Things like the call which throw out… To keep this simple, 
when “throw” is seen, checking its enclosing function(only destructor and 
dealloc functions) with noexcept(true) specifier emit warning.

Here is implementation detail:
A new member function CheckCXXThrowInNonThrowingFunc is added for class Sema 
in Sema.h. It is used in the call to both BuildCXXThrow and 
TransformCXXThrowExpr.

The function basic check if the enclosing function with non-throwing noexcept 
specifer, if so emit warning for it.

The example of warning message like:
k1.cpp:18:3: warning: ''~dependent_warn'' has a (possible implicit) non-throwing

    noexcept specifier. Throwing exception may cause termination.
        [-Wthrow-in-dtor]
        throw 1;
        ^

        k1.cpp:43:30: note: in instantiation of member function

        'dependent_warn<noexcept_fun>::~dependent_warn' requested here

        dependent_warn<noexcept_fun> f; // cause warning

Differential Revision: https://reviews.llvm.org/D33333

llvm-svn: 306149
2017-06-23 20:22:19 +00:00
Reid Kleckner 9c980cb502 [MS] Don't statically initialize dllimport member function pointers
We were already applying the same rules to dllimport function pointers.
David Majnemer added that logic back in r211677 to fix PR20130.  We
failed to extend that logic to non-virtual member function pointers,
which are basically function pointers in a struct with some extra
offsets.

Fixes PR33570.

llvm-svn: 306137
2017-06-23 18:29:13 +00:00
Yuka Takahashi 90caa8ff4b [GSoC] Add support for CC1 options.
Summary:
Add value completion support for options which are defined in
CC1Options.td, because we only handled options in Options.td.

Reviewers: ruiu, v.g.vassilev, teemperor

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D34558

llvm-svn: 306127
2017-06-23 17:05:50 +00:00
Peter Collingbourne 8d29223386 Add a ThinLTO cache policy for controlling the maximum cache size in bytes.
This is useful when an upper limit on the cache size needs to be
controlled independently of the amount of the amount of free space.

One use case is a machine with a large number of cache directories
(e.g. a buildbot slave hosting a large number of independent build
jobs). By imposing an upper size limit on each cache directory,
users can more easily estimate the server's capacity.

Differential Revision: https://reviews.llvm.org/D34547

llvm-svn: 306126
2017-06-23 17:05:03 +00:00
Peter Collingbourne 38a02daea4 docs: Add documentation for the ThinLTO cache pruning policy string.
Differential Revision: https://reviews.llvm.org/D34546

llvm-svn: 306125
2017-06-23 16:56:27 +00:00
Saleem Abdulrasool 9ac7181a2c test: fix negative test case
Add missing -### to the driver to ensure that we dont try to run the
actual command.  The host may not support the IAS.  Should fix the SCEI
buildbots.

llvm-svn: 306123
2017-06-23 16:52:49 +00:00
Rui Ueyama 5cb4b35b80 Sort the autocomplete candidates before printing them out.
Currently, autocompleted options are displayed in the same order as we
wrote them in .td files. This patch sort them out in clang so that they
are sorted alphabetically. This should improve usability.

Differential Revision: https://reviews.llvm.org/D34557

llvm-svn: 306116
2017-06-23 15:37:52 +00:00
Saleem Abdulrasool d064e91ece Revert "Revert r305164/5/7."
Restore the `-gz` option to the driver with some minor tweaks to handle
the additional case for `-Wa,--compress-debug-sections`.

This intends to make the compression of the debug information
controllable from the driver.  The following is the behaviour:

  -gz           enable compression (ambiguous for format, will default to zlib-gnu)
  -gz=none      disable compression
  -gz=zlib-gnu  enable compression (deprecated GNU style zlib compression)
  -gz=zlib      enable compression (zlib based compression)

Although -Wa,-compress-debug-sections works, it should be discouraged
when using the driver to invoke the assembler.  However, we permit the
assembler to accept the GNU as style argument --compress-debug-sections
to maintain compatibility.

Note, -gz/-gz= does *NOT* imply -g.  That is, you need to additionally
specific -g for debug information to be generated.

llvm-svn: 306115
2017-06-23 15:34:16 +00:00
Alex Lorenz a2af95a615 Revert r306103: "PR26195: Set correct NestedNameSpecifierLoc for the
dependent initializer"

It caused buildbot failures such as this one:
http://bb.pgr.jp/builders/test-clang-msc-x64-on-i686-linux-RA/builds/3777/steps/test_clang/logs/Clang%20%3A%3A%20Index__ctor-init-source-loc.cpp

llvm-svn: 306111
2017-06-23 15:10:54 +00:00
Alex Lorenz 787d30fe18 PR26195: Set correct NestedNameSpecifierLoc for the dependent initializer
This commit fixes incorrect source positions of dependent c'tor initializers
like in the following code:

template<typename MyBase>
struct Derived: MyBase::InnerIterator
{

Derived() : MyBase::InnerIterator() {} /// This line is problematic: all positions point to InnerIterator and nothing points to MyBase
};

Patch by Serge Preis!

Differential Revision: https://reviews.llvm.org/D32439

llvm-svn: 306103
2017-06-23 14:10:07 +00:00
Krasimir Georgiev ac16a201a6 [clang-format] Add a SortUsingDeclaration option and enable it by default
Summary:
This patch adds a `SortUsingDeclaration` style option and enables it for llvm
style.

Reviewers: klimek

Reviewed By: klimek

Subscribers: klimek

Differential Revision: https://reviews.llvm.org/D34453

llvm-svn: 306094
2017-06-23 11:46:03 +00:00
Krasimir Georgiev 90b4ce38cb [clang-format] Update dump_format_style.py to indent nested fields
Summary:
This updates the format options documentation script to indent the
documentation of nested fields. The previous format caused some problems,
as when a bulleted list ends with a multiline comment. See the buildbot failure
http://lab.llvm.org:8011/builders/clang-sphinx-docs/builds/10020/steps/docs-clang-html/logs/stdio

Reviewers: djasper

Reviewed By: djasper

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D34552

llvm-svn: 306093
2017-06-23 11:29:40 +00:00
Krasimir Georgiev 575b25f2c0 [clang-format] Update style documentation, NFC
Summary: Style documentation is generated automatically by `docs/tools/dump_format_style.py`. This hasn't been ran for a while.

Reviewers: djasper

Subscribers: cfe-commits, klimek

Differential Revision: https://reviews.llvm.org/D34457

llvm-svn: 306089
2017-06-23 08:48:00 +00:00
Brian Gesiak 0ea58886c4 [Frontend] 'Show hotness' can be used with a sampling profile
Summary:
Prior to this change, using `-fdiagnostics-show-hotness` with a sampling
profile specified via `-fprofile-sample-use=` would result in the Clang
frontend emitting a warning: "argument '-fdiagnostics-show-hotness' requires
profile-guided optimization information". Of course, a sampling profile
*is* profile-guided optimization information, so the warning is misleading.
Furthermore, despite the warning, hotness was displayed based on the data in
the sampling profile.

Prevent the warning from being emitted when a sampling profile is used, and
add a test that verifies this.

Reviewers: anemet, davidxl

Reviewed By: davidxl

Subscribers: danielcdh, cfe-commits

Differential Revision: https://reviews.llvm.org/D34082

llvm-svn: 306079
2017-06-23 02:38:45 +00:00
Richard Smith b2bbd9c9ef Add missing file from r306075.
llvm-svn: 306077
2017-06-23 01:18:27 +00:00
Richard Smith 90dc525472 PR33552: Distinguish between declarations that are owned by no module and
declarations that are owned but unconditionally visible.

This allows us to set declarations as visible even if they have a local owning
module, without losing information. In turn, that means that our Objective-C
support can keep on incorrectly assuming the "hidden" bit on the declaration is
the whole story with regard to name visibility. This will also be useful once
we support the C++ Modules TS export semantics.

Objective-C name visibility is still incorrect in any case where the "hidden"
bit is not the complete story: for instance, in Objective-C++ the set of
visible categories will be wrong during template instantiation, and with local
submodule visibility enabled it will be wrong when building modules. Fixing that
will require a major overhaul of how visibility is handled for Objective-C (and
particularly for categories).

llvm-svn: 306075
2017-06-23 01:04:34 +00:00
Sam Clegg 8202e86a99 [WebAssembly] Add default -allow-undefined-file to linker args
Also, don't use the outdated lib32/lib64 naming of files
within the sysroot. The more modern/flexible approach
IIUC is to use seperate sysroots or /lib/<target-tripple>
and /include/<target-tripple>.

Differential Revision: https://reviews.llvm.org/D33565

llvm-svn: 306074
2017-06-23 00:02:55 +00:00
Richard Smith 05a21351d6 PR33002: When we instantiate the definition of a static data member, we might
have attached an initializer to the in-class declaration. If so, include the
initializer in the update record for the instantiation.

llvm-svn: 306065
2017-06-22 22:18:46 +00:00
Alex Lorenz c9a369fbec [Sema] Add -Wunguarded-availability-new
The new compiler warning -Wunguarded-availability-new is a subset of
-Wunguarded-availability. It is on by default. It only warns about uses of APIs
that have been introduced in macOS >= 10.13, iOS >= 11, watchOS >= 4 and
tvOS >= 11. We decided to use this kind of solution as we didn't want to turn
on -Wunguarded-availability by default, because we didn't want our users to get
warnings about uses of old APIs in their existing projects.

rdar://31054725

Differential Revision: https://reviews.llvm.org/D34264

llvm-svn: 306033
2017-06-22 17:02:24 +00:00
Alex Lorenz b6e03aa967 [index] Add the "SpecializationOf" relation to the forward declarations
of class template specializations

This commit fixes an issue where a forward declaration of a class template
specialization was not related to the base template. We need to relate even
forward declarations because specializations don't have to be defined.

rdar://32869409

Differential Revision: https://reviews.llvm.org/D34462

llvm-svn: 305996
2017-06-22 11:20:07 +00:00
Gabor Horvath b3bcddf769 [analyzer] Do not continue to analyze a path if the constraints contradict with builtin assume
Differential Revision: https://reviews.llvm.org/D34502

llvm-svn: 305991
2017-06-22 10:09:40 +00:00
Arnold Schwaighofer 7b871611b9 SwiftCC: Perform physical layout when computing coercion types
We need to take type alignment padding into account whe computing physical
layouts.

The layout must be compatible with the input layout, offsets are defined in
terms of offsets within a packed struct which are computed in terms of the alloc
size of a type.

Usingthe store size we would insert padding for the following type for example:

struct {

  int3 v;
  long long l;
} __attribute((packed))

On x86-64 int3 is padded to int4 alignment. The swiftcc type would be
<{ <3 x float>, [4 x i8], i64 }> which is not compatible with <{ <3 x float>,
i64 }>.

The latter has i64 at offset 16 and the former at offset 20.

rdar://32618125

llvm-svn: 305956
2017-06-21 21:43:40 +00:00
George Burgess IV 798feb4147 [test] Make absolute line numbers relative; NFC
Done to remove noise from https://reviews.llvm.org/D32332 (and to make
this test more resilient to changes in general).

llvm-svn: 305947
2017-06-21 19:59:05 +00:00
Argyrios Kyrtzidis d750e1c491 [preprocessor] Fix assertion hit when 'SingleFileParseMode' option is enabled and #if with an undefined identifier and without #else
'HandleEndifDirective' asserts that 'WasSkipping' is false, so switch to using 'FoundNonSkip' as the hint for 'SingleFileParseMode' to keep going with parsing.

llvm-svn: 305940
2017-06-21 18:52:44 +00:00
Rui Ueyama 0f8a345fb4 Use -NOT prefix instead of adding `not` to FileCheck.
If we want to make sure that a particular string is not in an output,
the regular way of doing it is to add `-NOT` prefix instead of checking
if FileCheck resulted in an error.

Differential Revision: https://reviews.llvm.org/D34435

llvm-svn: 305930
2017-06-21 16:50:38 +00:00
Erich Keane 4bd39300ef Correct VectorCall x86 (32 bit) behavior for SSE Register Assignment
In running some internal vectorcall tests in 32 bit mode, we discovered that the 
behavior I'd previously implemented for x64 (and applied to x32) regarding the 
assignment of SSE registers was incorrect. See spec here: 
https://msdn.microsoft.com/en-us/library/dn375768.aspx

My previous implementation applied register argument position from the x64 
version to both. This isn't correct for x86, so this removes and refactors that 
section. Additionally, it corrects the integer/int-pointer assignments. Unlike 
x64, x86 permits integers to be assigned independent of position.

Finally, the code for 32 bit was cleaned up a little to clarify the intent, 
as well as given a descriptive comment.

Differential Revision: https://reviews.llvm.org/D34455

llvm-svn: 305928
2017-06-21 16:37:22 +00:00
Francois Ferrand d3f0e3dee0 clang-format: introduce InlineOnly short function style
Summary:
This is the same as Inline, except it does not imply all empty
functions are merged: with this style, empty functions are merged only
if they also match the 'inline' criteria (i.e. defined in a class).

This is helpful to avoid inlining functions in implementations files.

Reviewers: djasper, krasimir

Reviewed By: djasper

Subscribers: klimek, rengolin, cfe-commits

Differential Revision: https://reviews.llvm.org/D34399

llvm-svn: 305912
2017-06-21 13:56:02 +00:00
Alex Lorenz d283dd4e06 [index] Nested class declarations should be annotated with the
"specializationOf" relation if they pseudo-override a type in the base template

This commit fixes an issue where Xcode's renaming engine couldn't find the
reference to the second occurrence of "InnerClass" in this example:

template<typename T> struct Ts { template<typename U> struct InnerClass { }; };

template<> struct Ts<int> {
template<typename U> struct InnerClass; // This occurrence wasn't renamed
};

rdar://31884960

Differential Revision: https://reviews.llvm.org/D34392

llvm-svn: 305911
2017-06-21 13:51:04 +00:00
Serge Pavlov 25dbe1a16e Function with unparsed body is a definition
While a function body is being parsed, the function declaration is not considered
as a definition because it does not have a body yet. In some cases it leads to
incorrect interpretation, the case is presented in
https://bugs.llvm.org/show_bug.cgi?id=14785:
```
    template<typename T> struct Somewhat {
      void internal() const {}
      friend void operator+(int const &, Somewhat<T> const &) {}
    };
void operator+(int const &, Somewhat<char> const &x) { x.internal(); }
```
When statement `x.internal()` in the body of global `operator+` is parsed, the type
of `x` must be completed, so the instantiation of `Somewhat<char>` is started. It
instantiates the declaration of `operator+` defined inline, and makes a check for
redefinition. The check does not detect another definition because the declaration
of `operator+` is still not defining as does not have a body yet.

To solves this problem the function `isThisDeclarationADefinition` considers
a function declaration as a definition if it has flag `WillHaveBody` set.

This change fixes PR14785.

Differential Revision: https://reviews.llvm.org/D30375

This is a recommit of 305379, reverted in 305381, with small changes.

llvm-svn: 305903
2017-06-21 12:46:57 +00:00
Ilya Biryukov f81d46f45e Fixed compiler warnings after r305890.
Should fix buildbots that pass -Werror.

llvm-svn: 305902
2017-06-21 12:34:27 +00:00
Krasimir Georgiev b03877ab83 [clang-format] Support sorting using declarations
Summary:
This patch adds UsingDeclarationsSorter, a TokenAnalyzer that sorts consecutive
using declarations.

Reviewers: klimek

Reviewed By: klimek

Subscribers: Typz, djasper, cfe-commits, klimek, mgorny

Differential Revision: https://reviews.llvm.org/D33823

llvm-svn: 305901
2017-06-21 12:03:12 +00:00
Artem Dergachev 4a084cfde7 [analyzer] Bump a few default performance thresholds.
This makes the analyzer around 10% slower by default,
allowing it to find deeper bugs.

Default values for the following -analyzer-config change:
max-nodes: 150000 -> 225000;
max-inlinable-size: 50 -> 100.

rdar://problem/32539666
Differential Revision: https://reviews.llvm.org/D34277

llvm-svn: 305900
2017-06-21 11:29:35 +00:00
Haojian Wu 53dd644c5d Fix unused-variable compilation error.
llvm-svn: 305898
2017-06-21 11:26:58 +00:00
Artem Dergachev 928d72fa36 [analyzer] LocalizationChecker: Support new localizable APIs.
Add support for new methods that were added in macOS High Sierra & iOS 11
and require a localized string.

Patch by Kulpreet Chilana!

rdar://problem/32795210
Differential Revision: https://reviews.llvm.org/D34266

llvm-svn: 305896
2017-06-21 11:12:07 +00:00
Alex Lorenz 71d72135b0 Revert r305678: [driver][macOS] Pick the system version for the
deployment target if the SDK is newer than the system

This commit also reverts follow-up commits r305680 and r305685 that have
buildbot fixes.

The change in r305678 wasn't correct because it relied on
`llvm::sys::getProcessTriple`, which uses a pre-configured OS version. We should
lookup the actual macOS version of the system on which the compiler is running.

llvm-svn: 305891
2017-06-21 10:27:24 +00:00
Ilya Biryukov 200b328972 Moved code hanlding precompiled preamble out of the ASTUnit.
Reviewers: bkramer, krasimir, arphaman, akyrtzi, klimek

Reviewed By: klimek

Subscribers: mgorny, klimek, cfe-commits

Differential Revision: https://reviews.llvm.org/D34287

llvm-svn: 305890
2017-06-21 10:24:58 +00:00
Raphael Isemann 676b457b8b Changed wording in comment
llvm-svn: 305878
2017-06-21 05:41:39 +00:00