Richard Smith [Sat, 12 Aug 2017 01:46:03 +0000 (01:46 +0000)]
PR34163: Don't cache an incorrect key function for a class if queried between
the class becoming complete and its inline methods being parsed.
This replaces the hack of using the "late parsed template" flag to track member
functions with bodies we've not parsed yet; instead we now use the "will have
body" flag, which carries the desired implication that the function declaration
*is* a definition, and that we've just not parsed its body yet.
George Karpenkov [Fri, 11 Aug 2017 17:22:58 +0000 (17:22 +0000)]
Add -fsanitize=fuzzer-no-link flag to the driver.
The flag will perform instrumentation necessary to the fuzzing,
but will NOT link libLLVMFuzzer.a library.
Necessary when modifying CFLAGS for projects which may produce
executables as well as a fuzzable target.
Alex Lorenz [Fri, 11 Aug 2017 12:06:52 +0000 (12:06 +0000)]
[modules] Set the lexical DC for dummy tag decls that refer to hidden
declarations that are made visible after the dummy is parsed and ODR verified
Prior to this commit the
"(getContainingDC(DC) == CurContext && "The next DeclContext should be lexically contained in the current one."),"
assertion failure was triggered during semantic analysis of the dummy
tag declaration that was declared in another tag declaration because its
lexical context did not point to the outer tag decl.
This is causing failures when compiling clang with -O3
as one of the structures used by clang is passed by
value and uses the fastcc calling convention.
Richard Smith [Fri, 11 Aug 2017 02:04:19 +0000 (02:04 +0000)]
PR33489: A function-style cast to a deduced class template specialization type is type-dependent if it can't be resolved due to a type-dependent argument.
Akira Hatanaka [Fri, 11 Aug 2017 00:06:49 +0000 (00:06 +0000)]
[Sema][ObjC] Fix spurious -Wcast-qual warnings.
We do not meaningfully track object const-ness of Objective-C object
types. Silence the -Wcast-qual warning that is issued when casting to or
from Objective-C object types results in losing const qualification.
Bob Wilson [Thu, 10 Aug 2017 16:42:46 +0000 (16:42 +0000)]
Add a getName accessor for ModuleMacros.
Swift would like to be able to access the name of a ModuleMacro.
There was some discussion of this in
https://github.com/apple/swift-clang/pull/93, suggesting that it makes
sense to have this accessor in Clang.
Momchil Velikov [Thu, 10 Aug 2017 15:43:06 +0000 (15:43 +0000)]
Place implictly declared functions at block scope
Such implicitly declared functions behave as if the enclosing block
contained the declaration extern int name() (C90, 6.3.3.2 Function calls),
thus their names should have block scope (C90, 6.1.2.1 Scope of identifiers).
This patch fixes https://bugs.llvm.org/show_bug.cgi?id=33224
Simon Atanasyan [Thu, 10 Aug 2017 15:42:25 +0000 (15:42 +0000)]
[mips] Show warning in case of mixing -mlong-calls and -mabicalls options
While we do not support `-mshared / -mno-shared` properly, show warning
and ignore `-mlong-calls` option in case of implicitly or explicitly
provided `-mabicalls` option.
Simon Atanasyan [Thu, 10 Aug 2017 15:42:16 +0000 (15:42 +0000)]
[mips] Notify user that `-mabicalls` is ignored on non-PIC N64 ABI
The -mabicalls option does not make sense in the case of non position
independent code for the N64 ABI. After this change the driver shows a
warning that -mabicalls is ignored in that case.
[Modules] Prevent #import to reenter header if not building a module.
When non-modular headers are imported while not building a module but
in -fmodules mode, be conservative and preserve the default #import
semantic: do not reenter headers.
[sanitizer-coverage] Change cmp instrumentation to distinguish const operands
This implementation of SanitizerCoverage instrumentation inserts different
callbacks depending on constantness of operands:
1. If both operands are non-const, then a usual
__sanitizer_cov_trace_cmp[1248] call is inserted.
2. If exactly one operand is const, then a
__sanitizer_cov_trace_const_cmp[1248] call is inserted. The first
argument of the call is always the constant one.
3. If both operands are const, then no callback is inserted.
This separation comes useful in fuzzing when tasks like "find one operand
of the comparison in input arguments and replace it with the other one"
have to be done. The new instrumentation allows us to not waste time on
searching the constant operands in the input.
Nikolai Bozhenov [Thu, 10 Aug 2017 11:22:52 +0000 (11:22 +0000)]
[ValueTracking] Enabling ValueTracking patch by default (recommit). Part 1.
The original patch was an improvement to IR ValueTracking on non-negative
integers. It has been checked in to trunk (D18777, r284022). But was disabled by
default due to performance regressions.
Perf impact has improved. The patch would be enabled by default.
Alex Lorenz [Thu, 10 Aug 2017 10:34:46 +0000 (10:34 +0000)]
Revert r310489 and follow-up commits r310505, r310519, r310537 and r310549
Commit r310489 caused 'openmp-offload.c' test failures on Darwin and other
platforms:
http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-incremental_check/39230/testReport/junit/Clang/Driver/openmp_offload_c/
The follow-up commits tried to fix the test, but the test is still failing.
Petr Hosek [Thu, 10 Aug 2017 04:16:38 +0000 (04:16 +0000)]
[Driver] Search compiler-rt paths in -print-file-name=
This makes it possible to print the name of compiler-rt libraries
by using simply clang -print-file-name=libclang_rt.${runtime}-${arch}.so
same as other libraries, without having to know the details of the
resource directory organization.
[clang-format] let PointerAlignment dictate spacing of function ref qualifiers
Summary: The original changes for ref qualifiers in rL272537 and rL272548 allowed function const+ref qualifier spacing to diverge from the spacing used for variables. It seems more consistent for `T const& x;` to match `void foo() const&;`.
clang-format: Fix bug with ENAS_DontAlign and empty lines
This fixes a bug in `ENAS_DontAlign` (introduced in D32733) where blank lines had an EscapedNewlineColumn of 0, causing a subtraction to overflow when converted back to unsigned and leading to runaway memory allocation.
Coby Tayree [Wed, 9 Aug 2017 21:50:22 +0000 (21:50 +0000)]
[X86][Asm] Allow negative immediate to appear before bracketed expression
Currently, only non-negative immediate is allowed prior to a brac expression (memory reference).
MASM / GAS does not have any problem cope with the left side of the real line, so we should be able to as well.
Matt Arsenault [Wed, 9 Aug 2017 21:44:58 +0000 (21:44 +0000)]
AMDGPU: Use direct struct returns and arguments
This is an improvement over always using byval for
structs.
This will use registers until ~16 are used, and then
switch back to byval. This needs more work, since I'm
not sure it ever really makes sense to use byval. If
the register limit is exceeded, the arguments still
end up passed on the stack, but with a different ABI.
It also may make sense to base this on number of
registers used for non-struct arguments, rather than
just arguments that appear first in the argument list.
Hans Wennborg [Wed, 9 Aug 2017 20:12:53 +0000 (20:12 +0000)]
Make -std=c++17 an alias of -std=c++1z
As suggested on PR33912.
Trying to keep this small to make it easy to merge to the 5.0 branch. We
can do a follow-up with more thorough renaming (diagnostic text,
options, ids, etc.) later.
(For C++14 this was done in r215982, and I think a smaller patch for the
3.5 branch:
http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20140818/113013.html)
[OpenMP] Enable executable lookup into driver directory.
Summary: Invoking the compiler inside a script causes the clang-offload-bundler executable to not be found. This patch enables the lookup for executables in the driver directory where the clang-offload-bundler resides.
Alexey Bataev [Wed, 9 Aug 2017 19:38:53 +0000 (19:38 +0000)]
[OPENMP] Emit non-debug version of outlined functions with original
name.
If the host code is compiled with the debug info, while the target
without, there is a problem that the compiler is unable to find the
debug wrapper. Patch fixes this problem by emitting special name for the
debug version of the code.
[OpenMP] Add flag for disabling the default generation of relocatable OpenMP target code for NVIDIA GPUs.
Summary: Previously we have added the "-c" flag which gets passed to PTXAS by default to generate relocatable OpenMP target code by default. This set of flags exposes control over this behaviour.
Erich Keane [Wed, 9 Aug 2017 15:27:36 +0000 (15:27 +0000)]
Fix broken getAttributeSpellingListIndex for pragma attributes
We noticed when implementing a new pragma that the TableGen-generated function
getAttributeSpellingListIndex() did not work for pragma attributes. It relies
on the values in the enum AttributeList::Syntax and a new value
AS_ContextSensitiveKeyword was added changing the value for AS_Pragma.
Apparently no tests failed since no pragmas currently make use of the
generated function.
To fix this we can move AS_Pragma back to the value that TableGen code expects.
Also to prevent changes in the enum from breaking that routine again I added
calls to getAttributeSpellingListIndex() in the unroll pragma code. That will
cause some lit test failures if the order is changed. I added a comment to
remind of this issue in the future.
This assumes we don’t need/want full TableGen support for
AS_ContextSensitiveKeyword. It currently only appears in getAttrKind and no
other TableGen-generated routines.
Tim Northover [Wed, 9 Aug 2017 14:56:48 +0000 (14:56 +0000)]
Reapply Sema: allow imaginary constants via GNU extension if UDL overloads not present.
C++14 added user-defined literal support for complex numbers so that you
can write something like "complex<double> val = 2i". However, there is
an existing GNU extension supporting this syntax and interpreting the
result as a _Complex type.
This changes parsing so that such literals are interpreted in terms of
C++14's operators if an overload is present but otherwise falls back to
the original GNU extension.
(We now have more robust diagnostics for implicit conversions so the
libc++ test that caused the original revert still passes).
Coby Tayree [Wed, 9 Aug 2017 13:31:41 +0000 (13:31 +0000)]
[X86][Ms-InlineAsm] Extend MS Dot operator to accept "this" + struct/class pointers aliases
MS InlineAsm Dot operator accepts "Bases" such as "this" (cpp) and class/struct pointer typedef.
This patch enhance its implementation with this behavior.
It was timing out on this test, but for reasons unrelated to the
specific bug it was testing for. Randomly breaking in gdb with `clang
-target i686-windows -fmsc-version=1700` reveals *many* frames from
MicrosoftCXXNameMangler. So, it would seem that some caching is needed
there, as well...
Fingers crossed that specifying a triple is sufficient to work around
this.
[AST] Move visibility computations into a class; NFC
This is patch 1 in a 2 patch series that aims to fix PR29160. Its goal
is to cache decl visibility/linkage for the duration of each
visibility+linkage query.
The simplest way I can see to do this is to put the visibility
calculation code that needs to (transitively) access this cache into a
class, which is what this patch does. Actual caching will come in patch
2. (Another way would be to keep the cache in ASTContext + manually
invalidate it or something, but that felt way too subtle to me.)
Caching visibility results across multiple queries seems a bit tricky,
since the user can add visibility attributes ~whenever they want, and
these attributes can apparently have far-reaching effects (e.g. class
visibility extends to its members, ...). Because a cache that's dropped
at the end of each top-level query seems to work nearly as well and
doesn't require any eviction logic, I opted for that design.
Richard Trieu [Wed, 9 Aug 2017 02:03:59 +0000 (02:03 +0000)]
Allow operator delete to be an invalid Decl.
Do not discard invalid Decl when searching for the operator delete function.
The lookup for this function always expects to find a result, so sometimes the
invalid Decl is the only choice possible. This fixes PR34109.
Tim Northover [Tue, 8 Aug 2017 23:18:05 +0000 (23:18 +0000)]
Sema: disable implicit conversion from _Complex to real types in C++.
Converting a _Complex type to a real one simply discards the imaginary part.
This can easily lead to loss of information so for safety (and GCC
compatibility) this patch disallows that when the conversion would be implicit.
The one exception is bool, which actually compares both real and imaginary
parts and so is safe.
Matt Morehouse [Tue, 8 Aug 2017 20:15:04 +0000 (20:15 +0000)]
Integrate Kostya's clang-proto-fuzzer with LLVM.
Summary:
The clang-proto-fuzzer models a subset of C++ as a protobuf and
uses libprotobuf-mutator to generate interesting mutations of C++
programs. Clang-proto-fuzzer has already found several bugs in
Clang (e.g., https://bugs.llvm.org/show_bug.cgi?id=33747,
https://bugs.llvm.org/show_bug.cgi?id=33749).
As with clang-fuzzer, clang-proto-fuzzer requires the following
cmake flags:
- CMAKE_C_COMPILER=clang
- CMAKE_CXX_COMPILER=clang++
- LLVM_USE_SANITIZE_COVERAGE=YES // needed for libFuzzer
- LLVM_USE_SANITIZER=Address // needed for libFuzzer
In addition, clang-proto-fuzzer requires:
- CLANG_ENABLE_PROTO_FUZZER=ON
clang-proto-fuzzer also requires the following dependencies:
- binutils // needed for libprotobuf-mutator
- liblzma-dev // needed for libprotobuf-mutator
- libz-dev // needed for libprotobuf-mutator
- docbook2x // needed for libprotobuf-mutator
- Recent version of protobuf [3.3.0 is known to work]
A working version of libprotobuf-mutator will automatically be
downloaded and built as an external project.
Implementation of clang-proto-fuzzer provided by Kostya
Serebryany.
Eli Friedman [Tue, 8 Aug 2017 20:10:14 +0000 (20:10 +0000)]
[coverage] Special-case calls to noreturn functions.
The code after a noreturn call doesn't execute.
The pattern in the testcase is pretty common in LLVM (a switch with
a default case that calls llvm_unreachable).
The original version of this patch was reverted in r309995 due to a
crash. This version includes a fix for that crash (testcase in
test/CoverageMapping/md.cpp).
Josh Gao [Tue, 8 Aug 2017 19:44:35 +0000 (19:44 +0000)]
Thread Safety Analysis: warn on nonsensical attributes.
Add warnings in cases where an implicit `this` argument is expected to
attributes because either `this` doesn't exist because the attribute is
on a free function, or because `this` is on a type that doesn't have a
corresponding capability/lockable/scoped_lockable attribute.
Richard Smith [Tue, 8 Aug 2017 19:12:28 +0000 (19:12 +0000)]
PR19668, PR23034: Fix handling of move constructors and deleted copy
constructors when deciding whether classes should be passed indirectly.
This fixes ABI differences between Clang and GCC:
* Previously, Clang ignored the move constructor when making this
determination. It now takes the move constructor into account, per
https://github.com/itanium-cxx-abi/cxx-abi/pull/17 (this change may
seem recent, but the ABI change was agreed on the Itanium C++ ABI
list a long time ago).
* Previously, Clang's behavior when the copy constructor was deleted
was unstable -- depending on whether the lazy declaration of the
copy constructor had been triggered, you might get different behavior.
We now eagerly declare the copy constructor whenever its deletedness
is unclear, and ignore deleted copy/move constructors when looking for
a trivial such constructor.
This also fixes an ABI difference between Clang and MSVC:
* If the copy constructor would be implicitly deleted (but has not been
lazily declared yet), for instance because the class has an rvalue
reference member, we would pass it directly. We now pass such a class
indirectly, matching MSVC.
Aaron Ballman [Tue, 8 Aug 2017 18:07:17 +0000 (18:07 +0000)]
Restore previous structure ABI behavior for bit-fields with the packed attribute for PS4 targets.
An ABI change was introduced in r254596 that modified structure layouts when the 'packed' attribute was used on one-byte bitfields. Since the PS4 target needs to maintain backwards compatibility for all structure layouts, this change reintroduces the old behavior for PS4 targets only. It also introduces PS4 specific cases to the relevant test.
Alexey Bataev [Tue, 8 Aug 2017 18:04:06 +0000 (18:04 +0000)]
[OPENMP][DEBUG] Set proper address space info if required by target.
Arguments, passed to the outlined function, must have correct address
space info for proper Debug info support. Patch sets global address
space for arguments that are mapped and passed by reference.
Also, cuda-gdb does not handle reference types correctly, so reference
arguments are represented as pointers.
Craig Topper [Tue, 8 Aug 2017 17:43:44 +0000 (17:43 +0000)]
[X86] Support 'avx5124vnniw' and 'avx5124fmaps' for __builtin_cpu_supports.
They still need to be implemented in the intrinsics, the command line, and the backend. But this change isn't dependent on any of that and resolves a TODO.
Alexey Bataev [Tue, 8 Aug 2017 16:29:11 +0000 (16:29 +0000)]
[OPENMP][DEBUG] Set proper address space info if required by target.
Arguments, passed to the outlined function, must have correct address
space info for proper Debug info support. Patch sets global address
space for arguments that are mapped and passed by reference.
Also, cuda-gdb does not handle reference types correctly, so reference
arguments are represented as pointers.
Nico Weber [Tue, 8 Aug 2017 16:21:23 +0000 (16:21 +0000)]
Use "foo-12345.o.tmp" instead of "foo.o-12345" as temporary file name.
This helps some tools that do things based on the output's extension.
For example, we got reports from users on Windows that have a tool that scan a
build output dir (but skip .obj files). The tool would keep the "foo.obj-12345"
file open, and then when clang tried to rename the temp file to the final
output filename, that would fail. By making the tempfile end in ".obj.tmp",
tools like this could now have a rule to ignore .tmp files.
This is a less ambitious reland of https://reviews.llvm.org/D36238
Martin Probst [Tue, 8 Aug 2017 15:00:58 +0000 (15:00 +0000)]
clang-format: [JS] fix union type spacing in object & array types.
Summary:
Previously, clang-format would insert whitespace in union types nested in object
and array types, as it wouldn't recognize those as a type operator:
[OpenMP] OpenMP device offloading code generation produces a cubin file which is then integrated in the host binary using the host linker.
Diff: D29654
Alexey Bataev [Tue, 8 Aug 2017 14:25:14 +0000 (14:25 +0000)]
[OPENMP][DEBUG] Set proper address space info if required by target.
Arguments, passed to the outlined function, must have correct address
space info for proper Debug info support. Patch sets global address
space for arguments that are mapped and passed by reference.
Also, cuda-gdb does not handle reference types correctly, so reference
arguments are represented as pointers.
Alex Lorenz [Tue, 8 Aug 2017 11:20:17 +0000 (11:20 +0000)]
Revert r310291, r310300 and r310332 because of test failure on Darwin
The commit r310291 introduced the failure. r310332 was a test fix commit and
r310300 was a followup commit. I reverted these two to avoid merge conflicts
when reverting.
The 'openmp-offload.c' test is failing on Darwin because the following
run lines:
// RUN: touch %t1.o
// RUN: touch %t2.o
// RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -save-temps -no-canonical-prefixes %t1.o %t2.o 2>&1 \
// RUN: | FileCheck -check-prefix=CHK-TWOCUBIN %s
trigger the following assertion:
Driver.cpp:3418:
assert(CachedResults.find(ActionTC) != CachedResults.end() &&
"Result does not exist??");