]> granicus.if.org Git - clang/log
clang
9 years ago[cuda] treat file scope __asm as __host__ and ignore it during device-side compilation.
Artem Belevich [Mon, 27 Apr 2015 18:52:00 +0000 (18:52 +0000)]
[cuda] treat file scope __asm as __host__ and ignore it during device-side compilation.

Currently clang emits file-scope asm during *both* host and device
compilation modes which is usually a wrong thing to do.

There's no way to attach any attribute to an __asm statement, so
there's no way to differentiate between host-side and device-side
file-scope asm.  This patch makes clang to match nvcc behavior and
emit file-scope-asm only during host-side compilation.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235905 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoSupport generating NMake/Jom-style depfiles.
Paul Robinson [Mon, 27 Apr 2015 18:14:32 +0000 (18:14 +0000)]
Support generating NMake/Jom-style depfiles.

NMake is a Make-like builder that comes with Microsoft Visual Studio.
Jom (https://wiki.qt.io/Jom) is an NMake-compatible build tool.
Dependency files for NMake/Jom need to use double-quotes to wrap
filespecs containing special characters, instead of the backslash
escapes that GNU Make wants.

Adds the -MV option, which specifies to use double-quotes as needed
instead of backslash escapes when writing the dependency file.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235903 91177308-0d34-0410-b5e6-96231b3b80d8

9 years ago[MS ABI] Use 'continue' instead of 'return false' where intended
Reid Kleckner [Mon, 27 Apr 2015 17:19:49 +0000 (17:19 +0000)]
[MS ABI] Use 'continue' instead of 'return false' where intended

This was a bug in r218285 that prevented us from seeing subsequent
virtual bases in the class hierarchy, leading to crashes later.

Also add some comments to this function, now that we better understand
what it's trying to do.

Fixes PR21062 and PR21064.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235899 91177308-0d34-0410-b5e6-96231b3b80d8

9 years ago[OPENMP] Simplified iteration over clauses, NFC.
Alexey Bataev [Mon, 27 Apr 2015 08:00:32 +0000 (08:00 +0000)]
[OPENMP] Simplified iteration over clauses, NFC.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235838 91177308-0d34-0410-b5e6-96231b3b80d8

9 years ago[OPENMP] Codegen for 'taskwait' directive.
Alexey Bataev [Mon, 27 Apr 2015 05:22:09 +0000 (05:22 +0000)]
[OPENMP] Codegen for 'taskwait' directive.

Emit the following code for 'taskwait' directive within tied task:
call i32 @__kmpc_omp_taskwait(<loc>, i32 <thread_id>);
Differential Revision: http://reviews.llvm.org/D9245

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235836 91177308-0d34-0410-b5e6-96231b3b80d8

9 years ago[OPENMP] Codegen for 'reduction' clause in 'sections' directive.
Alexey Bataev [Mon, 27 Apr 2015 05:04:13 +0000 (05:04 +0000)]
[OPENMP] Codegen for 'reduction' clause in 'sections' directive.

Emit a code for reduction clause. Next code should be emitted for reductions:

static kmp_critical_name lock = { 0 };

void reduce_func(void *lhs[<n>], void *rhs[<n>]) {
    *(Type0*)lhs[0] = ReductionOperation0(*(Type0*)lhs[0], *(Type0*)rhs[0]);
      ...
        *(Type<n>-1*)lhs[<n>-1] =
          ReductionOperation<n>-1(*(Type<n>-1*)lhs[<n>-1],
            *(Type<n>-1*)rhs[<n>-1]);
}

...
void *RedList[<n>] = {&<RHSExprs>[0], ..., &<RHSExprs>[<n>-1]};
switch (__kmpc_reduce{_nowait}(<loc>, <gtid>, <n>, sizeof(RedList), RedList, reduce_func, &<lock>)) {
case 1:
  <LHSExprs>[0] = ReductionOperation0(*<LHSExprs>[0], *<RHSExprs>[0]);
  ...
  <LHSExprs>[<n>-1] = ReductionOperation<n>-1(*<LHSExprs>[<n>-1], *<RHSExprs>[<n>-1]);
  __kmpc_end_reduce{_nowait}(<loc>, <gtid>, &<lock>);
  break;
case 2:
  Atomic(<LHSExprs>[0] = ReductionOperation0(*<LHSExprs>[0], *<RHSExprs>[0]));
  ...
  Atomic(<LHSExprs>[<n>-1] = ReductionOperation<n>-1(*<LHSExprs>[<n>-1], *<RHSExprs>[<n>-1]));
  break;
default:;
}
Reduction variables are a kind of a private variables, they have private copies, but initial values are chosen in accordance with the reduction operation.
If sections directive has only single section, then original shared variables are used instead with barrier at the end of the directive.
Differential Revision: http://reviews.llvm.org/D9242

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235835 91177308-0d34-0410-b5e6-96231b3b80d8

9 years ago[OPENMP] Codegen for 'lastprivate' clause in 'sections' directive.
Alexey Bataev [Mon, 27 Apr 2015 04:34:03 +0000 (04:34 +0000)]
[OPENMP] Codegen for 'lastprivate' clause in 'sections' directive.

#pragma omp sections lastprivate(<var>)
<BODY>;
This construct is translated into something like:

<last_iter> = alloca i32
<init for lastprivates>;
<last_iter> = 0
; No initializer for simple variables or a default constructor is called for objects.
; For arrays perform element by element initialization by the call of the default constructor.
...
OMP_FOR_START(...,<last_iter>, ..); sets <last_iter> to 1 if this is the last iteration.
<BODY>
...
OMP_FOR_END
if (<last_iter> != 0) {
  <final copy for lastprivate>; Update original variable with the lastprivate value.
}
call __kmpc_cancel_barrier() ; an implicit barrier to avoid possible data race.
If there is only one section, there is no special code generation, original shared variables are used + barrier is emitted at the end of the directive.
Differential Revision: http://reviews.llvm.org/D9240

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235834 91177308-0d34-0410-b5e6-96231b3b80d8

9 years ago[OPENMP] Codegen for 'private' clause in 'sections' directive.
Alexey Bataev [Mon, 27 Apr 2015 04:12:12 +0000 (04:12 +0000)]
[OPENMP] Codegen for 'private' clause in 'sections' directive.

If there are 2 or more sections in a 'section' directive the following code is generated:

<default init for privates>
@__kmpc_for_static_init_4();
<BODY for sections directive>
@__kmpc_for_static_fini()
If there is only one section, the following code is generated:

if (@__kmpc_single()) {
  <default init for privates>
  @__kmpc_end_single();
}
Differential Revision: http://reviews.llvm.org/D9239

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235833 91177308-0d34-0410-b5e6-96231b3b80d8

9 years ago[OPENMP] Codegen for 'private' clause in 'single' directive.
Alexey Bataev [Mon, 27 Apr 2015 03:48:52 +0000 (03:48 +0000)]
[OPENMP] Codegen for 'private' clause in 'single' directive.
Emit the following code for 'single' directive with 'private' clause:

if (@__kmpc_single()) {
  <default init for privates>
  @__kmpc_end_single();
}
Differential Revision: http://reviews.llvm.org/D9238

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235832 91177308-0d34-0410-b5e6-96231b3b80d8

9 years ago[MS ABI] Rephrase the mangling of array types in parameters
David Majnemer [Mon, 27 Apr 2015 03:07:47 +0000 (03:07 +0000)]
[MS ABI] Rephrase the mangling of array types in parameters

Make the canonicalization of array types more consistent.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235831 91177308-0d34-0410-b5e6-96231b3b80d8

9 years ago[Sema] Do not permit binding a reference to a compound literal
David Majnemer [Sun, 26 Apr 2015 07:35:03 +0000 (07:35 +0000)]
[Sema] Do not permit binding a reference to a compound literal

We could probably make this work if we cared enough.  However, we are
far outside any language rules at this point.

This fixes PR21834.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235818 91177308-0d34-0410-b5e6-96231b3b80d8

9 years ago[Sema] Don't allow unverified bitfields in FieldDecls
David Majnemer [Sun, 26 Apr 2015 04:58:18 +0000 (04:58 +0000)]
[Sema] Don't allow unverified bitfields in FieldDecls

VerifyBitField must be called if we are to form a bitfield FieldDecl.
We will not verify the bitfield if the decl is known to be malformed in
other ways; pretend that we don't have a bitfield if this happens.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235816 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoCorrectly handle zero-sized but non-empty base classes in IRGen.
John McCall [Sun, 26 Apr 2015 04:43:26 +0000 (04:43 +0000)]
Correctly handle zero-sized but non-empty base classes in IRGen.

Fixes rdar://20621065.

A more elegant fix would preclude this case by defining the
rules such that zero-size classes are always formally empty.
I believe the only extensions which create zero-size classes
right now are flexible arrays and zero-length arrays; it's
not abstractly unreasonable to say that those don't count
as members for the purposes of emptiness, just as zero-width
bitfields don't count.  But that's an ABI-affecting change
and requires further discussion; in the meantime, let's not
assert / miscompile.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235815 91177308-0d34-0410-b5e6-96231b3b80d8

9 years ago[Sema] Check if a builtin is FunctionPrototype().
Davide Italiano [Sat, 25 Apr 2015 20:20:04 +0000 (20:20 +0000)]
[Sema] Check if a builtin is FunctionPrototype().

Don't assume it's always is. This prevents a crash in Sema while
trying to merge return type for a builtin w/out function prototype.

PR: 23086
Differential Revision: http://reviews.llvm.org/D9235
Reviewed by: rsmith

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235806 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoInstrProf: Fix coverage maps for conditional operators
Justin Bogner [Fri, 24 Apr 2015 23:37:57 +0000 (23:37 +0000)]
InstrProf: Fix coverage maps for conditional operators

This fixes a crash when we're emitting coverage and a macro appears
between two binary conditional operators, ie, "foo ?: MACRO ?: bar",
and fixes the interaction of macros and conditional operators in
general.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235793 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoclang-cl: Don't look up absolute paths in %LIB%.
Nico Weber [Fri, 24 Apr 2015 22:16:53 +0000 (22:16 +0000)]
clang-cl: Don't look up absolute paths in %LIB%.

Before this patch, passing a non-existent absolute path to clang-cl would cause
stat'ing of impossible paths. For example, `clang-cl -c d:\adsfasdf.txt` would
cause a stat of
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\LIBd:\asdfadsf.cc

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235787 91177308-0d34-0410-b5e6-96231b3b80d8

9 years ago[opaque pointer type] Update test cases now that the type for an invoke is just a...
David Blaikie [Fri, 24 Apr 2015 19:33:25 +0000 (19:33 +0000)]
[opaque pointer type] Update test cases now that the type for an invoke is just a function type, not a pointer-to-function type

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235756 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoRevert r235749 - Accidentally commited cruft from the wrong path.
Lang Hames [Fri, 24 Apr 2015 19:08:30 +0000 (19:08 +0000)]
Revert r235749 - Accidentally commited cruft from the wrong path.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235750 91177308-0d34-0410-b5e6-96231b3b80d8

9 years ago[CodeGen] Make AsmPrinter's OutStreamer member a unique_ptr.
Lang Hames [Fri, 24 Apr 2015 19:04:55 +0000 (19:04 +0000)]
[CodeGen] Make AsmPrinter's OutStreamer member a unique_ptr.

AsmPrinter owns the OutStreamer, so an owning pointer makes sense here. Using a
reference for this is crufty.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235749 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoclang-format: Don't wrap after short first segments of builder calls.
Daniel Jasper [Fri, 24 Apr 2015 10:08:09 +0000 (10:08 +0000)]
clang-format: Don't wrap after short first segments of builder calls.

Before:
  a()
      .aaaaa()
      .aaaaa()
      .aaaaa();

After:
  a().aaaaa()
      .aaaaa()
      .aaaaa();

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235707 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoclang-format: More selectively detect QT's "signals".
Daniel Jasper [Fri, 24 Apr 2015 07:50:34 +0000 (07:50 +0000)]
clang-format: More selectively detect QT's "signals".

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235702 91177308-0d34-0410-b5e6-96231b3b80d8

9 years ago[TableGen] Clang changes for r235697 to stop leaking Expanders and Operators in SetTh...
Craig Topper [Fri, 24 Apr 2015 06:53:50 +0000 (06:53 +0000)]
[TableGen] Clang changes for r235697 to stop leaking Expanders and Operators in SetTheory.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235698 91177308-0d34-0410-b5e6-96231b3b80d8

9 years ago[OPENMP] Codegen for 'firstprivate' clause in 'single' directive.
Alexey Bataev [Fri, 24 Apr 2015 04:21:15 +0000 (04:21 +0000)]
[OPENMP] Codegen for 'firstprivate' clause in 'single' directive.

Emit the following code for 'single' directive with 'firtstprivate' clause:

if (@__kmpc_single()) {
  <init for firstprivates>
  @__kmpc_end_single();
}
@__kmpc_cancel_barrier(); // To avoid data race in firstprivate init
Differential Revision: http://reviews.llvm.org/D9223

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235694 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoRemove unused variable to silence GCC warning
David Majnemer [Fri, 24 Apr 2015 04:14:25 +0000 (04:14 +0000)]
Remove unused variable to silence GCC warning

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235693 91177308-0d34-0410-b5e6-96231b3b80d8

9 years ago[OPENMP] Do not emit implicit barrier for single directive with 'copyprivate' clause(s).
Alexey Bataev [Fri, 24 Apr 2015 04:00:39 +0000 (04:00 +0000)]
[OPENMP] Do not emit implicit barrier for single directive with 'copyprivate' clause(s).

Runtime function for 'copyprivate' directive generates implicit barriers, so no need to emit it.
Differential Revision: http://reviews.llvm.org/D9215

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235692 91177308-0d34-0410-b5e6-96231b3b80d8

9 years ago[OPENMP] Codegen for 'firstprivate' clause in 'sections' directive.
Alexey Bataev [Fri, 24 Apr 2015 03:37:03 +0000 (03:37 +0000)]
[OPENMP] Codegen for 'firstprivate' clause in 'sections' directive.

If there are 2 or more sections in a 'section' directive the following code is generated:

<init for firstprivates>
@__kmpc_cancel_barrier();// To avoid data race in firstprivate init
@__kmpc_for_static_init_4();
<BODY for sections directive>
@__kmpc_for_static_fini()
If there is only one section, the following code is generated:

if (@__kmpc_single()) {
  <init for firstprivates>
  @__kmpc_end_single();
}
@__kmpc_cancel_barrier(); // To avoid data race in firstprivate init
Differential Revision: http://reviews.llvm.org/D9214

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235691 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoReplace getPointeeType()->isFunctionType with isMemberDataPointerType
David Majnemer [Fri, 24 Apr 2015 01:25:08 +0000 (01:25 +0000)]
Replace getPointeeType()->isFunctionType with isMemberDataPointerType

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235682 91177308-0d34-0410-b5e6-96231b3b80d8

9 years ago[MS ABI] Fix the preferred alignment of member pointers
David Majnemer [Fri, 24 Apr 2015 01:25:05 +0000 (01:25 +0000)]
[MS ABI] Fix the preferred alignment of member pointers

Member pointers in the MS ABI have different alignment depending on
whether they were created on the stack or live in a record.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235681 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoCleanup some MS-ABI specific code
David Majnemer [Fri, 24 Apr 2015 01:24:59 +0000 (01:24 +0000)]
Cleanup some MS-ABI specific code

No functional change intended.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235680 91177308-0d34-0410-b5e6-96231b3b80d8

9 years ago[modules] Partial revert of r235669: don't create ModuleMacros for imported local...
Richard Smith [Fri, 24 Apr 2015 00:41:09 +0000 (00:41 +0000)]
[modules] Partial revert of r235669: don't create ModuleMacros for imported local macros.

The surrounding infrastructure isn't quite ready for this yet.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235677 91177308-0d34-0410-b5e6-96231b3b80d8

9 years ago[modules] Refactor creation of ModuleMacros and create them when importing from local...
Richard Smith [Thu, 23 Apr 2015 23:29:05 +0000 (23:29 +0000)]
[modules] Refactor creation of ModuleMacros and create them when importing from local submodules.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235669 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoInstrProf: Stop using RegionCounter outside of CodeGenPGO (NFC)
Justin Bogner [Thu, 23 Apr 2015 23:06:47 +0000 (23:06 +0000)]
InstrProf: Stop using RegionCounter outside of CodeGenPGO (NFC)

The RegionCounter type does a lot of legwork, but most of it is only
meaningful within the implementation of CodeGenPGO. The uses elsewhere
in CodeGen generally just want to increment or read counters, so do
that directly.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235664 91177308-0d34-0410-b5e6-96231b3b80d8

9 years ago[modules] Properly attribute macros to modules if they're in a file textually include...
Richard Smith [Thu, 23 Apr 2015 22:58:06 +0000 (22:58 +0000)]
[modules] Properly attribute macros to modules if they're in a file textually included into a file in the module.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235661 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoFix clang docs build.
Sergey Matveev [Thu, 23 Apr 2015 21:29:37 +0000 (21:29 +0000)]
Fix clang docs build.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235650 91177308-0d34-0410-b5e6-96231b3b80d8

9 years ago[modules] Remove the now-redundant import of all pending macros at the end of buildin...
Richard Smith [Thu, 23 Apr 2015 21:20:19 +0000 (21:20 +0000)]
[modules] Remove the now-redundant import of all pending macros at the end of building a module.

Since we now track module macros separately from their visibility state, this
is no longer necessary.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235648 91177308-0d34-0410-b5e6-96231b3b80d8

9 years ago[modules] Store a ModuleMacro* on an imported macro directive rather than duplicating...
Richard Smith [Thu, 23 Apr 2015 20:40:50 +0000 (20:40 +0000)]
[modules] Store a ModuleMacro* on an imported macro directive rather than duplicating the info within it.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235644 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoAdd clang/docs/SanitizerCoverage.rst
Sergey Matveev [Thu, 23 Apr 2015 20:40:04 +0000 (20:40 +0000)]
Add clang/docs/SanitizerCoverage.rst

Moved from https://code.google.com/p/address-sanitizer/wiki/AsanCoverage

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235643 91177308-0d34-0410-b5e6-96231b3b80d8

9 years ago[modules] Determine the set of macros exported by a submodule at the end of that...
Richard Smith [Thu, 23 Apr 2015 18:18:26 +0000 (18:18 +0000)]
[modules] Determine the set of macros exported by a submodule at the end of that submodule.

Previously we'd defer this determination until writing the AST, which doesn't
allow us to use this information when building other submodules of the same
module. This change also allows us to use a uniform mechanism for writing
module macro records, independent of whether they are local or imported.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235614 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoDon't emit lifetime markers when msan is enabled
Reid Kleckner [Thu, 23 Apr 2015 18:07:13 +0000 (18:07 +0000)]
Don't emit lifetime markers when msan is enabled

In r235553, Clang started emitting lifetime markers more often. This
caused false negative in MSan, because MSan only poisons all allocas
once at function entry. Eventually, MSan should poison allocas at
lifetime start and probably also lifetime end, but until then, let's not
emit markers that aren't going to be useful.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235613 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoExtend format specifier checking to include field function pointers in addition to...
Aaron Ballman [Thu, 23 Apr 2015 16:14:19 +0000 (16:14 +0000)]
Extend format specifier checking to include field function pointers in addition to variable function pointers. Addresses PR21082.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235606 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoDiagnose variadic main() as an extension; addresses PR17905.
Aaron Ballman [Thu, 23 Apr 2015 16:12:42 +0000 (16:12 +0000)]
Diagnose variadic main() as an extension; addresses PR17905.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235605 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoclang-format: Properly detect variable declarations with ObjC.
Daniel Jasper [Thu, 23 Apr 2015 13:58:40 +0000 (13:58 +0000)]
clang-format: Properly detect variable declarations with ObjC.

Before:
  LoooooooooooooooooooooooooooooooooooooooongType
  LoooooooooooooooooooooooooooooooooooooongVariable([A a]);

After:
  LoooooooooooooooooooooooooooooooooooooooongType
      LoooooooooooooooooooooooooooooooooooooongVariable([A a]);

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235599 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoclang-format: Allow splitting "= default" and "= delete".
Daniel Jasper [Thu, 23 Apr 2015 12:59:09 +0000 (12:59 +0000)]
clang-format: Allow splitting "= default" and "= delete".

Otherwise, this can violate the column limit.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235592 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoclang-format: Don't add unwanted space when creating new arrays.
Daniel Jasper [Thu, 23 Apr 2015 10:23:53 +0000 (10:23 +0000)]
clang-format: Don't add unwanted space when creating new arrays.

Before:
  char** newargv = new char* [argc];

After:
  char** newargv = new char*[argc];

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235583 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoclang-format: [Proto] Don't linewrap top-level options.
Daniel Jasper [Thu, 23 Apr 2015 09:54:10 +0000 (09:54 +0000)]
clang-format: [Proto] Don't linewrap top-level options.

They are very similar to import statements.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235582 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoclang-format: Support nested block formatting with ColumnLimit=0.
Daniel Jasper [Thu, 23 Apr 2015 09:23:17 +0000 (09:23 +0000)]
clang-format: Support nested block formatting with ColumnLimit=0.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235580 91177308-0d34-0410-b5e6-96231b3b80d8

9 years ago[OPENMP] Fix for failed tests for 'omp atomic write' construct.
Alexey Bataev [Thu, 23 Apr 2015 07:56:25 +0000 (07:56 +0000)]
[OPENMP] Fix for failed tests for 'omp atomic write' construct.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235576 91177308-0d34-0410-b5e6-96231b3b80d8

9 years ago[MS ABI] Add support for mangling VLA types
David Majnemer [Thu, 23 Apr 2015 07:42:08 +0000 (07:42 +0000)]
[MS ABI] Add support for mangling VLA types

Treat a VLA type like an incomplete array type.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235575 91177308-0d34-0410-b5e6-96231b3b80d8

9 years ago[OPENMP] Codegen for 'atomic capture'.
Alexey Bataev [Thu, 23 Apr 2015 06:35:10 +0000 (06:35 +0000)]
[OPENMP] Codegen for 'atomic capture'.

Adds codegen for 'atomic capture' constructs with the following forms of expressions/statements:

v = x binop= expr;
v = x++;
v = ++x;
v = x--;
v = --x;
v = x = x binop expr;
v = x = expr binop x;
{v = x; x = binop= expr;}
{v = x; x++;}
{v = x; ++x;}
{v = x; x--;}
{v = x; --x;}
{x = x binop expr; v = x;}
{x binop= expr; v = x;}
{x++; v = x;}
{++x; v = x;}
{x--; v = x;}
{--x; v = x;}
{x = x binop expr; v = x;}
{x = expr binop x; v = x;}
{v = x; x = expr;}
If x and expr are integer and binop is associative or x is a LHS in a RHS of the assignment expression, and atomics are allowed for type of x on the target platform atomicrmw instruction is emitted.
Otherwise compare-and-swap sequence is emitted.
Update of 'v' is not required to be be atomic with respect to the read or write of the 'x'.

bb:
...
atomic load <x>
cont:
<expected> = phi [ <x>, label %bb ], [ <new_failed>, %cont ]
<desired> = <expected> binop <expr>
<res> = cmpxchg atomic &<x>, desired, expected
<new_failed> = <res>.field1;
br <res>field2, label %exit, label %cont
exit:
atomic store <old/new x>, <v>
...
Differential Revision: http://reviews.llvm.org/D9049

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235573 91177308-0d34-0410-b5e6-96231b3b80d8

9 years ago[MS ABI] Treat ConstantArrayType like IncompleteArrayType in args
David Majnemer [Thu, 23 Apr 2015 05:21:20 +0000 (05:21 +0000)]
[MS ABI] Treat ConstantArrayType like IncompleteArrayType in args

Type backreferences for arguments use the DecayedType's original type.
Because of this, arguments with the same canonical type with the same
mangling would not backreference each other if one was a
ConstantArrayType while the other was an IncompleteArrayType.  Solve
this by canonicalizing the ConstantArrayType to a suitable
IncompleteArrayType.

This fixes PR23325.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235572 91177308-0d34-0410-b5e6-96231b3b80d8

9 years ago[modules] Actually allocate the extra space we use for the tail-allocated array
Richard Smith [Thu, 23 Apr 2015 04:13:52 +0000 (04:13 +0000)]
[modules] Actually allocate the extra space we use for the tail-allocated array
in this class.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235570 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoUnify the way we report overflow in increment/decrement operator.
Alexey Samsonov [Thu, 23 Apr 2015 01:50:45 +0000 (01:50 +0000)]
Unify the way we report overflow in increment/decrement operator.

Summary:
Make sure signed overflow in "x--" is checked with
llvm.ssub.with.overflow intrinsic and is reported as:
  "-2147483648 - 1 cannot be represented in type 'int'"
instead of:
  "-2147483648 + -1 cannot be represented in type 'int'"
, like we do for unsigned overflow.

Test Plan: clang + compiler-rt regression test suite

Reviewers: rsmith

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235568 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoInstrProf: Fix a shadowing error that would break length of profile names
Justin Bogner [Thu, 23 Apr 2015 00:31:16 +0000 (00:31 +0000)]
InstrProf: Fix a shadowing error that would break length of profile names

We try to use the member variable "FuncName" here, but we've also used
that name as a parameter. This ends with us getting the length of the
function name wrong when we generate the coverage data.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235565 91177308-0d34-0410-b5e6-96231b3b80d8

9 years ago[WinEH] Don't emit an exceptional cleanup for llvm.eh.endcatch
Reid Kleckner [Wed, 22 Apr 2015 23:39:15 +0000 (23:39 +0000)]
[WinEH] Don't emit an exceptional cleanup for llvm.eh.endcatch

These extra endcatch markers aren't helping identify regions to outline,
so let's get rid of them.  LLVM outlines (more or less) from begincatch
to endcatch.  Any unwind edge from an enclosed invoke is a transition to
a new exception handler, which has it's own outlining markers.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235562 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoFix another test broken by r235537
Reid Kleckner [Wed, 22 Apr 2015 21:39:55 +0000 (21:39 +0000)]
Fix another test broken by r235537

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235555 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoRevert "Revert r234581, it might have caused a few miscompiles in Chromium."
David Majnemer [Wed, 22 Apr 2015 21:38:15 +0000 (21:38 +0000)]
Revert "Revert r234581, it might have caused a few miscompiles in Chromium."

This reverts commit r234700.  It turns out that the lifetime markers
were not the cause of Chromium failing but a bug which was uncovered by
optimizations exposed by the markers.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235553 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoFix test failure caused by r235537. It does not run on Windows due to REQUIRES: shell
Reid Kleckner [Wed, 22 Apr 2015 21:14:25 +0000 (21:14 +0000)]
Fix test failure caused by r235537. It does not run on Windows due to REQUIRES: shell

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235551 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoSet normal LLVM function attributes on global initializer functions
Reid Kleckner [Wed, 22 Apr 2015 19:37:32 +0000 (19:37 +0000)]
Set normal LLVM function attributes on global initializer functions

Otherwise -fno-omit-frame-pointer and other flags like it aren't
applied.

Basic idea taken from Gao's patch, thanks!

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235537 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoSilencing a -Wunused-variable warning; NFC.
Aaron Ballman [Wed, 22 Apr 2015 15:25:05 +0000 (15:25 +0000)]
Silencing a -Wunused-variable warning; NFC.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235512 91177308-0d34-0410-b5e6-96231b3b80d8

9 years ago[OPENMP] Codegen for 'if' clause in 'task' directive.
Alexey Bataev [Wed, 22 Apr 2015 13:57:31 +0000 (13:57 +0000)]
[OPENMP] Codegen for 'if' clause in 'task' directive.

If condition evaluates to true, the code executes task by calling @__kmpc_omp_task() runtime function.
If condition evaluates to false, the code executes serial version of the code by executing the following code:

call void @__kmpc_omp_task_begin_if0(<loc>, <threadid>, <task_t_ptr, returned by @__kmpc_omp_task_alloc()>);
proxy_task_entry(<gtid>, <task_t_ptr, returned by @__kmpc_omp_task_alloc()>);
call void @__kmpc_omp_task_complete_if0(<loc>, <threadid>, <task_t_ptr, returned by @__kmpc_omp_task_alloc()>);
Also it checks if the condition is constant and if it is constant it evaluates its value and then generates either parallel version of the code (if the condition evaluates to true), or the serial version of the code (if the condition evaluates to false).
Differential Revision: http://reviews.llvm.org/D9143

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235507 91177308-0d34-0410-b5e6-96231b3b80d8

9 years ago[OPENMP] Codegen for 'reduction' clause in 'for' directive.
Alexey Bataev [Wed, 22 Apr 2015 13:43:03 +0000 (13:43 +0000)]
[OPENMP] Codegen for 'reduction' clause in 'for' directive.

Emit a code for reduction clause. Next code should be emitted for reductions:

static kmp_critical_name lock = { 0 };

void reduce_func(void *lhs[<n>], void *rhs[<n>]) {
    *(Type0*)lhs[0] = ReductionOperation0(*(Type0*)lhs[0], *(Type0*)rhs[0]);
      ...
        *(Type<n>-1*)lhs[<n>-1] =
          ReductionOperation<n>-1(*(Type<n>-1*)lhs[<n>-1],
            *(Type<n>-1*)rhs[<n>-1]);
}

 ...
  void *RedList[<n>] = {&<RHSExprs>[0], ..., &<RHSExprs>[<n>-1]};
   switch (__kmpc_reduce{_nowait}(<loc>, <gtid>, <n>, sizeof(RedList), RedList, reduce_func, &<lock>)) {
      case 1:
        <LHSExprs>[0] = ReductionOperation0(*<LHSExprs>[0], *<RHSExprs>[0]);
          ...
            <LHSExprs>[<n>-1] = ReductionOperation<n>-1(*<LHSExprs>[<n>-1], *<RHSExprs>[<n>-1]);
             __kmpc_end_reduce{_nowait}(<loc>, <gtid>, &<lock>);
              break;
               case 2:
                 Atomic(<LHSExprs>[0] = ReductionOperation0(*<LHSExprs>[0], *<RHSExprs>[0]));
                   ...
                     Atomic(<LHSExprs>[<n>-1] = ReductionOperation<n>-1(*<LHSExprs>[<n>-1], *<RHSExprs>[<n>-1]));
                      break;
                       default:;
                        }
                        Reduction variables are a kind of a private variables, they have private copies, but initial values are chosen in accordance with the reduction operation.
Differential Revision: http://reviews.llvm.org/D9139

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235506 91177308-0d34-0410-b5e6-96231b3b80d8

9 years ago[OPENMP] Codegen for 'private' clause in 'for' directive.
Alexey Bataev [Wed, 22 Apr 2015 12:24:45 +0000 (12:24 +0000)]
[OPENMP] Codegen for 'private' clause in 'for' directive.

This patch generates helper variables which used as a private copies of the corresponding original variables inside an OpenMP 'for' directive. These generated variables are initialized by default (with the default constructor, if any). In OpenMP region references to original variables are replaced by the references to these private helper variables.
Differential Revision: http://reviews.llvm.org/D9106

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235503 91177308-0d34-0410-b5e6-96231b3b80d8

9 years ago[OPENMP] Fixed test incompatibility for simd codegen.
Alexey Bataev [Wed, 22 Apr 2015 12:20:41 +0000 (12:20 +0000)]
[OPENMP] Fixed test incompatibility for simd codegen.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235501 91177308-0d34-0410-b5e6-96231b3b80d8

9 years ago[OPENMP] Fix use of unsigned counters in loops with zero trip count.
Alexey Bataev [Wed, 22 Apr 2015 11:59:37 +0000 (11:59 +0000)]
[OPENMP] Fix use of unsigned counters in loops with zero trip count.

Patch fixes bugs in codegen for loops with unsigned counters and zero trip count. Previously preconditions for all loops were built using logic (Upper - Lower) > 0. But if the loop is a loop with zero trip count, then Upper - Lower is < 0 only for signed integer, for unsigned we're running into an underflow situation.
In this patch we're using original Lower<Upper condition to check that loop body can be executed at least once. Also this allows to skip code generation for loops, if it is known that preconditions for the loop are always false.
Differential Revision: http://reviews.llvm.org/D9103

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235500 91177308-0d34-0410-b5e6-96231b3b80d8

9 years ago[OPENMP] Codegen for 'ordered' directive.
Alexey Bataev [Wed, 22 Apr 2015 11:15:40 +0000 (11:15 +0000)]
[OPENMP] Codegen for 'ordered' directive.

Add codegen for 'ordered' directive:

__kmpc_ordered(ident_t *, gtid);
<associated statement>;
__kmpc_end_ordered(ident_t *, gtid);
Also for 'for' directives with the dynamic scheduling and an 'ordered' clause added a call to '__kmpc_dispatch_fini_(4|8)[u]()' function after increment expression for loop control variable:

while(__kmpc_dispatch_next(&LB, &UB)) {
  idx = LB;
  while (idx <= UB) { BODY; ++idx;
    __kmpc_dispatch_fini_(4|8)[u](); // For ordered loops only.
  } // inner loop
}
Differential Revision: http://reviews.llvm.org/D9070

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235496 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoclang-format: Fix for #pragma option formatting.
Daniel Jasper [Wed, 22 Apr 2015 09:45:42 +0000 (09:45 +0000)]
clang-format: Fix for #pragma option formatting.

Adapted patch from Sergey Razmetov. Thank you.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235492 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoDon't dllimport/export class members with internal linkage (PR23308)
Hans Wennborg [Wed, 22 Apr 2015 04:05:17 +0000 (04:05 +0000)]
Don't dllimport/export class members with internal linkage (PR23308)

For example, a function taking a parameter with internal linkage will
itself have internal linkage since it cannot be called outside the
translation unit.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235471 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoWrap to 80 columns, fix typo in comment. No behavior change.
Nico Weber [Wed, 22 Apr 2015 03:44:51 +0000 (03:44 +0000)]
Wrap to 80 columns, fix typo in comment. No behavior change.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235470 91177308-0d34-0410-b5e6-96231b3b80d8

9 years ago[modules] Cope with partial module macro information, fix memory leak found by buildbot.
Richard Smith [Wed, 22 Apr 2015 02:09:43 +0000 (02:09 +0000)]
[modules] Cope with partial module macro information, fix memory leak found by buildbot.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235464 91177308-0d34-0410-b5e6-96231b3b80d8

9 years ago[modules] Build a DAG of module macros for each identifier.
Richard Smith [Wed, 22 Apr 2015 00:26:11 +0000 (00:26 +0000)]
[modules] Build a DAG of module macros for each identifier.

This graph will be used to determine the current set of active macros. This is
foundation work for getting macro visibility correct across submodules of the
current module. No functionality change for now.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235461 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoExpose -fdiagnostics-parseable-fixits to clang-cl
Hans Wennborg [Tue, 21 Apr 2015 23:12:03 +0000 (23:12 +0000)]
Expose -fdiagnostics-parseable-fixits to clang-cl

Patch by Daniel Cheng!

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235456 91177308-0d34-0410-b5e6-96231b3b80d8

9 years ago[cuda] Allow using integral non-type template parameters as launch_bounds attribute...
Artem Belevich [Tue, 21 Apr 2015 22:55:54 +0000 (22:55 +0000)]
[cuda] Allow using integral non-type template parameters as launch_bounds attribute arguments.

 - Changed CUDALaunchBounds arguments from integers to Expr* so they can
   be saved in AST for instantiation.
 - Added support for template instantiation of launch_bounds attrubute.
 - Moved evaluation of launch_bounds arguments to NVPTXTargetCodeGenInfo::
   SetTargetAttributes() where it can be done after template instantiation.
 - Added a warning on negative launch_bounds arguments.
 - Amended test cases.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235452 91177308-0d34-0410-b5e6-96231b3b80d8

9 years ago[cuda] Added support for CUDA built-in variables.
Artem Belevich [Tue, 21 Apr 2015 22:14:13 +0000 (22:14 +0000)]
[cuda] Added support for CUDA built-in variables.

Added cuda_builtin_vars.h which implements built-in CUDA variables
using __declattr(property).

Fields of built-in variables (except for warpSize) are implemented
using __declattr(property) which replaces read/write of a member field
with a call to a getter/setter member function, in this case with
appropriate NVPTX builtin.

Added a test case to check diagnostics on attempt to construct or
improperly access a built-in variable.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235448 91177308-0d34-0410-b5e6-96231b3b80d8

9 years ago[modules] Move list of exported module macros from IdentifierInfo lookup table to...
Richard Smith [Tue, 21 Apr 2015 21:46:32 +0000 (21:46 +0000)]
[modules] Move list of exported module macros from IdentifierInfo lookup table to separate storage, adjacent to the macro directive history.

This is substantially simpler, provides better space usage accounting in bcanalyzer,
and gives a more compact representation. No functionality change intended.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235420 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoDebugInfo: Prepare for removal of DIArray and DITypeArray typedefs
Duncan P. N. Exon Smith [Tue, 21 Apr 2015 20:07:29 +0000 (20:07 +0000)]
DebugInfo: Prepare for removal of DIArray and DITypeArray typedefs

An upcoming LLVM commit will remove the `DIArray` and `DITypeArray`
typedefs that shadow `DebugNodeArray` and `MDTypeRefArray`,
respectively.  Use those types directly.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235412 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoDebugInfo: Prepare for deletion of DIDescriptor subclasses
Duncan P. N. Exon Smith [Tue, 21 Apr 2015 18:43:54 +0000 (18:43 +0000)]
DebugInfo: Prepare for deletion of DIDescriptor subclasses

An upcoming LLVM commit will delete all the remaining subclasses of (the
already deleted) `DIDescriptor`.  Stop using them.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235403 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoRecommend to use CMake on the Clang Getting Started page.
Alexey Samsonov [Tue, 21 Apr 2015 18:38:31 +0000 (18:38 +0000)]
Recommend to use CMake on the Clang Getting Started page.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235402 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoRevert r235398 "[cuda] Added support for CUDA built-in variables."
Artem Belevich [Tue, 21 Apr 2015 18:36:42 +0000 (18:36 +0000)]
Revert r235398 "[cuda] Added support for CUDA built-in variables."

r235398 was causing buildbot break due to missing Makefile changes.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235401 91177308-0d34-0410-b5e6-96231b3b80d8

9 years ago[cuda] Added support for CUDA built-in variables.
Artem Belevich [Tue, 21 Apr 2015 17:39:06 +0000 (17:39 +0000)]
[cuda] Added support for CUDA built-in variables.

Added cuda_builtin_vars.h which implements built-in CUDA variables
using __declattr(property).

Fields of built-in variables (except for warpSize) are implemented
using __declattr(property) which replaces read/write of a member field
with a call to a getter/setter member function, in this case with
appropriate NVPTX builtin.

Added a test case to check diagnostics on attempt to construct or
improperly access a built-in variable.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235398 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoImplement target-specific __attribute__((aligned)) value
Ulrich Weigand [Tue, 21 Apr 2015 17:29:35 +0000 (17:29 +0000)]
Implement target-specific __attribute__((aligned)) value

The GCC construct __attribute__((aligned)) is defined to set alignment
to "the default alignment for the target architecture" according to
the GCC documentation:

  The default alignment is sufficient for all scalar types, but may not be
  enough for all vector types on a target that supports vector operations.
  The default alignment is fixed for a particular target ABI.

clang currently hard-coded an alignment of 16 bytes for that construct,
which is correct on some platforms (including X86), but wrong on others
(including SystemZ).  Since this value is ABI-relevant, it is important
to get correct for compatibility purposes.

This patch adds a new TargetInfo member "DefaultAlignForAttributeAligned"
that targets can set to the appropriate default __attribute__((aligned))
value.

Note that I'm deliberately *not* using the existing "SuitableAlign"
value, which is used to set the pre-defined macro __BIGGEST_ALIGNMENT__,
since those two values may not be the same on all platforms.  In fact,
on X86, __attribute__((aligned)) always uses 16-byte alignment, while
__BIGGEST_ALIGNMENT__ may be larger if AVX-2 or AVX-512 are supported.
(This is actually not yet correctly implemented in clang either.)

The patch provides a value for DefaultAlignForAttributeAligned only for
SystemZ, and leaves the default for all other targets at 16, which means
no visible change in behavior on all other targets.  (The value is still
wrong for some other targets, but I'd prefer to leave it to the target
maintainers for those platforms to fix.)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235397 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoProvide alignment info on LLVM external symbols
Ulrich Weigand [Tue, 21 Apr 2015 17:27:59 +0000 (17:27 +0000)]
Provide alignment info on LLVM external symbols

Code in CodeGenModule::GetOrCreateLLVMGlobal that sets up GlobalValue
object for LLVM external symbols has this comment:

    // FIXME: This code is overly simple and should be merged with other global
    // handling.

One part does seems to be "overly simple" currently is that this code
never sets any alignment info on the GlobalValue, so that the emitted
IR does not have any align attribute on external globals.  This can
lead to unnecessarily inefficient code generation.

This patch adds a GV->setAlignment call to set alignment info.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235396 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoFix __alignof__ of global variables on SystemZ
Ulrich Weigand [Tue, 21 Apr 2015 17:26:18 +0000 (17:26 +0000)]
Fix __alignof__ of global variables on SystemZ

SystemZ prefers to align all global variables to two bytes, which is
implemented by setting the TargetInfo member MinGlobalAlign.

However, for compatibility with existing compilers this should *not*
change the ABI alignment value as retrieved via __alignof__, which
it currently does.

This patch fixes the issue by having ASTContext::getDeclAlign ignore
the MinGlobalAlign setting in the ForAlignof case.

Since SystemZ is the only platform setting MinGlobalAlign, this should
cause no change for any other target.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235395 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoDebugInfo: Prepare for deletion of subclasses of DIScope
Duncan P. N. Exon Smith [Mon, 20 Apr 2015 22:09:57 +0000 (22:09 +0000)]
DebugInfo: Prepare for deletion of subclasses of DIScope

Prepare for the deletion in LLVM of the subclasses of (the already
deleted) `DIScope` by using the raw pointers they were wrapping
directly.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235355 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoDebugInfo: Prepare for deletion of subclasses of DIType
Duncan P. N. Exon Smith [Mon, 20 Apr 2015 21:17:26 +0000 (21:17 +0000)]
DebugInfo: Prepare for deletion of subclasses of DIType

Subclasses of (the already deleted) `DIType` will be deleted by an
upcoming LLVM commit.  Remove references.

While `DICompositeType` wraps `MDCompositeTypeBase` and `DIDerivedType`
wraps `MDDerivedTypeBase`, most uses of each really meant the more
specific `MDCompositeType` and `MDDerivedType`.  I updated accordingly.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235350 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoAdd conversionDecl matcher for node CXXConversionDecl.
Samuel Benzaquen [Mon, 20 Apr 2015 20:58:50 +0000 (20:58 +0000)]
Add conversionDecl matcher for node CXXConversionDecl.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235348 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoPut statement expression decls in the enclosing code DeclContext
Reid Kleckner [Mon, 20 Apr 2015 20:00:49 +0000 (20:00 +0000)]
Put statement expression decls in the enclosing code DeclContext

We already check that statement expressions are in a function or block,
but we didn't do anything with that information. Now we use that
DeclContext for the duration of the statement expression. Otherwise,
we'd treat statement expression locals as static data members and go
into the weeds.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235335 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoDebugInfo: Prepare for deletion of DIType
Duncan P. N. Exon Smith [Mon, 20 Apr 2015 18:51:48 +0000 (18:51 +0000)]
DebugInfo: Prepare for deletion of DIType

`DIType` is going to be deleted by an upcoming LLVM commit, so replace
uses with `MDType*`.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235330 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoDebugInfo: Prepare for deletion of DIScope
Duncan P. N. Exon Smith [Mon, 20 Apr 2015 18:32:15 +0000 (18:32 +0000)]
DebugInfo: Prepare for deletion of DIScope

An upcoming LLVM commit will delete `DIScope`, so update users to
`MDScope*`.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235326 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoclang-format: Fix incorrect multi-var declstmt detection.
Daniel Jasper [Mon, 20 Apr 2015 12:54:29 +0000 (12:54 +0000)]
clang-format: Fix incorrect multi-var declstmt detection.

This is now obvious as the pointer alignment behavior was changed.

Before (even with pointer alignment "Left"):
  MACRO Constructor(const int &i) : a(a), b(b) {}

After:
  MACRO Constructor(const int& i) : a(a), b(b) {}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235301 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoFix bug in Replacement's toString on Windows (missing flush).
Manuel Klimek [Mon, 20 Apr 2015 06:58:56 +0000 (06:58 +0000)]
Fix bug in Replacement's toString on Windows (missing flush).

Adapt function to LLVM coding style.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235286 91177308-0d34-0410-b5e6-96231b3b80d8

9 years ago[Sema] Check availability of ObjC super class and protocols of a container
Argyrios Kyrtzidis [Sun, 19 Apr 2015 20:15:55 +0000 (20:15 +0000)]
[Sema] Check availability of ObjC super class and protocols of a container
in the context of the container itself.

Otherwise we will emit 'unavailable' errors when referencing an unavailable super class
even though the subclass is also marked 'unavailable'.

rdar://20598702

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235276 91177308-0d34-0410-b5e6-96231b3b80d8

9 years ago[MS ABI] Correctly associate align attrs before the class-key
David Majnemer [Sun, 19 Apr 2015 07:53:29 +0000 (07:53 +0000)]
[MS ABI] Correctly associate align attrs before the class-key

__declspec(align(...)) is unlike all other attributes in that it is not
applied to a variable if it appears before the class-key.  If the
tag in question isn't part of a variable declaration, it is not ignored.

Instead, the alignment attribute is applied to the tag.

This fixes PR18024.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235272 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoTry to work around failure to convert this lambda to a function pointer in some versi...
Richard Smith [Sun, 19 Apr 2015 01:47:53 +0000 (01:47 +0000)]
Try to work around failure to convert this lambda to a function pointer in some versions of GCC.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235264 91177308-0d34-0410-b5e6-96231b3b80d8

9 years ago[modules] Refactor macro emission. No functionality change.
Richard Smith [Sun, 19 Apr 2015 01:34:23 +0000 (01:34 +0000)]
[modules] Refactor macro emission. No functionality change.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235263 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoMake helper function static. NFC.
Benjamin Kramer [Sat, 18 Apr 2015 10:00:10 +0000 (10:00 +0000)]
Make helper function static. NFC.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235253 91177308-0d34-0410-b5e6-96231b3b80d8

9 years ago[Sema] Don't crash if array bound calculation overflowed constexpr array
David Majnemer [Sat, 18 Apr 2015 04:55:51 +0000 (04:55 +0000)]
[Sema] Don't crash if array bound calculation overflowed constexpr array

We didn't correctly expect a QualifiedTypeLoc when faced with fixing a
variable array type into a constant array type.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235251 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoRemove dead code, NFC
Duncan P. N. Exon Smith [Sat, 18 Apr 2015 00:26:49 +0000 (00:26 +0000)]
Remove dead code, NFC

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235246 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoDebugInfo: Prepare for deletion of DIDescriptor
Duncan P. N. Exon Smith [Sat, 18 Apr 2015 00:07:30 +0000 (00:07 +0000)]
DebugInfo: Prepare for deletion of DIDescriptor

Prepare for upcoming LLVM change to delete `DIDescriptor`.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235245 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoChange AArch64 i128 returns to use [2 x i64] when possible.
Pete Cooper [Fri, 17 Apr 2015 22:16:24 +0000 (22:16 +0000)]
Change AArch64 i128 returns to use [2 x i64] when possible.

Something like { void*, void * } would be passed to a function as a [2 x i64], but returned as an i128.  This patch unifies the 2 behaviours so that we also return it as a [2 x i64].

This is better for the quality of the IR, and the size of the final LLVM binary as we tend to want to insert/extract values from these types and do so with the insert/extract instructions is less IR than shifting, truncating, and or'ing values.

Reviewed by Tim Northover.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235231 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoAdd a missing forward def of CheckerManager. NFC.
Pete Cooper [Fri, 17 Apr 2015 17:00:16 +0000 (17:00 +0000)]
Add a missing forward def of CheckerManager.  NFC.

This file doesn't include CheckerManager or forward declare it, so is sensitive to include order.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235209 91177308-0d34-0410-b5e6-96231b3b80d8