Commit Graph

4489 Commits

Author SHA1 Message Date
Eric Fiselier 12a9f344c6 Make __has_unique_object_representations reject empty union types.
Summary:
Clang incorrectly reports empty unions as having a unique object representation. However, this is not correct since `sizeof(EmptyUnion) == 1` AKA it has 8 bits of padding. Therefore it should be treated the same as an empty struct and report `false`.

@erichkeane also suggested this fix should be merged into the 6.0 release branch, so the initial release of `__has_unique_object_representations` is as bug-free as possible. 

Reviewers: erichkeane, rsmith, aaron.ballman, majnemer

Reviewed By: erichkeane

Subscribers: cfe-commits, erichkeane

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

llvm-svn: 324134
2018-02-02 20:30:39 +00:00
Brian Gesiak 61f4ac98e0 [coroutines] Pass coro func args to promise ctor
Summary:
Use corutine function arguments to initialize a promise type, but only
if the promise type defines a constructor that takes those arguments.
Otherwise, fall back to the default constructor.

Test Plan: check-clang

Reviewers: rsmith, GorNishanov, eric_niebler

Reviewed By: GorNishanov

Subscribers: toby-allsopp, lewissbaker, EricWF, cfe-commits

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

llvm-svn: 323381
2018-01-24 22:15:42 +00:00
Artem Belevich 224879ea47 [DeclPrinter] Fix two cases that crash clang -ast-print.
Both are related to handling anonymous structures.
* clang didn't handle () around an anonymous struct variable.
* clang also crashed on syntax errors that could lead to other
  syntactic constructs following the declaration of an
  anonymous struct. While the code is invalid, that's not
  a good reason to panic compiler.

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

llvm-svn: 322742
2018-01-17 19:29:39 +00:00
Vedant Kumar a14a1f923f [Parse] Forward brace locations to TypeConstructExpr
When parsing C++ type construction expressions with list initialization,
forward the locations of the braces to Sema.

Without these locations, the code coverage pass crashes on the given test
case, because the pass relies on getLocEnd() returning a valid location.

Here is what this patch does in more detail:

  - Forwards init-list brace locations to Sema (ParseExprCXX),
  - Builds an InitializationKind with these locations (SemaExprCXX), and
  - Uses these locations for constructor initialization (SemaInit).

The remaining changes fall out of introducing a new overload for
creating direct-list InitializationKinds.

Testing: check-clang, and a stage2 coverage-enabled build of clang with
asserts enabled.

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

llvm-svn: 322729
2018-01-17 18:53:51 +00:00
George Burgess IV d74b6a8f64 [Sema] Fix a crash on invalid features in multiversioning
We were trying to emit a diag::err_bad_multiversion_option diagnostic,
which expects an int as its first argument, with a string argument. As
it happens, the string `Feature` that was causing this was shadowing an
int `Feature` from the surrounding scope. :)

llvm-svn: 322530
2018-01-16 03:01:50 +00:00
Jan Korous fda9daeb03 [Sema] Fix crash for type-dependent base classes
llvm-svn: 322438
2018-01-13 15:24:16 +00:00
Richard Smith 56ae0a67e8 DR126: partially implement the const-correct rules for exception handler matching.
While here, fix up the myriad other ways in which Sema's two "can this handler
catch that exception?" implementations get things wrong and unify them.

llvm-svn: 322431
2018-01-13 05:05:45 +00:00
Eric Fiselier 1af6c114cc Add `__reference_binds_to_temporary` trait for checking safe reference initialization.
Summary:
The STL types `std::pair` and `std::tuple` can both store reference types. However their constructors cannot adequately check if the initialization of reference types is safe.  For example:

```
std::tuple<std::tuple<int> const&> t = 42;
// The stored reference is already dangling.
```

Libc++ has a best effort attempts in tuple to diagnose this, but they're not able to handle all valid cases (If I'm not mistaken). For example initialization of a reference from the result of a class's conversion operator.  Libc++ would benefit from having a builtin traits which can provide a much better implementation.

This patch introduce the `__reference_binds_to_temporary(T, U)` trait  that determines whether a reference of type `T` bound to an expression of type `U` would bind to a materialized temporary object.

Note that the trait simply returns false if `T` is not a reference type instead of reporting it as an error.

```
static_assert(__is_constructible(int const&, long));
static_assert(__reference_binds_to_temporary(int const&, long));
```


Reviewers: majnemer, rsmith

Reviewed By: rsmith

Subscribers: compnerd, cfe-commits

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

llvm-svn: 322334
2018-01-12 00:09:37 +00:00
Richard Smith e97654b2f2 Handle scoped_lockable objects being returned by value in C++17.
In C++17, guaranteed copy elision means that there isn't necessarily a
constructor call when a local variable is initialized by a function call that
returns a scoped_lockable by value. In order to model the effects of
initializing a local variable with a function call returning a scoped_lockable,
pretend that the move constructor was invoked within the caller at the point of
return.

llvm-svn: 322316
2018-01-11 22:13:57 +00:00
Richard Smith 52b36918d6 PR35862: Suppress -Wmissing-variable-declarations warning on inline variables,
variable templates, and instantiations thereof.

llvm-svn: 322030
2018-01-08 21:46:42 +00:00
Erich Keane 281d20b601 Implement Attribute Target MultiVersioning
GCC's attribute 'target', in addition to being an optimization hint,
also allows function multiversioning. We currently have the former
implemented, this is the latter's implementation.

This works by enabling functions with the same name/signature to coexist,
so that they can all be emitted. Multiversion state is stored in the
FunctionDecl itself, and SemaDecl manages the definitions.
Note that it ends up having to permit redefinition of functions so
that they can all be emitted. Additionally, all versions of the function
must be emitted, so this also manages that.

Note that this includes some additional rules that GCC does not, since
defining something as a MultiVersion function after a usage has been made illegal.

The only 'history rewriting' that happens is if a function is emitted before
it has been converted to a multiversion'ed function, at which point its name
needs to be changed.

Function templates and virtual functions are NOT yet supported (not supported
in GCC either).

Additionally, constructors/destructors are disallowed, but the former is 
planned.

llvm-svn: 322028
2018-01-08 21:34:17 +00:00
Richard Smith db70052b65 Remove bogus check for template specialization from self-comparison warning.
The important check is that we're not within a template *instantiation*, which
we check separately.

llvm-svn: 321977
2018-01-07 22:25:55 +00:00
Richard Smith 07c0f285ba Fix a couple of wrong self-comparison diagnostics.
Check whether we are comparing the same entity, not merely the same
declaration, and don't assume that weak declarations resolve to distinct
entities.

llvm-svn: 321976
2018-01-07 22:18:05 +00:00
Richard Smith 32f39731c2 Add tests for three-way self- and array comparison.
llvm-svn: 321973
2018-01-07 22:03:44 +00:00
Richard Smith 1337318eea PR35045: Convert injected-class-name to its corresponding simple-template-id
during template argument deduction.

We already did this when the injected-class-name was in P, but missed the case
where it was in A. This (probably) can't happen except in implicit deduction
guides.

llvm-svn: 321779
2018-01-04 01:24:17 +00:00
Roman Lebedev c5417aafec [Sema] -Wtautological-constant-compare is too good. Cripple it.
Summary:
The diagnostic was mostly introduced in D38101 by me, as a reaction to wasting a lot of time, see [[ https://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20171009/206427.html | mail ]].
However, the diagnostic is pretty dumb. While it works with no false-positives,
there are some questionable cases that are diagnosed when one would argue that they should not be.

The common complaint is that it diagnoses the comparisons between an `int` and
`long` when compiling for a 32-bit target as tautological, but not when
compiling for 64-bit targets. The underlying problem is obvious: data model.
In most cases, 64-bit target is `LP64` (`int` is 32-bit, `long` and pointer are
64-bit), and the 32-bit target is `ILP32` (`int`, `long`, and pointer are 32-bit).

I.e. the common pattern is: (pseudocode)
```
#include <limits>
#include <cstdint>
int main() {
  using T1 = long;
  using T2 = int;

  T1 r;
  if (r < std::numeric_limits<T2>::min()) {}
  if (r > std::numeric_limits<T2>::max()) {}
}
```
As an example, D39149 was trying to fix this diagnostic in libc++, and it was not well-received.

This *could* be "fixed", by changing the diagnostics logic to something like
`if the types of the values being compared are different, but are of the same size, then do diagnose`,
and i even attempted to do so in D39462, but as @rjmccall rightfully commented,
that implementation is incomplete to say the least.

So to stop causing trouble, and avoid contaminating upcoming release, lets do this workaround:
* move these three diags (`warn_unsigned_always_true_comparison`, `warn_unsigned_enum_always_true_comparison`, `warn_tautological_constant_compare`) into it's own `-Wtautological-constant-in-range-compare`
* Disable them by default
* Make them part of `-Wextra`
* Additionally, give `warn_tautological_constant_compare` it's own flag `-Wtautological-type-limit-compare`.
  I'm not happy about that name, but i can't come up with anything better.

This way all three of them can be enabled/disabled either altogether, or one-by-one.

Reviewers: aaron.ballman, rsmith, smeenai, rjmccall, rnk, mclow.lists, dim

Reviewed By: aaron.ballman, rsmith, dim

Subscribers: thakis, compnerd, mehdi_amini, dim, hans, cfe-commits, rjmccall

Tags: #clang

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

llvm-svn: 321691
2018-01-03 08:45:19 +00:00
Richard Smith 99f54799d1 PR35697: look at the first declaration when determining whether a function or
variable is extern "C" in linkage calculations.

llvm-svn: 321686
2018-01-03 02:34:35 +00:00
Richard Smith 50e291eaf2 Fix and simplify handling of return type for (generic) lambda conversion function to function pointer.
Previously, we would:
 * compute the type of the conversion function and static invoker as a
   side-effect of template argument deduction for a conversion
 * re-compute the type as part of deduced return type deduction when building
   the conversion function itself

Neither of these turns out to be quite correct. There are other ways to reach a
declaration of the conversion function than in a conversion (such as an
explicit call or friend declaration), and performing auto deduction causes the
function type to be rebuilt in the context of the lambda closure type (which is
different from the context in which it originally appeared, resulting in
spurious substitution failures for constructs that are valid in one context but
not the other, such as the use of an enclosing class's "this" pointer).

This patch switches us to use a different strategy: as before, we use the
declared type of the operator() to form the type of the conversion function and
invoker, but we now populate that type as part of return type deduction for the
conversion function. And the invoker is now treated as simply being an
implementation detail of building the conversion function, and isn't given
special treatment by template argument deduction for the conversion function
any more.

llvm-svn: 321683
2018-01-02 23:52:42 +00:00
Jacob Bandes-Storch bb93578108 [Sema] Improve diagnostics for const- and ref-qualified member functions
(Re-submission of D39937 with fixed tests.)

Adjust wording for const-qualification mismatch to be a little more clear.

Also add another diagnostic for a ref qualifier mismatch, which previously produced a useless error (this error path is simply very old; see rL119336):

Before:
  error: cannot initialize object parameter of type 'X0' with an expression of type 'X0'

After:
  error: 'this' argument to member function 'rvalue' is an lvalue, but function has rvalue ref-qualifier

Reviewers: aaron.ballman

Reviewed By: aaron.ballman

Subscribers: lebedev.ri, cfe-commits

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

llvm-svn: 321609
2017-12-31 18:27:29 +00:00
Jacob Bandes-Storch 1dbc09363a Reverted 321592: [Sema] Improve diagnostics for const- and ref-qualified member functions
A few tests need to be fixed

llvm-svn: 321593
2017-12-31 05:13:03 +00:00
Jacob Bandes-Storch c7e67a04e0 [Sema] Improve diagnostics for const- and ref-qualified member functions
Summary:
Adjust wording for const-qualification mismatch to be a little more clear.

Also add another diagnostic for a ref qualifier mismatch, which previously produced a useless error (this error path is simply very old; see rL119336):

Before:
  error: cannot initialize object parameter of type 'X0' with an expression of type 'X0'

After:
  error: 'this' argument to member function 'rvalue' is an lvalue, but function has rvalue ref-qualifier

Reviewers: rsmith, aaron.ballman

Reviewed By: aaron.ballman

Subscribers: lebedev.ri, aaron.ballman, cfe-commits

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

llvm-svn: 321592
2017-12-31 04:49:39 +00:00
Richard Smith e9d8789de3 Suppress "redundant parens" warning for "A (::B())".
This is a slightly odd construct (it's more common to see "A (::B)()") but can
happen in friend declarations, and the parens are not redundant as they prevent
the :: binding to the left.

llvm-svn: 321318
2017-12-21 22:26:47 +00:00
Paul Robinson f183848ace [AST] Incorrectly qualified unscoped enumeration as template actual parameter.
An unscoped enumeration used as template argument, should not have any
qualified information about its enclosing scope, as its visibility is
global.

In the case of scoped enumerations, they must include information
about their enclosing scope.

Patch by Carlos Alberto Enciso!

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

llvm-svn: 321312
2017-12-21 21:47:22 +00:00
Aaron Ballman 8c20828b5c Re-commit r321223, which adds a printing policy to the ASTDumper.
This allows you to dump C++ code that spells bool instead of _Bool, leaves off the elaborated type specifiers when printing struct or class names, and other C-isms.

Fixes the -Wreorder issue and fixes the ast-dump-color.cpp test.

llvm-svn: 321310
2017-12-21 21:42:42 +00:00
Aaron Ballman 9d6501f6cd Reverting r321223 and its follow-up commit because of failing bots due to Misc/ast-dump-color.cpp.
llvm-svn: 321229
2017-12-20 23:17:29 +00:00
Aaron Ballman 207ee3d0a7 Add a printing policy to the ASTDumper.
This allows you to dump C++ code that spells bool instead of _Bool, leaves off the elaborated type specifiers when printing struct or class names, and other C-isms.

llvm-svn: 321223
2017-12-20 22:04:54 +00:00
Erich Keane 47475f9ec7 Correct UnaryTransformTypeLoc to properly initialize.
The initializeLocal function of UnaryTransformTypeLoc missed
the UnderlyingTInfo member.  This caused a null-dereference
issue, as reported in PR23421. This patch correctly initializss 
the UnderlyingTInfo.

llvm-svn: 320765
2017-12-14 23:37:08 +00:00
Dimitry Andric c7bc461298 Don't trigger -Wuser-defined-literals for system headers
Summary:
In D41064, I proposed adding `#pragma clang diagnostic ignored
"-Wuser-defined-literals"` to some of libc++'s headers, since these
warnings are now triggered by clang's new `-std=gnu++14` default:

```
$ cat test.cpp
#include <string>

$ clang -std=c++14 -Wsystem-headers -Wall -Wextra -c test.cpp
In file included from test.cpp:1:
In file included from /usr/include/c++/v1/string:470:
/usr/include/c++/v1/string_view:763:29: warning: user-defined literal suffixes not starting with '_' are reserved [-Wuser-defined-literals]
    basic_string_view<char> operator "" sv(const char *__str, size_t __len)
                            ^
/usr/include/c++/v1/string_view:769:32: warning: user-defined literal suffixes not starting with '_' are reserved [-Wuser-defined-literals]
    basic_string_view<wchar_t> operator "" sv(const wchar_t *__str, size_t __len)
                               ^
/usr/include/c++/v1/string_view:775:33: warning: user-defined literal suffixes not starting with '_' are reserved [-Wuser-defined-literals]
    basic_string_view<char16_t> operator "" sv(const char16_t *__str, size_t __len)
                                ^
/usr/include/c++/v1/string_view:781:33: warning: user-defined literal suffixes not starting with '_' are reserved [-Wuser-defined-literals]
    basic_string_view<char32_t> operator "" sv(const char32_t *__str, size_t __len)
                                ^
In file included from test.cpp:1:
/usr/include/c++/v1/string:4012:24: warning: user-defined literal suffixes not starting with '_' are reserved [-Wuser-defined-literals]
    basic_string<char> operator "" s( const char *__str, size_t __len )
                       ^
/usr/include/c++/v1/string:4018:27: warning: user-defined literal suffixes not starting with '_' are reserved [-Wuser-defined-literals]
    basic_string<wchar_t> operator "" s( const wchar_t *__str, size_t __len )
                          ^
/usr/include/c++/v1/string:4024:28: warning: user-defined literal suffixes not starting with '_' are reserved [-Wuser-defined-literals]
    basic_string<char16_t> operator "" s( const char16_t *__str, size_t __len )
                           ^
/usr/include/c++/v1/string:4030:28: warning: user-defined literal suffixes not starting with '_' are reserved [-Wuser-defined-literals]
    basic_string<char32_t> operator "" s( const char32_t *__str, size_t __len )
                           ^
8 warnings generated.
```

Both @aaron.ballman and @mclow.lists felt that adding this workaround to
the libc++ headers was the wrong way, and it should be fixed in clang
instead.

Here is a proposal to do just that.  I verified that this suppresses the
warning, even when -Wsystem-headers is used, and that the warning is
still emitted for a declaration outside of system headers.

Reviewers: aaron.ballman, mclow.lists, rsmith

Reviewed By: aaron.ballman

Subscribers: mclow.lists, aaron.ballman, andrew, emaste, cfe-commits

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

llvm-svn: 320755
2017-12-14 22:32:24 +00:00
Yi Kong 2d58d19c48 [ThreadSafetyAnalysis] Fix isCapabilityExpr
There are many more expr types that can be a capability expr, like
CXXThisExpr, CallExpr, MemberExpr. Instead of enumerating all of them,
just check typeHasCapability for any type given.

Also add & and * operators to allowed unary operators.

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

llvm-svn: 320753
2017-12-14 22:24:45 +00:00
Richard Smith c70f1d63f8 [c++20] P0515R3: Parsing support and basic AST construction for operator <=>.
Adding the new enumerator forced a bunch more changes into this patch than I
would have liked. The -Wtautological-compare warning was extended to properly
check the new comparison operator, clang-format needed updating because it uses
precedence levels as weights for determining where to break lines (and several
operators increased their precedence levels with this change), thread-safety
analysis needed changes to build its own IL properly for the new operator.

All "real" semantic checking for this operator has been deferred to a future
patch. For now, we use the relational comparison rules and arbitrarily give
the builtin form of the operator a return type of 'void'.

llvm-svn: 320707
2017-12-14 15:16:18 +00:00
Erich Keane bd2197c0c1 Fix ICE when __has_unqiue_object_representations called with invalid decl
llvm-svn: 320489
2017-12-12 16:02:06 +00:00
Erich Keane bf5fad86db PR35586: Relax two asserts that are overly restrictive
The two asserts are too aggressive.  In C++  mode, an
enum is NOT considered an integral type, but an enum value
is allowed to be an enum.  This patch relaxes the two asserts
to allow the enum value as well (as typechecking does).

llvm-svn: 320411
2017-12-11 19:44:28 +00:00
Hans Wennborg b1c8f45249 Fix warn-enum-compare.cpp on Windows
It's been failing since r319875.

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

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

Reviewers: rsmith, aaron.ballman

Reviewed By: rsmith

Subscribers: cfe-commits

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

llvm-svn: 320401
2017-12-11 18:29:54 +00:00
Malcolm Parsons d900a0c4e2 [Sema] Fix crash in unused-lambda-capture warning for VLAs
Summary:
Clang was crashing when diagnosing an unused-lambda-capture for a VLA because
From.getVariable() is null for the capture of a VLA bound.
Warning about the VLA bound capture is not helpful, so only warn for the VLA
itself.

Fixes: PR35555

Reviewers: aaron.ballman, dim, rsmith

Reviewed By: aaron.ballman, dim

Subscribers: cfe-commits

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

llvm-svn: 320396
2017-12-11 18:00:36 +00:00
Tim Northover 36bb6d5d46 Switch to gnu++14 as the default dialect.
This is C++14 with conforming GNU extensions.

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

Reviewers: kcc, pcc, alekseyshl

Subscribers: srhines, javed.absar, cfe-commits

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

llvm-svn: 320232
2017-12-09 01:32:07 +00:00
Richard Smith a5370fb82c Unify implementation of our two different flavours of -Wtautological-compare,
and fold together into a single function.

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

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

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

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

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

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

This caused a new warning in Chromium:

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

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

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

llvm-svn: 320162
2017-12-08 16:54:08 +00:00
Richard Smith bf0ad43503 Unify implementation of our two different flavours of -Wtautological-compare.
In so doing, fix a handful of remaining bugs where we would report false
positives or false negatives if we promote a signed value to an unsigned type
for the comparison.

llvm-svn: 320122
2017-12-08 00:45:25 +00:00
Roger Ferrer Ibanez d80d6c5a56 Ignore pointers to incomplete types when diagnosing misaligned addresses
This is a fix for PR35509 in which we crash because we attempt to compute the
alignment of an incomplete type.

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

llvm-svn: 320017
2017-12-07 09:23:50 +00:00
Zhihao Yuan c81f4538ec Allow conditions to be decomposed with structured bindings
Summary:
This feature was discussed but not yet proposed.  It allows a structured binding to appear as a //condition//

    if (auto [ok, val] = f(...))

So the user can save an extra //condition// if the statement can test the value to-be-decomposed instead.  Formally, it makes the value of the underlying object of the structured binding declaration also the value of a //condition// that is an initialized declaration.

Considering its logicality which is entirely evident from its trivial implementation, I think it might be acceptable to land it as an extension for now before I write the paper.

Reviewers: rsmith, faisalv, aaron.ballman

Reviewed By: rsmith

Subscribers: aaron.ballman, cfe-commits

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

llvm-svn: 320011
2017-12-07 07:03:15 +00:00
Richard Smith 251720194f P0722R2: The first parameter in an implicit call to a destroying operator
delete should be a cv-unqualified pointer to the deleted object.

llvm-svn: 319858
2017-12-05 23:54:25 +00:00
Richard Smith d30b23d6a5 [c++2a] P0515R3: Support for overloaded operator<=>.
No CodeGen support for MSABI yet, we don't know how to mangle this there.

llvm-svn: 319513
2017-12-01 02:13:10 +00:00
Erich Keane 8a6b740995 Fix __has_unique_object_representations implementation
As rsmith pointed out, the original implementation of this intrinsic
missed a number of important situations.  This patch fixe a bunch of
shortcomings and implementation details to make it work correctly.

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

llvm-svn: 319446
2017-11-30 16:37:02 +00:00
Richard Smith 527b3966d0 Preserve the "last diagnostic was suppressed" flag across SFINAE checks.
Sometimes we check the validity of some construct between producing a
diagnostic and producing its notes. Ideally, we wouldn't do that, but in
practice running code that "cannot possibly produce a diagnostic" in such a
situation should be safe, and reasonable factoring of some code requires it
with our current diagnostics infrastruture. If this does happen, a diagnostic
that's suppressed due to SFINAE should not cause notes connected to the prior
diagnostic to be suppressed.

llvm-svn: 319408
2017-11-30 08:18:21 +00:00
Aaron Ballman adf66b6174 Determine the attribute subject for diagnostics based on declarative information in DeclNodes.td. This greatly reduces the number of enumerated values used for more complex diagnostics; these are now only required when the "attribute only applies to" diagnostic needs to be generated manually as part of semantic processing.
This also clarifies some terminology used by the diagnostic (methods -> Objective-C methods, fields -> non-static data members, etc).

Many of the tests needed to be updated in multiple places for the diagnostic wording tweaks. The first instance of the diagnostic for that attribute is fully specified and subsequent instances cut off the complete list (to make it easier if additional subjects are added in the future for the attribute).

llvm-svn: 319002
2017-11-26 20:01:12 +00:00
Hamza Sood 81fe14e4c3 [Modules TS] Added module re-export support.
This implements [dcl.modules.export] from the C++ Modules TS, which lets a module re-export another module with the "export import" syntax.
Differential Revision: https://reviews.llvm.org/D40270

llvm-svn: 318744
2017-11-21 09:42:42 +00:00
Hans Wennborg 59ad150939 Revert r318456 "Issue -Wempty-body warnings for else blocks"
This caused warnings also when the if or else comes from macros. There was an
attempt to fix this in r318556, but that introduced new problems and was
reverted. Reverting this too until the whole issue is sorted.

> This looks like it was just an oversight.
>
> Fixes http://llvm.org/pr35319
>
> git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@318456 91177308-0d34-0410-b5e6-96231b3b80d8

llvm-svn: 318667
2017-11-20 17:48:54 +00:00
Hans Wennborg 9541975071 Revert r318556 "Loosen -Wempty-body warning"
It seems this somehow made -Wempty-body fire in some macro cases where
it didn't before, e.g.

  ../../third_party/ffmpeg/libavcodec/bitstream.c(169,5):  error: if statement has empty body [-Werror,-Wempty-body]
      ff_dlog(NULL, "new table index=%d size=%d\n", table_index, table_size);
      ^
  ../../third_party/ffmpeg\libavutil/internal.h(276,80):  note: expanded from macro 'ff_dlog'
  #   define ff_dlog(ctx, ...) do { if (0) av_log(ctx, AV_LOG_DEBUG, __VA_ARGS__); } while (0)
                                                                                 ^
  ../../third_party/ffmpeg/libavcodec/bitstream.c(169,5):  note: put the
  semicolon on a separate line to silence this warning

Reverting until this can be figured out.

> Do not show it when `if` or `else` come from macros.
> E.g.,
>
>     #define USED(A) if (A); else
>     #define SOME_IF(A) if (A)
>
>     void test() {
>       // No warnings are shown in those cases now.
>       USED(0);
>       SOME_IF(0);
>     }
>
> Patch by Ilya Biryukov!
>
> Differential Revision: https://reviews.llvm.org/D40185

llvm-svn: 318665
2017-11-20 17:38:16 +00:00