Commit Graph

53681 Commits

Author SHA1 Message Date
Petr Hosek 9c178356e0 [Driver] Don't pass default value to getCompilerRTArgString
Using static library is already a default.

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

llvm-svn: 351710
2019-01-21 01:34:09 +00:00
Serge Guelton c190404249 Tentative fix for r351701 and gcc 6.2 build on ubuntu
llvm-svn: 351706
2019-01-20 23:43:37 +00:00
Serge Guelton be88539b85 Replace llvm::isPodLike<...> by llvm::is_trivially_copyable<...>
As noted in https://bugs.llvm.org/show_bug.cgi?id=36651, the specialization for
isPodLike<std::pair<...>> did not match the expectation of
std::is_trivially_copyable which makes the memcpy optimization invalid.

This patch renames the llvm::isPodLike trait into llvm::is_trivially_copyable.
Unfortunately std::is_trivially_copyable is not portable across compiler / STL
versions. So a portable version is provided too.

Note that the following specialization were invalid:

    std::pair<T0, T1>
    llvm::Optional<T>

Tests have been added to assert that former specialization are respected by the
standard usage of llvm::is_trivially_copyable, and that when a decent version
of std::is_trivially_copyable is available, llvm::is_trivially_copyable is
compared to std::is_trivially_copyable.

As of this patch, llvm::Optional is no longer considered trivially copyable,
even if T is. This is to be fixed in a later patch, as it has impact on a
long-running bug (see r347004)

Note that GCC warns about this UB, but this got silented by https://reviews.llvm.org/D50296.

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

llvm-svn: 351701
2019-01-20 21:19:56 +00:00
Craig Topper 9fddc3fd00 [X86] Remove the cvtuqq2ps256/cvtqq2ps256 mask builtins. Replace with uitofp/sitofp and select.
Reviewers: RKSimon, spatel

Reviewed By: RKSimon

Subscribers: kristina, cfe-commits

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

llvm-svn: 351694
2019-01-20 19:04:56 +00:00
Simon Pilgrim a7bcd72c0a [X86] Replace VPCOM/VPCOMU with generic integer comparisons (clang)
These intrinsics can always be replaced with generic integer comparisons without any regression in codegen, even for -O0/-fast-isel cases.

Noticed while cleaning up vector integer comparison costs for PR40376.

A future commit will remove/autoupgrade the existing VPCOM/VPCOMU llvm intrinsics.

llvm-svn: 351687
2019-01-20 16:40:33 +00:00
Stephen Kelly 8805f67da9 [ASTDump] NFC: Convert iterative loops to cxx_range_for
This is coming up a lot in reviews. Better just to change them all at
once.

llvm-svn: 351647
2019-01-19 09:57:59 +00:00
Stephen Kelly aaebc5f2c5 [ASTDump] NFC: Use `const auto` in cxx_range_for loops
This is coming up a lot in reviews. Better just to do them all at once.

llvm-svn: 351646
2019-01-19 09:57:51 +00:00
Stephen Kelly 25f18bfd4f Move decl context dumping to TextNodeDumper
Summary: Only an obscure case is moved.

Reviewers: aaron.ballman

Subscribers: cfe-commits

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

llvm-svn: 351637
2019-01-19 09:05:55 +00:00
Chandler Carruth 2946cd7010 Update the file headers across all of the LLVM projects in the monorepo
to reflect the new license.

We understand that people may be surprised that we're moving the header
entirely to discuss the new license. We checked this carefully with the
Foundation's lawyer and we believe this is the correct approach.

Essentially, all code in the project is now made available by the LLVM
project under our new license, so you will see that the license headers
include that license only. Some of our contributors have contributed
code under our old license, and accordingly, we have retained a copy of
our old license notice in the top-level files in each project and
repository.

llvm-svn: 351636
2019-01-19 08:50:56 +00:00
Chandler Carruth 4a50956c07 Convert two more files that were using Windows line endings and remove
a stray single '\r' from one file. These are the last line ending issues
I can find in the files containing parts of LLVM's file headers.

llvm-svn: 351634
2019-01-19 06:36:08 +00:00
Chandler Carruth d92d70b7f0 Remove random windows line endings that snuck into the middle of this
code.

llvm-svn: 351633
2019-01-19 06:36:00 +00:00
Johannes Doerfert ac991bbb44 Emit !callback metadata and introduce the callback attribute
With commit r351627, LLVM gained the ability to apply (existing) IPO
  optimizations on indirections through callbacks, or transitive calls.
  The general idea is that we use an abstraction to hide the middle man
  and represent the callback call in the context of the initial caller.
  It is described in more detail in the commit message of the LLVM patch
  r351627, the llvm::AbstractCallSite class description, and the
  language reference section on callback-metadata.

  This commit enables clang to emit !callback metadata that is
  understood by LLVM. It does so in three different cases:
    1) For known broker functions declarations that are directly
       generated, e.g., __kmpc_fork_call for the OpenMP pragma parallel.
    2) For known broker functions that are identified by their name and
       source location through the builtin detection, e.g.,
       pthread_create from the POSIX thread API.
    3) For user annotated functions that carry the "callback(callee, ...)"
       attribute. The attribute has to include the name, or index, of
       the callback callee and how the passed arguments can be
       identified (as many as the callback callee has). See the callback
       attribute documentation for detailed information.

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

llvm-svn: 351629
2019-01-19 05:36:54 +00:00
Artem Dergachev 097a049740 [analyzer] pr37688: Fix a crash upon evaluating a deleted destructor of a union.
Add a defensive check against an invalid destructor in the CFG.

Unions with fields with destructors have their own destructor implicitly
deleted. Due to a bug in the CFG we're still trying to evaluate them
at the end of the object's lifetime and crash because we are unable
to find the destructor's declaration.

rdar://problem/47362608

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

llvm-svn: 351610
2019-01-18 23:05:07 +00:00
Artem Dergachev c2c47f24f5 [analyzer] Do not try to body-farm Objective-C properties with custom accessors.
If a property is defined with a custom getter, we should not behave as if
the getter simply returns an instance variable. We don't support setters,
so they aren't affected.

On top of being the right thing to do, this also fixes a crash on
the newly added test - in which a property and its getter are defined
in two separate categories.

rdar://problem/47051544

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

llvm-svn: 351609
2019-01-18 22:52:13 +00:00
Stephen Kelly 1e07f4e2e7 [ASTDump] NFC: Move variable into if() statement
llvm-svn: 351605
2019-01-18 22:15:09 +00:00
Stephen Kelly 4e35baa842 [ASTDump] NFC: Remove redundant condition
These conditions are duplicated from the dumpDeclContext function called
within the if(). This is presumably an attempt to avoid calling the
function in the case it will do nothing.

That may have made sense in the past if the code was different, but it
doesn't make sense now.

llvm-svn: 351604
2019-01-18 22:15:05 +00:00
Stephen Kelly f4129fd58b [ASTDump] NFC: Remove non-needed braces
llvm-svn: 351603
2019-01-18 22:14:59 +00:00
Stephen Kelly bbd08cce79 [ASTDump] Mark null params with a tag rather than a child node
Reviewers: aaron.ballman

Subscribers: cfe-commits

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

llvm-svn: 351601
2019-01-18 22:00:16 +00:00
Stephen Kelly 5110ebd9fe [ASTDump] Mark BlockDecls which capture this with a tag
Summary:
Removal of the child node makes it easier to separate traversal from
output generation.

Reviewers: aaron.ballman

Subscribers: cfe-commits

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

llvm-svn: 351600
2019-01-18 21:55:24 +00:00
Stephen Kelly 149119dc5f [ASTDump] Mark variadic declarations with a tag instead of child node
Summary:
This makes it easier to separate traversal of the AST from output
generation.

Reviewers: aaron.ballman

Subscribers: cfe-commits

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

llvm-svn: 351597
2019-01-18 21:38:30 +00:00
Erik Pilkington 14d47cfd49 [Sema] Suppress a warning about a forward-declared fixed enum in C mode
As of r343360, we support fixed-enums in C. This lead to some
warnings in project headers where a fixed enum is forward declared
then later defined. In C++, this is fine, the forward declaration is
treated as a complete type even though the definition isn't present.
We use this rule in C too, but still warn about the forward
declaration anyways. This patch suppresses the warning.

rdar://problem/47356469

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

llvm-svn: 351595
2019-01-18 21:33:23 +00:00
Leonard Chan d3f3e16293 [Fixed Point Arithmetic] Fixed Point Addition Constant Expression Evaluation
This patch includes logic for constant expression evaluation of fixed point additions.

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

llvm-svn: 351593
2019-01-18 21:04:25 +00:00
Simon Pilgrim c636806297 Fix MSVC "not all control paths return a value" warning. NFCI.
llvm-svn: 351588
2019-01-18 20:40:35 +00:00
Vladimir Stefanovic 99113a0ccf [mips] Add '-mrelax-pic-calls', '-mno-relax-pic-calls'
These two options enable/disable emission of R_{MICRO}MIPS_JALR fixups along
with PIC calls. The linker may then try to turn PIC calls into direct jumps.
By default, these fixups do get emitted by the backend, use
'-mno-relax-pic-calls' to omit them.

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

llvm-svn: 351579
2019-01-18 19:54:51 +00:00
Erich Keane 8e77216c1a [NFC] Fix wParentheses warning in ASTContext getFixedPointSemantics
Change-Id: I862f00a548236872fe24f7da8eb2bf7917e123ff
llvm-svn: 351576
2019-01-18 19:31:54 +00:00
George Karpenkov 2c2d0b6e97 Revert "Fix failing MSan bots"
This reverts commit 2cedaaef383d8d6142046074ffebc2bb5a914778.

Revert with a fix.

llvm-svn: 351575
2019-01-18 19:24:55 +00:00
Mandeep Singh Grang d36da8a0ab [clang] Change to range-based invocation of llvm::sort
llvm-svn: 351573
2019-01-18 18:45:26 +00:00
Craig Topper d08d90ce51 [X86] Only define _XCR_XFEATURE_ENABLED_MASK in xsaveintrin.h when _MSC_VER is defined. Remove from intrin.h.
I think this was my intention when I added it xsaveintrin.h

llvm-svn: 351568
2019-01-18 17:51:51 +00:00
Zola Bridges 826ef59568 [clang][slh] add Clang attr no_speculative_load_hardening
Summary:
This attribute will allow users to opt specific functions out of
speculative load hardening. This compliments the Clang attribute
named speculative_load_hardening. When this attribute or the attribute
speculative_load_hardening is used in combination with the flags
-mno-speculative-load-hardening or -mspeculative-load-hardening,
the function level attribute will override the default during LLVM IR
generation. For example, in the case, where the flag opposes the
function attribute, the function attribute will take precendence.
The sticky inlining behavior of the speculative_load_hardening attribute
may cause a function with the no_speculative_load_hardening attribute
to be tagged with the speculative_load_hardening tag in
subsequent compiler phases which is desired behavior since the
speculative_load_hardening LLVM attribute is designed to be maximally
conservative.

If both attributes are specified for a function, then an error will be
thrown.

Reviewers: chandlerc, echristo, kristof.beyls, aaron.ballman

Subscribers: llvm-commits

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

llvm-svn: 351565
2019-01-18 17:20:46 +00:00
Nirav Dave 7503316d10 Revert "Clang side support for @cc assembly operands."
llvm-svn: 351561
2019-01-18 16:03:08 +00:00
Nirav Dave d410e392cd Clang side support for @cc assembly operands.
llvm-svn: 351559
2019-01-18 15:57:23 +00:00
Anastasia Stulova ef19af1942 [OpenCL] Fix overloading ranking rules for addrspace conversions.
Extend ranking to work with address spaces correctly when
resolving overloads.

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

llvm-svn: 351546
2019-01-18 11:38:16 +00:00
Kadir Cetinkaya 2eff821bbd [tooling] Add a new argument adjuster for deleting plugin related command line args
Summary:
Currently both clangd and clang-tidy makes use of this mechanism so
putting it into tooling so that all tools can make use of it.

Reviewers: ilya-biryukov, sammccall

Subscribers: ioeric, cfe-commits

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

llvm-svn: 351531
2019-01-18 09:00:31 +00:00
Vlad Tsyrklevich d5dd6a5fdd Fix failing MSan bots
Revert r351508-351514, this block of changes introduced a consistent
MSan failure on the sanitizer bots.

llvm-svn: 351528
2019-01-18 08:43:22 +00:00
George Karpenkov 1a5ce51626 [analyzer] Introduce proper diagnostic for freeing unowned object
Insert a note when the object becomes not (exclusively) owned.

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

llvm-svn: 351514
2019-01-18 03:13:53 +00:00
George Karpenkov e880840d8c [analyzer] Extend the PathDiagnosticLocation constructor to handle CallExitEnd
Differential Revision: https://reviews.llvm.org/D56890

llvm-svn: 351513
2019-01-18 03:13:40 +00:00
George Karpenkov 9bf9938492 [analyzer] [NFC] Clean up messy handling of bug categories in RetainCountChecker
https://reviews.llvm.org/D56887

llvm-svn: 351512
2019-01-18 03:13:27 +00:00
George Karpenkov 0029c3b64c [analyzer] const-ify reference to bug type used in BugReporter
Differential Revision: https://reviews.llvm.org/D56885

llvm-svn: 351511
2019-01-18 03:13:14 +00:00
George Karpenkov 1aa2bf8ea4 [analyzer] Extend BugType constructor to accept "SuppressOnSink" as a parameter
Differential Revision: https://reviews.llvm.org/D56884

llvm-svn: 351510
2019-01-18 03:13:01 +00:00
George Karpenkov a2280e0c93 [analyzer] [RetainCountChecker] Produce a correct message when OSTypeAlloc is used
Differential Revision: https://reviews.llvm.org/D56820

llvm-svn: 351509
2019-01-18 03:12:48 +00:00
George Karpenkov a0425f3a2f [analyzer] [RetainCountChecker] Smart pointer support.
rdar://47323216

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

llvm-svn: 351508
2019-01-18 03:12:35 +00:00
Artem Dergachev 342a7ac8d6 [analyzer] MoveChecker: Add one more common resetting method, "append".
This is especially crucial for reports related to use-after-move of
standard library objects.

rdar://problem/47338505

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

llvm-svn: 351500
2019-01-18 00:16:25 +00:00
Artem Dergachev 2ed0e79bb8 [analyzer] Make sure base-region and its sub-regions are either all alive or all dead.
SymbolReaper now realizes that our liveness analysis isn't sharp enough
to discriminate between liveness of, say, variables and their fields.
Surprisingly, this didn't quite work before: having a variable live only
through Environment (eg., calling a C++ method on a local variable
as the last action ever performed on that variable) would not keep the
region value symbol of a field of that variable alive.

It would have been broken in the opposite direction as well, but both
Environment and RegionStore use the scanReachableSymbols mechanism for finding
live symbols regions within their values, and due to that they accidentally
end up marking the whole chain of super-regions as live when at least one
sub-region is known to be live.

It is now a direct responsibility of SymbolReaper to maintain this invariant,
and a unit test was added in order to make sure it stays that way.

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

rdar://problem/46914108

llvm-svn: 351499
2019-01-18 00:08:56 +00:00
Richard Smith 0444006fff Fix cleanup registration for lambda captures.
Lambda captures should be destroyed if an exception is thrown only if
the construction of the complete lambda-expression has not completed.
(If the lambda-expression has been fully constructed, any exception will
invoke its destructor, which will destroy the captures.)

This is directly modeled after how we handle the equivalent situation in
InitListExprs.

Note that EmitLambdaLValue was unreachable because in C++11 onwards the
frontend never creates the awkward situation where a prvalue expression
(such as a lambda) is used in an lvalue context (such as the left-hand
side of a class member access).

llvm-svn: 351487
2019-01-17 22:05:50 +00:00
Eric Fiselier 73b51ae160 Add -Wctad-maybe-unsupported to diagnose CTAD on types with no user defined deduction guides.
Summary:
Some style guides want to allow using CTAD only on types that "opt-in"; i.e. on types that are designed to support it and not just types that *happen* to work with it.

This patch implements the `-Wctad-maybe-unsupported` warning, which is off by default, which warns when CTAD is used on a type that does not define any deduction guides.

The following pattern can be used to suppress the warning in cases where the type intentionally doesn't define any deduction guides:

```
struct allow_ctad_t;

template <class T>
struct TestSuppression {
  TestSuppression(T) {}
};
TestSuppression(allow_ctad_t)->TestSuppression<void>; // guides with incomplete parameter types are never considered.
```

Reviewers: rsmith, james.dennett, gromer

Reviewed By: rsmith

Subscribers: jdennett, Quuxplusone, lebedev.ri, cfe-commits

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

llvm-svn: 351484
2019-01-17 21:44:24 +00:00
Aaron Ballman 65e96bdaca Revert r351209 (which was a revert of r350891) with a fix.
The test case had a parse error that was causing the condition string to be misreported. We now have better fallback code for error cases.

llvm-svn: 351470
2019-01-17 20:21:34 +00:00
Erik Pilkington 2ff012df81 [CodeGenObjC] Use a constant value for non-fragile ivar offsets when possible
If a class inherits from NSObject and has an implementation, then we
can assume that ivar offsets won't need to be updated by the runtime.
This allows us to index into the object using a constant value and
avoid loading from the ivar offset variable.

This patch was adapted from one written by Pete Cooper.

rdar://problem/10132568

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

llvm-svn: 351461
2019-01-17 18:18:53 +00:00
Alex Lorenz 194d00e142 [ObjC] Follow-up r350768 and allow the use of unavailable methods that are
declared in a parent class from within the @implementation context

This commit extends r350768 and allows the use of methods marked as unavailable
that are declared in a parent class/category from within the @implementation of
the class where the method is marked as unavailable.
This allows users to call init that's marked as unavailable even if they don't
define it.

rdar://47134898

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

llvm-svn: 351459
2019-01-17 18:12:45 +00:00
Vlad Tsyrklevich c93390b5c5 TLS: Respect visibility for thread_local variables on Darwin (PR40327)
Summary:
Teach clang to mark thread wrappers for thread_local variables with
hidden visibility when the original variable is marked with hidden
visibility. This is necessary on Darwin which exposes the thread wrapper
instead of the thread variable. The thread wrapper would previously
always be created with default visibility unless it had
linkonce*/weak_odr linkage.

Reviewers: rjmccall

Reviewed By: rjmccall

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

llvm-svn: 351457
2019-01-17 17:53:45 +00:00
Anton Korobeynikov 81cff31ccf CodeGen: Cast llvm.flt.rounds result to match __builtin_flt_rounds
llvm.flt.rounds returns an i32, but the builtin expects an integer. 
On targets where integers are not 32-bits clang tries to bitcast the result, causing an assertion failure.

The patch enables newlib build for msp430.

Patch by Edward Jones!

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

llvm-svn: 351449
2019-01-17 15:21:55 +00:00