Richard Smith [Thu, 25 Jun 2015 20:48:44 +0000 (20:48 +0000)]
[modules] Fix findDirectiveAtLoc to not call a member function on a null pointer.
This is exercised by existing tests, and fixes a failure with -fsanitize=null.
No observable change otherwise; the code happened to do the right thing in
practice under recent versions of Clang and GCC because
MacroDirective::getDefinition happens to check whether this == null.
Chris Bieneman [Thu, 25 Jun 2015 20:25:43 +0000 (20:25 +0000)]
Add -miphonesimulator-version-min as alias to -ios-simulator-version-min.
Summary:
For better or worse the OS X command line tools refer to the iOS simulator as iphonesimucator. We should provide an alias flag -miphonesimulator-version-min that matches a consistent pattern with the other tools.
This is in the interest of making it easier for people to write platform-agnostic darwin build scripts.
Artem Belevich [Thu, 25 Jun 2015 18:29:42 +0000 (18:29 +0000)]
[CUDA] Implemented __nvvm_atom_*_gen_* builtins.
Integer variants are implemented as atomicrmw or cmpxchg instructions.
Atomic add for floating point (__nvvm_atom_add_gen_f()) is implemented
as a call to an overloaded @llvm.nvvm.atomic.load.add.f32.* LVVM
intrinsic.
Aaron Ballman [Thu, 25 Jun 2015 15:37:16 +0000 (15:37 +0000)]
Fix #pragma redefine_extname when there is a local variable of the same name. The local should not be renamed, only the externally-available declaration should be.
Steven Wu [Thu, 25 Jun 2015 01:59:35 +0000 (01:59 +0000)]
Update darwin SDK version parsing to support OSX and simulator
This re-commits r226005 with a tweak. The origin attempt failed because
Darwin bot sets up SDKROOT and clang can deduce SDK version from them
after this patch. That broke many driver tests due to the change of
deployment target version. Now the tests should not complain after
r240574.
Hubert Tong [Thu, 25 Jun 2015 00:25:49 +0000 (00:25 +0000)]
Consolidate and unify initializer list deduction
Summary:
This patch reduces duplication in the template argument deduction code
for handling deduction from initializer lists in a function call. This
extends the fix for PR12119 to also apply to the case where the
corresponding parameter is a trailing parameter pack.
Test Plan:
A test for deduction from nested initializer lists where the
corresponding parameter is a trailing parameter pack is added in
`clang/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp`.
Hubert Tong [Thu, 25 Jun 2015 00:23:39 +0000 (00:23 +0000)]
[Concepts] Parsing of requires-clause in template-declaration
Summary:
This change implements parse-only acceptance of the optional
requires-clause in a template-declaration. Diagnostic testing is added
for cases where the grammar is ambiguous with the expectation that the
longest token sequence which matches the syntax of a
constraint-expression is consumed without backtracking.
Ranjeet Singh [Wed, 24 Jun 2015 23:39:25 +0000 (23:39 +0000)]
[ARM] The bits set in the variable HW_FP could get unset
when iterating through the Features vector if we don't
keep track of what's already been set. This could lead to
the macro __ARM_FP getting the wrong value. This patch
fixes this issue by keeping track of the bits that have
already been set in the loop.
Derek Schuff [Wed, 24 Jun 2015 22:36:36 +0000 (22:36 +0000)]
Relax assertion in x86_64 byval argument handling for 32-bit pointers
Summary:
Byval argument pair formation assumes that if a type is less than 8 bytes
it must be an integer and not a pointer, which is not true for x32 and NaCl.
Relax the assertion and add a test for a codegen case that triggered it.
Steven Wu [Wed, 24 Jun 2015 19:30:36 +0000 (19:30 +0000)]
Remove environment variables from driver tests
Summary:
Remove some of dangerous environmental variables from clang/Driver tests.
Driver tests should not rely on preset value of these variables and may
actually fail because of them.
They cannot be removed in test/lit.cfg because we still need to support
relocatable SDKs and other overwrite for other clang tests.
Alexey Bataev [Wed, 24 Jun 2015 11:01:36 +0000 (11:01 +0000)]
[OPENMP] Codegen for 'depend' clause (OpenMP 4.0).
If task directive has associated 'depend' clause then function kmp_int32 __kmpc_omp_task_with_deps ( ident_t *loc_ref, kmp_int32 gtid, kmp_task_t * new_task, kmp_int32 ndeps, kmp_depend_info_t *dep_list,kmp_int32 ndeps_noalias, kmp_depend_info_t *noalias_dep_list) must be called instead of __kmpc_omp_task().
If this directive has associated 'if' clause then also before a call of kmpc_omp_task_begin_if0() a function void __kmpc_omp_wait_deps ( ident_t *loc_ref, kmp_int32 gtid, kmp_int32 ndeps, kmp_depend_info_t *dep_list, kmp_int32 ndeps_noalias, kmp_depend_info_t *noalias_dep_list) must be called.
Array sections are not supported yet.
Bob Wilson [Wed, 24 Jun 2015 06:05:20 +0000 (06:05 +0000)]
Move the special-case check from r240462 into ARM-specific code.
This fixes a serious bug in r240462: checking the BuiltinID for
ARM::BI_MoveToCoprocessor* in EmitBuiltinExpr() ignores the fact that
each target has an overlapping range of the BuiltinID values. That check
can trigger for builtins from other targets, leading to very bad
behavior.
Part of the reason I did not implement r240462 this way to begin with is
the special handling of the last argument for Neon builtins. In this
change, I have factored out the check to see which builtins have that
extra argument into a new HasExtraNeonArgument() function. There is still
some awkwardness in having to check for those builtins in two separate
places, i.e., once to see if the extra argument is present and once to
generate the appropriate IR, but this seems much cleaner than my previous
patch.
This patch makes the following improvements to the SafeStack documentation:
Explicitly states the security guarantees of the SafeStack
Clarifies which of the security guarantees are probabilistic
Re-orders security limitations to put the most severe ones first
Explains how `__attribute__((no_sanitize("safe-stack")))` works and how to use it safely
Explains that SafeStack should be combined with a forward-edge protection mechanism, such as CPI, IFCC or others
Multiple readability and stylistic improvements
Bob Wilson [Tue, 23 Jun 2015 21:10:24 +0000 (21:10 +0000)]
Improve error handling for PR22560.
The ARM _MoveToCoprocessor and _MoveFromCoprocessor builtins require
integer constants for most arguments, but clang was not checking that.
With this change, we now report meaningful errors instead of crashing
in the backend.
Bob Wilson [Tue, 23 Jun 2015 21:10:15 +0000 (21:10 +0000)]
PR22560: Fix argument order for ARM _MoveToCoprocessor builtins.
The Microsoft-extension _MoveToCoprocessor and _MoveToCoprocessor2
builtins take the register value to be moved as the first argument,
but the corresponding mcr and mcr2 LLVM intrinsics expect that value
to be the third argument. Handle this as a special case, while still
leaving those intrinsics as generic MSBuiltins. I considered the
alternative of handling these in EmitARMBuiltinExpr, but that does
not work well for the follow-up change that I'm going to make to improve
the error handling for PR22560 -- we need the GetBuiltinType() checks
for ICEArguments, and the ARM version of that code is only used for
Neon intrinsics where the last argument is special and not
checked in the normal way.
Douglas Katzman [Tue, 23 Jun 2015 20:42:09 +0000 (20:42 +0000)]
Pedantically rename all Tool subclasses to be nouns, not verbs. NFC
Classes in Tools.h inherit ultimately from Tool, which is a noun,
but subclasses of Tool were named for their operation, such as "Compile",
wherein the constructor call "Compile(args...)" could be misconstrued
as actually causing a compile to happen.
Likewise various other methods were not harmonious with their effect,
in that "BuildLinker()" returned a "new namespace::Link(...)"
instead of a "new namespace::Linker(...)" which it now does.
Exceptions: Clang and ClangAs are un-renamed. Those are their rightful names.
And there is no particulary great way to name the "Lipo-er" and a few others.
David Majnemer [Tue, 23 Jun 2015 20:34:18 +0000 (20:34 +0000)]
[MS ABI] Account for the virtual inheritance quirk when mangling
Virtual inheritance member pointers are always relative to the vbindex,
even when the member pointer doesn't point into a virtual base. This is
corrected by adjusting the non-virtual offset backwards from the vbptr
back to the top of the most derived class. While we performed this
adjustment when manifesting member pointers as constants or when
performing conversions, we didn't perform the adjustment when mangling
them.
Kaelyn Takata [Tue, 23 Jun 2015 18:42:21 +0000 (18:42 +0000)]
Ensure delayed typos have been corrected in calls to builtins before
checking those calls when not in C++ mode, since those code paths can't
handle dependent exprs.
Aaron Ballman [Tue, 23 Jun 2015 17:14:51 +0000 (17:14 +0000)]
AttributeReference.rst is automatically generated by a server-side process currently. To cut down on accidental commits to this file that are not properly reflected in AttrDocs.td (such as r215806 - r215808), this file now contains nothing but a comment explaining the current state of affairs.
Aaron Ballman [Tue, 23 Jun 2015 13:41:03 +0000 (13:41 +0000)]
Moving r215806, r215807, and r215808 into AttrDocs.td. These changes were originally applied to the RST file that is automatically generated by the server, and so the changes were never properly reflected online once the server overwrote AttributeReference.rst.
NAKAMURA Takumi [Tue, 23 Jun 2015 08:37:21 +0000 (08:37 +0000)]
Tweak clang/test/Modules/modules-with-same-name.m to run with GnuWin32's find.exe on newer version of Windows.
It seems "*.pcm" would be expanded with current directory by NTOS 6.x's msvcrt. GnuWin32 utils are affected.
To avoid the issue, put an expression that msvcrt's glob won't match, like "*.pc[m]".
David Majnemer [Tue, 23 Jun 2015 07:31:11 +0000 (07:31 +0000)]
[MS ABI] Rework member pointer conversion
Member pointers in the MS ABI are made complicated due to the following:
- Virtual methods in the most derived class (MDC) might live in a
vftable in a virtual base.
- There are four different representations of member pointer: single
inheritance, multiple inheritance, virtual inheritance and the "most
general" representation.
- Bases might have a *more* general representation than classes which
derived from them, a most surprising result.
We believed that we could treat all member pointers as-if they were a
degenerate case of the multiple inheritance model. This fell apart once
we realized that implementing standard member pointers using this ABI
requires referencing members with a non-zero vbindex.
On a bright note, all but the virtual inheritance model operate rather
similarly. The virtual inheritance member pointer representation
awkwardly requires a virtual base adjustment in order to refer to
entities in the MDC.
However, the first virtual base might be quite far from the start of the
virtual base. This means that we must add a negative non-virtual
displacement.
However, things get even more complicated. The most general
representation interprets vbindex zero differently from the virtual
inheritance model: it doesn't reference the vbtable at all.
It turns out that this complexity can increase for quite some time:
consider a derived to base conversion from the most general model to the
multiple inheritance model...
To manage this complexity we introduce a concept of "normalized" member
pointer which allows us to treat all three models as the most general
model. Then we try to figure out how to map this generalized member
pointer onto the destination member pointer model. I've done my best to
furnish the code with comments explaining why each adjustment is
performed.
David Majnemer [Tue, 23 Jun 2015 07:31:07 +0000 (07:31 +0000)]
[MS ABI] Refactor member pointer generation
The MS ABI has very complicated member pointers. Don't attempt to
synthesize the final member pointer ab ovo usque ad mala in one go.
Instead, start with a member pointer which points to the declaration in
question as-if it's decl context was the target class. Then, utilize
our conversion logical to convert it to the target type.
This allows us to simplify how we think about member pointers because we
don't need to consider non-zero nv adjustments before we even generate
the member pointer. Furthermore, it gives our adjustment logic more
exposure by utilizing it in a common path.
Alexey Bataev [Tue, 23 Jun 2015 04:51:00 +0000 (04:51 +0000)]
[OPENMP] Do not emit references to original variables in 'private' clause.
Currently if the variable is captured in captured region, capture record for this region stores reference to this variable for future use. But we don't need to provide the reference to the original variable if it was explicitly marked as private in the 'private' clause of the OpenMP construct, this variable is replaced by private copy.
Differential Revision: http://reviews.llvm.org/D9550
Richard Smith [Mon, 22 Jun 2015 22:20:47 +0000 (22:20 +0000)]
[modules] When building a module, if there are multiple matches for a header
file in the loaded module maps and one of them is from the current module,
that's the right match.
Richard Smith [Mon, 22 Jun 2015 21:15:01 +0000 (21:15 +0000)]
[modules] Add a flag to disable the feature that permits conflicting redefinitions of internal-linkage symbols that are not visible.
Such conflicts are an accident waiting to happen, and this feature conflicts
with the desire to include existing headers into multiple modules and merge the
results. (In an ideal world, it should not be possible to export internal
linkage symbols from a module, but sadly the glibc and libstdc++ headers
provide 'static inline' functions in a few cases.)
Justin Bogner [Mon, 22 Jun 2015 18:47:10 +0000 (18:47 +0000)]
test: Set lit features appropriately when using asan and ubsan together
The asan/not_asan and ubsan/not_ubsan features weren't being set
correctly when LLVM_USE_SANITIZER is set to 'Address;Undefined'. Fix
this by doing substring instead of exact matching. Also simplify the
msan check for consistency.
Sema: add a helper for enumerating the TST id (NFC)
The same pattern was repeated a few times. Create a trivial helper method to
map the Type Specifier to an ID for the diagnostic. Flip the selection order on
one of the diagnostic messages to get the same ordering across all of the
messages. This makes the emission of the diagnostic slightly more legible by
changing the cascading ternary into a switch in a function. NFC.
Nico Weber [Sun, 21 Jun 2015 20:49:05 +0000 (20:49 +0000)]
Clean up CLCompatOptions.td a bit.
Move /Qvec flags from the "// Non-aliases:" section up to the "// Aliases:"
section since the flags are just aliases. For the same reason, move the
/vm flags the other way. Also reflow a few lines to 80 columns.
Justin Bogner [Sun, 21 Jun 2015 20:32:40 +0000 (20:32 +0000)]
ASTReader: Treat InputFileOffsets as unaligned to avoid UB
This is a better approach to fixing the undefined behaviour I tried to
fix in r240228. This data doesn't necessarily have suitable alignment
for uint64_t, so use unaligned_uint64_t instead.
This fixes 225 test failures when clang is built with ubsan.
Justin Bogner [Sat, 20 Jun 2015 22:31:04 +0000 (22:31 +0000)]
ASTReader: Copy input file offset data to avoid unaligned accesses
We interpret Blob as an array of uint64_t here, but there's no reason
to think that it has suitable alignment. Instead, read the data in in
an alignment-safe way and store it in a std::vector.
This fixes 225 test failures when clang is built with ubsan.
Adrian Prantl [Sat, 20 Jun 2015 18:53:08 +0000 (18:53 +0000)]
Introduce a PCHContainerOperations interface (NFC).
A PCHContainerOperations abstract interface provides operations for
creating and unwrapping containers for serialized ASTs (precompiled
headers and clang modules). The default implementation is
RawPCHContainerOperations, which uses a flat file for the output.
The main application for this interface will be an
ObjectFilePCHContainerOperations implementation that uses LLVM to
wrap the module in an ELF/Mach-O/COFF container to store debug info
alongside the AST.
Douglas Gregor [Fri, 19 Jun 2015 23:18:03 +0000 (23:18 +0000)]
Stop moving attributes off of a block literal's decl specifiers.
These usually apply to the return type. At one point this was necessary to
get some of them to apply to the entire block, but it appears that's working
anyway (see block-return.c).
Douglas Gregor [Fri, 19 Jun 2015 23:18:00 +0000 (23:18 +0000)]
Handle 'instancetype' in ParseDeclarationSpecifiers.
...instead of as a special case in ParseObjCTypeName with lots of
duplicated logic. Besides being a nice refactoring, this also allows
"- (instancetype __nonnull)self" in addition to "- (nonnull instancetype)self".
Douglas Gregor [Fri, 19 Jun 2015 23:17:46 +0000 (23:17 +0000)]
Allow the cf_returns_[not_]retained attributes to appear on out-parameters.
Includes a simple static analyzer check and not much else, but we'll also
be able to take advantage of this in Swift.
This feature can be tested for using __has_feature(cf_returns_on_parameters).
This commit also contains two fixes:
- Look through non-typedef sugar when deciding whether something is a CF type.
- When (cf|ns)_returns(_not)?_retained is applied to invalid properties,
refer to "property" instead of "method" in the error message.