]> granicus.if.org Git - clang/log
clang
7 years ago[libclang] [OpenCL] Expose more OpenCL CIndex types
Sven van Haastregt [Tue, 23 May 2017 10:36:43 +0000 (10:36 +0000)]
[libclang] [OpenCL] Expose more OpenCL CIndex types

Expose pipe, sampler_t, clk_event_t, queue_t, reserve_id_t, and all
image types.

Update the opencl-types.cl test RUN line such that we can test the
OpenCL 2.0 types.

Patch by Simon Perretta.

Differential Revision: https://reviews.llvm.org/D33197

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

7 years ago[mips] Make checks in CodeGen/mips-varargs.c less fragile
Simon Dardis [Tue, 23 May 2017 09:42:50 +0000 (09:42 +0000)]
[mips] Make checks in CodeGen/mips-varargs.c less fragile

This test was failing on our fork of clang because it was not capturing
[[ARG]] in the N32 case. Therefore it used the value from the last function
which does not always have to be the same. All other cases were already
capturing ARG so this appears to be an oversight.
The test now uses -enable-var-scope to prevent such errors in the future.

Reviewers: sdardis, atanasyan

Patch by: Alexander Richardson

Differential Revision: https://reviews.llvm.org/D32425

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

7 years ago[coroutines] Skip over passthrough operator co_await
Gor Nishanov [Tue, 23 May 2017 05:25:31 +0000 (05:25 +0000)]
[coroutines] Skip over passthrough operator co_await

https://reviews.llvm.org/D31627

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

7 years agoAdded LLVM_FALLTHROUGH to address gcc warning: this statement may fall through.
Galina Kistanova [Tue, 23 May 2017 05:17:49 +0000 (05:17 +0000)]
Added LLVM_FALLTHROUGH to address gcc warning: this statement may fall through.

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

7 years ago[coroutines] Add emission of initial and final suspends
Gor Nishanov [Tue, 23 May 2017 05:04:01 +0000 (05:04 +0000)]
[coroutines] Add emission of initial and final suspends

https://reviews.llvm.org/D31608

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

7 years ago[coroutines] Add support for deallocation elision
Gor Nishanov [Tue, 23 May 2017 04:21:27 +0000 (04:21 +0000)]
[coroutines] Add support for deallocation elision

Wrap deallocation code with:

  if (auto *mem = coro.free()) Deallocate

When backend decides to elide allocations it will replace coro.free with nullptr to suppress deallocation code.

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

7 years ago[coroutines] Replace all coro.frame builtins with an SSA value of coro.begin
Gor Nishanov [Tue, 23 May 2017 03:46:59 +0000 (03:46 +0000)]
[coroutines] Replace all coro.frame builtins with an SSA value of coro.begin

SemaCoroutine forms expressions referring to the coroutine frame of the enclosing coroutine using coro.frame builtin.
During codegen, we emit llvm.coro.begin intrinsic that returns the address of the coroutine frame.
When coro.frame is emitted, we replace it with SSA value of coro.begin.

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

7 years ago[coroutines] Add support for allocation elision
Gor Nishanov [Tue, 23 May 2017 01:13:17 +0000 (01:13 +0000)]
[coroutines] Add support for allocation elision

Summary:
We wrap allocation code so that backend can elide it if necessary.
llvm.coro.alloc intrinsic returns true, when allocation is needed and false otherwise.

```
  %NeedAlloc = call i1 @llvm.coro.alloc(token %2)
  br i1 %NeedAlloc, label %AllocBB, label %InitBB

AllocBB:
  %5 = call i64 @llvm.coro.size.i64()
  %call = call i8* @_Znwm(i64 %5) ; operator new
  br label %InitBB

InitBB:
  %Phi = phi i8* [ null, %0 ], [ %call, %4 ]
  call i8* @llvm.coro.begin(token %2, i8* %Phi)
```

Reviewers: majnemer, EricWF

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D31584

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

7 years ago[NFC, Refactor] Modernize TemplateIdAnnotation using TrailingObjects
Faisal Vali [Tue, 23 May 2017 01:07:12 +0000 (01:07 +0000)]
[NFC, Refactor] Modernize TemplateIdAnnotation using TrailingObjects

A refactoring of TemplateIdAnnotation that uses TrailingObjects to create a variably-sized object on the heap.

https://reviews.llvm.org/D31414

Thanks to Aaron B for the review!

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

7 years agoAdjust clang test for r303590
Teresa Johnson [Tue, 23 May 2017 00:35:09 +0000 (00:35 +0000)]
Adjust clang test for r303590

Forgot to commit this separately from the llvm change to use a new
module flag type for pic and pie levels. Should fix the bot errors

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

7 years agoAdd option to include multiple lines in snippets.
Richard Smith [Mon, 22 May 2017 23:51:40 +0000 (23:51 +0000)]
Add option to include multiple lines in snippets.

When a diagnostic includes a highlighted range spanning multiple lines, clang
now supports printing out multiple lines of context if necessary to show the
highlighted ranges. This is not yet exposed in the driver, but can be enabled
by "-Xclang -fcaret-diagnostics-max-lines -Xclang N".

This is experimental until we can find out whether it works well in practice,
and if so, what a good default for the maximum number of lines is.

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

7 years ago[coroutines] Fix coro-eh-cleanup.cpp test
Gor Nishanov [Mon, 22 May 2017 22:41:28 +0000 (22:41 +0000)]
[coroutines] Fix coro-eh-cleanup.cpp test

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

7 years ago[coroutines] Wrap the body of the coroutine in try-catch
Gor Nishanov [Mon, 22 May 2017 22:33:17 +0000 (22:33 +0000)]
[coroutines] Wrap the body of the coroutine in try-catch

Summary:
If unhandled_exception member function is present in the coroutine promise,
wrap the body of the coroutine in:

```
try {
  body
} catch(...) { promise.unhandled_exception(); }
```

Reviewers: EricWF, rnk, rsmith

Reviewed By: rsmith

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D31692

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

7 years agoGive files from #line the characteristics of the current file
Reid Kleckner [Mon, 22 May 2017 21:42:58 +0000 (21:42 +0000)]
Give files from #line the characteristics of the current file

This allows #line directives to appear in system headers that have code
that clang would normally warn on. This is compatible with GCC, which is
easy to test by running `gcc -E`.

Fixes PR30752

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

7 years ago[coroutines] Build GRO declaration and return GRO statement
Gor Nishanov [Mon, 22 May 2017 20:22:23 +0000 (20:22 +0000)]
[coroutines] Build GRO declaration and return GRO statement

Summary:
1. build declaration of the gro local variable that keeps the result of get_return_object.
2. build return statement returning the gro variable
3. emit them during CodeGen
4. sema and CodeGen tests updated

Reviewers: EricWF, rsmith

Reviewed By: rsmith

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D31646

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

7 years ago[index] Index the default template parameter values
Alex Lorenz [Mon, 22 May 2017 16:50:54 +0000 (16:50 +0000)]
[index] Index the default template parameter values

rdar://32323724

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

7 years ago[mips] Add one more check to the micromips attribute test case. NFC
Simon Atanasyan [Mon, 22 May 2017 15:53:34 +0000 (15:53 +0000)]
[mips] Add one more check to the micromips attribute test case. NFC

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

7 years ago[mips] Quote command line options with `` in the micromips attribute description...
Simon Atanasyan [Mon, 22 May 2017 15:53:31 +0000 (15:53 +0000)]
[mips] Quote command line options with `` in the micromips attribute description. NFC

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

7 years ago[index] Index the deleted functions
Alex Lorenz [Mon, 22 May 2017 15:42:45 +0000 (15:42 +0000)]
[index] Index the deleted functions

rdar://32323386

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

7 years ago[Sema][ObjC] Fix a bug where -Wunguarded-availability was emitted at the wrong location
Erik Pilkington [Mon, 22 May 2017 15:41:12 +0000 (15:41 +0000)]
[Sema][ObjC] Fix a bug where -Wunguarded-availability was emitted at the wrong location

Differential revision: https://reviews.llvm.org/D33250

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

7 years ago[index] Visit the default argument values in function definitions
Alex Lorenz [Mon, 22 May 2017 15:17:44 +0000 (15:17 +0000)]
[index] Visit the default argument values in function definitions

rdar://32323315

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

7 years agoclang-format: [JS] avoid line breaks before unindented r_parens.
Martin Probst [Mon, 22 May 2017 14:58:26 +0000 (14:58 +0000)]
clang-format: [JS] avoid line breaks before unindented r_parens.

The change that enabled wrapping at the previous scope's indentation had
unintended side-effects in that clang-format would prefer to wrap
closing parentheses to the next line if it avoided a wrap on the next
line (assuming very narrow lines):

    fooObject
        .someCall(barbazbam)
        .then(bam);

Would get formatted as:

    fooObject.someCall(barbazbam
    ).then(bam);

Because the ')' is now indented at the parent level (fooObject).

Normally formatting a builder pattern style call sequence like that is
outlawed in clang-format anyway. However for JavaScript this is special
cased to support trailing .bind calls.

This change disallows this special case when following a closing ')' to
avoid the problem.

Included are some random comment fixes.

Reviewers: djasper

Subscribers: klimek, cfe-commits

Differential Revision: https://reviews.llvm.org/D33399

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

7 years agoclang-format: do not reflow bullet lists
Francois Ferrand [Mon, 22 May 2017 14:47:17 +0000 (14:47 +0000)]
clang-format: do not reflow bullet lists

Summary:
This patch prevents reflowing bullet lists in block comments.

It handles all lists supported by doxygen and markdown, e.g. bullet
lists starting with '-', '*', '+', as well as numbered lists starting
with -# or a number followed by a dot.

Reviewers: krasimir

Reviewed By: krasimir

Subscribers: djasper, klimek, cfe-commits

Differential Revision: https://reviews.llvm.org/D33285

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

7 years ago[index] 'using namespace' declarations in functions should record
Alex Lorenz [Mon, 22 May 2017 14:39:39 +0000 (14:39 +0000)]
[index] 'using namespace' declarations in functions should record
the reference to the namespace

rdar://32323190

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

7 years ago[mips] Support `micromips` attribute
Simon Atanasyan [Mon, 22 May 2017 12:47:43 +0000 (12:47 +0000)]
[mips] Support `micromips` attribute

This patch adds support for the `micromips` and `nomicromips` attributes
for MIPS targets.

Differential revision: https://reviews.llvm.org/D33363

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

7 years ago[clang-format] Keep trailing preprocessor line comments separate from the following...
Krasimir Georgiev [Mon, 22 May 2017 10:07:56 +0000 (10:07 +0000)]
[clang-format] Keep trailing preprocessor line comments separate from the following section comments

Summary:
r303415 changed the way a sequence of line comments following a preprocessor
macro is handled, which has the unfortunate effect of aligning a trailing
preprocessor line comment and following unrelated section comments, so:
```
#ifdef A // comment about A
// section comment
#endif
```
gets turned into:
```
#ifdef A // comment about A
         // section comment
#endif
```
This patch fixes this by additionally checking the original start columns of
the line comments.

Reviewers: djasper

Reviewed By: djasper

Subscribers: klimek, cfe-commits

Differential Revision: https://reviews.llvm.org/D33394

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

7 years agoclang-format: Allow customizing the penalty for breaking assignment
Francois Ferrand [Mon, 22 May 2017 08:28:17 +0000 (08:28 +0000)]
clang-format: Allow customizing the penalty for breaking assignment

Summary:
Add option to customize the penalty for breaking assignment

This allows increasing the priority of the assignment, to prefer spliting
an operation instead of splitting the assignment, e.g. :

  int a = bbbbbbbbbbbbbbbb +
          cccccccccccccccc;

Reviewers: krasimir, djasper

Reviewed By: djasper

Subscribers: cfe-commits, klimek

Differential Revision: https://reviews.llvm.org/D32477

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

7 years ago[Format] Add curly braces to suppress a -Wmisleading-indentation warning from gcc.
Craig Topper [Sun, 21 May 2017 07:29:07 +0000 (07:29 +0000)]
[Format] Add curly braces to suppress a -Wmisleading-indentation warning from gcc.

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

7 years agoFix PR25627: constant expressions being odr-used in template arguments.
Faisal Vali [Sat, 20 May 2017 19:58:04 +0000 (19:58 +0000)]
Fix PR25627: constant expressions being odr-used in template arguments.

This patch ensures that clang processes the expression-nodes that are generated when disambiguating between types and expressions within template arguments as constant-expressions by installing the ConstantEvaluated ExpressionEvaluationContext just before attempting the disambiguation - and then making sure that Context carries through into ParseConstantExpression (by refactoring it out into a function that does not create its own EvaluationContext: ParseConstantExpressionInExprEvalContext)

Note, prior to this patch, trunk would correctly disambiguate and identify the expression as an expression - and while it would annotate the token with the expression - it would fail to complete the odr-use processing (specifically, failing to trigger Sema::UpdateMarkingForLValueToRValue as is done for all Constant Expressions, which would remove it from being considered odr-used).  By installing the ConstantExpression Evaluation Context prior to disambiguation, and making sure it carries though, we ensure correct processing of the expression-node.

For e.g:
  template<int> struct X { };
  void f() {
    const int N = 10;
    X<N> x; // should be OK.
    [] { return X<N>{}; }; // Should be OK - no capture - but clang errors!
  }

See a related bug: https://bugs.llvm.org//show_bug.cgi?id=25627

In summary (and reiteration), the fix is as follows:

    - Remove the EnteredConstantEvaluatedContext action from ParseTemplateArgumentList (relying on ParseTemplateArgument getting it right)
    - Add the EnteredConstantEvaluatedContext action just prior to undergoing the disambiguating parse, and if the parse succeeds for an expression, carry the context though into a refactored version of ParseConstantExpression that does not create its own ExpressionEvaluationContext.

See https://reviews.llvm.org/D31588 for additional context regarding some of the more fragile and complicated approaches attempted, and Richard's feedback that eventually shaped the simpler and more robust rendition that is being committed.

Thanks Richard!

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

7 years ago[Devirtualization] insert placement new barrier with -O0
Piotr Padlewski [Sat, 20 May 2017 08:56:18 +0000 (08:56 +0000)]
[Devirtualization] insert placement new barrier with -O0

Summary:
To not break LTO with different optimizations levels, we should insert
the barrier regardles of optimization level.

Reviewers: rjmccall, rsmith, mehdi_amini

Reviewed By: mehdi_amini

Subscribers: mehdi_amini, cfe-commits

Differential Revision: https://reviews.llvm.org/D32401

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

7 years ago[index] Fix forward declarations interfering with USR generation of external source...
Argyrios Kyrtzidis [Sat, 20 May 2017 04:11:33 +0000 (04:11 +0000)]
[index] Fix forward declarations interfering with USR generation of external source symbols

Patch by Nathan Hawes.
https://reviews.llvm.org/D33346

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

7 years agoRename RAII objects for performing eager instantiation to have names that
Richard Smith [Sat, 20 May 2017 01:36:41 +0000 (01:36 +0000)]
Rename RAII objects for performing eager instantiation to have names that
describe what they're for, not how they do it, and factor out a bit more
common code into them.

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

7 years agoCodeGenModule: Always output wchar_size, check LLVM assumptions.
Matthias Braun [Sat, 20 May 2017 01:29:55 +0000 (01:29 +0000)]
CodeGenModule: Always output wchar_size, check LLVM assumptions.

Re-commit r303463 now that LLVM is fixed and adjust some lit tests.

llvm::TargetLibraryInfo needs to know the size of wchar_t to work on
functions like `wcslen`. This patch changes clang to always emit the
wchar_size module flag (it would only do so for ARM previously).
This also adds an `assert()` to ensure the LLVM defaults based on the
target triple are in sync with clang.

Differential Revision: https://reviews.llvm.org/D32982

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

7 years agoRevert "CodeGenModule: Always output wchar_size, check LLVM assumptions."
Matthias Braun [Sat, 20 May 2017 00:38:27 +0000 (00:38 +0000)]
Revert "CodeGenModule: Always output wchar_size, check LLVM assumptions."

Let's revert this for now (and with it the assert()) to get the bots
back to green until I have LLVM synced up properly.

This reverts commit r303463.

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

7 years agoFix valid-for-expr ellipses eaten as invalid decl
Hubert Tong [Sat, 20 May 2017 00:21:55 +0000 (00:21 +0000)]
Fix valid-for-expr ellipses eaten as invalid decl

Summary:
The trial parse for declarative syntax accepts an invalid pack
declaration syntax, which is ambiguous with valid pack expansions of
expressions. This commit removes the invalid pack declaration syntax to
avoid mistaking valid pack expansions as invalid declarator components.

Additionally, the trial parse of a //template-argument-list// then needs
to handle the optional ellipsis that is part of that grammar, as opposed
to relying on the trial parse for declarators accepting stray ellipses.

Reviewers: rsmith, rcraik, aaron.ballman

Reviewed By: rsmith

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D33339

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

7 years agoRemove last (unnecessary) use of mapping from SourceLocation to Module and
Richard Smith [Fri, 19 May 2017 23:49:00 +0000 (23:49 +0000)]
Remove last (unnecessary) use of mapping from SourceLocation to Module and
remove the mechanism for doing so.

This mechanism was incorrect in the presence of preprocessed modules (and
#pragma clang module begin/end).

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

7 years ago[modules] Simplify module macro handling in non-local-submodule-visibility mode.
Richard Smith [Fri, 19 May 2017 23:32:38 +0000 (23:32 +0000)]
[modules] Simplify module macro handling in non-local-submodule-visibility mode.

When reaching the end of a module, we used to convert its macros to
ModuleMacros but also leave them in the MacroDirective chain for the
identifier. This meant that every lookup of such a macro would find two
(identical) definitions. It also made it difficult to determine the correct
owner for a macro when reaching the end of a module: the most recent
MacroDirective in the chain could be from an #included submodule rather than
the current module.

Simplify this: whenever we convert a MacroDirective to a ModuleMacro when
leaving a module, clear out the MacroDirective chain for that identifier, and
just rely on the ModuleMacro to provide the macro definition information.

(We don't want to do this for local submodule visibility mode, because in that
mode we maintain a distinct MacroDirective chain for each submodule, and we
need to keep around the prior MacroDirective in case we re-enter the submodule
-- for instance, if its header is #included more than once in a module build,
we need the include guard directive to stick around. But the problem doesn't
arise in this case for the same reason: each submodule has its own
MacroDirective chain, so the macros don't leak out of submodules in the first
place.)

This reinstates r302932, reverted in r302947, with a fix for a bug that
resulted in us sometimes losing macro definitions due to failing to clear out
the overridden module macro list when promoting a directive to a module macro.

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

7 years agoCodeGenModule: Always output wchar_size, check LLVM assumptions.
Matthias Braun [Fri, 19 May 2017 22:37:15 +0000 (22:37 +0000)]
CodeGenModule: Always output wchar_size, check LLVM assumptions.

llvm::TargetLibraryInfo needs to know the size of wchar_t to work on
functions like `wcslen`. This patch changes clang to always emit the
wchar_size module flag (it would only do so for ARM previously).
This also adds an `assert()` to ensure the LLVM defaults based on the
target triple are in sync with clang.

Differential Revision: https://reviews.llvm.org/D32982

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

7 years ago[ODRHash] Revert r303450 to fix buildbot
Richard Trieu [Fri, 19 May 2017 22:35:41 +0000 (22:35 +0000)]
[ODRHash] Revert r303450 to fix buildbot

r303450
[ODRHash] Support TemplateName and TemplateArgument

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

7 years agoDo not issue -Wnullability-completeness for dependent types that are not written...
Richard Smith [Fri, 19 May 2017 20:20:13 +0000 (20:20 +0000)]
Do not issue -Wnullability-completeness for dependent types that are not written as pointer types.

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

7 years ago[ODRHash] Support TemplateName and TemplateArgument
Richard Trieu [Fri, 19 May 2017 20:05:16 +0000 (20:05 +0000)]
[ODRHash] Support TemplateName and TemplateArgument

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

7 years ago[modules] Further delay calling DeclMustBeEmitted until it's safe.
Vassil Vassilev [Fri, 19 May 2017 16:46:06 +0000 (16:46 +0000)]
[modules] Further delay calling DeclMustBeEmitted until it's safe.

As discussed in D30793, we have some unsafe calls to isConsumerInterestedIn().
This patch implements Richard's suggestion (from the inline comment) that we
should track if we just deserialized an declaration. If we just deserialized,
we can skip the unsafe call because we know it's interesting. If we didn't just
deserialize the declaration, calling isConsumerInterestedIn() should be safe.

We tried to create a test case for this but we were not successful.

Patch by Raphael Isemann (D32499)!

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

7 years agoRestore and update documentation comment for EmitPointerWithAlignment
Krzysztof Parzyszek [Fri, 19 May 2017 12:03:34 +0000 (12:03 +0000)]
Restore and update documentation comment for EmitPointerWithAlignment

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

7 years ago[clang-format] Handle trailing comment sections in import statement lines
Krasimir Georgiev [Fri, 19 May 2017 10:34:57 +0000 (10:34 +0000)]
[clang-format] Handle trailing comment sections in import statement lines

Summary:
This patch updates the handling of multiline trailing comment sections in
import statement lines to make it more consistent with the case in general.
This includes updating the parsing logic to collect the trailing comment
sections and the formatting logic to not insert escaped newlines at the end of
comment lines in import statement lines.

Specifically, before this patch this code:
```
#include <a> // line 1
             // line 2
```
will be turned into two unwrapped lines, whereas this code:
```
int i; // line 1
       // line 2
```
is turned into a single unwrapped line, enabling reflowing across comments.

An example where the old behaviour is bad is when partially formatting the lines
3 to 4 of this code:
```
#include <a> // line 1
             // line 2

int i;
```
which gets turned into:
```
#include <a> // line 1
             // line 2

             int i;
```
because the two comment lines were independent and the indent was copied.

Reviewers: djasper

Reviewed By: djasper

Subscribers: cfe-commits, klimek

Differential Revision: https://reviews.llvm.org/D33351

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

7 years agoCodeGenFunction::EmitPointerWithAlignment(): Prune a \param in r303358, possibly...
NAKAMURA Takumi [Fri, 19 May 2017 10:19:59 +0000 (10:19 +0000)]
CodeGenFunction::EmitPointerWithAlignment(): Prune a \param in r303358, possibly obsolete. [-Wdocumentation]

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

7 years agoWhen a type-id is unexpectedly given a name, assume that the name is unrelated
Richard Smith [Fri, 19 May 2017 01:54:59 +0000 (01:54 +0000)]
When a type-id is unexpectedly given a name, assume that the name is unrelated
syntax unless we have a reason to think otherwise.

This improves error recovery in a couple of cases.

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

7 years agoclang-format: [JS] for await, and fix a crash with for loops.
Martin Probst [Thu, 18 May 2017 21:19:29 +0000 (21:19 +0000)]
clang-format: [JS] for await, and fix a crash with for loops.

Summary:
The syntax is actually `for await (const x of y)` (d'oh).
This also fixes a crash for `for` tokens not followed by additional tokens.

Reviewers: djasper

Subscribers: cfe-commits, klimek

Differential Revision: https://reviews.llvm.org/D33329

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

7 years agoWhen we enter a module within a linkage specification, switch the linkage
Richard Smith [Thu, 18 May 2017 19:34:55 +0000 (19:34 +0000)]
When we enter a module within a linkage specification, switch the linkage
specification and the TU to the new module.

This is necessary to get the module ownership correct for entities that we
temporarily hang off the TranslationUnitDecl, such as template parameters and
function parameters.

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

7 years agoFix the location of "missing ';'" suggestions after annotation tokens.
Richard Smith [Thu, 18 May 2017 19:21:48 +0000 (19:21 +0000)]
Fix the location of "missing ';'" suggestions after annotation tokens.

We were incorrectly setting PrevTokLocation to the first token in the
annotation token instead of the last when consuming it. To fix this without
adding a complex switch to the hot path through ConsumeToken, we now have a
ConsumeAnnotationToken function for consuming annotation tokens in addition
to the other Consume*Token special case functions.

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

7 years agoCodeGen: Cast alloca to expected address space
Yaxun Liu [Thu, 18 May 2017 18:51:09 +0000 (18:51 +0000)]
CodeGen: Cast alloca to expected address space

Alloca always returns a pointer in alloca address space, which may
be different from the type defined by the language. For example,
in C++ the auto variables are in the default address space. Therefore
cast alloca to the expected address space when necessary.

Differential Revision: https://reviews.llvm.org/D32248

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

7 years ago[index] Avoid one more crash caused by infinite recursion that happens when
Alex Lorenz [Thu, 18 May 2017 18:06:07 +0000 (18:06 +0000)]
[index] Avoid one more crash caused by infinite recursion that happens when
looking up a dependent name in a record that derives from itself

rdar://32273000

Differential Revision: https://reviews.llvm.org/D33324

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

7 years ago[CodeGen] Propagate LValueBaseInfo instead of AlignmentSource
Krzysztof Parzyszek [Thu, 18 May 2017 17:07:11 +0000 (17:07 +0000)]
[CodeGen] Propagate LValueBaseInfo instead of AlignmentSource

The functions creating LValues propagated information about alignment
source. Extend the propagated data to also include information about
possible unrestricted aliasing. A new class LValueBaseInfo will
contain both AlignmentSource and MayAlias info.

This patch should not introduce any functional changes.

Differential Revision: https://reviews.llvm.org/D33284

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

7 years ago[clang-format] Fix MatchingOpeningBlockLineIndex computation
Krasimir Georgiev [Thu, 18 May 2017 15:16:24 +0000 (15:16 +0000)]
[clang-format] Fix MatchingOpeningBlockLineIndex computation

Summary:
Computed line index must be relative to the current 'parent' node, and
thus use CurrentLines instead of Lines.

Without this, a child line's MatchingOpeningBlockLineIndex is out of
range of the parent's list of line, which can cause crash or unexpected
behavior if this field is used in childs.

Contributed by @Typz!

Reviewers: krasimir, djasper

Reviewed By: krasimir

Subscribers: cfe-commits, klimek

Differential Revision: https://reviews.llvm.org/D32524

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

7 years ago[index] Record references to class receivers used in property references
Alex Lorenz [Thu, 18 May 2017 10:43:11 +0000 (10:43 +0000)]
[index] Record references to class receivers used in property references

rdar://32250025

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

7 years ago[clang-format] Make NoLineBreakFormatter respect MustBreakBefore
Krasimir Georgiev [Thu, 18 May 2017 08:07:52 +0000 (08:07 +0000)]
[clang-format] Make NoLineBreakFormatter respect MustBreakBefore

Summary:
This patch makes NoLineBreakFormatter to insert a break before tokens where
MustBreakBefore is true.

Reviewers: djasper

Reviewed By: djasper

Subscribers: cfe-commits, klimek

Differential Revision: https://reviews.llvm.org/D33238

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

7 years agoclang-format: fix prefix for doxygen comments after member
Krasimir Georgiev [Thu, 18 May 2017 07:36:21 +0000 (07:36 +0000)]
clang-format: fix prefix for doxygen comments after member

Summary:
Doxygen supports putting documentation blocks after member, by adding
an additional < marker in the comment block. This patch makes sure
this marker is used in lines which are introduced by breaking the
comment.

  int foo; ///< Some very long comment.

becomes:

  int foo; ///< Some very long
           ///< comment.

Contributed by @Typz!

Reviewers: krasimir

Reviewed By: krasimir

Subscribers: djasper, klimek, cfe-commits

Differential Revision: https://reviews.llvm.org/D33282

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

7 years agoFix an assertion failure in FormatASTNodeDiagnosticArgument.
Alexander Kornienko [Thu, 18 May 2017 03:02:15 +0000 (03:02 +0000)]
Fix an assertion failure in FormatASTNodeDiagnosticArgument.

Summary:
The test being added in this patch used to cause an assertion failure:

/build/./bin/clang -cc1 -internal-isystem /build/lib/clang/5.0.0/include -nostdsysteminc -verify -fsyntax-only -std=c++11 -Wshadow-all /src/tools/clang/test/SemaCXX/warn-shadow.cpp
--
Exit Code: 134

Command Output (stderr):
--
clang: /src/tools/clang/lib/AST/ASTDiagnostic.cpp:424: void clang::FormatASTNodeDiagnosticArgument(DiagnosticsEngine::ArgumentKind, intptr_t, llvm::StringRef, llvm::StringRef, ArrayRef<DiagnosticsEngine::ArgumentValue>, SmallVectorImpl<char> &, void *, ArrayRef<intptr_t>): Assertion `isa<NamedDecl>(DC) && "Expected a NamedDecl"' failed.
#0 0x0000000001c7a1b4 PrintStackTraceSignalHandler(void*) (/build/./bin/clang+0x1c7a1b4)
#1 0x0000000001c7a4e6 SignalHandler(int) (/build/./bin/clang+0x1c7a4e6)
#2 0x00007f30880078d0 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0xf8d0)
#3 0x00007f3087054067 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x35067)
#4 0x00007f3087055448 abort (/lib/x86_64-linux-gnu/libc.so.6+0x36448)
#5 0x00007f308704d266 (/lib/x86_64-linux-gnu/libc.so.6+0x2e266)
#6 0x00007f308704d312 (/lib/x86_64-linux-gnu/libc.so.6+0x2e312)
#7 0x00000000035b7f22 clang::FormatASTNodeDiagnosticArgument(clang::DiagnosticsEngine::ArgumentKind, long, llvm::StringRef, llvm::StringRef, llvm::ArrayRef<std::pair<clang::DiagnosticsEngine::ArgumentKind, long> >, llvm::SmallVectorImpl<char>&, void*, llvm::ArrayRef<long>) (/build/
./bin/clang+0x35b7f22)
#8 0x0000000001ddbae4 clang::Diagnostic::FormatDiagnostic(char const*, char const*, llvm::SmallVectorImpl<char>&) const (/build/./bin/clang+0x1ddbae4)
#9 0x0000000001ddb323 clang::Diagnostic::FormatDiagnostic(char const*, char const*, llvm::SmallVectorImpl<char>&) const (/build/./bin/clang+0x1ddb323)
#10 0x00000000022878a4 clang::TextDiagnosticBuffer::HandleDiagnostic(clang::DiagnosticsEngine::Level, clang::Diagnostic const&) (/build/./bin/clang+0x22878a4)
#11 0x0000000001ddf387 clang::DiagnosticIDs::ProcessDiag(clang::DiagnosticsEngine&) const (/build/./bin/clang+0x1ddf387)
#12 0x0000000001dd9dea clang::DiagnosticsEngine::EmitCurrentDiagnostic(bool) (/build/./bin/clang+0x1dd9dea)
#13 0x0000000002cad00c clang::Sema::EmitCurrentDiagnostic(unsigned int) (/build/./bin/clang+0x2cad00c)
#14 0x0000000002d91cd2 clang::Sema::CheckShadow(clang::NamedDecl*, clang::NamedDecl*, clang::LookupResult const&) (/build/./bin/clang+0x2d91cd2)

Stack dump:
0.      Program arguments: /build/./bin/clang -cc1 -internal-isystem /build/lib/clang/5.0.0/include -nostdsysteminc -verify -fsyntax-only -std=c++11 -Wshadow-all /src/tools/clang/test/SemaCXX/warn-shadow.cpp
1.      /src/tools/clang/test/SemaCXX/warn-shadow.cpp:214:23: current parser token ';'
2.      /src/tools/clang/test/SemaCXX/warn-shadow.cpp:213:26: parsing function body 'handleLinkageSpec'
3.      /src/tools/clang/test/SemaCXX/warn-shadow.cpp:213:26: in compound statement ('{}')
/build/tools/clang/test/SemaCXX/Output/warn-shadow.cpp.script: line 1: 15595 Aborted                 (core dumped) /build/./bin/clang -cc1 -internal-isystem /build/lib/clang/5.0.0/include -nostdsysteminc -verify -fsyntax-only -std=c++11 -Wshadow-all /src/tools/clang/test/SemaCXX/warn-shadow.cpp

Reviewers: rsmith

Reviewed By: rsmith

Subscribers: krytarowski, cfe-commits

Differential Revision: https://reviews.llvm.org/D33207

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

7 years ago[modules] Switch from inferring owning modules based on source location to
Richard Smith [Thu, 18 May 2017 02:29:20 +0000 (02:29 +0000)]
[modules] Switch from inferring owning modules based on source location to
inferring based on the current module at the point of creation.

This should result in no functional change except when building a preprocessed
module (or more generally when using #pragma clang module begin/end to switch
module in the middle of a file), in which case it allows us to correctly track
the owning module for declarations. We can't map from FileID to module in the
preprocessed module case, since all modules would have the same FileID.

There are still a couple of remaining places that try to infer a module from a
source location; I'll clean those up in follow-up changes.

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

7 years ago[Statistics] Use the new Statistic::updateMax to atomically calculate a maximum value...
Craig Topper [Thu, 18 May 2017 01:11:52 +0000 (01:11 +0000)]
[Statistics] Use the new Statistic::updateMax to atomically calculate a maximum value statistic.

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

7 years agoThe constant expression evaluator should examine function arguments for non-constexpr...
Nick Lewycky [Wed, 17 May 2017 23:56:54 +0000 (23:56 +0000)]
The constant expression evaluator should examine function arguments for non-constexpr function calls unless the EvalInfo says to stop.

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

7 years agoclang-cl: Fix path-based MSVC version detection
Hans Wennborg [Wed, 17 May 2017 15:27:44 +0000 (15:27 +0000)]
clang-cl: Fix path-based MSVC version detection

The code wasn't taking the architecture-specific subdirectory into
account.

Differential Revision: https://reviews.llvm.org/D33258

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

7 years ago[Frontend] Remove unused TemporaryFiles
Krasimir Georgiev [Wed, 17 May 2017 14:51:44 +0000 (14:51 +0000)]
[Frontend] Remove unused TemporaryFiles

Summary:
OnDiskData.TemporaryFiles is filled only by ASTUnit::addTemporaryFile, which is
dead. Also these files are used nowhere in the frontend nor in libclang.

Reviewers: bkramer, ilya-biryukov

Reviewed By: bkramer, ilya-biryukov

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D33270

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

7 years agoConstify.
Vassil Vassilev [Wed, 17 May 2017 12:09:11 +0000 (12:09 +0000)]
Constify.

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

7 years ago[Lexer] Ensure that the token is not an annotation token when
Alex Lorenz [Wed, 17 May 2017 11:08:36 +0000 (11:08 +0000)]
[Lexer] Ensure that the token is not an annotation token when
retrieving the identifer info for an Objective-C keyword

This commit fixes an assertion that's triggered in getIdentifier when the token
is an annotation token.

rdar://32225463

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

7 years ago[ODRHash] Support NestedNameSpecifier
Richard Trieu [Wed, 17 May 2017 03:23:35 +0000 (03:23 +0000)]
[ODRHash] Support NestedNameSpecifier

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

7 years ago[ODRHash] Support more types in the ODR checker.
Richard Trieu [Wed, 17 May 2017 02:29:02 +0000 (02:29 +0000)]
[ODRHash] Support more types in the ODR checker.

Added support for TagType, TypeWithKeyword, and all children types.

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

7 years ago(1) Fixed mismatch in intrinsics names in declarations and in doxygen comments.
Ekaterina Romanova [Wed, 17 May 2017 01:46:11 +0000 (01:46 +0000)]
(1) Fixed mismatch in intrinsics names in declarations and in doxygen comments.
(2) Removed uncessary anymore \c commands, since the same effect will be achived by <c> ... </c> sequence.

I got an OK from Eric Christopher to commit doxygen comments without prior code
review upstream.

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

7 years ago[modules] When creating a declaration, cache its owning module immediately
Richard Smith [Wed, 17 May 2017 00:24:14 +0000 (00:24 +0000)]
[modules] When creating a declaration, cache its owning module immediately
rather than waiting until it's queried.

Currently this is only applied to local submodule visibility mode, as we don't
yet allocate storage for the owning module in non-local-visibility modules
compilations.

This reinstates r302965, reverted in r303037, with a fix for the reported
crash, which occurred when reparenting a local declaration to be a child of
a hidden imported declaration (specifically during template instantiation).

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

7 years agoFix scope of namespaced DISubprograms when the function definition is out-of-line.
Adrian Prantl [Tue, 16 May 2017 23:46:10 +0000 (23:46 +0000)]
Fix scope of namespaced DISubprograms when the function definition is out-of-line.
This fixes a regression introduced in r302915.

Using the lexical decl context is not necessary here for what r302915
wast trying to achieve. Not canonicalizing the NamespaceDecl in
getOrCreateNamespace is suficient.

rdar://problem/29339538

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

7 years ago[index] Avoid another crash that happens when looking up a dependent name
Alex Lorenz [Tue, 16 May 2017 17:33:17 +0000 (17:33 +0000)]
[index] Avoid another crash that happens when looking up a dependent name
in a record that has a base without a definition

rdar://32224197

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

7 years ago[Sema] Avoid duplicate -Wunguarded-availability warnings in nested functions
Alex Lorenz [Tue, 16 May 2017 13:58:53 +0000 (13:58 +0000)]
[Sema] Avoid duplicate -Wunguarded-availability warnings in nested functions

rdar://31862310

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

7 years ago[StaticAnalyzer] Move inline counter increaser to inlineCall function
Peter Szecsi [Tue, 16 May 2017 11:54:00 +0000 (11:54 +0000)]
[StaticAnalyzer] Move inline counter increaser to inlineCall function

Even though the shouldInlineCall function returns true, it can happen that the
function is not going to be inlined (as it can be seen at line 913 and below).
Moved the bumpNumTimesInlined(D) (the counter increaser) call to the inlineCall
function where it logically belongs.

Differential Revision: https://reviews.llvm.org/D32179

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

7 years agoFix PR 10758: Infinite recursion when dealing with copy-initialization
Alex Lorenz [Tue, 16 May 2017 10:23:58 +0000 (10:23 +0000)]
Fix PR 10758: Infinite recursion when dealing with copy-initialization

This commit fixes a bug that's tracked by PR 10758 and duplicates like PR 30343.
The bug causes clang to crash with a stack overflow while recursing infinitely
trying to perform copy-initialization on a type without a copy constructor but
with a constructor that accepts another type that can be constructed using the
original type.

The commit fixes this bug by detecting the recursive behavior and failing
correctly with an appropriate error message. It also tries to provide a
meaningful diagnostic note about the constructor which leads to this behavior.

rdar://28483944

Differential Revision: https://reviews.llvm.org/D25051

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

7 years ago[Sema] Use CK_NoOp instead CK_Invalid in tryGCCVectorConvertAndSplat
Vitaly Buka [Mon, 15 May 2017 22:04:03 +0000 (22:04 +0000)]
[Sema] Use CK_NoOp instead CK_Invalid in tryGCCVectorConvertAndSplat

This fix UBSAN bots after r302935. Storing non-defined values in enum is
undefined behavior.

Other places, where "if (ScalarCast != CK_Invalid)" is used, never get to the
"if" with CK_Invalid. tryGCCVectorConvertAndSplat can get to the "if" with
CK_Invalid and it looks like expected case. So we have to use something other
than CK_Invalid, e.g. CK_NoOp.

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

7 years ago[asan] One more test for -fsanitize-address-globals-dead-stripping.
Evgeniy Stepanov [Mon, 15 May 2017 20:43:48 +0000 (20:43 +0000)]
[asan] One more test for -fsanitize-address-globals-dead-stripping.

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

7 years agoclang-format: [JS] for async loops.
Martin Probst [Mon, 15 May 2017 19:33:20 +0000 (19:33 +0000)]
clang-format: [JS] for async loops.

Summary:
JavaScript supports asynchronous loop iteration in async functions:

    for async (const x of y) ...

Reviewers: djasper

Subscribers: klimek, cfe-commits

Differential Revision: https://reviews.llvm.org/D33193

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

7 years ago[OPENMP] Check DSA for variables captured by value.
Alexey Bataev [Mon, 15 May 2017 16:26:15 +0000 (16:26 +0000)]
[OPENMP] Check DSA for variables captured by value.

Currently clang checks for default data sharing attributes only for
variables captured in OpenMP regions by reference. Patch adds checks for
variables captured by value.

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

7 years ago[OpenCL] Emit function-scope variable in constant address space as static variable
Yaxun Liu [Mon, 15 May 2017 14:47:47 +0000 (14:47 +0000)]
[OpenCL] Emit function-scope variable in constant address space as static variable

Differential Revision: https://reviews.llvm.org/D32977

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

7 years ago[index] References to fields from template instantiations should refer to
Alex Lorenz [Mon, 15 May 2017 14:26:22 +0000 (14:26 +0000)]
[index] References to fields from template instantiations should refer to
fields in base templates

rdar://32197158

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

7 years agoJavaScript allows parameter lists to include trailing commas:
Martin Probst [Mon, 15 May 2017 11:15:29 +0000 (11:15 +0000)]
JavaScript allows parameter lists to include trailing commas:

    myFunction(param1, param2,);

For symmetry with other parenthesized lists ([...], {...}), clang-format should
wrap parenthesized lists one-per-line if they contain a trailing comma:

    myFunction(
        param1,
        param2,
    );

This is particularly useful in function declarations or calls with many
arguments, e.g. commonly in constructors.

Differential Revision: https://reviews.llvm.org/D33023

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

7 years ago[index] Visit and store information about namespace alias declarations
Alex Lorenz [Mon, 15 May 2017 10:56:31 +0000 (10:56 +0000)]
[index] Visit and store information about namespace alias declarations

rdar://32195226

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

7 years ago[index] Store correct location for namespace nested name qualifiers
Alex Lorenz [Mon, 15 May 2017 10:41:04 +0000 (10:41 +0000)]
[index] Store correct location for namespace nested name qualifiers

rdar://32195200

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

7 years ago[index] Avoid a crash that happens when looking up a dependent name
Alex Lorenz [Mon, 15 May 2017 10:20:39 +0000 (10:20 +0000)]
[index] Avoid a crash that happens when looking up a dependent name
in a record that has no definition

rdar://32194921

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

7 years agoclang-format: [JS] fix non-null assertion operator recognition.
Martin Probst [Mon, 15 May 2017 08:15:53 +0000 (08:15 +0000)]
clang-format: [JS] fix non-null assertion operator recognition.

Summary:
`getIdentifierInfo()` includes all keywords, whereas non-null assertion
operators should only be recognized after non-keywords or pseudo keywords.
Ideally this should list all tokens that clang-format recognizes as a keyword,
but that are pseudo or no keywords in JS. For the time being, just recognize
the specific bits users ran into (`namespace` in this case).

Reviewers: djasper

Subscribers: klimek

Differential Revision: https://reviews.llvm.org/D33182

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

7 years agoRevert r302965 - [modules] When creating a declaration, cache its owning
Daniel Jasper [Mon, 15 May 2017 07:51:10 +0000 (07:51 +0000)]
Revert r302965 - [modules] When creating a declaration, cache its owning
module immediately

Also revert dependent r302969. This is leading to crashes.
Will provide more details reproduction instructions to Richard.

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

7 years ago[DOXYGEN] Minor improvements in doxygen comments.
Ekaterina Romanova [Mon, 15 May 2017 03:25:04 +0000 (03:25 +0000)]
[DOXYGEN] Minor improvements in doxygen comments.

Separated very long brief sections into two sections.

I got an OK from Eric Christopher to commit doxygen comments without prior code
review upstream.

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

7 years agoSilence buildbots by tweaking an IR codegen test to be less specific w register names.
Faisal Vali [Mon, 15 May 2017 02:56:02 +0000 (02:56 +0000)]
Silence buildbots by tweaking an IR codegen test to be less specific w register names.

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

7 years ago[NFC] Remove some comments (IR aid) from a test file erroneous committed in r303026
Faisal Vali [Mon, 15 May 2017 01:54:02 +0000 (01:54 +0000)]
[NFC] Remove some comments (IR aid) from a test file erroneous committed in r303026

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

7 years agoFix PR32933: crash on lambda capture of VLA
Faisal Vali [Mon, 15 May 2017 01:49:19 +0000 (01:49 +0000)]
Fix PR32933: crash on lambda capture of VLA

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

Turns out clang wasn't really handling vla's (*) in C++11's for-range entirely correctly.

For e.g. This would lead to generation of buggy IR:

  void foo(int b) {
    int vla[b];
    b = -1;  // This store would affect the '__end = vla + b'
    for (int &c : vla)
      c = 0;
  }

Additionally, code-gen would get confused when VLA's were reference-captured by lambdas, and then used in a for-range, which would result in an attempt to generate IR for '__end = vla + b' within the lambda's body - without any capture of 'b' - hence the assertion.

This patch modifies clang, so that for VLA's it translates the end pointer approximately into:
  __end = __begin + sizeof(vla)/sizeof(vla->getElementType())

As opposed to the __end = __begin + b;

I considered passing a magic value into codegen - or having codegen special case the '__end' variable when it referred to a variably-modified type, but I decided against that approach, because it smelled like I would be increasing a complicated form of coupling, that I think would be even harder to maintain than the above approach (which can easily be optimized (-O1) to refer to the run-time bound that was calculated upon array's creation or copied into the lambda's closure object).

(*) why oh why gcc would you enable this by default?! ;)

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

7 years ago[ASTImporter] Improve handling of incomplete types
Sean Callanan [Sat, 13 May 2017 00:46:33 +0000 (00:46 +0000)]
[ASTImporter] Improve handling of incomplete types

ASTImporter has some bugs when it's importing types
that themselves come from an ExternalASTSource. This
is exposed particularly in the behavior when
comparing complete TagDecls with forward
declarations. This patch does several things:

- Adds a test case making sure that conflicting
  forward-declarations are resolved correctly;
- Extends the clang-import-test harness to test
  two-level importing, so that we make sure we
  complete types when necessary; and
- Fixes a few bugs I found this way. Failure to
  complete types was one; however, I also discovered
  that complete RecordDecls aren't properly added to
  the redecls chain for existing forward
  declarations.

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

7 years agoAdd LangOptions method to query whether we are tracking the owning module for a local...
Richard Smith [Sat, 13 May 2017 00:00:16 +0000 (00:00 +0000)]
Add LangOptions method to query whether we are tracking the owning module for a local declaration.

In preparation for expanding this behavior to cover additional cases.

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

7 years agoRemove unused tracking of owning module for MacroInfo objects.
Richard Smith [Fri, 12 May 2017 23:40:52 +0000 (23:40 +0000)]
Remove unused tracking of owning module for MacroInfo objects.

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

7 years ago[modules] When creating a declaration, cache its owning module immediately
Richard Smith [Fri, 12 May 2017 23:27:00 +0000 (23:27 +0000)]
[modules] When creating a declaration, cache its owning module immediately
rather than waiting until it's queried.

Currently this is only applied to local submodule visibility mode, as we don't
yet allocate storage for the owning module in non-local-visibility modules
compilations.

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

7 years agoRevert r302932, as it appears to be breaking stage2 for some of our modules-enabled...
Richard Smith [Fri, 12 May 2017 20:42:54 +0000 (20:42 +0000)]
Revert r302932, as it appears to be breaking stage2 for some of our modules-enabled buildbots.

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

7 years ago[Sema] Silence buildbot failures introduced by r302935
Simon Dardis [Fri, 12 May 2017 19:55:32 +0000 (19:55 +0000)]
[Sema] Silence buildbot failures introduced by r302935

Attempt to silence buildbot failures by pinning the test to a given
triple rather than the host's triple.

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

7 years agoRemove ignore-empty-index-file option
Teresa Johnson [Fri, 12 May 2017 19:32:17 +0000 (19:32 +0000)]
Remove ignore-empty-index-file option

Summary:
Clang changes to remove this option and replace with a parameter
always set in the context of a ThinLTO distributed backend.

Depends on D33133.

Reviewers: pcc

Subscribers: mehdi_amini, eraman, cfe-commits

Differential Revision: https://reviews.llvm.org/D33134

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

7 years ago[Sema] Support implicit scalar to vector conversions
Simon Dardis [Fri, 12 May 2017 19:11:06 +0000 (19:11 +0000)]
[Sema] Support implicit scalar to vector conversions

This patch teaches clang to perform implicit scalar to vector conversions
when one of the operands of a binary vector expression is a scalar which
can be converted to the element type of the vector without truncation
following GCC's implementation.

If the (constant) scalar is can be casted safely, it is implicitly casted to the
vector elements type and splatted to produce a vector of the same type.

Contributions from: Petar Jovanovic

Reviewers: bruno, vkalintiris

Differential Revision: https://reviews.llvm.org/D25866

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

7 years ago[modules] Simplify module macro handling in non-local-submodule-visibility mode.
Richard Smith [Fri, 12 May 2017 18:56:03 +0000 (18:56 +0000)]
[modules] Simplify module macro handling in non-local-submodule-visibility mode.

When reaching the end of a module, we used to convert its macros to
ModuleMacros but also leave them in the MacroDirective chain for the
identifier. This meant that every lookup of such a macro would find two
(identical) definitions. It also made it difficult to determine the correct
owner for a macro when reaching the end of a module: the most recent
MacroDirective in the chain could be from an #included submodule rather than
the current module.

Simplify this: whenever we convert a MacroDirective to a ModuleMacro when
leaving a module, clear out the MacroDirective chain for that identifier, and
just rely on the ModuleMacro to provide the macro definition information.

(We don't want to do this for local submodule visibility mode, because in that
mode we maintain a distinct MacroDirective chain for each submodule, and we
need to keep around the prior MacroDirective in case we re-enter the submodule
-- for instance, if its header is #included more than once in a module build,
we need the include guard directive to stick around. But the problem doesn't
arise in this case for the same reason: each submodule has its own
MacroDirective chain, so the macros don't leak out of submodules in the first
place.)

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

7 years ago[index] Index template specialization arguments for function templats
Alex Lorenz [Fri, 12 May 2017 16:32:26 +0000 (16:32 +0000)]
[index] Index template specialization arguments for function templats

Also ensure that class template specialization arguments are covered

rdar://31812032

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

7 years agoSimplify DINamespace caching in CGDebugInfo
Adrian Prantl [Fri, 12 May 2017 16:23:53 +0000 (16:23 +0000)]
Simplify DINamespace caching in CGDebugInfo

This addresses review feedback from r302840.

By not canonicalizing namespace decls and using lexical decl context
instead of lookuing up the semantic decl context we can take advantage
of the fact that DINamespaces a reuniqued. This way non-module debug
info is unchanged and module debug info still gets distinct namespace
declarations when they ocur in different modules.

Thanks to Richard Smith for pointing this out!

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