Tony Jiang [Tue, 15 Nov 2016 14:30:56 +0000 (14:30 +0000)]
[PowerPC] Implement BE VSX load/store builtins - clang portion.
This patch implements all the overloads for vec_xl_be and vec_xst_be. On BE,
they behaves exactly the same with vec_xl and vec_xst, therefore they are
simply implemented by defining a matching macro. On LE, they are implemented
by defining new builtins and intrinsics. For int/float/long long/double, it
is just a load (lxvw4x/lxvd2x) or store(stxvw4x/stxvd2x). For char/char/short,
we also need some extra shuffling before or after call the builtins to get the
desired BE order. For int128, simply call vec_xl or vec_xst.
Michal Gorny [Tue, 15 Nov 2016 12:54:10 +0000 (12:54 +0000)]
[test] Correctly include build llvm_shlib_dir in stand-alone builds
Add the build llvm_shlib_dir into LD_LIBRARY_PATH before the directory
specified as llvm_libs_dir, in order to fix stand-alone builds
attempting to use installed clang libraries.
In case of stand-alone builds llvm_libs_dir specifies the location of
installed LLVM libraries which can also contain an older version
(previous build) of clang libraries. Therefore, ensure to specify
llvm_shlib_dir (which is always the build tree path) before
the potentially-system llvm_libs_dir.
Alexey Bataev [Tue, 15 Nov 2016 09:11:50 +0000 (09:11 +0000)]
[OPENMP] Fixed codegen for 'omp cancel' construct.
If 'omp cancel' construct is used in a worksharing construct it may cause
hanging of the software in case if reduction clause is used. Patch fixes
this problem by avoiding extra reduction processing for branches that
were canceled.
Dominic Chen [Tue, 15 Nov 2016 01:54:41 +0000 (01:54 +0000)]
[analyzer] Rename assumeWithinInclusiveRange*()
Summary: The name is slightly confusing, since the constraint is not necessarily within the range unless `Assumption` is true. Split out renaming for ConstraintManager.h from D26061
Kuba Brecka [Mon, 14 Nov 2016 22:38:57 +0000 (22:38 +0000)]
[sanitizer] Passthrough CMAKE_OSX_DEPLOYMENT_TARGET when building compiler-rt from clang/runtime/CMakeLists.txt
This breaks some Swift builds, because Swift's build scripts explicitly set CMAKE_OSX_DEPLOYMENT_TARGET. This however isn't propagated to the compiler-rt build, causing build errors.
Sean Fertile [Mon, 14 Nov 2016 18:47:15 +0000 (18:47 +0000)]
[PPC] altivec.h functions for converting half precision to single precision.
Adds 2 vector functions for converting from a vector of unsigned short to a
vector of float. One converts the low 4 halfwords and one converts the high
4 halfwords.
[OpenCL] Fix for integer parameters of enqueue_kernel
Make handling integer parameters more flexible:
- For the number of events argument allow to pass larger
integers than 32 bits as soon as compiler can prove that
the range fits in 32 bits. If not, the diagnostic will be given.
- Change type of the arguments specifying the sizes of
the corresponding block arguments to be size_t.
[OpenCL] Change to clk_event parameter in enqueue_kernel.
- Accept NULL pointer as a valid parameter value for clk_event.
- Generate clk_event_t arguments of internal
__enqueue_kernel_XXX function as pointers in generic address space.
Sean Fertile [Mon, 14 Nov 2016 14:43:27 +0000 (14:43 +0000)]
[PPC] add extract sig/exp test data class for vec float and vec double.
Add vector extract exponent/significand functions to altivec.h, as well as
functions (and related constants) to test the data class of vector float
and vector double.
[OpenCL] always use SPIR address spaces for kernel_arg_addr_space MD
It doesn't make sense to use the target's address space ids in this context as
this is metadata that should be referring to the "logical" OpenCL address spaces.
For flat AS machines like all "CPUs" in general, the logical AS info gets lost as
there's only one address space (0).
This commit changes the logic such that we always use the SPIR address space
ids for the argument metadata. It thus allows implementing the clGetKernelArgInfo()
and the other detection needs.
Faisal Vali [Sun, 13 Nov 2016 06:09:16 +0000 (06:09 +0000)]
Fix PR28366: Handle variables from enclosing local scopes more gracefully during constant expression evaluation.
Only look for a variable's value in the constant expression evaluation activation frame, if the variable was indeed declared in that frame, otherwise it might be a constant expression and be usable within a nested local scope or emit an error.
void f(char c) {
struct X {
static constexpr char f() {
return c; // error gracefully here as opposed to crashing.
}
};
int I = X::f();
}
Serge Pavlov [Sat, 12 Nov 2016 15:38:55 +0000 (15:38 +0000)]
Use descriptive message if list initializer is incorrectly parenthesized.
If initializer contains parentheses around braced list where it is not allowed,
as in construct int({0}), clang issued message like `functional-style cast
from 'void' to 'int' is not allowed`, which does not help much. Both gcc and
msvc issue message `list-initializer for non-class type must not be
parenthesized`, which is more descriptive. This change implements similar
message for clang.
Devin Coughlin [Sat, 12 Nov 2016 01:23:01 +0000 (01:23 +0000)]
[analyzer] Fix copy-pasta in NullableReturnedFromNonnullChecker checker name.
The name of the NullableReturnedFromNonnullChecker in Checkers.td
was accidentally "NullablePassedToNonnull", which made it impossible
to explicitly turn the checker on.
Devin Coughlin [Sat, 12 Nov 2016 01:03:06 +0000 (01:03 +0000)]
[analyzer] Improve misleading RetainCountChcker diagnostic under ARC
Under automated reference counting the analyzer treats a methods -- even those
starting with 'copy' and friends -- as returning an unowned value. This is
because ownership of CoreFoundation objects must be transferred to ARC
with __bridge_transfer or CFBridgingRelease() before being returned as
ARC-managed bridged objects.
Unfortunately this could lead to a poor diagnostic inside copy methods under
ARC where the analyzer would complain about a leak of a returned CF value inside
a method "whose name does not start with 'copy'" -- even though the name did
start with 'copy'.
This commit improves the diagnostic under ARC to say inside a method "returned
from a method managed by Automated Reference Counting".
Anna Zaks [Fri, 11 Nov 2016 23:22:44 +0000 (23:22 +0000)]
[tsan][clang] Introduce a function attribute to disable TSan checking at run time
This introduces a function annotation that disables TSan checking for the
function at run time. The benefit over attribute((no_sanitize("thread")))
is that the accesses within the callees will also be suppressed.
The motivation for this attribute is a guarantee given by the objective C
language that the calls to the reference count decrement and object
deallocation will be synchronized. To model this properly, we would need to
intercept all ref count decrement calls (which are very common in ObjC due
to use of ARC) and also every single message send. Instead, we propose to
just ignore all accesses made from within dealloc at run time. The main
downside is that this still does not introduce any synchronization, which
means we might still report false positives if the code that relies on this
synchronization is not executed from within dealloc. However, we have not
seen this in practice so far and think these cases will be very rare.
(This problem is similar in nature to https://reviews.llvm.org/D21609;
unfortunately, the same solution does not apply here.)
Richard Trieu [Fri, 11 Nov 2016 21:50:39 +0000 (21:50 +0000)]
Remove double setting of invalid flag.
In r286630, Decl::setInvalidDecl will automatically set the invalid flag for
BindingDecl for children in invalid DecompositionDecl. It no longer is
necessary to do a separate setInvalidDecl when finalizing a BindingDecl.
Devin Coughlin [Fri, 11 Nov 2016 21:31:38 +0000 (21:31 +0000)]
[analyzer] Teach RetainCountChecker about VTCompressionSessionEncodeFrame()
The context argument passed to VideoToolbox's
VTCompressionSessionEncodeFrame() function is ultimately passed to a callback
supplied when creating the compression session and so may be freed by that
callback. To suppress false positives in this case, teach the retain count
checker to stop tracking that argument.
This isn't suppressed by the usual callback context mechanism because the call
to VTCompressionSessionEncodeFrame() doesn't include the callback itself.
Douglas Katzman [Fri, 11 Nov 2016 16:51:40 +0000 (16:51 +0000)]
Fix mismatched enum value name and diagnostic text.
ExpectedFunctionGlobalVarMethodOrProperty
would previously say "functions and global variables"
instead of "functions, methods, properties, and global variables"
The newly added ExpectedFunctionOrGlobalVariable
says "functions and global variables"
Alexey Bataev [Fri, 11 Nov 2016 12:36:20 +0000 (12:36 +0000)]
Fix for PR28523: unexpected compilation error.
Clang emits error message for the following code:
```
template <class F> void parallel_loop(F &&f) { f(0); }
int main() {
int x;
parallel_loop([&](auto y) {
{
x = y;
};
});
}
```
$ clang++ --std=gnu++14 clang_test.cc -o clang_test
clang_test.cc:9:7: error: reference to local variable 'x' declared in enclosing function 'main'
x = y;
^
clang_test.cc:2:48: note: in instantiation of function template specialization 'main()::(anonymous class)::operator()<int>' requested here
template <class F> void parallel_loop(F &&f) { f(0); }
^
clang_test.cc:6:3: note: in instantiation of function template specialization 'parallel_loop<(lambda at clang_test.cc:6:17)>' requested here parallel_loop([&](auto y) {
^
clang_test.cc:5:7: note: 'x' declared here
int x;
^
1 error generated.
Teresa Johnson [Fri, 11 Nov 2016 05:35:12 +0000 (05:35 +0000)]
Mirror the llvm changes that split Bitcode/ReaderWriter.h
The change in D26502 splits ReaderWriter.h, which contains the APIs
into both the BitReader and BitWriter libraries, into BitcodeReader.h
and BitcodeWriter.h.
Change clang uses to the appropriate split header(s).
Stephen Hines [Fri, 11 Nov 2016 01:29:39 +0000 (01:29 +0000)]
Define __ANDROID_API__ when specified as part of an Android target.
Summary:
This macro should be defined only when the user directly specifies an
API level as part of an Android target. For any regular Android target,
we leave this macro undefined.
Richard Smith [Fri, 11 Nov 2016 01:01:31 +0000 (01:01 +0000)]
PR30937: don't devirtualize if we find that the callee is a pure virtual
function. In that case, there is no requirement that the callee is actually
defined, and the code may in fact be valid and have defined behavior if the
virtual call is unreachable.
Jordan Rose [Fri, 11 Nov 2016 00:55:14 +0000 (00:55 +0000)]
Speculative fix for va_list/nullability test on Hexagon and PPC.
PowerPC's va_list, at least, is a typedef for an array, which means it
decays to a pointer in parameter position. Since the decayed type is
built from the array element type, the typedef sugar is lost.
Jordan Rose [Fri, 11 Nov 2016 00:23:59 +0000 (00:23 +0000)]
Don't require nullability on 'va_list' harder.
Platform headers don't always define 'va_list' in terms of Clang's
'__builtin_va_list', so in addition to checking for our own
synthesized decl, also just look for typedefs literally named
'va_list'. Better to err on the side of false negatives here.
Jordan Rose [Thu, 10 Nov 2016 23:28:34 +0000 (23:28 +0000)]
Don't require nullability on 'va_list'.
There are many non-portable typedefs, but va_list is one that nobody
ever thinks of as a pointer or an array. (When's the last time you saw
someone check for a NULL va_list?) Make an exception for this one
special type.
Jordan Rose [Thu, 10 Nov 2016 23:28:30 +0000 (23:28 +0000)]
Warn when 'assume_nonnull' infers nullability within an array.
...or within a reference. Both of these add an extra level of
indirection that make us less certain that the pointer really was
supposed to be non-nullable. However, changing the default behavior
would be a breaking change, so we'll just make it a warning instead.
Jordan Rose [Thu, 10 Nov 2016 23:28:26 +0000 (23:28 +0000)]
Add -Wnullability-completeness-on-arrays.
This is an addition to (and sub-warning of) -Wnullability-completeness
that warns when an array parameter is missing nullability. When the
specific warning is switched off, the compiler falls back to only
warning on pointer types written as pointer types.
Note that use of nullability /within/ an array triggers the
completeness checks regardless of whether or not the array-specific
warning is enabled; the intent there is simply to determine whether a
particular header is trying to be nullability-aware at all.
Jordan Rose [Thu, 10 Nov 2016 23:28:17 +0000 (23:28 +0000)]
Accept nullability qualifiers on array parameters.
Since array parameters decay to pointers, '_Nullable' and friends
should be available for use there as well. This is especially
important for parameters that are typedefs of arrays. The unsugared
syntax for this follows the syntax for 'static'-sized arrays in C:
void test(int values[_Nullable]);
This syntax was previously accepted but the '_Nullable' (and any other
attributes) were silently discarded. However, applying '_Nullable' to
a typedef was previously rejected and is now accepted; therefore, it
may be necessary to test for the presence of this feature:
#if __has_feature(nullability_on_arrays)
One important change here is that DecayedTypes don't always
immediately contain PointerTypes anymore; they may contain an
AttributedType instead. This only affected one place in-tree, so I
would guess it's not likely to cause problems elsewhere.
This commit does not change -Wnullability-completeness just yet. I
want to think about whether it's worth doing something special to
avoid breaking existing clients that compile with -Werror. It also
doesn't change '#pragma clang assume_nonnull' behavior, which
currently treats the following two declarations as equivalent:
#pragma clang assume_nonnull begin
void test(void *pointers[]);
#pragma clang assume_nonnull end
void test(void * _Nonnull pointers[]);
This is not the desired behavior, but changing it would break
backwards-compatibility. Most likely the best answer is going to be
adding a new warning.
Nico Weber [Thu, 10 Nov 2016 21:49:25 +0000 (21:49 +0000)]
[clang-format] Fix PR30527: Regression when clang-format insert spaces in [] when in template
Actual regression was introduced in r272668. This revision fixes JS script, but
also regress Cpp case. It manifests with spaces added when template is followed
with array. Bug 30527 mentions case of array as a nested template type
(foo<bar<baz>[]>). Fix is to detect such case and to prevent treating it as
array initialization, but as a subscript case. However, before r272668, this
case was treated simple because we were detecting it as a StartsObjCMethodExpr.
Same was true for other similar case - array of templates (foo<int>[]). This
patch tries to address two problems: 1) fixing regression 2) making sure both
cases (array as a nested type, array of templates) which were entering
StartsObjCMethodExpr branch are handled now appropriately.
https://reviews.llvm.org/D26163
Patch from Branko Kokanovic <branko@kokanovic.org>!
Clean up uses of unique_ptr for RAII objects. NFC.
- EnterExpressionEvaluationContext allows you to specify whether you
*actually* want to enter an evaluation context.
- For types that don't allow that, llvm::Optional<Foo> should do the
same thing as std::unique_ptr<Foo>, but with 100% less heap
allocations.
Alex Lorenz [Thu, 10 Nov 2016 16:19:11 +0000 (16:19 +0000)]
[Sema] Avoid -Wshadow warnings for shadowed variables that
aren't captured by lambdas with a default capture specifier
This commit is a follow-up to r286354. It avoids the -Wshadow warning for
variables which shadow variables that aren't captured by lambdas with a default
capture specifier. It provides an additional note that points to location of
the capture.
The old behaviour is preserved with -Wshadow-all or -Wshadow-uncaptured-local.
Serge Pavlov [Thu, 10 Nov 2016 08:49:37 +0000 (08:49 +0000)]
Make output of -ast-print a valid C++ code.
Output generated by option -ast-print looks like C/C++ code, and it
really is for plain C. For C++ the produced output was not valid C++
code, but the differences were small. With this change the output
is fixed and can be compiled. Tests are changed so that output produced
by -ast-print is compiled again with the same flags and both outputs are
compared.
Option -ast-print is extensively used in clang tests but it itself
was tested poorly, existing tests only checked that compiler did not
crash. There are unit tests in file DeclPrinterTest.cpp, but they test
only terse output mode.
Shoaib Meenai [Wed, 9 Nov 2016 23:52:20 +0000 (23:52 +0000)]
[Sema] Use MS ABI behavior for dllexport in Itanium
Similar to r284288, make the Itanium ABI follow MS ABI dllexport
semantics in the case of an explicit instantiation declaration followed
by a dllexport explicit instantiation definition.
Adrian Prantl [Wed, 9 Nov 2016 21:43:51 +0000 (21:43 +0000)]
Use an artificial debug location for non-virtual thunks.
Thunks are artificial and have no corresponding source location except for the
line number on the DISubprogram, which is marked as artificial.