]> granicus.if.org Git - clang/log
clang
7 years agoRevert "[AMDGPU] add __builtin_amdgcn_s_getpc"
Reid Kleckner [Thu, 25 May 2017 20:28:26 +0000 (20:28 +0000)]
Revert "[AMDGPU] add __builtin_amdgcn_s_getpc"

This reverts commit r303861, the LLVM intrinsic was reverted.

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

7 years agoAppease more buildbots about r303873
Jonathan Roelofs [Thu, 25 May 2017 18:55:22 +0000 (18:55 +0000)]
Appease more buildbots about r303873

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

7 years agoRevert MSVC CXXOperatorNames patch due to issues with Chromium
Erich Keane [Thu, 25 May 2017 16:24:49 +0000 (16:24 +0000)]
Revert MSVC CXXOperatorNames patch due to issues with Chromium

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

7 years agoRelax testcase to appease buildbots
Jonathan Roelofs [Thu, 25 May 2017 16:20:51 +0000 (16:20 +0000)]
Relax testcase to appease buildbots

When lld isn't built, the tests as they were previously, were too picky about
the path to the linker.

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

7 years agoDon't defer to the GCC driver for linking arm-baremetal
Jonathan Roelofs [Thu, 25 May 2017 15:42:13 +0000 (15:42 +0000)]
Don't defer to the GCC driver for linking arm-baremetal

Also comes with a cmake cache for building the runtime bits:

 $ cmake <normal cmake flags> \
   -DBAREMETAL_ARMV6M_SYSROOT=/path/to/sysroot \
   -DBAREMETAL_ARMV7M_SYSROOT=/path/to/sysroot \
   -DBAREMETAL_ARMV7EM_SYSROOT=/path/to/sysroot \
   -C /path/to/clang/cmake/caches/BaremetalARM.cmake \
   /path/to/llvm

https://reviews.llvm.org/D33259

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

7 years agoMake git-clang-format python 3 compatible
Eric Fiselier [Thu, 25 May 2017 15:24:04 +0000 (15:24 +0000)]
Make git-clang-format python 3 compatible

Summary: This patch attempts to make `git-clang-format` both python2 and python3 compatible. Currently it only works in python2.

Reviewers: modocache, compnerd, djasper, jbcoe, srhines, ddunbar

Reviewed By: jbcoe

Subscribers: kimgr, mgorny, llvm-commits, cfe-commits

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

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

7 years ago[coroutines] Diagnose when promise types fail to declare either return_void or return...
Eric Fiselier [Thu, 25 May 2017 14:59:39 +0000 (14:59 +0000)]
[coroutines] Diagnose when promise types fail to declare either return_void or return_value.

Summary:
According to the PDTS it's perfectly legal to have a promise type that defines neither `return_value` nor `return_void`. However a coroutine that uses such a promise type will almost always have UB, because it can never `co_return`.

This patch changes Clang to diagnose such cases as an error. It also cleans up some of the diagnostic messages relating to member lookup in the promise type.

Reviewers: GorNishanov, rsmith

Reviewed By: GorNishanov

Subscribers: cfe-commits

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

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

7 years ago[coroutines] Bump __cpp_coroutines version
Eric Fiselier [Thu, 25 May 2017 14:58:46 +0000 (14:58 +0000)]
[coroutines] Bump __cpp_coroutines version

Summary: This patch is needed so that Libc++ can actually tess if Clang supports coroutines, instead of just paying lip service with a partial implementation. Otherwise the libc++ test suite will fail against older versions of Clang

Reviewers: GorNishanov, rsmith

Reviewed By: GorNishanov

Subscribers: cfe-commits

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

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

7 years ago[AMDGPU] add __builtin_amdgcn_s_getpc
Tim Corringham [Thu, 25 May 2017 14:16:11 +0000 (14:16 +0000)]
[AMDGPU] add __builtin_amdgcn_s_getpc

Summary: Added the builtin corresponding to the s_getpc intrinsic added in llvm D32862

Subscribers: kzhuravl, wdng, nhaehnle, yaxunl, dstuttard, tpr, t-tye

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

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

7 years ago[X86] Adding avx512_vpopcntdq feature set and its intrinsics
Oren Ben Simhon [Thu, 25 May 2017 13:44:11 +0000 (13:44 +0000)]
[X86] Adding avx512_vpopcntdq feature set and its intrinsics

AVX512_VPOPCNTDQ is a new feature set that was published by Intel.
The patch represents the Clang side of the addition of six intrinsics for two new machine instructions (vpopcntd and vpopcntq).
It also includes the addition of the new feature set.

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

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

7 years ago[CodeGen] Pessimize aliasing for member unions (and may-alias) objects
Krzysztof Parzyszek [Thu, 25 May 2017 12:55:47 +0000 (12:55 +0000)]
[CodeGen] Pessimize aliasing for member unions (and may-alias) objects

Use the TBAA info of the omnipotent char for these objects.

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

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

7 years ago[OpenCL] reserve_id_t cannot be used as argument to kernel function
Egor Churaev [Thu, 25 May 2017 07:18:37 +0000 (07:18 +0000)]
[OpenCL] reserve_id_t cannot be used as argument to kernel function

Reviewers: Anastasia

Reviewed By: Anastasia

Subscribers: yaxunl, cfe-commits, bader

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

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

7 years ago[OpenCL] Added regression test on invalid vector initialization.
Egor Churaev [Thu, 25 May 2017 06:55:02 +0000 (06:55 +0000)]
[OpenCL] Added regression test on invalid vector initialization.

Summary: This patch increases code coverage.

Reviewers: Anastasia

Reviewed By: Anastasia

Subscribers: cfe-commits, bader, yaxunl

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

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

7 years ago[coroutines] Fix fallthrough diagnostics for coroutines
Eric Fiselier [Thu, 25 May 2017 02:16:53 +0000 (02:16 +0000)]
[coroutines] Fix fallthrough diagnostics for coroutines

Summary:
This patch fixes a number of issues with the analysis warnings emitted when a coroutine may reach the end of the function w/o returning.

* Fix bug where coroutines with `return_value` are incorrectly diagnosed as missing `co_return`'s.
* Rework diagnostic message to no longer say "non-void coroutine", because that implies the coroutine doesn't have a void return type, which it might. In this case a non-void coroutine is one who's promise type does not contain `return_void()`

As a side-effect of this patch, coroutine bodies that contain an invalid coroutine promise objects are marked as invalid.

Reviewers: GorNishanov, rsmith, aaron.ballman, majnemer

Reviewed By: GorNishanov

Subscribers: cfe-commits

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

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

7 years agoRevert "Sema: allow imaginary constants via GNU extension if UDL overloads not present."
Tim Northover [Wed, 24 May 2017 22:18:35 +0000 (22:18 +0000)]
Revert "Sema: allow imaginary constants via GNU extension if UDL overloads not present."

This reverts commit r303697. It broke libc++ tests that were specifically
checking incompatibility in C++14 mode.

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

7 years agoBasic: fix whitespace in file header (NFC)
Saleem Abdulrasool [Wed, 24 May 2017 20:27:09 +0000 (20:27 +0000)]
Basic: fix whitespace in file header (NFC)

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

7 years ago[coroutines] Add support for coroutines with non-scalar parameters
Gor Nishanov [Wed, 24 May 2017 20:09:14 +0000 (20:09 +0000)]
[coroutines] Add support for coroutines with non-scalar parameters

Summary:
Simple types like int are handled by LLVM Coroutines just fine.
But for non-scalar parameters we need to create copies of those parameters in the coroutine frame and make all uses of those parameters to refer to parameter copies.

Reviewers: rsmith, EricWF, GorNishanov

Subscribers: cfe-commits

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

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

7 years agoFor Microsoft compatibility, set fno_operator_names
Erich Keane [Wed, 24 May 2017 19:31:19 +0000 (19:31 +0000)]
For Microsoft compatibility, set fno_operator_names

There's a Microsoft header in the Windows SDK which won't
compile with clang because it uses an operator name (and)
as a field name. This patch allows that file to compile by
setting the option which disables operator names.
The header which doesn't compile <Query.h> C:/Program Files (x86)/
Windows Kits/10/include/10.0.14393.0/um\Query.h:259:40:
error: expected member name or ';' after declaration specifiers

  /* [case()] */ NODERESTRICTION or;
                   ~~~~~~~~~~~~~~~ ^

                   1 error generated.

Contributed for Melanie Blower

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

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

7 years agoAddress follow-up feedback for r303712
Argyrios Kyrtzidis [Wed, 24 May 2017 18:35:01 +0000 (18:35 +0000)]
Address follow-up feedback for r303712

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

7 years agoFix one test case faiulre in commit 303766.
Tony Jiang [Wed, 24 May 2017 18:12:11 +0000 (18:12 +0000)]
Fix one test case faiulre in commit 303766.

It is clean when I build boostrap and run make checkall on my machine, I guess
it could be I only build bootstrap with assert, while the buildbots may build
without asserts, which could cause the difference.

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

7 years ago[OPENMP] Allow value of thread local variables in target regions.
Alexey Bataev [Wed, 24 May 2017 16:00:02 +0000 (16:00 +0000)]
[OPENMP] Allow value of thread local variables in target regions.

If the variable is marked as TLS variable and target device does not
support TLS, the error is emitted for the variable even if it is not
used in target regions. Patch fixes this and allows to use the values of
the TLS variables in target regions.

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

7 years ago[PowerPC] Implement vec_xxsldwi builtin.
Tony Jiang [Wed, 24 May 2017 15:54:13 +0000 (15:54 +0000)]
[PowerPC] Implement vec_xxsldwi builtin.

The vec_xxsldwi builtin is missing from altivec.h. This has been requested by
developers working on libvpx for VP9 support for Google.

The patch fixes PR: https://bugs.llvm.org/show_bug.cgi?id=32653
Differential Revision: https://reviews.llvm.org/D33236

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

7 years ago[coroutines] Make generic lambda coroutines work
Gor Nishanov [Wed, 24 May 2017 15:44:57 +0000 (15:44 +0000)]
[coroutines] Make generic lambda coroutines work

Summary:
1. Coroutine cannot be constexpr (added a check in SemaLambda.cpp not to mark coroutine as constexpr)
2. TransformCoroutineBodyStmt should transform ResultDecl and ReturnStmt

Reviewers: rsmith, GorNishanov

Reviewed By: GorNishanov

Subscribers: EricWF, cfe-commits

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

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

7 years agoWarn about uses of `@available` that can't suppress the
Alex Lorenz [Wed, 24 May 2017 15:15:29 +0000 (15:15 +0000)]
Warn about uses of `@available` that can't suppress the
-Wunguarded-availability warnings

rdar://32306520

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

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

7 years ago[PowerPC] Implement vec_xxpermdi builtin.
Tony Jiang [Wed, 24 May 2017 15:13:32 +0000 (15:13 +0000)]
[PowerPC] Implement vec_xxpermdi builtin.

The vec_xxpermdi builtin is missing from altivec.h. This has been requested by
developers working on libvpx for VP9 support for Google.

The patch fixes PR: https://bugs.llvm.org/show_bug.cgi?id=32653
Differential Revision: https://reviews.llvm.org/D33053

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

7 years agoDriver must return non-zero code on errors in command line
Serge Pavlov [Wed, 24 May 2017 14:57:17 +0000 (14:57 +0000)]
Driver must return non-zero code on errors in command line

This is recommit of r302775, reverted in r302777 due to a fail in
clang-tidy. Original mesage is below.

Now if clang driver is given wrong arguments, in some cases it
continues execution and returns zero code. This change fixes this
behavior.

The fix revealed some errors in clang test set.

File test/Driver/gfortran.f90 added in r118203 checks forwarding
gfortran flags to GCC. Now driver reports error on this file, because
the option -working-directory implemented in clang differs from the
option with the same name implemented in gfortran, in clang the option
requires argument, in gfortran does not.

In the file test/Driver/arm-darwin-builtin.c clang is called with
options -fbuiltin-strcat and -fbuiltin-strcpy. These option were removed
in r191435 and now clang reports error on this test.

File arm-default-build-attributes.s uses option -verify, which is not
supported by driver, it is cc1 option.

Similarly, the file split-debug.h uses options -fmodules-embed-all-files
and -fmodule-format=obj, which are not supported by driver.

Other revealed errors are mainly mistypes.

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

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

7 years agoGeneralize two diagnostic messages to take function name as parameter.
Tony Jiang [Wed, 24 May 2017 14:45:57 +0000 (14:45 +0000)]
Generalize two diagnostic messages to take function name as parameter.

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

7 years ago[coroutines] Improved diagnostics when unhandled_exception is missing in the promise_type
Gor Nishanov [Wed, 24 May 2017 14:34:19 +0000 (14:34 +0000)]
[coroutines] Improved diagnostics when unhandled_exception is missing in the promise_type

Summary: Now we helpfully provide a note pointing at the promise_type in question.

Reviewers: EricWF, GorNishanov

Reviewed By: GorNishanov

Subscribers: cfe-commits

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

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

7 years ago[index] The references to explicit class properties should be recorded
Alex Lorenz [Wed, 24 May 2017 14:23:40 +0000 (14:23 +0000)]
[index] The references to explicit class properties should be recorded

rdar://32376363

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

7 years ago[coroutines] [NFC] Add tests for return_void, unhandled_exception and promise dtor
Gor Nishanov [Wed, 24 May 2017 14:19:48 +0000 (14:19 +0000)]
[coroutines] [NFC] Add tests for return_void, unhandled_exception and promise dtor

Summary:
* Test that coroutine promise destructor is called.
* Test that we call return_void on fallthrough
* Test that we call unhandled exception in a try catch surrounding the body

Reviewers: EricWF, GorNishanov

Reviewed By: GorNishanov

Subscribers: cfe-commits

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

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

7 years ago[clang-format] Remove unused using directive, NFC
Krasimir Georgiev [Wed, 24 May 2017 12:15:42 +0000 (12:15 +0000)]
[clang-format] Remove unused using directive, NFC

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

7 years agoMethod loadFromCommandLine should be able to report errors
Serge Pavlov [Wed, 24 May 2017 11:57:37 +0000 (11:57 +0000)]
Method loadFromCommandLine should be able to report errors

Now FixedCompilationDatabase::loadFromCommandLine has no means to report
which error occurred if it fails to create compilation object. This is
a block for implementing D33013, because after that change driver will
refuse to create compilation if command line contains erroneous options.

This change adds additional argument to loadFromCommandLine, which is
assigned error message text if compilation object was not created. This is
the same way as other methods of CompilationDatabase report failure.

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

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

7 years agoclang-format: Introduce BreakConstructorInitializers option
Francois Ferrand [Wed, 24 May 2017 11:36:58 +0000 (11:36 +0000)]
clang-format: Introduce BreakConstructorInitializers option

Summary:
This option replaces the BreakConstructorInitializersBeforeComma option with an enum, thus introducing a mode where the colon stays on the same line as constructor declaration:

  // When it fits on line:
  Constructor() : initializer1(), initializer2() {}

  // When it does not fit:
  Constructor() :
      initializer1(), initializer2()
  {}

  // When ConstructorInitializerAllOnOneLineOrOnePerLine = true:
  Constructor() :
      initializer1(),
      initializer2()
  {}

Reviewers: krasimir, djasper

Reviewed By: djasper

Subscribers: cfe-commits, klimek

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

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

7 years agoFix 'set but not used' [-Wunused-but-set-variable] warning
Simon Pilgrim [Wed, 24 May 2017 10:38:09 +0000 (10:38 +0000)]
Fix 'set but not used' [-Wunused-but-set-variable] warning

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

7 years ago[XRay][clang] Allow imbuing arg1 logging attribute via -fxray-always-instrument=
Dean Michael Berris [Wed, 24 May 2017 05:46:36 +0000 (05:46 +0000)]
[XRay][clang] Allow imbuing arg1 logging attribute via -fxray-always-instrument=

Summary:
This change allows us to add arg1 logging support to functions through
the special case list provided through -fxray-always-instrument=. This
is useful for adding arg1 logging to functions that are either in
headers that users don't have control over (i.e. cannot change the
source) or would rather not do.

It only takes effect when the pattern is matched through the "fun:"
special case, as a category. As in:

  fun:*pattern=arg1

Reviewers: pelikan, rnk

Subscribers: cfe-commits

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

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

7 years ago[coroutines] Implement correct GRO lifetime
Gor Nishanov [Wed, 24 May 2017 02:38:26 +0000 (02:38 +0000)]
[coroutines] Implement correct GRO lifetime

Summary:
Sema creates a declaration for gro variable as:

auto $gro = $promise.get_return_object();

However, gro variable has to outlive coroutine frame and coroutine promise, but,
it can only be initialized after the coroutine promise was created, thus, we
split its emission in two parts: EmitGroAlloca emits an alloca and sets up
the cleanups. Later when the coroutine promise is available we initialize
the gro and set the flag that the cleanup is now active.

Duplicate of: https://reviews.llvm.org/D31670 (which arc patch refuses to apply for some reason)

Reviewers: GorNishanov, rsmith

Reviewed By: GorNishanov

Subscribers: EricWF, cfe-commits

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

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

7 years ago[coroutines] Fix leak in CGCoroutine.cpp
Gor Nishanov [Wed, 24 May 2017 01:54:37 +0000 (01:54 +0000)]
[coroutines] Fix leak in CGCoroutine.cpp

FinalBB need to be emitted even when unused to make sure it is deleted

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

7 years agoChange __has_feature(objc_diagnose_if_attr) to __has_feature(attribute_diagnose_if_ob...
Argyrios Kyrtzidis [Wed, 24 May 2017 01:38:00 +0000 (01:38 +0000)]
Change __has_feature(objc_diagnose_if_attr) to __has_feature(attribute_diagnose_if_objc) for consistency with rest of attribute checks.

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

7 years agoEnhance the 'diagnose_if' attribute so that we can apply it for ObjC methods and...
Argyrios Kyrtzidis [Wed, 24 May 2017 00:46:27 +0000 (00:46 +0000)]
Enhance the 'diagnose_if' attribute so that we can apply it for ObjC methods and properties as well

This is an initial commit to allow using it with constant expressions, a follow-up commit will enable full support for it in ObjC methods.

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

7 years ago[Modules] Fix overly conservative assertion for import diagnostic
Bruno Cardoso Lopes [Tue, 23 May 2017 23:53:17 +0000 (23:53 +0000)]
[Modules] Fix overly conservative assertion for import diagnostic

We currenltly assert when want to diagnose a missing import and the decl
in question is already visible. It turns out that the decl in question
might be visible because another decl from the same module actually made
the module visible in a previous error diagnostic.

Remove the assertion and avoid re-exporting the module if it's already
visible.

rdar://problem/27975402

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

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

7 years ago[modules] When reparenting a local declaration, don't mark the declaration as
Richard Smith [Tue, 23 May 2017 22:02:49 +0000 (22:02 +0000)]
[modules] When reparenting a local declaration, don't mark the declaration as
being visible with its owning module if we're not tracking owning modules for
local declarations.

This avoids the possibility of a declaration being (meaninglessly) marked as
hidden with no owning module, which would otherwise lead to violated AST
invariants (checked by the added assertion).

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

7 years agoSema: allow imaginary constants via GNU extension if UDL overloads not present.
Tim Northover [Tue, 23 May 2017 21:41:49 +0000 (21:41 +0000)]
Sema: allow imaginary constants via GNU extension if UDL overloads not present.

C++14 added user-defined literal support for complex numbers so that you can
write something like "complex<double> val = 2i". However, there is an existing
GNU extension supporting this syntax and interpreting the result as a _Complex
type.

This changes parsing so that such literals are interpreted in terms of C++14's
operators if an overload is present but otherwise falls back to the original
GNU extension.

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

7 years ago[Frontend] Don't index into an empty string.
Benjamin Kramer [Tue, 23 May 2017 20:48:21 +0000 (20:48 +0000)]
[Frontend] Don't index into an empty string.

Found by msan!

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

7 years agoRemove trailing whitespace
Yuka Takahashi [Tue, 23 May 2017 18:52:27 +0000 (18:52 +0000)]
Remove trailing whitespace

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

7 years ago[GSoC] Shell autocompletion for clang
Yuka Takahashi [Tue, 23 May 2017 18:39:08 +0000 (18:39 +0000)]
[GSoC] Shell autocompletion for clang

Summary:
This is a first patch for GSoC project, bash-completion for clang.
To use this on bash, please run `source clang/utils/bash-autocomplete.sh`.
bash-autocomplete.sh is code for bash-completion.

Simple flag completion and path completion is available in this patch.

Reviewers: teemperor, v.g.vassilev, ruiu, Bigcheese, efriedma

Subscribers: llvm-commits

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

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

7 years agoRemoved fallthrough annotation which does not directly precede switch label.
Galina Kistanova [Tue, 23 May 2017 16:56:10 +0000 (16:56 +0000)]
Removed fallthrough annotation which does not directly precede switch label.

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

7 years ago[index] The references to enum constants from member enums that are
Alex Lorenz [Tue, 23 May 2017 16:47:01 +0000 (16:47 +0000)]
[index] The references to enum constants from member enums that are
from template instantiations should refer to the enum constant in the pattern
enum in the base template

rdar://32325459

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

7 years ago[index] The references to member enums from template instantiations should
Alex Lorenz [Tue, 23 May 2017 16:35:50 +0000 (16:35 +0000)]
[index] The references to member enums from template instantiations should
refer to the pattern member enum in the base template

rdar://32325459

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@303650 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 16:33:07 +0000 (16:33 +0000)]
Added LLVM_FALLTHROUGH to address gcc warning: this statement may fall through.

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

7 years ago[index] The references to type aliases and typedefs from template
Alex Lorenz [Tue, 23 May 2017 16:27:42 +0000 (16:27 +0000)]
[index] The references to type aliases and typedefs from template
instantiations should refer to the pattern type aliases / typedefs in the base
templates

rdar://32325459

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

7 years ago[index] The references to fields from nested records in template instantiations
Alex Lorenz [Tue, 23 May 2017 16:25:06 +0000 (16:25 +0000)]
[index] The references to fields from nested records in template instantiations
should refer to the pattern fields in the nested records in the base templates

rdar://32352429

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

7 years ago[index] The references to records from template instantiations should refer
Alex Lorenz [Tue, 23 May 2017 16:23:28 +0000 (16:23 +0000)]
[index] The references to records from template instantiations should refer
to the pattern records in the base templates

rdar://32325459

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

7 years ago[AMDGPU] Do not require opencl triple environment for OpenCL
Yaxun Liu [Tue, 23 May 2017 16:15:53 +0000 (16:15 +0000)]
[AMDGPU] Do not require opencl triple environment for OpenCL

A recent change requires opencl triple environment for compiling OpenCL
program, which causes regressions in libclc.

This patch fixes that. Instead of deducing language based on triple
environment, it checks LangOptions.

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

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

7 years agoAdd test coverage for recent behavior change in GNU line marker pre-processing
Reid Kleckner [Tue, 23 May 2017 16:09:13 +0000 (16:09 +0000)]
Add test coverage for recent behavior change in GNU line marker pre-processing

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

7 years ago[Tooling][libclang] Remove unused CompilationDatabase::MappedSources
Krasimir Georgiev [Tue, 23 May 2017 13:50:43 +0000 (13:50 +0000)]
[Tooling][libclang] Remove unused CompilationDatabase::MappedSources

Summary:
This field is never assigned to and it's only ever read from libclang.
This patch removes it and adapts libclang to return constants.

Reviewers: klimek, bkramer

Reviewed By: klimek

Subscribers: cfe-commits, klimek

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

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

7 years agoAllow to use vfs::FileSystem for file accesses inside ASTUnit.
Ilya Biryukov [Tue, 23 May 2017 11:37:52 +0000 (11:37 +0000)]
Allow to use vfs::FileSystem for file accesses inside ASTUnit.

Reviewers: bkramer, krasimir, arphaman, akyrtzi

Reviewed By: bkramer

Subscribers: klimek, cfe-commits

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

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

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