Commit Graph

36579 Commits

Author SHA1 Message Date
NAKAMURA Takumi 4a070dc428 [CMake] Reorder libdeps by alphabetical order.
llvm-svn: 212919
2014-07-14 04:59:27 +00:00
Richard Smith 19172c4f70 Superficial fix for PR20218: binding a function lvalue to a const reference to
a function pointer is neither better nor worse than binding a function lvalue
to a function rvalue reference. Don't get confused and think that both bindings
are binding to a function lvalue (which would make the lvalue form win); the
const reference is binding to an rvalue.

The "real" bug in PR20218 is still present: we're getting the wrong answer from
template argument deduction, and that's what leads us to this weird overload
set.

llvm-svn: 212916
2014-07-14 02:28:44 +00:00
David Majnemer b2615aa44d MS ABI: Stick internal vftables in a comdat if they have RTTI data
Previously, we would have a private backing variable and an internal
alias pointing at it.

However, -fdata-sections only fires if a global variable has non-private
linkage.  This means that an unreferenced vftable wouldn't get
discarded, bloating the object file.

Instead, stick the backing variable in a comdat even if the alias has
internal linkage.  This will allow the linker to drop the vftable if it
is unused.

llvm-svn: 212901
2014-07-13 05:19:56 +00:00
Saleem Abdulrasool 07257fe14e Headers: add hint intrinsics to arm_acle.h
This adds the ARM ACLE hint intrinsic wrappers to arm_acle.h.  These need to be
protected with a !defined(_MSC_VER) since MSVC (and thus clang in compatibility
mode) provide these wrappers as proper builtin intrinsics.

llvm-svn: 212891
2014-07-12 23:27:26 +00:00
Saleem Abdulrasool 572250d60a CodeGen: support hint intrinsics from ACLE on AArch64
This adds support for the ACLE hint intrinsics on AArch64 similar to ARM.  This
is required to properly support ACLE on AArch64.

llvm-svn: 212890
2014-07-12 23:27:22 +00:00
Yi Kong 4e00ce7d0c Improve comments of ARM ACLE header file and tests
Include section number in ARM ACLE specification for easier navigation.

llvm-svn: 212887
2014-07-12 22:48:13 +00:00
Hal Finkel d8442b1b21 Add nonnull in CodeGen for __attribute__((returns_nonnull))
As a follow-up to r212835, also add the LLVM nonnull function attribute when
__attribute__((returns_nonnull)) is provided.

llvm-svn: 212874
2014-07-12 04:51:04 +00:00
Alexey Samsonov 15c9669615 [ASan] Collect unmangled names of global variables in Clang to print them in error reports.
Currently ASan instrumentation pass creates a string with global name
for each instrumented global (to include global names in the error report). Global
name is already mangled at this point, and we may not be able to demangle it
at runtime (e.g. there is no __cxa_demangle on Android).

Instead, create a string with fully qualified global name in Clang, and pass it
to ASan instrumentation pass in llvm.asan.globals metadata. If there is no metadata
for some global, ASan will use the original algorithm.

This fixes https://code.google.com/p/address-sanitizer/issues/detail?id=264.

llvm-svn: 212872
2014-07-12 00:42:52 +00:00
Reid Kleckner f392ec6ecc Form a CallExpr from __noop without parens
MSVC accepts __noop without any trailing parens and treats it like a
literal zero.  We don't treat __noop as an integer literal, but now at
least we can parse a naked __noop expression.

Reviewers: rsmith

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

llvm-svn: 212860
2014-07-11 23:54:29 +00:00
Argyrios Kyrtzidis baa97663c2 [Driver] clang::driver::getARMCPUForMArch() moved to llvm::Triple::getARMCPUForArch().
Depends on llvm r212846.
Suggested by Eric Christopher.

llvm-svn: 212858
2014-07-11 23:47:48 +00:00
Alp Toker 5d96e0a3a7 Consolidate header inclusion diagnostics
Make argument orders match, unify diagnostic IDs and reword the message to be a
little less saccharine.

llvm-svn: 212845
2014-07-11 20:53:51 +00:00
David Majnemer 9b21c33da4 CodeGen: Don't emit a thread-wrapper if we can't touch the backing variable
OS X TLS has all accesses going through the thread-wrapper function and
gives the backing thread-local variable internal linkage.  This means
that thread-wrappers must have WeakAnyLinkage so that references to the
internal thread-local variables do not get propagated to other code.

It also means that translation units which do not provide a definition
for the thread-local variable cannot attempt to emit a thread-wrapper
because the thread wrapper will attempt to reference the backing
variable.

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

llvm-svn: 212841
2014-07-11 20:28:10 +00:00
Reid Kleckner ed5d4adb36 MS extension: Make __noop be the integer zero, not void
We still don't accept '__noop;', and we don't consider __noop to be the
integer literal zero.  More work is needed.

llvm-svn: 212839
2014-07-11 20:22:55 +00:00
Brad Smith 10cd0f457a Handle SPARC float command line parameters for SPARCv9.
llvm-svn: 212838
2014-07-11 20:12:08 +00:00
Richard Smith 547864d26a [modules] When merging a class template, also merge the definition of its pattern.
llvm-svn: 212836
2014-07-11 18:22:58 +00:00
Hal Finkel 82504f03ce Add nonnull in CodeGen for __attribute__((nonnull))
We now have an LLVM-level nonnull attribute that can be applied to function
parameters, and we emit it for reference types (as of r209723), but did not
emit it when an __attribute__((nonnull)) was provided. Now we will.

llvm-svn: 212835
2014-07-11 17:35:21 +00:00
Aaron Ballman 6288d0648a The returns_nonnull attribute does not require a function prototype because it affects only the return value, not any arguments. In turn, asking for a function or method result type should not require a function prototype either, so getFunctionOrMethodResultType has been relaxed.
llvm-svn: 212827
2014-07-11 16:31:29 +00:00
NAKAMURA Takumi ad4c06c656 Instantiate llvm::Registry<clang::PluginASTAction> in FrontendAction.cpp.
- Plugins don't need to export _ZN4llvm8Registry*.
  - Win32.DLL cannot merge common symbols among DLLs. Static members in llvm::Registry should be instantiated in a parent.

llvm-svn: 212821
2014-07-11 15:06:24 +00:00
Zinovy Nis 3d16387413 [PATCH] [x32] Introduce -mx32 flag enforcing x32 mode for other triplets. By Pavel Chupin (@pavel.v.chupin).
-mx32 flag setup target environment to GNUX32 and can be used for 
other 32/64-bit triplets (i386-unknown-linux, x86_64-unknown-linux) to
turn on x32 mode. Compatible with GCC -mx32 flag.

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

llvm-svn: 212817
2014-07-11 14:28:45 +00:00
Sylvestre Ledru 2fe501eef9 GCC compatibility: Create a Group to ignore unsupported optimization.
Returns a warning when using an unknown optimization flag.
This patch includes -finline-limit as one of those ignored flags.
More options will be moved in this group

Patch by Arthur Marble <arthur@info9.net> in the context of
Debian Google Summer of code 2014.

Reviewers: rnk, Sylvestre
llvm-svn: 212805
2014-07-11 11:43:57 +00:00
Alexey Bataev 9c2e8ee72f [OPENMP] Parsing and sema analysis for 'omp task' directive.
llvm-svn: 212804
2014-07-11 11:25:16 +00:00
Ben Langmuir e013bdc2e7 Don't assume StringRef.data() is null-terminated
llvm-svn: 212790
2014-07-11 00:43:47 +00:00
NAKAMURA Takumi 5787cc2ccf TestAfterDivZeroChecker.cpp: Avoid member initializer. It is unsupported in msc17.
llvm-svn: 212789
2014-07-11 00:32:35 +00:00
Richard Smith dc5523d38f [modules] Don't try to merge template specializations by performing name lookup
into their container; we won't find them there. These things are already being
merged when they're added to their primary template's folding set, so this
merging is redundant (and causes us to reject-valid because we think we've
found an odr violation).

llvm-svn: 212788
2014-07-11 00:20:06 +00:00
Reid Kleckner 675d438e23 Return a FixItHint instead of taking a diagnostic builder
Addressing review comments from r212784.

llvm-svn: 212786
2014-07-11 00:16:51 +00:00
Reid Kleckner 0902a51baf MSVC compat: Allow lookup of friend types in enclosing namespaces
The relevant portion of C++ standard says [namespace.memdef]p3:

  If the name in a friend declaration is neither qualified nor a
  template-id and the declaration is a function or an
  elaborated-type-specifier, the lookup to determine whether the entity
  has been previously declared shall not consider any scopes outside the
  innermost enclosing namespace.

MSVC does not implement that rule for types.  If there is a type in an
enclosing namespace, they consider an unqualified tag declaration with
the same name to be a redeclaration of the type from another namespace.

Implementing compatibility is a simple matter of disabling our
implementation of this rule for types, which was added in r177473.

Reviewers: rsmith

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

llvm-svn: 212784
2014-07-10 23:44:52 +00:00
Diego Novillo 94b276deba Enable -gcolumn-info by default.
This patch flips the default value for -gcolumn-info to be on by
default. I discussed the rationale and provided compile/size data
in:

http://lists.cs.uiuc.edu/pipermail/llvmdev/2014-June/074290.html

This also updates the documentation and some tests that relied on
the lack of column information. Some tests had column information
in the expected output, but it was wrong (the tsan tests). Others
were using the driver to execute.

llvm-svn: 212781
2014-07-10 23:29:28 +00:00
Richard Smith d9967cccfb Add AST dumping for VarDecl init kind.
llvm-svn: 212774
2014-07-10 22:54:03 +00:00
Alexey Samsonov 848560125d [UBSan] Introduce type-based blacklisting.
Teach UBSan vptr checker to ignore technically invalud down-casts on
blacklisted types.

Based on http://reviews.llvm.org/D4407 by Byoungyoung Lee!

llvm-svn: 212770
2014-07-10 22:34:19 +00:00
Alexey Samsonov b2cc23df20 Be more specific about return types of some methods.
This would allow to call addCompilerUsedGlobal on some
Clang-generated globals.

llvm-svn: 212767
2014-07-10 22:18:36 +00:00
Richard Smith 95b83e917e PR20256: don't accidentally instantiate non-dependent default-initialization as
value-initialization.

llvm-svn: 212764
2014-07-10 20:53:43 +00:00
David Blaikie 1b5adb82d9 Fix the dtor location issues in PR20038 harder.
Originally committed in r211722, this fixed one case of dtor calls being
emitted without locations (this causes problems for debug info if the
call is then inlined), this caught only some of the cases.

Instead of trying to re-enable the location before the cleanup, simply
re-enable the location immediately after the unconditional branches in
question using a scoped device to ensure the no-location state doesn't
leak out arbitrarily.

llvm-svn: 212761
2014-07-10 20:42:59 +00:00
David Blaikie 40f842de9c Remove use of uniform initialization ({}) introduced in r212725 since this isn't supported in MSVC.
llvm-svn: 212754
2014-07-10 18:46:15 +00:00
Ehsan Akhgari f3a896bd22 Avoid definining more GCC specific predefined macros in clang-cl
Reviewers: hansw, rnk

Subscribers: cfe-commits

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

llvm-svn: 212753
2014-07-10 18:44:24 +00:00
Ulrich Weigand 581badce4b [PowerPC] ABI support for aligned by-value aggregates
This patch adds support for respecting the ABI and type alignment
of aggregates passed by value.  Currently, all aggregates are aligned
at 8 bytes in the parameter save area.  This is incorrect for two
reasons:

- Aggregates that need alignment of 16 bytes or more should be aligned
  at 16 bytes in the parameter save area.  This is implemented by
  using an appropriate "byval align" attribute in the IR.

- Aggregates that need alignment beyond 16 bytes need to be dynamically
  realigned by the caller.  This is implemented by setting the Realign
  flag of the ABIArgInfo::getIndirect call.

In addition, when expanding a va_arg call accessing a type that is
aligned at 16 bytes in the argument save area (either one of the
aggregate types as above, or a vector type which is already aligned
at 16 bytes), code needs to align the va_list pointer accordingly.

Reviewed by Hal Finkel.

llvm-svn: 212743
2014-07-10 17:20:07 +00:00
Andy Gibbs c1f152ee6c Provide -verify support to match "any" line for diagnostics in included files.
Allow diagnostic checks that originate in included files to be matched without necessarily determining the line number that the diagnostic occurs on.  The new syntax replaces the line number with '*'.  This extension is limited to diagnostics in included files and may be used where the include file is not part of the test-suite itself.

Expected uses are for diagnostics originating in system headers, or for users who use -verify in testing 3rd-party library code where the location of diagnostics in header files may change from revision to revision and their precise location is not important to the success of the test-case.

llvm-svn: 212735
2014-07-10 16:43:29 +00:00
Ulrich Weigand f4eba98853 [PowerPC] ABI support for non-Altivec vector types
This patch adds support for passing arguments of non-Altivec vector type
(i.e. defined via attribute ((vector_size (...)))) on powerpc64-linux.

While such types are not mentioned in the formal ABI document, this
patch implements a calling convention compatible with GCC:

- Vectors of size < 16 bytes are passed in a GPR
- Vectors of size > 16 bytes are passed via reference

Note that vector types with a number of elements that is not a power
of 2 are not supported by GCC, so there is no pre-existing ABI to
follow.  We choose to pass those (of size < 16) as if widened to the
next power of two, so they might end up in a vector register or
in a GPR.  (Sizes > 16 are always passed via reference as well.)

Reviewed by Hal Finkel.

llvm-svn: 212734
2014-07-10 16:39:01 +00:00
Jordan Rose dc352bb82b [analyzer] Check for code testing a variable for 0 after using it as a denominator.
This new checker, alpha.core.TestAfterDivZero, catches issues like this:

  int sum = ...
  int avg = sum / count; // potential division by zero...
  if (count == 0) { ... } // ...caught here

Because the analyzer does not necessarily explore /all/ paths through a program,
this check is restricted to only work on zero checks that immediately follow a
division operation (/ % /= %=). This could later be expanded to handle checks
dominated by a division operation but not necessarily in the same CFG block.

Patch by Anders Rönnholm! (with very minor modifications by me)

llvm-svn: 212731
2014-07-10 16:10:52 +00:00
Zinovy Nis 6e3c63064a [Codestyle][x32] Cosmetic codestyle fix.
llvm-svn: 212728
2014-07-10 15:42:35 +00:00
Zinovy Nis 1db9573f03 [x32] Adding X32 target support to driver, including TargetInfo,DescriptionString, flags, paths lookup, etc. Cover changes with new tests. The author of the patch is Pavel Chupin (@pavel.v.chupin).
The changes enable "hello world" on x32 target (x86_64-*-linux-gnux32). s/isX32/IsX32/ also fixed.

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

llvm-svn: 212725
2014-07-10 15:27:19 +00:00
Daniel Sanders 2bf1366ca6 [mips][mips64r6] Add support for mips-img-linux-gnu GCC toolchains
Summary:
* Support the multilib layout used by the mips-img-linux-gnu
* Recognize mips{,64}{,el}-img-linux-gnu as being aliases of mips-img-linux-gnu
* Use the correct dynamic linker for mips-img-linux-gnu
* Make mips32r6/mips64r6 the default CPU for mips-img-linux-gnu

Subscribers: mpf

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

llvm-svn: 212719
2014-07-10 14:40:57 +00:00
Daniel Sanders 28e5d39183 [mips] Add support for -modd-spreg/-mno-odd-spreg
Differential Revision: http://reviews.llvm.org/D4432

llvm-svn: 212700
2014-07-10 10:39:51 +00:00
Viktor Kutuzov 63537656c6 Add clang headers that fix machine-dependent definitions on FreeBSD 9.2
Differential Revision: http://reviews.llvm.org/D3908

llvm-svn: 212689
2014-07-10 08:43:39 +00:00
Reid Kleckner 677539d0af MS ABI: Fix __fastcall methods that return structs
The sret paramater consumes the register after the implicit 'this'
parameter, as with other calling conventions.

Fixes PR20278, which turned out to be very easy.

llvm-svn: 212669
2014-07-10 01:58:55 +00:00
Richard Smith 8b4e1e2c8d Cleanup. No functionality change.
llvm-svn: 212667
2014-07-10 01:20:17 +00:00
Argyrios Kyrtzidis 1b49db6035 [Driver] Expose getARMCPUForMArch() function in the Driver API; NFC.
llvm-svn: 212666
2014-07-10 01:03:37 +00:00
Alexey Samsonov b7dd329f2f Decouple llvm::SpecialCaseList text representation and its LLVM IR semantics.
Turn llvm::SpecialCaseList into a simple class that parses text files in
a specified format and knows nothing about LLVM IR. Move this class into
LLVMSupport library. Implement two users of this class:
  * DFSanABIList in DFSan instrumentation pass.
  * SanitizerBlacklist in Clang CodeGen library.
The latter will be modified to use actual source-level information from frontend
(source file names) instead of unstable LLVM IR things (LLVM Module identifier).

Remove dependency edge from ClangCodeGen/ClangDriver to LLVMTransformUtils.

No functionality change.

llvm-svn: 212643
2014-07-09 19:40:08 +00:00
David Majnemer 837d5de330 Sema: Allow aliases to have incomplete type
gcc supports this behavior and it is pervasively used inside the Linux
kernel.

Note that both gcc and clang will reject code that attempts to do this
in a C++ language mode.

This fixes PR17998.

llvm-svn: 212631
2014-07-09 17:15:52 +00:00
Alp Toker 9907f08e61 Fix 'source-level' hyphenations
llvm-svn: 212621
2014-07-09 14:06:35 +00:00
Alp Toker 61dad75b10 cc1as: consolidate option flags with cc1 and eliminate duplication
The clang -cc1as options are nearly a strict subset of -cc1. Instead of
duplicating the definitions and documentation, let's go ahead and share the
definitions in a similar way the current handling of combined driver and
frontend flags, eliminating some of the vestigial legacy surrounding the
assembler subcommand.

llvm-svn: 212620
2014-07-09 14:05:11 +00:00
Daniel Sanders 9500d2d751 [mips][mips64r6] Define _MIPS_FPSET, __mips_fpr, and __mips_nan2008 correctly on MIPS32r6/MIPS64r6
Summary:
This removes the need to pass -mnan=2008 explicitly to be able to compile
the test-suite for MIPS32r6/MIPS64r6.

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

llvm-svn: 212619
2014-07-09 13:56:23 +00:00
Daniel Sanders cfbb71dfb6 [mips] clz is defined to give 32 for zero. Similarly, dclz gives 64.
Summary:
While debugging another issue, I noticed that Mips currently specifies that the
count leading zero builtins are undefined when the input is zero. The
architecture specifications say that the clz and dclz instructions write 32 or
64 respectively when given zero.

This doesn't fix any bugs that I'm aware of but it may improve optimisation in
some cases.

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

llvm-svn: 212618
2014-07-09 13:43:19 +00:00
Daniel Jasper 85bcadcdc6 clang-format: Fix behavior around pointer-to-member invocations.
Before:
  (aaaaaaaaaa->*
   bbbbbbb)(aaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaa));

After:
  (aaaaaaaaaa->*bbbbbbb)(
      aaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaa));

llvm-svn: 212617
2014-07-09 13:07:57 +00:00
Tim Northover e8c3721165 ARM: use LLVM's atomicrmw instructions when ldrex/strex are available.
Having some kind of weird kernel-assisted ABI for these when the
native instructions are available appears to be (and should be) the
exception; OSs have been gradually opting in for years and the code
was getting silly.

So let LLVM decide whether it's possible/profitable to inline them by
default.

Patch by Phoebe Buckheister.

llvm-svn: 212598
2014-07-09 09:24:43 +00:00
Daniel Jasper c75e1effed clang-format: Add new option to indent wrapped function declarations.
Though not completely identical, make former
IndentFunctionDeclarationAfterType change this flag for backwards
compatibility (it is somewhat close in meaning and better the err'ing on
an unknown config flag).

llvm-svn: 212597
2014-07-09 08:42:42 +00:00
Daniel Jasper 4355e7f0ef clang-format: Revamp function declaration/definition indentation.
Key changes:
- Correctly (well ...) distinguish function declarations and variable
  declarations with ()-initialization.
- Don't indent when breaking function declarations/definitions after the
  return type.
- Indent variable declarations and typedefs when breaking after the
  type.

This fixes llvm.org/PR17999.

llvm-svn: 212591
2014-07-09 07:50:33 +00:00
Nikola Smiljanic 1c1256830d Fix typos.
llvm-svn: 212589
2014-07-09 05:42:35 +00:00
Alp Toker 4ea0d2389b Simplify warning flag value handling from r206826
Also give the field it a more appropriate name and improve the docs.

llvm-svn: 212584
2014-07-09 01:37:24 +00:00
Nico Weber 9709ebfaf0 rewrap to 80 cols, no behavior change
llvm-svn: 212578
2014-07-08 23:54:25 +00:00
Nico Weber 3c68ee95ca rewrap to 80 cols, no behavior change
llvm-svn: 212574
2014-07-08 23:46:20 +00:00
Reid Kleckner fd068271e6 MS compat: Allow lookup of types from dependent bases in functions
If we want to resolve the remaining FIXMEs here, we probably want to
extend the main lookup mechanism to perform lookup into dependent bases,
but we would have to tread lightly.  Adding more name lookup has major
impact on compile time.

If we did extend the main mechanism, we would add a flag to LookupResult
that allows us to find names from dependent base classes where the base
is a specialization of a known template.  The final LookupResult would
still return LookupResult::NotFoundInCurrentInstantiation, but it would
have a collection of Decls.  If we find a real lookup result, we would
clear the flag and the existing lookup results and begin accumulating
only real lookup results.

We would structure the lookup as a secondary lookup between normal
lookup and typo correction for normal compilation, but for MSVC
compatibility mode, we would always enable this extra lookup into
dependent bases.

llvm-svn: 212566
2014-07-08 21:35:03 +00:00
Alexey Samsonov cb1ad6f582 Remove unnecessary check for NULL
llvm-svn: 212564
2014-07-08 20:23:18 +00:00
Reid Kleckner 1ba38f8879 Allow more lookup of types in dependent base classes
MSVC appears to perform name lookup into dependent base classes when the
dependent base class has a known primary template.  This allows them to
know whether some unqualified ids are types or not, which allows them to
parse more class templates without typename keywords.

We can do the same thing when type name lookup fails, and if we find a
single type decl in one of our dependent base classes, recover as though
the user wrote 'typename MyClass::TypeFromBase'.

This allows us to parse some COM smart pointer classes in wrl/client.h
from the Windows 8 SDK.

Reviewers: rsmith

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

llvm-svn: 212561
2014-07-08 20:05:48 +00:00
Nico Weber a62cffae52 Don't pull in setjmp.h in -ffreestanding compiles.
Also provide _setjmpex(). r200243 put in _setjmp() and _setjmpex() behind a
comment since jmp_buf wasn't available. r200344 added jmp_buf and put in
_setjmp(), but missed _setjmpex().

llvm-svn: 212557
2014-07-08 18:34:46 +00:00
Nico Weber 1287091373 Replace a few // comments with /**/ comments in headers, for consistency.
llvm-svn: 212556
2014-07-08 18:29:27 +00:00
David Majnemer 03f705fe92 Sema: Don't allow CVR qualifiers before structors
We would silently accept volatile ~S() when the user probably intended
to write virtual ~S().

This fixes PR20238.

llvm-svn: 212555
2014-07-08 18:18:04 +00:00
Richard Smith 1133085461 PR20227: materialize a temporary when dynamic_casting a class prvalue to a
reference type.

llvm-svn: 212551
2014-07-08 17:25:14 +00:00
Benjamin Kramer ce416398ef Turn some Twine locals into const char * variables.
No functionality change, just stylistic cleanup. Change made by clang-tidy
and clang-format.

llvm-svn: 212544
2014-07-08 16:07:36 +00:00
David Blaikie 326ffb3683 Improve memory ownership of vfs::Files in the FileSystemStatCache by using std::unique_ptr
Spotted after a memory leak (due to the complexities of manual memory
management) was fixed in 212466.

llvm-svn: 212541
2014-07-08 15:46:02 +00:00
Richard Sandiford dcb8d9cc80 Move misplaced x86_32 ABI code
r184166 added an X86_32 function in the middle of the SystemZ code.
The SystemZ port had been added only a couple of weeks earlier and
the original patch probably predated that.

No behavioral change intended.

llvm-svn: 212524
2014-07-08 11:10:34 +00:00
Alexey Bataev 84d0b3efee [OPENMP] Parsing and sema analysis for 'omp parallel sections' directive.
llvm-svn: 212516
2014-07-08 08:12:03 +00:00
Saleem Abdulrasool c4ebb129b7 Headers: conditionalise more declarations
Protect MMX specific declarations under a __MMX__ guard.  This header can be
included on non-x86 architectures (e.g. ARM) which do not support the MMX ISA.
Use the preprocessor to prevent these declarations from being processed.

llvm-svn: 212512
2014-07-08 05:46:04 +00:00
Saleem Abdulrasool 60df0615b6 Headers: mark arm_acle.h with extern "C"
Although the functions are marked as always_inline, the compiler with which they
are used may not honour the extended attributes and emit them as functions.  In
such a case, indicate that they should have extern "C" linkage and should not be
mangled in C++ style if used within C++.

llvm-svn: 212511
2014-07-08 05:46:00 +00:00
Reid Kleckner afba553ede MS ABI: "Fix" passing non-POD structs by value to variadic functions
Of course, such code is horribly broken and will explode on impact.
That said, ATL does it, and we have to support them, at least a little
bit.

Fixes PR20191.

llvm-svn: 212508
2014-07-08 02:24:27 +00:00
Alexey Samsonov c94285a1a0 [ASan] Completely remove sanitizer blacklist file from instrumentation pass.
All blacklisting logic is now moved to the frontend (Clang).
If a function (or source file it is in) is blacklisted, it doesn't
get sanitize_address attribute and is therefore not instrumented.
If a global variable (or source file it is in) is blacklisted, it is
reported to be blacklisted by the entry in llvm.asan.globals metadata,
and is not modified by the instrumentation.

The latter may lead to certain false positives - not all the globals
created by Clang are described in llvm.asan.globals metadata (e.g,
RTTI descriptors are not), so we may start reporting errors on them
even if "module" they appear in is blacklisted. We assume it's fine
to take such risk:
  1) errors on these globals are rare and usually indicate wild memory access
  2) we can lazily add descriptors for these globals into llvm.asan.globals
     lazily.

llvm-svn: 212505
2014-07-08 00:50:49 +00:00
Alp Toker d920b7fc85 Rename static function to better describe its purpose
llvm-svn: 212502
2014-07-08 00:02:05 +00:00
Alexey Samsonov ac4afe49e7 [Sanitizer] Remove brittle cache variable and slightly simplify blacklisting code.
Now CodeGenFunction is responsible for looking at sanitizer blacklist
(in CodeGenFunction::StartFunction) and turning off instrumentation,
if necessary.

No functionality change.

llvm-svn: 212501
2014-07-07 23:59:57 +00:00
Alexey Samsonov e7a8ccfaad [Sanitizer] Reduce the usage of sanitizer blacklist in CodeGenModule
Get rid of cached CodeGenModule::SanOpts, which was used to turn off
sanitizer codegen options if current LLVM Module is blacklisted, and use
plain LangOpts.Sanitize instead.

1) Some codegen decisions (turning TBAA or writable strings on/off)
   shouldn't depend on the contents of blacklist.

2) llvm.asan.globals should *always* be created, even if the module
   is blacklisted - soon Clang's CodeGen where we read sanitizer
   blacklist files, so we should properly report which globals are
   blacklisted to the backend.

llvm-svn: 212499
2014-07-07 23:34:34 +00:00
Joe Groff 98ac7d2d35 ASTContext: Factor 'getObjCEncodingForPropertyType' as its own method.
It is useful to get the property encoding for an ObjC type without a full
ObjCPropertyDecl.

llvm-svn: 212496
2014-07-07 22:25:15 +00:00
Justin Bogner 761439962b Driver: Fix think-o in adding -ivfsoverlay flag to crashdumps
If there isn't a VFS to overlay we shouldn't be adding a -ivfsoverlay
flag.

llvm-svn: 212468
2014-07-07 17:34:40 +00:00
Manuel Klimek 1f6f6e60ad Fix memory leak in FileSystemStatCache.
Patch by Guochun Shi.

llvm-svn: 212466
2014-07-07 17:00:49 +00:00
Anders Carlsson 1a9fe3d4db Handle __builtin_clzs and __builtin_ctzs in the constant expression evaluator.
llvm-svn: 212464
2014-07-07 15:53:44 +00:00
David Majnemer ccef89db65 MS ABI: Don't unnecessarily use CGM abstraction
If we are in MicrosoftCXXABI, we don't need to use CGM to get a
TypeDescriptor.

llvm-svn: 212463
2014-07-07 15:29:16 +00:00
David Majnemer 26a90f85f7 Fix comment typo.
No functionality changed.

llvm-svn: 212462
2014-07-07 15:29:10 +00:00
Alp Toker 2584735846 PTH: use a variable instead of a macro
Cleanup only.

llvm-svn: 212457
2014-07-07 14:01:37 +00:00
Alexey Bataev 4acb859fbd [OPENMP] Added initial support for 'omp parallel for'.
llvm-svn: 212453
2014-07-07 13:01:15 +00:00
Alp Toker 9e0523d749 Move ChainedIncludesSource into the implementation
This doesn't need to be in the headers.

llvm-svn: 212451
2014-07-07 11:07:10 +00:00
Alp Toker 7eb95e21d7 ChainedIncludesSource: avoid copying n*(n+1)/2 file contents into memory
Just reference the data instead with shallow MemoryBuffer instances.

llvm-svn: 212450
2014-07-07 11:06:51 +00:00
Tobias Grosser 889c71e90f Revert "Add lib/Codgen/[CGRTTI|MicrosoftRTTI].cpp to CMakeLists.txt (r212445)"
I misidentified the problem and did not test suffifiently. The files had
correctly been removed, but for some reason they still remained in my git
checkout. Not adding the files back to CMakeLists.txt, but rather removing
the stale files was the solution. Sorry for the unnecessary noise.

llvm-svn: 212446
2014-07-07 09:39:09 +00:00
Tobias Grosser e680eaf9e6 Add lib/Codgen/[CGRTTI|MicrosoftRTTI].cpp to CMakeLists.txt
This fixes the cmake builds.

llvm-svn: 212445
2014-07-07 09:23:06 +00:00
Alp Toker 03376dc2c5 Switch over a few uses of param_begin() to parameters()
llvm-svn: 212442
2014-07-07 09:02:20 +00:00
Alp Toker 221285bde7 Remove unused sys/stat.h includes
The facility was abstracted to LLVM in r187364.

llvm-svn: 212441
2014-07-07 08:37:15 +00:00
David Majnemer 611cdb9a63 CodeGen: Cleanup MS ABI RTTI LLVM IR
The MS ABI RTTI emission code would choose names for IR types like
%"MSRTTITypeDescriptor\02".  This name is undesirable because it
requires escaping; the underlying reason for this is that the name is
unprintable.  Fix this by naming it %rtti.TypeDescriptor2.

While here, stop trying to do lookups in the LLVM Module's type table.
Instead, store the IR types in MicrosoftCXXABI.  Lookups by name aren't
particularly fast.

llvm-svn: 212439
2014-07-07 08:09:15 +00:00
Alp Toker 1b070d25ca Peel away old-style file remapping typedefs and cruft
llvm-svn: 212438
2014-07-07 07:47:20 +00:00
Richard Smith a9a1c68a1b Fix an iterator invalidation issue: deserializing a key function can write to
the key functions table. Don't hold references to anything within that table
across such an access.

llvm-svn: 212437
2014-07-07 06:38:20 +00:00
David Majnemer f456e44211 StaticAnalyzer: Silence a warning
ExprEngine wasn't ready for SEHLeaveStmtClass.  Handle it like all the
other SEH constructs by aborting.

llvm-svn: 212436
2014-07-07 06:20:50 +00:00
David Majnemer e2cb8d198f CodeGen: Refactor RTTI emission
Let's not expose ABI specific minutia inside of CodeGenModule and Type.
Instead, let's abstract it through CXXABI.

This gets rid of:
CodeGenModule::getCompleteObjectLocator,
CodeGenModule::EmitFundamentalTypeDescriptor{s,},
CodeGenModule::getMSTypeDescriptor,
CodeGenModule::getMSCompleteObjectLocator,
CGCXXABI::shouldRTTIBeUnique,
CGCXXABI::classifyRTTIUniqueness.

CGRTTI was *almost* entirely centered around providing Itanium-style
RTTI information.  Instead of providing interfaces that only it
consumes, move it to the ItaniumCXXABI implementation file.  This allows
it to have access to Itanium-specific implementation details without
providing useless expansion points for the Microsoft ABI side.

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

llvm-svn: 212435
2014-07-07 06:20:47 +00:00
Alp Toker c358000ed3 Fix layering of file remapping and header search initialization
These two functions initialize the source manager and header search objects and
shouldn't be in InitPreprocessor which is concerned with priming the
preprocessor itself and predefining macros.

llvm-svn: 212434
2014-07-07 06:05:00 +00:00
Richard Smith 22a5d61b5d Add an explicit diagnostic for the case where an expression is not a constant
expression because it uses 'this'. Inspired by PR20219 comment#2.

llvm-svn: 212433
2014-07-07 06:00:13 +00:00
Richard Smith 45d099b995 Cleanup. No functionality change intended.
llvm-svn: 212432
2014-07-07 05:36:14 +00:00
Nico Weber 9b982078e9 Add an AST node for __leave statements, hook it up.
Codegen is still missing (and I won't work on that), but __leave is now
as implemented as __try and friends.

llvm-svn: 212425
2014-07-07 00:12:30 +00:00
Nico Weber eb61d4d7c2 Sema: Check that __leave is contained in a __try block.
Give scope a SEHTryScope bit, set that in ParseSEHTry(), and let Sema
walk the scope chain to find the SEHTry parent on __leave statements.
(They are rare enough that it seems better to do the walk instead of
giving Scope a SEHTryParent pointer -- this is similar to AtCatchScope.)

llvm-svn: 212422
2014-07-06 22:53:19 +00:00
Nico Weber c7d0596429 Add parser support for __leave (sema and onward still missing).
llvm-svn: 212421
2014-07-06 22:32:59 +00:00
Rafael Espindola 2d2b420ab9 Update for llvm api change.
llvm-svn: 212408
2014-07-06 17:43:24 +00:00
Alp Toker 452bfcf00c PlistSupport.h: avoid gcc 'defined but not used' warning
llvm-svn: 212396
2014-07-06 07:59:14 +00:00
Alp Toker dbb0c75977 Modernize a couple of loops
llvm-svn: 212394
2014-07-06 06:09:20 +00:00
Ehsan Akhgari 0f89fac7a5 Add support for nested blocks in Microsoft inline assembly
This fixes http://llvm.org/PR20204.

llvm-svn: 212389
2014-07-06 05:26:54 +00:00
Alp Toker 80758084f7 Use non-intrusive refcounting for TargetOptions
llvm-svn: 212388
2014-07-06 05:26:44 +00:00
Alp Toker 269d840e40 Use non-intrusive refcounting for LangOptions
This type is only refcounted in a couple of places so making ownership explicit
improves clarity.

llvm-svn: 212387
2014-07-06 05:26:07 +00:00
Alp Toker 74437975c4 Constify a read-only parameter and give function a better name
This makes it clear that TargetInfo doesn't capture the LangOptions object,
rather uses it to apply adjustments.

llvm-svn: 212386
2014-07-06 05:14:24 +00:00
Alp Toker 069736222b writeARCDiagsToPlist(): make sure all diag levels get handled
Handle 'remark' level diagnostics as warnings instead of supplemental notes,
and use a covered switch to ensure the mapping is kept up to date.

llvm-svn: 212385
2014-07-06 04:27:03 +00:00
Alp Toker 525fdfc11e Use PlistSupport in a few more places
Switch over LogDiagnosticPrinter and introduce an integer helper.

llvm-svn: 212384
2014-07-06 04:26:52 +00:00
Nico Weber 2582895832 clang-cl: /showIncludes output should go to stdout, not stderr. Fixes PR20217.
llvm-svn: 212383
2014-07-06 03:04:24 +00:00
Alp Toker 37da619d34 Remove leftovers of '-arcmt-modify-in-memory' from r133315
llvm-svn: 212381
2014-07-05 22:12:36 +00:00
Saleem Abdulrasool e700cab4e9 CodeGen: add support for a few MSVC ARM intrinsics
This adds support for simple MSVC compatibility mode intrinsics.  These
intrinsics are simple in that they are either directly passed through to the
annotated MSBuiltin intrinsic or they mirror existing GCC builtins.

llvm-svn: 212378
2014-07-05 20:10:05 +00:00
Alp Toker f994cef836 Track IntrusiveRefCntPtr::get() changes from LLVM r212366
llvm-svn: 212369
2014-07-05 03:08:06 +00:00
Saleem Abdulrasool 96bfda8dbc CodeGen: add support for MSBuiltin aliases
This completes the infrastructure for the new MSBuiltin aliases in the
instruction definitions.  These behave similar to the GCCBuiltin in that they
can be implicitly constructed without special handling unless needed.

With this change it is possible to annotate an LLVM intrinsic in the backend
instruction definitions and indicate it as a builtin in the Builtin*.def files
in clang via LANGBUILTIN.  That will automatically pass through the instruction
much as a GCCBuiltin.

Note that there is no need for the special handling for ensuring that the
compatibility flag is enabled since the filtering on the LANGBUILTIN will
automatically prevent the intrinsic from bleeding into non-MS compatible
compiler invocations.

llvm-svn: 212359
2014-07-04 21:49:39 +00:00
Simon Atanasyan 4e16a4250d [Driver][Mips] Support one more MIPS CPU name - octeon.
llvm-svn: 212339
2014-07-04 12:37:04 +00:00
Simon Atanasyan 26610c5960 [Driver][Mips] Support more MIPS CPU names: mips1 - mips5.
llvm-svn: 212338
2014-07-04 12:36:56 +00:00
Fariborz Jahanian a99119a18b Make a small crash preventing change.
llvm-svn: 212291
2014-07-03 21:06:20 +00:00
Yi Kong 4efadfb0b0 [ARM] Implement ISB memory barrier intrinsic
Adds support for __builtin_arm_isb. Also corrects DSB and ISB instructions
modelling by adding has-side-effects property.

llvm-svn: 212277
2014-07-03 16:01:25 +00:00
Renato Golin 47843efcf6 Add the __qdbl intrinsic to the arm_acle.h header
Patch by: Moritz Roth

llvm-svn: 212264
2014-07-03 10:14:52 +00:00
Robert Lytton 57765d5347 Move the calling of emitTargetMD() later.
Summary:
Because a global created by GetOrCreateLLVMGlobal() is not finalised until later viz:
  extern char a[];
  char f(){ return a[5];}
  char a[10];

Change MangledDeclNames to use a MapVector rather than a DenseMap so that the
Metadata is output in order of original declaration, so to make deterministic
and improve human readablity.

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

llvm-svn: 212263
2014-07-03 09:30:33 +00:00
Robert Lytton 5b88f78f7a refactor for-loop as range-loop before making changes.
Differential Revision: http://reviews.llvm.org/D4176

llvm-svn: 212262
2014-07-03 09:30:29 +00:00
Christian Pirker c3d3217525 ARMEB: Fix function result return for composite types
Reviewed at http://reviews.llvm.org/D4364

llvm-svn: 212261
2014-07-03 09:28:12 +00:00
Simon Atanasyan 6b3544eb1d [Driver][Mips] Check MIPS CPU name provided to the Clang driver.
llvm-svn: 212260
2014-07-03 08:31:23 +00:00
David Majnemer 93de4b1608 MS ABI: Get linkage of RTTI data correct
The Itanium rules are not appropriate for the MS ABI.  RTTI data is
_never_ imported and thus is never available_externally.  It is either
internal (if the type's linkage is internal) or linkonce_odr.

This also means that classes which inherit from dllimport'd bases force
their translation unit to duplicate the entirety of the RTTI data of
that base.

Interestingly, the complete object locator can never be referenced by
translation units which import the class.

This fixes PR20106.

llvm-svn: 212256
2014-07-03 05:51:27 +00:00
Saleem Abdulrasool ece7217f70 ARM: rename ARM builtins to use __builtin_arm prefix
This corrects SVN r212196's naming change to use the proper prefix of
`__builtin_arm_` instead of `__builtin_`.

Thanks to Yi Kong for pointing out the incorrect naming!

llvm-svn: 212253
2014-07-03 02:43:20 +00:00
Nico Weber 5752ad0abc Address review feedback for r212238.
Also, forgot to say in the commit message of r212238: Library authors will
see a warning about this issue if they build with -Wsystem-headers.

llvm-svn: 212243
2014-07-03 00:38:25 +00:00
Nico Weber bcb70eee1a Enable clang to continue to parse libstdc++4.6 and stlport after r210091.
r210091 made initialization checking more strict in c++11 mode. LWG2193 is
about changing standard libraries to still be valid under these new rules,
but older libstdc++ (e.g. libstdc++4.6 in -D_GLIBCXX_DEBUG=1 mode, or stlport)
do not implement that yet.  So fall back to the C++03 semantics for container
classes in system headers below the std namespace.

llvm-svn: 212238
2014-07-02 23:51:09 +00:00
Larisse Voufo 5899e19def Fix linkage bug that miscompiled variable templates instantiated from similarly named local types. In essence, this bug ensures that the x<Foo> specialization in function foo() defined as follows differs between two distinct translation units.
static int &foo() {
       struct Foo { };
       return x<Foo>;
    }

llvm-svn: 212233
2014-07-02 23:08:34 +00:00
Saleem Abdulrasool 4bddd9d400 CodeGen: make target builtins support languages
This extends the target builtin support to allow language specific annotations
(i.e. LANGBUILTIN).  This is to allow MSVC compatibility whilst retaining the
ability to have EABI targets use a __builtin_ prefix.  This is merely to allow
uniformity in the EABI case where the unprefixed name is provided as an alias in
the header.

llvm-svn: 212196
2014-07-02 17:41:27 +00:00
Alp Toker 379b97f285 ARCMigrate: simplify diagnostic handling
Recent enhancements in the diagnostics engine mean that
TransformActions::report() no longer needs to duplicate this suppression logic.

That's great because the old code was flawed and would have attached notes to
the wrong primary diagnostic in non-trivial use.

With these changes it becomes safe to use reportNote() freely in the migration
tool.

llvm-svn: 212191
2014-07-02 17:08:00 +00:00
Alexey Samsonov 4f319cca42 [ASan] Print exact source location of global variables in error reports.
See https://code.google.com/p/address-sanitizer/issues/detail?id=299 for the
original feature request.

Introduce llvm.asan.globals metadata, which Clang (or any other frontend)
may use to report extra information about global variables to ASan
instrumentation pass in the backend. This metadata replaces
llvm.asan.dynamically_initialized_globals that was used to detect init-order
bugs. llvm.asan.globals contains the following data for each global:
  1) source location (file/line/column info);
  2) whether it is dynamically initialized;
  3) whether it is blacklisted (shouldn't be instrumented).

Source location data is then emitted in the binary and can be picked up
by ASan runtime in case it needs to print error report involving some global.
For example:

  0x... is located 4 bytes to the right of global variable 'C::array' defined in '/path/to/file:17:8' (0x...) of size 40

These source locations are printed even if the binary doesn't have any
debug info.

This is an ABI-breaking change. ASan initialization is renamed to
__asan_init_v4(). Pre-built libraries compiled with older Clang will not work
with the fresh runtime.

llvm-svn: 212188
2014-07-02 16:54:41 +00:00
Yaron Keren 672efea2e9 Added standard macro guard. In case __GNUC_VA_LIST was not
defined or defined identically before there will not be any
change in functionality.

MinGW-w64 defines __GNUC_VA_LIST as

  #define __GNUC_VA_LIST
  
which is different than the definition here, causing
a warning without the guard.
 

llvm-svn: 212183
2014-07-02 15:25:03 +00:00
Simon Atanasyan a42a84e44c [Driver][Mips] If ABI name is not provided deduce it from the target triple
not from the CPU name. This approach is closer to the method used by gcc driver.

llvm-svn: 212176
2014-07-02 13:20:36 +00:00
Tim Northover 3acd6bd0b6 ARM: add support for v8 ldaex/stlex builtins.
ARMv8 adds (to both AArch32 and AArch64) acquiring and releasing
variants of the exclusive operations, in line with the C++11 memory
model.

This adds support for two new intrinsics to expose them to C & C++
developers directly: __builtin_arm_ldaex and __builtin_arm_stlex, in
direct analogy with the versions with no implicit barrier.

rdar://problem/15885451

llvm-svn: 212175
2014-07-02 12:56:02 +00:00
Alp Toker f5b107940a Make FunctionDecl::getReturnTypeSourceRange() support non-builtin types
Also document that the function is a "best-effort" facility to extract source
ranges from limited AST type location info.

llvm-svn: 212174
2014-07-02 12:55:58 +00:00
Tim Northover 1471cb17ae X86: inline all atomic operations up to 128-bits.
The backend *can* cope with all of these now, so Clang should give it the
chance. On CPUs without cmpxchg16b (e.g. the original athlon64) LLVM can reform
the libcalls.

rdar://problem/13496295

llvm-svn: 212173
2014-07-02 10:25:45 +00:00
Alp Toker 70fc29ca86 Don't accept qualified 'int' main return types in C++ or standard C mode
C++ [basic.start.main]p1: "It shall have a return type of type int"

ISO C is also clear about this, so only accept 'int' with qualifiers in GNUMode
C.

llvm-svn: 212171
2014-07-02 07:07:20 +00:00
Alexey Bataev a15539498a [OPENMP, C++11] Improve code of InitVLACaptures function.
llvm-svn: 212162
2014-07-02 05:15:00 +00:00
Richard Trieu dadefde294 Prevent Clang from crashing on template code.
Fixes PR20110, where Clang hits an assertion failure when it expects that the
sub-expression of a bit cast to pointer to also be a pointer, but gets a value
instead.

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

llvm-svn: 212160
2014-07-02 04:39:38 +00:00
Alexey Bataev 41b9732f68 [OPENMP] Fixed error message reporting for nesting of regions
llvm-svn: 212156
2014-07-02 03:04:53 +00:00
Alp Toker d0787ebf5e Introduce a FunctionDecl::getReturnTypeSourceRange() utility
This source range is useful for all kinds of diagnostic QOI and refactoring
work, so let's make it more discoverable.

This commit also makes use of the new function to enhance various diagnostics
relating to return types and resolves an old FIXME.

llvm-svn: 212154
2014-07-02 01:47:15 +00:00
David Majnemer bb84871ffa CodeGen: Add some comments describing VFTable CG
No functionality change, just some comments to describe what is going
on.

llvm-svn: 212142
2014-07-01 22:37:08 +00:00
David Majnemer f607234fde Driver: Handle /GR- in a compatible way with MSVC
There are slight differences between /GR- and -fno-rtti which made
mapping one to the other inappropriate.

-fno-rtti disables dynamic_cast, typeid, and does not emit RTTI related
information for the v-table.

/GR- does not generate complete object locators and thus will not
reference them in vftables.  However, constructs like dynamic_cast and
typeid are permitted.

This should bring our implementation of RTTI up to semantic parity with
MSVC modulo bugs.

llvm-svn: 212138
2014-07-01 22:24:56 +00:00
Reid Kleckner 6433f7c84d Win64: Disable uwtable until we fix .pdata emission in LLVM
LLVM r211399 started emitting .pdata for win64 by default.
Unfortunately, it produces invalid object files.  I plan to fix that
Soon.  For now, don't request unwind tables.  This fixes the clang-cl
self-host on win64.

llvm-svn: 212137
2014-07-01 22:23:54 +00:00
David Majnemer 3c7228e468 AST: Small simplification in VTableBuilder
Stash whether or not we have an RTTI component away instead of
recomputing it.

llvm-svn: 212127
2014-07-01 21:10:07 +00:00
David Majnemer d905da4a5f MS ABI: Reference MSVC RTTI from the VFTable
The pointer for a class's RTTI data comes right before the VFTable but
has no name.  To be properly compatible with this, we do the following:
* Create a single GlobalVariable which holds the contents of the VFTable
  _and_ the pointer to the RTTI data.
* Create a GlobalAlias, with appropriate linkage/visibility, that points
  just after the RTTI data pointer.  This ensures that the VFTable
  symbol will always refer to VFTable data.
* Create a Comdat with a "Largest" SelectionKind and stick the private
  GlobalVariable in it.  By transitivity, the GlobalAlias will be a
  member of the Comdat group.  Using "Largest" ensures that foreign
  definitions without an RTTI data pointer will _not_ be chosen in the
  final linked image.

Whether or not we emit RTTI data depends on several things:
* The -fno-rtti flag implies that we should never not emit a pointer to
  RTTI data before the VFTable.
* __declspec(dllimport) brings in the VFTable from a remote DLL. Use an
  available_externally GlobalVariable to provide a local definition of
  the VFTable.  This means that we won't have any available_externally
  definitions of things like complete object locators.  This is
  acceptable because they are never directly referenced.

To my knowledge, this completes the implementation of MSVC RTTI code
generation.

Further semantic work should be done to properly support /GR-.

llvm-svn: 212125
2014-07-01 20:30:31 +00:00
Sylvestre Ledru 91f380a499 GCC compatibility: Ignore -finput_charset=UTF-8 argument. It is the default in Clang.
Currently, we fail with an error.

Reviewers: rafael

Reviewed By: rafael

Subscribers: rnk, cfe-commits

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

llvm-svn: 212110
2014-07-01 17:24:27 +00:00
Logan Chien e9c8ccbf8f Remove CleanupHackLevel from CGException.
This patch removes the dead code, and refines the
getEHResumeBlock() slightly.

The CleanupHackLevel was a hack to the old exception
handling intrinsics, which have several issues with function
inliner.

Since LLVM 3.0, the new landingpad and resume instructions
are added to LLVM IR.  With the new exception handling
mechanism, most of the issues are fixed now.  We should
always use these instructions to implement the exception
handling code nowadays, and we don't need the hack any more.

Besides, the `CleanupHackLevel` is a compile-time constant,
thus other cases have been considered as dead code for a while.

llvm-svn: 212097
2014-07-01 11:47:10 +00:00
Simon Atanasyan ad80595b60 [Driver][Mips] MIPS ABI names "32" and "64" used as arguments of the "-mabi"
command line option only. Internally we convert them to the "o32" and "n64"
respectively. So we do not need to refer them anywhere after that conversion.

No functional changes.

llvm-svn: 212096
2014-07-01 10:59:09 +00:00
Nikola Smiljanic 3fe1e09a6e PR15677 - Crash in template diffing. Check that expression is evaluatable before evaluating it.
llvm-svn: 212090
2014-07-01 04:17:53 +00:00
Ehsan Akhgari 9be07e1acd Do not define __STRICT_ANSI__ in clang-cl
llvm-svn: 212066
2014-06-30 20:36:33 +00:00
Alexey Samsonov c6496816b1 [UBSan] Don't link UBSan runtime into shared libraries.
It used to be a feature of UBSan (it could sanitize a standalone
shared object instead of the whole program), but now it causes
more problems, like PR20165.

llvm-svn: 212064
2014-06-30 20:27:16 +00:00
Ben Langmuir 33c8090a2f Consider module depedencies when checking a preamble in libclang
Add module dependencies (header files, module map files) to the list of
files to check when deciding whether to rebuild a preamble. That fixes
using preambles with module imports so long as they are in
non-overridden files.

My intent is to use to unify the existing dependency collectors to the
new “DependencyCollectory” interface from this commit, starting with the
DependencyFileGenerator.

llvm-svn: 212060
2014-06-30 20:04:14 +00:00
Ehsan Akhgari de8c93b982 Use the newly added FindInEnvPath helper in clang
llvm-svn: 212058
2014-06-30 19:56:37 +00:00
Andrea Di Biagio eb606a3c27 [x86] Add Clang support for intrinsic __rdpmc.
This patch adds intrinsic __rdpmc to header file 'ia32intrin.h'.
Intrinsic __rdmpc can be used to read performance monitoring counters. It is
implemented as a direct call to __builtin_ia32_rdpmc.

It takes as input a value representing the index of the performance counter to
read. The value of the performance counter is then returned as a unsigned
64-bit quantity.

llvm-svn: 212053
2014-06-30 18:23:58 +00:00
Ben Langmuir e4f86bd851 Removed unused typedef for recursive_directory_iterator
llvm-svn: 212047
2014-06-30 16:10:15 +00:00
Daniel Jasper 2520fe9662 clang-format: Support member function reference qualifiers.
Before:
  string // break
      operator()() &
  {}

After:
  string // break
  operator()() & {}

llvm-svn: 212041
2014-06-30 13:54:27 +00:00
Daniel Jasper 91beebd04a clang-format: Improve expression heuristics.
Upon encountering a binary operator inside parentheses, assume that the
parentheses contain an expression.

Before:
  MACRO('0' <= c&& c <= '9');

After:
  MACRO('0' <= c && c <= '9');

llvm-svn: 212040
2014-06-30 13:44:47 +00:00
Daniel Jasper ad9eb0d79d clang-format: [JS] support free-standing functions again.
This worked initially but was broken by r210887.

Before:
  function outer1(a, b) {
    function inner1(a, b) { return a; } inner1(a, b);
  } function outer2(a, b) { function inner2(a, b) { return a; } inner2(a, b); }

After:
  function outer1(a, b) {
    function inner1(a, b) { return a; }
    inner1(a, b);
  }
  function outer2(a, b) {
    function inner2(a, b) { return a; }
    inner2(a, b);
  }

Thanks to Adam Strzelecki for working on this.

llvm-svn: 212038
2014-06-30 13:24:54 +00:00
Alexey Bataev 18eb25e85b [OPENMP] Added table with allowed nesting info for OpenMP regions (per request from Samuel F Antao).
llvm-svn: 212034
2014-06-30 10:22:46 +00:00
Alexey Bataev aca7fcf276 Using of variable length arrays in captured statements and OpenMP constructs.
Differential Revision: http://reviews.llvm.org/D4067

llvm-svn: 212010
2014-06-30 02:55:54 +00:00
Alp Toker 7b463d5a07 CodeGenAction::ExecuteAction(): check for invalid LLVM source locations
Add sign checks to deal with the fact that IR parser line/column pairs are
signed integers and sometimes invalid.

The crash path is potentially triggered by corrupt '.bc' files in practice,
though I don't have a binary input test case that can be checked-in right now.

(Unfortunately the backend itself crashes on various ill-formed '.bc' inputs so
this bandage isn't as helpful as it appears yet.)

llvm-svn: 212007
2014-06-30 01:33:59 +00:00
Alp Toker 034bbd5db7 Extract an isReservedName() function
We'll want to share the implementation if anything else decides to check
for reserved names in future, so make this little snippet of code more
discoverable.

Also remove the __va_list_tag and __builtin_va_list special-case
checks. They're leftovers from before when the reserved name logic was
added.

No change in functionality.

llvm-svn: 212006
2014-06-30 01:33:53 +00:00
Saleem Abdulrasool 521cec84ac Basic: correct the va_list type on Windows on ARM
Windows on ARM defines va_list as a typedef for char *.  Although the semantics
of argument passing for variadic functions matches AAPCS VFP, the wrapped
struct __va_list type is unused.  This makes the intrinsic definition for
va_list match that of Visual Studio.

llvm-svn: 212004
2014-06-29 23:05:41 +00:00
Chandler Carruth 095b696b50 Fix a stray semi-colon. (Found by a pedantic warning)
llvm-svn: 212003
2014-06-29 22:42:51 +00:00
NAKAMURA Takumi 557fb62e80 Revert r211866, r211895 and r211995, "Driver: use GNU::Link for the Generic_GCC toolchain". It broke users of Generic_GCC, cygwin and mingw32.
It reverts commits as follows:
  r211866: "Driver: use GNU::Link for the Generic_GCC toolchain"
  r211895: "Replace GetProgramPath("ld") with GetLinkerPath()."
  r211995: "Driver: add a cygwin linker tool"

llvm-svn: 211998
2014-06-29 16:00:11 +00:00
Saleem Abdulrasool a4a474b859 Driver: add a cygwin linker tool
This adds a linker tool for the Windows cygwin environment.  This linker
invocation is significantly different from the generic ld invocation.  It
requires additional parameters as well as does not accept some normal
parameters.  This should fix self-hosting on Cygwin.

llvm-svn: 211995
2014-06-29 06:11:14 +00:00
Saleem Abdulrasool 24bd7da2d2 Basic: fix handling for Windows Itanium environment
This corrects the handling for i686-windows-itanium.  This environment is nearly
identical to Windows MSVC, except it uses the itanium ABI for C++.

llvm-svn: 211991
2014-06-28 23:34:11 +00:00
Saleem Abdulrasool d1ee08e7cd Basic: whitespace cleanup
Remove unnecessary separation of anonymous namespace.  NFC.

llvm-svn: 211990
2014-06-28 23:34:07 +00:00
Richard Trieu c1888e0c6e Extend -Wtautological-undefined-compare and -Wundefined-bool-conversion to
trigger on taking the address of a reference that is returned from a function
call.

llvm-svn: 211989
2014-06-28 23:25:37 +00:00
Craig Topper e3d2ecbe86 Import MutableArrayRef into clang namespace.
llvm-svn: 211988
2014-06-28 23:22:33 +00:00
Craig Topper 00bbdcf9b3 Remove llvm:: from uses of ArrayRef.
llvm-svn: 211987
2014-06-28 23:22:23 +00:00
Simon Atanasyan 98ba8a657d [Driver][Mips] Fix else-after-return.
No functional changes.

llvm-svn: 211984
2014-06-28 15:56:08 +00:00
Simon Atanasyan 755d7f9c28 [Driver][Mips] Remove redundant brackets.
No functional changes.

llvm-svn: 211983
2014-06-28 15:56:03 +00:00
Simon Atanasyan 9601e6bfaa [Driver][Mips] Remove redundant abstract/override function.
No functional changes.

llvm-svn: 211982
2014-06-28 15:55:55 +00:00
Reid Kleckner 5fb5b12d48 Extend -Wdynamic-class-memaccess to records containing dynamic classes
Reviewers: rtrieu

Subscribers: cfe-commits

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

llvm-svn: 211972
2014-06-27 23:58:21 +00:00
Yi Kong a44c4d7173 Introduce arm_acle.h supporting existing LLVM builtin intrinsics
Summary: This patch introduces ACLE header file, implementing extensions that can be directly mapped to existing Clang intrinsics. It implements for both AArch32 and AArch64.

Reviewers: t.p.northover, compnerd, rengolin

Reviewed By: compnerd, rengolin

Subscribers: rnk, echristo, compnerd, aemerson, mroth, cfe-commits

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

llvm-svn: 211962
2014-06-27 21:25:42 +00:00
David Blaikie 66cc07b4f7 Remove 'const' from MemoryBuffers used through the SourceManager
This removes a const_cast added in r211884 that occurred due to an
inconsistency in how MemoryBuffers are handled between some parts of
clang and LLVM.

MemoryBuffers are immutable and the general convention in the LLVM
project is to omit const from immutable types as it's simply
redundant/verbose (see llvm::Type, for example). While this change
doesn't remove "const" from /every/ MemoryBuffer, it at least makes this
chain of ownership/usage consistent.

llvm-svn: 211915
2014-06-27 17:40:03 +00:00
Reid Kleckner c542d37995 clang-cl: Map /EHs- to -fno-exceptions
This isn't 100% compatible with MSVC, but it's close enough.  MSVC's /EH
flag doesn't really control exceptions so much as how to clean up after
an exception is thrown.  The upshot is that cl.exe /EHs- will compile
try, throw, and catch statements with a warning, but clang-cl will
reject such constructs with a hard error.  We can't compile such EH
constructs anyway, but this may matter to consumers of the AST.

Reviewers: hans

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

llvm-svn: 211909
2014-06-27 17:02:02 +00:00
David Majnemer 4632e1eec1 CodeGen: Fix a typo in getThreadLocalWrapperLinkage
The description had a misspelling.  No functionality change.

llvm-svn: 211908
2014-06-27 16:56:27 +00:00
Oliver Stannard 3f32b9be7f [ARM] Fix AAPCS non-compliance caused by very large structs
This is a fix to the code in clang which inserts padding arguments to
ensure that the ARM backend can emit AAPCS-VFP compliant code. This code
needs to track the number of registers which have been allocated in order
to do this. When passing a very large struct (>64 bytes) by value, clang
emits IR which takes a pointer to the struct, but the backend converts this
back to passing the struct in registers and on the stack. The bug was that
this was being considered by clang to only use one register, meaning that
there were situations in which padding arguments were incorrectly emitted
by clang.

llvm-svn: 211898
2014-06-27 13:59:27 +00:00
Logan Chien c237a1a2e3 Replace GetProgramPath("ld") with GetLinkerPath().
llvm-svn: 211895
2014-06-27 12:37:36 +00:00
Alexey Bataev bae9a793fd [OPENMP] Parsing and sema analysis for 'copyprivate' clause.
llvm-svn: 211886
2014-06-27 10:37:06 +00:00
Alp Toker 895a23fa2b const_cast the memory MemoryBuffer following LLVM r211883
llvm-svn: 211884
2014-06-27 09:24:27 +00:00
Justin Bogner 80effa415c Driver: Pass -ivfsoverlay to module crashdumps
When we create a crashdump involving modules, we build a VFS to
reproduce the problem with. This updates the reproduction script to
use that VFS.

llvm-svn: 211876
2014-06-27 06:35:05 +00:00
Alp Toker aa0dd5a409 Add a FIXME for an unfortunate issue in ConvertBackendLocation()
This function is copying the entire file contents into memory repeatedly and
allocating new file IDs *each time* a source location is processed.

llvm-svn: 211874
2014-06-27 06:02:00 +00:00
Saleem Abdulrasool 4b68a05f3d Driver: use GNU::Link for the Generic_GCC toolchain
This changes the behaviour of the driver for linking to match that of the
Generic_GCC::Assemble.    The default link should use "ld" rather than "gcc" for
the linker as gcc does.  This avoids the unnecessary round-tripping through gcc.
It also is much more reasonable behaviour from the user's perspective.  This
should have been updated with SVN r195554 which changed the behaviour of
Generic_GCC::Assemble.

The gcc_forward test needs to be updated to mark the fact that -march is a flag
for GCC not ld.  This was updated as a typo fix, but added a check for a flag
that is not a link flag.

The bindings test covers the change for testing, and thus no new test was added.

llvm-svn: 211866
2014-06-27 05:06:41 +00:00
Alp Toker dc2c475904 CodeGenAction: don't duplicate entire .ll/.bc files into memory
Requires supporting changes from LLVM r211861.

llvm-svn: 211862
2014-06-27 04:34:44 +00:00
Anna Zaks b8de0c4278 Do not inline methods of C++ containers (coming from headers).
This silences false positives (leaks, use of uninitialized value) in simple
code that uses containers such as std::vector and std::list. The analyzer
cannot reason about the internal invariances of those data structures which
leads to false positives. Until we come up with a better solution to that
problem, let's just not inline the methods of the containers and allow objects
to escape whenever such methods are called.

This just extends an already existing flag "c++-container-inlining" and applies
the heuristic not only to constructors and destructors of the containers, but
to all of their methods.

We have a bunch of distinct user reports all related to this issue
(radar://16058651, radar://16580751, radar://16384286, radar://16795491
[PR19637]).

llvm-svn: 211832
2014-06-27 01:03:05 +00:00
Reid Kleckner 11c6f6165b Avoid extra back reference key lookup in msmangler
Avoid a second key lookup when the back reference key is going to be
inserted in the StringMap. The string lookups in the msmangler are the
main responsible for the huge overhead when compared to the itanium
mangler. This patch makes a small but noticeable improvement.

Reviewed by: rnk

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

Patch by Agustín Bergé!

llvm-svn: 211813
2014-06-26 22:42:18 +00:00
Fariborz Jahanian 53f867ac45 Objective-C ARC. Provide diagnostic and fix-it
when casting a retainable object to a objc_bridge_related
CF type with the suggestion of applying the method
specified in the bridging attribute to the object.
// rdar://15932435

llvm-svn: 211807
2014-06-26 21:22:16 +00:00
Justin Bogner f05a499339 Driver: Fix a misleading comment and test for what it actually did
llvm-svn: 211806
2014-06-26 20:59:39 +00:00
Justin Bogner 5aaf2e729b Driver: Remove trailing whitespace
llvm-svn: 211805
2014-06-26 20:59:36 +00:00
Hans Wennborg 1da044a4da clang-cl: Don't store the cl compiler Tool on the stack (PR20131)
The Command will refer back to the Tool as its source,
so it has to outlive the Command.

Having the Tool on the stack would cause us to crash
when using "clang-cl -GR -fallback", because if the
Command fails, Driver::ExecuteCompilation tries to
peek at the Command's source.

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

llvm-svn: 211802
2014-06-26 19:59:02 +00:00
Jim Grosbach be83cb8c96 ARM: Correctly identify cortex-m4 as v7em.
Get the predefined macro for the architecture correct.
cortex-m4: __ARM_ARCH_7EM__
cortex-m3: __ARM_ARCH_7M__
cortex-m0: __ARM_ARCH_6M__

rdar://17420090

llvm-svn: 211792
2014-06-26 17:24:16 +00:00
Logan Chien eb9162f0bb Implement the -fuse-ld= option.
This commit implements the -fuse-ld= option, so that the user
can specify -fuse-ld=bfd to use ld.bfd.

This commit re-applies r194328 with some test case changes.
It seems that r194328 was breaking macosx or mingw build
because clang can't find ld.bfd or ld.gold in the given sysroot.
We should use -B to specify the executable search path instead.

Patch originally by David Chisnall.

llvm-svn: 211785
2014-06-26 14:23:45 +00:00
Will Schmidt f048751912 Add ppc64/power8 as a target
llvm-svn: 211778
2014-06-26 13:34:10 +00:00