Commit Graph

68161 Commits

Author SHA1 Message Date
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
Michal Gorny 5ef8bf7369 [cmake] Support Gentoo install for z3
Add the 'z3' subdirectory to the list of possible path suffixes for
libz3 header search. The z3 headers are installed in /usr/include/z3
on Gentoo.

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

llvm-svn: 299813
2017-04-08 14:38:06 +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 f6388b182d Attempt to fix ms-intrinsics.c test
llvm-svn: 299785
2017-04-07 17:01:56 +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
NAKAMURA Takumi a77d32b7af CloneDetection.h: Fix warnings. [-Wdocumentation]
llvm-svn: 299760
2017-04-07 11:06:31 +00:00
Laszlo Nagy 6d9a7e8aaf [scan-build-py] merge runner module to analyzer
Differential Revision: https://reviews.llvm.org/D31237

llvm-svn: 299759
2017-04-07 11:04:49 +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 6c2898a3e9 Avoid the -Wdocumentation-unknown-command warning in Clang's C API docs
rdar://20441985

llvm-svn: 299650
2017-04-06 14:03:25 +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 266f8f8d4c [Sema] Retarget test to a specific platform for consistent datasizes
Attempt to satisfy llvm-clang-x86_64-expensive-checks-win by targeting
x86_64-apple-darwin10 for Sema/vector-ops.c. The underlying failure is
due to datatype differences between platforms.

llvm-svn: 299643
2017-04-06 11:12:14 +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
Vassil Vassilev 4b8e29d516 PR16106: Correct the docs to reflect the actual behavior of the interface.
llvm-svn: 299639
2017-04-06 10:05:46 +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
Reid Kleckner 2ae37c15c3 [lit] Fix Analysis test format pickling error
Move the test format into a standalone .py file and add it to the site
module search path. This allows us to run the test on Windows, and it
makes it compatible with the multiprocessing.Pool lit test execution
strategy.

I think this test was only passing everywhere else because
multiprocessing uses 'fork' to spawn workers, so the test format never
needs to be pickled.

llvm-svn: 299577
2017-04-05 18:56:48 +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
Antonio Maiorano a16ab5aee5 clang-format-vsix: Add "Format on Save" feature
This change adds a feature to the clang-format VS extension that optionally
enables the automatic formatting of documents when saving. Since developers
always need to save their files, this eases the workflow of making sure source
files are properly formatted.

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

llvm-svn: 299543
2017-04-05 14:13:45 +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
Adam Nemet d7f9511041 Another attempt to fix the sphinx warning from r299470
llvm-svn: 299488
2017-04-04 23:46:34 +00:00
Adam Nemet e73e00c9b2 Fix sphinx warning from r299470
llvm-svn: 299481
2017-04-04 22:45:20 +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
Coby Tayree b76fb84032 [fixup][X86][inline-asm] Add support for MS 'EVEN' directive
refining tested targets resolution, to amend failures caused by rL299454

llvm-svn: 299459
2017-04-04 19:20:21 +00:00
Coby Tayree b186493cc8 [X86][inline-asm] Add support for MS 'EVEN' directive
MS assembly syntax provide us with the 'EVEN' directive as a synonymous to at&t '.even'.
This patch include the (small, simple) changes need to allow it.

llvm-side:
https://reviews.llvm.org/D27417

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

llvm-svn: 299454
2017-04-04 17:58:28 +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