Commit Graph

38257 Commits

Author SHA1 Message Date
Erich Keane 8a410bcef0 Fix Calling Convention through aliases
r369697 changed the behavior of stripPointerCasts to no longer include
aliases.  However, the code in CGDeclCXX.cpp's createAtExitStub counted
on the looking through aliases to properly set the calling convention of
a call.

The result of the change was that the calling convention mismatch of the
call would be replaced with a llvm.trap, causing a runtime crash.

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

llvm-svn: 373929
2019-10-07 17:28:03 +00:00
Hans Wennborg 32b47ddb2d clang-cl: Ignore the new /ZH options
These were added to the MS docs in
85b9b6967e
and are supposedly available in VS 2019 16.4 (though my 2019 Preview,
version 16.4.0-pre.1.0 don't seem to have them.)

llvm-svn: 373887
2019-10-07 09:30:15 +00:00
Richard Smith df3761f6dc [c++20] Check for a class-specific operator delete when deleting an
object of class type with a virtual destructor.

llvm-svn: 373875
2019-10-07 03:14:28 +00:00
Richard Smith 74ce7112c3 Fix behavior of __builtin_bit_cast when the From and To types are the
same.

We were missing the lvalue-to-rvalue conversion entirely in this case,
and in fact still need the full CK_LValueToRValueBitCast conversion to
perform a load with no TBAA.

llvm-svn: 373874
2019-10-07 02:45:12 +00:00
Richard Smith 344df110e5 Implements CWG 1601 in [over.ics.rank/4.2]
Summary:
The overload resolution for enums with a fixed underlying type has changed in the C++14 standard. This patch implements the new rule.

Patch by Mark de Wever!

Reviewers: rsmith

Reviewed By: rsmith

Subscribers: cfe-commits

Tags: #clang

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

llvm-svn: 373866
2019-10-06 18:50:40 +00:00
Richard Smith 1e9c0cecab [Sema] Avoids an assertion failure when an invalid conversion declaration is used
Summary:
When using a user-defined conversion function template with a deduced return type the compiler gives a set of warnings:
```
bug.cc:252:44: error: cannot specify any part of a return type in the declaration of a conversion function; use an alias template to declare a conversion to 'auto (Ts &&...) const'
  template <typename... Ts> operator auto()(Ts &&... xs) const;
                                           ^~~~~~~~~~~~~~~~~~~
bug.cc:252:29: error: conversion function cannot convert to a function type
  template <typename... Ts> operator auto()(Ts &&... xs) const;
                            ^
error: pointer to function type cannot have 'const' qualifier
```
after which it triggers an assertion failure. It seems the last error is incorrect and doesn't have any location information. This patch stops the compilation after the second warning.

Fixes bug 31422.

Patch by Mark de Wever!

Reviewers: rsmith

Reviewed By: rsmith

Subscribers: bbannier, cfe-commits

Tags: #clang

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

llvm-svn: 373862
2019-10-06 18:40:59 +00:00
Sanjay Patel c38881a6b7 [InstCombine] don't assume 'inbounds' for bitcast pointer to GEP transform (PR43501)
https://bugs.llvm.org/show_bug.cgi?id=43501
We can't declare a GEP 'inbounds' in general. But we may salvage that information if
we have known dereferenceable bytes on the source pointer.

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

llvm-svn: 373847
2019-10-06 13:08:08 +00:00
David Bolvansky 3acc649b86 [NFCI] Slightly improve warning message
llvm-svn: 373818
2019-10-05 08:09:06 +00:00
David Bolvansky 559265c8da [Diagnostics] Use Expr::isKnownToHaveBooleanValue() to check bitwise negation of bool in languages without a bool type
Thanks for this advice, Richard Trieu!

llvm-svn: 373817
2019-10-05 08:02:11 +00:00
Yuanfang Chen 442ddffe13 [clang] fix a typo from r372531
Reviewers: xbolva00

Subscribers: cfe-commits

Tags: #clang

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

llvm-svn: 373792
2019-10-04 21:37:20 +00:00
Erik Pilkington f7766b1ed4 [Sema] Split out -Wformat-type-confusion from -Wformat-pedantic
The warnings now in -Wformat-type-confusion don't align with how we interpret
'pedantic' in clang, and don't belong in -pedantic.

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

llvm-svn: 373774
2019-10-04 19:20:27 +00:00
Alexey Bataev 1c9e1731b0 [OPENMP50]Suppport for multiple vendors in the same vendor context
selector.

According to OpenMP 5.0, multiple vendors could be specified in the
vendor context selector via ',' as a separator.

llvm-svn: 373756
2019-10-04 15:58:45 +00:00
Sam McCall f44ca7f6eb Further improve -Wbool-operation bitwise negation message
llvm-svn: 373749
2019-10-04 14:11:05 +00:00
Haojian Wu 5d862c042b [clang-rename] Fix a crash when renaming a class without definition.
Reviewers: sammccall

Subscribers: cfe-commits

Tags: #clang

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

llvm-svn: 373748
2019-10-04 14:09:31 +00:00
Simon Tatham f8ad4d663f [clang] Prevent false positives in arm-mfpu-none codegen test.
A user pointed out to me in private email that this test will fail if
it sees the letter 's' followed by a digit in any part of clang's
assembly output after the function label. That includes the .ident at
the end, which can include a full pathname or hostname or both from
the system clang was built on. So if that path or hostname includes
any text like 's5' then it will cause the test to fail.

Fixed by adding a check for `.fnend`, to limit the scope of the
`CHECK-NOT` to only the actual generated code for the test function.

(Committed without prior review on the basis that it's a simple and
obvious pure test-suite fix and also in a test I contributed myself.)

llvm-svn: 373744
2019-10-04 13:01:41 +00:00
David Bolvansky 5e851ad6c1 [NFCI] Improve the -Wbool-operation's warning message
Based on the request from the post commit review. Also added one new test.

llvm-svn: 373743
2019-10-04 12:55:13 +00:00
Ilya Biryukov 8613e90ba7 [CodeComplete] Ensure object is the same in compareOverloads()
Summary:
This fixes a regression that led to size() not being available in clangd
when completing 'deque().^' and using libc++.

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: jkorous, arphaman, kadircet, usaxena95, cfe-commits

Tags: #clang

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

llvm-svn: 373710
2019-10-04 08:10:27 +00:00
Richard Smith 772e266fbf Properly handle instantiation-dependent array bounds.
We previously failed to treat an array with an instantiation-dependent
but not value-dependent bound as being an instantiation-dependent type.
We now track the array bound expression as part of a constant array type
if it's an instantiation-dependent expression.

llvm-svn: 373685
2019-10-04 01:25:59 +00:00
Alexey Bataev a92b5309e5 [OPENMP]Fix the test on Windows, NFC.
llvm-svn: 373672
2019-10-03 22:10:33 +00:00
Alexey Bataev 0364c760ad [OPENMP50]Codegen support for scores in context selectors.
If the context selector has associated score and several contexts
selectors matches current context, the function with the highest score
must be selected.

llvm-svn: 373661
2019-10-03 20:49:48 +00:00
Yaxun Liu 99d0d3ae90 [HIP] Use option -nogpulib to disable linking device lib
Differential Revision: https://reviews.llvm.org/D68300

llvm-svn: 373649
2019-10-03 18:59:56 +00:00
Richard Smith 5d96b4ce28 Check for qualified function types after substituting into the operand
of 'typeid'.

This is a rare place where it's valid for a function type to be
substituted but not valid for a qualified function type to be
substituted, so needs a special check.

llvm-svn: 373648
2019-10-03 18:55:23 +00:00
Richard Smith 8d2eaf9239 PR43547: substitute into the type of a non-type template parameter if
it's instantiation-dependent, even if it's not dependent.

There might be a SFINAE check in the parameter type.

llvm-svn: 373643
2019-10-03 18:24:40 +00:00
Michael Liao 691e44c146 [HIP] Enable specifying different default gpu arch for HIP/CUDA.
Reviewers: tra, yaxunl

Subscribers: cfe-commits

Tags: #clang

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

llvm-svn: 373634
2019-10-03 17:49:20 +00:00
Alexey Bataev 36724b78e8 [OPENMP]Fix emission of the declare target variables in device mode.
Declare target variables must be emitted in device mode, target triples
can be empty in this case.

llvm-svn: 373624
2019-10-03 16:46:49 +00:00
Alexey Bataev ba643691dd [OPENMP]Improve diagnostics for not found declare target entries.
We can point to the target region + emit parent functions names/real var
names if they were not found in host module during device codegen.

llvm-svn: 373620
2019-10-03 16:20:34 +00:00
David Bolvansky b4ee523ffc [Diagnostics] Bitwise negation of a boolean expr always evaluates to true; warn with -Wbool-operation
Requested here:
http://lists.llvm.org/pipermail/cfe-dev/2019-October/063452.html

llvm-svn: 373614
2019-10-03 15:17:59 +00:00
Serge Pavlov 110a24fb44 Fix driver tests when `LLVM_ENABLE_PER_TARGET_RUNTIME_DIR` is `ON`
Some Driver tests relied on the default resource direcory having per-os per-arch
subdirectory layout, and when clang is built with `-DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON`,
those test fail, because clang by default assumes per-target subdirectories.

Explicitly set `-resource-dir` flag to point to a tree with per-os per-arch layout.

See also: D45604, D62469

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

Patch by Sergej Jaskiewicz <jaskiewiczs@icloud.com>.

llvm-svn: 373565
2019-10-03 04:52:46 +00:00
Yaxun Liu f13b8d4fe9 [HIP] Support -emit-llvm for device compilation
Sometimes it is useful to compile HIP device code to LLVM BC. It is not convenient to use clang -cc1 since
there are lots of options needed.

This patch allows clang driver to compile HIP device code to LLVM BC with -emit-llvm -c.

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

llvm-svn: 373561
2019-10-03 03:27:43 +00:00
Nico Weber 6713f8235b Revert 373538 and follow-ups 373549 and 373552.
They break tests on (at least) macOS.

llvm-svn: 373556
2019-10-03 02:38:43 +00:00
Richard Smith 5258202a81 PR43519: don't inject a diagnostic when constant-evaulation of a
pointer-to-member call can't determine a callee.

We will have produced a diagnostic already if the callee is known to be
unevaluatable, and diagnosing here rejects valid code during potential
constant expression checking.

llvm-svn: 373553
2019-10-03 01:20:27 +00:00
Puyan Lotfi 30c8df02ba Fixing broken builds due to r373538, issues with filepath and hexagon toolchain.
It appears there are some issues with the hexagon toolchain, and also the file
path for the library file. If this doesn't fix the remaining breakages I will
attempt a revert.

llvm-svn: 373552
2019-10-03 01:19:51 +00:00
Puyan Lotfi 8581f860c7 Fixing broken builds due to r373538 due to test that should have been deleted.
test/InterfaceStubs/object.cpp should have been deleted.

llvm-svn: 373549
2019-10-03 00:41:13 +00:00
Richard Smith 69e9d84b1a Mark P0784R7 as complete and start defining its feature-test macro.
Note that this only covers the language side of this feature. (The
library side has its own feature test macro.)

llvm-svn: 373548
2019-10-03 00:39:37 +00:00
Richard Smith b542602c5f For P0784R7: support placement new-expressions in constant evaluation.
For now, we restrict this support to use from within the standard
library implementation, since we're required to make parts of the
standard library that use placement new work, but not permitted to
make uses of placement new from user code work.

llvm-svn: 373547
2019-10-03 00:39:35 +00:00
Richard Smith 19ad523971 For P0784R7: allow direct calls to operator new / operator delete from
std::allocator::{allocate,deallocate} in constant evaluation.

llvm-svn: 373546
2019-10-03 00:39:33 +00:00
Puyan Lotfi 406de17b9b [clang][ifs] Clang Interface Stubs ToolChain plumbing.
This patch enables end to end support for generating ELF interface stubs
directly from clang. Now the following:

clang -emit-interface-stubs -o libfoo.so a.cpp b.cpp c.cpp

will product an ELF binary with visible symbols populated. Visibility attributes
and -fvisibility can be used to control what gets populated.

* Adding ToolChain support for clang Driver IFS Merge Phase
* Implementing a default InterfaceStubs Merge clang Tool, used by ToolChain
* Adds support for the clang Driver to involve llvm-ifs on ifs files.
* Adds -emit-merged-ifs flag, to tell llvm-ifs to emit a merged ifs text file
  instead of the final object format (normally ELF)


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

llvm-svn: 373538
2019-10-02 22:50:07 +00:00
Alexey Bataev a15a1413ac [OPENMP50]Add parsing/sema analysis for declare variant score.
Context selectors may include optional score clause in format
`score(<expr>):`, where `<expr>` must be a constant integer expression.
Added parsing/sema analysis only.

llvm-svn: 373502
2019-10-02 18:19:02 +00:00
Haojian Wu fbd134f969 [clang-rename] Better renaming the typedef decl.
Summary:
when renaming a typedef decl, we used to rename the underlying decl of the
typedef, we should rename the typedef itself.

Subscribers: cfe-commits

Tags: #clang

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

llvm-svn: 373440
2019-10-02 09:50:46 +00:00
Richard Trieu e388725316 Revert r368237 - Update fix-it hints for std::move warnings.
r368237 attempted to improve fix-its for move warnings, but introduced some
regressions to -Wpessimizing-move.  Revert that change and add the missing
test cases to the pessimizing move test to prevent future regressions.

llvm-svn: 373421
2019-10-02 02:32:15 +00:00
Richard Smith 5e18f4db08 Fix crash on constant-evaluation of pseudo-destruction of a pointer.
We got confused and thought we might be pseudo-destroying the pointee
instead.

llvm-svn: 373418
2019-10-02 01:13:57 +00:00
Alexey Bataev 2df5f12ea1 [OPENMP50]Initial codegen for declare variant implementation vendor.
Initial implementation of global aliases emission for the declare
variant pragma with implementation vendor context selector set.

llvm-svn: 373387
2019-10-01 20:18:32 +00:00
David Bolvansky 1f345cb05d [NFC] Updated tests after rL373371
Forgot to run check-clang-semacxx.

llvm-svn: 373375
2019-10-01 18:18:45 +00:00
Alexey Bataev b9b8ca2334 [OPENMP]Fix PR43330: OpenMP target: Mapping of partial arrays fails.
Fixed calculation the size of the array sections.

llvm-svn: 373374
2019-10-01 18:18:03 +00:00
David Bolvansky 00d632e089 [Diagnostics] Make -Wenum-compare-conditional off by default
Too many false positives, eg. in Chromium.

llvm-svn: 373371
2019-10-01 18:12:13 +00:00
Teresa Johnson dca5b94e79 [ThinLTO] Enable index-only WPD from clang
Summary:
To trigger the index-only Whole Program Devirt support added to LLVM, we
need to be able to specify -fno-split-lto-unit in conjunction with
-fwhole-program-vtables. Keep the default for -fwhole-program-vtables as
-fsplit-lto-unit, but don't error on that option combination.

Reviewers: pcc

Subscribers: mehdi_amini, inglorion, steven_wu, dexonsmith, arphaman, cfe-commits

Tags: #clang

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

llvm-svn: 373370
2019-10-01 18:08:29 +00:00
Alexey Bataev 658ad4d4d2 [OPENMP]Fix PR43516: Compiler crash with collapse(2) on non-rectangular
loop.

Missed check if the condition is also dependent when building final
expressions for the collapsed loop directives.

llvm-svn: 373348
2019-10-01 16:19:10 +00:00
David Bolvansky 362055d1fa [Diagnostics] Move warning into the subgroup (-Wenum-compare-conditional)
llvm-svn: 373345
2019-10-01 15:44:38 +00:00
Kadir Cetinkaya fd019ed54e [clang] Make handling of unnamed template params similar to function params
Summary:
Clang uses the location identifier should be inserted for declarator
decls when a decl is unnamed. But for type template and template template
paramaters it uses the location of "typename/class" keyword, which makes it hard
for tooling to insert/change parameter names.

This change tries to unify these two cases by making template parameter
parsing and sourcerange operations similar to function params/declarator decls.

Reviewers: ilya-biryukov

Subscribers: arphaman, cfe-commits

Tags: #clang

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

llvm-svn: 373340
2019-10-01 14:08:51 +00:00
Raphael Isemann ed5a8971ec [clang] Ignore builtin namespaces in test/Import/cxx-anon-namespace
Some platforms (e.g. AArch64) put __va_list in the 'std' namespace which might
end up being the first namespace we match in this test. Instead let
the first namespace match via file name/line so that we skip the
builtin namespaces.

llvm-svn: 373327
2019-10-01 11:53:20 +00:00