Commit Graph

20876 Commits

Author SHA1 Message Date
Roger Ferrer Ibanez e3d8026cc7 Remove some false positives when taking the address of packed members
Differential Revision: https://reviews.llvm.org/D23657

llvm-svn: 286798
2016-11-14 08:53:27 +00:00
Craig Topper 5e0709d60b [AVX-512] Replace masked dword and qword variable shift builtins with unmasked builtins and a select.
This is part of a set of changes to allow InstCombine in the backend to optimize variable shifts without having to know about masking.

llvm-svn: 286757
2016-11-13 07:26:34 +00:00
Konstantin Zhuravlyov 81a78bb864 [AMDGPU] Add f16 builtin functions (VI+)
Differential Revision: https://reviews.llvm.org/D26476

llvm-svn: 286741
2016-11-13 02:37:05 +00:00
Craig Topper 2c8f49e67b [AVX-512] Use scalar vfmsub/vfnmsub mask3 intrinsics instead of inverting the mask argument of a vfmadd intrinsic.
Summary: Inverting the mask argument does not reflect the intended semantics of the intrinsic.

Reviewers: igorb, delena

Subscribers: cfe-commits

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

llvm-svn: 286733
2016-11-12 23:24:34 +00:00
Serge Pavlov 3852637005 Use descriptive message if list initializer is incorrectly parenthesized.
If initializer contains parentheses around braced list where it is not allowed,
as in construct int({0}), clang issued message like `functional-style cast
from 'void' to 'int' is not allowed`, which does not help much. Both gcc and
msvc issue message `list-initializer for non-class type must not be
parenthesized`, which is more descriptive. This change implements similar
message for clang.

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

llvm-svn: 286721
2016-11-12 15:38:55 +00:00
Craig Topper 1a44193afd [AVX-512] Convert the rest of the masked shift by immediate and by single element builtins over to the newly added unmasked builtins and a select.
This should also fix PR30691 since the new builtins are handled like the legacy builtins in the backend.

llvm-svn: 286714
2016-11-12 07:16:59 +00:00
Devin Coughlin 3dc29a52c7 [analyzer] Fix copy-pasta in NullableReturnedFromNonnullChecker checker name.
The name of the NullableReturnedFromNonnullChecker in Checkers.td
was accidentally "NullablePassedToNonnull", which made it impossible
to explicitly turn the checker on.

rdar://problem/28354459

llvm-svn: 286697
2016-11-12 01:23:01 +00:00
Argyrios Kyrtzidis db4698352e [index] Rename SymbolSubKind -> SymbolProperty, NFC.
This better reflects what it represents.

llvm-svn: 286680
2016-11-11 23:49:55 +00:00
Evgeniy Stepanov 8a2bedbf27 Tread TSan LLVM flags to driver: add TSan controlling flags to clang.
Summary:
New clang flags, all default to true:
-f[no-]sanitize-thread-data-races
-f[no-]sanitize-thread-stack-traces
-f[no-]sanitize-thread-atomics

Reviewers: dvyukov, pcc, eugenis

Subscribers: pcc, cfe-commits

Patch by Alex Shlyapnikov.

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

llvm-svn: 286669
2016-11-11 23:17:36 +00:00
Nemanja Ivanovic 4de0011b5c [PowerPC] Implement remaining permute builtins in altivec.h - Clang portion
This patch corresponds to review:
https://reviews.llvm.org/D26479

It adds the remaining vector permute/rotate builtins to altivec.h.

llvm-svn: 286650
2016-11-11 22:34:44 +00:00
Artem Dergachev d23982fb3c [ASTMatchers] Fix a typo in cStyleCastExpr() docs. NFC.
llvm-svn: 286628
2016-11-11 20:29:59 +00:00
Nemanja Ivanovic 4079fc8188 [PowerPC] Add vector conversion builtins to altivec.h - clang portion
This patch corresponds to review:
https://reviews.llvm.org/D26308

It adds a number of vector type conversion builtins to altivec.h.

llvm-svn: 286627
2016-11-11 19:56:17 +00:00
Douglas Katzman 180529892d Fix mismatched enum value name and diagnostic text.
ExpectedFunctionGlobalVarMethodOrProperty
would previously say "functions and global variables"
instead of "functions, methods, properties, and global variables"

The newly added ExpectedFunctionOrGlobalVariable
says "functions and global variables"

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

llvm-svn: 286599
2016-11-11 16:51:40 +00:00
Alexey Bataev 31939e39db Fix for PR28523: unexpected compilation error.
Clang emits error message for the following code:
```
template <class F> void parallel_loop(F &&f) { f(0); }

int main() {
  int x;
  parallel_loop([&](auto y) {
    {
      x = y;
    };
  });
}
```

$ clang++ --std=gnu++14 clang_test.cc -o clang_test
clang_test.cc:9:7: error: reference to local variable 'x' declared in enclosing function 'main'
      x = y;
            ^
clang_test.cc:2:48: note: in instantiation of function template specialization 'main()::(anonymous class)::operator()<int>' requested here
            template <class F> void parallel_loop(F &&f) { f(0); }
                                                           ^
clang_test.cc:6:3: note: in instantiation of function template specialization 'parallel_loop<(lambda at clang_test.cc:6:17)>' requested here parallel_loop([&](auto y) {
           ^
clang_test.cc:5:7: note: 'x' declared here
      int x;
          ^
1 error generated.

Patch fixes this issue.

llvm-svn: 286584
2016-11-11 12:36:20 +00:00
Jordan Rose 3b917fe019 Warn when 'assume_nonnull' infers nullability within an array.
...or within a reference. Both of these add an extra level of
indirection that make us less certain that the pointer really was
supposed to be non-nullable. However, changing the default behavior
would be a breaking change, so we'll just make it a warning instead.

Part of rdar://problem/25846421

llvm-svn: 286521
2016-11-10 23:28:30 +00:00
Jordan Rose f85a9b06b8 Add -Wnullability-completeness-on-arrays.
This is an addition to (and sub-warning of) -Wnullability-completeness
that warns when an array parameter is missing nullability. When the
specific warning is switched off, the compiler falls back to only
warning on pointer types written as pointer types.

Note that use of nullability /within/ an array triggers the
completeness checks regardless of whether or not the array-specific
warning is enabled; the intent there is simply to determine whether a
particular header is trying to be nullability-aware at all.

Part of rdar://problem/25846421.

llvm-svn: 286520
2016-11-10 23:28:26 +00:00
Jordan Rose 303e2f1eac Accept nullability qualifiers on array parameters.
Since array parameters decay to pointers, '_Nullable' and friends
should be available for use there as well. This is especially
important for parameters that are typedefs of arrays. The unsugared
syntax for this follows the syntax for 'static'-sized arrays in C:

  void test(int values[_Nullable]);

This syntax was previously accepted but the '_Nullable' (and any other
attributes) were silently discarded. However, applying '_Nullable' to
a typedef was previously rejected and is now accepted; therefore, it
may be necessary to test for the presence of this feature:

  #if __has_feature(nullability_on_arrays)

One important change here is that DecayedTypes don't always
immediately contain PointerTypes anymore; they may contain an
AttributedType instead. This only affected one place in-tree, so I
would guess it's not likely to cause problems elsewhere.

This commit does not change -Wnullability-completeness just yet. I
want to think about whether it's worth doing something special to
avoid breaking existing clients that compile with -Werror. It also
doesn't change '#pragma clang assume_nonnull' behavior, which
currently treats the following two declarations as equivalent:

  #pragma clang assume_nonnull begin
  void test(void *pointers[]);
  #pragma clang assume_nonnull end

  void test(void * _Nonnull pointers[]);

This is not the desired behavior, but changing it would break
backwards-compatibility. Most likely the best answer is going to be
adding a new warning.

Part of rdar://problem/25846421

llvm-svn: 286519
2016-11-10 23:28:17 +00:00
Argyrios Kyrtzidis f42032abde [index] Add SymbolSubKind for the GKInspectable annotation.
llvm-svn: 286518
2016-11-10 23:27:11 +00:00
Aaron Ballman 811cdc979b Correcting a documentation formatting bug; NFC.
llvm-svn: 286494
2016-11-10 19:45:49 +00:00
Alex Lorenz a5430bd5d6 Add -Wduplicate-protocol for existing diagnostic
Expose a warning flag for warn_duplicate_protocol_def. This allows control
over the severity of duplicate protocol definitions.

For example -Werror=duplicate-protocol or
#pragma clang diagnostic ignored "-Wduplicate-protocol".

Patch provided by Dave Lee!

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

llvm-svn: 286487
2016-11-10 18:30:26 +00:00
Alex Lorenz d60bb28307 [Sema] Avoid -Wshadow warnings for shadowed variables that
aren't captured by lambdas with a default capture specifier

This commit is a follow-up to r286354. It avoids the -Wshadow warning for
variables which shadow variables that aren't captured by lambdas with a default
capture specifier. It provides an additional note that points to location of
the capture.

The old behaviour is preserved with -Wshadow-all or -Wshadow-uncaptured-local.

rdar://14984176

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

llvm-svn: 286465
2016-11-10 16:19:11 +00:00
Pavel Labath ac71c8e298 [VFS] Replace TimeValue usage with std::chrono
Summary: NFCI

Reviewers: benlangmuir, zturner

Subscribers: cfe-commits

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

llvm-svn: 286356
2016-11-09 10:52:22 +00:00
Alex Lorenz 175388c00d [Sema] Avoid -Wshadow warnings for shadowed variables that aren't captured
by lambdas with an explicit capture list

This commit avoids the -Wshadow warning for variables which shadow variables
that aren't captured by lambdas with an explicit capture list. It provides an
additional note that points to location of the explicit capture.

The old behaviour is preserved with -Wshadow-all or -Wshadow-uncaptured-local.

rdar://17135966

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

llvm-svn: 286354
2016-11-09 10:38:57 +00:00
Argyrios Kyrtzidis f95a000421 [index] Fix issue with protocol name locations in conformance list of an ObjC class when they come from a typedef.
The ObjC class protocol list assumes there is an associated location for each protocol but no location is provided
when the protocol list comes from a typedef, and we end up with a buffer overflow when trying to get locations for the protocol names.

Fixes crash of rdar://28980278.

llvm-svn: 286331
2016-11-09 02:47:07 +00:00
Dominic Chen 09d52e1cd4 [analyzer] Provide Contains() on ImmutableMap program state partial trait.
Reviewers: zaks.anna, dcoughlin

Subscribers: cfe-commits

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

llvm-svn: 286306
2016-11-08 22:39:14 +00:00
Daniel Jasper d21485d2f5 Remove FormatContext from libClang as it is now unused.
llvm-svn: 286279
2016-11-08 19:47:19 +00:00
Daniel Jasper 528d682ff6 [clang-format] Remove (SourceManager, FileID) variants
In Format, remove the reformat() and clean() functions taking a SourceManager
and a FileID. Keep the versions taking StringRef Code.

- there was duplicated functionality
- the FileID versions were harder to use
- the clean() version is dead code anyways

Patch by Krasimir Georgiev. Thank you.

llvm-svn: 286243
2016-11-08 16:11:33 +00:00
Ayman Musa e60a41ca28 [X86][AVX512][Clang] Add support for mask_{move|store|load}_s{s/d} and int2mask/mask2int intrinsics.
Differential Revision: https://reviews.llvm.org/D26021

llvm-svn: 286229
2016-11-08 12:00:30 +00:00
Alexander Kornienko 8df2a62ae6 Add a method to get the list of registered static analyzer checkers.
Summary:
This provides a better interface for clang-tidy and encapsulates the knowledge
about experimental checkers instead of leaving this to the clients.

Reviewers: zaks.anna

Subscribers: a.sidorin, NoQ, dcoughlin, cfe-commits

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

llvm-svn: 286218
2016-11-08 07:23:32 +00:00
Peter Collingbourne 77c89b6958 Bitcode: Decouple block info block state from reader.
As proposed on llvm-dev:
http://lists.llvm.org/pipermail/llvm-dev/2016-October/106630.html

Move block info block state to a new class, BitstreamBlockInfo.
Clients may set the block info for a particular cursor with the
BitstreamCursor::setBlockInfo() method.

At this point BitstreamReader is not much more than a container for an
ArrayRef<uint8_t>, so remove it and replace all uses with direct uses
of memory buffers.

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

llvm-svn: 286207
2016-11-08 04:17:11 +00:00
Eric Liu cf2913c6f1 Deduplicate replacements by FileEntry instead of file names.
Summary:
The current version does not deduplicate equivalent file paths correctly.
For example, a relative path and an absolute path are considered inequivalent.
Comparing FileEnry addresses these issues.

Reviewers: djasper

Subscribers: alexshap, klimek, cfe-commits

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

llvm-svn: 286096
2016-11-07 06:08:23 +00:00
Olivier Goffart d211c648b9 [index] Expose FriendDecl
Differential Revision: https://reviews.llvm.org/D26285

llvm-svn: 285984
2016-11-04 06:29:27 +00:00
Richard Smith 018ac39f94 Improve obvious-most-derived-type devirtualization:
* if the base is produced by a series of derived-to-base conversions, check
    the expression inside them when looking for an expression with a known
    dynamic type
  * step past MaterializeTemporaryExprs when checking for a known dynamic type
  * when checking for a known dynamic type, treat all class prvalues as having
    a known dynamic type after skipping all relevant rvalue subobject
    adjustments
  * treat callees formed by pointer-to-member access for a non-reference member
    type like callees formed by member access.

llvm-svn: 285954
2016-11-03 18:55:18 +00:00
Samuel Antao 7108bf36b6 Rename the version of ConstructJob for multiple outputs to ConstructJobMultipleOutputs.
It was causing trouble with the GCC bots.

llvm-svn: 285925
2016-11-03 15:41:50 +00:00
Eric Fiselier e4e9e281a1 [Sema] Allow static_cast<T&&>(e) to check explicit conversions for non-reference-related types.
Summary:
[expr.cast.static] states:
> 3. A glvalue of type “cv1 T1” can be cast to type “rvalue reference to cv2 T2” if “cv2 T2” is reference-compatible
> with “cv1 T1”. The result refers to the object or the specified base class subobject thereof. If T2 is
> an inaccessible or ambiguous base class of T1, a program that necessitates such a cast is
> ill-formed.
> 
> 4. Otherwise, an expression e can be explicitly converted to a type T using a static_cast of the form static_-
> cast<T>(e) if the declaration T t(e); is well-formed, for some invented temporary variable t. [...]

Currently when checking p3 Clang will diagnose `static_cast<T&&>(e)` as invalid if the argument is not reference compatible with `T`. However I believe the correct behavior is to also check p4 in those cases.  For example:

```
double y = 42;
static_cast<int&&>(y); // this should be OK.  'int&& t(y)' is well formed
```

Note that we still don't check p4 for non-reference-compatible types which are reference-related since  `T&& t(e);` should never be well formed in those cases.


Reviewers: rsmith

Subscribers: cfe-commits

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

llvm-svn: 285872
2016-11-03 02:13:17 +00:00
Richard Smith 14d0484a16 Teach clang-query to dump types. I couldn't find any existing tests for clang-query's dumping functionality. =(
llvm-svn: 285869
2016-11-02 23:57:18 +00:00
Erich Keane 757d317c24 regcall: Implement regcall Calling Conv in clang
This patch implements the register call calling convention, which ensures
as many values as possible are passed in registers. CodeGen changes
were committed in https://reviews.llvm.org/rL284108.

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

llvm-svn: 285849
2016-11-02 18:29:35 +00:00
Alex Lorenz 560ae565e9 Add a note that points to the linkage specifier for the C++ linkage errors
This commit improves the "must have C++ linkage" error diagnostics that are
emitted for C++ declarations like templates and literal operators by adding an
additional note that points to the appropriate extern "C" linkage specifier.

rdar://19021120

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

llvm-svn: 285823
2016-11-02 15:46:34 +00:00
Yaxun Liu 7d07ae7c85 [OpenCL] Mark group functions as convergent in opencl-c.h
Certain OpenCL builtin functions are supposed to be executed by all threads in a work group or sub group. Such functions should not be made divergent during transformation. It makes sense to mark them with convergent attribute.

The adding of convergent attribute is based on Ettore Speziale's work and the original proposal and patch can be found at https://www.mail-archive.com/cfe-commits@lists.llvm.org/msg22271.html.

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

llvm-svn: 285725
2016-11-01 18:45:32 +00:00
Alexey Bader 0ea075328e [OpenCL] Override supported OpenCL extensions with -cl-ext option
Summary:
This patch adds a command line option '-cl-ext' to control a set of
supported OpenCL extensions. Option accepts a comma-separated list
of extensions prefixed with '+' or '-'.

It can be used together with a target triple to override support for some
extensions:

  // spir target supports all extensions, but we want to disable fp64
  clang -cc1 -triple spir-unknown-unknown -cl-ext=-cl_khr_fp64

Special 'all' extension allows to enable or disable all possible
extensions:

  // only fp64 will be supported
  clang -cc1 -triple spir-unknown-unknown -cl-ext=-all,+cl_khr_fp64

Patch by asavonic (Andrew Savonichev).

Reviewers: joey, yaxunl

Subscribers: yaxunl, bader, Anastasia, cfe-commits

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

llvm-svn: 285700
2016-11-01 15:50:52 +00:00
Nemanja Ivanovic 05ce4ca0dd [PowerPC] Implement vector shift builtins - clang portion
This patch corresponds to review https://reviews.llvm.org/D26092.
Committing on behalf of Tony Jiang.

llvm-svn: 285694
2016-11-01 14:46:20 +00:00
Nemanja Ivanovic 251f6dd93d [PPC] Add vec_absd functions to altivec.h
This patch corresponds to review https://reviews.llvm.org/D26073.
Committing on behalf of Sean Fertile.

llvm-svn: 285679
2016-11-01 08:39:56 +00:00
Craig Topper 08bf53ffda [AVX-512] Remove masked vector insert builtins and replace with native shufflevectors and selects.
Unfortunately, the backend currently doesn't fold masks into the instructions correctly when they come from these shufflevectors. I'll work on that in a future commit.

llvm-svn: 285667
2016-11-01 05:47:56 +00:00
Richard Smith 6e5610fa4d Implement ABI proposal for throwing noexcept function pointers, per discussion
on cxx-abi-dev (thread starting 2016-10-11). This is currently hidden behind a
cc1-only -m flag, pending discussion of how best to deal with language changes
that require use of new symbols from the ABI library.

llvm-svn: 285664
2016-11-01 01:34:46 +00:00
Tim Shen 43ee05e804 [ReachableCode] Skip over ExprWithCleanups in isConfigurationValue
Summary: Fixes pr29152.

Reviewers: rsmith, pirama, krememek

Subscribers: cfe-commits

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

llvm-svn: 285657
2016-11-01 00:19:04 +00:00
Malcolm Parsons 7d96c334d2 [ASTMatcher] Add CXXNewExpr support to hasDeclaration
Reviewers: sbenza, lukasza, aaron.ballman, klimek

Subscribers: lukasza, sbenza, cfe-commits

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

llvm-svn: 285644
2016-10-31 22:04:07 +00:00
David Majnemer 6f51be3118 Add a warning flag for warn_alloca_align_alignof
llvm-svn: 285612
2016-10-31 18:23:02 +00:00
David Majnemer 86b1bfad05 [Sema] Warn when alignof is used with __builtin_alloca_with_align
The second argument to __builtin_alloca_with_align is supposed to be in
bits, not bytes.  Using alignof there would be indicative of a bug.

llvm-svn: 285609
2016-10-31 18:07:57 +00:00
Elad Cohen 938f516424 [Modules] Add a command line option for loading the clang builtins modulemap.
-fbuiltin-module-map loads the clang builtins modulemap file. (This is
equivalent to -fmodule-map-file=<resource dir>/include/module.modulemap)

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

llvm-svn: 285548
2016-10-31 08:21:54 +00:00
David Majnemer 5116993f8e Add support for __builtin_alloca_with_align
__builtin_alloca always uses __BIGGEST_ALIGNMENT__ for the alignment of
the allocation.  __builtin_alloca_with_align allows the programmer to
specify the alignment of the allocation.

This fixes PR30658.

llvm-svn: 285544
2016-10-31 05:37:48 +00:00