Commit Graph

47465 Commits

Author SHA1 Message Date
Adam Nemet 03af42444b Don't pass FPOpFusion::Strict to the backend
This restores the behavior prior to D31167 where the code-gen default was
FPC_On which mapped to FPOpFusion::Standard.  After merging the FE
state (on/off) and the code-gen state (on/fast/off), the default became off to
match the front-end.

In other words, the front-end controls when to fuse along the language
standards and the backend shouldn't override this by splitting fused
intrinsics as FPOpFusion::Strict would imply.

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

llvm-svn: 300858
2017-04-20 17:09:35 +00:00
Krasimir Georgiev e48c1b564f Delete unused IncompleteFormat variable, NFCi.
llvm-svn: 300841
2017-04-20 13:37:27 +00:00
Alex Lorenz f6071c34a5 [index] Record class template specializations using a new 'SpecializationOf'
relationship

rdar://31603531

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

llvm-svn: 300832
2017-04-20 10:43:22 +00:00
Alex Lorenz 472cc79086 Add #pragma clang attribute support to the availability attribute
rdar://31707804

llvm-svn: 300826
2017-04-20 09:35:02 +00:00
Leslie Zhai ff04109ca2 [AVR] Add -mmcu option to the driver
A patch by Peter Wu!

Reviewers: jroelofs, xiangzhai

Reviewed By: jroelofs, dylanmckay, xiangzhai

Subscribers: dlj, dylanmckay, cfe-commits

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

llvm-svn: 300818
2017-04-20 04:23:24 +00:00
Richard Smith 479ba8ee0e PR32673: Don't wrap parameter packs in SubstTemplateTypeParmPackType nodes when forming implicit deduction guides.
Doing so thwarts template type deduction. Instead, substitute the pack directly
by picking "slice 0" of the resulting expansion.

llvm-svn: 300805
2017-04-20 01:15:31 +00:00
Shoaib Meenai a90474544e [Sema] Use MSVC inner class behavior on Itanium
Windows Itanium aims to use MSVC export and import semantics. Inner
class members shouldn't be exported on a dllexport explicit
instantiation definition of the outer class, and they shouldn't be
imported on a dllimport explicit instantiation declaration of the outer
class (instead a local copy should be emitted). We were doing the first
but not the second, and this mismatch can lead to link errors. Fix the
behavior and add tests for both.

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

llvm-svn: 300804
2017-04-20 01:11:42 +00:00
Carlo Bertolli ffafe10fac [OpenMP] Prepare sema to support combined constructs with omp distribute and omp for
https://reviews.llvm.org/D32237

This patch prepares sema with additional fields to support all those composite and combined constructs of OpenMP that include pragma 'distribute' and 'for', such as 'distribute parallel for'. It also extends the regression tests for 'distribute parallel for' and adds a new one.

llvm-svn: 300802
2017-04-20 00:39:39 +00:00
Kostya Serebryany 1c0e9e98c0 [sanitizer-coverage] deprecate -fsanitize-coverage=trace-bb
llvm-svn: 300767
2017-04-19 21:31:11 +00:00
Erich Keane 4b87d81068 Corrrect warn_unused_result attribute
The original idea was that if the attribute on an operator, 
that the return-value unused-ness wouldn't matter. However, 
all of the operators except postfix inc/dec return 
references! References don't result in this warning 
anyway, so those are already excluded.

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

llvm-svn: 300764
2017-04-19 21:24:55 +00:00
Richard Smith ada0888a11 Fix assertion failure in codegen on non-template deduction guide.
llvm-svn: 300762
2017-04-19 21:15:45 +00:00
Craig Topper 61e14d8dfe [CodeGen] Use preincrement version of APInt::operator++ instead of postincrement to avoid creating and immediately discarding a temporary APInt.
This is preparation for a clang change to improve the [[nodiscard]] warning to not be ignored on methods that return a class marked [[nodiscard]] that are defined in the class itself. See D32207.

llvm-svn: 300756
2017-04-19 21:02:45 +00:00
Kostya Serebryany 1a02d8bc8d [sanitizer-coverage] deprecate -fsanitize-coverage=8bit-counters
llvm-svn: 300744
2017-04-19 20:15:58 +00:00
David Blaikie 6e2ec5f10e Parse backend options during thinlto backend compile actions
llvm-svn: 300741
2017-04-19 20:08:21 +00:00
Kostya Serebryany 9d1ed13b53 [sanitizer-coverage] deprecate some of the stale coverage variants
llvm-svn: 300738
2017-04-19 19:57:16 +00:00
Vedant Kumar f224d707df [Coverage] Don't emit mappings for functions in dependent contexts (fixes PR32679)
The coverage implementation marks functions which won't be emitted as
'deferred', so that it can emit empty coverage regions for them later
(once their linkages are known).

Functions in dependent contexts are an exception: if there isn't a full
instantiation of a function, it shouldn't be marked 'deferred'. We've
been breaking that rule without much consequence because we just ended
up with useless, extra, empty coverage mappings. With PR32679, this
behavior finally caused a crash, because clang marked a partial template
specialization as 'deferred', causing the MS mangler to choke in its
delayed-template-parsing mode:

  error: cannot mangle this template type parameter type yet
  (http://bugs.llvm.org/show_bug.cgi?id=32679)

Fix this by checking if a decl's context is a dependent context before
marking it 'deferred'.

Based on a patch by Adam Folwarczny!

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

llvm-svn: 300723
2017-04-19 17:58:30 +00:00
Akira Hatanaka 3901377c22 [Sema][ObjC] Disallow jumping into ObjC fast enumeration loops.
rdar://problem/31635406

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

llvm-svn: 300722
2017-04-19 17:54:08 +00:00
Reid Kleckner 9d16fa09c6 Prefer addAttr(Attribute::AttrKind) over the AttributeList overload
This should simplify the call sites, which typically want to tweak one
attribute at a time. It should also avoid creating ephemeral
AttributeLists that live forever.

llvm-svn: 300718
2017-04-19 17:28:52 +00:00
Alex Lorenz 24952fbc6f Add #pragma clang attribute support to the external_source_symbol attribute
Prior to this commit the external_source_symbol attribute wasn't supported by
#pragma clang attribute for the following two reasons:

- The Named attribute subject hasn't been supported by TableGen.
- There was no way to specify a subject match rule for #pragma clang attribute
 that could operate on a set of attribute subjects (e.g. the ones that derive
 from NamedDecl).

This commit fixes the two issues and thus adds external_source_symbol support to
#pragma clang attribute.

rdar://31169028

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

llvm-svn: 300712
2017-04-19 15:52:11 +00:00
Gabor Horvath 10a837a27e Remove unnecessary condition as suggested by clang-tidy. NFC
Patch by: Gergely Angeli!

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

llvm-svn: 300703
2017-04-19 15:11:10 +00:00
Jonas Hahnfeld 8ea76fa9b4 [Driver] Unify linking of OpenMP runtime. NFCI.
While at it, extend test for FreeBSD and check for -lrt iff on Linux.

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

llvm-svn: 300689
2017-04-19 13:55:39 +00:00
Roger Ferrer Ibanez cb89513bc7 Avoid assert when a non-static member function is qualified with __unaligned
Under -fms-extensions __unaligned is a type-qualifier that can be applied to a
non-static member function declaration.

This causes an assertion when mangling the name under Itanium, where that
qualifier is not mangled.

This patch justs makes the minimal change to avoid the crash and avoid mangling
__unaligned, as it currently happens with non-member functions.

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

llvm-svn: 300686
2017-04-19 12:23:28 +00:00
Alex Lorenz 1be800c511 Add support for editor placeholders to Clang
This commit teaches Clang to recognize editor placeholders that are produced
when an IDE like Xcode inserts a code-completion result that includes a
placeholder. Now when the lexer sees a placeholder token, it emits an
'editor placeholder in source file' error and creates an identifier token
that represents the placeholder. The parser/sema can now recognize the
placeholders and can suppress the diagnostics related to the placeholders. This
ensures that live issues in an IDE like Xcode won't get spurious diagnostics
related to placeholders.

This commit also adds a new compiler option named '-fallow-editor-placeholders'
that silences the 'editor placeholder in source file' error. This is useful
for an IDE like Xcode as we don't want to display those errors in live issues.

rdar://31581400

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

llvm-svn: 300667
2017-04-19 08:58:56 +00:00
Daniel Jasper 47d58ea681 clang-format: Properly match parens of macro parameter lists.
No tests yet, but this will be tested by the upcoming:
https://reviews.llvm.org/D28462

llvm-svn: 300661
2017-04-19 06:06:38 +00:00
Chandler Carruth bd186c0787 Revert r300653 and r300650. The underlying commit fixes one issue with
modules but exposes much more widespread issues. Example and more
information is on the review thread for r300650.

Original commit summary:
[modules] Properly look up the owning module for an instantiation of a merged template.

llvm-svn: 300659
2017-04-19 05:25:13 +00:00
Craig Topper 73daaa8fb2 [CodeGen] Use APInt::lshrInPlace instead of APInt::lshr. NFC
llvm-svn: 300658
2017-04-19 05:17:33 +00:00
Richard Smith eb86173f7b Fix member function call with null 'this' pointer.
llvm-svn: 300653
2017-04-19 02:19:21 +00:00
Richard Smith 5aacc4021b [modules] Properly look up the owning module for an instantiation of a merged template.
When looking for the template instantiation pattern of a templated entity,
consistently select the definition of the pattern if there is one. This means
we'll pick the same owning module when we start instantiating a template that
we'll later pick when determining which modules are visible during that
instantiation.

llvm-svn: 300650
2017-04-19 01:36:43 +00:00
Reid Kleckner cdd26794a9 Use less temporary AttributeLists NFC
llvm-svn: 300628
2017-04-18 23:50:03 +00:00
Richard Smith 34e485f922 [modules-ts] Fold together -x c++ and -x c++-module at -cc1 level.
The driver needs to know whether it's building a module interface or
implementation unit because it affects which outputs it produces and how it
builds the command pipeline. But the frontend doesn't need to know and should
not care: all it needs to know is what action it is being asked to perform on
the input.

(This is in preparation for permitting -emit-obj to be used on a module
interface unit to produce object code without going via a "full" PCM file.)

llvm-svn: 300611
2017-04-18 21:55:37 +00:00
Richard Smith 4c132e576b Do not warn about whitespace between ??/ trigraph and newline in line comments if trigraphs are disabled in the current language.
llvm-svn: 300609
2017-04-18 21:45:04 +00:00
Vassil Vassilev a0320b97fa PR30508: Downgrade error to warning if the umbrella folder doesn't exist.
Patch by Yuka Takahashi (D32119)!

llvm-svn: 300594
2017-04-18 20:57:29 +00:00
Alex Lorenz 26b476502c The SubjectMatchRule enum should not be used as a DenseMap key to avoid
UBSAN 'invalid value' failures

The commit r300556 introduced a UBSAN issue that was caught by
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap. The DenseMap
failed to create an empty/tombstone value as the empty/tombstone values for the
SubjectMatchRule enum were not valid enum constants.

llvm-svn: 300591
2017-04-18 20:54:23 +00:00
Ekaterina Romanova 0a40d67b20 [DOXYGEN] Minor improvements in doxygen comments.
- To be consistent with the rest of the intrinsics headers, I removed the tags <i> .. </i> for marking instruction names in italics in in smmintrin.h. 

- Formatting changes to fit into 80 characters. 

I got an OK from Eric Christopher to commit doxygen comments without prior code
review upstream.

llvm-svn: 300578
2017-04-18 19:44:07 +00:00
Reid Kleckner cc7a035a2e Remove unused varible
The Result variable is unused both in Sema::CheckARMBuiltinFunctionCall
and Sema::CheckAArch64BuiltinFunctionCall, remove it.

Patch by Wei-Ren Chen!

Reviewers: craig.topper, rnk

Reviewed By: rnk

Subscribers: aemerson, cfe-commits, rengolin

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

llvm-svn: 300572
2017-04-18 17:44:41 +00:00
Manoj Gupta bb75b35811 [AArch64][clang] Pass cpu/arch information to assembler for AArch64.
Summary:
Pass Cpu/Arch options to assembler for AArch64 with no-integrated-as.
This fixes PR20019.

Reviewers: richard.barton.arm, kristof.beyls, rengolin

Reviewed By: rengolin

Subscribers: srhines, pirama, aemerson, rengolin, cfe-commits

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

llvm-svn: 300571
2017-04-18 17:36:10 +00:00
Alex Lorenz 47fd10c3b5 [ASTPrinter] Print template parameter lists for out-of-line functions
llvm-svn: 300560
2017-04-18 15:12:34 +00:00
Alex Lorenz 9e7bf161ea Add #pragma clang attribute
This is a recommit of r300539 that was reverted in r300543 due to test failures.
The original commit message is displayed below:

The new '#pragma clang attribute' directive can be used to apply attributes to
multiple declarations. An attribute must satisfy the following conditions to
be supported by the pragma:
- It must have a subject list that's defined in the TableGen file.
- It must be documented.
- It must not be late parsed.
- It must have a GNU/C++11 spelling.

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

llvm-svn: 300556
2017-04-18 14:33:39 +00:00
Martell Malone f9799c70a3 Driver: Better detection of mingw-gcc
Stop blindly searching for "gcc.exe" on windows.
Stop assuming "/usr" on unix, fixes cross compiling.

Reviewers: mati865, yaron.keren

Subscribers: ismail, rnk

Differential revision: https://reviews.llvm.org/D15005

llvm-svn: 300555
2017-04-18 14:27:36 +00:00
Oliver Stannard 692dc54b0d [ARM] Add hardware build attributes in assembler
This passes an option to the ARM assembly parser to emit build
attributes for the hardware selected by command line options, when
assembling an assembly file.

This is not enabled for C/C++, as this would result in duplicate build
attribute directives being emitted in each inline assembly block, when
emitting assembly.

This also adds an option to allow disabling this behaviour for assembly
files, for users who were relying on the old behaviour.

Differential revision: https://reviews.llvm.org/D31813

llvm-svn: 300550
2017-04-18 13:21:05 +00:00
Oliver Stannard 233310f3e6 [ARM,AArch64] Define __ELF__ for arm-none-eabihf and AArch64
This macro is defined for arm-none-eabi as of r266625, but it should also be
defined for eabihf and aarch64.

llvm-svn: 300549
2017-04-18 13:12:36 +00:00
Alex Lorenz 3bfe962afa Revert r300539 - Add #pragma clang attribute
Some tests fail on the Windows buildbots. I will have to investigate more.
This commit reverts r300539, r300540 and r300542.

llvm-svn: 300543
2017-04-18 10:46:41 +00:00
Alex Lorenz 787fbd7add Fix one more 'not all control paths return a value' MSVC warning
The warning was caused by r300539.

llvm-svn: 300542
2017-04-18 10:17:41 +00:00
Alex Lorenz 0a849f47d2 Add #pragma clang attribute
The new '#pragma clang attribute' directive can be used to apply attributes to
multiple declarations. An attribute must satisfy the following conditions to
be supported by the pragma:
- It must have a subject list that's defined in the TableGen file.
- It must be documented.
- It must not be late parsed.
- It must have a GNU/C++11 spelling.

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

llvm-svn: 300539
2017-04-18 09:41:47 +00:00
Eric Fiselier c512875ff6 Assert that a valid operator new/delete signature is always found by the coroutine body
llvm-svn: 300529
2017-04-18 05:30:39 +00:00
Eric Fiselier f747f53238 Speculatively attempt to fix bot failures caused by recent coroutine changes.
llvm-svn: 300528
2017-04-18 05:08:08 +00:00
Eric Fiselier f692e7db51 [coroutines] Fix building of new/delete expressions when get_return_object_on_allocation_failure() is present.
Summary:
This patch implements [dcl.fct.def.coroutine]p8:
> The unqualified-id get_return_object_on_allocation_failure is looked up in the scope of
> class P by class member access lookup (3.4.5). If a declaration is found, ..., and if a 
> global allocation function is selected, the ::operator new(size_t, nothrow_t) form shall be used.
> [...]
> The allocation function used in this case must have a non-throwing noexcept-specification.

Reviewers: GorNishanov, rsmith, majnemer, aaron.ballman

Reviewed By: GorNishanov

Subscribers: cfe-commits

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

llvm-svn: 300524
2017-04-18 03:12:48 +00:00
Adrian Prantl c3782a1a6f Debug Info: Remove special-casing of indirect function argument handling.
LLVM has changed the semantics of dbg.declare for describing function
arguments. After this patch a dbg.declare always takes the *address*
of a variable as the first argument, even if the argument is not an
alloca.

https://bugs.llvm.org/show_bug.cgi?id=32382
rdar://problem/31205000

llvm-svn: 300523
2017-04-18 01:22:01 +00:00
Richard Smith 1d2ae94b5d Fix mishandling of escaped newlines followed by newlines or nuls.
Previously, if an escaped newline was followed by a newline or a nul, we'd lex
the escaped newline as a bogus space character. This led to a bunch of
different broken corner cases:

For the pattern "\\\n\0#", we would then have a (horizontal) space whose
spelling ends in a newline, and would decide that the '#' is at the start of a
line, and incorrectly start preprocessing a directive in the middle of a
logical source line. If we were already in the middle of a directive, this
would result in our attempting to process multiple directives at the same time!
This resulted in crashes, asserts, and hangs on invalid input, as discovered by
fuzz-testing.

For the pattern "\\\n" at EOF (with an implicit following nul byte), we would
produce a bogus trailing space character with spelling "\\\n". This was mostly
harmless, but would lead to clang-format getting confused and misformatting in
rare cases. We now produce a trailing EOF token with spelling "\\\n",
consistent with our handling for other similar cases -- an escaped newline is
always part of the token containing the next character, if any.

For the pattern "\\\n\n", this was somewhat more benign, but would produce an
extraneous whitespace token to clients who care about preserving whitespace.
However, it turns out that our lexing for line comments was relying on this bug
due to an off-by-one error in its computation of the end of the comment, on the
slow path where the comment might contain escaped newlines.

llvm-svn: 300515
2017-04-17 23:44:51 +00:00
Eric Fiselier 47ee0f4d31 Revert r300504 - [coroutines] Fix rebuilding of implicit and dependent coroutine statements.
I have no idea what's happening here. The tests that fail on all of the bots
pass on my machine. Further investigation needed.

llvm-svn: 300511
2017-04-17 22:40:44 +00:00
Vedant Kumar dbbdda4d23 [ubsan] Skip null checks if they are constant-folded away
The IR builder can constant-fold null checks if the pointer operand
points to a constant. If the "is-non-null" check is folded away to
"true", don't emit the null check + branch.

Testing: check-clang, check-ubsan.

This slightly reduces the amount of null checks we emit when compiling
X86ISelLowering.cpp. Here are the numbers from patched/unpatched clangs
based on r300371.

  -------------------------------------
  | Setup          | # of null checks |
  -------------------------------------
  | unpatched, -O0 |            25251 |
  | patched, -O0   |            23925 | (-5.3%)
  -------------------------------------

llvm-svn: 300509
2017-04-17 22:26:10 +00:00
Vedant Kumar 379d9c1dc6 [ubsan] Skip null checks on pointers to the start of an alloca
Pointers to the start of an alloca are non-null, so we don't need to
emit runtime null checks for them.

Testing: check-clang, check-ubsan.

This significantly reduces the amount of null checks we emit when
compiling X86ISelLowering.cpp. Here are the numbers from patched /
unpatched clangs based on r300371.

  -------------------------------------
  | Setup          | # of null checks |
  -------------------------------------
  | unpatched, -O0 |            45439 |
  | patched, -O0   |            25251 | (-44.4%)
  -------------------------------------

llvm-svn: 300508
2017-04-17 22:26:07 +00:00
Eric Fiselier fb289ecde0 [coroutines] Fix rebuilding of implicit and dependent coroutine statements.
Summary:
Certain implicitly generated coroutine statements, such as the calls to 'return_value()' or `return_void()` or `get_return_object_on_allocation_failure()`, cannot be built until the promise type is no longer dependent. This means they are not built until after the coroutine body statement has been transformed.

This patch fixes an issue where these statements would never be built for coroutine templates.

It also fixes a small issue where diagnostics about `get_return_object_on_allocation_failure()` were incorrectly suppressed. 

Reviewers: rsmith, majnemer, GorNishanov, aaron.ballman

Reviewed By: GorNishanov

Subscribers: cfe-commits

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

llvm-svn: 300504
2017-04-17 22:06:13 +00:00
Benjamin Kramer dcb52b167a Revert "Address http://bugs.llvm.org/pr30994 so that a non-friend can properly replace a friend, and a visible friend can properly replace an invisible friend but not vice verse, and definitions are not replaced. This fixes the two FIXME in SemaTemplate/friend-template.cpp."
This reverts commit r300443. Breaks compiling libc++ with modules in
some configurations.

llvm-svn: 300497
2017-04-17 20:57:40 +00:00
Yaxun Liu d7523283a7 CodeGen: Let byval parameter use alloca address space
Differential Revision: https://reviews.llvm.org/D32133

llvm-svn: 300487
2017-04-17 20:10:44 +00:00
Yaxun Liu 7f7f323e4f CodeGen: Let lifetime intrinsic use alloca address space
Differential Revision: https://reviews.llvm.org/D31717

llvm-svn: 300485
2017-04-17 20:03:11 +00:00
David Blaikie 0a0c033295 Use default ref capture to simplify local lambdas, use a template to avoid std::function overhead, other cleanup
llvm-svn: 300461
2017-04-17 17:16:19 +00:00
Akira Hatanaka b5d1ea44af [ObjC] Mark loads from __NSArray0 and __NSDictionary0 as invariant.load.
Also, simplify code by calling MakeNaturalAlignAddrLValue.

This is a follow-up to r300396.

llvm-svn: 300454
2017-04-17 15:21:55 +00:00
Yaron Keren 27e2ff964f Address http://bugs.llvm.org/pr30994 so that a non-friend can properly replace a friend, and a visible friend can properly replace an invisible friend but not vice verse, and definitions are not replaced. This fixes the two FIXME in SemaTemplate/friend-template.cpp.
The code implements Richard Smith suggestion in comment 3 of the PR.

reviewer: Vassil Vassilev

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

llvm-svn: 300443
2017-04-17 08:51:20 +00:00
Alexander Shaposhnikov ae33dfac6e [clang] Register isConstexpr matcher
This diff registers isConstexpr matcher.

Test plan:
make check-all
check that "match varDecl(isConstexpr())" 
works in clang-query

Differential revision: https://reviews.llvm.org/D32112

llvm-svn: 300427
2017-04-16 19:05:17 +00:00
Yaron Keren 9370ea2058 Use setUsedForHeaderGuard() accessor function instead of direcly accessing UsedForHeaderGuard.
llvm-svn: 300423
2017-04-16 15:53:19 +00:00
Eric Fiselier 1bcc937b56 Revert r300420 - [coroutines] Fix building of new/delete expressions when get_return_object_on_allocation_failure() is present
llvm-svn: 300421
2017-04-16 09:34:28 +00:00
Eric Fiselier 627a63cf50 [coroutines] Fix building of new/delete expressions when get_return_object_on_allocation_failure() is present.
Summary:
This patch implements [dcl.fct.def.coroutine]p8:
> The unqualified-id get_return_object_on_allocation_failure is looked up in the scope of
> class P by class member access lookup (3.4.5). If a declaration is found, ..., and if a 
> global allocation function is selected, the ::operator new(size_t, nothrow_t) form shall be used.
> [...]
> The allocation function used in this case must have a non-throwing noexcept-specification.

Reviewers: GorNishanov, rsmith, majnemer, aaron.ballman

Reviewed By: GorNishanov

Subscribers: cfe-commits

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

llvm-svn: 300420
2017-04-16 09:19:59 +00:00
Aaron Ballman 565019ff32 Add isStaticStorageClass to the dynamic matcher registry so that it can be used from clang-query.
Patch by Dave Lee.

llvm-svn: 300400
2017-04-15 12:53:20 +00:00
Akira Hatanaka 4d53a1cb31 [ObjC] Use empty Objective-C collection literal constants when
available.

Original patch by Douglas Gregor with minor modifications.

This recommits r300389, which broke bots because there have been API
changes since the original patch was written.

rdar://problem/20689633

llvm-svn: 300396
2017-04-15 06:42:00 +00:00
Eric Christopher d26d8839d8 When we turn on vsx it should also turn on altivec explicitly, same
with disabling it as well as disabling all vsx specific features when
turning off altivec.

Fixes PR32663.

llvm-svn: 300395
2017-04-15 06:15:00 +00:00
Akira Hatanaka f8a27a96e2 Revert "[ObjC] Use empty Objective-C collection literal constants when"
This reverts commit r300389. There were mistakes in the changes I made
to CodeGen.

llvm-svn: 300391
2017-04-15 05:44:27 +00:00
Akira Hatanaka dad5266044 [ObjC] Use empty Objective-C collection literal constants when
available.

Original patch by Douglas Gregor with minor modifications.

rdar://problem/20689633

llvm-svn: 300389
2017-04-15 05:31:35 +00:00
Vedant Kumar 8a767a430d [Coverage] Use the new getInstrProfSectionName API (NFC)
llvm-svn: 300382
2017-04-15 00:10:05 +00:00
Duncan P. N. Exon Smith 03df14c6dd Modules: Do not serialize #pragma pack state
The modules side of r299226, which serializes #pragma pack state,
doesn't work well.

The main purpose was to make -include and -include-pch match semantics
(the PCH side).  We also started serializing #pragma pack in PCMs, in
the hopes of making modules and non-modules builds more consistent.  But
consider:

    $ cat a.h
    $ cat b.h
    #pragma pack(push, 2)
    $ cat module.modulemap
    module M {
        module a { header "a.h" }
        module b { header "b.h" }
    }
    $ cat t.cpp
    #include "a.h"
    #pragma pack(show)

As of r299226, the #pragma pack(show) gives "2", even though we've only
included "a.h".

- With -fmodules-local-submodule-visibility, this is clearly wrong.  We
  should get the default state (8 on x86_64).

- Without -fmodules-local-submodule-visibility, this kind of matches how
  other things work (as if include-the-whole-module), but it's still
  really terrible, and it doesn't actually make modules and non-modules
  builds more consistent.

This commit disables the serialization for modules, essentially a
partial revert of r299226.

Going forward:

 1. Having this #pragma pack stuff escape is terrible design (or, more
    often, a horrible bug).  We should prioritize adding warnings (maybe
    -Werror by default?).

 2. If we eventually reintroduce this for modules, it should only apply
    to -fmodules-local-submodule-visibility, and it should be tracked on
    a per-submodule basis.

llvm-svn: 300380
2017-04-15 00:07:57 +00:00
Vedant Kumar 116aebcae0 [ubsan] Don't check alignment if the alignment is 1
If a pointer is 1-byte aligned, there's no use in checking its
alignment. Somewhat surprisingly, ubsan can spend a significant amount
of time doing just that!

This loosely depends on D30283.

Testing: check-clang, check-ubsan, and a stage2 ubsan build.

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

llvm-svn: 300371
2017-04-14 22:03:37 +00:00
Vedant Kumar ffd7c887d6 [ubsan] Reduce alignment checking of C++ object pointers
This patch teaches ubsan to insert an alignment check for the 'this'
pointer at the start of each method/lambda. This allows clang to emit
significantly fewer alignment checks overall, because if 'this' is
aligned, so are its fields.

This is essentially the same thing r295515 does, but for the alignment
check instead of the null check. One difference is that we keep the
alignment checks on member expressions where the base is a DeclRefExpr.
There's an opportunity to diagnose unaligned accesses in this situation
(as pointed out by Eli, see PR32630).

Testing: check-clang, check-ubsan, and a stage2 ubsan build.

Along with the patch from D30285, this roughly halves the amount of
alignment checks we emit when compiling X86FastISel.cpp. Here are the
numbers from patched/unpatched clangs based on r298160.

  ------------------------------------------
  | Setup          | # of alignment checks |
  ------------------------------------------
  | unpatched, -O0 |                 24326 |
  | patched, -O0   |                 12717 | (-47.7%)
  ------------------------------------------

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

llvm-svn: 300370
2017-04-14 22:03:34 +00:00
Kuba Mracek 5e5e4e790f [ObjC] Fix lifetime markers of loop variable in EmitObjCForCollectionStmt [take 2]
CodeGenFunction::EmitObjCForCollectionStmt currently emits lifetime markers for the loop variable in an inconsistent way:  lifetime.start is emitted before the loop is entered, but lifetime.end is emitted inside the loop. AddressSanitizer uses these markers to track out-of-scope accesses to local variables, and we get false positives in Obj-C foreach loops (in the 2nd iteration of the loop). This patch keeps the loop variable alive for the whole loop by extending ForScope and registering the cleanup function inside EmitAutoVarAlloca.

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

llvm-svn: 300340
2017-04-14 16:53:25 +00:00
Erich Keane 750fe2220e Make Gentoo GNU GCC Config override whitespace tolerant
The config-*triple* file handling isn't tolerant of 
leading/trailing whitespace, making it not terribly 
obvious when a single extraneous tab/space/etc will 
cause the override to be ignored. This patch simply 
trims the lines to ensure that it is tolerant of 
whitespace.

llvm-svn: 300328
2017-04-14 15:21:18 +00:00
Simon Pilgrim 9f6e79c5e4 [X86][SSE] Update MOVNTDQA non-temporal loads to generic implementation (clang)
MOVNTDQA non-temporal aligned vector loads can be correctly represented using generic builtin loads, allowing us to remove the existing x86 intrinsics.

LLVM companion patch: D31767.

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

llvm-svn: 300326
2017-04-14 15:05:57 +00:00
Vassil Vassilev 1a1678e7eb PR32280: Do not crash on nested initializers.
Patch by Yuka Takahashi (D31591)!

llvm-svn: 300313
2017-04-14 08:48:08 +00:00
Konstantin Zhuravlyov e668b1cd1e [AMDGPU][GFX9] Set +fp32-denormals for >=gfx900 unless -cl-denorms-are-zero is set
Differential Revision: https://reviews.llvm.org/D31482

llvm-svn: 300306
2017-04-14 05:33:57 +00:00
Xinliang David Li 1f39fcf26d Fix use after free error
llvm-svn: 300304
2017-04-14 04:14:29 +00:00
Xinliang David Li 3e8257e48e Remove unused function /nfc
llvm-svn: 300301
2017-04-14 03:01:25 +00:00
Kuba Mracek 82c2175793 Revert r300287.
llvm-svn: 300290
2017-04-14 01:00:03 +00:00
Kuba Mracek 8f56846d4f [ObjC] Fix lifetime markers of loop variable in EmitObjCForCollectionStmt
CodeGenFunction::EmitObjCForCollectionStmt currently emits lifetime markers for the loop variable in an inconsistent way:  lifetime.start is emitted before the loop is entered, but lifetime.end is emitted inside the loop.  AddressSanitizer uses these markers to track out-of-scope accesses to local variables, and we get false positives in Obj-C foreach loops (in the 2nd iteration of the loop). The markers of the loop variable need to be either both inside the loop (so that we poison and unpoison the variable in each iteration), or both outside. This patch implements the "both inside" approach.

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

llvm-svn: 300287
2017-04-14 00:32:43 +00:00
George Burgess IV cfd48d93d3 Fix PR31934: forming refs to functions with enable_if attrs.
llvm-svn: 300283
2017-04-13 23:47:08 +00:00
Xinliang David Li f0e879dffd [Profile] PE binary coverage bug fix
PR/32584

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

llvm-svn: 300279
2017-04-13 23:37:21 +00:00
Reid Kleckner f021fab2af [IR] Make getParamAttributes take argument numbers, not ArgNo+1
Add hasParamAttribute() and use it instead of hasAttribute(ArgNo+1,
Kind) everywhere.

The fact that the AttributeList index for an argument is ArgNo+1 should
be a hidden implementation detail.

NFC

llvm-svn: 300272
2017-04-13 23:12:13 +00:00
Richard Smith cf681266e6 Diagnose attempt to take address of bitfield members in anonymous structs.
Patch by Jacob Young!

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

llvm-svn: 300264
2017-04-13 21:49:46 +00:00
Richard Smith 1389418e18 PR32185: Revert r291512 and add a testcase for PR32185.
This reverts an attempt to check that types match when matching a
dependently-typed non-type template parameter. (This comes up when matching the
parameters of a template template parameter against the parameters of a
template template argument.)

The matching rules here are murky at best. Our behavior after this revert is
definitely wrong for certain C++17 features (for 'auto' template parameter
types within the parameter list of a template template argument in particular),
but our behavior before this revert is wrong for some pre-existing testcases,
so reverting to our prior behavior seems like our best option.

llvm-svn: 300262
2017-04-13 21:37:24 +00:00
Artem Dergachev 6dd11048f5 [analyzer] Enforce super-region classes for various memory regions.
We now check the type of the super-region pointer for most SubRegion classes
in compile time; some checks are run-time though.

This is an API-breaking change (we now require explicit casts to specific region
sub-classes), but in practice very few checkers are affected.

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

llvm-svn: 300189
2017-04-13 09:56:07 +00:00
Artem Dergachev b3241f41b2 [analyzer] Add numerous assertions to SVal, SymExpr, and MemRegion classes.
Clean up vtable anchors (remove anchors for regions that have regular
out-of-line virtual methods, add anchors for regions that don't have those).

Fix private/public methods (all constructors should now be private for leaf
classes, protected for abstract classes).

No functional change intended, only extra sanity checks and cleanups.

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

llvm-svn: 300187
2017-04-13 09:48:05 +00:00
Artem Dergachev 12294f8d2e [analyzer] Simplify values in binary operations a bit more aggressively.
SValBuilder tries to constant-fold symbols in the left-hand side of the symbolic
expression whenever it fails to evaluate the expression directly. However, it
only constant-folds them when they are atomic expressions, not when they are
complicated expressions themselves. This patch adds recursive constant-folding
to the left-hand side subexpression (there's a lack of symmetry because we're
trying to have symbols on the left and constants on the right). As an example,
we'd now be able to handle operations similar to "$x + 1 < $y", when $x is
constrained to a constant.

rdar://problem/31354676

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

llvm-svn: 300178
2017-04-13 07:20:04 +00:00
Reid Kleckner 7f72033e1c [IR] Take func, ret, and arg attrs separately in AttributeList::get
This seems like a much more natural API, based on Derek Schuff's
comments on r300015. It further hides the implementation detail of
AttributeList that function attributes come last and appear at index
~0U, which is easy for the user to screw up. git diff says it saves code
as well: 97 insertions(+), 137 deletions(-)

This also makes it easier to change the implementation, which I want to
do next.

llvm-svn: 300153
2017-04-13 00:58:09 +00:00
NAKAMURA Takumi 23ad196a22 ExternalASTMerger.cpp: Silence another warning. [-Wunused-lambda-capture]
llvm-svn: 300145
2017-04-13 00:17:28 +00:00
Richard Smith ac65f642a5 Update to match LLVM r300135.
Remove "REQUIRES: long_tests" from test/Driver/response-file.c since it is now about 10x faster. (We can add that back if it's still too slow for some buildbot.)

llvm-svn: 300136
2017-04-12 23:21:25 +00:00
Eric Fiselier 0736066b0b [Sema] Add __is_aggregate type-trait
Summary:
[LWG 2911](http://cplusplus.github.io/LWG/lwg-defects.html#2911) adds `std::is_aggregate` to the library, which requires a new builtin trait. This patch implements `__is_aggregate`.


Reviewers: rsmith, majnemer, aaron.ballman

Reviewed By: aaron.ballman

Subscribers: STL_MSFT, cfe-commits

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

llvm-svn: 300116
2017-04-12 22:12:15 +00:00
Alexander Shaposhnikov 5f24c12dc4 [analyzer] Add a check for IvarRegion in getExtraInvalidatedValues
This diff adds a defensive check in getExtraInvalidatedValues
for the case when there are no regions for the ivar associated with
a property. Corresponding test case added.

Test plan:
make check-clang
make check-clang-analysis

llvm-svn: 300114
2017-04-12 22:00:13 +00:00
Vassil Vassilev 46afbbb210 [modules] Delay calling DeclMustBeEmitted until it's safe.
This patch implements the suggestion in D29753 that calling DeclMustBeEmitted in
the middle of deserialization should be avoided and that the actual check should
be deferred until it's safe to do so.

This patch fixes a crash when accessing the invalid redecl chains while trying
to evaluate the value of a const VarDecl that contains a function call.

Patch by Raphael Isemann (D30793)!

llvm-svn: 300110
2017-04-12 21:56:05 +00:00
Bruno Cardoso Lopes 52dfe71645 [Driver] Add compiler option to generate a reproducer
One way to currently test the reproducers is to setup
"FORCE_CLANG_DIAGNOSTICS_CRASH=1" before invoking clang. This simulates
a crash and produces the same contents needed by the reproducers.  The
reproducers are specially useful when triaging Modules issues, not only
on crashes, but also for reproducing misleading warnings, errors, etc.

Add a '-gen-reproducer' driver option to clang (or any similar name) and
give users a flag option.

Note that clang already has a -fno-crash-diagnostics, which disables the
crash reproducers. I've decided not to propose "-fcrash-diagnostics"
since it doesn't convey the ideia of reproduction despite a crash.

rdar://problem/24114619

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

llvm-svn: 300109
2017-04-12 21:46:20 +00:00
Bruno Cardoso Lopes c69f9f3530 [Modules] Enable local submodule visibility for ObjC/C
Remove the restriction where this is only valid with C++

rdar://problem/29055656

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

llvm-svn: 300108
2017-04-12 21:46:16 +00:00
David Blaikie f63556d8b4 Modular Codegen: Separate flags for function and debug info support
This allows using and testing these two features separately. (noteably,
debug info is, so far as I know, always a win (basically). But function
modular codegen is currently a loss for highly optimized code - where
most of the linkonce_odr definitions are optimized away, so providing
weak_odr definitions is only overhead)

llvm-svn: 300104
2017-04-12 20:58:33 +00:00
Hans Wennborg 227077613a Revert r300001 "Revert r298824 & r298816, recommit r298742 & r298754"
It caused PR32640.

llvm-svn: 300074
2017-04-12 16:40:26 +00:00
Sanjay Patel bd0d0068ef [x86] fix AVX FP cmp intrinsic documentation (PR28110)
This copies the text used in the #define statements to the code comments. 
The conflicting text comes from AMD manuals, but those are wrong. Sadly, 
that FP cmp text has not been updated even after some docs were updated 
for Zen:
http://support.amd.com/en-us/search/tech-docs 
( AMD64 Architecture Programmer's Manual Volume 4 )

See PR28110 for more discussion:
https://bugs.llvm.org/show_bug.cgi?id=28110

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

llvm-svn: 300068
2017-04-12 15:19:08 +00:00
Alex Lorenz 53b4b1846d Add support for __builtin_available to __has_builtin
rdar://31576715

llvm-svn: 300049
2017-04-12 11:03:25 +00:00
Yaron Keren 31bde5863f Rangify for loop, NFC.
llvm-svn: 300043
2017-04-12 10:05:48 +00:00
Chandler Carruth 260161b8c5 Update Clang for an API change to LLVM's switch case iterator (it is now
an actual iterator and so we need to look through it to the case
handle).

llvm-svn: 300035
2017-04-12 08:12:30 +00:00
Bruno Cardoso Lopes 69cdc901f0 [Modules] Remove darwin specific code to check for SystemVersion.plist
This isn't need anymore and modules options -fbuild-session-file and
-fmodules-validate-once-per-build-session already provide a sane
mechanism to validate the system headers.

rdar://problem/19767523

llvm-svn: 300027
2017-04-12 04:49:00 +00:00
Duncan P. N. Exon Smith 900f817591 Serialization: Simulate -Werror settings in implicit modules
r293123 started serializing diagnostic pragma state for modules.  This
makes the serialization work properly for implicit modules.

An implicit module build (using Clang's internal build system) uses the
same PCM file location for different `-Werror` levels.

E.g., if a TU has `-Werror=format` and tries to load a PCM built without
`-Werror=format`, a new PCM will be built in its place (and the new PCM
should have the same signature, since r297655).  In the other direction,
if a TU does not have `-Werror=format` and tries to load a PCM built
with `-Werror=format`, it should "just work".

The idea is to evolve the PCM toward the strictest -Werror flags that
anyone tries.

r293123 started serializing the diagnostic pragma state for each PCM.
Since this encodes the -Werror settings at module-build time, it breaks
the implicit build model.

This commit filters the diagnostic state in order to simulate the
current compilation's diagnostic settings.  Firstly, it ignores the
module's serialized first diagnostic state, replacing it with the state
from this compilation's command-line.  Secondly, if a pragma warning was
upgraded to error/fatal when generating the PCM (e.g., due to `-Werror`
on the command-line), it checks whether it should still be upgraded in
its current context.

llvm-svn: 300025
2017-04-12 03:58:58 +00:00
Duncan P. N. Exon Smith a351c10df3 Serialization: Emit the final diagnostic state last, almost NFC
Emit the final diagnostic state last to match source order.  This also
prepares for a follow-up commit for implicit modules.

There's no real functionaliy change, just a slightly different AST file
format.

llvm-svn: 300024
2017-04-12 03:45:32 +00:00
Duncan P. N. Exon Smith f2435b9574 Serialization: Skip check in WritePragmaDiagnosticMappings, NFC
The record is never empty, since we always serialize the initial state.
Skip the check.

llvm-svn: 300021
2017-04-12 02:31:17 +00:00
Reid Kleckner c2cb560045 [IR] Add AttributeSet to hide AttributeSetNode* again, NFC
Summary:
For now, it just wraps AttributeSetNode*. Eventually, it will hold
AvailableAttrs as an inline bitset, and adding and removing enum
attributes will be super cheap.

This sinks AttributeSetNode back down to lib/IR/AttributeImpl.h.

Reviewers: pete, chandlerc

Subscribers: llvm-commits, jfb

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

llvm-svn: 300014
2017-04-12 00:38:00 +00:00
Benjamin Kramer 4ecc848ebd Silence unused variable warning in release builds.
llvm-svn: 300006
2017-04-11 23:06:49 +00:00
Richard Trieu 304ef22e6e Revert r298824 & r298816, recommit r298742 & r298754
r299989 fixes the underlying issue by waiting long enough to late parsed
arguments to be processed before doing an calculating the hash.

r298742
[ODRHash] Add error messages for mismatched parameters in methods.

r298754
[ODRHash] Add support for array and decayed types.

llvm-svn: 300001
2017-04-11 22:32:03 +00:00
Akira Hatanaka ad51539597 [Sema][ObjC] Check whether a variable has a definition, rather than
checking its storage class, when determining whether casting a C pointer
to an ObjC pointer is allowed.

This change allows casting variables whose declarations are directly
contained in a linkage specification to an ObjC pointer type. Those
variables are treated as if they contain the extern specifier for the
purpose of determining whether they are definitions or not.

rdar://problem/29249853

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

llvm-svn: 299992
2017-04-11 22:01:33 +00:00
Richard Trieu fd1acbb9bb [ODRHash] Improve handling of hash values
Calculating the hash in Sema::ActOnTagFinishDefinition could happen before
all sub-Decls were parsed or processed, which would produce the wrong hash
value.  Change to calculating the hash on the first use and storing the value
instead.  Also, avoid using the macros that were only for Boolean fields and
use an explicit checker during the DefintionData merge.  No functional change,
but was this blocking other ODRHash patches.

llvm-svn: 299989
2017-04-11 21:31:00 +00:00
David Blaikie 1ac9c98e6c Modular Codegen: Support homing debug info for types in modular objects
Matching the function-homing support for modular codegen. Any type
implicitly (implicit template specializations) or explicitly defined in
a module is attached to that module's object file and omitted elsewhere
(only a declaration used if necessary for references).

llvm-svn: 299987
2017-04-11 21:13:37 +00:00
Sean Callanan f8edb1de32 [ExternalASTMerger] Removed a move constructor to address MSVC build failure
llvm-svn: 299983
2017-04-11 20:51:21 +00:00
David Blaikie e6b7c28d17 Modular Codegen: Add/use a bit in serialized function definitions to track whether they are the subject of modular codegen
Some decls are created not where they are written, but in other module
files/users (implicit special members and function template implicit
specializations). To correctly identify them, use a bit next to the definition
to track the modular codegen property.

Discussed whether the module file bit could be omitted in favor of
reconstituting from the modular codegen decls list - best guess today is that
the efficiency improvement of not having to deserialize the whole list whenever
any function is queried by a module user is worth it for the small size
increase of this redundant (list + bit-on-def) representation.

Reviewers: rsmith

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

llvm-svn: 299982
2017-04-11 20:46:34 +00:00
Aaron Ballman 4c54fe0c7b Add const children() accessors to match the existing non-const children() accessors.
llvm-svn: 299981
2017-04-11 20:21:30 +00:00
Sean Callanan 4bb0d78c84 [ExternalASTMerger] Fix the MSVC build
llvm-svn: 299977
2017-04-11 19:50:37 +00:00
Sean Callanan b7160ca466 [clang-import-test] Lookup inside contexts
clang-import-test has until now been only able to report top-level Decls.
This is clearly insufficient; we should be able to look inside structs 
and namespaces also.  This patch adds new test cases for a variety of 
lookups inside existing ASTContexts, and adds the functionality necessar
to make most of these testcases work.  (One testcase is known to fail 
because of ASTImporter limitations when importing templates; I'll look 
into that separately.)

This patch also separates the core functionality out into 
ExternalASTMerger, an interface that allows clients like LLDB to make 
use of it.  clang-import-test now only has the machinery necessary to
set up the tests.

Differential revision: https://reviews.llvm.org/D30435

llvm-svn: 299976
2017-04-11 19:33:35 +00:00
Yaxun Liu b34ec829be [OpenCL] Map default address space to alloca address space
For OpenCL, the private address space qualifier is 0 in AST. Before this change, 0 address space qualifier
is always mapped to target address space 0. As now target private address space is specified by
alloca address space in data layout, address space qualifier 0 needs to be mapped to alloca addr space specified by the data layout.

This change has no impact on targets whose alloca addr space is 0.

With contributions from Matt Arsenault, Tony Tye and Wen-Heng (Jack) Chung

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

llvm-svn: 299965
2017-04-11 17:24:23 +00:00
Alex Lorenz a981c7d79e [ASTPrinter] Print nested name specifiers for out-of-line functions
rdar://31501863

llvm-svn: 299962
2017-04-11 16:46:03 +00:00
Vassil Vassilev c42bce8097 Revert temporarily D29877 "Warn about unused static file scope function template declarations."
We need to address cases (breaking libc++) such as

template <class _Up> static int __test(...);

template<typename _Tp>
auto v = __test<_Tp>(0);

llvm-svn: 299956
2017-04-11 16:05:23 +00:00
Nico Weber 48c94a6164 [clang-format] Recognize Java logical shift assignment operator
At present, clang-format mangles Java containing logical right shift operators
('>>>=' or '>>>'), splitting them in two, resulting in invalid code:

 public class Minimal {
   public void func(String args) {
     int i = 42;
-    i >>>= 1;
+    i >> >= 1;
     return i;
   }
 }

This adds both forms of logical right shift to the FormatTokenLexer, so
clang-format won't attempt to split them and insert bogus whitespace.

https://reviews.llvm.org/D31652
Patch from Richard Bradfield <bradfier@fstab.me>!

llvm-svn: 299952
2017-04-11 15:50:04 +00:00
Alex Lorenz 46103e0ede Fix PR13910: Don't warn that __builtin_unreachable() is unreachable
Differential Revision: https://reviews.llvm.org/D25321

llvm-svn: 299951
2017-04-11 15:36:06 +00:00
Alex Lorenz f127821140 [Parser][ObjC++] Improve diagnostics and recovery when C++ keywords are used
as identifiers in Objective-C++

This commit improves the 'expected identifier' errors that are presented when a
C++ keyword is used as an identifier in Objective-C++ by mentioning that this is
a C++ keyword in the diagnostic message. It also improves the error recovery:
the parser will now treat the C++ keywords as identifiers to prevent unrelated
parsing errors.

rdar://20626062

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

llvm-svn: 299950
2017-04-11 15:01:53 +00:00
Vassil Vassilev e63a39d6cb Warn about unused static file scope function template declarations.
Reviewed by Richard Smith (D29877)!

llvm-svn: 299930
2017-04-11 10:13:54 +00:00
Alexander Kornienko d4fa2e6348 [clang-format] Handle NSString literals by merging tokens.
Summary:
This fixes a few outstanding bugs:
  * incorrect breaking of NSString literals containing double-width characters;
  * inconsistent formatting of ObjC dictionary literals containing NSString
    literals;
  * AlwaysBreakBeforeMultilineStrings ignoring implicitly-concatenated NSString
    literals.

Reviewers: djasper

Reviewed By: djasper

Subscribers: klimek, cfe-commits

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

llvm-svn: 299927
2017-04-11 09:55:00 +00:00
Maxim Ostapenko 2084b6bcf8 [lsan] Enable LSan on arm Linux, clang part
This is a compiler part of https://reviews.llvm.org/D29586. Enable LSan on arm Linux.

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

llvm-svn: 299921
2017-04-11 07:22:11 +00:00
Reid Kleckner eb9dd5b87f Reland "[IR] Make AttributeSetNode public, avoid temporary AttributeList copies"
This re-lands r299875.

I introduced a bug in Clang code responsible for replacing K&R, no
prototype declarations with a real function definition with a prototype.
The bug was here:

       // Collect any return attributes from the call.
  -    if (oldAttrs.hasAttributes(llvm::AttributeList::ReturnIndex))
  -      newAttrs.push_back(llvm::AttributeList::get(newFn->getContext(),
  -                                                  oldAttrs.getRetAttributes()));
  +    newAttrs.push_back(oldAttrs.getRetAttributes());

Previously getRetAttributes() carried AttributeList::ReturnIndex in its
AttributeList. Now that we return the AttributeSetNode* directly, it no
longer carries that index, and we call this overload with a single node:
  AttributeList::get(LLVMContext&, ArrayRef<AttributeSetNode*>)

That aborted with an assertion on x86_32 targets. I added an explicit
triple to the test and added CHECKs to help find issues like this in the
future sooner.

llvm-svn: 299899
2017-04-10 23:31:05 +00:00
Matt Arsenault 502ad60c8f Update for AllocaInst construction changes
llvm-svn: 299889
2017-04-10 22:28:02 +00:00
Matt Arsenault d972949b10 Update for lifetime intrinsic signature change
llvm-svn: 299877
2017-04-10 20:18:45 +00:00
Alexey Bataev f7ce166220 [OPENMP] Fix for PR32333: Crash in call of outlined Function.
If the type of the captured variable is a pointer(s) to variably
modified type, this type was not processed correctly. Need to drill into
the type, find the innermost variably modified array type and convert it
to canonical parameter type.

llvm-svn: 299868
2017-04-10 19:16:45 +00:00
Evgeniy Stepanov 1a8030e737 [cfi] Emit __cfi_check stub in the frontend.
Previously __cfi_check was created in LTO optimization pipeline, which
means LLD has no way of knowing about the existence of this symbol
without rescanning the LTO output object. As a result, LLD fails to
export __cfi_check, even when given --export-dynamic-symbol flag.

llvm-svn: 299806
2017-04-07 23:00:38 +00:00
Saleem Abdulrasool 552629eaf4 Toolchains: remove crtbegin on xwindows
crtbegin is not really a proper windows support thing.  This was
duplicated when the toolchain was initially built.  If the injection of
crtbegin is needed, it can be done via the `/include` directive.
Furthermore, since `-fPIC` doesnt make sense on PE/COFF, crtbegin and
crtbeginS dont really need to be different.

llvm-svn: 299800
2017-04-07 20:47:06 +00:00
Hans Wennborg 5c3c51fe05 Implement _interlockedbittestandset as a builtin
It's used by MS headers in VS 2017 without including intrin.h, so we
can't implement it in the header anymore.

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

llvm-svn: 299782
2017-04-07 16:41:47 +00:00
Saleem Abdulrasool b51bcaf2f0 Sema: prevent __declspec(naked) use on x64
MSDN (https://msdn.microsoft.com/en-us/library/h5w10wxs.aspx) indicates
that `__declspec(naked)` is only permitted on x86 and ARM targets.
Testing with cl does confirm this behaviour.  Provide a warning for use
of `__declspec(naked)` on x64.

llvm-svn: 299774
2017-04-07 15:13:47 +00:00
Sanne Wouda db1bdf472a Skip Unicode character expansion in assembly files
Summary: When using the C preprocessor with assembly files, either with a
capital `S` file extension, or with `-xassembler-with-cpp`, the Unicode escape
sequence `\u` is ignored. The `\u` pattern can be used for expanding a macro
argument that starts with `u`.

Author: Salman Arif <salman.arif@arm.com>

Reviewers: rengolin, olista01

Reviewed By: olista01

Subscribers: cfe-commits

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

llvm-svn: 299754
2017-04-07 10:13:00 +00:00
Yaxun Liu b122ed9181 [AMDGPU] Temporarily change constant address space from 4 to 2 for the new address space mapping
Change constant address space from 4 to 2 for the new address space mapping in Clang.

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

llvm-svn: 299691
2017-04-06 19:18:36 +00:00
Chih-Hung Hsieh a0b99e45e9 [Basic] getColumnNumber returns location of CR+LF on Windows
When fixing a Clang-Tidy bug in D31406,
reuse of FileID enabled the missing highlightRange function.
Assertion in highlightRange failed because the end-of-range column
number was 2 + the last column of a line on Windows.
This fix is required to enable D31406.

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

llvm-svn: 299681
2017-04-06 18:36:50 +00:00
Stanislav Mekhanoshin 921a42314b [AMDGPU] Translate reqd_work_group_size into amdgpu_flat_work_group_size
These two attributes specify the same info in a different way.
AMGPU BE only checks the latter as a target specific attribute
as opposed to language specific reqd_work_group_size.

This change produces amdgpu_flat_work_group_size out of
reqd_work_group_size if specified.

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

llvm-svn: 299678
2017-04-06 18:15:44 +00:00
Ivan Krasin 1e1acbc95b Fix unused lambda capture. Follow up to r299653.
llvm-svn: 299671
2017-04-06 17:42:05 +00:00
Artem Dergachev da9e718fb4 [analyzer] Reland r299544 "Add a modular constraint system to the CloneDetector"
Hopefully fix crashes by unshadowing the variable.


Original commit message:

A big part of the clone detection code is functionality for filtering clones and
clone groups based on different criteria. So far this filtering process was
hardcoded into the CloneDetector class, which made it hard to understand and,
ultimately, to extend.

This patch splits the CloneDetector's logic into a sequence of reusable
constraints that are used for filtering clone groups. These constraints
can be turned on and off and reodreder at will, and new constraints are easy
to implement if necessary.

Unit tests are added for the new constraint interface.

This is a refactoring patch - no functional change intended.

Patch by Raphael Isemann!

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

llvm-svn: 299653
2017-04-06 14:34:07 +00:00
Alex Lorenz a983213459 [ObjC++] Conversions from specialized to non-specialized Objective-C generic
object types should be preferred over conversions to other object pointers

This change ensures that Clang will select the correct overload for the
following code sample:

  void overload(Base *b);
  void overload(Derived *d);
  void test(Base<Base *> b) {
    overload(b); // Select overload(Base *), not overload(Derived *)
  }

rdar://20124827

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

llvm-svn: 299648
2017-04-06 13:06:34 +00:00
Alex Lorenz b4791c7595 Fix lambda to block conversion in C++17 by avoiding copy elision for the
lambda capture used by the created block

The commit r288866 introduced guaranteed copy elision to C++ 17. This
unfortunately broke the lambda to block conversion in C++17 (the compiler
crashes when performing IRGen). This commit fixes the conversion by avoiding
copy elision for the capture that captures the lambda that's used in the block
created by the lambda to block conversion process.

rdar://31385153

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

llvm-svn: 299646
2017-04-06 12:53:43 +00:00
Simon Dardis f81c995dab [Sema] Extend GetSignedVectorType to deal with non ExtVector types
This improves some error messages which would otherwise refer to
ext_vector_type types in contexts where there are no such types.

Factored out from D25866 at reviewer's request.

Reviewers: bruno

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

llvm-svn: 299641
2017-04-06 10:38:03 +00:00
George Burgess IV 2d82b091d9 [Sema] Update CheckOverload docs
- Replace documented return values (true/false) with what's actually
  returned
- Doxygenify the comment
- Reflow said comment to 80 cols

Not overly familiar with Doxygen, so nits are welcome. :)

llvm-svn: 299603
2017-04-06 00:23:31 +00:00
George Burgess IV 05859d8238 Simplify. NFC.
Two simplifications:
- We check `!Previous.empty()` above and only use `Previous` in const
  contexts after that check, so the `!Previous.empty()` check seems
  redundant.
- The null check looks pointless, as well: AFAICT, `LookupResults`
  should never contain null entries, and `OldDecl` should always be
  non-null if `Redeclaration` is true.

llvm-svn: 299601
2017-04-06 00:08:35 +00:00
Meador Inge a91139525a [Driver] Print a newline when invoking `-print-resource-dir`
The commit yesterday (r299473) to add the `-print-resource-dir`
option was supposed to emit a newline after the resource dir.

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

llvm-svn: 299597
2017-04-05 22:27:20 +00:00
Nico Weber dc06518ff4 clang-format: Support formatting utf-8 character literals in C++11+ mode.
clang-format <<END
auto c1 = u8'a';
auto c2 = u'a';
END

Before:
  auto c1 = u8 'a';
  auto c2 = u'a';

Now:
  auto c1 = u8'a';
  auto c2 = u'a';

Patch from Denis Gladkikh <llvm@denis.gladkikh.email>!

llvm-svn: 299574
2017-04-05 18:10:42 +00:00
Artem Dergachev c4aee48b9f Revert "[analyzer] Add a modular constraint system to the CloneDetector"
This reverts commit r299544.

Crashes on tests on some buildbots.

llvm-svn: 299550
2017-04-05 15:06:17 +00:00
Artem Dergachev f8b4fc38fd [analyzer] Add a modular constraint system to the CloneDetector
A big part of the clone detection code is functionality for filtering clones and
clone groups based on different criteria. So far this filtering process was
hardcoded into the CloneDetector class, which made it hard to understand and,
ultimately, to extend.

This patch splits the CloneDetector's logic into a sequence of reusable
constraints that are used for filtering clone groups. These constraints
can be turned on and off and reodreder at will, and new constraints are easy
to implement if necessary.

Unit tests are added for the new constraint interface.

This is a refactoring patch - no functional change intended.

Patch by Raphael Isemann!

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

llvm-svn: 299544
2017-04-05 14:17:36 +00:00
Alex Lorenz 6615f2b3d6 -Wunreachable-code: 'true' and 'false' should not be treated as configuration
macros

Clang should emit -Wunreachable-code warnings in C mode for code that's
unreachable because of a 'false' or '!true' condition.

llvm-svn: 299541
2017-04-05 14:07:21 +00:00
Egor Churaev 3bccec5da7 [OpenCL] Extended diagnostics for atomic initialization
Summary:
I saw the same changes in the following review: https://reviews.llvm.org/D17438

I don't know in that way I could determine that atomic variable was initialized by macro ATOMIC_VAR_INIT. Anyway I added check that atomic variables can be initialize only in global scope.
I think that we can discuss this change.

Reviewers: Anastasia, cfe-commits

Reviewed By: Anastasia

Subscribers: bader, yaxunl

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

llvm-svn: 299537
2017-04-05 12:47:10 +00:00
Martin Probst c4a3d081a9 clang-format: [JS] fix whitespace around "of" operator.
Summary:
Previously:
    import {of } from 'x';
    of (null);

Now:
    import {of} from 'x';
    of(null);

Reviewers: djasper

Subscribers: cfe-commits, klimek

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

llvm-svn: 299533
2017-04-05 10:56:07 +00:00
Egor Churaev a8d2451533 [OpenCL] Enables passing sampler initializer to function argument
Reviewers: Anastasia, cfe-commits

Reviewed By: Anastasia

Subscribers: yaxunl, bader

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

llvm-svn: 299524
2017-04-05 09:02:56 +00:00
Daniel Marjamaki 2641a52ee4 [analyzer] alpha.core.Conversion - Fix false positive for 'U32 += S16;' expression, that is not unsafe
Summary:
The alpha.core.Conversion was too strict about compound assignments and could warn even though there is no problem.

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

llvm-svn: 299523
2017-04-05 08:57:04 +00:00
Stephan Bergmann be55c60d94 Don't issue a warning if the shadowing declaration is in a class
Follow-up to r299363 "Enhance -Wshadow to warn when shadowing typedefs or type
aliases".

Patch by Ahmed Asadi.

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

llvm-svn: 299522
2017-04-05 08:36:58 +00:00
Gor Nishanov 818a776102 [coroutines] Add coro.end handling
Summary:
For WinEH, We add a funclet bundle to a coro.end call, so that CoroSplit in LLVM can replace it with cleanup ret and cut the rest out.
For landing pad, we add a branch to resume block if coro.end returns true.

LLVM Part: https://reviews.llvm.org/D25445

Reviewers: majnemer

Reviewed By: majnemer

Subscribers: EricWF, cfe-commits, rsmith, mehdi_amini

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

llvm-svn: 299510
2017-04-05 04:55:03 +00:00
Meador Inge 51208a38de [Driver] Add option to print the resource directory
This patch adds the option -print-resource-dir. It simply
prints the resource directory. This information will eventually
be used in compiler-rt to setup COMPILER_RT_LIBRARY_INSTALL_DIR.

Patch by Catherine Moore!

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

llvm-svn: 299473
2017-04-04 21:46:50 +00:00
Adam Nemet 60d3264d5f Add #pragma clang fp
This adds the new pragma and the first variant, contract(on/off/fast).

The pragma has the same block scope rules as STDC FP_CONTRACT, i.e. it can be
placed at the beginning of a compound statement or at file scope.

Similarly to STDC FP_CONTRACT there is no need to use attributes.  First an
annotate token is inserted with the parsed details of the pragma.  Then the
annotate token is parsed in the proper contexts and the Sema is updated with
the corresponding FPOptions using the shared ActOn function with STDC
FP_CONTRACT.

After this the FPOptions from the Sema is propagated into the AST expression
nodes.  There is no change here.

I was going to add a 'default' option besides 'on/off/fast' similar to STDC
FP_CONTRACT but then decided against it. I think that we'd have to make option
uppercase then to avoid using 'default' the keyword.  Also because of the
scoped activation of pragma I am not sure there is really a need a for this.

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

llvm-svn: 299470
2017-04-04 21:18:36 +00:00
Adam Nemet 370d0877f6 Set FMF for -ffp-contract=fast
With this, FMF(contract) becomes an alternative way to express the request to
contract.

These are currently only propagated for FMul, FAdd and FSub.  The rest will be
added as more FMFs are hooked up for this.

This is toward fixing PR25721.

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

llvm-svn: 299469
2017-04-04 21:18:30 +00:00
Matthias Gehre ddae2516b8 [clang-format] fix crash in NamespaceEndCommentsFixer (PR32438)
Summary:
The new test case was crashing before. Now it passes
as expected.

Reviewers: djasper

Subscribers: klimek, cfe-commits

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

llvm-svn: 299465
2017-04-04 20:11:13 +00:00
Dominic Chen 08f943c563 [analyzer] Add new Z3 constraint manager backend
Summary: Implement new Z3 constraint manager backend.

Reviewers: zaks.anna, dcoughlin, NoQ, xazax.hun

Subscribers: mgorny, cfe-commits

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

llvm-svn: 299463
2017-04-04 19:52:25 +00:00
Anastasia Stulova 297908da5b [Bug 25404] Fix crash on typedef in OpenCL 2.0
Fixed the assertion due to absence of source location for
implicitly defined types (using addImplicitTypedef()).
During Sema checks the source location is being expected
and therefore an assertion is triggered.

The change is not specific to OpenCL. But it is particularly
common for OpenCL types to be declared implicitly in Clang
to support the mode without the standard header.

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

llvm-svn: 299447
2017-04-04 16:50:46 +00:00
Jin-Gu Kang e7cdcdea73 Preserve vec3 type.
Summary: Preserve vec3 type with CodeGen option.

Reviewers: Anastasia, bruno

Reviewed By: Anastasia

Subscribers: bruno, ahatanak, cfe-commits

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

llvm-svn: 299445
2017-04-04 16:40:25 +00:00
Michael Zuckerman 755a13db3d [X86][Clang] Converting __mm{|256|512}_movm_epi{8|16|32|64} LLVMIR call into generic intrinsics.
This patch is a part two of two reviews, one for the clang and the other for LLVM. 
In this patch, I covered the clang side, by introducing the intrinsic to the front end. 
This is done by creating a generic replacement.

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

llvm-svn: 299431
2017-04-04 13:29:53 +00:00
Craig Topper 451eedd3b6 [X86] Remove some code that tries to disable HLE feature. This feature flag was removed from the backend.
llvm-svn: 299416
2017-04-04 06:38:44 +00:00
Craig Topper 01bba17819 Recommit r299321 '[X86] Add __extension__ to f16c macro intrinsics to suppress warnings about compound literals when compiled for with earlier language standards enabled.'
The bot didn't recover after the revert. So it looks like this wasn't the issue.

llvm-svn: 299397
2017-04-03 22:59:30 +00:00
Gabor Horvath 3b392bb8d8 Revert r299355 "[ASTImporter] Fix for importing unnamed structs"
It breaks windows bots. 

llvm-svn: 299386
2017-04-03 21:06:45 +00:00
Craig Topper 27b71e5b1b Revert r299321 '[X86] Add __extension__ to f16c macro intrinsics to suppress warnings about compound literals when compiled for with earlier language standards enabled.' to see if recovers a fuzzer bot.
llvm-svn: 299382
2017-04-03 19:43:47 +00:00
Eric Fiselier bee782bb92 [coroutines] Fix rebuilding of implicit and dependent coroutine statements.
Summary:
Certain implicitly generated coroutine statements, such as the calls to 'return_value()' or `return_void()` or `get_return_object_on_allocation_failure()`, cannot be built until the promise type is no longer dependent. This means they are not built until after the coroutine body statement has been transformed.

This patch fixes an issue where these statements would never be built for coroutine templates.

It also fixes a small issue where diagnostics about `get_return_object_on_allocation_failure()` were incorrectly suppressed. 

Reviewers: rsmith, majnemer, GorNishanov, aaron.ballman

Reviewed By: GorNishanov

Subscribers: cfe-commits

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

llvm-svn: 299380
2017-04-03 19:21:00 +00:00
Davide Italiano 7a3b69d096 [TargetInfo] Use llvm::alignOf() instead of rewriting it. NFCI.
llvm-svn: 299364
2017-04-03 16:51:39 +00:00
Alex Lorenz 348c144d50 Enhance -Wshadow to warn when shadowing typedefs or type aliases
Enhance -Wshadow to emit a warning when typedefs or type aliases are shadowed.

Fixes bug https://bugs.llvm.org//show_bug.cgi?id=28676.

Patch by Ahmed Asadi.

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

llvm-svn: 299363
2017-04-03 16:43:21 +00:00
Gabor Horvath 3d2c10d941 [ASTImporter] Fix for importing unnamed structs
Patch by Peter Szecsi!

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

llvm-svn: 299355
2017-04-03 11:57:11 +00:00
Gabor Horvath 5558ba2d82 [ASTImporter] Lookup SearchName instead of Name
When the SearchName is already calculated we should use that for the lookup.

Patch by Peter Szecsi!

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

llvm-svn: 299354
2017-04-03 09:30:20 +00:00
Craig Topper bf82498301 [AVX-512] Fix a couple more intrinsic macros I missed in r299346.
llvm-svn: 299347
2017-04-03 03:51:57 +00:00
Craig Topper ac9959eb53 [AVX-512] Fix some intrinsic macros that use the wrong macro parameter names and don't have parentheses around them.
Thanks to Matthew Barr for reporting this issue.

llvm-svn: 299346
2017-04-03 03:41:29 +00:00
Craig Topper ce272ae2c5 [X86] Add __extension__ to f16c macro intrinsics to suppress warnings about compound literals when compiled for with earlier language standards enabled.
Fixes PR32491.

llvm-svn: 299321
2017-04-02 03:02:53 +00:00
Faisal Vali d143a0c2de [NFC, Scoped Enum] Convert Sema::ExpressionEvaluationContext into a scoped Enum
- also replace direct equality checks against the ConstantEvaluated enumerator  with isConstantEvaluted(), in anticipation of adding finer granularity to the various ConstantEvaluated contexts and reinstating certain restrictions on where lambda expressions can occur in C++17.

- update the clang tablegen backend that uses these Enumerators, and add the relevant scope where needed.

llvm-svn: 299316
2017-04-01 21:30:49 +00:00
Davide Italiano 1a3665bb82 [Driver] Don't crash on invalid values of -mrelocation-model=.
This is handled in a similar way we handle invalid -mcode-model.

PR: 31840
llvm-svn: 299315
2017-04-01 21:07:07 +00:00
Benjamin Kramer 9851cb76e2 [ObjC++] Use the correct EH personality in GNU mode
Previously, it would just always use the ObjC DWARF personality, even with SjLj
or SEH exceptions.

Patch by Jonathan Schleifer, test case by me.

llvm-svn: 299306
2017-04-01 17:59:01 +00:00
Gor Nishanov 63b6df4f05 [coroutines] Add cleanup for compiler injected objects/allocations in coroutine body
Summary:
* Use pushCleanup to emit freeing coroutine memory on normal and EH exits.
* Surround emitted code with CodeGenFunction::RunCleanupsScope.

Reviewers: rsmith, rnk, EricWF

Reviewed By: rnk

Subscribers: cfe-commits

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

llvm-svn: 299281
2017-04-01 00:22:47 +00:00
Teresa Johnson b637cb07ed [ThinLTO] Handle -emit-llvm* in ThinLTO backends
Summary:
Use PreCodeGenModuleHook to invoke the correct writer when emitting LLVM
IR, returning false to skip codegen from within thinBackend.

Reviewers: pcc, mehdi_amini

Subscribers: Prazek, cfe-commits

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

llvm-svn: 299274
2017-03-31 22:35:47 +00:00
Brad Smith 3f2b1d741e Add/update PIE defaults for OpenBSD.
llvm-svn: 299269
2017-03-31 22:13:17 +00:00
Craig Topper f771f79b2f [Sema][X86] Update immediate check for gather/scatter prefetch instructions to match the _MM_HINT_T0/T1 constant definitions
Our _MM_HINT_T0/T1 constant values are 3/2 which matches gcc, but not icc or Intel documentation. Interestingly gcc had this same bug on their implementation of the gather/scatter builtins at one point too.

Fixes PR32411.

llvm-svn: 299233
2017-03-31 17:22:30 +00:00
Petar Jovanovic 9b8b9e81dd [mips][msa] Range adjustment for ldi_b builtin function operand
Reasoning behind this change was allowing the function to accept all values
from range [-128, 255] since all of them can be encoded in an 8bit wide
value.
This differs from the prior state where only range [-128, 127] was accepted,
where values were assumed to be signed, whereas now the actual
interpretation of the immediate is deferred to the consumer as required.

Patch by Stefan Maksimovic.

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

llvm-svn: 299229
2017-03-31 16:16:43 +00:00
Alex Lorenz 7d7e1e0218 [Modules][PCH] Serialize #pragma pack
This patch serializes the state of #pragma pack. It preserves the state of the
pragma from a PCH/from modules in a file that uses that PCH/those modules.

rdar://21359084

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

llvm-svn: 299226
2017-03-31 15:36:21 +00:00
Daniel Jasper 1dbc2105dc clang-format: Fix post-commit review comment of r299204, use Style.isCpp().
Also, while at it, s/IsCpp/isCpp/ so that it follows LLVM style.

llvm-svn: 299214
2017-03-31 13:30:24 +00:00
Daniel Jasper 72b3357f2d clang-format: [JavaScript] Ignore QT keywords.
llvm-svn: 299204
2017-03-31 12:04:37 +00:00
Simon Pilgrim 750bde62dd Spelling mistakes in comments. NFCI.
llvm-svn: 299198
2017-03-31 11:00:53 +00:00
Egor Churaev ba8b84d7fb [OpenCL] Do not generate "kernel_arg_type_qual" metadata for non-pointer args
Summary:
"kernel_arg_type_qual" metadata should contain const/volatile/restrict
tags only for pointer types to match the corresponding requirement of
the OpenCL specification.

OpenCL 2.0 spec 5.9.3 Kernel Object Queries:

CL_KERNEL_ARG_TYPE_VOLATILE is returned if the argument is a pointer
and the referenced type is declared with the volatile qualifier.
[...]
Similarly, CL_KERNEL_ARG_TYPE_CONST is returned if the argument is a
pointer and the referenced type is declared with the restrict or const
qualifier.
[...]
CL_KERNEL_ARG_TYPE_RESTRICT will be returned if the pointer type is
marked restrict.

Reviewers: Anastasia, cfe-commits

Reviewed By: Anastasia

Subscribers: bader, yaxunl

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

llvm-svn: 299192
2017-03-31 10:14:52 +00:00
Benjamin Kramer 2a7d39dfe8 [msan] Turn off lifetime markers even when use after scope checking is on.
Since r299174 use after scope checking is on by default. Even though
msan doesn't check for use after scope it gets confused by the lifetime
markers emitted for it, making unit tests fail. This is covered by
ninja check-msan.

llvm-svn: 299191
2017-03-31 09:19:25 +00:00
Teresa Johnson 5ed6c10761 [ThinLTO] Set up lto::Config properly for codegen in ThinLTO backends
Summary:
This involved refactoring out pieces of
EmitAssemblyHelper::CreateTargetMachine for use in runThinLTOBackend.

Subsumes D31114.

Reviewers: mehdi_amini, pcc

Subscribers: Prazek, cfe-commits

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

llvm-svn: 299152
2017-03-31 02:05:15 +00:00
Eric Christopher 0d2c56a5c0 Fix typo, defind -> defined.
llvm-svn: 299148
2017-03-31 01:45:39 +00:00
Dean Michael Berris 504fc2262a [XRay][clang] Fix the -fxray-instruction-threshold flag processing
Summary:
The refactoring introduced a regression in the flag processing for
-fxray-instruction-threshold which causes it to not get passed properly.
This change should restore the previous behaviour.

Reviewers: rnk, pelikan

Subscribers: cfe-commits

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

llvm-svn: 299126
2017-03-30 22:46:45 +00:00
Erich Keane 623efd8a75 Clang changes for alloc_align attribute
GCC has the alloc_align attribute, which is similar to assume_aligned, except the attribute's parameter is the index of the integer parameter that needs aligning to.

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

llvm-svn: 299117
2017-03-30 21:48:55 +00:00
Simon Pilgrim 2c51880a82 Spelling mistakes in comments. NFCI. (PR27635)
llvm-svn: 299083
2017-03-30 14:13:19 +00:00
Alex Lorenz df42cf101f [ARC][ObjC++] Use ObjC semantic rules for comparisons between a pointer and
an ObjC object pointer

When ARC is enabled in Objective-C++, comparisons between a pointer and
Objective-C object pointer typically result in errors like this:
"invalid operands to a binary expression". This error message can be quite
confusing as it doesn't provide a solution to the problem, unlike the non-C++
diagnostic: "implicit conversion of Objective-C pointer type 'id' to C pointer
type 'void *' requires a bridged cast" (it also provides fix-its). This commit
forces comparisons between pointers and Objective-C object pointers in ARC to
use the Objective-C semantic rules to ensure that a better diagnostic is
reported.

rdar://31103857

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

llvm-svn: 299080
2017-03-30 13:48:33 +00:00
Nirav Dave 741dea003e Move NumRegParameters Module Flag. NFCI.
llvm-svn: 299079
2017-03-30 13:41:44 +00:00
Alex Lorenz 535571a2a1 [Sema][ObjC] Avoid the "type of property does not match type of accessor"
warning for methods that resemble the setters of readonly properties

rdar://30415679

llvm-svn: 299078
2017-03-30 13:33:51 +00:00
Haojian Wu ce27e59b3e Add `replace` interface with range in AtomicChange.
Reviewers: ioeric

Reviewed By: ioeric

Subscribers: alexshap, klimek, cfe-commits

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

llvm-svn: 299073
2017-03-30 13:07:38 +00:00