Commit Graph

71521 Commits

Author SHA1 Message Date
Erich Keane 1a3b8fd8af Revert a part of 320489 that was submitted unintentionally.
llvm-svn: 320493
2017-12-12 16:22:31 +00:00
Erich Keane bd2197c0c1 Fix ICE when __has_unqiue_object_representations called with invalid decl
llvm-svn: 320489
2017-12-12 16:02:06 +00:00
Krasimir Georgiev 11ef531b5c [clang-format] Improve ObjC headers detection.
This patch improves detection of ObjC header files.
Right now many ObjC headers, especially short ones, are categorized as C/C++.

Way of filtering still isn't the best, as most likely it should be token-based.

Contributed by jolesiak!

llvm-svn: 320479
2017-12-12 13:43:59 +00:00
Eric Liu 06d3402816 [SemaCodeComplete] Allow passing out scope specifiers in qualified-id completions via completion context.
Reviewers: ilya-biryukov, arphaman

Reviewed By: arphaman

Subscribers: nik, cfe-commits

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

llvm-svn: 320471
2017-12-12 11:35:46 +00:00
Artem Dergachev e67a575dfb [analyzer] StackAddrEscape: For now, disable the new async escape checks.
The new check introduced in r318705 is useful, but suffers from a particular
class of false positives, namely, it does not account for
dispatch_barrier_sync() API which allows one to ensure that the asyncronously
executed block that captures a pointer to a local variable does not actually
outlive that variable.

The new check is split into a separate checker, under the name of
alpha.core.StackAddressAsyncEscape, which is likely to get enabled by default
again once these positives are fixed. The rest of the StackAddressEscapeChecker
is still enabled by default.

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

llvm-svn: 320455
2017-12-12 02:59:09 +00:00
Artem Dergachev 3ef5deb3a7 [analyzer] In getSVal() API, disable auto-detection of void type as char type.
This is a follow-up from r314910. When a checker developer attempts to
dereference a location in memory through ProgramState::getSVal(Loc) or
ProgramState::getSVal(const MemRegion *), without specifying the second
optional QualType parameter for the type of the value he tries to find at this
location, the type is auto-detected from location type. If the location
represents a value beyond a void pointer, we thought that auto-detecting the
type as 'char' is a good idea. However, in most practical cases, the correct
behavior would be to specify the type explicitly, as it is available from other
sources, and the few cases where we actually need to take a 'char' are
workarounds rather than an intended behavior. Therefore, try to fail with an
easy-to-understand assertion when asked to read from a void pointer location.

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

llvm-svn: 320451
2017-12-12 02:27:55 +00:00
Craig Topper 9a724aa38f [Driver][CodeGen] Add -mprefer-vector-width driver option and attribute during CodeGen.
This adds a new command line option -mprefer-vector-width to specify a preferred vector width for the vectorizers. Valid values are 'none' and unsigned integers. The driver will check that it meets those constraints. Specific supported integers will be managed by the targets in the backend.

Clang will take the value and add it as a new function attribute during CodeGen.

This represents the alternate direction proposed by Sanjay in this RFC: http://lists.llvm.org/pipermail/llvm-dev/2017-November/118734.html

The syntax here matches gcc, though gcc treats it as an x86 specific command line argument. gcc only allows values of 128, 256, and 512. I'm not having clang check any values.

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

llvm-svn: 320419
2017-12-11 21:09:19 +00:00
Craig Topper 188252dd1e [Docs] Regenerate command line documentation.
llvm-svn: 320418
2017-12-11 21:09:16 +00:00
Erich Keane bf5fad86db PR35586: Relax two asserts that are overly restrictive
The two asserts are too aggressive.  In C++  mode, an
enum is NOT considered an integral type, but an enum value
is allowed to be an enum.  This patch relaxes the two asserts
to allow the enum value as well (as typechecking does).

llvm-svn: 320411
2017-12-11 19:44:28 +00:00
Krzysztof Parzyszek 049278c86a [Hexagon] Remove unsupported vlut intrinsics
llvm-svn: 320410
2017-12-11 19:29:56 +00:00
Hans Wennborg b1c8f45249 Fix warn-enum-compare.cpp on Windows
It's been failing since r319875.

llvm-svn: 320405
2017-12-11 18:58:18 +00:00
Zhihao Yuan 00c9dfdfd0 P0620 follow-up: deducing `auto` from braced-init-list in new expr
Summary:
This is a side-effect brought in by p0620r0, which allows other placeholder types (derived from `auto` and `decltype(auto)`) to be usable in a `new` expression with a single-clause //braced-init-list// as its initializer (8.3.4 [expr.new]/2).  N3922 defined its semantics.

References:
 http://wg21.link/p0620r0
 http://wg21.link/n3922

Reviewers: rsmith, aaron.ballman

Reviewed By: rsmith

Subscribers: cfe-commits

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

llvm-svn: 320401
2017-12-11 18:29:54 +00:00
Erich Keane 6c4835978a Revert 320391: Certain targets are failing, pulling back to diagnose.
llvm-svn: 320398
2017-12-11 18:14:51 +00:00
Malcolm Parsons d900a0c4e2 [Sema] Fix crash in unused-lambda-capture warning for VLAs
Summary:
Clang was crashing when diagnosing an unused-lambda-capture for a VLA because
From.getVariable() is null for the capture of a VLA bound.
Warning about the VLA bound capture is not helpful, so only warn for the VLA
itself.

Fixes: PR35555

Reviewers: aaron.ballman, dim, rsmith

Reviewed By: aaron.ballman, dim

Subscribers: cfe-commits

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

llvm-svn: 320396
2017-12-11 18:00:36 +00:00
Erich Keane bb322555af For Linux/gnu compatibility, preinclude <stdc-predef.h> if the file is available
As reported in llvm bugzilla 32377.
Here’s a patch to add preinclude of stdc-predef.h.

The gcc documentation says “On GNU/Linux, <stdc-predef.h> is pre-included.” See https://gcc.gnu.org/gcc-4.8/porting_to.html;

The preinclude is inhibited with –ffreestanding.

Basically I fixed the failing test cases by adding –ffreestanding which inhibits this behavior.

I fixed all the failing tests, including some in extra/test, there's a separate patch for that which is linked here

Note: this is a recommit after a test failure took down the original (r318669)

Patch By: mibintc
Differential Revision: https://reviews.llvm.org/D34158

llvm-svn: 320391
2017-12-11 17:36:42 +00:00
Aleksandar Beserminji 92985796dc [mips] Minor update to the comment (NFC)
llvm-svn: 320354
2017-12-11 12:12:16 +00:00
Aleksandar Beserminji 8ee5296152 [mips] Removal of microMIPS64R6
microMIPS64R6 is removed from backend, and therefore frontend
will show an error when target is microMIPS64R6.

This is Clang part of patch.

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

llvm-svn: 320351
2017-12-11 11:29:17 +00:00
Simon Pilgrim d038b475ac Fix MSVC 'not all control paths return a value' warning
llvm-svn: 320297
2017-12-10 11:05:14 +00:00
Duncan P. N. Exon Smith 6c63b07a55 Update Clang CMake cache to use cxx-headers, NFC
Apparently libcxx-headers is going away.  Fixes PR35584.

llvm-svn: 320271
2017-12-09 23:44:42 +00:00
Tim Northover 36bb6d5d46 Switch to gnu++14 as the default dialect.
This is C++14 with conforming GNU extensions.

llvm-svn: 320250
2017-12-09 12:09:54 +00:00
Richard Trieu c4ec87af1d Revert r320230 to fix buildbots.
llvm-svn: 320239
2017-12-09 03:02:21 +00:00
Alex Lorenz 25e93db6b5 Fix Driver/darwin-version.c test
A target argument should be provided to avoid failures on non-Darwin

llvm-svn: 320238
2017-12-09 02:56:48 +00:00
Alex Lorenz f04fb276e7 [driver][darwin] Refactor the target selection code, NFC
The simulator variant of Darwin's platforms is removed in favor of a new
environment field.
The code that selects the platform and the version is split into 4 different
functions instead of being all in one function.
This is an NFC commit, although it slightly improves the
"invalid version number" diagnostic by displaying the environment variable
instead of -m<os>-version-min if the OS version was derived from the
environment.

rdar://35813850

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

llvm-svn: 320235
2017-12-09 02:27:11 +00:00
Evgeniy Stepanov ababedd0b0 Fix fsanitize-blacklist test on Windows.
Broken in r320232.

llvm-svn: 320233
2017-12-09 02:15:42 +00:00
Evgeniy Stepanov 12817e59de Hardware-assisted AddressSanitizer (clang part).
Summary:
Driver, frontend and LLVM codegen for HWASan.
A clone of ASan, basically.

Reviewers: kcc, pcc, alekseyshl

Subscribers: srhines, javed.absar, cfe-commits

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

llvm-svn: 320232
2017-12-09 01:32:07 +00:00
Richard Trieu e81caeb314 [ODRHash] Support ODR violation detection in functions.
Extend the hashing to functions, which allows detection of function definition
mismatches across modules.

llvm-svn: 320230
2017-12-09 01:29:40 +00:00
Kamil Rytarowski 62d421f32b Don't link NetBSD programs with -ldl in linkXRayRuntimeDeps
Summary:
There is no such library on NetBSD, the corresponding functions like dlopen(3) are in libc.

Sponsored by <The NetBSD Foundation>

Reviewers: joerg, vitalybuka, eugenis

Reviewed By: vitalybuka

Subscribers: dberris, llvm-commits, #sanitizers

Tags: #sanitizers

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

llvm-svn: 320220
2017-12-09 00:34:01 +00:00
Akira Hatanaka 502775a2ee [CodeGen][X86] Fix handling of __fp16 vectors.
This commit fixes a bug in IRGen where it generates completely broken
code for __fp16 vectors on X86. For example when the following code is
compiled:

half4 hv0, hv1, hv2; // these are vectors of __fp16.

void foo221() {
  hv0 = hv1 + hv2;
}

clang generates the following IR, in which two i16 vectors are added:

@hv1 = common global <4 x i16> zeroinitializer, align 8
@hv2 = common global <4 x i16> zeroinitializer, align 8
@hv0 = common global <4 x i16> zeroinitializer, align 8

define void @foo221() {
  %0 = load <4 x i16>, <4 x i16>* @hv1, align 8
  %1 = load <4 x i16>, <4 x i16>* @hv2, align 8
  %add = add <4 x i16> %0, %1
  store <4 x i16> %add, <4 x i16>* @hv0, align 8
  ret void
}

To fix the bug, this commit uses the code committed in r314056, which
modified clang to promote and truncate __fp16 vectors to and from float
vectors in the AST. It also fixes another IRGen bug where a short value
is assigned to an __fp16 variable without any integer-to-floating-point
conversion, as shown in the following example:

__fp16 a;
short b;

void foo1() {
  a = b;
}

@b = common global i16 0, align 2
@a = common global i16 0, align 2

define void @foo1() #0 {
  %0 = load i16, i16* @b, align 2
  store i16 %0, i16* @a, align 2
  ret void
}

rdar://problem/20625184

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

llvm-svn: 320215
2017-12-09 00:02:37 +00:00
Richard Smith 354abec3e6 Remove creation of out-of-bounds value of enumeration type (resulting in UB).
Also remove unnecessary initialization of out-parameters with this value, so
that MSan is able to catch errors appropriately.

llvm-svn: 320212
2017-12-08 23:29:59 +00:00
Richard Smith a5370fb82c Unify implementation of our two different flavours of -Wtautological-compare,
and fold together into a single function.

In so doing, fix a handful of remaining bugs where we would report false
positives or false negatives if we promote a signed value to an unsigned type
for the comparison.

This re-commits r320122 and r320124, minus two changes:

 * Comparisons between a constant and a non-constant expression of enumeration
   type never warn, not even if the constant is out of range. We should be
   warning about the creation of such a constant, not about its use.

 * We do not use more precise bit-widths for comparisons against bit-fields.
   The more precise diagnostics probably are the right thing, but we should
   consider moving them under their own warning flag.

Other than the refactoring, this patch should only change the behavior for the
buggy cases (where the warnings didn't take into account that promotion from
signed to unsigned can leave a range of inaccessible values in the middle of
the promoted type).

llvm-svn: 320211
2017-12-08 22:57:11 +00:00
Eugene Zelenko cb96ac64b0 [Lex] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).
llvm-svn: 320207
2017-12-08 22:39:26 +00:00
Alexey Bataev e83b3e89e6 [OPENMP] Simplify codegen for loop iteration variables in loop preamble.
Initial patch could cause trouble in the optimized code because of the
incorrectly generated lifetime intrinsics.

llvm-svn: 320191
2017-12-08 20:18:58 +00:00
Vedant Kumar 9174b684b7 [ubsan] array-bounds: Ignore params with constant size
This is a follow-up to r320128. Eli pointed out that there is some gray
area in the language standard about whether the constant size is exact,
or a lower bound.

https://reviews.llvm.org/D40940

llvm-svn: 320185
2017-12-08 19:51:42 +00:00
Kostya Serebryany 67a3af0991 [hwasan] typo in docs
llvm-svn: 320168
2017-12-08 18:14:03 +00:00
Kamil Rytarowski bb9a852afd Fix a comment in the code
The -ldl library is missing on NetBSD too, make the comment more generic.

llvm-svn: 320165
2017-12-08 17:38:25 +00:00
Hans Wennborg 5791ce77ba Revert "Unify implementation of our two different flavours of -Wtautological-compare."
> Unify implementation of our two different flavours of -Wtautological-compare.
>
> In so doing, fix a handful of remaining bugs where we would report false
> positives or false negatives if we promote a signed value to an unsigned type
> for the comparison.

This caused a new warning in Chromium:

../../base/trace_event/trace_log.cc:1545:29: error: comparison of constant 64
with expression of type 'unsigned int' is always true
[-Werror,-Wtautological-constant-out-of-range-compare]
  DCHECK(handle.event_index < TraceBufferChunk::kTraceBufferChunkSize);
         ~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The 'unsigned int' is really a 6-bit bitfield, which is why it's always
less than 64.

I thought we didn't use to warn (with out-of-range-compare) when comparing
against the boundaries of a type?

llvm-svn: 320162
2017-12-08 16:54:08 +00:00
Alexey Bataev dfa430f694 [OPENMP] Initial codegen for `target teams distribute` directive.
Host + default devices codegen for `target teams distribute` directive.

llvm-svn: 320149
2017-12-08 15:03:50 +00:00
Stephan Bergmann feed26ff07 In stdbool.h, define bool, false, true only in gnu++98
GCC has meanwhile corrected that with the similar
<https://gcc.gnu.org/viewcvs/gcc?view=revision&revision=216679> "C++11
explicitly forbids macros for bool, true and false."

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

llvm-svn: 320135
2017-12-08 08:28:08 +00:00
Hans Wennborg 5bb88e0f9e Revert r320124 "Fold together the in-range and out-of-range portions of -Wtautological-compare."
This broke Chromium:

../../base/trace_event/trace_log.cc:1545:29: error: comparison of constant 64
with expression of type 'unsigned int' is always true
[-Werror,-Wtautological-constant-out-of-range-compare]
  DCHECK(handle.event_index < TraceBufferChunk::kTraceBufferChunkSize);
         ~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The 'unsigned int' is really a 6-bit bitfield, which is why it's always
less than 63.

Did this use to fall under the "in-range" case before? I thought we
didn't use to warn when comparing against the boundaries of a type.

llvm-svn: 320133
2017-12-08 05:19:12 +00:00
Vedant Kumar 29477dc82e [Blocks] Inherit sanitizer options from parent decl
There is no way to apply sanitizer suppressions to ObjC blocks. A
reasonable default is to have blocks inherit their parent's sanitizer
options.

rdar://32769634

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

llvm-svn: 320132
2017-12-08 02:47:58 +00:00
Aaron Ballman 1c30924420 Add a test that the __STDC_VERSION__ macro reports the correct value for -std=c17.
llvm-svn: 320131
2017-12-08 02:39:26 +00:00
Vedant Kumar 36347d917f [ubsan] Use pass_object_size info in bounds checks
Teach UBSan's bounds check to opportunistically use pass_object_size
information to check array accesses.

rdar://33272922

llvm-svn: 320128
2017-12-08 01:51:47 +00:00
Richard Smith 6a7513e2cd Fold together the in-range and out-of-range portions of -Wtautological-compare.
llvm-svn: 320124
2017-12-08 01:00:27 +00:00
Richard Smith bf0ad43503 Unify implementation of our two different flavours of -Wtautological-compare.
In so doing, fix a handful of remaining bugs where we would report false
positives or false negatives if we promote a signed value to an unsigned type
for the comparison.

llvm-svn: 320122
2017-12-08 00:45:25 +00:00
Aaron Ballman 7c18159bb5 Correct line endings that got mixed up in r320088; NFC.
llvm-svn: 320115
2017-12-07 23:10:09 +00:00
Ahmed Bougacha d8f0e6caa9 Fix more line endings changed in r320089. NFC.
llvm-svn: 320114
2017-12-07 23:08:46 +00:00
Aaron Ballman 29dc5ded45 Correct line endings that got mixed up in r320089; NFC.
llvm-svn: 320113
2017-12-07 23:04:11 +00:00
Ahmed Bougacha 100a0eedc0 Remove line-endings added by r320089. NFC.
llvm-svn: 320112
2017-12-07 22:58:02 +00:00
Eugene Zelenko 38c70521ff [Analysis] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).
llvm-svn: 320091
2017-12-07 21:55:09 +00:00
Aaron Ballman 5b6c0f75e0 Add new language mode flags for C17.
This adds -std=c17, -std=gnu17, and -std=iso9899:2017 as language mode flags for C17 and updates the value of __STDC_VERSION__ to the value based on the C17 FDIS. Given that this ballot cannot succeed until 2018, it is expected that we (and GCC) will add c18 flags as aliases once the ballot passes.

llvm-svn: 320089
2017-12-07 21:46:26 +00:00