Commit Graph

57621 Commits

Author SHA1 Message Date
Daniel Jasper e99c72fc2e clang-format: Fix merging of _T macros.
NewlinesBefore and HasUnescapedNewline were not properly propagated
leading to llvm.org/PR23032.

llvm-svn: 233276
2015-03-26 14:47:35 +00:00
Ed Schouten 3c3e58c42d Let Clang invoke CloudABI's linker.
Now that CloudABI's target information and header search logic for Clang
has been submitted, the only thing that remains to be done is adding
support for CloudABI's linker.

CloudABI uses Binutils ld, although there is some work to use lld
instead. This means that this code is largely based on what we use on
FreeBSD. There are some exceptions, however:

- Only static linking is performed. CloudABI does not support any
  dynamically linked executables.
- CloudABI uses compiler-rt, libc++ and libc++abi unconditionally. Link
  in these libraries instead of using libgcc_s, libstdc++, etc.
- We must ensure that the .eh_frame_hdr is present to make C++
  exceptions work properly.


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

llvm-svn: 233269
2015-03-26 11:13:44 +00:00
Chandler Carruth 52cee4dad2 [Modules] Preserve source order for the map of late parsed templates.
Clang was inserting these into a dense map. While it never iterated the
dense map during normal compilation, it did when emitting a module. Fix
this by using a standard MapVector to preserve the order in which we
encounter the late parsed templates.

I suspect this still isn't ideal, as we don't seem to remove things from
this map even when we mark the templates as no longer late parsed. But
I don't know enough about this particular extension to craft a nice,
subtle test case covering this. I've managed to get the stress test to
at least do some late parsing and demonstrate the core problem here.
This patch fixes the test and provides deterministic behavior which is
a strict improvement over the prior state.

I've cleaned up some of the code here as well to be explicit about
inserting when that is what is actually going on.

llvm-svn: 233264
2015-03-26 09:08:15 +00:00
Chandler Carruth 70a1369b34 [Modules] Add some more fun code to my modules stress test, this time
templates. Turns out all of this works correctly (so far). But it should
cover more code paths and will let me test some things that don't
actually work next.

llvm-svn: 233263
2015-03-26 08:49:55 +00:00
Chandler Carruth f85d98285e [Modules] Make "#pragma weak" undeclared identifiers be tracked
deterministically.

This fixes a latent issue where even Clang's Sema (and diagnostics) were
non-deterministic in the face of this pragma. The fix is super simple --
just use a MapVector so we track the order in which these are parsed (or
imported). Especially considering how rare they are, this seems like the
perfect tradeoff. I've also simplified the client code with judicious
use of auto and range based for loops.

I've added some pretty hilarious code to my stress test which now
survives the binary diff without issue.

llvm-svn: 233261
2015-03-26 08:32:49 +00:00
Chandler Carruth 8a3d24dcf8 [Modules] Delete a bunch of complex code for ensuring visible decls in
updated decl contexts get emitted.

Since this code was added, we have newer vastly simpler code for
handling this. The code I'm removing was very expensive and also
generated unstable order of declarations which made module outputs
non-deterministic.

All of the tests continue to pass for me and I'm able to check the
difference between the .pcm files after merging modules together.

llvm-svn: 233251
2015-03-26 04:27:10 +00:00
Richard Smith 65ebb4ac8a [modules] If we reach a definition of a class for which we already have a
non-visible definition, skip the new definition and make the old one visible
instead of trying to parse it again and failing horribly. C++'s ODR allows
us to assume that the two definitions are identical.

llvm-svn: 233250
2015-03-26 04:09:53 +00:00
Chandler Carruth e972c36221 [Modules] A second attempt at writing out on-disk hash tables for the
decl context lookup tables.

The first attepmt at this caused problems. We had significantly more
sources of non-determinism that I realized at first, and my change
essentially turned them from non-deterministic output into
use-after-free. Except that they weren't necessarily caught by tools
because the data wasn't really freed.

The new approach is much simpler. The first big simplification is to
inline the "visit" code and handle this directly. That works much
better, and I'll try to go and clean up the other caller of the visit
logic similarly.

The second key to the entire approach is that we need to *only* collect
names into a stable order at first. We then need to issue all of the
actual 'lookup()' calls in the stable order of the names so that we load
external results in a stable order. Once we have loaded all the results,
the table of results will stop being invalidated and we can walk all of
the names again and use the cheap 'noload_lookup()' method to quickly
get the results and serialize them.

To handle constructors and conversion functions (whose names can't be
stably ordered) in this approach, what we do is record only the visible
constructor and conversion function names at first. Then, if we have
any, we walk the decls of the class and add those names in the order
they occur in the AST. The rest falls out naturally.

This actually ends up simpler than the previous approach and seems much
more robust.

It uncovered a latent issue where we were building on-disk hash tables
for lookup results when the context was a linkage spec! This happened to
dodge all of the assert by some miracle. Instead, add a proper predicate
to the DeclContext class and use that which tests both for function
contexts and linkage specs.

It also uncovered PR23030 where we are forming somewhat bizarre negative
lookup results. I've just worked around this with a FIXME in place
because fixing this particular Clang bug seems quite hard.

I've flipped the first part of the test case I added for stability back
on in this commit. I'm taking it gradually to try and make sure the
build bots are happy this time.

llvm-svn: 233249
2015-03-26 03:11:40 +00:00
Eric Christopher 118ee4c07b Add an explanatory comment as to why we're turning on and off
certain other options as aliases. There be dragons here.

llvm-svn: 233238
2015-03-26 00:50:13 +00:00
Richard Smith 88f4bba21e Reformatting, NFC
llvm-svn: 233234
2015-03-26 00:16:07 +00:00
Manuel Klimek 093b2d48b4 Keep track of canonical decls in Redeclarable.
More than 2x speedup on modules builds with large redecl chains.
Roughly 15-20% speedup on non-modules builds for very large TUs.
Between 2-3% cost in memory on large TUs.

llvm-svn: 233228
2015-03-25 23:18:30 +00:00
Eric Christopher 70c1665d83 Reapply r232888 after applying a fix for -msse4 code generation.
As a note, any target that uses fake target features via command
line options will have similar problems.

llvm-svn: 233227
2015-03-25 23:14:47 +00:00
Eric Christopher f43966f38d Make the msse4/mno-sse4 flags aliases of the maximum sse values
they enable/disable.

This fixes two things:

a) sse4 isn't actually a target feature, don't treat it as one.
b) we weren't correctly disabling sse4.1 when we'd pass -mno-sse4
   after enabling it, thus passing preprocessor directives and
   (soon) passing the function attribute as well when we shouldn't.

llvm-svn: 233223
2015-03-25 22:09:26 +00:00
Ehsan Akhgari a2956ff405 Fix coverage-ld.c on systems with an Android linker in $PATH
Summary:
On my system, clang tries to invoke /path/to/arm-linux-androideabi-ld
as the linker for Android, and the regex inside the test file considers
this as unacceptable.

Reviewers: samsonov

Subscribers: tberghammer, aemerson, cfe-commits

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

llvm-svn: 233211
2015-03-25 20:17:20 +00:00
Yunzhong Gao 7b0f428573 Disable this test for PS4 target because PS4 issues different diagnostics.
llvm-svn: 233210
2015-03-25 20:16:29 +00:00
Jingyue Wu 4f7b9eb217 Fix addrspace when emitting constructors of static local variables
Summary:
Due to CUDA's implicit address space casting, the type of a static local
variable may be more specific (i.e. with address space qualifiers) than
the type expected by the constructor. Emit an addrspacecast in that
case.

Test Plan: Clang used to crash on the added test.

Reviewers: nlewycky, pcc, eliben, rsmith

Reviewed By: eliben, rsmith

Subscribers: llvm-commits

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

llvm-svn: 233208
2015-03-25 20:06:28 +00:00
Kit Barton 8246f28237 Add Hardware Transactional Memory (HTM) Support
This patch adds Hardware Transaction Memory (HTM) support supported by ISA 2.07
(POWER8). The intrinsic support is based on GCC one [1], with both 'PowerPC HTM
Low Level Built-in Functions' and 'PowerPC HTM High Level Inline Functions'
implemented.

Along with builtins a new driver switch is added to enable/disable HTM
instruction support (-mhtm) and a header with common definitions (mostly to
parse the TFHAR register value). The HTM switch also sets a preprocessor builtin
HTM.

The HTM usage requires a recently newer kernel with PPC HTM enabled. Tested on
powerpc64 and powerpc64le.

This is send along a llvm patch to enabled the builtins and option switch.

[1]
https://gcc.gnu.org/onlinedocs/gcc/PowerPC-Hardware-Transactional-Memory-Built-in-Functions.html

Phabricator Review: http://reviews.llvm.org/D8248

llvm-svn: 233205
2015-03-25 19:41:41 +00:00
Tamas Berghammer 6373cee3b6 Create android x86_32 and x86_64 target info
On android x86_32 the long double is only 64 bits (compared to 80 bits
on linux x86_32) and on android x86_64 the long double is IEEEquad
(compared to x87DoubleExtended on linux x86_64). This CL creates new
TargetInfo classes for this targets to represent these differences.

Differential revision: http://reviews.llvm.org/D8357

llvm-svn: 233177
2015-03-25 10:38:50 +00:00
Daniel Jasper cb47d8d17b Temporarily disable one more non-determinism flag.
This turned the bots to red after r233172 which reverted r233156.

llvm-svn: 233173
2015-03-25 06:59:19 +00:00
Rafael Espindola c606b3e6d0 Revert "[Modules] When writing out the on-disk hash table for the decl context lookup tables, we need to establish a stable ordering for constructing the hash table. This is trickier than it might seem."
This reverts commit r233156. It broke the bots.

llvm-svn: 233172
2015-03-25 04:43:15 +00:00
Justin Bogner f14b207882 InstrProf: Handle whitespace and comments at the ends of macros
When we try to find the end loc for a token, we have to re-lex the
token. This was running into a problem when we'd store the end loc of
a macro's coverage region, since we wouldn't actually be at the
beginning of a token when we tried to re-lex it, leading us to do
silly things (and eventually assert) when whitespace or comments
followed.

This pushes our use of getPreciseTokenLocEnd earlier, so that we won't
call it when it doesn't make sense to. It also removes an unnecessary
adjustment by 1 that was working around this problem in some cases.

llvm-svn: 233169
2015-03-25 04:13:49 +00:00
Chandler Carruth d5f1db6b36 [Modules] Disable the diff of the merged module, there is still some
non-determinism here, I just got lucky a bunch of times on my system.

llvm-svn: 233163
2015-03-25 01:30:02 +00:00
Chandler Carruth 75fc6a7f61 [Modules] Make the DeclUpdates map be processed in insertion order.
This fixes my stress tests non-determinism so far. However, I've not
started playing with templates, friends, or terrible macros. I've found
at least two more seeming instabilities and am just waiting for a test
case to actually trigger them.

llvm-svn: 233162
2015-03-25 01:02:12 +00:00
Ehsan Akhgari c07d1e23fb Diagnose ref-qualifiers occuring after virt-specifier-seq and generate fixit hints
Summary: Follow-up to the fix of PR22075.

Reviewers: rsmith

Subscribers: cfe-commits

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

llvm-svn: 233161
2015-03-25 00:53:33 +00:00
Ehsan Akhgari 93ed5cf5e6 Diagnose declspecs occuring after virt-specifier-seq and generate fixit hints
Summary: This fixes PR22075.

Reviewers: rsmith

Subscribers: cfe-commits

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

llvm-svn: 233160
2015-03-25 00:53:27 +00:00
Chandler Carruth 75c9f13aa8 [Modules] When writing out the on-disk hash table for the decl context
lookup tables, we need to establish a stable ordering for constructing
the hash table. This is trickier than it might seem.

Most of these cases are easily handled by sorting the lookup results
associated with a specific name that has an identifier. However for
constructors and conversion functions, the story is more complicated.
Here we need to merge all of the constructors or conversion functions
together and this merge needs to be stable. We don't have any stable
ordering for either constructors or conversion functions as both would
require a stable ordering across types.

Instead, when we have constructors or conversion functions in the
results, we reconstruct a stable order by walking the decl context in
lexical order and merging them in the order their particular declaration
names are encountered. This doesn't generalize as there might be found
declaration names which don't actually occur within the lexical context,
but for constructors and conversion functions it is safe. It does
require loading the entire decl context if necessary to establish the
ordering but there doesn't seem to be a meaningful way around that.

Many thanks to Richard for talking through all of the design choices
here. While I wrote the code, he guided all the actual decisions about
how to establish the order of things.

No test case yet because the test case I have doesn't pass yet -- there
are still more sources of non-determinism. However, this is complex
enough that I wanted it to go into its own commit in case it causes some
unforseen issue or needs to be reverted.

llvm-svn: 233156
2015-03-25 00:34:51 +00:00
Reid Kleckner 5a63d7073c Fix obviously broken assertion, NFC
llvm-svn: 233138
2015-03-24 23:46:25 +00:00
Ahmed Bougacha 6ba3831ebe [CodeGen] Support native half inc/dec amounts.
We previously defaulted to long double, but it's also possible to have
a half inc/dec amount, when LangOpts NativeHalfType is set.
Currently, that's only true for OpenCL.

llvm-svn: 233135
2015-03-24 23:44:42 +00:00
Chandler Carruth 580dd296fa [Modules] Stop creating timestamps for the modules cache and trying to
prune it when we have disabled implicit module generation and thus are
not using any cached modules.

Also update a test of explicitly generated modules to pass this CC1 flag
correctly.

This fixes an issue where Clang was dropping files into the source tree
while running its tests.

llvm-svn: 233117
2015-03-24 21:44:25 +00:00
Chandler Carruth 885e78cb22 [Modules] Start making explicit modules produce deterministic output.
There are two aspects of non-determinism fixed here, which was the
minimum required to cause at least an empty module to be deterministic.

First, the random number signature is only inserted into the module when
we are building modules implicitly. The use case for these random
signatures is to work around the very fact that modules are not
deterministic in their output when working with the implicitly built and
populated module cache. Eventually this should go away entirely when
we're confident that Clang is producing deterministic output.

Second, the on-disk hash table is populated based on the order of
iteration over a DenseMap. Instead, use a MapVector so that we can walk
it in insertion order.

I've added a test that an empty module, when built twice, produces the
same binary PCM file.

llvm-svn: 233115
2015-03-24 21:18:10 +00:00
Sanjay Patel 7a9f5d380b Adding back a CHECK that works with r233110
llvm-svn: 233111
2015-03-24 20:42:20 +00:00
Sanjay Patel 1a94ccbec8 Removing a CHECK that is about to go wrong.
I'm about to commit a patch for:
http://reviews.llvm.org/D8567

That patch will break this one existing test case in Clang.
I'm not sure if this file is intending to create a Clang
dependency on the LLVM IR optimizer, but that's the
consequence of specifying -O3 on this test file.

My hope is to avoid buildbot rage by removing this check,
committing the LLVM patch, and then fixing this check.
I don't know how to make a simultaneous commit to Clang
and LLVM.

I will commit the correct CHECK line fix for this test 
shortly.

llvm-svn: 233109
2015-03-24 20:35:24 +00:00
Fariborz Jahanian a9dccd41e9 [Objective-C diagnostic PATCH] Accept and ignore -Wreceiver-is-weak
warning until Xcode removes the warning setting.
rdar://20262140

llvm-svn: 233093
2015-03-24 17:14:20 +00:00
Aaron Ballman f4cb2be05a Track the source location of the dot or arrow operator in a MemberExpr.
Patch by Joe Ranieri!

llvm-svn: 233085
2015-03-24 15:07:53 +00:00
Aaron Ballman 368701a0c8 Reverting r233023 -- it caused test failures on Windows with MSVC x86.
http://bb.pgr.jp/builders/ninja-clang-i686-msc18-R/builds/572

llvm-svn: 233082
2015-03-24 13:51:13 +00:00
Ehsan Akhgari 841cfe1c69 Revert "Diagnose declspecs occuring after virt-specifier-seq and generate fixit hints"
This reverts commit 2131e63e2fdff7c831ab3bfe31facf2e3ebab03d.

llvm-svn: 233074
2015-03-24 13:25:26 +00:00
Ehsan Akhgari 378444331b Revert "Diagnose ref-qualifiers occuring after virt-specifier-seq and generate fixit hints"
This reverts commit 49079d45966a3f57cd82edb35bde2e8e88fccf40.

llvm-svn: 233073
2015-03-24 13:25:23 +00:00
Ehsan Akhgari 86638e59bf Diagnose ref-qualifiers occuring after virt-specifier-seq and generate fixit hints
Summary: Follow-up to the fix of PR22075.

Reviewers: rsmith

Subscribers: cfe-commits

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

llvm-svn: 233070
2015-03-24 13:02:50 +00:00
Ehsan Akhgari 9a7adfcf3a Diagnose declspecs occuring after virt-specifier-seq and generate fixit hints
Summary: This fixes PR22075.

Reviewers: rsmith

Subscribers: cfe-commits

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

llvm-svn: 233069
2015-03-24 13:02:47 +00:00
Benjamin Kramer 2a403d1c01 [analyzer] Remove unused function. No functional change intended.
llvm-svn: 233060
2015-03-24 11:11:11 +00:00
Benjamin Kramer e80728cfa2 Make header standalone, it uses memset and memcmp.
NFC.

llvm-svn: 233059
2015-03-24 11:11:05 +00:00
Daniel Jasper c77b0a1b60 Silence unused warning in non-assert builds.
llvm-svn: 233053
2015-03-24 08:06:38 +00:00
Richard Smith c2bb81860b [modules] Deserialize CXXCtorInitializer list for a constructor lazily.
Previously we'd deserialize the list of mem-initializers for a constructor when
we deserialized the declaration of the constructor. That could trigger a
significant amount of unnecessary work (pulling in all base classes
recursively, for a start) and was causing problems for the modules buildbot due
to cyclic deserializations. We now deserialize these on demand.

This creates a certain amount of duplication with the handling of
CXXBaseSpecifiers; I'll look into reducing that next.

llvm-svn: 233052
2015-03-24 06:36:48 +00:00
Ben Langmuir 70a1b816cc A couple of readASTFileSignature improvements (NFC)
* Strength reduce a std::function to a function pointer,
* Factor out checking the AST file magic number,
* Add a brief doc comment to readAStFileSignature

Thanks to Chandler for spotting these oddities.

llvm-svn: 233050
2015-03-24 04:43:52 +00:00
Richard Smith d2f887dd02 [modules] More removal of unnecessary deserialization of lexical decls.
Even if we have no external visible declarations, we may still have external
lexical decls that lookup() would import to fill its lookup table. It's simpler
and faster to always take the no-deserialization path through noload_lookup.

llvm-svn: 233046
2015-03-24 02:49:55 +00:00
Richard Smith 18b380b1e5 When looking for lexical decls from an external source, check all contexts
rather than just the primary context. This is technically correct but results
in no functionality change (in Clang nor LLDB) because all users of this
functionality only use it on single-context DCs.

llvm-svn: 233045
2015-03-24 02:44:20 +00:00
Eli Bendersky 4184222e82 Cleanup: no need to pass DefinitionKind into ParseCXXInlineMethodDef
All ParseCXXInlineMethodDef does with it is assign it on the ParsingDeclarator.
Since that is passed in as well, the (single) caller may as well set the
DefinitionKind, thus simplifying the code.

No change in functionality.

llvm-svn: 233043
2015-03-23 23:49:41 +00:00
Alexey Samsonov 498f3c3416 [UBSan] Use shared library for UBSan on OS X (Clang part).
Summary:
UBSan is now used in the same way as ASan, and is supported on
OSX and on iOS simulator. At the moment ASan and UBSan can't be used
together due to PR21112, but I hope to resolve it soon by
embedding UBSan into ASan.

Test Plan: regression test suite.

Reviewers: zaks.anna, kubabrecka

Subscribers: cfe-commits

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

llvm-svn: 233035
2015-03-23 23:14:05 +00:00
Eli Bendersky 5f4d76efd3 Record correct source range for defaulted/deleted members.
Fixes https://llvm.org/bugs/show_bug.cgi?id=20744

struct A {

A() = default;
};

Previously the source range of the declaration of A ended at the ')'. It should
include the '= default' part as well. The same for '= delete'.

Note: this will break one of the clang-tidy fixers, which is going to be
addessed in a follow-up patch.

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

llvm-svn: 233028
2015-03-23 21:43:28 +00:00
Reid Kleckner a7b275d3b2 MS ABI: lambda call operators are instance methods and should use thiscall
Fixes an issue reported by Daniel Berenyi on cfe-dev.

llvm-svn: 233023
2015-03-23 21:16:49 +00:00
Fariborz Jahanian 98253306f3 [SDK modernizer PATCH]. Fixes a bug whereby a call to super
was not converted to property-dot syntax by removing an unused
code. rdar://19140267

llvm-svn: 233019
2015-03-23 20:52:26 +00:00
Chris Bieneman c3e44c2284 [cmake] Clang's install should install clang/Config/config.h
llvm-svn: 233016
2015-03-23 20:43:21 +00:00
Yunzhong Gao 99efc0361b Adds a warning for unrecognized argument to #pragma comment() on PS4.
PS4 target recognizes the #pragma comment() syntax as in -fms-extensions, but
only handles the case of #pragma comment(lib). This patch adds a warning if any
other arguments are encountered.

This patch also refactors the code in ParsePragma.cpp a little bit to make it
more obvious that some codes are being shared between -fms-extensions and PS4.

llvm-svn: 233015
2015-03-23 20:41:42 +00:00
Alexey Samsonov 3ae177cdb3 [UBSan] Introduce "ubsan_standalone" library (Clang part).
Get rid of "libclang_rt.san" library that used to contain
sanitizer_common pieces required by UBSan if it's used in a standalone
mode. Instead, build two variants of UBSan runtime: "ubsan" and
"ubsan_standalone" (same for "ubsan_cxx" and "ubsan_standalone_cxx").

Later "ubsan" and "ubsan_cxx" libraries will go away, as they will
embedded it into corresponding ASan runtimes.

llvm-svn: 233010
2015-03-23 20:05:42 +00:00
Richard Smith 7226f2a497 [modules] Fix an iterator invalidation bug found by the modules selfhost bot.
llvm-svn: 233007
2015-03-23 19:54:56 +00:00
David Blaikie 96cedb52b3 Make Oveflow tracking more legible (CR feedback from Richard Smith on r232999)
llvm-svn: 233006
2015-03-23 19:54:44 +00:00
David Blaikie 252f743858 Refactor: Simplify boolean expresssions in lib/Lex
Simplify boolean expressions using `true` and `false` with `clang-tidy`

Patch by Richard Thomson.

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

llvm-svn: 232999
2015-03-23 19:39:19 +00:00
Eric Christopher c54920a123 Fix and update comments and a small reformatting.
llvm-svn: 232997
2015-03-23 19:26:05 +00:00
Dmitri Gribenko e5423a766b Refactor: Simplify boolean expressions in libclang
Simplify boolean expresions using true and false with clang-tidy.

Patch by Richard.

llvm-svn: 232996
2015-03-23 19:23:50 +00:00
Benjamin Kramer 53f5e893c2 Explicitly include raw_ostream.h instead of relying on transitive inclusion.
NFC.

llvm-svn: 232975
2015-03-23 18:05:43 +00:00
Ahmed Bougacha d1801afeac [CodeGen] Properly support the half FP type with non-native operations.
On AArch64, the -fallow-half-args-and-returns option is the default.
With it, the half type is considered legal (rather than the i16 used
normally for __fp16), but no operation is, except conversions and
load/stores and such.

The previous behavior was tantamount to saying LangOpts.NativeHalfType
was implied by LangOpts.HalfArgsAndReturns, which isn't true.
Instead, teach the various parts of CodeGen that already know about
half (using the intrinsics or not) about this weird in-between case,
where the "half" type is legal, but operations on it aren't.

This is a smaller intermediate step to the end-goal of removing the
intrinsic, always using "half", and letting the backend legalize.

Builds on r232968.
rdar://20045970, rdar://17468714
Differential Revision: http://reviews.llvm.org/D8367

llvm-svn: 232971
2015-03-23 17:54:16 +00:00
Ahmed Bougacha 47ec2c7479 [CodeGen] Convert double -> __fp16 in one step.
Fix the CodeGen so that for types bigger than float, instead of
converting to fp16 via the sequence "InTy -> float -> fp16", we
perform conversions in just one step.  This avoids the double
rounding which potentially changes results from a natural
IEEE-754 operation.

rdar://17594379, rdar://17468714
Differential Revision: http://reviews.llvm.org/D4602
Part of: http://reviews.llvm.org/D8367

llvm-svn: 232968
2015-03-23 17:48:07 +00:00
NAKAMURA Takumi 544d2bdb5c OpenMPClause.h: Fix typo in \param. [-Wdocumentation]
llvm-svn: 232956
2015-03-23 16:05:50 +00:00
Benjamin Kramer 9e925c1d66 [tooling] Move ArgumentsAdjustingCompilations into an anonymous namespace.
NFC.

llvm-svn: 232947
2015-03-23 12:47:15 +00:00
Benjamin Kramer d5748c7b9d Move private classes into anonymous namespaces
Also merge anonymous namespaces in Targets.cpp a bit. NFC.

llvm-svn: 232945
2015-03-23 12:31:05 +00:00
Scott Douglass 3205f52198 handle armeb/thumb/thumbeb consistently in gnutools::Assemble::ConstructJob
Differential Revision: http://reviews.llvm.org/D8196

llvm-svn: 232940
2015-03-23 10:54:24 +00:00
Scott Douglass d4cfffccc7 Convert cascading if-else-if to switch. NFC
Differential Revision: http://reviews.llvm.org/D8485

llvm-svn: 232939
2015-03-23 10:46:28 +00:00
Alexey Bataev 1b752aab3f [OPENMP] Fixed test for 'single' directive codegen.
llvm-svn: 232933
2015-03-23 06:40:37 +00:00
Alexey Bataev a63048e4fd [OPENMP] Codegen for 'copyprivate' clause ('single' directive).
If there is at least one 'copyprivate' clause is associated with the single directive, the following code is generated:

```
i32 did_it = 0;                                  \\ for 'copyprivate' clause
if(__kmpc_single(ident_t *, gtid)) {
  SingleOpGen();
  __kmpc_end_single(ident_t *, gtid);
  did_it = 1;                                    \\ for 'copyprivate' clause
}
<copyprivate_list>[0] = &var0;
...
<copyprivate_list>[n] = &varn;
call __kmpc_copyprivate(ident_t *, gtid, <copyprivate_list_size>,
                        <copyprivate_list>, <copy_func>, did_it);

...

void<copy_func>(void *LHSArg, void *RHSArg) {
  Dst = (void * [n])(LHSArg);
  Src = (void * [n])(RHSArg);
  Dst[0] = Src[0];
  ... Dst[n] = Src[n];
}
```
All list items from all 'copyprivate' clauses are gathered into single <copyprivate list> (<copyprivate_list_size> is a size in bytes of this list) and <copy_func> is used to propagate values of private or threadprivate variables from the 'single' region to other implicit threads from outer 'parallel' region.
Differential Revision: http://reviews.llvm.org/D8410

llvm-svn: 232932
2015-03-23 06:18:07 +00:00
Daniel Jasper 17ae9f0206 Revert "Add CodeGen support for adding cpu attributes on functions based on"
This breaks CodeGen for an internal target. I'll get repro instructions
to you.

llvm-svn: 232930
2015-03-23 05:52:28 +00:00
Richard Smith 9e2341d093 [modules] Remove redundant import of lexical decls when building a lookup table
for a DeclContext, and fix propagation of exception specifications along
redeclaration chains.

This reverts r232905, r232907, and r232907, which reverted r232793, r232853,
and r232853.

One additional change is present here to resolve issues with LLDB: distinguish
between whether lexical decls missing from the lookup table are local or are
provided by the external AST source, and still look in the external source if
that's where they came from.

llvm-svn: 232928
2015-03-23 03:25:59 +00:00
Benjamin Kramer 70f19df90d [ASTMatchers] Factor wrapping matcher classes into a common base class.
The deduplication here is negligible, but it allows the compiler to
skip emission of many templated base class destructors. Shrinks
clang-query by 53k. No functionality change intended.

llvm-svn: 232924
2015-03-22 21:57:53 +00:00
Benjamin Kramer b474c04f49 [Analyzer] Don't inherit from FoldingSet.
That's not really necessary here. NFCI.

llvm-svn: 232921
2015-03-22 18:16:22 +00:00
Benjamin Kramer 15a6194b5d Update unit test for r232916.
llvm-svn: 232918
2015-03-22 16:05:46 +00:00
Benjamin Kramer ac75baaad8 [multilib] Turn virtual functor into functin_ref
And update code to use lambdas where possible, plus random cleanup. NFCI.

llvm-svn: 232916
2015-03-22 15:56:12 +00:00
Faisal Vali 2da8ed9241 Add a dump function to Stmt that takes only an output stream. No functionality change.
This allows dumping to any given output stream but without requiring a SourceManager, similar to the interface provided by Decl.

It's useful when writing certain generic debug functions, external to the clang code base (for e.g.).

llvm-svn: 232912
2015-03-22 13:35:56 +00:00
Benjamin Kramer b7e4a1a0b6 Remove empty files left behind by r232907.
llvm-svn: 232909
2015-03-22 10:08:31 +00:00
Vince Harron 08dcf60295 Reverting 232853 and 232870 because they depend on 232793,
which was reverted because it was causing LLDB test failures

llvm-svn: 232907
2015-03-22 08:47:07 +00:00
David Majnemer c371ff048d MS ABI: Implement driver-level support for thread-safe statics
Decide whether or not to use thread-safe statics depending on whether or
not we have an explicit request from the driver.  If we don't have an
explicit request, infer which behavior to use depending on the
compatibility version we are targeting.

N.B. CodeGen support is still ongoing.

llvm-svn: 232906
2015-03-22 08:39:22 +00:00
Vince Harron a3ea9a4e09 Reverting r232793 until some new LLDB failures are discussed
llvm-svn: 232905
2015-03-22 05:59:59 +00:00
Nico Weber bac8b6b39a -Wdynamic-class-memaccess: Also warn about array types.
It looks like not warning on this was an oversight in the original
implementation of this warning.

llvm-svn: 232900
2015-03-21 17:56:44 +00:00
Nico Weber c44b35e3be Dedent code for -Wdynamic-class-memaccess warning. No behavior change.
The diff looks intimidating, but this just moves the -Wdynamic-class-memaccess
code out a scope, protected by a

    if (PointeeTy == QualType())
      continue;

check so that it still only runs when it should.

llvm-svn: 232899
2015-03-21 17:37:46 +00:00
Alexander Musman 0470124abc Small test fix for r232890
llvm-svn: 232893
2015-03-21 11:49:27 +00:00
Alexander Musman 3276a27b5c [OPENMP] CodeGen of the 'linear' clause for the 'omp simd' directive.
The linear variable is privatized (similar to 'private') and its
value on current iteration is calculated, similar to the loop
counter variables.
Differential revision: http://reviews.llvm.org/D8375

llvm-svn: 232890
2015-03-21 10:12:56 +00:00
Eric Christopher ea00c2a06f Add CodeGen support for adding cpu attributes on functions based on
the target-cpu, if different from the triple's cpu, and
target-features as they're written that are passed down from the
driver.

Together with LLVM r232885 this should allow the LTO'ing of binaries
that contain modules compiled with different code generation options
on a subset of architectures with full backend support (x86, powerpc,
aarch64).

llvm-svn: 232888
2015-03-21 06:15:15 +00:00
Richard Smith decef8007f [modules] When either redecl chain merging or an update record causes us to
give an exception specification to a declaration that didn't have an exception
specification in any of our imported modules, emit an update record ourselves.
Without this, code importing the current module would not see an exception
specification that we could see and might have relied on.

llvm-svn: 232870
2015-03-21 00:58:54 +00:00
Filipe Cabecinhas c473255110 Only add -fno-rtti if KernelOrKext or in C++ mode.
llvm-svn: 232869
2015-03-20 23:51:15 +00:00
Filipe Cabecinhas 3e707d98ee Don't claim exception related arguments when looking at RTTIMode
Summary:
We were claiming the -f*exceptions arguments when looking for the
RTTIMode. This makes us not warn about unused arguments if compiling a C
file with -fcxx-exceptions.

This patch fixes it by not claiming the exception-related arguments at
that point.

Reviewers: rsmith, samsonov

Subscribers: cfe-commits

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

llvm-svn: 232860
2015-03-20 23:33:23 +00:00
Sanjay Patel 2ad80dac9b fixed vperm2* intrinsics to check for shuffles
This corresponds to llvm r232852:
http://reviews.llvm.org/rL232852

llvm-svn: 232857
2015-03-20 22:37:20 +00:00
Richard Smith 5a07892dec [modules] Remove temporary IdentifierInfo lookup results when we're done with them.
llvm-svn: 232853
2015-03-20 21:56:50 +00:00
Jordan Rose 03ad616143 [analyzer] RetainCountChecker: Don't assume +0 for ivars backing readonly properties.
Similarly, don't assume +0 if the property's setter is manually implemented.
In both cases, if the property's ownership is explicitly written, then we /do/
assume the ivar has the same ownership.

rdar://problem/20218183

llvm-svn: 232849
2015-03-20 21:12:27 +00:00
Rafael Espindola e9ad54b3ee Update for llvm api change.
llvm-svn: 232843
2015-03-20 20:00:30 +00:00
Alexey Samsonov ecf380ef3b [UBSan] Don't allow to use UBSan with anything except for ASan.
We are not able to make a reliable solution for using UBSan together
with other sanitizers with runtime support (and sanitizer_common).
Instead, we want to follow the path used for LSan: have a "standalone"
UBSan tool, and plug-in UBSan that would be explicitly embedded into
specific sanitizers (in short term, it will be only ASan).

llvm-svn: 232829
2015-03-20 18:45:06 +00:00
David Majnemer c403a1ce32 MS ABI: Accept calls to an unprototyped declaration of _setjmp
This fixes PR22961.

llvm-svn: 232824
2015-03-20 17:03:35 +00:00
Alexey Bataev 0068cb2499 [MSVC] Explicit specializations can be declared in any namespace (fix for http://llvm.org/PR13738)
MS compiler emits no errors in case of explicit specializations outside declaration enclosing namespaces, even when language extensions are disabled.
The patch is to suppress errors and emit extension warnings if explicit specializations are not declared in the corresponding namespaces.
This fixes PR13738.

Patch by Alexey Frolov.

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

llvm-svn: 232800
2015-03-20 07:21:46 +00:00
Justin Bogner e9fe0a298c InstrProf: Make profile variables private to reduce binary size overhead
When we instrument a program for profiling, we copy the linkage of an
instrumented function so that our datastructures merge in the same way
as the function. This avoids redundant copies for things like
linkonce, but ends up emitting names we never need to reference for
normal and internal symbols. Promoting internal and external linkage
to private for these variables reduces the size overhead of profiling
drastically.

llvm-svn: 232799
2015-03-20 06:34:38 +00:00
Richard Smith 625ccb3f78 [modules] Remove some redundant work when building a lookup table for a DeclContext.
When we need to build the lookup table for a DeclContext, we used to pull in
all lexical declarations for the context; instead, just build a lookup table
for the local lexical declarations. We previously didn't guarantee that the
imported declarations would be in the returned map, but in some cases we'd
happen to put them all in there regardless. Now we're even lazier about this.

This unnecessary work was papering over some other bugs:

 - LookupVisibleDecls would use the DC for name lookups in the TU in C, and
   this was not guaranteed to find all imported names (generally, the DC for
   the TU in C is not a reliable place to perform lookups). We now use an
   identifier-based lookup mechanism for this.

 - We didn't actually load in the list of eagerly-deserialized declarations
   when importing a module (so external definitions in a module wouldn't be
   emitted by users of those modules unless they happened to be deserialized
   by the user of the module).

llvm-svn: 232793
2015-03-20 02:17:21 +00:00
Duncan P. N. Exon Smith 7ea96c222f DebugInfo: Check for null before using DIType
A WIP patch to turn on stricter `DIDescriptor` accessor checks fires
here; it's obvious from the code that `T` can be null, so add an
explicit check.  Caught by dozens of current testcases.

llvm-svn: 232791
2015-03-20 00:53:40 +00:00
Reid Kleckner 7ffc3fbb2f C++14: Disable sized deallocation by default due to ABI breakage
There are no widely deployed standard libraries providing sized
deallocation functions, so we have to punt and ask the user if they want
us to use sized deallocation. In the future, when such libraries are
deployed, we can teach the driver to detect them and enable this
feature.

N3536 claimed that a weak thunk from sized to unsized deallocation could
be emitted to avoid breaking backwards compatibility with standard
libraries not providing sized deallocation. However, this approach and
other variations don't work in practice.

With the weak function approach, the thunk has to have default
visibility in order to ensure that it is overridden by other DSOs
providing sized deallocation. Weak, default visibility symbols are
particularly expensive on MachO, so John McCall was considering
disabling this feature by default on Darwin. It also changes behavior
ELF linking behavior, causing certain otherwise unreferenced object
files from an archive to be pulled into the link.

Our second approach was to use an extern_weak function declaration and
do an inline conditional branch at the deletion call site. This doesn't
work because extern_weak only works on MachO if you have some archive
providing the default value of the extern_weak symbol. Arranging to
provide such an archive has the same challenges as providing the symbol
in the standard library. Not to mention that extern_weak doesn't really
work on COFF.

Reviewers: rsmith, rjmccall

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

llvm-svn: 232788
2015-03-20 00:31:07 +00:00
Kostya Serebryany 6fe5fcbcbc Allow -fsanitize-coverage with -fsanitize=dataflow
Summary: Allow -fsanitize-coverage with -fsanitize=dataflow

Test Plan: check-clang

Reviewers: pcc

Reviewed By: pcc

Subscribers: cfe-commits

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

llvm-svn: 232787
2015-03-20 00:06:52 +00:00
David Majnemer 73768709f2 Don't crash-on-valid when an inline function is friend of class template
We assumed that the most recent declaration of an inline function would
also be inline.  However, a more recent declaration can come from a
friend declaration in a class template that is instantiated at the
definition of the function.

llvm-svn: 232786
2015-03-20 00:02:27 +00:00
Duncan P. N. Exon Smith f80840f784 Clang follow-up to LLVM r232772
-verify-di is dead! Long live -verify!

llvm-svn: 232779
2015-03-19 22:43:38 +00:00
Chandler Carruth c66deafb73 [Modules] Implement __builtin_isinf_sign in Clang.
Somehow, we never managed to implement this fully. We could constant
fold it like crazy, including constant folding complex arguments, etc.
But if you actually needed to generate code for it, error.

I've implemented it using the somewhat obvious lowering. Happy for
suggestions on a more clever way to lower this.

Now, what you might ask does this have to do with modules? Fun story. So
it turns out that libstdc++ actually uses __builtin_isinf_sign to
implement std::isinf when in C++98 mode, but only inside of a template.
So if we're lucky, and we never instantiate that, everything is good.
But once we try to instantiate that template function, we need this
builtin. All of my customers at least are using C++11 and so they never
hit this code path.

But what does that have to do with modules? Fun story. So it turns out
that with modules we actually observe a bunch of bugs in libstdc++ where
their <cmath> header clobbers things exposed by <math.h>. To fix these,
we have to provide global function definitions to replace the macros
that C99 would have used. And it turns out that ::isinf needs to be
implemented using the exact semantics used by the C++98 variant of
std::isinf. And so I started to fix this bug in libstdc++ and ceased to
be able to compile libstdc++ with Clang.

The yaks are legion.

llvm-svn: 232778
2015-03-19 22:39:51 +00:00
David Majnemer a7f8c46439 MS ABI: Implement the MSVC 2015 scheme for scope disambiguation
consider C++ that looks like:
  inline int &f(bool b) {
    if (b) {
      static int i;
      return i;
    }
    static int i;
    return i;
  }

Both 'i' variables must have distinct (and stable) names for linkage
purposes.  The MSVC 2013 ABI would number the variables using a count of
the number of scopes that have been created.  However, the final 'i'
returns to a scope that has already been created leading to a mangling
collision.

MSVC 2015 fixes this by giving the second 'i' the name it would have if
it were declared before the 'if'.  However, this results in ABI breakage
because the mangled name, in cases where there was no ambiguity, would
now be different.

We implement the new behavior and only enable it if we are targeting the
MSVC 2015 ABI, otherwise the old behavior will be used.

This fixes PR18131.

llvm-svn: 232766
2015-03-19 21:54:30 +00:00
Kaelyn Takata b939fb3478 Correct typos in C11 generic-selection expressions.
llvm-svn: 232760
2015-03-19 20:56:07 +00:00
Benjamin Kramer 56376ef58f Remove unused diagnostic.
Unused since r231851.

llvm-svn: 232751
2015-03-19 19:44:37 +00:00
Nico Weber 0055a19926 Add -Wpartial-availability.
This warns when using decls that are not available on all deployment targets.
For example, a call to

  - (void)ppartialMethod __attribute__((availability(macosx,introduced=10.8)));

will warn if -mmacosx-version-min is set to less than 10.8.

To silence the warning, one has to explicitly redeclare the method like so:

  @interface Whatever(MountainLionAPI)
  - (void)ppartialMethod;
  @end

This way, one cannot accidentally call a function that isn't available
everywhere.  Having to add the redeclaration will hopefully remind the user
to add an explicit respondsToSelector: call as well.

Some projects build against old SDKs to get this effect, but building against
old SDKs suppresses some bug fixes -- see http://crbug.com/463171 for examples.
The hope is that SDK headers are annotated well enough with availability
attributes that new SDK + this warning offers the same amount of protection
as using an old SDK.

llvm-svn: 232750
2015-03-19 19:18:22 +00:00
Artem Belevich f3d3db65de Remove .CUDAIsDevice flags from CodeGenOpts as it's already
available in LangOpts.

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

llvm-svn: 232749
2015-03-19 18:58:18 +00:00
Reid Kleckner 461c0c6934 Fix -ast-dump of dependent new and delete exprs
llvm-svn: 232748
2015-03-19 18:47:47 +00:00
Artem Belevich 5196fe7c19 Ignore device-side asm constraint errors while compiling CUDA code for host and vice versa.
Differential Revision: http://reviews.llvm.org/D8392

llvm-svn: 232747
2015-03-19 18:40:25 +00:00
Reid Kleckner 5c682bc4b8 Add -ast-dump support for new and delete expressions to help figure out which operator got selected
llvm-svn: 232740
2015-03-19 18:09:25 +00:00
Reid Kleckner e4f77deaeb Fix incremental linking with ninja and CMake 3.2+, see LLVM r232662 for details
llvm-svn: 232739
2015-03-19 17:45:12 +00:00
Artem Belevich 83a6dcc470 Ensure that we still parse preprocessed CUDA files as CUDA when we use
-save-temps option.

Summary: Fixes PR22926.

Review: http://reviews.llvm.org/D8383
llvm-svn: 232737
2015-03-19 17:32:06 +00:00
Reid Kleckner 7270ef5705 Revert "Improvement on sized deallocation from r230160"
This reverts commit r230580.

extern_weak functions don't appear to work on Darwin (PR22951), so we'll
need to come up with a new approach.

llvm-svn: 232731
2015-03-19 17:03:58 +00:00
Benjamin Kramer 845e32cd4d Devirtualize Attr and all subclasses.
We know all subclasses in tblgen so just generate a giant switch for
the few virtual methods or turn them into a member variable using spare
bits. The giant jump tables aren't pretty but still much smaller than
a vtable for every attribute, shrinking Release+Asserts clang by ~400k.

Also halves the size of the Attr base class. No functional change
intended.

llvm-svn: 232726
2015-03-19 16:06:49 +00:00
Benjamin Kramer 539803c9e1 Move ThreadSafetyReporter into an anonymous namespace. NFC.
llvm-svn: 232723
2015-03-19 14:23:45 +00:00
Manuel Klimek c68aa16d46 Add option to switch off putting header modules into the dependency file.
llvm-svn: 232721
2015-03-19 12:00:22 +00:00
Daniel Jasper 414c9c6fb0 clang-format: Fix another bug in wrapping around "*".
Before:
  void aaaaa(
      aaaaaaaaaaaa* aaaaaaaaaaaaaa) {} // even violation the column limit

After:
  void aaaaa(aaaaaaaaaaaa*
                 aaaaaaaaaaaaaa) {}

llvm-svn: 232717
2015-03-19 09:40:16 +00:00
Alexey Bataev 87b1302a84 [OPENMP] Fixed bug in codegen of 'atomic write'.
Fixed codegen for exit/continue order after success/failed atomic cmpxchg instruction for 'atomic write' construct.

llvm-svn: 232712
2015-03-19 08:44:10 +00:00
David Majnemer a8f2f1da99 Parse: Don't assume tokens have a length
Don't crash if the last token in a bad inline method body is an
annotation token.

llvm-svn: 232694
2015-03-19 00:10:23 +00:00
David Majnemer a03849b2e7 MS ABI: Don't try to emit VF/VB-Tables for extern class templates
There will be an explicit template instantiation in another translation
unit which will provide the definition of the VF/VB-Tables.

This fixes PR22932.

llvm-svn: 232680
2015-03-18 22:04:43 +00:00
Richard Trieu 948bd5e231 When cloning LocalInstantiationScope's, don't update the current scope in Sema.
Construction of LocalInstantiationScope automatically updates the current scope
inside Sema.  However, when cloning a scope, the current scope does not change.
Change the cloning function to preserve the current scope.

Review: http://reviews.llvm.org/D8407
BUG: https://llvm.org/bugs/show_bug.cgi?id=22931
llvm-svn: 232675
2015-03-18 21:52:47 +00:00
NAKAMURA Takumi 8bf64b32d6 Appease clang/test/Parser/opencl-atomics-cl20.cl for 32-bit targets with explicit triple.
llvm-svn: 232638
2015-03-18 15:07:54 +00:00
Daniel Jasper 1130981907 clang-format: Fix bad wrapping after "*" introduced in r232044.
Before:
  void aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaa*
                                              const aaaaaaaaaaaa) {}

After:
  void aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(
      aaaaaaaaaaaaaaaaaaaaaaaaa* const aaaaaaaaaaaa) {}

llvm-svn: 232635
2015-03-18 14:20:13 +00:00
Daniel Jasper 92e0982936 [clang-format] Add missing test for std::function<void( int, int )>
spacing also fixed by r230473.

The fix in r230473 was done to enable fixing the spacing for
  std::function<void( int, int )>.
I did not realized that it also fixed this
issue.  Since it is fairly different from
  Deleted &operator=(const Deleted &)& = default;
fixed in r230473, it seems sensible to add the regression test for it.

Also cleaned up the test by removing duplicated code and comment, and kept
repeated test set consistent.

Result of running the new tests with r230473 backed out:
  [ RUN      ] FormatTest.ConfigurableSpacesInParentheses
  Actual: "std::function<void(int, int)> callback;"
  Expected: "std::function<void( int, int )> callback;"
  Actual: "std::function<void( int, int )> callback;"
  Expected: "std::function<void(int, int)> callback;"
  Actual: "std::function<void( int, int ) > callback;"
  Expected: "std::function<void(int, int)> callback;"
  [  FAILED  ] FormatTest.ConfigurableSpacesInParentheses (402 ms)

Result of new tests with r230473:
  [ RUN      ] FormatTest.ConfigurableSpacesInParentheses
  [       OK ] FormatTest.ConfigurableSpacesInParentheses (209 ms)

Review: http://reviews.llvm.org/D7922

Patch by Jean-Philippe Dufraigne. Thanks!

llvm-svn: 232632
2015-03-18 12:59:19 +00:00
Anastasia Stulova b1152f1e56 OpenCL: CL2.0 atomic types
OpenCL C Spec v2.0 Section 6.13.11

- Made c11 _Atomic being not accepted for OpenCL

- Implemented CL2.0 atomics by aliasing them to the corresponding c11 atomic types using implicit typedef

- Added diagnostics for atomics Khronos extension enabling

llvm-svn: 232631
2015-03-18 12:55:29 +00:00
Yaron Keren 1a9f58b32d Fix another ternary Visual C++ is OK wiht but gcc not.
llvm-svn: 232624
2015-03-18 10:30:57 +00:00
Yaron Keren 49c63695c0 Fix gcc ambiguity error (Visual C++ was OK with these).
llvm-svn: 232623
2015-03-18 10:26:22 +00:00
Yaron Keren 92e1b62d45 Remove many superfluous SmallString::str() calls.
Now that SmallString is a first-class citizen, most SmallString::str()
calls are not required. This patch removes a whole bunch of them, yet
there are lots more.

There are two use cases where str() is really needed:
1) To use one of StringRef member functions which is not available in
SmallString.
2) To convert to std::string, as StringRef implicitly converts while 
SmallString do not. We may wish to change this, but it may introduce
ambiguity.

llvm-svn: 232622
2015-03-18 10:17:07 +00:00
David Majnemer d8dee1f54b Lex: Don't call getIdentifierInfo on annotation tokens
These calls are usually guarded by checks for isAnnotation() but it
looks like we missed a spot.  This would cause the included test to
crash clang.

llvm-svn: 232616
2015-03-18 07:53:20 +00:00
David Majnemer aaf2b84f99 MS ABI: Define _HAS_CHAR16_T_LANGUAGE_SUPPORT when appropriate
If we are in MSVC 2015 compatibility mode and C++11 language conformance
is enabled, define _HAS_CHAR16_T_LANGUAGE_SUPPORT to 1.

llvm-svn: 232615
2015-03-18 07:53:18 +00:00
David Majnemer 28aae9c29b MSVC Compat: Permit char16_t, char32_t and _Atomic when targeting > 2013
We disabled support for _Atomic because the STL had name conflicts,
they've been resolved in 2015.  Similarly, reenable char16_t and
char32_t.

llvm-svn: 232611
2015-03-18 04:15:23 +00:00
Alexey Bataev 91797559ac [OPENMP] Fix crash on code emitting if errors are found.
Codegen for threadprivate variables (and in some other cases) may cause crash of the compiler if some diagnostic is produced later. This happens because some of the autogenerated globals are not removed from InternalVars StringMap when llvm::Module is reset.
Differential Revision: http://reviews.llvm.org/D8360

llvm-svn: 232610
2015-03-18 04:13:55 +00:00
David Majnemer 4deaac780c MS ABI: Empty pack expansions had their mangling changed in 2013->2015
We used to support the 2013 mangling and changed it to the more
reasonable 2015 mangling.  Let's make the mangling conditional on what
version of MSVC is targeted.

This fixes PR21888.

llvm-svn: 232609
2015-03-18 03:56:27 +00:00
Richard Smith 7f330cdb31 Make module files passed to a module build via -fmodule-file= available to
consumers of that module.

Previously, such a file would only be available if the module happened to
actually import something from that module.

llvm-svn: 232583
2015-03-18 01:42:29 +00:00
NAKAMURA Takumi 59aca19708 Fix test in release mode. This reapplies r232456, corresponding to r232579.
llvm-svn: 232582
2015-03-18 01:41:58 +00:00
Nick Lewycky 84146bee6c Fix the LLVM type used when lowering initializer list reference temporaries to global variables. Reapplies r232454 with fix for PR22940.
llvm-svn: 232579
2015-03-18 01:06:24 +00:00
David Majnemer 8fa8c384d2 Basic: Update clang to reflect changes made to LLVM datalayout
We now give x86-64 COFF targets a different mangling code, update clang
to use it.

llvm-svn: 232571
2015-03-17 23:55:00 +00:00
Kaelyn Takata 3587fff95e Fix a crash when the size of an 'auto' is needed and its initalizer
contained a typo correction (the auto decl was being marked as dependent
unnecessarily, which triggered an assertion in cases where the size of
the type is needed).

llvm-svn: 232568
2015-03-17 23:50:12 +00:00
Justin Bogner 0729afa4a6 MS ABI: Fix a couple of -Winconsistent-missing-override warnings
llvm-svn: 232559
2015-03-17 22:31:34 +00:00
Michael Zolotukhin d0cf6c852a Imply linker arguments from '-fveclib' option.
Summary: As discussed in D8097, we should provide corresponding linking flags when 'fveclib' is specified.

Reviewers: hfinkel

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

llvm-svn: 232556
2015-03-17 22:13:05 +00:00
Reid Kleckner 93f661a1da MS ABI: Build C++ default argument exprs for exported template classes
This was an omission from r232229.

llvm-svn: 232554
2015-03-17 21:51:43 +00:00
David Majnemer 5f0dd6162c MS ABI: Emit HandlerMap entries for C++ catch
The HandlerMap describes, to the runtime, what sort of catches surround
the try.  In principle, this structure has to be emitted by the backend
because only it knows the layout of the stack (the runtime needs to know
where on the stack the destination of a copy lives, etc.) but there is
some C++ specific information that the backend can't reason about.

Stick this information in special LLVM globals with the relevant
"const", "volatile", "reference" info mangled into the name.

llvm-svn: 232538
2015-03-17 20:35:05 +00:00
David Majnemer 443250f08d WIP
llvm-svn: 232537
2015-03-17 20:35:00 +00:00
Michael Zolotukhin c888dd0cb8 Add fveclib option.
Review: http://reviews.llvm.org/D8097
llvm-svn: 232533
2015-03-17 20:03:11 +00:00
Reid Kleckner bba3cb95cc MS ABI: Delay default constructor closure checking until the outermost class scope ends
Previously, we would error out on this code because the default argument
wasn't parsed until the end of Outer:

  struct __declspec(dllexport) Outer {
    struct __declspec(dllexport) Inner {
      Inner(void *p = 0);
    };
  };

Now we do the checking on the closing brace of Outer instead of Inner.

llvm-svn: 232519
2015-03-17 19:00:50 +00:00
Dmitri Gribenko 7fe22f66d0 Comment parsing: move a diagnostic to the correct group.
Based on a patch by LE GARREC Vincent.

llvm-svn: 232511
2015-03-17 18:03:42 +00:00
Hans Wennborg f9d865b059 Revert r232454 and r232456: "Fix the LLVM type used when lowering initializer list reference temporaries to global variables."
This caused PR22940.

llvm-svn: 232496
2015-03-17 16:38:58 +00:00
Renato Golin e11531f7ea [ARM] Add support for ARMV6K subtarget (Clang)
ARMv6K is another layer between ARMV6 and ARMV6T2. This is the Clang
side of the changes.

ARMV6 family LLVM implementation.

+-------------------------------------+
| ARMV6                               |
+----------------+--------------------+
| ARMV6M (thumb) | ARMV6K (arm,thumb) | <- From ARMV6K and ARMV6M processors
+----------------+--------------------+    have support for hint instructions
| ARMV6T2 (arm,thumb,thumb2)          |    (SEV/WFE/WFI/NOP/YIELD). They can
+-------------------------------------+    be either real or default to NOP.
| ARMV7 (arm,thumb,thumb2)            |    The two processors also use
+-------------------------------------+    different encoding for them.

Patch by Vinicius Tinti.

llvm-svn: 232469
2015-03-17 11:55:43 +00:00
Yaron Keren 1ee89fc432 Teach Twine to support SmallString.
Enable removing .str() member calls for these frequent cases. 

 http://reviews.llvm.org/D6372

llvm-svn: 232465
2015-03-17 09:51:17 +00:00
Nick Lewycky 563dfdb111 Fix test in release mode.
llvm-svn: 232456
2015-03-17 02:31:46 +00:00
Richard Smith 15e32fd215 [modules] Fix bug where an anonymous namespace could cause the containing
namespace to not merge properly.

We have an invariant here: after a declaration reads its canonical declaration,
it can assume the canonical declaration is fully merged. This invariant can be
violated if deserializing some declaration triggers the deserialization of a
later declaration, because that later declaration can in turn deserialize a
redeclaration of that first declaration before it is fully merged.

The anonymous namespace for a namespace gets stored with the first declaration
of that namespace, which may be before its parent namespace, so defer loading
it until after we've finished merging the surrounding namespace.

llvm-svn: 232455
2015-03-17 02:23:11 +00:00
Nick Lewycky cf191adaf5 Fix the LLVM type used when lowering initializer list reference temporaries to global variables.
llvm-svn: 232454
2015-03-17 02:21:31 +00:00
Duncan P. N. Exon Smith a7fd07f3fc CodeGenCXX: Test that linetables work with variadic virtual thunks
Add a frontend test for PR22929, which was fixed by LLVM r232449.
Besides the crash test, check that the `!dbg` attachment is sane since
its presence was the trigger.

llvm-svn: 232450
2015-03-17 01:19:01 +00:00
Justin Bogner c0a4b59c2f Fix typo in previous commit
llvm-svn: 232440
2015-03-17 00:04:57 +00:00
Justin Bogner 4e46237c6d GCOV: Expose the -coverage-exit-block-before-body flag in clang -cc1
This exposes the optional exit block placement logic from r232438 as a
clang -cc1 option. There is a test on the llvm side, but there isn't
really a way to inspect the gcov options from clang to test it here as
well.

llvm-svn: 232439
2015-03-16 23:52:21 +00:00
Rafael Espindola 55cfaa2552 Update for llvm API change.
llvm-svn: 232430
2015-03-16 22:30:13 +00:00
Richard Trieu a1877598aa Take the non-reference type when constructing a dummy expression.
Otherwise, Expr will assert during construction with a reference type.

llvm-svn: 232425
2015-03-16 21:49:43 +00:00
Richard Smith e687bf83c0 [modules] If we find more formerly-canonical declarations of an entity while
building its redecl chains, make sure we pull in the redeclarations of those
canonical declarations.

It's pretty difficult to reach a situation where we can find more canonical
declarations of an entity while building its redecl chains; I think the
provided testcase (4 modules and 7 declarations) cannot be reduced further.

llvm-svn: 232411
2015-03-16 20:54:07 +00:00
Richard Smith 2095ffea41 Lambdaify some helper functions. No functionality change.
llvm-svn: 232407
2015-03-16 20:11:03 +00:00
Joerg Sonnenberger 1d3b431c98 Global inline assembler blocks are merged before parsing, so no specific
location data is available. If pragma handling wants to look up the
position, it finds the LLVM buffer and wants to compare it with the
special built-in buffer, failing badly. Extend to the special handling
of the built-in buffer to also check for the inline asm buffer. Expect
only a single asm buffer. Sort it between the built-in buffers and the
normal file buffers.

Fixes the assert part of PR 22576.

llvm-svn: 232389
2015-03-16 17:54:54 +00:00
Gabor Horvath 98bd098205 [clang] Replacing asserts with static_asserts where appropriate
Summary: This patch consists of the suggestions of clang-tidy/misc-static-assert check.

Reviewers: alexfh

Subscribers: dblaikie, xazax.hun, cfe-commits

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

Patch by Szabolcs Sipos!

llvm-svn: 232367
2015-03-16 09:59:54 +00:00
Alexander Musman 7931b98735 [OPENMP] Enable codegen of the ‘private’ clause for ‘omp simd’ directive
llvm-svn: 232353
2015-03-16 07:14:41 +00:00
Benjamin Kramer 6eb776547e SimpleArray: Provide reverse iteration via std::reverse_iterator.
NFC intended.

llvm-svn: 232330
2015-03-15 18:47:26 +00:00
Benjamin Kramer 15b9717873 Implement PreprocessingRecord's and LazyVector's iterators on top of iterator_adaptor_base
This basically creates a wrapper around an 'int' that poses as an iterator.
While that looks a bit counter-intuitive it works just fine because iterator
operations and basic integer arithmetic works in exactly the same way.

Remove the manual integer wrapping code and reduce the reliance on iterator
internals in the implementation. No functionality change intended.

llvm-svn: 232322
2015-03-15 15:27:19 +00:00
Daniel Jasper bc46b939e6 clang-format: [JS] support cast syntax and type arguments.
Casts in TS syntax (foo = <type>bar;) should not be followed by
whitespace.

Patch by Martin Probst. Thank you.

llvm-svn: 232321
2015-03-15 13:59:51 +00:00
Daniel Jasper 60948b12bb clang-format: [JS] more precisely detect enums.
The current enum detection is overly aggressive. As NestingLevel only
applies per line (?) it classifies many if not most object literals as
enum declarations and adds superfluous line breaks into them. This
change narrows the heuristic by requiring an assignment just before the
open brace and requiring the line to start with an identifier.

Patch by Martin Probst. Thank you.

llvm-svn: 232320
2015-03-15 13:55:54 +00:00
David Majnemer ad803d4b76 MS ABI: Don't use qualified pointee types for 'catch' EH TypeDescriptors
Qualifiers are located next to the TypeDescriptor in order to properly
ensure that a pointer type can only be caught by a more qualified catch
handler.  This means that a catch handler of type 'const int *' requires
an RTTI object for 'int *'.  We got this correct for 'throw' but not for
'catch'.

N.B.  We don't currently have the means to store the qualifiers because
LLVM's EH strategy is tailored to the Itanium scheme.  The Itanium ABI
stores qualifiers inside the type descriptor in such a way that the
manner of qualification is stored in addition to the pointee type's
descriptor.  Perhaps the best way of modeling this for the MS ABI is
using an aggregate type to bundle the qualifiers with the descriptor?
This is tricky because we want to make it clear to the optimization
passes which catch handlers invalidate other handlers.

My current thoughts on a design for this is along the lines of:
  { { TypeDescriptor* TD, i32 QualifierFlags }, i32 MiscFlags }

The idea is that the inner most aggregate is all that is needed to
communicate that one catch handler might supercede another.  The
'MiscFlags' field would be used to hold the bitpattern for the notion
that the 'catch' handler does not need to invoke a copy-constructor
because we are catching by reference.

llvm-svn: 232318
2015-03-15 07:10:01 +00:00
Dmitri Gribenko ad80af8f19 -Wempty-body: fix false negative triggered by macros
When if statement condition ended in a macro:

    if (ptr == NULL);

the check used to consider the definition location of NULL, instead of the
current line.

Patch by Manasij Mukherjee.

llvm-svn: 232295
2015-03-15 01:08:23 +00:00
David Majnemer 9ced3dd64c MS ABI: Tidy up references to the ASTContext
CGCXXABI has a handy getContext() method.  Use that instead of
explicitly going through the CodeGenModule.

llvm-svn: 232289
2015-03-14 23:44:48 +00:00
David Majnemer 8062eb6bed CodeGen: Correctly initialize bitfields with non-constant initializers
It is possible to construct an initializer for a bitfield which is not
constant.  Instead of emitting code to initialize the field before the
execution of main, clang would crash.

llvm-svn: 232285
2015-03-14 22:24:38 +00:00
Benjamin Kramer 0eb262fb28 Sort ObjCProtocolDecls with array_pod_sort.
The predicate is essentially a string comparison. NFC.

llvm-svn: 232264
2015-03-14 13:32:49 +00:00
Benjamin Kramer 5caa50e469 [analyzer] Sort path diagnostics with array_pod_sort.
They're expensive to compare and we won't sort many of them so std::sort
doesn't give any benefits and causes code bloat. Func fact: clang -O3 didn't
even bother to inline libc++'s std::sort here.

While there validate the predicate a bit harder, the sort is unstable and we
don't want to introduce any non-determinism. I had to spell out the function
pointer type because GCC 4.7 still fails to convert the lambda to a function
pointer :(

No intended functionality change.

llvm-svn: 232263
2015-03-14 12:39:22 +00:00
David Majnemer bc02d32f4d MS ABI: Mangle virtual member pointer thunks with the correct CC
Virtual member pointers are implemented using a thunk.  We assumed that
the calling convention for this thunk was always __thiscall for 32-bit
targets and __cdecl for 64-bit targets.  However, this is not the case.
Mangle in whichever calling convention is appropriate for this member
function thunk.

llvm-svn: 232254
2015-03-14 06:34:41 +00:00
Chandler Carruth 0d745bcf66 [modules] Teach the AST reader to handle the case of importing a module
with a subset of the existing target CPU features or mismatched CPU
names.

While we can't check that the CPU name used to build the module will end
up being able to codegen correctly for the translation unit, we actually
check that the imported features are a subset of the existing features.

While here, rewrite the code to use std::set_difference and have it
diagnose all of the differences found.

Test case added which walks the set relationships and ensures we
diagnose all the right cases and accept the others.

No functional change for implicit modules here, just better diagnostics.

llvm-svn: 232248
2015-03-14 04:47:43 +00:00
Peter Collingbourne d2926c91d5 Implement bad cast checks using control flow integrity information.
This scheme checks that pointer and lvalue casts are made to an object of
the correct dynamic type; that is, the dynamic type of the object must be
a derived class of the pointee type of the cast. The checks are currently
only introduced where the class being casted to is a polymorphic class.

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

llvm-svn: 232241
2015-03-14 02:42:25 +00:00
Ahmed Bougacha 5a4aa42a59 Add a bunch of missing "CHECK" colons in tests. NFC.
llvm-svn: 232237
2015-03-14 01:10:19 +00:00
David Majnemer 37fd66e78b MS ABI: Generate default constructor closures
The MS ABI utilizes a compiler generated function called the "vector
constructor iterator" to construct arrays of objects with
non-trivial constructors/destructors.  For this to work, the constructor
must follow a specific calling convention.  A thunk must be created if
the default constructor has default arguments, is variadic or is
otherwise incompatible.  This thunk is called the default constructor
closure.

N.B.  Default constructor closures are only generated if the default
constructor is exported because clang itself does not utilize vector
constructor iterators.  Failing to export the default constructor
closure will result in link/load failure if a translation unit compiled
with MSVC is on the import side.

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

llvm-svn: 232229
2015-03-13 22:36:55 +00:00
Robert Lougher 7607b918a7 Make tests more robust. No functional change.
In preparation for recommit of revision 232190, change tests so that they
are resilient to operands being commuted by the reassociate pass.

llvm-svn: 232206
2015-03-13 20:35:45 +00:00
David Majnemer ba3e5ecf07 MS ABI: Implement __GetExceptionInfo for std::make_exception_ptr
std::make_exception_ptr calls std::__GetExceptionInfo in order to figure
out how to properly copy the exception object.

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

llvm-svn: 232188
2015-03-13 18:26:17 +00:00
David Blaikie bdf40a62a7 Test case updates for explicit type parameter to the gep operator
llvm-svn: 232187
2015-03-13 18:21:46 +00:00
David Blaikie 81e96f8192 Update test case to make it easier to automatically port to typeless pointer gep operator changes coming soon
llvm-svn: 232185
2015-03-13 18:21:11 +00:00
Benjamin Kramer 1553727ed3 Sema: Replace the SetVector/DenseMap/std::sort combination with a simple std::map
This guarantees the order and doesn't increase malloc counts a lot as there are
typically very few elements int the map. Provide a little iterator adapter to
keep the same interface as we had with the flat sorted list.

No functional change intended.

llvm-svn: 232173
2015-03-13 16:10:42 +00:00
Daniel Jasper 0ab544f1a5 When building a module, all headers of submodules can be used.
This extends r232159.

llvm-svn: 232168
2015-03-13 14:29:39 +00:00
Daniel Jasper 9ecb0e96b8 clang-format: Don't corrupt macros with open braces.
Formatting:
  #define A { {
  #define B } }

Before:
  #define A               \
    {                     \
      { #define B }       \
    }

After:
  #define A               \
    {                     \
      {
  #define B               \
    }                     \
    }

This fixes llvm.org/PR22884.

llvm-svn: 232166
2015-03-13 13:32:11 +00:00
Alexey Bataev 1d160b1945 [OPENMP] Additional sema analysis for 'omp atomic[ update]'.
Adds additional semantic analysis + generation of helper expressions for proper codegen.

llvm-svn: 232164
2015-03-13 12:27:31 +00:00
Daniel Jasper b6ba46ef30 Make a module "use" also count as use of all its submodules
llvm-svn: 232159
2015-03-13 11:26:16 +00:00
Alexander Musman 21212e4198 [OPENMP] Re-factor __kmpc_for_static_init_* routine generation.
llvm-svn: 232154
2015-03-13 10:38:23 +00:00
Chandler Carruth c2132d8f33 [Modules] Teach Clang to survive ambiguous macros which come from system
headers even if they arrived when merging non-system modules.

The idea of this code is that we don't want to warn the user about
macros defined multiple times by their system headers with slightly
different definitions. We should have this behavior if either the
macro comes from a system module, or the definition within the module
comes from a system header. Previously, we would warn on ambiguous
macros being merged when they came from a users modules even though they
only showed up via system headers.

By surviving this we can handle common system header macro differences
like differing 'const' qualification of pointers due to some headers
predating 'const' being valid in C code, even when those systems headers
are pre-built into a system module.

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

llvm-svn: 232149
2015-03-13 08:29:54 +00:00
Argyrios Kyrtzidis ee1d76f361 [libclang] Fix crash when code-completing inside constructor initializer for a builtin type.
rdar://20149746

llvm-svn: 232145
2015-03-13 07:39:30 +00:00
Argyrios Kyrtzidis 58d0e7ab79 [libclang] During member ref expression visitation, ignore base anonymous struct/union fields.
Otherwise they will shadow the real field that that we are interested in.

rdar://19783938

llvm-svn: 232141
2015-03-13 04:40:07 +00:00
Richard Smith df8a83127f Deduplicate #undef directives imported from multiple modules.
No functionality change, but deeply-importing module files are smaller and
faster now.

llvm-svn: 232140
2015-03-13 04:05:01 +00:00
Joerg Sonnenberger dfd511e9bc Simplify.
llvm-svn: 232130
2015-03-13 00:54:30 +00:00
NAKAMURA Takumi 08b87a8c42 [CMake] Add clangBasic in ASTMatchersTests, according to r232051.
Jan Vesely noticed it. See also r232055.

llvm-svn: 232123
2015-03-12 23:49:06 +00:00
Benjamin Kramer 7f1f6b5370 Disambiguate call for GCC.
llvm-svn: 232122
2015-03-12 23:46:55 +00:00
Benjamin Kramer 51680bccda CodeGen: Base the conditional cleanup machinery on variadic templates
This is complicated by the fact that we can't simply use side-effecting
calls in an argument list without losing all guarantees about the order
they're emitted. To keep things deterministic we use tuples and brace
initialization, which thankfully guarantees evaluation order.

No functionality change intended.

llvm-svn: 232121
2015-03-12 23:41:40 +00:00
Daniel Jasper 55ca608cdc clang-format: [OBJC] Don't indent 8 spaces in method declarations.
Before:
  - (void)aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:
          (SoooooooooooooooooooooomeType *)bbbbbbbbbb;

After:
  - (void)aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:
      (SoooooooooooooooooooooomeType *)bbbbbbbbbb;

llvm-svn: 232112
2015-03-12 22:13:45 +00:00
Sanjay Patel 0a6da5de55 [X86, AVX2] Replace inserti128 and extracti128 intrinsics with generic shuffles
This is nearly identical to the v*f128_si256 parts of r231792 and r232052.

AVX2 introduced proper integer variants of the hacked integer insert/extract
C intrinsics that were created for this same functionality with AVX1.

This should complete the front end fixes for insert/extract128 intrinsics. 
Corresponding LLVM patch to follow.

llvm-svn: 232109
2015-03-12 21:54:24 +00:00
Benjamin Kramer 8cbf749690 Sema: Make BoundTypeDiagnoser a variadic template
llvm-svn: 232101
2015-03-12 20:58:06 +00:00
Nico Weber 3f8dafb021 Fix grammar in a comment, wrap to 80 columns. No behavior change.
llvm-svn: 232087
2015-03-12 19:37:10 +00:00