Alex Lorenz [Wed, 12 Oct 2016 09:36:35 +0000 (09:36 +0000)]
[Sema] Handle transparent_union attributes in C mode only
This commit marks the transparent_union attributes as C only because clang
doesn't support them in C++ mode. Prior to this commit, clang still tried to
verify these attributes in C++, leading to crashes when analyzing templated
transparent_union unions that have dependent field types. This commit ensures
that such crashes won't happen again.
As a result of this commit clang now displays a warning every time it encounters
a transparent_union attribute in C++ mode.
Mehdi Amini [Tue, 11 Oct 2016 19:04:24 +0000 (19:04 +0000)]
Revert "Change Builtins name to be stored as StringRef instead of raw pointers (NFC)"
This reverts commit r283802. It introduces temporarily static
initializers, because StringRef ctor isn't (yet) constexpr for
string literals.
I plan to get there this week, but apparently GCC is so terrible
with these static initializer right now (10 min+ extra codegen
time was reported) that I'll hold on to this patch till the
constexpr one is ready, and land these at the same time.
Reapply [Driver][Diagnostics] Make 'show option names' default for driver warnings
Reapply r283827 by fixing the tests to not be target specific
Currently, driver level warnings do not show option names (e.g. warning:
complain about foo [-Woption-name]) in a diagnostic unless
-fdiagnostics-show-option is explictly specified. OTOH, the driver by
default turn this option on for CC1. Change the logic to show option
names by default in the driver as well.
Justin Lebar [Tue, 11 Oct 2016 17:36:03 +0000 (17:36 +0000)]
[CUDA] Re-land support for <complex> (r283683 and r283680).
These were reverted in r283753 and r283747.
The first patch added a header to the root 'Headers' install directory,
instead of into 'Headers/cuda_wrappers'. This was fixed in the second
patch, but by then the damage was done: The bad header stayed in the
'Headers' directory, continuing to break the build.
We reverted both patches in an attempt to fix things, but that still
didn't get rid of the header, so the Windows boostrap build remained
broken.
It's probably worth fixing up our cmake logic to remove things from the
install dirs, but in the meantime, re-land these patches, since we
believe they no longer have this bug.
Manuel Klimek [Tue, 11 Oct 2016 09:25:34 +0000 (09:25 +0000)]
Delete clang-completion-mode.el.
It has been unmaintained for a while (last change was more than four
years ago), and it appears not widely used.
By now there are multiple well-maintained alternatives (emacs-ycmd,
atuo-complete-clang), and if users try to make this work they'll likely
have a bad user experience.
Reasoning and problems pointed out by Philipp Stephani.
Hal Finkel [Tue, 11 Oct 2016 00:26:09 +0000 (00:26 +0000)]
Add an option to save the backend-produced YAML optimization record to a file
The backend now has the capability to save information from optimizations, the
same information that can be used to generate optimization diagnostics but in
machine-consumable form, into an output file. This can be enabled when using
opt (see r282539), and this change enables it when using clang. The idea is
that other tools will be able to consume these files, and perhaps in
combination with the original source code, produce various kinds of
optimization reports for users (and for compiler developers).
We now have at-least two tools that can consume these files:
* tools/llvm-opt-report
* utils/opt-viewer
Using the flag -fsave-optimization-record will cause the YAML file to be
generated; the file name will be based on the output file name (if we're using
-c or -S and have an output name), or the input file name. When we're using
CUDA, or some other offloading mechanism, separate files are generated for each
backend target. The output file name can be specified by the user using
-foptimization-record-file=filename.
Richard Smith [Tue, 11 Oct 2016 00:21:10 +0000 (00:21 +0000)]
Aligned allocation versus CUDA: make deallocation function preference order
match other CUDA preference orders, per discussion with jlebar. We now model
this in an attempt to match overload resolution as closely as possible:
- First, we throw out all non-callable (due to CUDA host/device mismatch)
operator delete functions.
- Then we apply sizedness / alignedness preferences based on whether the type
is overaligned and whether the deallocation function is a member.
- Finally, we use the CUDA callability preference as a tiebreaker.
[Driver][Diagnostics] Make 'show option names' default for driver warnings
Currently, driver level warnings do not show option names (e.g. warning:
complain about foo [-Woption-name]) in a diagnostic unless
-fdiagnostics-show-option is explictly specified. OTOH, the driver by
default turn this option on for CC1. Change the logic to show option
names by default in the driver as well.
Adrian Prantl [Mon, 10 Oct 2016 21:56:20 +0000 (21:56 +0000)]
[Driver] Let -gline-tables-only win when it comes after -gmodules.
The -gmodules option is all about putting debug type info into clang
modules and for line tables the type information is irrelevant, so
combining these two options makes no sense.
This commmit fixes the behavior to match the one documented on the
clang man page: the last -g... option wins.
Nick Lewycky [Mon, 10 Oct 2016 20:07:13 +0000 (20:07 +0000)]
Make the LValue created in EmitValueForIvarAtOffset have the same Qualifiers in the LValue as the QualType in the LValue. No functionality change intended.
Eric Fiselier [Mon, 10 Oct 2016 14:26:40 +0000 (14:26 +0000)]
[Sema] Prevent using member declaration diagnostic if the base class is invalid.
Summary:
Once a base class has been made invalid (by a static_assert for example) all using-member declarations in the derived classes will result in a "not a base class" diagnostic. This diagnostic is very misleading and should not be emitted.
This change is needed to help libc++ produce reasonable diagnostics in `std::optional` and `std::variant`.
Nico Weber [Mon, 10 Oct 2016 14:10:00 +0000 (14:10 +0000)]
Revert r283680.
Breaks bootstrap builds on (at least) Windows:
In file included from D:\buildslave\clang-x64-ninja-win7\llvm\lib\Support\Allocator.cpp:14:
In file included from D:\buildslave\clang-x64-ninja-win7\llvm\include\llvm/Support/Allocator.h:24:
In file included from D:\buildslave\clang-x64-ninja-win7\llvm\include\llvm/ADT/SmallVector.h:20:
In file included from D:\buildslave\clang-x64-ninja-win7\llvm\include\llvm/Support/MathExtras.h:19:
D:\buildslave\clang-x64-ninja-win7\stage1.install\bin\..\lib\clang\4.0.0\include\algorithm(63,8) :
error: unknown type name '__device__'
inline __device__ const __T &
Michal Gorny [Mon, 10 Oct 2016 12:23:40 +0000 (12:23 +0000)]
[Driver] Make -print-libgcc-file-name print compiler-rt lib when used
Make the -print-libgcc-file-name option print an appropriate compiler
runtime library, that is libgcc.a if gcc runtime is used
and an appropriate compiler-rt library if that runtime is used.
The main use for this is to allow linking executables built with
-nodefaultlibs (e.g. to avoid linking to the standard C++ library) to
the compiler runtime library, e.g. using:
in which case currently a program built like this linked to the gcc
runtime unconditionally. The patch fixes it to use compiler-rt libraries
instead when compiler-rt is the active runtime.
1.'v' constraint for (x86) non-avx arch imitates the already implemented 'x' constraint, i.e. allows XMM{0-15} & YMM{0-15} depending on the apparent arch & mode (32/64).
2.for the avx512 arch it allows [X,Y,Z]MM{0-31} (mode dependent)
This patch applies the needed changes to clang
LLVM patch: https://reviews.llvm.org/D25005
Hal Finkel [Sun, 9 Oct 2016 03:06:31 +0000 (03:06 +0000)]
When optimizing for size, enable loop rerolling by default
We have a loop-rerolling optimization which can be enabled by using
-freroll-loops. While sometimes loops are hand-unrolled for performance
reasons, when optimizing for size, we should always undo this manual
optimization to produce smaller code (our optimizer's unroller will still
unroll the rerolled loops if it thinks that is a good idea).
Justin Lebar [Sat, 8 Oct 2016 22:16:03 +0000 (22:16 +0000)]
[CUDA] Declare our __device__ math functions in the same inline namespace as our standard library.
Summary:
Currently we declare our inline __device__ math functions in namespace
std. But libstdc++ and libc++ declare these functions in an inline
namespace inside namespace std. We need to match this because, in a
later patch, we want to get e.g. <complex> to use our device overloads,
and it only will if those overloads are in the right inline namespace.
Justin Lebar [Sat, 8 Oct 2016 01:07:11 +0000 (01:07 +0000)]
[CUDA] Do a better job at detecting wrong-side calls.
Summary:
Move CheckCUDACall from ActOnCallExpr and BuildDeclRefExpr to
DiagnoseUseOfDecl. This lets us catch some edge cases we were missing,
specifically around class operators.
This necessitates a few other changes:
- Avoid emitting duplicate deferred diags in CheckCUDACall.
Previously we'd carefully placed our call to CheckCUDACall such that
it would only ever run once for a particular callsite. But now this
isn't the case.
- Emit deferred diagnostics from a template
specialization/instantiation's primary template, in addition to from
the specialization/instantiation itself. DiagnoseUseOfDecl ends up
putting the deferred diagnostics on the template, rather than the
specialization, so we need to check both.
Michal Gorny [Fri, 7 Oct 2016 20:04:00 +0000 (20:04 +0000)]
Revert r283572 - [Driver] Make -print-libgcc-file-name print compiler-rt lib when used
Revert the -print-libgcc-file-name change as the new test fails
on Darwin. It needs to be updated to run the libgcc part only on systems
supporting that rtlib.
This is the primary suspect for causing the msvc crash, now that vector of
smart pointers was proven to be safe. Probably the default {}-initializer
is the problem.
Michal Gorny [Fri, 7 Oct 2016 17:08:06 +0000 (17:08 +0000)]
[Driver] Make -print-libgcc-file-name print compiler-rt lib when used
Make the -print-libgcc-file-name option print an appropriate compiler
runtime library, that is libgcc.a if gcc runtime is used
and an appropriate compiler-rt library if that runtime is used.
The main use for this is to allow linking executables built with
-nodefaultlibs (e.g. to avoid linking to the standard C++ library) to
the compiler runtime library, e.g. using:
in which case currently a program built like this linked to the gcc
runtime unconditionally. The patch fixes it to use compiler-rt libraries
instead when compiler-rt is the active runtime.
Richard Smith [Thu, 6 Oct 2016 23:12:58 +0000 (23:12 +0000)]
PR25890: Fix incoherent error handling in PerformImplicitConversion and
CheckSingleAssignmentConstraints. These no longer produce ExprError() when they
have not emitted an error, and reliably inform the caller when they *have*
emitted an error.
This fixes some serious issues where we would fail to emit any diagnostic for
invalid code and then attempt to emit code for an invalid AST, and conversely
some issues where we would emit two diagnostics for the same problem.
Anton Yartsev [Thu, 6 Oct 2016 21:42:21 +0000 (21:42 +0000)]
[analyzer] Add explanation why analyzer report is not generated (fix for PR12421).
Currently if the path diagnostic consumer (e.g HTMLDiagnostics and PlistDiagnostics) do not support cross file diagnostics then the path diagnostic report is silently omitted in the case of cross file diagnostics. The patch adds a little verbosity to Clang in this case.
The patch also adds help entry for the "--analyzer-output" driver option.
Eric Fiselier [Thu, 6 Oct 2016 21:23:38 +0000 (21:23 +0000)]
[coroutines] Fix co_return statement for initializer list arguments
Summary:
Previously the statement `co_return {42}` would be transformed into `P.return_void()`, since the type of `{42}` is represented as `void` by Clang.
This patch fixes the bug by checking for `InitListExpr` arguments and transforming them accordingly.
Richard Smith [Thu, 6 Oct 2016 20:30:51 +0000 (20:30 +0000)]
[modules] Be sure to emit local specializations of imported templates, even if
the resulting specialization is not referenced by the rest of the AST. This
both avoids performing unnecessary reinstantiations in downstream users of the
AST file and fixes a bug (breaking modules self-host right now) where we would
sometimes fail to emit a definition of a class template specialization if we
imported just a declaration of it from elsewhere (see new testcase for reduced
example).
Justin Lebar [Thu, 6 Oct 2016 19:47:56 +0000 (19:47 +0000)]
[Sema] Replace smart quote with "'" in comment.
Looks like the smart quote was copy/pasted from the C++ standard.
The smart quote was not encoded as valid UTF-8 (?), even though vim was
detecting the file as UTF-8. This broke the clang-format Python script,
which tried to read the file using the same encoding as vim detected.