Commit Graph

41617 Commits

Author SHA1 Message Date
Alexey Bataev ed5fb67ad1 [OPENMP] Fix printing of array section with single index.
llvm-svn: 247389
2015-09-11 04:54:28 +00:00
Richard Smith 7acebe4cf1 [modules] Don't load files specified by -fmodule-file= when modules are
disabled. (We still allow this via -cc1 / -Xclang, primarily for testing.)

llvm-svn: 247384
2015-09-11 03:58:07 +00:00
Richard Smith 3864be7bf0 [modules] Slightly defang an assert that produces false-positives on the selfhost bot.
llvm-svn: 247375
2015-09-11 02:22:03 +00:00
Argyrios Kyrtzidis 322d853d7d [sema] Fix assertion hit when using libclang to index a particular C++ snippet involving templates.
Assertion hit was in ClassTemplateSpecializationDecl::getSourceRange().

llvm-svn: 247373
2015-09-11 01:44:56 +00:00
Adrian Prantl 49553dd269 Module Debugging: Emit forward declarations for types that are defined in
clang modules, if -dwarf-ext-refs (DebugTypesExtRefs) is specified.

llvm-svn: 247369
2015-09-11 01:03:26 +00:00
Adrian Prantl d0929a1c87 Cleanup: Let CGDebugInfo::ModuleRefCache use a TrackingMDNode (NFC).
llvm-svn: 247368
2015-09-11 01:03:19 +00:00
David Majnemer e03226b1d9 [MS ABI] Remove another call to RequireCompleteType
I cannot come up with a testcase which would rely on this call to
RequireCompleteType, I believe that it is superfluous given the current
state of clang.

llvm-svn: 247367
2015-09-11 00:53:15 +00:00
Reid Kleckner 7531f7dd8d [Driver] Use UniversalCRT on Windows if available
Summary:
With Visual Studio 2015 release, a part of runtime library was extracted
and now comes with Windows Kits. This patch enables clang to use
Universal CRT library if  %INCLUDE or %LIB environment varaibles are not
specified.

See also https://llvm.org/bugs/show_bug.cgi?id=24741

Patch by Igor Kudrin

Reviewers: zturner, hans, rnk

Subscribers: ruiu, cfe-commits

Differential Revision: http://reviews.llvm.org/D12695

llvm-svn: 247362
2015-09-11 00:09:39 +00:00
John McCall 1e3157beb7 Support noreturn in limited contexts on Objective-C message sends.
rdar://6198039

llvm-svn: 247350
2015-09-10 22:27:50 +00:00
Reid Kleckner 2586aac908 [SEH] Use cleanupendpad so that WinEHPrepare gets the coloring right
Cleanupendpad is a lot like catchendpad, so we can reuse the same
EHScopeStack type.

llvm-svn: 247349
2015-09-10 22:11:13 +00:00
David Majnemer 9df56372e8 [MS ABI] Make member pointers return true for isIncompleteType
The type of a member pointer is incomplete if it has no inheritance
model.  This lets us reuse more general logic already embedded in clang.

llvm-svn: 247346
2015-09-10 21:52:00 +00:00
Piotr Padlewski 4bed31b9bf Revert "Generating assumption loads of vptr after ctor call (fixed)"
It seems that there is small bug, and we can't generate assume loads
when some virtual functions have internal visibiliy
This reverts commit 982bb7d966947812d216489b3c519c9825cacbf2.

llvm-svn: 247332
2015-09-10 20:18:30 +00:00
Peter Collingbourne 24ec4924c0 Driver: Support cfi-icall on all OSs when targeting x86/x86_64.
llvm-svn: 247324
2015-09-10 19:18:05 +00:00
Adrian Prantl 6ec370a4ed Add a getDeclContextDescriptor() helper function to CGDebugInfo. (NFC)
llvm-svn: 247319
2015-09-10 18:39:45 +00:00
Reid Kleckner bb34b60359 [SEH] Use catchret in the new EH IR like we do for C++
Also add tests for SEH with the new IRGen.

llvm-svn: 247318
2015-09-10 18:39:41 +00:00
Artem Belevich 7cb25c9b69 [CUDA] Postprocess bitcode linked in during device-side CUDA compilation.
Link in and internalize the symbols we need from supplied bitcode library.

Differential Revision: http://reviews.llvm.org/D11664

llvm-svn: 247317
2015-09-10 18:24:23 +00:00
Artem Belevich da1851ca58 [CUDA] Allow trivial constructors as initializer for __shared__ variables.
Differential Revision: http://reviews.llvm.org/D12739

llvm-svn: 247307
2015-09-10 17:26:58 +00:00
Adrian Prantl 54a3457fe1 Debug Info: Remove an unnecessary debug type visitor.
Thanks to dblaikie for spotting this.

llvm-svn: 247303
2015-09-10 17:13:31 +00:00
Hans Wennborg 7eb5464bc5 Re-commit r247218: "Fix Clang-tidy misc-use-override warnings, other minor fixes"
This never broke the build; it was the LLVM side, r247216, that caused problems.

llvm-svn: 247302
2015-09-10 17:07:54 +00:00
Alexey Bataev 6a43c00ebd [OPENMP] Generate threadprivates as TLS variables by default.
If target supports TLS all threadprivates are generated as TLS. If target does not support TLS, use runtime calls for proper codegen of threadprivate variables.

llvm-svn: 247273
2015-09-10 12:06:58 +00:00
Alexey Bataev 1d7f0faf93 [OPENMP] Propagate alignment from original variables to the private copies.
Currently private copies of captured variables have default alignment. Patch makes private variables to have same alignment as original variables.

llvm-svn: 247260
2015-09-10 09:48:30 +00:00
Alexey Bataev 2377fe95c6 [OPENMP] Outlined function for parallel and other regions with list of captured variables.
Currently all variables used in OpenMP regions are captured into a record and passed to outlined functions in this record. It may result in some poor performance because of too complex analysis later in optimization passes. Patch makes to emit outlined functions for parallel-based regions with a list of captured variables. It reduces code for 2*n GEPs, stores and loads at least.
Codegen for task-based regions remains unchanged because runtime requires that all captured variables are passed in captured record.

llvm-svn: 247251
2015-09-10 08:12:02 +00:00
David Majnemer cca07d7c48 [MS ABI] Select a pointer to member representation more often
Given a reference to a pointer to member whose class's inheritance model
is unspecified, make sure we come up with an inheritance model in
plausible places.  One place we were missing involved LValue to RValue
conversion, another involved unary type traits.

llvm-svn: 247248
2015-09-10 07:20:05 +00:00
Peter Collingbourne 2c7f7e31c4 CFI: Introduce -fsanitize=cfi-icall flag.
This flag causes the compiler to emit bit set entries for functions as well
as runtime bitset checks at indirect call sites. Depends on the new function
bitset mechanism.

Differential Revision: http://reviews.llvm.org/D11857

llvm-svn: 247238
2015-09-10 02:17:40 +00:00
Mehdi Amini 57a41913ed EmitRecord* API change: accepts ArrayRef instead of a SmallVector (NFC)
This reapply a variant commit r247179 after post-commit review from
D.Blaikie.
Hopefully I got it right this time: lifetime of initializer list ends
as with any expression, which make invalid the pattern:

ArrayRef<int> Arr = { 1, 2, 3, 4};

Just like StringRef, ArrayRef shouldn't be used to initialize local
variable but only as function argument.

From: Mehdi Amini <mehdi.amini@apple.com>
llvm-svn: 247233
2015-09-10 01:46:39 +00:00
John McCall 9a2c1c9603 Don't crash when emitting a block under returns_nonnull.
rdar://22071955

llvm-svn: 247228
2015-09-10 00:57:46 +00:00
Hans Wennborg e89c8c8033 Revert r247218: "Fix Clang-tidy misc-use-override warnings, other minor fixes"
Seems it broke the Polly build.
From http://lab.llvm.org:8011/builders/perf-x86_64-penryn-O3-polly-fast/builds/11687/steps/compile/logs/stdio:

In file included from /home/grosser/buildslave/perf-x86_64-penryn-O3-polly-fast/llvm.src/lib/TableGen/Record.cpp:14:0:
/home/grosser/buildslave/perf-x86_64-penryn-O3-polly-fast/llvm.src/include/llvm/TableGen/Record.h:369:3: error: looser throw specifier for 'virtual llvm::TypedInit::~TypedInit()'
/home/grosser/buildslave/perf-x86_64-penryn-O3-polly-fast/llvm.src/include/llvm/TableGen/Record.h:270:11: error:   overriding 'virtual llvm::Init::~Init() noexcept (true)'

llvm-svn: 247222
2015-09-10 00:37:18 +00:00
Hans Wennborg 60f3e1f466 Fix Clang-tidy misc-use-override warnings, other minor fixes
Patch by Eugene Zelenko!

Differential Revision: http://reviews.llvm.org/D12741

llvm-svn: 247218
2015-09-10 00:24:40 +00:00
John McCall 6380a28248 ARC: Fix the precise-lifetime suppression of returns_inner_pointer
receiver extension for message sends via property syntax.

rdar://22172983

llvm-svn: 247209
2015-09-09 23:37:17 +00:00
John McCall f4a1b77157 Fix access control for lookups using the Microsoft __super extension.
rdar://22464808

llvm-svn: 247207
2015-09-09 23:04:17 +00:00
Sanjay Patel daf34e9d85 convert builtin_unpredictable on a switch into metadata for LLVM
llvm-svn: 247203
2015-09-09 22:39:06 +00:00
Piotr Padlewski 255652e828 Generating assumption loads of vptr after ctor call (fixed)
Generating call assume(icmp %vtable, %global_vtable) after constructor
call for devirtualization purposes.

For more info go to:
http://lists.llvm.org/pipermail/cfe-dev/2015-July/044227.html

Edit:
Fixed version because of PR24479.
After this patch got reverted because of ScalarEvolution bug (D12719)
Merged after John McCall big patch (Added Address).

http://reviews.llvm.org/D11859

llvm-svn: 247199
2015-09-09 22:20:28 +00:00
Nathan Wilson 085b9ff6e2 [Concepts] Add diagnostic; invalid specifier on function or variable concept declaration
Summary: Diagnose variable and function concept declarations when an invalid specifier appears

Reviewers: rsmith, aaron.ballman, faisalv, fraggamuffin, hubert.reinterpretcast

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D12435

llvm-svn: 247194
2015-09-09 21:48:31 +00:00
David Majnemer 22ee1a7466 [MS ABI] Don't crash on references to pointers to members in args
We know that a reference can always be dereferenced.  However, we don't
always know the number of bytes if the reference's pointee type is
incomplete.  This case was correctly handled but we didn't consider the
case where the type is complete but we cannot calculate its size for ABI
specific reasons.  In this specific case, a member pointer's size is
available only under certain conditions.

This fixes PR24703.

llvm-svn: 247188
2015-09-09 20:57:59 +00:00
Mehdi Amini 5ae4a85e3f Revert "EmitRecordWith* API change: takes an ArrayRef instead of a SmallVector (NFC)"
This reverts commit r247179.

From: Mehdi Amini <mehdi.amini@apple.com>
llvm-svn: 247183
2015-09-09 20:35:37 +00:00
Mehdi Amini 65e742a34f EmitRecordWith* API change: takes an ArrayRef instead of a SmallVector (NFC)
From: Mehdi Amini <mehdi.amini@apple.com>
llvm-svn: 247179
2015-09-09 20:08:51 +00:00
Argyrios Kyrtzidis 203e92394d Fix a small bug in clang where generating some temporary files would have an extra period before the extension.
Patch by Cameron Esfahani!

llvm-svn: 247160
2015-09-09 16:48:47 +00:00
Rafael Espindola d511726ce9 [Solaris] Use the GCC Installation detector to add the C++ include paths.
Patch by Xan López!

llvm-svn: 247144
2015-09-09 13:36:00 +00:00
Steven Wu 0d22f2d57e Fix vld1_lane intrinsic generation
Fix a bug introduced in r246985 which causes assertion when generating
vld1_lane.

llvm-svn: 247117
2015-09-09 01:37:18 +00:00
Peter Collingbourne ee381ffba4 CodeGen: Add CFI unrelated cast checks to the new pointer code path.
llvm-svn: 247105
2015-09-09 00:01:31 +00:00
Michael Zolotukhin 84df12375c Introduce __builtin_nontemporal_store and __builtin_nontemporal_load.
Summary:
Currently clang provides no general way to generate nontemporal loads/stores.
There are some architecture specific builtins for doing so (e.g. in x86), but
there is no way to generate non-temporal store on, e.g. AArch64. This patch adds
generic builtins which are expanded to a simple store with '!nontemporal'
attribute in IR.

Differential Revision: http://reviews.llvm.org/D12313

llvm-svn: 247104
2015-09-08 23:52:33 +00:00
Peter Collingbourne 25a80bf9b6 CodeGen: Introduce CodeGenModule::CreateMetadataIdentifierForType.
This function can be used to create a metadata identifier for a specific
type. No functionality change, but this will be used by D11857 and D12026.

Differential Revision: http://reviews.llvm.org/D12038

llvm-svn: 247098
2015-09-08 23:01:30 +00:00
Adrian Prantl ab010c4e0e Remove unneeded #include.
llvm-svn: 247081
2015-09-08 22:06:40 +00:00
John McCall 0a49015629 Collect SEH captures in a set instead of a vector to avoid
doing redundant work if a variable is used multiple times.

Fixes PR24751.

llvm-svn: 247075
2015-09-08 21:15:22 +00:00
Gabor Horvath 1cbf435cd6 [Static Analyzer] Objective-C Generics Checker improvements.
Differential Revision: http://reviews.llvm.org/D12701

llvm-svn: 247071
2015-09-08 21:04:14 +00:00
Adrian Prantl 748a6cd1ac Module Debugging: Emit debug type information into clang ObjC modules.
When -fmodule-format is set to "obj", emit debug info for all types
declared in a module or referenced by a declaration into the module's
object file container.

This patch adds support for Objective-C types and methods.

llvm-svn: 247068
2015-09-08 20:41:52 +00:00
Richard Smith 0516b1864d [modules] Write the options records to a separate subblock rather than writing
them directly to the control block. These are fairly large, and in a build with
lots of modules / chained PCH, we don't need to read most of them. No
functionality change intended.

llvm-svn: 247055
2015-09-08 19:40:14 +00:00
Douglas Katzman 38dca88838 [Shave]: add a -MT option to moviCompile if there wasn't one
Differential Revision: http://reviews.llvm.org/D12622

llvm-svn: 247052
2015-09-08 19:29:55 +00:00
Adrian Prantl 4aa2b3a311 Module Debugging: Emit debug type information into clang modules.
When -fmodule-format is set to "obj", emit debug info for all types
declared in a module or referenced by a declaration into the module's
object file container.

This patch adds support for C and C++ types.

llvm-svn: 247049
2015-09-08 19:20:27 +00:00
Manuel Klimek 3ecd8c0aab Fix performance regression when running clang tools.
Brings tool start time for a large synthetic test case down from (on my
machine) 4 seconds to 0.5 seconds.

llvm-svn: 247018
2015-09-08 15:14:06 +00:00
Jakub Kuderski f50ab0ffce findDominatingStoreToReturn in CGCall.cpp didn't check if a candidate store
instruction used the ReturnValue as pointer operand or value operand. This
led to wrong code gen - in later stages (load-store elision code) the found
store and its operand would be erased, causing ReturnValue to become a <badref>.

The patch adds a check that makes sure that ReturnValue is a pointer operand of
store instruction. Regression test is also added.

This fixes PR24386.
Differential Revision: http://reviews.llvm.org/D12400

llvm-svn: 247003
2015-09-08 10:36:42 +00:00
NAKAMURA Takumi ff7a9252e8 clangCodeGen: Fix comments. [-Wdocumentation]
llvm-svn: 246995
2015-09-08 09:42:41 +00:00
John McCall 999110f903 When building the alloca for a local variable, set its name
separately from building the instruction so that it's
preserved even in -Asserts builds.

Employ C++'s mystical "comment" feature to discourage
breaking this in the future.

llvm-svn: 246991
2015-09-08 09:18:30 +00:00
John McCall f1044c044a Remove unnecessary braces; this resolves against a
single-pointer overload instead of the ArrayRef one.

llvm-svn: 246988
2015-09-08 08:57:00 +00:00
John McCall bd96e98af7 Move BlockByrefHelpers back to CodeGenModule.h to placate MSVC.
llvm-svn: 246986
2015-09-08 08:21:11 +00:00
John McCall 7f416cc426 Compute and preserve alignment more faithfully in IR-generation.
Introduce an Address type to bundle a pointer value with an
alignment.  Introduce APIs on CGBuilderTy to work with Address
values.  Change core APIs on CGF/CGM to traffic in Address where
appropriate.  Require alignments to be non-zero.  Update a ton
of code to compute and propagate alignment information.

As part of this, I've promoted CGBuiltin's EmitPointerWithAlignment
helper function to CGF and made use of it in a number of places in
the expression emitter.

The end result is that we should now be significantly more correct
when performing operations on objects that are locally known to
be under-aligned.  Since alignment is not reliably tracked in the
type system, there are inherent limits to this, but at least we
are no longer confused by standard operations like derived-to-base
conversions and array-to-pointer decay.  I've also fixed a large
number of bugs where we were applying the complete-object alignment
to a pointer instead of the non-virtual alignment, although most of
these were hidden by the very conservative approach we took with
member alignment.

Also, because IRGen now reliably asserts on zero alignments, we
should no longer be subject to an absurd but frustrating recurring
bug where an incomplete type would report a zero alignment and then
we'd naively do a alignmentAtOffset on it and emit code using an
alignment equal to the largest power-of-two factor of the offset.

We should also now be emitting much more aggressive alignment
attributes in the presence of over-alignment.  In particular,
field access now uses alignmentAtOffset instead of min.

Several times in this patch, I had to change the existing
code-generation pattern in order to more effectively use
the Address APIs.  For the most part, this seems to be a strict
improvement, like doing pointer arithmetic with GEPs instead of
ptrtoint.  That said, I've tried very hard to not change semantics,
but it is likely that I've failed in a few places, for which I
apologize.

ABIArgInfo now always carries the assumed alignment of indirect and
indirect byval arguments.  In order to cut down on what was already
a dauntingly large patch, I changed the code to never set align
attributes in the IR on non-byval indirect arguments.  That is,
we still generate code which assumes that indirect arguments have
the given alignment, but we don't express this information to the
backend except where it's semantically required (i.e. on byvals).
This is likely a minor regression for those targets that did provide
this information, but it'll be trivial to add it back in a later
patch.

I partially punted on applying this work to CGBuiltin.  Please
do not add more uses of the CreateDefaultAligned{Load,Store}
APIs; they will be going away eventually.

llvm-svn: 246985
2015-09-08 08:05:57 +00:00
Ted Kremenek 3a0678e33c [analyzer] Apply whitespace cleanups by Honggyu Kim.
llvm-svn: 246978
2015-09-08 03:50:52 +00:00
Alexandros Lamprineas 94d75dba14 Refactoring of how ARMTargetInfo handles default target features.
Differential Revision: http://reviews.llvm.org/D11299

llvm-svn: 246946
2015-09-06 16:15:45 +00:00
George Burgess IV b40cd567c3 Fix a bug in __builtin_object_size cast removal
Apparently there are many cast kinds that may cause implicit pointer
arithmetic to happen. In light of this, the cast ignoring logic
introduced in r246877 has been changed to only ignore a small set of
cast kinds, and a test for this behavior has been added.

Thanks to Richard for catching this before it became a bug report. :)

llvm-svn: 246890
2015-09-04 22:36:18 +00:00
Hal Finkel 0e2b975eb6 Don't crash on a self-alias declaration
We were crashing in CodeGen given input like this:

  int self_alias(void) __attribute__((weak, alias("self_alias")));

such a self-alias is invalid, but instead of diagnosing the situation, we'd
proceed to produce IR for both the function declaration and the alias. Because
we already had a function named 'self_alias', the alias could not be named the
same thing, and so LLVM would pick a different name ('self_alias1' for example)
for that value. When we later called CodeGenModule::checkAliases, we'd look up
the IR value corresponding to the alias name, find the function declaration
instead, and then assert in a cast to llvm::GlobalAlias. The easiest way to prevent
this is simply to avoid creating the wrongly-named alias value in the first
place and issue the diagnostic there (instead of in checkAliases). We detect a
related cycle case in CodeGenModule::EmitAliasDefinition already, so this just
adds a second such check.

Even though the other test cases for this 'alias definition is part of a cycle'
diagnostic are in test/Sema/attr-alias-elf.c, I've added a separate regression
test for this case. This is because I can't add this check to
test/Sema/attr-alias-elf.c without disturbing the other test cases in that
file. In order to avoid construction of the bad IR values, this diagnostic
is emitted from within CodeGenModule::EmitAliasDefinition (and the relevant
declaration is not added to the Aliases vector). The other cycle checks are
done within the CodeGenModule::checkAliases function based on the Aliases
vector, called from CodeGenModule::Release.  However, if there have been errors
earlier, HandleTranslationUnit does not call Release, and so checkAliases is
never called, and so none of the other diagnostics would be produced.

Fixes PR23509.

llvm-svn: 246882
2015-09-04 21:49:21 +00:00
Richard Smith 81c7248cac Fix crash on invalid if we can't find a suitable PCH file in a specified
directory, and our frontend action cares whether the frontend setup actually
succeeded.

llvm-svn: 246881
2015-09-04 21:44:32 +00:00
Reid Kleckner 5ee4b9a11f Don't use unreachable as a placeholder, it confuses EmitBlock
This fixes an issue raised in D12412, where we generated invalid IR.

Thanks to Vedant Kumar for coming up with the initial work around.

Differential Revision: http://reviews.llvm.org/D12412

llvm-svn: 246880
2015-09-04 21:39:15 +00:00
George Burgess IV 3a03fabdd0 Increase accuracy of __builtin_object_size.
Improvements:

- For all types, we would give up in a case such as:
    __builtin_object_size((char*)&foo, N);
  even if we could provide an answer to
    __builtin_object_size(&foo, N);
  We now provide the same answer for both of the above examples in all
  cases.

- For type=1|3, we now support subobjects with unknown bases, as long
  as the designator is valid.

Thanks to Richard Smith for the review + design planning.

Review: http://reviews.llvm.org/D12169
llvm-svn: 246877
2015-09-04 21:28:13 +00:00
Hans Wennborg 5427a69545 Don't allow dllexport/import on static local variables
They might technically have external linkage, but it still doesn't make sense
for the user to try and export such variables. This matches MSVC's and MinGW's
behaviour.

llvm-svn: 246864
2015-09-04 19:59:39 +00:00
Alexey Bataev 5a1954780f [OPENMP] Fix false diagnostic on instantiation-dependent exprs for atomic constructs.
Some of instantiation-dependent expressions could cause false diagnostic to be emitted about unsupported atomic constructs. Relaxed rules for detection of incorrect expressions.

llvm-svn: 246853
2015-09-04 12:55:50 +00:00
Alexey Bataev caacd53dde [OPENMP] Fix for http://llvm.org/PR24674: assertion failed and and abort trap
Fix processing of shared variables with reference types in OpenMP constructs. Previously, if the variable was not marked in one of the private clauses, the reference to this variable was emitted incorrectly and caused an assertion later.

llvm-svn: 246846
2015-09-04 11:26:21 +00:00
Olivier Goffart 1ba7dc38d0 Fix the perentheses location when the constructor is called on a class that has a destructor
llvm-svn: 246844
2015-09-04 10:17:10 +00:00
NAKAMURA Takumi f6cef72f12 Fix a couple of \param(s) in r246815. [-Wdocumentation]
llvm-svn: 246838
2015-09-04 05:19:31 +00:00
Richard Smith 37e14987c6 Cleanups, no functionality change.
llvm-svn: 246837
2015-09-04 04:09:21 +00:00
Alexey Bataev a7ab1b4206 [X86-64] Allow additional register names in inline assembler.
Patch allows to recognize additional registers x8d, x8b, x8w - x15d, x15b, x15w in inline assembler, already recognized by backend
Differential Revision: http://reviews.llvm.org/D12594

llvm-svn: 246835
2015-09-04 03:42:23 +00:00
Richard Smith 332653ccf6 Fix a potential APInt memory leak when using __attribute__((flag_enum)), and
simplify the implementation a bit.

llvm-svn: 246830
2015-09-04 01:03:03 +00:00
Gabor Horvath b47128aaf3 [Static Analyzer] Remove sinks from nullability checks.
Differential Revision: http://reviews.llvm.org/D12445 

llvm-svn: 246818
2015-09-03 23:16:21 +00:00
Naomi Musgrave 866af2d6d1 Refactored dtor sanitizing into EHScopeStack
Summary:
Dtor sanitization handled amidst other dtor cleanups,
between cleaning bases and fields. Sanitizer call pushed onto
stack of cleanup operations.

Reviewers: eugenis, kcc

Differential Revision: http://reviews.llvm.org/D12022

Refactoring dtor sanitizing emission order.

- Support multiple inheritance by poisoning after
 member destructors are invoked, and before base
 class destructors are invoked.
- Poison for virtual destructor and virtual bases.
- Repress dtor aliasing when sanitizing in dtor.
- CFE test for dtor aliasing, and repression of aliasing in dtor
 code generation.
- Poison members on field-by-field basis, with collective poisoning
 of trivial members when possible.
- Check msan flags and existence of fields, before dtor sanitizing,
 and when determining if aliasing is allowed.
- Testing sanitizing bit fields.

llvm-svn: 246815
2015-09-03 23:02:30 +00:00
Dan Gohman c285307e14 [WebAssembly] Initial WebAssembly support in clang
This implements basic support for compiling (though not yet assembling
or linking) for a WebAssembly target. Note that ABI details are not yet
finalized, and may change.

Differential Revision: http://reviews.llvm.org/D12002

llvm-svn: 246814
2015-09-03 22:51:53 +00:00
DeLesley Hutchins 445a31cd4b Thread safety analysis: the NO_THREAD_SAFETY_ANALYSIS attribute will now
disable checking of arguments to the function, which is done by
-Wthread-safety-reference.

llvm-svn: 246806
2015-09-03 21:14:22 +00:00
Yaron Keren 5bfa1084b1 Fix PR23472þ by emitting initialized variable and its guard in the same COMDAT only for ELF objects.
http://llvm.org/pr23472

Reviewed by Reid Kleckner.

llvm-svn: 246803
2015-09-03 20:33:29 +00:00
Alexandros Lamprineas a448f04697 Implement ACLE 2.0 macros of chapters 6.4 and 6.5 for [ARM] and [Aarch64] targets.
Differential Revision: http://reviews.llvm.org/D12244

Change-Id: Iffd4e822c15e18668fe8868278230ff232ef50aa
llvm-svn: 246768
2015-09-03 14:40:57 +00:00
Daniel Sanders 4f7cd2398b [mips] Added support for choosing between traps and breaks in the integrated assembler macros.
Summary: The command line options for these are -Wa,--trap and -Wa,--break.

Patch by Scott Egerton.

Reviewers: vkalintiris, dsanders

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D11676

llvm-svn: 246765
2015-09-03 12:58:39 +00:00
Oliver Stannard dc2854c2f1 [ARM] Allow passing/returning of __fp16 arguments
The ACLE (ARM C Language Extensions) 2.0 allows the __fp16 type to be
used as a functon argument or return type (ACLE 1.1 did not).

The current public release of the AAPCS (2.09) states that __fp16 values
should be converted to single-precision before being passed or returned,
but AAPCS 2.10 (to be released shortly) changes this, so that they are
passed in the least-significant 16 bits of either a GPR (for base AAPCS)
or a single-precision register (for AAPCS-VFP). This does not change how
arguments are passed if they get passed on the stack.

This patch brings clang up to compliance with the latest versions of
both of these specs.

We can now set the __ARM_FP16_ARGS ACLE predefine, and we have always
been able to set the __ARM_FP16_FORMAT_IEEE predefine (we do not support
the alternative format).

llvm-svn: 246764
2015-09-03 12:40:58 +00:00
Oliver Stannard 9253f00d13 Revert 246755 as it breaks buildbots
Original commit message:
[ARM] Allow passing/returning of __fp16 arguments

The ACLE (ARM C Language Extensions) 2.0 allows the __fp16 type to be
used as a functon argument or return type (ACLE 1.1 did not).

The current public release of the AAPCS (2.09) states that __fp16 values
should be converted to single-precision before being passed or returned,
but AAPCS 2.10 (to be released shortly) changes this, so that they are
passed in the least-significant 16 bits of either a GPR (for base AAPCS)
or a single-precision register (for AAPCS-VFP). This does not change how
arguments are passed if they get passed on the stack.

This patch brings clang up to compliance with the latest versions of
both of these specs.

We can now set the __ARM_FP16_ARGS ACLE predefine, and we have always
been able to set the __ARM_FP16_FORMAT_IEEE predefine (we do not support
the alternative format).

llvm-svn: 246760
2015-09-03 11:46:24 +00:00
Alexey Bataev b500101e1c [OPENMP] Fix for http://llvm.org/PR24687: ICE on compilation of R package TPmsm.
Fixed capturing of VLAs in 'private' clause of the OpenMP directives.

llvm-svn: 246757
2015-09-03 10:21:46 +00:00
Oliver Stannard ee0286201c [ARM] Allow passing/returning of __fp16 arguments
The ACLE (ARM C Language Extensions) 2.0 allows the __fp16 type to be
used as a functon argument or return type (ACLE 1.1 did not).

The current public release of the AAPCS (2.09) states that __fp16 values
should be converted to single-precision before being passed or returned,
but AAPCS 2.10 (to be released shortly) changes this, so that they are
passed in the least-significant 16 bits of either a GPR (for base AAPCS)
or a single-precision register (for AAPCS-VFP). This does not change how
arguments are passed if they get passed on the stack.

This patch brings clang up to compliance with the latest versions of
both of these specs.

We can now set the __ARM_FP16_ARGS ACLE predefine, and we have always
been able to set the __ARM_FP16_FORMAT_IEEE predefine (we do not support
the alternative format).

llvm-svn: 246755
2015-09-03 09:34:53 +00:00
Alexey Bataev 7371aa365c [OPENMP 4.1] Codegen for extended format of 'if' clause.
Fixed codegen for extended format of 'if' clauses with special 'directive-name-modifier' + ast-print tests for extended format of 'if' clause.

llvm-svn: 246748
2015-09-03 08:45:56 +00:00
Alexey Bataev 6b8046addf [OPENMP 4.1] Parsing/sema analysis for extended format of 'if' clause.
OpenMP 4.1 added special 'directive-name-modifier' to the 'if' clause.
Format of 'if' clause is as follows:
```
if([ directive-name-modifier :] scalar-logical-expression)
```

The restriction rules are also changed.
1. If any 'if' clause on the directive includes a 'directive-name-modifier' then all 'if' clauses on the directive must include a 'directive-name-modifier'.
2. At most one 'if' clause without a 'directive-name-modifier' can appear on the directive.
3. At most one 'if' clause with some particular 'directive-name-modifier' can appear on the directive.

'directive-name-modifier' is important for combined directives and allows to separate conditions in 'if' clause for simple sub-directives in combined directive. This 'directive-name-modifier' identifies the sub-directive to which this 'if' clause must be applied.

llvm-svn: 246747
2015-09-03 07:23:48 +00:00
Douglas Katzman 1a050c8aca Remove inadvertent debug output from prior change.
llvm-svn: 246715
2015-09-02 21:18:10 +00:00
Douglas Katzman 7f43af57db Use new utility function to clean leading junk from pathnames. NFC
llvm-svn: 246714
2015-09-02 21:14:53 +00:00
Eric Christopher 86fdc85181 Migrate the target attribute parsing code to returning an instance
every time it's called rather than attempting to cache the result.
It's unlikely to be called frequently and the overhead of using
it in the first place is already factored out.

llvm-svn: 246706
2015-09-02 20:40:12 +00:00
Ivan Krasin 4c3f237edb Do not include default sanitizer blacklists into -M/-MM/-MD/-MMD output.
Summary:
Do not include default sanitizer blacklists into -M/-MM/-MD/-MMD output.

Introduce a frontend option -fdepfile-entry, and only insert them
for the user-defined sanitizer blacklists. In frontend, grab ExtraDeps
from -fdepfile-entry, instead of -fsanitize-blacklist.

Reviewers: rsmith, pcc

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D12544

llvm-svn: 246700
2015-09-02 20:02:38 +00:00
Sanjay Patel a24296b459 add __builtin_unpredictable and convert to metadata
This patch depends on r246688 (D12341).

The goal is to make LLVM generate different code for these functions for a target that
has cheap branches (see PR23827 for more details):

int foo();

int normal(int x, int y, int z) {
   if (x != 0 && y != 0) return foo();
   return 1;
}

int crazy(int x, int y) {
   if (__builtin_unpredictable(x != 0 && y != 0)) return foo();
   return 1;
}

Differential Revision: http://reviews.llvm.org/D12458

llvm-svn: 246699
2015-09-02 20:01:30 +00:00
Richard Smith f8c3255843 [modules] Don't waste time reading in the names the module file writer gave to blocks. We don't need these names, and decoding the corresponding bitcode has a significant cost.
llvm-svn: 246680
2015-09-02 17:45:54 +00:00
David Majnemer b33cd908d4 [MS ABI] Number unnamed TagDecls which aren't externally visible
TagDecls (structs, enums, etc.) may have the same name for linkage
purposes of one another; to disambiguate, we add a number to the mangled
named.  However, we didn't do this if the TagDecl has a pseudo-name for
linkage purposes (it was defined alongside a DeclaratorDecl or a
TypeNameDecl).

This fixes PR24651.

llvm-svn: 246659
2015-09-02 15:50:38 +00:00
Benjamin Kramer 9b81903607 [OpenMP] Make helper functoin static. NFC.
llvm-svn: 246657
2015-09-02 15:31:05 +00:00
Douglas Katzman 15172619d4 [Shave]: pass through more clang options to moviCompile
llvm-svn: 246652
2015-09-02 13:42:43 +00:00
Douglas Katzman b76a3dfb7d [Sparc]: GCCInstallationDetector should not care if little-endian
llvm-svn: 246650
2015-09-02 13:33:42 +00:00
Aaron Ballman 7f0c25b6c9 Silence a -Wsign-compare warning; NFC.
llvm-svn: 246646
2015-09-02 12:50:12 +00:00
Vedant Kumar 2ea5393ca1 [Sema] Avoid crash on tag-type mismatch (Fixes PR24610)
Differential Revision: http://reviews.llvm.org/D12444

llvm-svn: 246618
2015-09-02 03:27:15 +00:00
Eric Christopher bb0cef6e9c Migrate the target attribute parsing code into an extension off of
the main attribute and cache the results so we don't have to parse
a single attribute more than once.

This reapplies r246596 with a fix for an uninitialized class member,
and a couple of cleanups and formatting changes.

llvm-svn: 246610
2015-09-02 00:12:02 +00:00
Hubert Tong 2cded44d82 Fix assertion failure in TransformOpaqueValueExpr
Summary:
`OpaqueValueExpr`s may not have a source expression (as in the case when
they are created due to a default argument error).
This can cause an assertion failure in `TransformOpaqueValueExpr` during
template instantiation.

This patch fixes the assertion failure.

Reviewers: hfinkel, rsmith

Subscribers: fraggamuffin, cfe-commits

Differential Revision: http://reviews.llvm.org/D11582

Patch by Rachel Craik!

llvm-svn: 246600
2015-09-01 22:50:31 +00:00
Eric Christopher bf91fbab3a Revert "Migrate the target attribute parsing code into an extension off of"
This is failing in release mode. Revert while I figure out what's happening.

This reverts commit r246596.

llvm-svn: 246598
2015-09-01 22:37:03 +00:00
Eric Christopher 21213a7040 Migrate the target attribute parsing code into an extension off of
the main attribute and cache the results so we don't have to parse
a single attribute more than once.

llvm-svn: 246596
2015-09-01 22:03:58 +00:00
Eric Christopher b57804a134 Use hasAttr, not getAttr if we're just checking for presence.
llvm-svn: 246595
2015-09-01 22:03:56 +00:00
David Majnemer b8ed364d8a [MS ABI] Switch to the CRC implementation in LLVM
We now have an implementation of the CRC in LLVM's libSupport.  Let's
consolidate around that one.

llvm-svn: 246591
2015-09-01 21:24:07 +00:00
Richard Smith d88a7f1a92 Re-commit r246497 (and dependent changes r246524 and r246521), reverted in
r246546, with a workaround for an MSVC 2013 miscompile and an MSVC 2015
rejects-valid.

Original commit message:

[modules] Rework serialized DeclContext lookup table management. Instead of
walking the loaded ModuleFiles looking for lookup tables for the context, store
them all in one place, and merge them together if we find we have too many
(currently, more than 4). If we do merge, include the merged form in our
serialized lookup table, so that downstream readers never need to look at our
imports' tables.

This gives a huge performance improvement to builds with very large numbers of
modules (in some cases, more than a 2x speedup was observed).

llvm-svn: 246582
2015-09-01 20:35:42 +00:00
Eric Christopher e9cdcaee7b Pull initFeatureMap out of line now that it's used in multiple places.
llvm-svn: 246565
2015-09-01 18:13:20 +00:00
Aaron Ballman 6924dcdf6f Add a new frontend warning for referencing members from the handler of a constructor or destructor function-try-block, which is UB in C++.
This corresponds to the CERT secure coding rule ERR53-CPP.

llvm-svn: 246548
2015-09-01 14:49:24 +00:00
Aaron Ballman 6a4a210126 Reverting r246497 (which requires also reverting r246524 and r246521 to avoid merge conflicts). It broke the build on MSVC 2015. It also broke an MSVC 2013 bot with testing issues.
llvm\tools\clang\lib\serialization\MultiOnDiskHashTable.h(117):
error C2065: 'Files': undeclared identifier

http://bb.pgr.jp/builders/ninja-clang-i686-msc18-R/builds/2917

llvm-svn: 246546
2015-09-01 13:24:39 +00:00
Richard Smith 6307849666 [modules] When emitting line tables, only emit filenames that are actually referenced by the entries that we emit.
llvm-svn: 246534
2015-09-01 07:41:55 +00:00
Richard Smith b5aaf5a57a Don't use fprintf to emit this diagnostic!
llvm-svn: 246526
2015-09-01 02:35:58 +00:00
Richard Smith 86f14e09a6 Use a more appropriate way of writing 1.
llvm-svn: 246524
2015-09-01 02:02:09 +00:00
David Majnemer 7f0674d6f0 [MS ABI] Cleanup get*ForUnnamedTagDecl
Use "lookup" instead of operator[], it will not perform unnecessary
insertions.  No functionality change is intended.

llvm-svn: 246523
2015-09-01 01:53:07 +00:00
Richard Smith 7fa450c6ae [modules] Preserve DeclID order when merging lookup tables to give a more
predictable diagnostic experience. The hash-of-DeclID order we were using
before gave different results on Win32 due to a different predefined
declaration of __builtin_va_list.

llvm-svn: 246521
2015-09-01 01:37:34 +00:00
Hal Finkel 65e1e4dbe0 [PowerPC] Support __builtin_ppc_get_timebase
GCC 4.8+ has a PowerPC-specific intrinsic, __builtin_ppc_get_timebase, to do
what Clang's __builtin_readcyclecounter does. For compatibility with code that
uses GCC's spelling (including glibc), support it as well.

Partially fixes PR23681.

llvm-svn: 246510
2015-08-31 23:55:19 +00:00
Eric Christopher dec31befef Revert "Pull the target attribute parsing out of CGCall and onto TargetInfo."
This reverts commit r246468 while we figure out what to do about Basic and AST.

llvm-svn: 246508
2015-08-31 23:19:55 +00:00
Richard Smith fa715655ee [modules] Add some missing blockinfo records.
llvm-svn: 246504
2015-08-31 22:43:10 +00:00
Richard Smith 9ce2b45936 [modules] Rework serialized DeclContext lookup table management. Instead of
walking the loaded ModuleFiles looking for lookup tables for the context, store
them all in one place, and merge them together if we find we have too many
(currently, more than 4). If we do merge, include the merged form in our
serialized lookup table, so that downstream readers never need to look at our
imports' tables.

This gives a huge performance improvement to builds with very large numbers of
modules (in some cases, more than a 2x speedup was observed).

llvm-svn: 246497
2015-08-31 22:17:11 +00:00
Gabor Horvath 742fd989b5 Revert r246345 until an assertion is fixed.
llvm-svn: 246479
2015-08-31 20:10:35 +00:00
Rafael Espindola c53c5b13be Stop hardcoding GCC paths in crt/ld.so lookup.
This patch refactors the code to use the GCC installation detector
(modified so that it works in Solaris), and uses
ToolChain::GetFilePath everywhere once it works.

Patch by Xan López <xan@igalia.com>!

llvm-svn: 246473
2015-08-31 19:17:51 +00:00
David Majnemer 0035052729 [MS ABI] Correctly mangle classes without names for linkage purposes
A class without a name for linkage purposes gets a name along the lines
of <unnamed-type-foo> where foo is either the name of a declarator which
defined it (like a variable or field) or a
typedef-name (like a typedef or alias-declaration).

We handled the declarator case correctly but it would fall down during
template instantiation if the declarator didn't share the tag's type.
We failed to handle the typedef-name case at all.

Instead, keep track of the association between the two and keep it up to
date in the face of template instantiation.

llvm-svn: 246469
2015-08-31 18:48:39 +00:00
Eric Christopher d40722e267 Pull the target attribute parsing out of CGCall and onto TargetInfo.
Also:
  - Add a typedef to make working with the result easier.
  - Update callers to use the new function.
  - Make initFeatureMap out of line.

llvm-svn: 246468
2015-08-31 18:39:22 +00:00
Eric Christopher a8a14c3d88 Pull out the ppc incompatible features check into a separate function.
llvm-svn: 246467
2015-08-31 18:39:16 +00:00
Jingyue Wu 2d69f9608e [CUDA] fix codegen for __nvvm_atom_min/max_gen_u*
Summary: Clang should emit "atomicrmw umin/umax" instead of "atomicrmw min/max".

Reviewers: eliben, tra

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D12487

llvm-svn: 246455
2015-08-31 17:25:51 +00:00
Andrey Bokhanko cab5858e1b PR17829: Proper diagnostic of mangled names conflicts
Proper diagnostic and resolution of mangled names conflicts between C++ methods
and C functions. This patch implements support for functions/methods only;
support for variables is coming separately.

Differential Revision: http://reviews.llvm.org/D11297

llvm-svn: 246438
2015-08-31 13:20:44 +00:00
Alexey Bataev d6fdc8b685 [OPENMP 4.0] Codegen for array sections.
Added codegen for array section in 'depend' clause of 'task' directive. It emits to pointers, one for the begin of array section and another for the end of array section. Size of the section is calculated as (end + 1 - start) * sizeof(basic_element_type).

llvm-svn: 246422
2015-08-31 07:32:19 +00:00
Alexey Bader f961e755b1 [OpenCL] Improve diagnostics detecting implicit vector conversion.
Reviewers: pekka.jaaskelainen

Differential Revision: http://reviews.llvm.org/D12470

llvm-svn: 246393
2015-08-30 18:06:39 +00:00
Benjamin Kramer fc600dc2ec [OpenMP] Make the filetered clause iterator a real iterator and type safe.
This replaces the filtered generic iterator with a type-specfic one based
on dyn_cast instead of comparing the kind enum. This allows us to use
range-based for loops and eliminates casts. No functionality change
intended.

llvm-svn: 246384
2015-08-30 15:12:28 +00:00
Chandler Carruth d96f37a772 Update for several APIs in LLVM that now use StringRefs rather than
const char pointers. In turn, push this through Clang APIs as well,
simplifying a number of bits of code that was handling the oddities of
nullptrs.

llvm-svn: 246375
2015-08-30 07:51:18 +00:00
Chandler Carruth aa0caeb431 Update for API change in LLVM: ARMTargetParser class is just the ARM
namespace.

llvm-svn: 246368
2015-08-30 02:16:36 +00:00
David Majnemer c378ca5043 [AST] Don't crash when comparing incomplete object
We cannot tell if an object is past-the-end if its type is incomplete.
Zero sized objects satisfy past-the-end criteria and our object might
turn out to be such an object.

This fixes PR24622.

llvm-svn: 246359
2015-08-29 08:32:55 +00:00
Hans Wennborg a37b065e8f Follow-up to r246338: use getParentFunctionOrMethod
llvm-svn: 246348
2015-08-28 22:56:21 +00:00
Richard Smith d35cb054c9 PR24612: Don't bail out of checking a constexpr function before checking
whether it can ever produce a constant expression in the case where it has a
void return type and no return statements.

llvm-svn: 246347
2015-08-28 22:33:53 +00:00
Eric Christopher 007b0a0e27 Fold TargetInfo::handleUserFeatures into TargetInfo::initFeatureMap.
llvm-svn: 246346
2015-08-28 22:32:01 +00:00
Devin Coughlin 35d5dd2986 [analyzer] When memcpy'ing into a fixed-size array, do not invalidate entire region.
Change the analyzer's modeling of memcpy to be more precise when copying into fixed-size
array fields. With this change, instead of invalidating the entire containing region the
analyzer now invalidates only offsets for the array itself when it can show that the
memcpy stays within the bounds of the array.

This addresses false positive memory leak warnings of the kind reported by
krzysztof in https://llvm.org/bugs/show_bug.cgi?id=22954

A patch by Pierre Gousseau!

Differential Revision: http://reviews.llvm.org/D11832

llvm-svn: 246345
2015-08-28 22:26:05 +00:00
Hans Wennborg 6eaa8323a8 Allow TLS vars in dllimport/export functions; only inline dllimport functions when safe (PR24593)
This patch does two things:

1) Don't error about dllimport/export on thread-local static local variables.
   We put those attributes on static locals in dllimport/export functions
   implicitly in case the function gets inlined. Now, for TLS variables this
   is a problem because we can't import such variables, but it's a benign
   problem becase:

2) Make sure we never inline a dllimport function TLS static locals. In fact,
   never inline a dllimport function that references a non-imported function
   or variable (because these are not defined in the importing library). This
   seems to match MSVC's behaviour.

Differential Revision: http://reviews.llvm.org/D12422

llvm-svn: 246338
2015-08-28 21:47:01 +00:00
Aaron Ballman 6c79f352b8 Adding an AST matcher for namespaceAliasDecl.
llvm-svn: 246322
2015-08-28 19:39:21 +00:00
Sanjay Patel 69e7f6e436 fix typo; NFC
llvm-svn: 246303
2015-08-28 14:42:54 +00:00
Sylvestre Ledru c0babf2bc0 Support Debian s390x multiarch paths
Summary: Patch by Steven Chamberlain <steven@pyro.eu.org>

Reviewers: uweigand

Differential Revision: http://reviews.llvm.org/D12430

llvm-svn: 246295
2015-08-28 12:26:09 +00:00
Daniel Jasper ad5b7962c9 Revert "[OPENMP 4.0] Codegen for array sections."
The test is currently failing on bots:
http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-incremental_check/12747/

llvm-svn: 246288
2015-08-28 08:42:22 +00:00
Steven Wu 5528da76ef Revert r246214 and r246213
These two commits causes llvm LTO bootstrap to hang in ScalarEvolution.

llvm-svn: 246282
2015-08-28 07:14:10 +00:00
Alexey Bataev 117fb35cf7 [OPENMP 4.0] Codegen for array sections.
Added codegen for array section in 'depend' clause of 'task' directive. It emits to pointers, one for the begin of array section and another for the end of array section. Size of the section is calculated as (end + 1 - start) * sizeof(basic_element_type).

llvm-svn: 246278
2015-08-28 06:09:05 +00:00
Richard Smith 52a980a97f PR24597: Fix in-place evaluation of call expressions to provide a proper "this"
pointer to an RVO construction of a returned object.

llvm-svn: 246263
2015-08-28 02:43:42 +00:00
Eric Christopher e6b6488c70 Instead of duplicating code, call the base implementation.
llvm-svn: 246260
2015-08-28 02:14:00 +00:00
Eric Christopher ef1e295a8c Merge the two feature map setting functions into a single function
and replace all callers.

llvm-svn: 246259
2015-08-28 02:13:58 +00:00
Richard Trieu a1d7ece05c Fix macro backtrace printing.
Sometimes, a macro that expands to another macro name will not be printed in
the macro backtrace.  This patch finds the missed macro expansions and prints
them.  Fixes PR16799

llvm-svn: 246237
2015-08-27 23:38:45 +00:00
Adrian Prantl 3a884fa9e3 CGDebugInfo: Instead of uniquing RetainedTypes, just refrain from retaining
them more than once. (NFC)

llvm-svn: 246231
2015-08-27 22:56:46 +00:00
Ahmed Bougacha 02b7b56af8 [X86] Bump Darwin MaxVectorAlign to 64 when AVX512 is enabled.
Without this, 64-byte vector types (__m512), specified to be 64-byte
aligned in the AVX512 draft SysV ABI, will only be 32-byte aligned.

This is analoguous to AVX, for which we accept 32-byte max alignment.

Differential Revision: http://reviews.llvm.org/D10724

llvm-svn: 246230
2015-08-27 22:42:12 +00:00
Ahmed Bougacha 82b619ea68 [X86] Conditionalize Darwin MaxVectorAlign on the presence of AVX.
There's no point in using a larger alignment if we have no instructions
that would benefit from it.

Differential Revision: http://reviews.llvm.org/D12389

llvm-svn: 246229
2015-08-27 22:30:38 +00:00
Ahmed Bougacha 68bf64e302 [X86] Use AVX features instead of ABI to init. SimdDefaultAlign.
The ABI string only exists to communicate with TargetCodeGenInfo.
Concretely, since we only used "avx*" ABI strings on x86_64 (as AVX
doesn't affect the i386 ABIs), this meant that, when initializing
SimdDefaultAlign, we would ignore AVX/AVX512 on i386, for no good
reason.

Instead, directly check the features. A similar change for
MaxVectorAlign will follow.

Differential Revision: http://reviews.llvm.org/D12390

llvm-svn: 246228
2015-08-27 22:24:56 +00:00
Eric Christopher da89d6804c Use an explicit assignment.
llvm-svn: 246225
2015-08-27 22:20:03 +00:00
Richard Smith 5f55d93c84 Don't call a member function on a null pointer.
llvm-svn: 246215
2015-08-27 21:38:25 +00:00
Piotr Padlewski 81461a4350 Assume loads fix #2
There was linker problem, and it turns out that it is not always safe
to refer to vtable. If the vtable is used, then we can refer to it
without any problem, but because we don't know when it will be used or
not, we can only check if vtable is external or it is safe to to emit it
speculativly (when class it doesn't have any inline virtual functions).
It should be fixed in the future.

http://reviews.llvm.org/D12385

llvm-svn: 246214
2015-08-27 21:35:41 +00:00
Piotr Padlewski 525f746710 Generating assumption loads of vptr after ctor call (fixed)
Generating call assume(icmp %vtable, %global_vtable) after constructor
call for devirtualization purposes.

For more info go to:
http://lists.llvm.org/pipermail/cfe-dev/2015-July/044227.html

Edit:
Fixed version because of PR24479.

http://reviews.llvm.org/D11859

llvm-svn: 246213
2015-08-27 21:35:37 +00:00
Adrian Prantl ad9a195ee9 CGDebugInfo: Factor out a getOrCreateStandaloneType() method.
Usually debug info is created on the fly while during codegen.
With this API it becomes possible to create standalone debug info
for types that are not referenced by any code, such as emitting debug info
for a clang module or for implementing something like -gfull.
Because on-the-fly debug info generation may still insert retained types
on top of them, all RetainedTypes are uniqued in CGDebugInfo::finalize().

llvm-svn: 246210
2015-08-27 21:21:19 +00:00
Eric Christopher 53b2afa28f Remove a dead assert, we'd have gotten the case above.
llvm-svn: 246202
2015-08-27 20:32:24 +00:00
Eric Christopher 3751bce2a9 Target attribute syntax compatibility fix - gcc uses no- rather than mno-.
llvm-svn: 246197
2015-08-27 20:05:48 +00:00
Eric Christopher 3a98b3c1a5 Rewrite the code generation handling for function feature and cpu attributes.
A couple of changes here:

a) Do less work in the case where we don't have a target attribute on the
function. We've already canonicalized the attributes for the function -
no need to do more work.

b) Use the newer canonicalized feature adding functions from TargetInfo
to do the work when we do have a target attribute. This enables us to diagnose
some warnings in the case of conflicting written attributes (only ppc does
this today) and also make sure to get all of the features for a cpu that's
listed rather than just change the cpu.

Updated all testcases accordingly and added a new testcase to verify that we'll
error out on ppc if we have some incompatible options using the existing diagnosis
framework there.

llvm-svn: 246195
2015-08-27 19:59:34 +00:00
Artem Belevich 5ef02c2db7 [CUDA] Check register names on appropriate side of cuda compilation only.
Differential Revision: http://reviews.llvm.org/D11950

llvm-svn: 246193
2015-08-27 19:54:21 +00:00
Adrian Prantl 6b21ab21d1 Add a -gmodules option to the driver and a -dwarf-ext-refs to cc1
to enable the use of external type references in the debug info
(a.k.a. module debugging).

The driver expands -gmodules to "-g -fmodule-format=obj -dwarf-ext-refs"
and passes that to cc1. All this does at the moment is set a flag
codegenopts.

http://reviews.llvm.org/D11958

llvm-svn: 246192
2015-08-27 19:46:20 +00:00
Gabor Horvath 8d3ad6b617 [Static Analyzer] Make NonNullParamChecker emit implicit null dereference events.
Differential Revision: http://reviews.llvm.org/D11433

llvm-svn: 246182
2015-08-27 18:49:07 +00:00
Eric Christopher 1c07d8ce83 const-ify TargetInfo::handleUserFeatures.
llvm-svn: 246180
2015-08-27 18:42:57 +00:00
Artem Belevich f8144ab44f [CUDA] Improve CUDA compilation pipeline creation.
Current implementation tries to guess which Action will result in a
job which needs to incorporate device-side GPU binaries. The guessing
was attempting to work around the fact that multiple actions may be
combined into a single compiler invocation. If CudaHostAction ends up
being combined (and thus bypassed during action list traversal) no
device-side actions it pointed to were processed. The guessing worked
for most of the usual cases, but fell apart when external assembler
was used.

This change removes the guessing and makes sure we create and pass
device-side jobs regardless of how the jobs get combined.

* CudaHostAction is always inserted either at Compile phase or the
  FinalPhase of current compilation, whichever happens first.
* If selectToolForJob combines CudaHostAction with other actions, it
  passes info about CudaHostAction up to the caller
* When it sees that CudaHostAction got combined with other actions
  (and hence will never be passed to BuildJobsForActions),
  BuildJobsForActions creates device-side jobs the same way they would
  be created if CudaHostAction was passed to BuildJobsForActions
  directly.
* Added two more test cases to make sure GPU binaries are passed to
  correct jobs.

Differential Revision: http://reviews.llvm.org/D11280

llvm-svn: 246174
2015-08-27 18:10:41 +00:00
Daniel Jasper 7b259cda96 clang-format: Don't let a leading "template <..>" lead to wrapped initializers.
Before:
  Constructor() : initializer(0) {}

  template <typename T>
  Constructor()
      : initializer(0) {}

After:
  Constructor() : initializer(0) {}

  template <typename T>
  Constructor() : initializer(0) {}

llvm-svn: 246146
2015-08-27 11:59:31 +00:00
Eric Christopher 2b4a725e0a Pass in a cpu to initDefaultFeatures so that we can share this code
with multiple uses of feature map construction.

Note: We could make this a static function on TargetInfo if we
fix the x86 port needing to check the triple in an isolated case.

llvm-svn: 246128
2015-08-27 00:05:52 +00:00
Eric Christopher c50738f139 const-ify X86TargetInfo::getCPUKind.
llvm-svn: 246127
2015-08-27 00:05:50 +00:00
Richard Smith a06c7e6da7 [modules] The key to a DeclContext name lookup table is not actually a
DeclarationName (because all ctor names are considered the same, and so on).
Reflect this in the type used as the lookup table key. As a side-effect, remove
one copy of the duplicated code used to compute the hash of the key.

llvm-svn: 246124
2015-08-26 23:55:49 +00:00
Eric Christopher b39e44b3f4 Pull out cpu string -> enum parsing for x86 as a separate function,
this is going to see use shortly in unifying feature set construction.

llvm-svn: 246122
2015-08-26 23:42:18 +00:00
Gabor Horvath 28690925ed [Static Analyzer] Checks to catch nullability related issues.
Differential Revision: http://reviews.llvm.org/D11468

llvm-svn: 246105
2015-08-26 23:17:43 +00:00
Duncan P. N. Exon Smith 31d38f70ea DI: Clarify meaning of createTempFunctionFwdDecl() arg, NFC
I stared at `false /*declaration*/` for quite some time before giving up
and checking the actual function to see what it meant.  Replacing with
`/* isDefinition = */ false` to save myself effort later.

llvm-svn: 246095
2015-08-26 22:21:09 +00:00
Charles Li 2af8f46030 Corrected 3 typos. NFC
llvm-svn: 246093
2015-08-26 22:13:30 +00:00
Reid Kleckner 14e96b4930 [ms-inline-asm] Add field access to MS inline asm identifier lookup
Now we can parse code like this:
  struct A {
    int field;
  };
  int f(A o) {
    __asm mov eax, o.field
  }

Fixes PR19117.

llvm-svn: 246088
2015-08-26 21:57:20 +00:00
Simon Pilgrim 5aba9925c0 [X86][SSE] Add _mm_undefined_* intrinsics
Added missing SSE/AVX 'undefined' intrinsics (PR24040):

_mm_undefined_pd, _mm_undefined_ps + _mm_undefined_si128
_mm256_undefined_pd, _mm256_undefined_ps + _mm256_undefined_si256
_mm512_undefined, _mm512_undefined_ps, _mm512_undefined_pd + _mm512_undefined_epi32

Added builtin intrinsicss:

__builtin_ia32_undef128, __builtin_ia32_undef256 + __builtin_ia32_undef512

Differential Revision: http://reviews.llvm.org/D12052

llvm-svn: 246083
2015-08-26 21:17:12 +00:00
Akira Hatanaka 9d99bb50c4 [ARM] Error out if float-ab=hard and abi=apcs-gnu on macho platforms.
Error out if -mfloat-abi=hard or -mhard-float is specified on the command
line and the target ABI is APCS. Previously clang issued no warnings or
errors and just passed the option to the backend, which had no effect on
code generation for targets using APCS.

This commit corrects the patch commited in r245866, which didn't take into
account the fact that not all darwin targets use APCS.

rdar://problem/22257950

http://reviews.llvm.org/D12344

llvm-svn: 246054
2015-08-26 19:00:11 +00:00
Derek Schuff 9afb05024d Change Native Client x86 usr include and link path to match SDK expectations
GNU multilib style uses x86_64-nacl/include and x86_64-nacl/usr/include
but the SDK expects i686-nacl/usr/include for its files. Change the driver
to use this.

Fixes https://code.google.com/p/nativeclient/issues/detail?id=4108

Differential Revision: http://reviews.llvm.org/D11271

llvm-svn: 246040
2015-08-26 17:14:08 +00:00
Samuel Benzaquen f8ec454f7d [ASTMatchers] Add type matcher for SubstTemplateTypeParmType.
llvm-svn: 246037
2015-08-26 16:15:59 +00:00
Eric Christopher 610fe11ad1 Convert a bunch of loops to ranged-for and clean up accordingly.
llvm-svn: 246027
2015-08-26 08:21:55 +00:00
Yaron Keren 8dec46cf5a Make FileManager::getFileSystemOptions consistent with CompilerInstance::getFileSystemOpts
and CompilerInvocation::getFileSystemOpts by renaming it to getFileSystemOpts,
marking the const-returning access method const and adding a non-const version,
making the function prototypes identical to CompilerInstance::getFileSystemOpts.

llvm-svn: 246026
2015-08-26 08:10:22 +00:00
Eric Christopher d50e2e6397 Remove dead code associated with parsing and setting ABI based on
string name.

llvm-svn: 246021
2015-08-26 07:01:33 +00:00
Eric Christopher 1d3cbfa1c1 Remove a TODO that isn't going to get fixed in this way.
llvm-svn: 246020
2015-08-26 07:01:30 +00:00
David Majnemer d39bcaed21 [Sema] Don't assume CallExpr::getDirectCallee will succeed
We tried to provide a very nice diagnostic when diagnosing an assignment
to a const int & produced by a function call.  However, we cannot always
determine what function was called.

This fixes PR24568.

llvm-svn: 246014
2015-08-26 05:13:19 +00:00
Eric Christopher b39156d068 Update file comment to more accurately describe what's implemented.
llvm-svn: 246006
2015-08-26 04:23:11 +00:00
Nathan Wilson e23a9a4514 Modify DeclaratorChuck::getFunction to be passed an Exception Specification SourceRange
Summary:
- Store the exception specification range's begin and end SourceLocation in DeclaratorChuck::FunctionTypeInfo. These SourceLocations can be used in a FixItHint Range.
- Add diagnostic; function concept having an exception specification.


Reviewers: hubert.reinterpretcast, fraggamuffin, faisalv, aaron.ballman, rsmith

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D11789

llvm-svn: 246005
2015-08-26 04:19:36 +00:00
Ted Kremenek 9589caf04d Add missing newline.
llvm-svn: 246003
2015-08-26 03:11:31 +00:00
Nick Lewycky e283c5529e Make sure that we evaluate __attribute__((enable_if)) on a method with no overloads. Patch by Ettore Speziale!
llvm-svn: 245985
2015-08-25 22:33:16 +00:00
Nick Lewycky 08426e2098 Clarify the error message when the reason the conversion is not viable is because the returned value does not match the function return type.
llvm-svn: 245979
2015-08-25 22:18:46 +00:00
Simon Pilgrim fbb8904411 [X86] Remove unnecessary MMX declarations from Intrin.h
As discussed in PR23648 - the intrinsics _m_from_int, _m_to_int and _m_prefetch are defined in mmintrin.h and prfchwintrin.h so we don't need to in Intrin.h

Added tests for _m_from_int and _m_to_int

D11338 already added a test for _m_prefetch

Differential Revision: http://reviews.llvm.org/D12272

llvm-svn: 245975
2015-08-25 21:27:46 +00:00
Nico Weber 8cdb3f90ef Revert r245879. Speculative, might have caused crbug.com/524604
llvm-svn: 245965
2015-08-25 18:43:32 +00:00
David Majnemer a94e7b6acf [Sema] Handle leading and trailing __ for GNU attributes
GNU attributes can have a leading and trailing __ appended/prepended to
the attribute name.  While the parser and AttributeList::getKind did the
right thing, AttributeList::getAttributeSpellingListIndex did not.

This fixes PR24565.

llvm-svn: 245953
2015-08-25 16:44:38 +00:00
Gabor Horvath 3240cd3421 [Static Analyzer] Fixed a typo in a diagnostic message.
llvm-svn: 245949
2015-08-25 16:27:03 +00:00
Diego Novillo d3ef1083c3 Convert SampleProfile pass into a Module pass.
Eventually, we will need sample profiles to be incorporated into the
inliner's cost models.  To do this, we need the sample profile pass to
be a module pass.

This patch makes no functional changes beyond the mechanical adjustments
needed to run SampleProfile as a module pass.

llvm-svn: 245941
2015-08-25 15:25:13 +00:00
Alexey Bataev 627cbd31d1 Fix possible crash on null base or type for array elements.
llvm-svn: 245939
2015-08-25 15:15:12 +00:00
Alexey Bataev 1a3320e463 [OPENMP 4.0] Initial support for array sections.
Adds parsing/sema analysis/serialization/deserialization for array sections in OpenMP constructs (introduced in OpenMP 4.0).
Currently it is allowed to use array sections only in OpenMP clauses that accepts list of expressions.
Differential Revision: http://reviews.llvm.org/D10732

llvm-svn: 245937
2015-08-25 14:24:04 +00:00
Eric Christopher f0c2dd07ea Rewrite the PPC target feature handling to more resemble other targets.
This involved specializing handleUserFeatures so that we could perform
diagnostics on -only- user supplied features and migrating the rest of
the initialization functions to set features based on enabling and disabling
full feature sets. No functional change intended.

llvm-svn: 245936
2015-08-25 13:45:28 +00:00
Eric Christopher 6b45437f6f Extract handling of user defined features into a function so we can
specialize it on the targets.

llvm-svn: 245935
2015-08-25 13:45:24 +00:00
Daniel Jasper af642c6927 clang-format: Add space before member function reference qualifiers.
Before:
  SomeType MemberFunction(const Deleted &)&;

After:
  SomeType MemberFunction(const Deleted &) &;

Seems to be much more common.

llvm-svn: 245934
2015-08-25 13:40:51 +00:00
Michael Kuperstein b62c5bc64d Revert r245923 since it breaks mingw.
llvm-svn: 245929
2015-08-25 11:42:31 +00:00
Michael Kuperstein 2c8f9c2c23 [X86] Expose the various _rot intrinsics on non-MS platforms
_rotl, _rotwl and _lrotl (and their right-shift counterparts) are official x86
intrinsics, and should be supported regardless of environment. This is in contrast
to _rotl8, _rotl16, and _rotl64 which are MS-specific.

Note that the MS documentation for _lrotl is different from the Intel 
documentation. Intel explicitly documents it as a 64-bit rotate, while for MS,
since sizeof(unsigned long) for MSVC is always 4, a 32-bit rotate is implied.

Differential Revision: http://reviews.llvm.org/D12271

llvm-svn: 245923
2015-08-25 07:21:33 +00:00
Eric Christopher 02c33354f0 Reimplement the PPC explicit option checking to be a bit more obvious
that we're looking for conflicting options and give an explanation.

llvm-svn: 245914
2015-08-25 00:59:11 +00:00
David Majnemer 7ab76f2d71 [clang-cl] Only respect /Oy- for x86_32
The /Oy- flag should have no effect for 64-bit X86, it has reliable
unwind tables.

llvm-svn: 245913
2015-08-25 00:46:45 +00:00
Derek Schuff ef465d7745 Use GetLinkerPath utility function to find linker for NaCl toolchain
Summary:
This is more consistent with other targets and also makes the -fuse-ld
flag work.

Reviewers: jvoung

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D10697

llvm-svn: 245908
2015-08-24 23:53:25 +00:00
Ahmed Bougacha 40882bb9f8 [ARM NEON] Use CGF cached Types instead of llvm::Type::get. NFC.
llvm-svn: 245906
2015-08-24 23:47:29 +00:00
Ahmed Bougacha 774b5e296f [ARM NEON] Replace redundant code with a new GetFloatNeonType. NFC.
llvm-svn: 245904
2015-08-24 23:41:31 +00:00
Richard Smith d8879c85f6 [modules] Remove unnecessary deserialization of fully-external HeaderFileInfos for all files we've seen in this compilation.
llvm-svn: 245881
2015-08-24 21:59:32 +00:00
David Majnemer 3cbfb65a52 [MS ABI] Don't emit stackrestore in cleanups
The stackrestore intrinsic isn't meaningful inside of a cleanup funclet.

llvm-svn: 245879
2015-08-24 21:34:21 +00:00
Akira Hatanaka 44a6184a6d Revert r245866.
This commit was causing buildbot failures.

llvm-svn: 245871
2015-08-24 20:30:57 +00:00
Akira Hatanaka bbede731a5 [ARM] Error out on apple darwin platforms if float-abi is "hard".
Error out if the user tries to use float-abi="hard" since it isn't
supported on darwin platforms. Previously clang issued no warnings or
erros and just passed the option to the backend, which had no effect on
code generation for targets using apcs.

rdar://problem/22257950

Differential Revision: http://reviews.llvm.org/D12155

llvm-svn: 245866
2015-08-24 19:50:35 +00:00
Daniel Jasper 788ffd71c6 clang-format: Always allow break after leading annotations.
Before:
  DEPRECATED("Use NewClass::NewFunction instead.") int OldFunction(
  const string &parameter) {}

Could not be formatted at all, as clang-format would both require and
disallow the break before "int".

llvm-svn: 245846
2015-08-24 15:10:01 +00:00
Daniel Jasper 5d7f06fa60 clang-format: Make formatting of member function reference qualifiers
more consistent.

Before:
  SomeType MemberFunction(const Deleted &)&&;
  SomeType MemberFunction(const Deleted &) && { ... }

After:
  SomeType MemberFunction(const Deleted &)&&;
  SomeType MemberFunction(const Deleted &)&& { ... }

llvm-svn: 245843
2015-08-24 14:28:08 +00:00
Daniel Jasper b86e2727f0 clang-format: Properly handle braced lists in macros.
Before:
  #define A    \
      { a, a } \
      ,

After:
  #define A {a, a},

llvm-svn: 245837
2015-08-24 13:23:37 +00:00
Keith Walker 71ad47f81f [AArch64] Define the macro __ARM_FP16_ARGS
The ACLE (ARM C Language Extensions) 2.0 defines that the predefined macro
__ARM_FP16_ARGS should be defined if __fp16 can be used as an argument and
result.

The support for __fp16 to be used as an argument and result is already
implemented for AArch64 so this change is just adding the missing macro.

Differential Revision: http://reviews.llvm.org/D12240

llvm-svn: 245833
2015-08-24 10:11:14 +00:00
Richard Smith 5196a17d3c [modules] If local submodule visibility is disabled, don't bother checking
whether the owning module of a hidden declaration is visible -- it can't be.

llvm-svn: 245822
2015-08-24 03:38:11 +00:00
Richard Smith 79bf920552 [modules] Stop updating all identifiers when writing a module. This is
unnecessary in C++ modules (where we don't need the identifiers for their
Decls) and expensive.

llvm-svn: 245821
2015-08-24 03:33:22 +00:00
Serge Pavlov b24a7111b4 Changes missed from r245810
llvm-svn: 245811
2015-08-23 11:09:40 +00:00
Serge Pavlov 73c6a2448f Instantiate function declarations in instantiated functions.
If a function declaration is found inside a template function as in:

    template<class T> void f() {
      void g(int x = T::v) except(T::w);
    }

it must be instantiated along with the enclosing template function,
including default arguments and exception specification.

Together with the patch committed in r240974 this implements DR1484.

Differential Revision: http://reviews.llvm.org/D11194

llvm-svn: 245810
2015-08-23 10:22:28 +00:00
Joseph Tremoulet ce536a596b [WinEH] Update to new EH pad/ret signatures (with tokens required)
Summary:
The signatures of the methods in LLVM for creating EH pads/rets are changing
to require token arguments on rets and assume token return type on pads.
Update creation code accordingly.

Reviewers: majnemer, rnk

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D12109

llvm-svn: 245798
2015-08-23 00:26:48 +00:00
Richard Smith cd31b85c12 Improve the performance of resolving a lookup result. We usually don't need to
pick the most recent declaration, and we can often tell which declaration is
more recent without walking the redeclaration chain. Do so when possible.

llvm-svn: 245794
2015-08-22 21:37:34 +00:00
Richard Smith d61d4acd70 [modules] Further simplification and speedup of redeclaration chain loading.
Instead of eagerly deserializing a list of DeclIDs when we load a module file
and doing a binary search to find the redeclarations of a decl, store a list of
redeclarations of each chain before the first declaration and load it directly.

llvm-svn: 245789
2015-08-22 20:13:39 +00:00
Jingyue Wu 284ebe237f [CUDA] Change initializer for CUDA device code based on CUDA documentation.
Summary:
According to CUDA documentation, global variables declared with __device__,
__constant__ can be initialized from host code, so mark them as
externally initialized. Because __shared__ variables cannot have an
initialization as part of their declaration and since the value maybe kept
across different kernel invocation, the value of __shared__ is effectively
undefined instead of zero initialized.

Wrongly using zero initializer may cause illegitimate optimization, e.g.
removing unused __constant__ variable because it's not updated in the device
code and the value is initialized with zero.

Test Plan: test/CodeGenCUDA/address-spaces.cu

Patch by Xuetian Weng

Reviewers: jholewinski, eliben, tra, jingyue

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D12241

llvm-svn: 245786
2015-08-22 05:49:28 +00:00
Richard Smith 0144f5154b [modules] Remove some dead code after r245779.
llvm-svn: 245780
2015-08-22 02:09:38 +00:00
Richard Smith d8a83718f0 [modules] Rearrange how redeclaration chains are loaded, to remove a walk over
all modules and reduce the number of declarations we load when loading a
redeclaration chain.

The new approach is:
 * when loading the first declaration of an entity within a module file, we
   first load all declarations of the entity that were imported into that
   module file, and then load all the other declarations of that entity from
   that module file and build a suitable decl chain from them
 * when loading any other declaration of an entity, we first load the first
   declaration from the same module file

As before, we complete redecl chains through name lookup where necessary.

To make this work, I also had to change the way that template specializations
are stored -- it no longer suffices to track only canonical specializations; we
now emit all "first local" declarations when emitting a list of specializations
for a template.

On one testcase with several thousand imported module files, this reduces the
total runtime by 72%.

llvm-svn: 245779
2015-08-22 01:47:18 +00:00
John McCall ee04aebbdb When building a pseudo-object assignment, and the RHS is
a contextually-typed expression that semantic analysis will
probably need to invasively rewrite, don't include the
RHS OVE as a separate semantic expression, and check the
operation with the original RHS expression.

There are two contextually-typed expressions that can survive
to here: overloaded function references, which are at least
safe to double-emit, and C++11 initializer list expressions,
which are not at all safe to double-emit and which often
don't update the original syntactic InitListExpr with
implicit conversions to member types, etc.

This means that the original RHS may appear, undecorated by
an OVE, in the semantic expressions.  Fortunately, it will
only ever be used in a single place there, and I don't
believe there are clients that rely on being able to pick
out the original RHS from the semantic expressions.
But this could be problematic if there are clients that do
visit the entire tree and rely on not seeing the same
expression multiple times, once in the syntactic and once
in the semantic expressions.  This is a very fiddly part
of the compiler.

rdar://21801088

llvm-svn: 245771
2015-08-22 00:35:27 +00:00
Ahmed Bougacha cd5b8a0235 [ARM NEON] Use the common naming scheme for vcvt f16 builtins. NFC.
We had "vcvt_f16" and "VCVT_HIGH_F16": for other FP types, this naming
is used for intrinsics with integer overloads. The FP->FP conversions,
on the other hand, use the full "vcvt_f32_f64" name instead.

Use the same naming convention for the f16<->f32 conversions.
While there, reorder the definitions a little bit.

llvm-svn: 245763
2015-08-21 23:34:20 +00:00
Piotr Padlewski fa0e11efdd Revert "Generating assumption loads of vptr after ctor call (fixed)"
Reverting because of 245721

This reverts commit 552658e2b60543c928030b09cc9b5dfcb40c3f28.

llvm-svn: 245727
2015-08-21 19:49:41 +00:00
Piotr Padlewski 910a059e42 Generating assumption loads of vptr after ctor call (fixed)
Generating call assume(icmp %vtable, %global_vtable) after constructor
call for devirtualization purposes.

For more info go to:
http://lists.llvm.org/pipermail/cfe-dev/2015-July/044227.html

Edit:
Fixed version because of PR24479.

http://reviews.llvm.org/D11859

llvm-svn: 245721
2015-08-21 18:28:00 +00:00
James Y Knight 7160857da3 Properly provide alignment of 'byval' arguments down to llvm.
This is important in the case that the LLVM-inferred llvm-struct
alignment is not the same as the clang-known C-struct alignment.

Differential Revision: http://reviews.llvm.org/D12243

llvm-svn: 245719
2015-08-21 18:19:06 +00:00
Eric Christopher 9207a52bc5 Fix typo - symetric -> symmetric.
llvm-svn: 245706
2015-08-21 16:24:01 +00:00
Benjamin Kramer c06b6bd6fb [RecordLayoutBuilder] Remove duplicated diagnostic argument. NFC.
llvm-svn: 245700
2015-08-21 12:51:01 +00:00
Alexey Bataev 45bfad51d8 [OPENMP 4.1] Add codegen for 'simdlen' clause.
Add emission of metadata for simd loops in presence of 'simdlen' clause.
If 'simdlen' clause is provided without 'safelen' clause, the vectorizer width for the loop is set to value of 'simdlen' clause + all read/write ops in loop are marked with '!llvm.mem.parallel_loop_access' metadata.
If 'simdlen' clause is provided along with 'safelen' clause, the vectorizer width for the loop is set to value of 'simdlen' clause + all read/write ops in loop are not marked with '!llvm.mem.parallel_loop_access' metadata.
If 'safelen' clause is provided without 'simdlen' clause, the vectorizer width for the loop is set to value of 'safelen' clause + all read/write ops in loop are not marked with '!llvm.mem.parallel_loop_access' metadata.

llvm-svn: 245697
2015-08-21 12:19:04 +00:00
Daniel Jasper 100ffc632a clang-format: Be more conservative about specially indenting blocks in C++.
This is a bit of a step back of what we did in r222531, as there are
some corner cases in C++, where this kind of formatting is really bad.

Example:
Before:
  virtual aaaaaaaaaaaaaaaa(std::function<bool()> IsKindWeWant = [&]() {
    return true;
  }, aaaaa aaaaaaaaa);

After:
  virtual aaaaaaaaaaaaaaaa(std::function<bool()> IsKindWeWant =
                               [&]() { return true; },
                           aaaaa aaaaaaaaa);

The block formatting logic in JavaScript will probably go some other changes,
too, and we'll potentially be able to make the rules more consistent again. For
now, this seems to be the best approach for C++.

llvm-svn: 245694
2015-08-21 11:44:57 +00:00
Alexey Bataev 66b15b505f [OPENMP 4.1] Initial support for 'simdlen' clause.
Add parsing/sema analysis for 'simdlen' clause in simd directives. Also add check that if both 'safelen' and 'simdlen' clauses are specified, the value of 'simdlen' parameter is less than the value of 'safelen' parameter.

llvm-svn: 245692
2015-08-21 11:14:16 +00:00
David Majnemer 9588a95b82 [Sema] Don't crash when diagnosing hack in libstdc++
While working around a bug in certain standard library implementations,
we would try to diagnose the issue so that library implementors would
fix their code.  However, we assumed an entity being initialized was
a non-static data member subobject when other circumstances are
possible.

This fixes PR24526.

llvm-svn: 245675
2015-08-21 06:44:10 +00:00
Alexey Bataev 84cfb1dcde [OPENMP 4.1] Improved codegen for 'uval' qualifier of 'linear' clause.
According to standard the 'uval' modifier declares the address of the original list item to have an invariant value for all iterations of the associated loop(s). Patch improves codegen for this qualifier by removing usage of the original reference variable and replacing by referenced l-value.

llvm-svn: 245674
2015-08-21 06:41:23 +00:00
James Y Knight c4015d3291 Stop treating -static as overriding -fPIC: they are distinct.
For some reason, clang had been treating a command like:
 clang -static -fPIC foo.c
as if it should be compiled without the PIC relocation model.

This was incorrect: -static should be affecting only the linking
model, and -fPIC only the compilation.

This new behavior also matches GCC.

This is a follow-up from a review comment on r245447.

Differential Revision: http://reviews.llvm.org/D12208

llvm-svn: 245667
2015-08-21 04:14:55 +00:00
Richard Trieu 6995de9f1d Fix a few things with -Winfinite-recursion. NFC
Now that -Winfinite-recursion no longer uses recursive calls to before path
analysis, several bits of the code can be improved.  The main changes:

1) Early return when finding a path to the exit block without a recursive call
2) Moving the states vector into checkForRecursiveFunctionCall instead of
   passing it in by reference
3) Change checkForRecursiveFunctionCall to return a bool when the warning
   should be emitted.
4) Use the State vector instead of storing it in the Stack vector.

llvm-svn: 245666
2015-08-21 03:43:09 +00:00
Richard Smith b9fa99649b [modules] When we see a definition of a function for which we already have a
non-visible definition, skip the new definition to avoid ending up with a
function with multiple definitions.

llvm-svn: 245664
2015-08-21 03:04:33 +00:00
Gabor Horvath 717b51c821 [Static Analyzer] Add checker to catch lightweight generics related type errors in Objective-C.
Differential Revision: http://reviews.llvm.org/D11427

llvm-svn: 245646
2015-08-21 00:18:28 +00:00
Yaron Keren 480bc9fc36 Revert the 64bit part of r245084; long double values were not changed by
it as they are already set correctly by X86_64TargetInfo and X86TargetInfo.

llvm-svn: 245620
2015-08-20 21:51:46 +00:00
Evgeniy Stepanov 2e6062cd41 Revert r245344.
That change is causing strange test failures on Fedora 22 (PR24503),
and it does not have any effect with Gold linker anyway (PR15823,
https://sourceware.org/bugzilla/show_bug.cgi?id=18859).

llvm-svn: 245619
2015-08-20 21:47:16 +00:00
Yaron Keren 4da1a3754a Revert the 32bit part of r245084; mingw values were correct before it.
llvm-svn: 245618
2015-08-20 21:36:14 +00:00
Aaron Ballman 6569387327 Do not crash when static analysis encounters a FunctionDecl that has a delayed template parse of its body.
llvm-svn: 245616
2015-08-20 21:27:35 +00:00
Richard Smith 419bb33b0b PR24483: Delete some dead/incorrect code that triggered assertions.
llvm-svn: 245609
2015-08-20 20:45:25 +00:00
Ahmed Bougacha 5e354cb547 [Headers][X86] Use __builtin_shufflevector in AVX2 broadcasts.
This lets us optimize them better. We agreed to remove the intrinsics,
instead of combining them later, as, at -O0, we generate the expected
instructions. Plus, it's a nice cleanup.

Differential Revision: http://reviews.llvm.org/D10556

llvm-svn: 245605
2015-08-20 20:27:21 +00:00
Douglas Katzman 38857551b5 [Sparc] Add '-EL' when invoking gcc to link little-endian binaries.
Differential Revision: http://reviews.llvm.org/D12201

llvm-svn: 245595
2015-08-20 18:32:26 +00:00
Artem Belevich 7230a22d5e Revert r245496 "[CUDA] Add appropriate host/device attribute to builtins."
It's breaking internal test.

llvm-svn: 245592
2015-08-20 18:28:56 +00:00
Aaron Ballman 2ec4928219 Silence a "not all control paths return a value" warning; NFC.
llvm-svn: 245562
2015-08-20 13:31:16 +00:00
Olivier Goffart 66be61ad4f Fix crash with two typos in the arguments of a function
The problem is that the arguments are of TheCall are reset later
to the ones in Args, making TypoExpr put back. Some TypoExpr that have
already  been diagnosed and will assert later in Sema::getTypoExprState

llvm-svn: 245560
2015-08-20 13:11:14 +00:00
Alexey Bataev 1185e193a4 [OPENMP 4.1] Allow to use 'uval' and 'ref' modifiers for reference types only.
Standard allows to use 'uval' and 'ref' modifiers in 'linear' clause for variables with reference types only. Added check for it and modified test.

llvm-svn: 245556
2015-08-20 12:15:57 +00:00
Alexey Bataev 182227bd5b [OPENMP 4.1] Initial support for modifiers in 'linear' clause.
OpenMP 4.1 adds 3 optional modifiers to 'linear' clause.
Format of 'linear' clause has changed to:
```
linear(linear-list[ : linear-step])
```
where linear-list is one of the following
```
list
modifier(list)
```
where modifier is one of the following:
```
 ref (C++)
 val (C/C++)
 uval (C++)
```
Patch adds parsing and sema analysis for these modifiers.

llvm-svn: 245550
2015-08-20 10:54:39 +00:00
John McCall 0d461693b6 Fix the layout of bitfields in ms_struct unions: their
alignment is ignored, and they always allocate a complete
storage unit.

Also, change the dumping of AST record layouts: use the more
readable C++-style dumping even in C, include bitfield offset
information in the dump, and don't print sizeof/alignof
information for fields of record type, since we don't do so
for bases or other kinds of field.

rdar://22275433

llvm-svn: 245514
2015-08-19 22:42:36 +00:00
Richard Trieu 1cd076eb34 Fix -Wlogical-not-parentheses to work better with C code.
Remove the assumption of a Boolean type by checking if an expression is known
to have a boolean value.  Disable warning in two other tests.

llvm-svn: 245507
2015-08-19 21:33:54 +00:00
Richard Smith 1d0f1996df [modules] Don't needlessly bounce through Sema when updating exception specifications.
llvm-svn: 245501
2015-08-19 21:09:32 +00:00
Richard Smith 7747ce2260 Internal-linkage variables with constant-evaluatable initializers do not need to be emitted. (Also reduces the set of variables that need to be eagerly deserialized when using PCH / modules.)
llvm-svn: 245497
2015-08-19 20:49:38 +00:00
Artem Belevich 39259ffc65 [CUDA] Add appropriate host/device attribute to builtins.
Differential Revision: http://reviews.llvm.org/D12122

llvm-svn: 245496
2015-08-19 20:48:20 +00:00
Piotr Padlewski 1d02f681a9 Generating available_externally vtables bugfix
Bugfix revealed in r245264.

http://reviews.llvm.org/D12128

llvm-svn: 245489
2015-08-19 20:09:09 +00:00
Yaron Keren 7890a01263 According to i686 ABI, long double size on x86 is 12 bytes not 16 bytes.
See
 https://gcc.gnu.org/onlinedocs/gcc-3.2/gcc/i386-and-x86-64-Options.html

llvm-svn: 245459
2015-08-19 17:02:32 +00:00
James Y Knight 5bdf7ab0cf Properly pass through the PIC mode to the integrated assembler when
doing assembly-only, and unify the Driver's PIC argument parsing.

On a few architectures, parsing of assembly files annoyingly depends
on whether PIC is enabled or not. This was handled for external 'as'
already (passing -KPIC), but was missed for calls to the standalone
internal assembler.

The integrated-as.s test needed to be modified to not expect
-fsanitize=address to be unused, as now fsanitize *IS* used for
assembly, since -fsanitize=memory can sometimes imply -fPIE, which the
assembler needs to know (gack!!).

Differential Revision: http://reviews.llvm.org/D11845

llvm-svn: 245447
2015-08-19 15:12:02 +00:00
Vladimir Sukharev 457d34193e [ARM] Proper generic cpus handling
"generic" cpu was wrongly handled as exact real CPU name of ARMv8.1A architecture.

This has been fixed, now it is abstract name, suitable for any arch.

Reviewers: rengolin

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D11640

llvm-svn: 245445
2015-08-19 14:50:18 +00:00
Alexey Bataev c7e8435bef [OPENMP] Link libomp.lib on Windows
Adds libomp.lib for -fopenmp=libomp and libiomp5md.lib for -fopenmp=libiomp5 on Windows
Differential Revision: http://reviews.llvm.org/D11932

llvm-svn: 245414
2015-08-19 04:49:01 +00:00
Richard Smith c52efa7d40 [modules] Don't eagerly deserialize so many ImportDecls. CodeGen basically ignores ImportDecls imported from modules, so only eagerly deserialize the ones from a PCH / preamble.
llvm-svn: 245406
2015-08-19 02:30:28 +00:00
Eric Christopher 72be1c1b64 Rename getDefaultFeatures -> initDefaultFeatures and update comment
with the current behavior as the name seems to match what's going on.

llvm-svn: 245405
2015-08-19 02:24:21 +00:00
Davide Italiano 992196220a [SemaExpr] Re-enable missing assertion.
This has been disabled for a long time, but:
1) Initializers work (and apparently they're re reason why this was disabled).
2) various tests happen to hit this code path and the invariant seems to be
always verified.

Differential Revision:	http://reviews.llvm.org/D12110
Reviewed by:	rsmith

llvm-svn: 245404
2015-08-19 02:21:12 +00:00
George Burgess IV bdb5b2687a Make __builtin_object_size always answer correctly
__builtin_object_size would return incorrect answers for many uses where
type=3. This fixes the inaccuracy by making us emit 0 instead of LLVM's
objectsize intrinsic.

Additionally, there are many cases where we would emit suboptimal (but
correct) answers, such as when arrays are involved. This patch fixes
some of these cases (please see new tests in test/CodeGen/object-size.c
for specifics on which cases are improved)

Resubmit of r245323 with PR24493 fixed.
Patch mostly by Richard Smith.
Differential Revision: http://reviews.llvm.org/D12000
This fixes PR15212.

llvm-svn: 245403
2015-08-19 02:19:07 +00:00
David Blaikie 8f2a7feec8 unique_ptrify CXXBasePaths::DeclsFound & remove the then-unnecessary user-defined dtor
Maybe this and the NumDeclsFound member should just be a std::vector
instead. (it could be a std::dynarray, but that missed standardization)

llvm-svn: 245392
2015-08-18 23:56:00 +00:00
Richard Smith 386bb073d2 [modules] Fix HeaderFileInfo serialization to store all the known owning modules for a header, not just the current favourite.
llvm-svn: 245390
2015-08-18 23:42:23 +00:00
David Blaikie 7e70d6803d Devirtualize EHScopeStack::Cleanup's dtor because it's never destroyed polymorphically
llvm-svn: 245378
2015-08-18 22:40:54 +00:00
David Blaikie 50ccaa653a Fix for MSVC
llvm-svn: 245368
2015-08-18 22:10:49 +00:00
David Blaikie fb2b796ecc Wdeprecated: Support movability of EHScopeStack::Cleanup objects as they are move constructed in ConditionalCleanup::restore
llvm-svn: 245367
2015-08-18 22:09:28 +00:00
Richard Smith 080056ba5a Range-based-for-convert some loops in ASTWriter. No functionality change intended.
llvm-svn: 245361
2015-08-18 21:53:42 +00:00
Richard Smith 293534b1a5 Initialize the AST consumer as soon as we have both an ASTConsumer and an
ASTContext. Fixes some cases where we could previously initialize the AST
consumer more than once.

llvm-svn: 245346
2015-08-18 20:39:29 +00:00
Evgeniy Stepanov 775d905644 [sanitizer] Add -lutil to static runtime link flags.
This is needed to prevent breakage of -Wl,-as-needed link when
interceptors for functions in libutil are added. See PR15823.

llvm-svn: 245344
2015-08-18 20:36:11 +00:00
Nico Weber 19999b4816 Revert r245323, it caused PR24493.
llvm-svn: 245342
2015-08-18 20:32:55 +00:00
Aaron Ballman 11825f2592 Add AST narrowing matchers for inline and anonymous namespaces. Since the inline keyword can also be specified on a FunctionDecl, this is a polymorphic matcher.
llvm-svn: 245337
2015-08-18 19:55:20 +00:00
George Burgess IV 232c76213d Make __builtin_object_size always answer correctly
__builtin_object_size would return incorrect answers for many uses where
type=3. This fixes the inaccuracy by making us emit 0 instead of LLVM's
objectsize intrinsic.

Additionally, there are many cases where we would emit suboptimal (but
correct) answers, such as when arrays are involved. This patch fixes
some of these cases (please see new tests in test/CodeGen/object-size.c
for specifics on which cases are improved)

Patch mostly by Richard Smith.
Differential Revision: http://reviews.llvm.org/D12000
This fixes PR15212.

llvm-svn: 245323
2015-08-18 18:18:27 +00:00
Benjamin Kramer e1c08b0bfe [TreeTransform] Simplify code. No functionality change.
llvm-svn: 245271
2015-08-18 08:10:39 +00:00
Alexey Bataev bd9fec1eaa [OPENMP 4.1] Allow variables with reference types in private clauses.
OpenMP 4.1 allows to use variables with reference types in all private clauses (private, firstprivate, lastprivate, linear etc.). Patch allows to use such variables and fixes codegen for linear variables with reference types.

llvm-svn: 245268
2015-08-18 06:47:21 +00:00
Justin Bogner 3c32c83daa Revert "Generating assumption loads of vptr after ctor call (fixed)"
Bootstrap bots were failing:

http://lab.llvm.org:8080/green/job/clang-stage2-configure-Rlto_build/6382/
http://bb.pgr.jp/builders/clang-3stage-i686-linux/builds/2969

This reverts r245264.

llvm-svn: 245267
2015-08-18 05:40:20 +00:00
Piotr Padlewski bc7497abbb Generating assumption loads of vptr after ctor call (fixed)
Generating call assume(icmp %vtable, %global_vtable) after constructor
call for devirtualization purposes.

For more info go to:
http://lists.llvm.org/pipermail/cfe-dev/2015-July/044227.html

Edit:
Fixed version because of PR24479.

http://reviews.llvm.org/D11859

llvm-svn: 245264
2015-08-18 03:52:00 +00:00
Hans Wennborg 386e442d1d Revert r245257 "Generating assumption loads of vptr after ctor call"
It caused PR24479

llvm-svn: 245260
2015-08-18 00:17:58 +00:00
Piotr Padlewski a3f6f9477b Generating assumption loads of vptr after ctor call
Generating call assume(icmp %vtable, %global_vtable) after constructor
call for devirtualization purposes.

For more info go to:
http://lists.llvm.org/pipermail/cfe-dev/2015-July/044227.html

http://reviews.llvm.org/D11859

llvm-svn: 245257
2015-08-17 23:33:49 +00:00
Eric Christopher 15c2f936de Remove dead code, there's no need for an override that just duplicates
the default behavior.

llvm-svn: 245251
2015-08-17 22:22:28 +00:00
Richard Smith 6dc8ae10aa [modules] When parsing the base specifiers of a parse-merged class, the current
context is the class itself but lookups should be performed starting with the
lookup parent of the class (class and base members don't shadow types from the
surrounding context because they have not been declared yet).

llvm-svn: 245236
2015-08-17 20:24:17 +00:00
Sean Silva 8b7c0398b6 [modules] PR20507: Avoid silent textual inclusion.
Summary:
If a module was unavailable (either a missing requirement on the module
being imported, or a missing file anywhere in the top-level module (and
not dominated by an unsatisfied `requires`)), we would silently treat
inclusions as textual. This would cause all manner of crazy and
confusing errors (and would also silently "work" sometimes, making the
problem difficult to track down).

I'm really not a fan of the `M->isAvailable(getLangOpts(), getTargetInfo(),
Requirement, MissingHeader)` function; it seems to do too many things at
once, but for now I've done things in a sort of awkward way.

The changes to test/Modules/Inputs/declare-use/module.map
were necessitated because the thing that was meant to be tested there
(introduced in r197805) was predicated on silently falling back to textual
inclusion, which we no longer do.

The changes to test/Modules/Inputs/macro-reexport/module.modulemap
are just an overlooked missing header that seems to have been missing since
this code was committed (r213922), which is now caught.

Reviewers: rsmith, benlangmuir, djasper

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D10423

llvm-svn: 245228
2015-08-17 16:39:30 +00:00
Alexander Kornienko 3474b55858 [clang-tidy] Make NumOccurrenceFlag for SourcePaths configurable.
Added an additional ctor that takes a NumOccurrenceFlag parameter for the
SourcePaths option. This frees applications from always having to pass at least
one source file, e.g., -list-checks.

http://reviews.llvm.org/D12069

Patch by Don Hinton!

llvm-svn: 245204
2015-08-17 10:01:42 +00:00
Richard Smith e75ee0f0c8 [modules] When explicitly building a module file, don't include timestamps in
the produced pcm file for stable file creation across distributed build
systems.

llvm-svn: 245199
2015-08-17 07:13:32 +00:00
James Y Knight 2db38f33f3 Tiny cleanup: move some Triple variables up to the top of the
function, and remove a duplicate var.

llvm-svn: 245154
2015-08-15 03:45:25 +00:00
David Majnemer e888a2f655 [MS ABI] Switch catchpad/cleanuppad to use tokens
llvm-svn: 245153
2015-08-15 03:21:08 +00:00
NAKAMURA Takumi a0d39dd80a clangStaticAnalyzerCheckers: Update libdesp.
llvm-svn: 245145
2015-08-15 01:56:49 +00:00
Hans Wennborg 99000c24c9 Delay emitting members of dllexport classes until the class is fully parsed (PR23542)
This enables Clang to correctly handle code such as:

  struct __declspec(dllexport) S {
    int x = 42;
  };

where it would otherwise error due to trying to generate the default
constructor before the in-class initializer for x has been parsed.

Differential Revision: http://reviews.llvm.org/D11850

llvm-svn: 245139
2015-08-15 01:18:16 +00:00
Richard Smith 3938f0c728 [modules] Stop dropping 'module.timestamp' files into the current directory
when building with implicit modules disabled.

llvm-svn: 245136
2015-08-15 00:34:15 +00:00
Nathan Wilson b20ab9245a [CONCEPTS] Add diagnostic; invalid tag when concept specified
Summary: Adding check to emit diagnostic for invalid tag when concept is specified and associated tests.

Reviewers: rsmith, hubert.reinterpretcast, fraggamuffin, faisalv, aaron.ballman

Subscribers: aaron.ballman, cfe-commits

Differential Revision: http://reviews.llvm.org/D11916

llvm-svn: 245123
2015-08-14 23:19:32 +00:00
Anna Zaks e5d74caf2a [analyzer] Add checkers for OS X / iOS localizability issues
Add checkers that detect code-level localizability issues for OS X / iOS:
  - A path sensitive checker that warns about uses of non-localized
    NSStrings passed to UI methods expecting localized strings.
  - A syntax checker that warns against not including a comment in
    NSLocalizedString macros.

A patch by Kulpreet Chilana!

(This is the second attempt with the compilation issue on Windows and
the random test failures resolved.)

llvm-svn: 245093
2015-08-14 20:22:22 +00:00
Martell Malone b8a3fe7a53 WindowsX86: long double is x87DoubleExtended on mingw
Summary:
    long double on x86 mingw is 80bits and is aligned to 16bytes

	Fixes:
    https://llvm.org/bugs/show_bug.cgi?id=24398

    Reviewers: rnk

    Subscribers: cfe-commits

    Differential Revision: http://reviews.llvm.org/D12037

llvm-svn: 245084
2015-08-14 19:05:56 +00:00
Martell Malone 7ccda3c38b Windows ARM: ignore calling conventions as described on MSDN
Summary:
MSDN says that fastcall, stdcall, thiscall, and vectorcall are all
accepted but ignored on ARM and X64.
https://msdn.microsoft.com/en-us/library/984x0h58.aspx

MSDN also says cdecl is also accepted and typically ignored
This patch brings ARM in line with how we ignore them for X64

Reviewers: rnk

Subscribers: compnerd, cfe-commits

Differential Revision: http://reviews.llvm.org/D12034

llvm-svn: 245076
2015-08-14 18:00:09 +00:00
Douglas Katzman cb07d15b4c Represent 2 parallel string arrays as one string[][2] array.
Differential Revision: http://reviews.llvm.org/D11991

llvm-svn: 245063
2015-08-14 15:52:12 +00:00
David Majnemer e694f3e847 [ASTContext] Call APValue destructors for MaterializedTemporaryValues
Hopefully this makes the sanitizer build bot happy.

llvm-svn: 245054
2015-08-14 14:43:50 +00:00
Davide Italiano da8a3b903b [Sema] main can't be declared as global variable, in C++.
So, we now reject that. We also warn for any external-linkage global
variable named main in C, because it results in undefined behavior.

PR:	  24309
Differential Revision:	http://reviews.llvm.org/D11658
Reviewed by:	rsmith

llvm-svn: 245051
2015-08-14 14:13:29 +00:00
Daniel Jasper d788457da5 clang-format: Don't remove space between #elif and parentheses.
Before:
  #elif(AAAA && BBBB)

After:
  #elif (AAAA && BBBB)

llvm-svn: 245043
2015-08-14 12:44:06 +00:00
Alexey Bataev b08f89ffc1 [OPENMP] Fix for http://llvm.org/PR24371: Assert failure compiling blender 2.75.
blender uses statements expression in condition of the loop under control of the '#pragma omp parallel for'. This condition is used several times in different expressions required for codegen of the loop directive. If there are some variables defined in statement expression, it fires an assert during codegen because of redefinition of the same variables.
We have to rebuild several expression to be sure that all variables are unique.

llvm-svn: 245041
2015-08-14 12:25:37 +00:00
Manuel Klimek 54042e743c Add structed way to express command line options in the compilation database.
Currently, arguments are passed via the string attribute 'command',
assuming a shell-escaped / quoted command line to extract the original
arguments. This works well enough on Unix systems, but turns out to be
problematic for Windows tools to generate.

This CL adds a new attribute 'arguments', an array of strings, which
specifies the exact command line arguments. If 'arguments' is available
in the compilation database, it is preferred to 'commands'.

Currently there is no plan to retire 'commands': there are enough
different use cases where users want to create their own mechanism for
creating compilation databases, that it doesn't make sense to force them
all to implement shell command line parsing.

Patch by Daniel Dilts.

llvm-svn: 245036
2015-08-14 09:55:36 +00:00
Richard Smith fb1e7f7d1a [modules] Add an experimental -cc1 feature to embed the contents of an input
file in the .pcm files. This allows a smaller set of files to be sent to a
remote build worker when building with explicit modules (for instance, module
map files need not be sent along with the corresponding precompiled modules).

This doesn't actually make the embedded files visible to header search, so
it's not useful as a packaging format for public header files.

llvm-svn: 245028
2015-08-14 05:02:58 +00:00
David Blaikie 86d8cf3502 unique_ptrify ConsumedBlockInfo analysis to make it move assignable
ConsumedBlockInfo objects were move assigned, but only in a state where
the dtor was a no-op anyway. Subtle and easily could've happened in ways
that wouldn't've been safe - so this change makes it safe no matter what
state the ConsumedBlockInfo object is in.

llvm-svn: 244998
2015-08-14 01:26:19 +00:00
David Blaikie 9255161665 Wdeprecated: ByrefHelpers are copy constructed by the ::buildByrefHelpers helper, make sure they're safely copyable
Make the copy/move ctors protected and defaulted in the base, make the
derived classes final to avoid exposing any slicing-prone APIs.

Also, while I'm here, simplify the use of buildByrefHelpers by taking
the parameter by value instead of non-const ref. None of the callers
care aobut observing the state after the call.

llvm-svn: 244990
2015-08-13 23:53:09 +00:00
David Majnemer 2dcef9e0a4 Avoid iteration invalidation issues around MaterializedTemporaryExpr
We risk iterator invalidation issues if we use a DenseMap to hold the
backing storage for an APValue.  Instead, BumpPtrAllocate them and
use APValue * as our DenseMap value.

Also, don't assume that MaterializedGlobalTemporaryMap won't regrow
between when we initially perform a lookup and later on when we actually
try to insert into it.

This fixes PR24289.

Differential Revision: http://reviews.llvm.org/D11629

llvm-svn: 244989
2015-08-13 23:50:15 +00:00
Richard Smith f7b41371d9 [modules] When writing a module file built with -fmodule-map-file-home-is-cwd,
via a module map found by -fmodule-map-file=, the home directory of the module
is the current working directory, even if that's a different directory on
reload.

llvm-svn: 244988
2015-08-13 23:47:44 +00:00
David Blaikie 2038b54eae Wdeprecated: Make the SecKeychainBugVisitor copyable (for the clone support in the CRTP base) my removing the user-declared dtor
The implicit dtor is just as good, and avoid suppressing implicit
copy/move ops.

llvm-svn: 244981
2015-08-13 23:09:18 +00:00
David Blaikie 6951e3e406 Wdeprecated: BugReporterVisitors are copied for cloning (BugReporterVisitorImpl), make sure such copies are safe
Make the copy/move ctors defaulted in the base class and make the
derived classes final to avoid any intermediate hierarchy slicing if
these types were further derived.

llvm-svn: 244979
2015-08-13 22:58:37 +00:00
David Blaikie 903c29347a Wdeprecated: CollectReachableSymbolsCallback are move constructed/returned by value, so make sure they're copy/moveable
(return by value is in ExprEngine::processPointerEscapedOnBind and any
other call to the scanReachableSymbols function template used there)

Protect the special members in the base class to avoid slicing, and make
derived classes final so these special members don't accidentally become
public on an intermediate base which would open up the possibility of
slicing again.

llvm-svn: 244975
2015-08-13 22:50:09 +00:00
David Blaikie 01cd46abae Wdeprecated: RegionBindingsRef are copy constructed, make sure that's safe by removing the unnecessary user-declared copy assignment operator
The user-defined copy assignment looks like it was working around the
presence of a reference member (that probably doesn't change in the copy
assignment cases present in the program). Rather than continuing this - just
change the reference to a pointer and let all the special members be
defined implicitly.

llvm-svn: 244974
2015-08-13 22:33:24 +00:00
David Blaikie 55477463d6 Wdeprecated: PathPieces are copied, make them safely implicitly copyable by removing the unnecessary user declared dtor.
llvm-svn: 244973
2015-08-13 22:23:53 +00:00
David Blaikie 210ea0b31a Wdeprecated: StoredDiagnostics are stored in a SmallVector, so make sure they're copy/movable
Removing the no-op dtor makes these objects safely implicitly
copyable/movable/etc.

(& tidy up the ctor, while I'm here)

llvm-svn: 244971
2015-08-13 22:20:14 +00:00
David Blaikie c1334cc17d Wdeprecated: Make BumpVectorContext movable
Turns out the one place that relied on the implicit copy ctor was safe
because it created an object in a state where the dtor was a no-op, but
that's more luck that good management.

Sure up the API by defining move construction and using it, which
implicitly disallows the unreliable copy operations.

llvm-svn: 244968
2015-08-13 22:12:21 +00:00
Brad Smith 56495d5b1f Removed one too many braces.
llvm-svn: 244962
2015-08-13 22:00:53 +00:00
Brad Smith 738591194f [SPARC] Fix types of size_t, intptr_t, and ptrdiff_t on OpenBSD.
llvm-svn: 244961
2015-08-13 21:45:57 +00:00
Eric Christopher b64963ecbc Fix some coding standard issues and delete a dead conditional.
llvm-svn: 244959
2015-08-13 21:34:35 +00:00
David Blaikie 9ae479c521 Wdeprecated: LambdaScopeInfos are copied in TreeTransform, so make sure they're copyable.
Partly addressed by r244843, but the explicit dtor in LambdaScopeInfo
was still thwarting the implicit copy ctor. This does remove the key
function from LambdaScopeInfo unfortunately, but it seems neater than
having to explicitly default any special members LambdaScopeInfo needs.

llvm-svn: 244957
2015-08-13 21:23:08 +00:00
Naomi Musgrave e50cb9b9c8 Fix previous commit: poison only class members, simpler tests
Summary: Poisoning applied to only class members, and before dtors for base class invoked

Implement poisoning of only class members in dtor, as opposed to also
poisoning fields inherited from base classes. Members are poisoned
only once, by the last dtor for a class. Skip poisoning if class has
no fields.
Verify emitted code for derived class with virtual destructor sanitizes
its members only once.
Removed patch file containing extraneous changes.

Reviewers: eugenis, kcc

Differential Revision: http://reviews.llvm.org/D11951


Simplified test cases for use-after-dtor

Summary: Simplified test cases to focus on one feature at time.
Tests updated to align with new emission order for sanitizing
callback.

Reviewers: eugenis, kcc

Differential Revision: http://reviews.llvm.org/D12003

llvm-svn: 244933
2015-08-13 18:35:11 +00:00
Richard Smith be9b6c75c3 [modules] For explicit module file dependencies, only list direct dependency module files.
llvm-svn: 244931
2015-08-13 18:30:25 +00:00
Yaron Keren 556b21aa10 Remove and forbid raw_svector_ostream::flush() calls.
After r244870 flush() will only compare two null pointers and return,
doing nothing but wasting run time. The call is not required any more
as the stream and its SmallString are always in sync.

Thanks to David Blaikie for reviewing.

llvm-svn: 244928
2015-08-13 18:12:56 +00:00
Reid Kleckner 90fd1db21b Try to fix the build after r244923
llvm-svn: 244926
2015-08-13 18:10:34 +00:00
Richard Smith 216a3bd70d [modules] Change the way we deal with .d output for explicitly-specified module
files: include the .pcm file itself in the .d output, rather than including its
own input files. Other forms of module file continue to be transparent for .d
output.

Arguably, the input files for the .pcm file are still inputs to the
compilation, but that's unnecessary for make-like build systems (where the
mtime of the .pcm file is sufficient) and harmful for smarter build systems
that know about module files and want to track only the local dependencies.

llvm-svn: 244923
2015-08-13 17:57:10 +00:00
Reid Kleckner 6cf4a6ba9b Turn off __has_feature(cxx_rtti) when -fno-rtti-data is present
-fno-rtti-data makes it so that vtables emitted in the current TU lack
RTTI data. This means that dynamic_cast usually fails at runtime. Users
of the existing cxx_rtti feature expect all of RTTI to work, not just
some of it.

Chromium bug for context: http://crbug.com/518191

llvm-svn: 244922
2015-08-13 17:56:49 +00:00
Ben Langmuir 41f81994fe Attempt to fix build after r244912
Some compilers were less happy about converting a lambda to a comparator
function for array_pod_sort.

llvm-svn: 244917
2015-08-13 17:30:07 +00:00
Ben Langmuir 7ff29148ac [Modules] Add Darwin-specific compatibility module map parsing hacks
This preserves backwards compatibility for two hacks in the Darwin
system module map files:

1. The use of 'requires excluded' to make headers non-modular, which
should really be mapped to 'textual' now that we have this feature.

2. Silently removes a bogus cplusplus requirement from IOKit.avc.

Once we start diagnosing missing requirements and headers on
auto-imports these would have broken compatibility with existing Darwin
SDKs.

llvm-svn: 244912
2015-08-13 17:13:33 +00:00
Martell Malone 1bc12bbea6 Driver: Fix include directories when not using libgcc under mingw
Summary:
When we want to use mingw-w64 and clang with compiler-rt we should not
need to have libgcc installed. This fixes finding includes when libgcc
is not installed

Reviewers: yaron.keren

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D11808

llvm-svn: 244902
2015-08-13 15:41:04 +00:00
Daniel Jasper 033181bcd2 clang-format: Inside decltype(), there is an expression.
Before:
  decltype(a* b) F();

After:
  decltype(a * b) F();

llvm-svn: 244891
2015-08-13 13:43:51 +00:00
Daniel Jasper 5eaa009e57 clang-format: Fix incorrect lambda-detection.
Before:
  [ a, a ]() -> a<1>{};

After:
  [a, a]() -> a<1> {};

llvm-svn: 244890
2015-08-13 13:37:08 +00:00
Yaron Keren a3668a3fcd Remove raw_svector_ostream::resync and users. It's no-op after r244870.
llvm-svn: 244888
2015-08-13 12:42:25 +00:00
Yaron Keren 2ed4060ab6 Remove superfluous private:, TypeCache is private by default.
llvm-svn: 244871
2015-08-13 07:12:03 +00:00
Ivan Krasin 1193f2cbc0 Add sanitizer blacklists to the rules generated with -M/-MM/-MD/-MMD.
Summary:
Clang sanitizers, such as AddressSanitizer, ThreadSanitizer, MemorySanitizer,
Control Flow Integrity and others, use blacklists to specify which types / functions
should not be instrumented to avoid false positives or suppress known failures.

This change adds the blacklist filenames to the list of dependencies of the rules,
generated with -M/-MM/-MD/-MMD. This lets CMake/Ninja recognize that certain
C/C++/ObjC files need to be recompiled (if a blacklist is updated).

Reviewers: pcc

Subscribers: rsmith, honggyu.kim, pcc, cfe-commits

Differential Revision: http://reviews.llvm.org/D11968

llvm-svn: 244867
2015-08-13 04:04:37 +00:00
Richard Smith 03a06dd13c Add SourceManager::dump() to dump the current set of SLocEntries.
llvm-svn: 244852
2015-08-13 00:45:11 +00:00
David Blaikie d7057d9e52 Wdeprecated: ApplyDebugLocation is returned by value yet if it is ever copied (rather than RVO'd) that would be broken, make it movable instead
llvm-svn: 244838
2015-08-12 23:49:57 +00:00
David Blaikie 01f4209631 Wdeprecated: CGBuilderInserter is copy constructed in some contexts - remove the unnecessarily disabling copy assignment to enable this
The object has very simple state, there seems no reason to disallow all
the usual value semantic operations.

llvm-svn: 244831
2015-08-12 23:16:55 +00:00
David Blaikie 737260662b -Wdeprecated: Job objects are stored in a vector yet are not really copyable, make them movable instead
llvm-svn: 244829
2015-08-12 23:09:24 +00:00
David Blaikie 8533e96e42 -Wdeprecated: SavedInstanceContext is returned by value but isn't really copyable, but it can be made movable
llvm-svn: 244826
2015-08-12 22:58:10 +00:00
Richard Smith 78d81ecfc3 [modules] If loading a .pcm file would cause us to run out of source locations, attempt to fail more gracefully. (No test; this requires >= 4GB of preprocessed input...)
llvm-svn: 244822
2015-08-12 22:25:24 +00:00
Naomi Musgrave 522168f7b8 Revert "Implement poisoning of only class members in dtor, as opposed to also poisoning fields inherited from base classes."
This reverts commit 8dbbf3578a9a5d063232b59e558e5fe46e2cd42c.
Rolled back due to buildbot failures on 'ninja check-clang'.

llvm-svn: 244820
2015-08-12 22:07:24 +00:00
Naomi Musgrave 9bd83fd465 Implement poisoning of only class members in dtor, as opposed to also poisoning fields inherited from base classes.
Verify emitted code for derived class with virtual destructor sanitizes its members only once.
Changed emission order for dtor callback, so only the last dtor for a class emits the sanitizing callback, while ensuring that class members are poisoned before base class destructors are invoked.
Skip poisoning of members, if class has no fields.
Removed patch file containing extraneous changes.

Summary: Poisoning applied to only class members, and before dtors for base class invoked

Reviewers: eugenis, kcc

Differential Revision: http://reviews.llvm.org/D11951

llvm-svn: 244819
2015-08-12 21:37:40 +00:00
Aaron Ballman 7596bcf726 Switching from an explicit loop to DeleteContainerSeconds; NFC.
llvm-svn: 244802
2015-08-12 20:05:18 +00:00
Aaron Ballman 001f168e94 RangRangify some more for loops; NFC.
llvm-svn: 244792
2015-08-12 19:00:39 +00:00
Douglas Katzman 15a63ed26e Don't compare getArchName() to "tce" as a string. NFC.
llvm-svn: 244791
2015-08-12 18:36:12 +00:00
Richard Trieu ecd36ee80b Stop printing macro backtraces that don't help diagnostics.
When displaying the macro backtrace, ignore some of the backtraces that do not
provide extra information to the diagnostic.  Typically, if the problem is
entirely contained within a macro argument, the macro expansion is often not
needed.  Also take into account SourceRange's attached to the diagnostic when
selecting which backtraces to ignore.  Two previous test cases have also been
updated.

Patch by Zhengkai Wu, with minor formatting fixes.

Differential Revision: http://reviews.llvm.org/D11778

llvm-svn: 244788
2015-08-12 18:24:59 +00:00
Aaron Ballman b226d3d0da Rangify some for loops; NFC.
llvm-svn: 244749
2015-08-12 13:38:59 +00:00
Alexey Bataev 4652e4baaf [OPENMP] Fix for http://llvm.org/PR24430: clang hangs on invalid input with openmp directive
Add parsing of openmp directives inside structs/unions in C mode.

llvm-svn: 244719
2015-08-12 07:10:54 +00:00
Richard Smith dd55b95fb2 [modules] Fix thread safety analysis to cope with merging of FieldDecls across modules.
llvm-svn: 244714
2015-08-12 02:17:52 +00:00
Eric Christopher 83dfb00fd7 Untabify.
llvm-svn: 244695
2015-08-11 23:17:31 +00:00
Richard Smith 9c9173dcc8 [modules] When instantiating the contents of an imported CXXRecordDecl, we can
emit lexical contents for a declaration for another module. Track which module
those contents came from, and ensure that we only grab the lexical contents
from a single such instantiation.

llvm-svn: 244682
2015-08-11 22:00:24 +00:00
Petar Jovanovic 2e0551f8d2 [MIPS] Use arch values for lock-free atomic operations
Let NaClMips32ELTargetInfo inherit arch values for maximum width lock-free
atomic operations.

Differential Revision: http://reviews.llvm.org/D11949

llvm-svn: 244675
2015-08-11 21:27:39 +00:00
Richard Smith 2317a3e18e Add an assert to catch lexical decl deserialization bugs.
llvm-svn: 244671
2015-08-11 21:21:20 +00:00
Aaron Ballman 6f6d0b6c5a Add a polymorphic AST matcher for testing whether a constructor or a conversion declaration is marked as explicit or not.
llvm-svn: 244666
2015-08-11 21:09:52 +00:00
Aaron Ballman ed455d4062 Add an AST matcher to match member intializers of a CXXCtorInitializer.
llvm-svn: 244662
2015-08-11 20:42:00 +00:00
Daniel Jasper a804d1ec80 clang-format: Make SpaceBeforeParens work with overloaded operators.
Patch by Jon Chesterfield, thank you!

llvm-svn: 244660
2015-08-11 20:32:24 +00:00
Daniel Jasper 3b0f87d289 Revert "[CUDA] Add implicit __attribute__((used)) to all __global__ functions."
This is breaking internal test. I'll provide a reproduction.

llvm-svn: 244583
2015-08-11 11:02:09 +00:00