Commit Graph

56590 Commits

Author SHA1 Message Date
Alexey Bataev 137421c8a9 Revert commit r226784.
Accidentally modified file SemaType.cpp must be restored to its original state. 

llvm-svn: 226785
2015-01-22 05:35:53 +00:00
Alexey Bataev 13c7c4930c [OPENMP] CodeGen for "omp atomic read [seq_cst]" directive.
"omp atomic read [seq_cst]" accepts expressions "v=x;". In this patch we perform
an atomic load of "x" (using builtin atomic loading instructions or a call to
"atomic_load()" for simple lvalues and "kmpc_atomic_start();load
<x>;kmpc_atomic_end();" for other lvalues), convert the result of loading to
type of "v" (using EmitScalarConversion() for simple types and
EmitComplexToScalarConversion() for conversions from complex to scalar) and then
store the result in "v".
Differential Revision: http://reviews.llvm.org/D6431

llvm-svn: 226784
2015-01-22 05:29:28 +00:00
Francisco Lopes da Silva 36e1ddfd13 Makes a simple member function static.
This function has been just included with the initial support for C++
parameter completion and it's trivial enough to be a static member.

llvm-svn: 226780
2015-01-22 04:30:23 +00:00
Richard Smith 1b65dbc477 [modules] If we add an implicit special member to a class through an update
record, and that class declaration is not the canonical definition of the
class, be sure to add the class to the list of classes that are consulted when
we look up a special member in the canonical definition.

llvm-svn: 226778
2015-01-22 03:50:31 +00:00
Richard Smith 9ba845c2e6 Fix test file names so they're picked up by lit.
llvm-svn: 226776
2015-01-22 03:24:07 +00:00
Reid Kleckner 2a2e156318 SEH: Emit the constant filter 1 as a catch-all
Minor optimization of code like __try { ... } __except(1) { ... }.

llvm-svn: 226766
2015-01-22 02:25:56 +00:00
Richard Smith f1f4bc2176 [modules] If we load two declarations with typedef names for linkage purposes
on top of a local declaration of the same entity, we still need to remember
that we loaded the first one or we may fail to merge the second one properly.

llvm-svn: 226765
2015-01-22 02:21:23 +00:00
Justin Bogner 00270df517 InstrProf: Avoid creating profile names for symbols in system headers
We don't emit any coverage mapping for uncovered functions that come
from system headers, but we were creating a GlobalVariable with each
of their names. This is wasteful since the linker will need to dead
strip the unused symbols, and it can lead to issues when merging
coverage with others TUs that do have coverage for those functions.

llvm-svn: 226764
2015-01-22 02:17:23 +00:00
Richard Smith 5156c38570 [modules] It's possible to merge into the pattern of a class template before we
load the definition data from the declaration itself. In that case, merge
properly; don't assume the prior definition is the same as our own.

llvm-svn: 226761
2015-01-22 01:41:56 +00:00
Reid Kleckner 1d59f99f5c Initial support for Win64 SEH IR emission
The lowering looks a lot like normal EH lowering, with the exception
that the exceptions are caught by executing filter expression code
instead of matching typeinfo globals. The filter expressions are
outlined into functions which are used in landingpad clauses where
typeinfo would normally go.

Major aspects that still need work:
- Non-call exceptions in __try bodies won't work yet. The plan is to
  outline the __try block in the frontend to keep things simple.
- Filter expressions cannot use local variables until capturing is
  implemented.
- __finally blocks will not run after exceptions. Fixing this requires
  work in the LLVM SEH preparation pass.

The IR lowering looks like this:

// C code:
bool safe_div(int n, int d, int *r) {
  __try {
    *r = normal_div(n, d);
  } __except(_exception_code() == EXCEPTION_INT_DIVIDE_BY_ZERO) {
    return false;
  }
  return true;
}

; LLVM IR:
define i32 @filter(i8* %e, i8* %fp) {
  %ehptrs = bitcast i8* %e to i32**
  %ehrec = load i32** %ehptrs
  %code = load i32* %ehrec
  %matches = icmp eq i32 %code, i32 u0xC0000094
  %matches.i32 = zext i1 %matches to i32
  ret i32 %matches.i32
}

define i1 zeroext @safe_div(i32 %n, i32 %d, i32* %r) {
  %rr = invoke i32 @normal_div(i32 %n, i32 %d)
      to label %normal unwind to label %lpad

normal:
  store i32 %rr, i32* %r
  ret i1 1

lpad:
  %ehvals = landingpad {i8*, i32} personality i32 (...)* @__C_specific_handler
      catch i8* bitcast (i32 (i8*, i8*)* @filter to i8*)
  %ehptr = extractvalue {i8*, i32} %ehvals, i32 0
  %sel = extractvalue {i8*, i32} %ehvals, i32 1
  %filter_sel = call i32 @llvm.eh.seh.typeid.for(i8* bitcast (i32 (i8*, i8*)* @filter to i8*))
  %matches = icmp eq i32 %sel, %filter_sel
  br i1 %matches, label %eh.except, label %eh.resume

eh.except:
  ret i1 false

eh.resume:
  resume
}

Reviewers: rjmccall, rsmith, majnemer

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

llvm-svn: 226760
2015-01-22 01:36:17 +00:00
Rafael Espindola e855c2ae0a Revert "Try to fix -Asserts build bots."
This reverts commit r226758.

Looks like rnk's 226757 fixed the real issue.
Sorry for the noise.

llvm-svn: 226759
2015-01-22 01:33:41 +00:00
Rafael Espindola b88c11281c Try to fix -Asserts build bots.
llvm-svn: 226758
2015-01-22 01:26:39 +00:00
Reid Kleckner 395dad8213 Give the block inlining test a triple to determinise output
It fails on Windows due to another temporary being emitted first, so the
LLVM internal renaming scheme gives out the name
__block_descriptor_tmp1.

llvm-svn: 226757
2015-01-22 01:19:19 +00:00
Richard Smith 855cbfddbe Remove an out-of-date and incorrect comment.
llvm-svn: 226756
2015-01-22 01:15:51 +00:00
Hans Wennborg 9cf7122ff7 Fix compiler_builtins.m test to not rely on including system stdlib.h and malloc.h
Importing _Builtin_intrinsics.sse and avx would transitively pull in those
headers, and the test would fail when building in an environment where
they were not available on the include path.

This fixes PR20995 for me.

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

llvm-svn: 226754
2015-01-22 00:45:20 +00:00
Rafael Espindola e5df59ff78 Emit DeferredDeclsToEmit in a DFS order.
Currently we emit DeferredDeclsToEmit in reverse order. This patch changes that.

The advantages of the change are that

* The output order is a bit closer to the source order. The change to
test/CodeGenCXX/pod-member-memcpys.cpp is a good example.

* If we decide to deffer more, it will not cause as large changes in the
estcases as it would without this patch.

llvm-svn: 226751
2015-01-22 00:24:57 +00:00
Rafael Espindola 701d2dd4b7 Use CHECK-LABEL when possible. NFC.
llvm-svn: 226743
2015-01-21 23:33:55 +00:00
Chris Bieneman 0a9f607f7b Adopt new cl::HideUnrelatedOptions API added r226729.
Summary: cl::HideUnrelatedOptions allows tools to hide all options not part of a specific OptionCategory. This is the common use case for cl::getRegisteredOptions, which should be deprecated in the future because it exposes implementation details of command line parsing.

Reviewers: dexonsmith

Subscribers: klimek, cfe-commits

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

llvm-svn: 226741
2015-01-21 23:26:11 +00:00
David Blaikie 835afb205f DebugInfo: Remove forced column-info workaround for inlined calls
This workaround was to provide unique call sites to ensure LLVM's inline
debug info handling would properly unique two calls to the same function
on the same line. Instead, this has now been fixed in LLVM (r226736) and
the workaround here can be removed.

Originally committed in r176895, but this isn't a straight revert due to
all the changes since then. I just searched for anything ForcedColumn*
related and removed them.

We could test this - but it didn't strike me as terribly valuable once
we're no longer adding this workaround everything just works as expected
& it's no longer a special case to test for.

llvm-svn: 226738
2015-01-21 23:08:17 +00:00
David Blaikie 07c6bfd502 DebugInfo: Remove distinct-call-inlining test case as this is being fixed in LLVM.
This test will start failing shortly once this bug is fixed in LLVM. At
that point this behavior is no longer required in Clang and will be
removed. In the interim, remove this test just to avoid the race between
the LLVM and Clang commits.

After the LLVM commit, I'll cleanup the workaround behavior in Clang.

llvm-svn: 226735
2015-01-21 22:57:22 +00:00
Rafael Espindola 2144377536 Use a CHECK-LABEL. NFC
llvm-svn: 226709
2015-01-21 22:38:24 +00:00
Reid Kleckner 9da9448339 Add the "thunk" attribute to MS ABI virtual member pointers
This attribute implies indicates that the function musttail calls
another function and returns whatever it returns. The return type of the
thunk is meaningless, as the thunk can dynamically call different
functions with different return types. So long as the callers bitcast
the thunk with the correct type, behavior is well defined.

This attribute was necessary to fix PR20944, where the indirect call
combiner noticed that the thunk returned void and replaced the results
of the indirect call instruction with undef.

Over-the-shoulder reviewed by David Majnemer.

llvm-svn: 226707
2015-01-21 22:18:17 +00:00
Francisco Lopes da Silva 24a777238e Add back a FIXME note to lit.cfg.
llvm-svn: 226703
2015-01-21 21:38:05 +00:00
Daniel Jasper e4b48c635c clang-format: Fix crasher when splitting incomplete escape sequences.
llvm-svn: 226698
2015-01-21 19:50:35 +00:00
Saleem Abdulrasool 97a01f0161 Fix isTriviallyCopyableType for arrays
Fix isTriviallyCopyableType for arrays. An array of type T is trivially copyable
if T is trivially copyable.

Patch by Agustín Bergé!

llvm-svn: 226696
2015-01-21 19:39:10 +00:00
Daniel Jasper 04b979dd81 clang-format: Fix crasher caused by incorrect resetting of token info.
llvm-svn: 226685
2015-01-21 18:35:47 +00:00
Daniel Jasper d1debfc2bb clang-format: Fix bad memory access.
llvm-svn: 226680
2015-01-21 18:04:02 +00:00
Daniel Jasper fd725c060b clang-format: Fix use-heap-after-free bug.
Discovered by the awesome test case and ASAN.

llvm-svn: 226678
2015-01-21 17:35:29 +00:00
Rafael Espindola 17c57ecf4a Used CHECK-DAG since the order is not important.
llvm-svn: 226677
2015-01-21 17:12:04 +00:00
Rafael Espindola 469e2ee83a Used CHECK-DAG since the order is not important.
llvm-svn: 226675
2015-01-21 16:56:43 +00:00
Francisco Lopes da Silva 975a9f6ece Initial support for C++ parameter completion
The improved completion in call context now works with:

 - Functions.
 - Member functions.
 - Constructors.
 - New expressions.
 - Function call expressions.
 - Template variants of the previous.

There are still rough edges to be fixed:

 - Provide support for optional parameters.         (fix known)
 - Provide support for member initializers.         (fix known)
 - Provide support for variadic template functions. (fix unknown)
 - Others?

llvm-svn: 226670
2015-01-21 16:24:11 +00:00
Rafael Espindola 11bb53bc77 Don't assume variable name.
Should fix the test in -Asserts builds.

llvm-svn: 226668
2015-01-21 16:18:42 +00:00
Rafael Espindola e20c966cf4 Make the test a bit stricter. NFC.
llvm-svn: 226667
2015-01-21 16:13:57 +00:00
Rafael Espindola 3a0e228cca Make the test a bit stricter. NFC.
llvm-svn: 226666
2015-01-21 16:03:26 +00:00
Rafael Espindola 6d1178ca40 clang-format function. NFC.
llvm-svn: 226662
2015-01-21 14:55:00 +00:00
David Majnemer 475b25eefa AST: Don't ignore alignas on EnumDecls when calculating alignment
We didn't consider any alignment attributes on an EnumDecl when
calculating alignment.

While we are here, ignore alignment specifications on typedef types if
one is used as the underlying type.  Otherwise, weird things happen:

enum Y : int;
Y y;

typedef int __attribute__((aligned(64))) u;
enum Y : u {};

What is the alignment of 'Y'?  It would be more consistent with the
overall design of enums with fixed underlying types to consider the
underlying type's UnqualifiedDesugaredType.

This fixes PR22279.

llvm-svn: 226653
2015-01-21 10:54:38 +00:00
David Majnemer 290d347471 Revert "Sema: err_after_alias is unreachable, remove it"
This reverts commit r226626.  err_after_alias is, in fact, reachable.

llvm-svn: 226633
2015-01-21 01:30:40 +00:00
David Majnemer 8c9cdb6573 MS ABI: Virtual member pointer thunks should be in COMDAT groups
They can be emitted by multiple translation units and thus belong in a
COMDAT group.

llvm-svn: 226630
2015-01-21 01:21:31 +00:00
David Majnemer 3072fc885e MS ABI: Let guard variables be present in COMDATs
A guard variable in a COMDAT'd function should also be in a COMDAT.

llvm-svn: 226629
2015-01-21 01:04:30 +00:00
David Majnemer 740d59ec49 CodeGen: Compiler generated __declspec(uuid) objects should be COMDAT'd
llvm-svn: 226628
2015-01-21 01:04:28 +00:00
David Majnemer 1efd55ff21 Sema: err_after_alias is unreachable, remove it
Examples this would have catched are now handled by the attribute
verification code.

llvm-svn: 226626
2015-01-21 00:52:17 +00:00
Kaelyn Takata 21a886936b Correct all typos in the initialization arguments, even if one could not
be corrected.

This fixes PR22250, which exposed the bug where if there's more than one
TypoExpr in the arguments, once one failed to be corrected none of the
TypoExprs after it would be handled at all thanks to an early return.

llvm-svn: 226624
2015-01-21 00:04:19 +00:00
Rafael Espindola e6fbdcedf9 Link libclang with dl if available.
This is in preparation for changing the link to use -Wl,-z,defs.

llvm-svn: 226609
2015-01-20 21:10:35 +00:00
Ben Langmuir c91ac9ed49 Fix crashes on missing @interface for category
In a few places we didn't check that Category->getClassInterface() was
not null before using it.

llvm-svn: 226605
2015-01-20 20:41:36 +00:00
Kaelyn Takata e7d3dfdb75 Add the test that was supposed to be included with r223162.
The test case is based on the reduction from PR21679 and has to be
freestanding to work correctly, since some of the expected errors (and
some of the problems that were fixed) only occur when the end of the
file is reached.

llvm-svn: 226603
2015-01-20 20:15:29 +00:00
Hans Wennborg 77dc236605 Implement command line options for stack probe space
This code adds the -mstack-probe-size command line option and implements the /Gs
compiler switch for clang-cl.

This should fix http://llvm.org/bugs/show_bug.cgi?id=21896

Patch by Andrew H!

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

llvm-svn: 226601
2015-01-20 19:45:50 +00:00
Fariborz Jahanian 86dd4565ec Patch fixes PR21932 crash on invalid code. Using
property-dot syntax on 'super' with no super
class. Patch by Jason Haslam.

llvm-svn: 226578
2015-01-20 16:53:34 +00:00
Daniel Jasper 6fd5d646cc clang-format: Fix AlwaysBreakBeforeMultilineStrings with ColumnLimit=0
Before:
  const char *x =
      "hello llvm";

After:
  const char *x = "hello llvm";

This fixes llvm.org/PR22245.
Patch by Bill Meltsner, thank you!

llvm-svn: 226564
2015-01-20 12:59:20 +00:00
Alexander Kornienko 21de0ae3d4 Re-apply "r226548 - Introduce SPIR calling conventions" reverted in r226558.
The test was fixed after a discussion with the revision author: the check
pattern was made more flexible as the "%call" part is not what we actually want
to check strictly there.

The original patch description:
===
Introduce SPIR calling conventions.

This implements Section 3.7 from the SPIR 1.2 spec:

    SPIR kernels should use "spir_kernel" calling convention.
    Non-kernel functions use "spir_func" calling convention. All
    other calling conventions are disallowed.

The patch works only for OpenCL source. Any other uses will need
to ensure that kernels are assigned the spir_kernel calling
convention correctly.
===

llvm-svn: 226561
2015-01-20 11:20:41 +00:00
Alexander Kornienko 22c9d67e34 Reverting r226548 as one of the tests fails in some configurations.
Here's the fail log from our internal setup:
===
  .../tools/clang/clang -cc1 -internal-isystem .../tools/clang/staging/include -nostdsysteminc .../tools/clang/test/CodeGenOpenCL/spir-calling-conv.cl -triple spir-unknown-unknown -emit-llvm -o -
  FileCheck .../tools/clang/test/CodeGenOpenCL/spir-calling-conv.cl
.../tools/clang/test/CodeGenOpenCL/spir-calling-conv.cl:11:12: error: expected string not found in input
 // CHECK: %call = tail call spir_func i32 @get_dummy_id(i32 0)
           ^
<stdin>:6:52: note: scanning from here
define spir_kernel void @foo(i32 addrspace(1)* %A) #0 {
                                                   ^
<stdin>:7:2: note: possible intended match here
 %1 = tail call spir_func i32 @get_dummy_id(i32 0) #2
 ^
===

Here's a failure on a public CI server:
http://lab.llvm.org:8080/green/job/clang-stage2-configure-Rlto_check/1183/

llvm-svn: 226558
2015-01-20 10:55:33 +00:00
Pavel Labath bb917683b6 Test commit, no changes.
llvm-svn: 226552
2015-01-20 09:47:57 +00:00
Alexey Bataev 42971a3342 [OPENMP] Fixed DSA processing for predetermined shared variables.
This patch allows to use predetermined shared variables in private clauses in
parallel or tasks regions.

llvm-svn: 226549
2015-01-20 07:03:46 +00:00
Sameer Sahasrabuddhe 450a58b8af Introduce SPIR calling conventions.
This implements Section 3.7 from the SPIR 1.2 spec:

    SPIR kernels should use "spir_kernel" calling convention.
    Non-kernel functions use "spir_func" calling convention. All
    other calling conventions are disallowed.

The patch works only for OpenCL source. Any other uses will need
to ensure that kernels are assigned the spir_kernel calling
convention correctly.

llvm-svn: 226548
2015-01-20 06:44:32 +00:00
Duncan P. N. Exon Smith 7fd74acd0b CodeGen: Update LoopAttributes for LLVM API change
`MDNode::getTemporary()` returns a `unique_ptr<>` as of r226504.

llvm-svn: 226505
2015-01-19 21:30:48 +00:00
Adam Nemet f893edeaea [AVX512] Add sub-vector FP extracts
Analogous to AVX2, these need to be implemented as macros to properly
propagate the immediate index operand.

Part of <rdar://problem/17688758>

llvm-svn: 226496
2015-01-19 20:12:05 +00:00
Adrian Prantl 7c6f944cdf Migrate all uses of DIVariable's FlagIndirectVariable to use a DIExpression
with a DW_OP_deref instead.

llvm-svn: 226474
2015-01-19 17:51:58 +00:00
Rafael Espindola f9b1730d41 Add comdat to thunks.
llvm-svn: 226465
2015-01-19 14:02:14 +00:00
Rafael Espindola 1be4c4546c Make this test a bit stricter. NFC.
llvm-svn: 226463
2015-01-19 13:59:31 +00:00
Daniel Jasper 9b79efb51f clang-format: Fix crasher on weird comments.
Crashing input:
  /\
  / comment

llvm-svn: 226454
2015-01-19 11:49:32 +00:00
Daniel Jasper 193cdd381b clang-format: Fix crasher on incomplete condition compilation.
Previously crashing input:
  void f(
  #if A
      );
  #else
  #endif

llvm-svn: 226451
2015-01-19 10:52:16 +00:00
Daniel Jasper 20e8c3be3c clang-format: Fix crash on invalid code.
Input "a<," made clang-format crash.

llvm-svn: 226450
2015-01-19 10:51:42 +00:00
Daniel Jasper 675b4f8350 clang-format: Fix clang-format crash on invalid code.
llvm-svn: 226449
2015-01-19 10:51:23 +00:00
Daniel Jasper 9d22bcc53e clang-format: Fix assertion when trying to build a nullptr StringRef.
llvm-svn: 226448
2015-01-19 10:51:05 +00:00
Daniel Jasper 2bd7a64d12 clang-format: Fix endless loop on incomplete try-catch-block.
llvm-svn: 226447
2015-01-19 10:50:51 +00:00
Daniel Jasper b1567c106f clang-format: Remove assert that isn't helpful.
This assert would trigger on:
  #d , = }

llvm-svn: 226446
2015-01-19 10:50:08 +00:00
Manuel Klimek 7a95ce4399 Make clang-format work in emacs buffers with unicode characters.
Emacs functions by default use character positions; convert characters
to offsets when handing parameters to clang-format and convert byte
offsets we get from clang-format back to character positions.
Reworked the code a bit so the 0-based to 1-based offset calculations
are done in the same place where we do the multi-byte to offset mapping.

llvm-svn: 226445
2015-01-19 10:48:04 +00:00
David Majnemer 6b90356ab4 Add back a check removed in r226436
It shouldn't have been removed, the code which replaced it didn't cover
this case.

llvm-svn: 226442
2015-01-19 10:21:22 +00:00
NAKAMURA Takumi 6a1565c7e5 SemaDeclCXX.cpp: Suppress a warning. [-Wunused-variable]
llvm-svn: 226441
2015-01-19 09:49:59 +00:00
David Majnemer 2dc8146643 Sema: Variable definitions cannot be __attribute__((alias))
Things that are OK:
  extern int var1 __attribute((alias("v1")));
  static int var2 __attribute((alias("v2")));

Things that are not OK:
  int var3 __attribute((alias("v3")));
  extern int var4 __attribute((alias("v4"))) = 4;

We choose to accpet:
  struct S { static int var5 __attribute((alias("v5"))); };

  This code causes assertion failues in GCC 4.8 and ICC 13.0.1, we have
  no reason to reject it.

This partially fixes PR22217.

llvm-svn: 226436
2015-01-19 09:00:28 +00:00
Craig Topper e954fd4cfa [X86] Change AVX512 intrinsics to take a 8-bit immediate for the comparision kind instead of a 32-bit immediate. This matches an equivalent change in llvm.
llvm-svn: 226431
2015-01-19 06:08:02 +00:00
Alexey Bataev 3255bf3aac [OPENMP] Disable copyprivate an nowait clauses in 'single' directive.
The copyprivate clause must not be used with the nowait clause in single
directive.

llvm-svn: 226429
2015-01-19 05:20:46 +00:00
Nathan Sidwell 44b21749b9 PR6037
Warn on inaccessible direct base

llvm-svn: 226423
2015-01-19 01:44:02 +00:00
Craig Topper a3306ca626 [x86] Teach Sema to check size of comparison immediate on avx512 cmpps/cmppd buitins.
llvm-svn: 226422
2015-01-19 01:18:22 +00:00
Craig Topper f557b09f14 [x86] Mark that the AVX-512 cmpps/cmppd builtins need an ICE for the comparison immediate. This requires converting to a macro in the header file.
llvm-svn: 226421
2015-01-19 01:18:19 +00:00
Serge Pavlov 25a8afa957 Handle unscoped enumeration in nested name specifier.
If an unscoped enum is used as a nested name specifier and the language dialect
is not C++ 11, issue an extension warning.
This fixes PR16951.

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

llvm-svn: 226413
2015-01-18 20:04:35 +00:00
Serge Pavlov f80df57d39 Update error message text.
Previously if an enumeration was used in a nested name specifier in pre-C++11
language dialect, error message was 'XXX is not a class, namespace, or scoped
enumeration'. This patch removes the word 'scoped' as in C++11 any enumeration
may be used in this context.

llvm-svn: 226410
2015-01-18 19:05:48 +00:00
David Blaikie a0a1a8726f Add comment after API changes in r225090
Code review suggestion by Eric Christopher.

llvm-svn: 226395
2015-01-18 02:48:07 +00:00
David Blaikie c6593075bf DebugInfo: Attribute complex expressions to the source location of the expression
Just as r225956 did for scalar expressions (CGExprScalar::Visit), do the
same for complex expressions.

llvm-svn: 226390
2015-01-18 01:57:54 +00:00
Nico Weber 7a92e1ad3d Address review feedback from r215780: Use a flag insteda of the heap. No behavior change.
llvm-svn: 226389
2015-01-18 01:50:35 +00:00
David Blaikie 01fb5fb128 DebugInfo: Attribute aggregate expressions to the source location of the expression
Just as r225956 did for scalar expressions (CGExprScalar::Visit), do the
same for aggregate expressions.

llvm-svn: 226388
2015-01-18 01:48:19 +00:00
David Blaikie 1c39bbb741 Refactor test so it's not lazily emitted on a global, simplifying ordering when more test cases are added
llvm-svn: 226384
2015-01-18 00:37:04 +00:00
David Blaikie 7d2a2ac57b Recommit r225083 (reverted in r225361) now that calls to aggregate initializers from in class non-static data members are explicitly attributed to the desired line.
The code setting the debug location being removed here was accidentally
leaking a location into the call to the non-static data member's ctor
call. Without it the call had no location and could cause assertion
failures if it was inlined. Now that it has a location (and a correct
one at that) this code should hopefully be no longer needed.

It's possible of course that other parts of the debug info are also
relying on the debug locations being set here to leak to where they're
needed - so we might see the same assertions again & will have to
investigate what the dependence was/is. But the chances are good that
any of those are debug info line table quality bugs we've just not found
yet anyway - so it'll be good to flush them out.

llvm-svn: 226383
2015-01-18 00:14:21 +00:00
David Blaikie a81d410d4f DebugInfo: Correct the debug location of non-static data member initializers
This was causing some trouble for otherwise dead code removed in r225085
(reverted in r225361). The location being set for function arguments was
leaking out to the call which wasn't setting its own location (so a
quality bug turned into a crasher with r225085). Fix this so r225085 can
be recommitted.

llvm-svn: 226382
2015-01-18 00:12:58 +00:00
Chandler Carruth 6f4d3a2e39 [msan] Fix a uninitialized-use bug in the template argument diffing
logic.

In one place we would try to check for the difference between integers
even if we were missing one of the integers. This would eventually end
up reading uninitialized data out of the APSInt objects. The fix is to
short circuit the sameness test when we don't have integers on both
sides.

This fixes a test failure I was seeing with MSan. Not sure whether other
bots were seeing it or not, but yay MSan. In particular the feature to
very carefully track origins back through stores throughout the program
was invaluable.

llvm-svn: 226375
2015-01-17 14:20:14 +00:00
Nico Weber 261c58c486 Add tests for two more asserts that r226365 fixed according to SLi's bot.
llvm-svn: 226371
2015-01-17 04:27:09 +00:00
Nico Weber e52e3b58c4 Add a test for something that used to crash before r226365.
llvm-svn: 226370
2015-01-17 04:14:31 +00:00
Nico Weber 71e377d6ee If a function decl cannot be merged, mark it as invalid.
Clang currently crashes on

    class C {
      C() = default;
      C() = delete;
    };

My cunning plan for fixing this was to change the `if (!FnD)` in
Parser::ParseCXXInlineMethodDef() to `if (!FnD || FnD->isInvalidDecl)` – but
alas, the second constructor decl wasn't marked as invalid.  This lets
Sema::MergeFunctionDecl() return true on function redeclarations, which leads
to them being marked invalid.

This also improves error messages when functions are redeclared.

llvm-svn: 226365
2015-01-17 02:33:17 +00:00
Nico Weber b6cb695135 Wrap to 80 columns. No behavior change.
llvm-svn: 226364
2015-01-17 02:27:54 +00:00
Nico Weber f56c85bc06 Address review feedback from r226306. No intended behavior change.
llvm-svn: 226363
2015-01-17 02:26:40 +00:00
Rafael Espindola d3e0469a84 Make sure all weak destructors go in a comdat in the ms abi.
Destructors have a special treatment in getFunctionLinkage. Instead of
duplicating the logic, check the resulting linkage.

llvm-svn: 226361
2015-01-17 01:47:39 +00:00
Richard Trieu dcd7bb022a Clean up a string comparison with StringRef. Suggestion by David Majnemer.
llvm-svn: 226359
2015-01-17 00:56:10 +00:00
Richard Trieu d4b05cef6b Remove std::move that was preventing return value optimization.
llvm-svn: 226357
2015-01-17 00:46:55 +00:00
Steven Wu cb0d13fc23 Adding option -fno-inline-asm to disallow inline asm
Summary:
This patch add a new option to dis-allow all inline asm.
Any GCC style inline asm will be reported as an error.

Reviewers: rnk, echristo

Reviewed By: rnk, echristo

Subscribers: bob.wilson, rnk, echristo, rsmith, cfe-commits

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

llvm-svn: 226340
2015-01-16 23:05:28 +00:00
Jordan Rose a34d04d35e Suggest objc_method_family(none) for a property named -newFoo or similar.
As mentioned in the previous commit, if a property (declared with @property)
has a name that matches a special Objective-C method family, the getter picks
up that family despite being declared by the property. The most correct way
to solve this problem is to add the 'objc_method_family' attribute to the
getter with an argument of 'none', which unfortunately requires an explicit
declaration of the getter.

This commit adds a note to the existing error (ARC) or warning (MRR) for
such a poorly-named property that suggests the solution; if there's already
a declaration of the getter, it even includes a fix-it.

llvm-svn: 226339
2015-01-16 23:04:31 +00:00
Jordan Rose 16ba553f75 ObjC getters with names like "newItem" should still be linked to the @property.
Two years ago I added a compile-time "optimization" to
ObjCMethodDecl::findPropertyDecl: exit early if the current method is part
of a special Objective-C method family (like 'new' or 'init'). However, if a
property (declared with @property) has a name that matches a method family,
the getter picks up that family despite being declared by the property. The
early exit then made ObjCMethodDecl::findPropertyDecl decide that there
was no associated property, despite the method itself being marked as an
accessor. This corrects that by removing the early exit.

This does /not/ change the fact that such a getter is considered to return a
value with a +1 retain count. The best way to eliminate this is by adding the
objc_method_family(none) attribute to the getter, but unlike the existing
ns_returns_not_retained that can't be applied directly to the property -- you
have to redeclare the getter instead.

(It'd be nice if @property just implied objc_method_family(none) for its
getter, but that would be a backwards-incompatible change.)

rdar://problem/19038838

llvm-svn: 226338
2015-01-16 23:04:26 +00:00
David Blaikie 71fb83ea7a Isolate test for PR22096 to clang.
Emitting inlinable calls without debug locations (in functions with
debug info, to functions with debug info) is problematic for debug info
when inlining occurs. Test specifically that we don't do that in this
case - thus the test isn't simply "don't crash", it's "include debug
location for this call" (granted it's the wrong location - fix for that
is coming)

llvm-svn: 226337
2015-01-16 22:55:09 +00:00
Kaelyn Takata ae9e97c9d6 Fix a case where delayed typo correction should have resolved an
ambiguity but wasn't.

In the new test case, "click" wasn't being corrected properly because
Sema::ClassifyName would call CorrectTypo for "click" then later
Sema::DiagnoseEmptyLookup would call CorrectTypoDelayed for the same use
of "click" (the former by the parser needing to determine what the
identifier is so it knows how to parse the statement, i.e. is it the
beginning of a declaration or an expression). CorrectTypo would record
that typo correction for "click" failed and CorrectTypoDelayed would see
that and not even try to correct the typo, even though in this case
CorrectTypo failed due to an ambiguity (both "Click" and "clock" having
an edit distance of one from "click") that could be resolved with more
information. The fix is two-fold:
  1) Have CorrectTypo not record failed corrections if the reason for
     the failure was two or more corrections with the same edit
     distance, and
  2) Make the CorrectionCandidateCallback used by
     Parser::ParseCastExpression reject FunctionDecl candidates when the
     next token after the identifier is a ".", "=", or "->" since
     functions cannot be assigned to and do not have members that can be
     referenced.

The reason for two correction spots is that from r222549 until r224375
landed, the first correction attempt would fail completely but the
second would suggest "clock" while having the note point to the
declaration of "Click".

llvm-svn: 226334
2015-01-16 22:11:04 +00:00
Eric Christopher 49b425d9d2 Remove pathname dependence. Also rewrite test to use FileCheck
at the same time.

Patch by David Callahan.

llvm-svn: 226331
2015-01-16 22:03:52 +00:00
Sean Silva 2a995148e8 Fix some copypasta typos in asserts.
Fixes PR22236

Patch by Nicolas Brunie! <nicolas.brunie@kalray.eu>

llvm-svn: 226328
2015-01-16 21:44:26 +00:00
Rafael Espindola 4af2cdb732 Also put vtables in a comdat when rtti is disabled.
llvm-svn: 226325
2015-01-16 21:41:44 +00:00
Nico Weber a089c7cb4b Wrap to 80 columns. No behavior change.
llvm-svn: 226320
2015-01-16 21:09:43 +00:00
Rafael Espindola d9b26d563a Add comdat to string literal variables on COFF.
llvm-svn: 226317
2015-01-16 20:32:35 +00:00
Nico Weber a7f137da65 Spell 0 in an enum-appropriate way. No behavior change.
llvm-svn: 226307
2015-01-16 19:35:01 +00:00
Nico Weber d89e6f79f7 Don't crash if a declarator in a friend decl doesn't have a name.
There was already an explicit check for that for the first decl.  Move that
to a different place so that it's called for the following decls too.  Also
don't randomly set the BitfieldSize ExprResult to true (this sets a pointer to
true internally).

Found by SLi's bot.

llvm-svn: 226306
2015-01-16 19:34:13 +00:00
Rafael Espindola 654542a5ed Add comdats to the RTTI variables in the microsoft abi.
llvm-svn: 226303
2015-01-16 19:23:42 +00:00
Adam Nemet c0cff244fc [AVX512] Add intrinsics for masked aligned FP loads and stores
Part of <rdar://problem/17688758>

llvm-svn: 226298
2015-01-16 18:51:50 +00:00
Adam Nemet d47dec4690 Fix typo in r225922.
llvm-svn: 226297
2015-01-16 18:51:46 +00:00
Tim Northover 7ad87af277 AArch64: implement AAPCS layout rules for bit-fields.
llvm-svn: 226294
2015-01-16 18:44:04 +00:00
Rafael Espindola 77abc3a7da Add comdats to dynamic init functions in the microsoft abi.
llvm-svn: 226286
2015-01-16 16:04:45 +00:00
Rafael Espindola a8eb9931ad Make this test a bit stricter. NFC.
llvm-svn: 226285
2015-01-16 16:02:03 +00:00
Alexander Kornienko d1f1fa2636 Attempt to fix the build with XCode 5.0.2 (and probably 5.1.1).
llvm-svn: 226282
2015-01-16 15:57:15 +00:00
Rafael Espindola 694cb5d9b7 Add comdats to constructs and destructor in the microsoft abi.
llvm-svn: 226280
2015-01-16 15:37:11 +00:00
Nathan Sidwell 9609002b4a restore fix for 18645, buildbot apparently gave a false positive.
Correct logic concerning 'T &&' deduction against lvalues.

llvm-svn: 226278
2015-01-16 15:20:14 +00:00
Alexey Bataev 24b04aa393 [OPENMP] Fixed data-sharing attributes processing for variables with global
storage.
This fix allows to use non-constant global variables, static local variables and static data
members in data-sharing attribute clauses in parallel and task regions.

llvm-svn: 226250
2015-01-16 07:11:33 +00:00
Rafael Espindola cb92c19fc4 Use a trivial comdat for C++ tables.
This produces comdats for vtables, typeinfo, typeinfo names, and vtts.

When combined with llvm not producing implicit comdats, not doing this would
cause code bloat on ELF and link errors on COFF.

llvm-svn: 226227
2015-01-15 23:18:01 +00:00
Rafael Espindola dbee8a7a7a Use a trivial comdat for inline ctor/dtor when not using C5/D5.
When combined with llvm not producing implicit comdats, not doing this would
cause code bloat on ELF and link errors on COFF.

llvm-svn: 226211
2015-01-15 21:36:08 +00:00
Hal Finkel 74618cc622 [PowerPC] Add a target option for invariant function descriptors
The PPC backend will now assume that PPC64 ELFv1 function descriptors are
invariant. This must be true for well-defined C/C++ code, but I'm providing an
option to disable this assumption in case someone's JIT-engine needs it.

llvm-svn: 226209
2015-01-15 21:22:22 +00:00
Hans Wennborg fd76d91366 Warn about dllexported explicit class template instantiation declarations (PR22035)
Clang would previously become confused and crash here.

It does not make a lot of sense to export these, so warning seems appropriate.

MSVC will export some member functions for this kind of specializations, whereas
MinGW ignores the dllexport-edness. The latter behaviour seems better.

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

llvm-svn: 226208
2015-01-15 21:18:30 +00:00
Nathan Sidwell c116802ef3 PR 20146
reject CV void return type on C definitions per 6.9.1/3

llvm-svn: 226178
2015-01-15 16:45:53 +00:00
Chandler Carruth a9711a9aa4 [PM] Track an LLVM API update which separates the TargetLibraryInfo
object from the pass that provides access to it.

We should probably refactor the createTLI code here in Clang in light of
the new structure, but I wanted this patch to be a minimal one that just
patches the behavior back together.

llvm-svn: 226158
2015-01-15 10:42:26 +00:00
David Majnemer 10fd83d11f AST: alignof might be dependent because of alignment attributes
Dependent alignment attributes should make an alignof expression
dependent as well.

llvm-svn: 226156
2015-01-15 10:04:14 +00:00
NAKAMURA Takumi 3a1e1a5424 [CMake] clangCodeGen: Prune a redundant "Target" out of libdeps. It is supplied by Analysis.
llvm-svn: 226152
2015-01-15 08:51:01 +00:00
David Majnemer f8637360e2 AST: Ensure implicit records have default visibility
Types composed with certain implicit record types would have their RTTI
marked as hidden because the implicit record type didn't have any
visibility.

This manifests itself as triggering false positives from tools like
clang's -fsantize=function feature.  The RTTI for a function type's
return type wouldn't match if the return type was an implicit record
type.

Patch by Stephan Bergmann!

llvm-svn: 226148
2015-01-15 08:41:25 +00:00
NAKAMURA Takumi 98501ea07a [CMake] Update libdeps on clangCodeGen, corresponding to r226079.
llvm-svn: 226142
2015-01-15 07:28:53 +00:00
Simon Atanasyan e6694eb245 [Mips] Define macros `__mips_isa_rev` in case of mips32r6/mips64r6 options
llvm-svn: 226136
2015-01-15 07:04:48 +00:00
David Majnemer 8e1a913cfa Sema: Recover when a function template is in an extern "C" block
llvm-svn: 226135
2015-01-15 07:04:38 +00:00
Nico Weber 8afb37e1a1 Remove unused parameter, followup to r179639. No behavior change.
llvm-svn: 226128
2015-01-15 06:00:15 +00:00
Nico Weber b6a5d05a8a Remove ASTConsumer::HandleVTable()'s bool parameter.
Sema calls HandleVTable() with a bool parameter which is then threaded through
three layers.  The only effect of this bool is an early return at the last
layer.

Instead, remove this parameter and call HandleVTable() only if the bool is
true.  No intended behavior change.

llvm-svn: 226096
2015-01-15 04:07:35 +00:00
Richard Smith 6eece29d8f PR13699: Include friend declarations in code completion results if they had a
prior visible declaration. Prefer to take template parameter names from the
first declaration.

Testcase from a patch by Francisco Lopes!

llvm-svn: 226083
2015-01-15 02:27:20 +00:00
Chandler Carruth 418bd1ab30 [PM] Update for LLVM r226078 which moved TargetLibraryInfo to the
Analysis library.

llvm-svn: 226079
2015-01-15 02:16:55 +00:00
Richard Smith 64e033f9c4 Fix crash-on-invalid and name lookup when recovering from ~X::X() typo.
llvm-svn: 226067
2015-01-15 00:48:52 +00:00
Duncan P. N. Exon Smith 8d3ef611ce IR: Move MDLocation into place (clang testcases)
Update testcases to match LLVM change in r226048.

llvm-svn: 226049
2015-01-14 22:28:03 +00:00
Steven Wu 76c508bc9a Revert "More robust deployment target parsing on darwin"
This breaks green-dragon. Revert it and investigate.

llvm-svn: 226011
2015-01-14 18:22:29 +00:00
Hans Wennborg fb8b408ba0 docs/conf.py: update for 3.7
llvm-svn: 226010
2015-01-14 18:14:05 +00:00
Hans Wennborg 0a7ec77ee0 ReleaseNotes.rst: update to 3.7
The 3.6 release notes are in the 3.6 branch.

llvm-svn: 226009
2015-01-14 18:14:03 +00:00
Hans Wennborg a38fb96796 Update cxx_dr_status.html after 3.6 branch
llvm-svn: 226008
2015-01-14 18:14:00 +00:00
Steven Wu faf31e7cc5 More robust deployment target parsing on darwin
Summary:
This is a more robust way of figuring out implicit deployment target
from isysroot. It also handles iphone simulator target.

Reviewers: bob.wilson, t.p.northover

Reviewed By: t.p.northover

Subscribers: t.p.northover, cfe-commits

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

llvm-svn: 226005
2015-01-14 18:01:27 +00:00
Daniel Jasper 1cd3c71c01 clang-format: Disable flag for Google's Java and Javascript styles.
Disable AlwaysBreakBeforeMultilineString, as the style guides don't
really say to do so.

llvm-svn: 225982
2015-01-14 12:24:59 +00:00
Daniel Sanders 998c910262 [mips] Handle transparent unions correctly.
Summary:
This fixes MultiSource/Applications/lemon on big-endian N32 by correcting the
handling of the argument to wait(). glibc defines it as a transparent union of
void* and int*. Such unions are passed according to the rules of the first
member so the argument must be passed as if it were a void* (sign extended from
i32 to i64) and not as a union (shifted to the upper bits of an i64).

wait() already behaves correctly on big-endian O32 and N64 since the union is
already the same size as an argument slot.

Reviewers: atanasyan

Reviewed By: atanasyan

Subscribers: cfe-commits

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

llvm-svn: 225981
2015-01-14 12:00:12 +00:00
Chandler Carruth 0d9593ddec [cleanup] Re-sort *all* #include lines with llvm/utils/sort_includes.py
Sorry for the noise, I managed to miss a bunch of recent regressions of
include orderings here. This should actually sort all the includes for
Clang. Again, no functionality changed, this is just a mechanical
cleanup that I try to run periodically to keep the #include lines as
regular as possible across the project.

llvm-svn: 225979
2015-01-14 11:29:14 +00:00
Chandler Carruth 575bc3ba62 [cleanup] Re-sort the #include lines using llvm/utils/sort_includes.py
No functionality changed, this is a purely mechanical cleanup to ensure
the #include order remains consistent across the project.

llvm-svn: 225975
2015-01-14 11:23:58 +00:00
Daniel Jasper e189d46512 clang-format: [Java] Support try blocks with resources.
Before:
  try
    (SomeResource rs = someFunction()) {
      Something();
    }

After:
  try (SomeResource rs = someFunction()) {
    Something();
  }

llvm-svn: 225973
2015-01-14 10:48:41 +00:00
Daniel Jasper 190fbda6de clang-format: [Java] Prefer not to break in parameter annotations.
Before:
  boolean someFunction(@Param(aaaaaaaaaaaaaaaa)
                       String aaaaa,
      String bbbbbbbbbbbbbbb) {}

After:
  boolean someFunction(
      @Param(aaaaaaaaaaaaaaaa) String aaaaa,
      String bbbbbbbbbbbbbbb) {}

llvm-svn: 225971
2015-01-14 10:36:31 +00:00
Daniel Jasper 16dbe0bc44 clang-format: [Java] Understand "import static".
llvm-svn: 225965
2015-01-14 10:02:49 +00:00
Daniel Jasper 404658aede clang-format: [Java] Don't let annotations confuse return type analysis.
Before:
  @Test
  ReturnType
  doSomething(String aaaaaaaaaaaaa, String bbbbbbbbbbbbbbb) {}

After:
  @Test
  ReturnType doSomething(
      String aaaaaaaaaaaaa, String bbbbbbbbbbbbbbb) {}

llvm-svn: 225964
2015-01-14 10:00:20 +00:00
Daniel Jasper 3e1bd1407b clang-format: [Java] Don't line-wrap before annotations' l_parens.
Before:
  @SomeAnnotation
  (aaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaa)
  int i;

After:
  @SomeAnnotation(
      aaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaa)
  int i;

llvm-svn: 225963
2015-01-14 09:51:32 +00:00
Daniel Jasper a831c58e53 clang-format: [Java] Don't get confused by leading annotations.
Before:
  @Test(a)
  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = aaaaaaaaaaaaaaaaaaaaaaaaaaaa(
      aaaaaaaaaaaaaaaaaaaaaaa);

After:
  @Test(a)
  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa =
      aaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaa);

llvm-svn: 225962
2015-01-14 09:47:57 +00:00
Brad Smith 0ebb309e47 The assembler is now enabled by default.
llvm-svn: 225961
2015-01-14 08:23:49 +00:00
David Majnemer d1091e5e34 Sema: It's cheaper to ask LookupResult::empty than to calculate linkage
llvm-svn: 225960
2015-01-14 08:08:52 +00:00
Brad Smith b7c9aff1bb Use the integrated assembler by default on 32-bit PowerPC and SPARC.
llvm-svn: 225958
2015-01-14 07:55:36 +00:00
David Blaikie 66e4197f07 Reapply r225000 (reverted in r225555): DebugInfo: Generalize debug info location handling (and follow-up commits).
Several pieces of code were relying on implicit debug location setting
which usually lead to incorrect line information anyway. So I've fixed
those (in r225955 and r225845) separately which should pave the way for
this commit to be cleanly reapplied.

The reason these implicit dependencies resulted in crashes with this
patch is that the debug location would no longer implicitly leak from
one place to another, but be set back to invalid. Once a call with
no/invalid location was emitted, if that call was ever inlined it could
produce invalid debugloc chains and assert during LLVM's codegen.

There may be further cases of such bugs in this patch - they're hard to
flush out with regression testing, so I'll keep an eye out for reports
and investigate/fix them ASAP if they come up.

Original commit message:

Reapply "DebugInfo: Generalize debug info location handling"

Originally committed in r224385 and reverted in r224441 due to concerns
this change might've introduced a crash. Turns out this change fixes the
crash introduced by one of my earlier more specific location handling
changes (those specific fixes are reverted by this patch, in favor of
the more general solution).

Recommitted in r224941 and reverted in r224970 after it caused a crash
when building compiler-rt. Looks to be due to this change zeroing out
the debug location when emitting default arguments (which were meant to
inherit their outer expression's location) thus creating call
instructions without locations - these create problems for inlining and
must not be created. That is fixed and tested in this version of the
change.

Original commit message:

This is a more scalable (fixed in mostly one place, rather than many
places that will need constant improvement/maintenance) solution to
several commits I've made recently to increase source fidelity for
subexpressions.

This resetting had to be done at the DebugLoc level (not the
SourceLocation level) to preserve scoping information (if the resetting
was done with CGDebugInfo::EmitLocation, it would've caused the tail end
of an expression's codegen to end up in a potentially different scope
than the start, even though it was at the same source location). The
drawback to this is that it might leave CGDebugInfo out of sync. Ideally
CGDebugInfo shouldn't have a duplicate sense of the current
SourceLocation, but for now it seems it does... - I don't think I'm
going to tackle removing that just now.

I expect this'll probably cause some more buildbot fallout & I'll
investigate that as it comes up.

Also these sort of improvements might be starting to show a weakness/bug
in LLVM's line table handling: we don't correctly emit is_stmt for
statements, we just put it on every line table entry. This means one
statement split over multiple lines appears as multiple 'statements' and
two statements on one line (without column info) are treated as one
statement.

I don't think we have any IR representation of statements that would
help us distinguish these cases and identify the beginning of each
statement - so that might be something we need to add (possibly to the
lexical scope chain - a scope for each statement). This does cause some
problems for GDB and possibly other DWARF consumers.

llvm-svn: 225956
2015-01-14 07:38:27 +00:00
David Blaikie 47d28e07c1 DebugInof: Correct the location of exception cleanups in global ctors/dtors and ObjC methods
Without setting the CurEHLocation these cleanups would be attributed to
whatever the last active debug line location was (the 'fn' call in the
included test cases). By setting CurEHLocation correctly the line
information is improved/corrected.

This quality bug turned into a crasher with r225000 when, instead of
allowing the last location to persist, it would be zero'd out. This
could lead to a function call (such as the dtor) being made without a
debug location - if that call was subsequently inlined (and the caller
and callee had debug info, just not the call instruction) the inliner
would violate important constraints about the debug location chains by
not updating the inlined instructions to chain up to the callee
locations.

So, by fixing this bug, I am addressing the assertion failures
introduced by r225000 and should be able to recommit that patch with
impunity...

llvm-svn: 225955
2015-01-14 07:10:46 +00:00
JF Bastien c7af264486 Revert "Insert random noops to increase security against ROP attacks (clang)"
This reverts commit:
http://reviews.llvm.org/D3393

llvm-svn: 225947
2015-01-14 05:24:11 +00:00
David Majnemer b5d2d45c5c Sema: Relax parsing of '#' in constraints
llvm-svn: 225942
2015-01-14 05:11:09 +00:00
David Majnemer ce12ed20c6 Sema: Check type compatibility with the most recent decl when merging
We would check the type information from the declaration found by lookup
but we would neglect checking compatibility with the most recent
declaration.  This would make it possible for us to not correctly
diagnose inconsistencies with declarations which were made in a
different scope.

llvm-svn: 225934
2015-01-14 02:27:38 +00:00
Adam Nemet 63a951eb1c [AVX512] Add FP unpack intrinsics
These are implemented with __builtin_shufflevector just like AVX.

We have some tests on the LLVM side to assert that these shufflevectors do
indeed generate the corresponding unpck instruction.

Part of <rdar://problem/17688758>

llvm-svn: 225922
2015-01-14 01:31:17 +00:00
JF Bastien 4cb557039d Insert random noops to increase security against ROP attacks (clang)
A pass that adds random noops to X86 binaries to introduce diversity with the goal of increasing security against most return-oriented programming attacks.

Command line options:
  -noop-insertion // Enable noop insertion.
  -noop-insertion-percentage=X // X% of assembly instructions will have a noop prepended (default: 50%, requires -noop-insertion)
  -max-noops-per-instruction=X // Randomly generate X noops per instruction. ie. roll the dice X times with probability set above (default: 1). This doesn't guarantee X noop instructions.

In addition, the following 'quick switch' in clang enables basic diversity using default settings (currently: noop insertion and schedule randomization; it is intended to be extended in the future).
  -fdiversify

This is the clang part of the patch.
llvm part: D3392

http://reviews.llvm.org/D3393
Patch by Stephen Crane (@rinon)

llvm-svn: 225910
2015-01-14 01:07:51 +00:00
Alexey Samsonov 7af6af4225 Update HelpText for -fsanitize= option.
There are too many available sanitizers now - redirect to
user manual instead of listing them all.

llvm-svn: 225894
2015-01-14 00:51:17 +00:00
Eric Christopher 2b8ef99aa8 Update for move in llvm.
llvm-svn: 225892
2015-01-14 00:50:32 +00:00
Richard Smith 43d3f55072 Look through sugar when determining whether a type is a scoped enumeration
type. Patch by Stephan Bergmann!

llvm-svn: 225889
2015-01-14 00:33:10 +00:00
David Majnemer a3b04cea04 Sema: An extern declaration can't be a redeclaration of a parameter
In the following:
void f(int x) { extern int x; }

The second declaration of 'x' shouldn't be considered a redeclaration of
the parameter.

This is a different approach to r225780.

llvm-svn: 225875
2015-01-14 00:31:13 +00:00
David Blaikie f142580dea Sink a parameter into the callee since it's always the same expression in terms of another parameter
llvm-svn: 225856
2015-01-14 00:04:42 +00:00
David Blaikie 1ae04916cc DebugInfo: Correct the location of EH cleanup for blocks
This was previously piggybacking on whatever happened to be the last
location set on CGDebugInfo/DIBuilder, which was wrong (it was often the
current location, such as the 'fn()' call site, not the end of the
block). With my improvements to set/unset the location in a scoped
manner (r225000) this went from a bad quality situation, to a crash.
Fixing this goes part-way to unblocking the recommit of r225000.

It's likely that any call to CodeGenFunction::StartFunction without the
CurEHLocation set represents a similar bug or risk of a bug. Perhaps
there are some callers that know they won't generate EH cleanups, but
I'm not sure.

I considered a generic catch-fix in StartFunction (just fallback to the
GlobalDecl's location) but that seemed like it'd mask bugs where the EH
location shouldn't be the same as the decl's location (& indeed by not
using that stop-gap I found this bug). We'll see how long I can hold out
on the generic catch-all. I might eventually be able to add an assertion
in.

llvm-svn: 225845
2015-01-13 23:06:27 +00:00
Nico Weber ed50166b6b clang-format: [Java] Detect `native` keyword.
Before:
  public native<X> Foo foo();

After:
  public native <X> Foo foo();

llvm-svn: 225839
2015-01-13 22:32:50 +00:00
Ben Langmuir c67a774e17 Add [extern_c] attribute to _Builtin_intrinsics module
This allows users to import this module inside an extern "C" {} block.

llvm-svn: 225835
2015-01-13 21:54:32 +00:00
Roman Divacky ed94e2f455 Mention FreeBSD support.
llvm-svn: 225834
2015-01-13 21:31:03 +00:00
Paul Robinson 080b1f3055 When attribute 'optnone' appears on the same declaration with a
conflicting attribute, warn about the conflict and pick a "winning"
attribute to preserve, instead of emitting an error.  This matches the
behavior when the conflicting attributes are on different declarations.

Along the way I discovered that conflicts involving __forceinline were
reported as 'always_inline' (alternate spelling, same attribute) so
fixed that up to report the attribute as spelled in the source.

llvm-svn: 225813
2015-01-13 18:34:56 +00:00
Ben Langmuir c1d88ea5a7 Inherit attributes when infering a framework module
If a module map contains
framework module * [extern_c] {}

We will now infer [extern_c] on the inferred framework modules (we
already inferred [system] as a special case).

llvm-svn: 225803
2015-01-13 17:47:44 +00:00
Ben Langmuir 7615f00e51 Handle [extern_c] attribute in module printer
I'm not sure why we have OS.indent(Indent+2) for the system attribute,
but presumably we want the same behaviour for all attributes...

llvm-svn: 225802
2015-01-13 17:47:38 +00:00
Ben Langmuir d3d7f3b5bd Remove unused method canInferFrameworkModule
llvm-svn: 225801
2015-01-13 17:47:29 +00:00
Daniel Sanders cdcb580d4e [mips] Fix va_arg() for pointer types on big-endian N32.
Summary:
The Mips ABI's treat pointers in the same way as integers. They are
sign-extended to 32-bit for O32, and 64-bit for N32/N64. This doesn't matter
for O32 and N64 where pointers are already the correct width but it does matter
for big-endian N32, where pointers are 32-bit and need promoting.

The caller side is already passing pointers correctly. This patch corrects the
callee.

Reviewers: vmedic, atanasyan

Reviewed By: atanasyan

Subscribers: cfe-commits

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

llvm-svn: 225782
2015-01-13 10:47:00 +00:00
David Majnemer cdf8a71d36 Revert "Sema: An extern declaration can't be a redeclaration of a parameter"
This reverts commit r225780, we can't compile line 181 in
sanitizer_platform_limits_posix.cc with this commit.

llvm-svn: 225781
2015-01-13 10:14:57 +00:00
David Majnemer c3691827c0 Sema: An extern declaration can't be a redeclaration of a parameter
In the following:
void f(int x) { extern int x; }

The second declaration of 'x' shouldn't be considered a redeclaration of
the parameter.

llvm-svn: 225780
2015-01-13 09:55:56 +00:00
Manuel Klimek 1ba46c661c Update clang-format.el to use xml output and patch in the returned chunks.
This leads to better undo behavior and avoids window content jumping
around.

Patch by Johann Klähn.

llvm-svn: 225777
2015-01-13 08:35:34 +00:00
David Majnemer d5946f51a5 Parse: Switch to using EOF tokens for late parsed attributes
The EOF token injection technique is preferable to using
isBeforeInTranslationUnit to determine whether or not additional cleanup
is needed.  I don't have an example off-hand that requires it but it is
nicer nonetheless.

llvm-svn: 225776
2015-01-13 08:35:24 +00:00
David Majnemer b3c6d52d3a Parse: Don't crash when default argument in typedef consists of sole '='
We'd crash trying to make the SourceRange for the tokens we'd like to
highlight.  Don't assume there is more than one token makes up the
default argument.

llvm-svn: 225774
2015-01-13 07:42:33 +00:00
David Majnemer 906ed278b9 Parse: Don't crash if missing an initializer expression
llvm-svn: 225768
2015-01-13 05:28:24 +00:00
David Majnemer a7ea1b1466 Parse: use the EOF token method to lex inline method bodies
Mark the end of the method body with an EOF token, collect it once we
expect to be done with method body parsing.  No functionality change
intended.

llvm-svn: 225765
2015-01-13 05:06:20 +00:00
David Majnemer 7cceba5d76 Parse: Further simplify ParseLexedMethodDeclaration
No functionality change intended, just moving code around to make it
simpler.

llvm-svn: 225763
2015-01-13 04:20:57 +00:00
Nico Weber 8b51ae93e4 Mark vtable used on explicit destructor definitions.
There are two things in a C++ program that need to read the vtable pointer:
Constructors and destructors.  (A few other operations -- virtual calls,
dynamic cast, rtti -- read the vtable pointer off a this pointer, but for
this they don't need the vtable symbol.)  Implicit constructors and destructors
and explicit constructors already marked the vtable as used, but explicit
destructors didn't.

Note that the only thing sema's "mark a class's vtable used" does is to mark all 
final overriders of the class as referenced, it does _not_ cause emission of
the vtable itself.  This is done on demand by codegen, independent of sema,
since sema might emit functions that are not referenced.  (The exception are
vtables that are forced via key functions -- these are forced onto codegen
by sema.)

This bug went unnoticed for years because it doesn't have observable effects
(yet -- I want to change this in PR20337, which is why I noticed this).

r213109 made it so that _calls_ to constructors don't mark the vtable used.
Currently, _calls_ to destructors still mark the vtable used.  If that
wasn't the case, this program would tickle the problem:

  test.h:
    template <typename T>
    struct B {
      int* p;
      virtual ~B() { delete p; }
      virtual void f() {}
    };

    struct __attribute__((visibility("default"))) C {
      C();
      B<int> m;
    };

  test2.cc:
    #include "test.h"
    int main() {
      C* c = new C;
      delete c;
    }

  test3.cc:
    #include "test.h"
    C::C() {}

  # This bin/clang++ binary doesn't MarkVTableUsed() for virtual dtor calls:
  $ bin/clang++ -shared test3.cc -std=c++11 -O2  -fvisibility=hidden \
        -fvisibility-inlines-hidden  -o libtest3.dylib
  $ bin/clang++ test2.cc -std=c++11 -O2  -fvisibility=hidden \
        -fvisibility-inlines-hidden  libtest3.dylib 
  Undefined symbols for architecture x86_64:
    "B<int>::f()", referenced from:
        vtable for B<int> in test2-af8f4f.o
  ld: symbol(s) not found for architecture x86_64

What's happening here is that there's a copy of B's vtable hidden in
libtest3.dylib, because C's constructor caused an implicit instantiation of that
(and implicit constructors generate vtables).
test2.cc calls C's destructDr, which destroys the B<int> member,
which wants to overwrite the vtable back to B (think of B as the base of a class
hierarchy, and of hierarchical destruction -- maybe we shouldn't do the vtable
writing in destructors of final classes), but there's nothing in test2.cc that
marks B's vtable used.  So codegen writes out the vtable, but since it wasn't
marked used, sema didn't mark all the virtual functions (in particular f())
as used.

Note that this change makes us reject programs we didn't reject before (see
the included Sema test case), but both gcc and cl also reject this code, and
clang used to reject it before r213109.

llvm-svn: 225761
2015-01-13 03:52:11 +00:00
Alexey Bataev 26a3924a4f [OPENMP] Consider global named register variables as threadprivate by default.
Register are thread-local by default, so we have to consider them as threadprivate.

llvm-svn: 225759
2015-01-13 03:35:30 +00:00
Richard Trieu 36d0b2b49f Extend the self move warning to record types.
Move the logic for checking self moves into SemaChecking and add that function
to Sema since it is now used in multiple places.

llvm-svn: 225756
2015-01-13 02:32:02 +00:00
Richard Smith b1c217e492 If we don't find a matching ) for a ( in an exception specification, keep the tokens around so we can diagnose an error rather than silently discarding them.
llvm-svn: 225755
2015-01-13 02:24:58 +00:00
Richard Smith 00a4a85d2b PR22208: On FreeBSD systems, __STDC_MB_MIGHT_NEQ_WC__ is expected to be defined
even though every basic source character literal has the same numerical value
as a narrow or wide character literal.

It appears that the FreeBSD folks are trying to use this macro to mean
something other than what the relevant standards say it means, but their usage
is conforming, so put up with it.

llvm-svn: 225751
2015-01-13 01:47:45 +00:00
Nico Weber c4b8e79396 Simplify a test. No behavior change.
Templates don't have key functions (cf computeKeyFunction() in
RecordLayoutBuilder.cpp), so don't have something that looks like one.

Also, instead of a vcall to force generation of the vtable, just construct
the object.  This is how the repro on PR5557 (what the test is for) worked too.

llvm-svn: 225741
2015-01-13 00:24:46 +00:00
Alexey Samsonov 8845952b54 Reimplement -fsanitize-recover family of flags.
Introduce the following -fsanitize-recover flags:
  - -fsanitize-recover=<list>: Enable recovery for selected checks or
      group of checks. It is forbidden to explicitly list unrecoverable
      sanitizers here (that is, "address", "unreachable", "return").
  - -fno-sanitize-recover=<list>: Disable recovery for selected checks or
     group of checks.
  - -f(no-)?sanitize-recover is now a synonym for
    -f(no-)?sanitize-recover=undefined,integer and will soon be deprecated.

These flags are parsed left to right, and mask of "recoverable"
sanitizer is updated accordingly, much like what we do for -fsanitize= flags.
-fsanitize= and -fsanitize-recover= flag families are independent.

CodeGen change: If there is a single UBSan handler function, responsible
for implementing multiple checks, which have different recoverable setting,
then we emit two handler calls instead of one:
the first one for the set of "unrecoverable" checks, another one - for
set of "recoverable" checks. If all checks implemented by a handler have the
same recoverability setting, then the generated code will be the same.

llvm-svn: 225719
2015-01-12 22:39:12 +00:00
Rafael Espindola 0d4fb98504 [patch][pr19848] Produce explicit comdats in clang.
The llvm IR until recently had no support for comdats. This was a problem when
targeting C++ on ELF/COFF as just using weak linkage would cause quite a bit of
dead bits to remain on the executable (unless -ffunction-sections,
-fdata-sections and --gc-sections were used).

To fix the problem, llvm's codegen will just assume that any weak or linkonce
that is not in an explicit comdat should be output in one with the same name as
the global.

This unfortunately breaks cases like pr19848 where a weak symbol is not
xpected to be part of any comdat.

Now that we have explicit comdats in the IR, we can finally get both cases
right.

This first patch just makes clang give explicit comdats to GlobalValues where
t is allowed to.

A followup patch to llvm will then stop implicitly producing comdats.

llvm-svn: 225705
2015-01-12 22:13:53 +00:00
Nico Weber 0a02992dc0 Wrap to 80 columns. No behavior change.
llvm-svn: 225703
2015-01-12 21:24:10 +00:00
Nico Weber f867c17ab5 Don't use a doc comment in a function body.
llvm-svn: 225701
2015-01-12 21:22:27 +00:00
Nathan Sidwell 822f041619 reverting due to build bot failure
llvm-svn: 225684
2015-01-12 20:13:20 +00:00
Ben Langmuir 74d5e7a79e Fix typo Block.h vs Blocks.h
Thanks for Jeremy for noticing!

llvm-svn: 225666
2015-01-12 19:42:27 +00:00
Bill Seurer cf2c96b0f6 [PowerPC]To provide better compatibility with gcc I added the __bool keyword to the Alitivec support in clang. __bool is functionally identical to using bool when declaring vector types. For example:
vector bool char v_bc;
vector __bool char v___bc;

clang already supported vector/__vector and pixel/__pixel but was missing __bool.

http://llvm.org/bugs/show_bug.cgi?id=19220

For reference: https://gcc.gnu.org/onlinedocs/gcc-4.9.2/gcc/PowerPC-AltiVec_002fVSX-Built-in-Functions.html

http://reviews.llvm.org/D6882

llvm-svn: 225664
2015-01-12 19:35:51 +00:00
Ben Langmuir a0c32e9310 Fix bogus 'method is unavailable' errors with modules
This just tweaks the fix from r224892 (which handled PCHs) to work with
modules, where we will serialize each method individually and hence the
hasMoreThanOneDecl bit needs to be updated as we add the methods.

llvm-svn: 225659
2015-01-12 19:27:00 +00:00
Toma Tabacu cfab40f95b [mips] Explain why we need to always clobber for MIPS inline asm. NFC.
llvm-svn: 225632
2015-01-12 14:41:30 +00:00
Alexander Kornienko 00691cf3bb Fix assertion in BreakableBlockComment (http://llvm.org/PR21916).
Reviewers: djasper

Reviewed By: djasper

Subscribers: klimek, cfe-commits

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

llvm-svn: 225628
2015-01-12 13:11:12 +00:00
NAKAMURA Takumi b70f83eb10 Suppress clang/test/Driver/rewrite-map-in-diagnostics.c on win32 for now. This doesn't fail on "env clang". Investigating.
llvm-svn: 225626
2015-01-12 11:39:04 +00:00
Daniel Jasper d6a1cab1bc clang-format: Improve format of lambdas in ctor initializers.
Before:
  Constructor()
      : Constructor([] { // comment
        int i;
      }) {}

After:
  Constructor()
      : Constructor([] { // comment
          int i;
        }) {}

llvm-svn: 225625
2015-01-12 10:23:24 +00:00
Alexey Bataev 19acc3d351 Rename RefersToCapturedVariable to RefersToEnclosingVariableOrCapture, NFC
llvm-svn: 225624
2015-01-12 10:17:46 +00:00
Daniel Jasper 2337f28063 clang-format: Fix formatting of inline asm.
Specifically, adjust the leading "__asm {" and trailing "}" while still
leaving the assembly inside it alone.

This fixes llvm.org/PR22190.

llvm-svn: 225623
2015-01-12 10:14:56 +00:00
David Majnemer 83de336b71 Parse: Get rid of cxx_exceptspec_end, use EOF instead
Similar to r225619, use a special EOF token to mark the end of the
exception specification instead of cxx_exceptspec_end.  Use the current
scope as the marker.

llvm-svn: 225622
2015-01-12 09:16:57 +00:00