]> granicus.if.org Git - clang/log
clang
7 years agoAdd support for -fno-auto-profile and -fno-profile-sample-use
Dehao Chen [Tue, 21 Mar 2017 21:40:53 +0000 (21:40 +0000)]
Add support for -fno-auto-profile and -fno-profile-sample-use

Summary: We need to be able to disable samplepgo for specific files by supporting -fno-auto-profile and -fno-profile-sample-use

Reviewers: davidxl, dnovillo, echristo

Reviewed By: echristo

Subscribers: echristo, cfe-commits

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

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

7 years agoApply clang-tidy's performance-unnecessary-value-param to parts of clang.
Benjamin Kramer [Tue, 21 Mar 2017 21:35:04 +0000 (21:35 +0000)]
Apply clang-tidy's performance-unnecessary-value-param to parts of clang.

No functionality change intended.

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

7 years ago[c-index-test] Fix memory leak in c-index-test tool.
Argyrios Kyrtzidis [Tue, 21 Mar 2017 21:34:05 +0000 (21:34 +0000)]
[c-index-test] Fix memory leak in c-index-test tool.

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

7 years agoiFix Test deprecation behavior in C89 mode as a result of r298410
Erich Keane [Tue, 21 Mar 2017 20:14:46 +0000 (20:14 +0000)]
iFix Test deprecation behavior in C89 mode as a result of r298410

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

7 years agoLet llvm.objectsize be conservative with null pointers
George Burgess IV [Tue, 21 Mar 2017 20:09:35 +0000 (20:09 +0000)]
Let llvm.objectsize be conservative with null pointers

D28494 adds another parameter to @llvm.objectsize. Clang needs to be
sure to pass that third arg whenever applicable.

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

7 years agoClang change: Do not inline hot callsites for samplepgo in thinlto compile phase.
Dehao Chen [Tue, 21 Mar 2017 19:55:46 +0000 (19:55 +0000)]
Clang change: Do not inline hot callsites for samplepgo in thinlto compile phase.

Summary:
Because SamplePGO passes will be invoked twice in ThinLTO build: once at compile phase, the other at backend. We want to make sure the IR at the 2nd phase matches the hot part in pro
file, thus we do not want to inline hot callsites in the first phase.

Reviewers: tejohnson, eraman

Reviewed By: tejohnson

Subscribers: mehdi_amini, cfe-commits, Prazek

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

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

7 years ago[X86][MS-compatability][clang] allow MS TYPE/SIZE/LENGTH operators as a part of a...
Coby Tayree [Tue, 21 Mar 2017 19:33:32 +0000 (19:33 +0000)]
[X86][MS-compatability][clang] allow MS TYPE/SIZE/LENGTH operators as a part of a compound expression

This patch introduces X86AsmParser with the ability to handle the aforementioned ops within compound "MS" arithmetical expressions.
Currently - only supported as a stand alone Operand, e.g.:
"TYPE X"
now allowed :
"4 + TYPE X * 128"

LLVM side: https://reviews.llvm.org/D31173
Differential Revision: https://reviews.llvm.org/D31174

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

7 years ago[CMake] fix CLANG_INCLUDE_DIRS CMake export
Guillaume Papin [Tue, 21 Mar 2017 19:17:53 +0000 (19:17 +0000)]
[CMake] fix CLANG_INCLUDE_DIRS CMake export

Summary:
This change should fixes the export of CLANG_INCLUDE_DIRS variable in ClangConfig.cmake.

Unlike for the other variables, CLANG_INSTALL_PREFIX wasn't escaped meaning CLANG_INCLUDE_DIRS
resulting in the path "/include" instead of "${CLANG_INSTALL_PREFIX}/include".

Reviewers: beanz

Subscribers: mgorny

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

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

7 years agoFix array sizes where address space is not yet known
Konstantin Zhuravlyov [Tue, 21 Mar 2017 18:55:39 +0000 (18:55 +0000)]
Fix array sizes where address space is not yet known

For variables in generic address spaces, for example:

```
unsigned char V[6442450944];
...
```

the address space is not yet known when we get into
*getConstantArrayType*, it is 0. AMDGCN target's
address space 0 has 32 bits pointers, so when we
call *getPointerWidth* with 0, the array size is
trimmed to 32 bits, which is not right.

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

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

7 years agoModules: Remove an invalid check in unit tests for r298278
Duncan P. N. Exon Smith [Tue, 21 Mar 2017 18:26:18 +0000 (18:26 +0000)]
Modules: Remove an invalid check in unit tests for r298278

This is a fixup for the unit tests from r298278 (originally r298165).

Since the buffer that RawB2 pointed at was later deleted, a new call to
getBuffer may very well return a buffer at the same/old address.  Which is
fine.  Just delete the spurious check.

A Windows bot was occasionally hitting this in practice:
http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/7086

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

7 years agoCorrect class-template deprecation behavior
Erich Keane [Tue, 21 Mar 2017 17:49:17 +0000 (17:49 +0000)]
Correct class-template deprecation behavior

Based on the comment in the test, and my reading of the standard, a deprecated warning should be issued in the following case:
template<typename T> [[deprecated]] class Foo{}; Foo<int> f;

This was not the case, because the ClassTemplateSpecializationDecl creation did not also copy the deprecated attribute.

Note: I did NOT audit the complete set of attributes to see WHICH ones should be copied, so instead I simply copy ONLY the deprecated attribute.

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

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

7 years agoUpdate Clang for LLVM rename AttributeSet -> AttributeList
Reid Kleckner [Tue, 21 Mar 2017 16:57:30 +0000 (16:57 +0000)]
Update Clang for LLVM rename AttributeSet -> AttributeList

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

7 years ago[index/AST] Determine if a typedef shares a name and spelling location with its under...
Argyrios Kyrtzidis [Tue, 21 Mar 2017 16:56:02 +0000 (16:56 +0000)]
[index/AST] Determine if a typedef shares a name and spelling location with its underlying tag type

In such a case, as when using the NS_ENUM macro, for indexing purposes treat the typedef as 'transparent',
meaning we treat its references as symbols of the underlying tag symbol.
Also provide a libclang API to check for such typedefs.

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

7 years ago[Modules] Find PrivateHeaders when looking into subframeworks
Bruno Cardoso Lopes [Tue, 21 Mar 2017 16:43:51 +0000 (16:43 +0000)]
[Modules] Find PrivateHeaders when looking into subframeworks

Fix the current parsing of subframeworks in modulemaps to lookup for
headers based on whether they are frameworks.

rdar://problem/30563982

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

7 years ago[DOXYGEN] Improvements to smmintrin.h and emmintrin.h intrinsics.
Ekaterina Romanova [Tue, 21 Mar 2017 13:34:06 +0000 (13:34 +0000)]
[DOXYGEN] Improvements to smmintrin.h and emmintrin.h intrinsics.

I made some small changes in smmintrin.h and emmintrin.h intrinsics.
 - changed some regular comments '//' into doxygen-style comments '///' where necessary
 - removed some trailing spaces in doxygen comments.

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@298371 91177308-0d34-0410-b5e6-96231b3b80d8

7 years ago[OpenCL] Added diagnostic for checking length of vector
Egor Churaev [Tue, 21 Mar 2017 13:20:57 +0000 (13:20 +0000)]
[OpenCL] Added diagnostic for checking length of vector

Reviewers: Anastasia, cfe-commits

Reviewed By: Anastasia

Subscribers: bader, yaxunl

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

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

7 years ago[OpenCL] Added implicit conversion rank for overloading functions with vector data...
Egor Churaev [Tue, 21 Mar 2017 12:55:55 +0000 (12:55 +0000)]
[OpenCL] Added implicit conversion rank for overloading functions with vector data type in OpenCL

Summary: I added a new rank to ImplicitConversionRank enum to resolve the function overload ambiguity with vector types. Rank of scalar types conversion is lower than vector splat. So, we can choose which function should we call. See test for more details.

Reviewers: Anastasia, cfe-commits

Reviewed By: Anastasia

Subscribers: bader, yaxunl

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

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

7 years ago[X86][AVX512] Add _mm512_cvtsd_f64 and _mm512_cvtss_f32 intrinsics (PR32305)
Simon Pilgrim [Tue, 21 Mar 2017 12:46:13 +0000 (12:46 +0000)]
[X86][AVX512] Add _mm512_cvtsd_f64 and _mm512_cvtss_f32 intrinsics (PR32305)

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

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

7 years ago[scan-build-py] reuse command line output parameter for report directory
Laszlo Nagy [Tue, 21 Mar 2017 10:15:18 +0000 (10:15 +0000)]
[scan-build-py] reuse command line output parameter for report directory

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

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

7 years agoAdd support for attribute enum_extensibility.
Akira Hatanaka [Tue, 21 Mar 2017 02:23:00 +0000 (02:23 +0000)]
Add support for attribute enum_extensibility.

This commit adds support for a new attribute that will be used to
distinguish between extensible and inextensible enums. There are three
main purposes of this attribute:

1. Give better control over when enum-related warnings are issued.
For example, in the code below, clang will not issue a -Wassign-enum
warning if the enum is marked "open":

enum __attribute__((enum_extensibility(closed))) EnumClosed {
  B0 = 1, B1 = 10
};

enum __attribute__((enum_extensibility(open))) EnumOpen {
  C0 = 1, C1 = 10
};

enum EnumClosed ec = 100; // warning issued
enum EnumOpen eo = 100; // no warning

2. Enable code-completion and debugging tools to offer better
suggestions.

3. Make it easier for swift's clang importer to determine which swift
type an enum should be mapped to.

For more details, see the discussion I started on cfe-dev:
http://lists.llvm.org/pipermail/cfe-dev/2017-February/052748.html

rdar://problem/12764379
rdar://problem/23145650

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

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

7 years agoIRGen: Do not set dllexport on declarations.
Peter Collingbourne [Tue, 21 Mar 2017 02:02:41 +0000 (02:02 +0000)]
IRGen: Do not set dllexport on declarations.

Setting dllexport on a declaration has no effect, as we do not emit export
directives for declarations.

Part of the fix for PR32334.

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

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

7 years agoAdd a function to MD5 a file's contents.
Zachary Turner [Mon, 20 Mar 2017 23:33:18 +0000 (23:33 +0000)]
Add a function to MD5 a file's contents.

In doing so, clean up the MD5 interface a little.  Most
existing users only care about the lower 8 bytes of an MD5,
but for some users that care about the upper and lower,
there wasn't a good interface.  Furthermore, consumers
of the MD5 checksum were required to handle endianness
details on their own, so it seems reasonable to abstract
this into a nicer interface that just gives you the right
value.

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

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

7 years agoFix parsing of htmxlintrin.h in C++ mode
Eric Christopher [Mon, 20 Mar 2017 22:31:33 +0000 (22:31 +0000)]
Fix parsing of htmxlintrin.h in C++ mode
 - Fix a variable naming mismatch
 - Fix gcc extension pointer arithmetic on void to cast to char *.
 - Test that the header (and htmintrin.h) parse.

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

7 years ago[docs] Clarify sanitizer flag behavior
Vedant Kumar [Mon, 20 Mar 2017 21:40:58 +0000 (21:40 +0000)]
[docs] Clarify sanitizer flag behavior

PR32346 suggests that UBSan's docs about the -fsanitize,
-fno-sanitize-recover, and -fsanitize-trap options are not explicit
enough. Try to improve the wording.

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

7 years agoTurn on HTM on power8 and later (including powerpc64le) since it's
Eric Christopher [Mon, 20 Mar 2017 21:12:53 +0000 (21:12 +0000)]
Turn on HTM on power8 and later (including powerpc64le) since it's
available by default on those cpus and configurations.

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

7 years agoProposal: Backward-edge CFI for return statements (RCFI)
Kostya Serebryany [Mon, 20 Mar 2017 20:42:00 +0000 (20:42 +0000)]
Proposal: Backward-edge CFI for return statements (RCFI)

Summary: Proposal: Backward-edge CFI for return statements (RCFI)

Reviewers: pcc, eugenis, krasin

Reviewed By: eugenis

Subscribers: llvm-commits

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

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

7 years agoAvoid these headers looking like the same file on a content-addressed file system.
Richard Smith [Mon, 20 Mar 2017 20:14:03 +0000 (20:14 +0000)]
Avoid these headers looking like the same file on a content-addressed file system.

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

7 years agoBump __cplusplus for C++17 to 201703L per the C++17 DIS.
Richard Smith [Mon, 20 Mar 2017 20:12:48 +0000 (20:12 +0000)]
Bump __cplusplus for C++17 to 201703L per the C++17 DIS.

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

7 years agoReapply "Modules: Cache PCMs in memory and avoid a use-after-free"
Duncan P. N. Exon Smith [Mon, 20 Mar 2017 17:58:26 +0000 (17:58 +0000)]
Reapply "Modules: Cache PCMs in memory and avoid a use-after-free"

This reverts commit r298185, effectively reapplying r298165, after fixing the
new unit tests (PR32338).  The memory buffer generator doesn't null-terminate
the MemoryBuffer it creates; this version of the commit informs getMemBuffer
about that to avoid the assert.

Original commit message follows:

----

Clang's internal build system for implicit modules uses lock files to
ensure that after a process writes a PCM it will read the same one back
in (without contention from other -cc1 commands).  Since PCMs are read
from disk repeatedly while invalidating, building, and importing, the
lock is not released quickly.  Furthermore, the LockFileManager is not
robust in every environment.  Other -cc1 commands can stall until
timeout (after about eight minutes).

This commit changes the lock file from being necessary for correctness
to a (possibly dubious) performance hack.  The remaining benefit is to
reduce duplicate work in competing -cc1 commands which depend on the
same module.  Follow-up commits will change the internal build system to
continue after a timeout, and reduce the timeout.  Perhaps we should
reconsider blocking at all.

This also fixes a use-after-free, when one part of a compilation
validates a PCM and starts using it, and another tries to swap out the
PCM for something new.

The PCMCache is a new type called MemoryBufferCache, which saves memory
buffers based on their filename.  Its ownership is shared by the
CompilerInstance and ModuleManager.

- The ModuleManager stores PCMs there that it loads from disk, never
touching the disk if the cache is hot.

- When modules fail to validate, they're removed from the cache.

- When a CompilerInstance is spawned to build a new module, each
already-loaded PCM is assumed to be valid, and is frozen to avoid
the use-after-free.

- Any newly-built module is written directly to the cache to avoid the
round-trip to the filesystem, making lock files unnecessary for
correctness.

Original patch by Manman Ren; most testcases by Adrian Prantl!

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

7 years agoFix some sphinx -Werror's
Jonathan Roelofs [Mon, 20 Mar 2017 17:07:49 +0000 (17:07 +0000)]
Fix some sphinx -Werror's

... mostly having to do with code blocks which the syntax highlighter chokes on

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

7 years ago[OpenCL] Fix extension guards for atomic functions
Anastasia Stulova [Mon, 20 Mar 2017 15:02:54 +0000 (15:02 +0000)]
[OpenCL] Fix extension guards for atomic functions

Review: D30830

Patch by James Price!

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

7 years agoAdd more examples to clang-format configuration
Sylvestre Ledru [Mon, 20 Mar 2017 12:56:40 +0000 (12:56 +0000)]
Add more examples to clang-format configuration

Reviewers: djasper

Reviewed By: djasper

Subscribers: klimek, cfe-commits

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

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

7 years ago[scan-build-py] use python tempfile for tempdir
Laszlo Nagy [Mon, 20 Mar 2017 09:03:24 +0000 (09:03 +0000)]
[scan-build-py] use python tempfile for tempdir

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

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

7 years agoCleaning up the IdentifierResolver::iterator class a bit; NFC.
Aaron Ballman [Sun, 19 Mar 2017 15:15:28 +0000 (15:15 +0000)]
Cleaning up the IdentifierResolver::iterator class a bit; NFC.

The comment about there being three different forms that Ptr represents was stale. Also, the opaque value does not need to be exposed (these functions are unused).

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

7 years ago[X86][AVX512][Clang][Intrinsics] Adding missing intrinsics to Clang .
Igor Breger [Sun, 19 Mar 2017 08:27:16 +0000 (08:27 +0000)]
[X86][AVX512][Clang][Intrinsics] Adding missing intrinsics to Clang .

Summary:
Adding missing intrinsics :
    _mm512_set_epi16,
    _mm512_set_epi8,
    _mm512_permutevar_epi32
    _mm512_mask_permutevar_epi32

Reviewers: zvi, guyblank, eladcohen, craig.topper

Reviewed By: craig.topper

Subscribers: craig.topper, cfe-commits

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

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

7 years agoRevert "Modules: Cache PCMs in memory and avoid a use-after-free"
Renato Golin [Sat, 18 Mar 2017 12:31:32 +0000 (12:31 +0000)]
Revert "Modules: Cache PCMs in memory and avoid a use-after-free"

This reverts commit r298165, as it broke the ARM builds.

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

7 years ago[X86] Add NumRegisterParameters Module Flag.
Nirav Dave [Sat, 18 Mar 2017 00:43:39 +0000 (00:43 +0000)]
[X86] Add NumRegisterParameters Module Flag.

Reviewers: rnk, mkuper

Subscribers: llvm-commits

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

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

7 years ago[Modules] In case of lock timeout, fallback and build module
Bruno Cardoso Lopes [Sat, 18 Mar 2017 00:26:18 +0000 (00:26 +0000)]
[Modules] In case of lock timeout, fallback and build module

Duncan's r298165 introduced the PCMCache mechanism, which guarantees
that locks aren't necessary anymore for correctness but only for
performance, by avoiding building it twice when possible.

Change the logic to avoid an error but actually build the module in case
the timeout happens. Instead of an error, still emit a remark for
debugging purposes.

rdar://problem/30297862

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

7 years ago[index] For C++ constructors/destructors, add references to the parent type where...
Argyrios Kyrtzidis [Fri, 17 Mar 2017 23:41:59 +0000 (23:41 +0000)]
[index] For C++ constructors/destructors, add references to the parent type where its name appears in definitions and declarations

Patch by Nathan Hawes!
https://reviews.llvm.org/D30730

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

7 years agoModules: Cache PCMs in memory and avoid a use-after-free
Duncan P. N. Exon Smith [Fri, 17 Mar 2017 22:55:13 +0000 (22:55 +0000)]
Modules: Cache PCMs in memory and avoid a use-after-free

Clang's internal build system for implicit modules uses lock files to
ensure that after a process writes a PCM it will read the same one back
in (without contention from other -cc1 commands).  Since PCMs are read
from disk repeatedly while invalidating, building, and importing, the
lock is not released quickly.  Furthermore, the LockFileManager is not
robust in every environment.  Other -cc1 commands can stall until
timeout (after about eight minutes).

This commit changes the lock file from being necessary for correctness
to a (possibly dubious) performance hack.  The remaining benefit is to
reduce duplicate work in competing -cc1 commands which depend on the
same module.  Follow-up commits will change the internal build system to
continue after a timeout, and reduce the timeout.  Perhaps we should
reconsider blocking at all.

This also fixes a use-after-free, when one part of a compilation
validates a PCM and starts using it, and another tries to swap out the
PCM for something new.

The PCMCache is a new type called MemoryBufferCache, which saves memory
buffers based on their filename.  Its ownership is shared by the
CompilerInstance and ModuleManager.

  - The ModuleManager stores PCMs there that it loads from disk, never
    touching the disk if the cache is hot.

  - When modules fail to validate, they're removed from the cache.

  - When a CompilerInstance is spawned to build a new module, each
    already-loaded PCM is assumed to be valid, and is frozen to avoid
    the use-after-free.

  - Any newly-built module is written directly to the cache to avoid the
    round-trip to the filesystem, making lock files unnecessary for
    correctness.

Original patch by Manman Ren; most testcases by Adrian Prantl!

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

7 years ago[Sema] Unbreak GCC -Werror build (enum compare).
Davide Italiano [Fri, 17 Mar 2017 22:19:20 +0000 (22:19 +0000)]
[Sema] Unbreak GCC -Werror build (enum compare).

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

7 years agoImplement DR 373 "Lookup on namespace qualified name in using-directive"
Matthias Gehre [Fri, 17 Mar 2017 21:41:20 +0000 (21:41 +0000)]
Implement DR 373 "Lookup on namespace qualified name in using-directive"

Summary:
3.4.6 [basic.lookup.udir] paragraph 1:
In a using-directive or namespace-alias-definition, during the lookup for a namespace-name or for a name in a nested-name-specifier, only namespace names are considered.

Reviewers: rsmith, aaron.ballman

Subscribers: cfe-commits

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

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

7 years ago[clang-cl] Fix cross-compilation with MSVC 2017.
Zachary Turner [Fri, 17 Mar 2017 16:24:34 +0000 (16:24 +0000)]
[clang-cl] Fix cross-compilation with MSVC 2017.

clang-cl works best when the user runs vcvarsall to set up
an environment before running, but even this is not enough
on VC 2017 when cross compiling (e.g. using an x64 toolchain
to target x86, or vice versa).

The reason is that although clang-cl itself will have a
valid environment, it will shell out to other tools (such
as link.exe) which may not.  Generally we solve this through
adding the appropriate linker flags, but this is not enough
in VC 2017.

The cross-linker and the regular linker both link against
some common DLLs, but these DLLs live in the binary directory
of the native linker.  When setting up a cross-compilation
environment through vcvarsall, it will add *both* directories
to %PATH%, so that when cl shells out to any of the associated
tools, those tools will be able to find all of the dependencies
that it links against.  If you don't do this, link.exe will
fail to run because the loader won't be able to find all of
the required DLLs that it links against.

To solve this we teach the driver how to spawn a process with
an explicitly specified environment.  Then we modify the
PATH before shelling out to subtools and run with the modified
PATH.

Patch by Hamza Sood
Differential Revision: https://reviews.llvm.org/D30991

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

7 years agoTest commit.
David Green [Fri, 17 Mar 2017 15:38:49 +0000 (15:38 +0000)]
Test commit.

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

7 years ago[AVX-512] Change the input type for some load intrinsics to take void type like the...
Craig Topper [Fri, 17 Mar 2017 05:59:25 +0000 (05:59 +0000)]
[AVX-512] Change the input type for some load intrinsics to take void type like the spec (and the test cases say).

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

7 years ago[AVX-512] Fix test cases that were using the builtins directly without typecasts...
Craig Topper [Fri, 17 Mar 2017 05:59:22 +0000 (05:59 +0000)]
[AVX-512] Fix test cases that were using the builtins directly without typecasts instead of the intrinsic header.

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

7 years ago[AVX-512] Add missing typecasts and parentheses to _mm512_mask_i64gather_ps. My macro...
Craig Topper [Fri, 17 Mar 2017 05:14:37 +0000 (05:14 +0000)]
[AVX-512] Add missing typecasts and parentheses to _mm512_mask_i64gather_ps. My macro cleanup script I used on the others last year must have missed it.

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

7 years ago[Serialization] Follow-up to r297972, deserialize name/loc in separate statements...
Argyrios Kyrtzidis [Fri, 17 Mar 2017 00:49:42 +0000 (00:49 +0000)]
[Serialization] Follow-up to r297972, deserialize name/loc in separate statements to make sure they deserialize in defined order.

This should fix the windows bots.

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

7 years agoRemove setting LessPreciseFPMADOption on the TargetOption as it's
Eric Christopher [Fri, 17 Mar 2017 00:37:53 +0000 (00:37 +0000)]
Remove setting LessPreciseFPMADOption on the TargetOption as it's
unused anywhere in llvm.

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

7 years ago[Headers] Reapply: Add #include_next for tgmath.h on Darwin
Bruno Cardoso Lopes [Thu, 16 Mar 2017 23:19:00 +0000 (23:19 +0000)]
[Headers] Reapply: Add #include_next for tgmath.h on Darwin

Reapply r289181 but rename the include guard to avoid
conflict with the one from Darwin.

Allow darwin to provide additional definitions and implementation
specifc values for tgmath.h on Apple platforms.

rdar://problem/19019845

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

7 years ago[Modules] Add documentation on private frameworks
Bruno Cardoso Lopes [Thu, 16 Mar 2017 23:18:55 +0000 (23:18 +0000)]
[Modules] Add documentation on private frameworks

Expand a bit on private modules with some guidance on how to write
them in the context of frameworks.

rdar://problem/24758771

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

7 years agoAdd a small test for __STRUCT_PARM_ALIGN__ for ppc64 darwin.
Eric Christopher [Thu, 16 Mar 2017 22:31:07 +0000 (22:31 +0000)]
Add a small test for __STRUCT_PARM_ALIGN__ for ppc64 darwin.

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

7 years agoCreate msbuild only when using MSVC
Reid Kleckner [Thu, 16 Mar 2017 21:21:00 +0000 (21:21 +0000)]
Create msbuild only when using MSVC

Patch by: Mateusz Mikula

Reviewers: rnk

Reviewed By: rnk

Subscribers: asl, mgorny, cfe-commits

Tags: #clang-c

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

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

7 years agoUse arg_begin() instead of getArgumentList().begin(), the argument list is an impleme...
Reid Kleckner [Thu, 16 Mar 2017 18:55:46 +0000 (18:55 +0000)]
Use arg_begin() instead of getArgumentList().begin(), the argument list is an implementation detail

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

7 years ago[AST] Follow-up to r297972, add default value for setGetterName/setSetterName if...
Argyrios Kyrtzidis [Thu, 16 Mar 2017 18:40:13 +0000 (18:40 +0000)]
[AST] Follow-up to r297972, add default value for setGetterName/setSetterName if a source-loc is not provided.

Fixes lldb build.

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

7 years ago[index/AST] Add references for ObjC getter=/setter= property attributes and related...
Argyrios Kyrtzidis [Thu, 16 Mar 2017 18:25:40 +0000 (18:25 +0000)]
[index/AST] Add references for ObjC getter=/setter= property attributes and related property getter/setter role fixes

This enhances the AST to keep track of locations of the names in those ObjC property attributes, and reports them for indexing.

Patch by Nathan Hawes!
https://reviews.llvm.org/D30907

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

7 years ago[ObjC][Sema] Avoid ARC performSelector error for 'self' selector
Alex Lorenz [Thu, 16 Mar 2017 16:36:11 +0000 (16:36 +0000)]
[ObjC][Sema] Avoid ARC performSelector error for 'self' selector

The instance method 'self' does not actually return an over-retained object,
so we shouldn't report an error when it's used with 'performSelector'.

rdar://31071620

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

7 years agoMake table cells referring to Clang 4 green, as Clang 4 has been released.
Ed Schouten [Thu, 16 Mar 2017 14:21:00 +0000 (14:21 +0000)]
Make table cells referring to Clang 4 green, as Clang 4 has been released.

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

7 years ago[OpenCL] Implement as_type operator as alias of __builtin_astype.
Egor Churaev [Thu, 16 Mar 2017 12:15:10 +0000 (12:15 +0000)]
[OpenCL] Implement as_type operator as alias of __builtin_astype.

Reviewers: Anastasia

Reviewed By: Anastasia

Subscribers: cfe-commits, yaxunl, bader

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

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

7 years ago[clang-format] disable adding extra space after MSVC '__super' keyword
Martin Probst [Thu, 16 Mar 2017 10:21:35 +0000 (10:21 +0000)]
[clang-format] disable adding extra space after MSVC '__super' keyword

clang-format treats MSVC `__super` keyword like all other keywords adding
a single space after. This change disables this behavior for `__super`.

Patch originally by jutocz (thanks!).

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

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

7 years agoclang-format: Fix bug in wrapping behavior of operators.
Daniel Jasper [Thu, 16 Mar 2017 07:54:11 +0000 (07:54 +0000)]
clang-format: Fix bug in wrapping behavior of operators.

Before (even violating the column limit):
  auto Diag =
      diag()
      << aaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);

After:
  auto Diag = diag() << aaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaa,
                                         aaaaaaaaaaaaaaaaaaaaaaaaaa);

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

7 years agoFix up testcase to:
Eric Christopher [Wed, 15 Mar 2017 23:41:58 +0000 (23:41 +0000)]
Fix up testcase to:

a) avoid actually compiling anything
b) avoid depositing files in the test directory
c) use a check line to make sure that we're looking for the correct behavior

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

7 years agoRemove repeated code (PR32250). NFCI.
Simon Pilgrim [Wed, 15 Mar 2017 22:43:36 +0000 (22:43 +0000)]
Remove repeated code (PR32250). NFCI.

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

7 years agofix build break by removing the target on command line
Guansong Zhang [Wed, 15 Mar 2017 21:46:44 +0000 (21:46 +0000)]
fix build break by removing the target on command line

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

7 years agoenable -save-temps with -finclude-defult-header
Guansong Zhang [Wed, 15 Mar 2017 20:57:11 +0000 (20:57 +0000)]
enable -save-temps with -finclude-defult-header

Currently the two flags can not work together.

To illustrate the issue, we can have an one line file a.cl contains only an empty function

cat a.cl

void test(){}

Then use

clang -v -save-temps -x cl -Xclang -cl-std=CL2.0 -Xclang -finclude-default-header -target amdgcn -S -c a.cl

we will get redefinition errors for various things.

The reason is that the -finclude-default-header flag is not meant to be on cc1 command other than the preprocessor.

The fix is modeled after the code just below the change to filter the -finclude-default-header flag out when we are not in the preprocess phase.

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

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

7 years ago[X86][XOP] Add codegen tests for vector integer comparison intrinsics (PR15844)
Simon Pilgrim [Wed, 15 Mar 2017 20:20:43 +0000 (20:20 +0000)]
[X86][XOP] Add codegen tests for vector integer comparison intrinsics (PR15844)

We were testing for the generic _mm_com_* intrinsics, but not the specific comparison mode versions.

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

7 years agoAdd AST matchers for ObjCProtocolDecl, ObjCCategoryDecl, ObjCMethodDecl, ObjCIvarDecl...
Aaron Ballman [Wed, 15 Mar 2017 20:14:25 +0000 (20:14 +0000)]
Add AST matchers for ObjCProtocolDecl, ObjCCategoryDecl, ObjCMethodDecl, ObjCIvarDecl, and ObjCPropertyDecl.

Patch by Dave Lee.

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

7 years agoFix uninitialized value.
Zachary Turner [Wed, 15 Mar 2017 19:54:25 +0000 (19:54 +0000)]
Fix uninitialized value.

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

7 years ago[Driver] Define macro __APPLE_EMBEDDED_SIMULATOR__ when option
Akira Hatanaka [Wed, 15 Mar 2017 18:04:13 +0000 (18:04 +0000)]
[Driver] Define macro __APPLE_EMBEDDED_SIMULATOR__ when option
-m(i|tv|watch)os-simulator-version-min is on the command line.

Previously the driver would treat -m(i|tv|watch)os-simulator-version-min
as an alias of -m(i|tv|watch)os-version-min. This no longer works since
we now need to distinguish between the two options (the latter is used
for iOS running in a VM, for example).

This commit stops making the simulator options the aliases of the OS
options and defines a macro to differentiate between the two groups of
options.

rdar://problem/28872911

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

7 years ago[ObjC][Sema] Avoid warning about a call to an instance method on an
Alex Lorenz [Wed, 15 Mar 2017 17:16:41 +0000 (17:16 +0000)]
[ObjC][Sema] Avoid warning about a call to an instance method on an
instance of a qualified Class object when that instance method comes from
a protocol that's implemented by NSObject

Instance methods from a root class like NSObject are also class methods because
the metaclass of root class derives from that root class. Therefore, we can
avoid the warning for instances of qualified Class objects that point to classes
that derive from NSObject. Note that we actually don't know if a Class instance
points to a class that derives from NSObject at compile-time, so we have to
make a reasonable assumption that the majority of instances will do so.

rdar://22812517

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

7 years agoDon't use MSVC Setup Api on MinGW.
Zachary Turner [Wed, 15 Mar 2017 17:09:36 +0000 (17:09 +0000)]
Don't use MSVC Setup Api on MinGW.

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

7 years agoDisable warning about MSVC not found.
Zachary Turner [Wed, 15 Mar 2017 16:35:13 +0000 (16:35 +0000)]
Disable warning about MSVC not found.

When this test runs on bots that are configured to default
to MSVC, but MSVC isn't actually installed, we can emit a
warning that MSVC is not found.  Since MSVC isn't actually
needed for this test to succeed, just disable this warning.

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

7 years agoUpdate clang-cl driver for MSVC 2017.
Zachary Turner [Wed, 15 Mar 2017 16:07:35 +0000 (16:07 +0000)]
Update clang-cl driver for MSVC 2017.

2017 changes the way you find an installed copy of
Visual Studio as well as its internal directory layout.
As a result, clang-cl was unable to find VS2017 even
when you had run vcvarsall to set up a toolchain
environment.  This patch updates everything for 2017
and cleans up the way we handle a tiered search a la
environment -> installation -> PATH for which copy
of Visual Studio to bind to.

Patch originally by Hamza Sood, with some fixups for landing.

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

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

7 years ago[Driver] Restructure handling of -ffast-math and similar options
John Brawn [Wed, 15 Mar 2017 14:03:32 +0000 (14:03 +0000)]
[Driver] Restructure handling of -ffast-math and similar options

The way -ffast-math and the various related options to tweak floating-point
handling are handled is inflexible and rather confusing. This patch restructures
things so that we go through the options adjusting our idea of what's enabled as
we go, instead of trying to figure each individual thing out by working
backwards from the end, as this makes the behaviour of each individual option
more clear.

Doing it this way also means we get gcc-compatible behaviour for when the
__FAST_MATH__ and __FINITE_MATH_ONLY__ macros are defined, as they should depend
on the final set of features that are enabled and not just on -ffast-math and
-ffinite-math-only specifically.

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

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

7 years agoFix test on Windows. Only a single backslash was required, not a double.
Douglas Yung [Wed, 15 Mar 2017 01:38:24 +0000 (01:38 +0000)]
Fix test on Windows. Only a single backslash was required, not a double.

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

7 years agoMake a blind attempt to fix this testcase on Windows.
Adrian Prantl [Tue, 14 Mar 2017 23:29:40 +0000 (23:29 +0000)]
Make a blind attempt to fix this testcase on Windows.

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

7 years agoCanonicalize the path provided by -fmodules-cache-path.
Adrian Prantl [Tue, 14 Mar 2017 23:07:49 +0000 (23:07 +0000)]
Canonicalize the path provided by -fmodules-cache-path.

This fixes lookup mismatches that could happen when the module cache
path contained a '/./' component.

<rdar://problem/30413458>

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

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

7 years agoFix Wdocumentation warning
Simon Pilgrim [Tue, 14 Mar 2017 21:43:52 +0000 (21:43 +0000)]
Fix Wdocumentation warning

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

7 years ago[Hexagon] Recognize hexagonv62 as a valid target CPU
Krzysztof Parzyszek [Tue, 14 Mar 2017 20:29:23 +0000 (20:29 +0000)]
[Hexagon] Recognize hexagonv62 as a valid target CPU

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

7 years agoModules: Optimize bitcode encoding of diagnostic state
Duncan P. N. Exon Smith [Tue, 14 Mar 2017 19:31:27 +0000 (19:31 +0000)]
Modules: Optimize bitcode encoding of diagnostic state

Since bitcode uses VBR encoding, large numbers are more expensive than
small ones.  Instead of emitting a UINT_MAX sentinel after each sequence
of state-change pairs, emit the size of the sequence as a prefix.

This should have no functionality change besides saving bits from the
encoding.

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

7 years agoFix arch-specific-libdir tests on Windows
Reid Kleckner [Tue, 14 Mar 2017 18:24:41 +0000 (18:24 +0000)]
Fix arch-specific-libdir tests on Windows

This is pretty horrible, but I forget if we have any better ways to
handle these backslashing issues.

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

7 years agoWarn on enum assignment to bitfields that can't fit all values
Reid Kleckner [Tue, 14 Mar 2017 18:01:02 +0000 (18:01 +0000)]
Warn on enum assignment to bitfields that can't fit all values

This adds -Wbitfield-enum-conversion, which warns on implicit
conversions that happen on bitfield assignment that change the value of
some enumerators.

Values of enum type typically take on a very small range of values, so
they are frequently stored in bitfields. Unfortunately, there is no
convenient way to calculate the minimum number of bits necessary to
store all possible values at compile time, so users usually hard code a
bitwidth that works today and widen it as necessary to pass basic
testing and validation. This is very error-prone, and leads to stale
widths as enums grow. This warning aims to catch such bugs.

This would have found two real bugs in clang and two instances of
questionable code. See r297680 and r297654 for the full description of
the issues.

This warning is currently disabled by default while we investigate its
usefulness outside of LLVM.

The major cause of false positives with this warning is this kind of
enum:
  enum E { W, X, Y, Z, SENTINEL_LAST };
The last enumerator is an invalid value used to validate inputs or size
an array. Depending on the prevalance of this style of enum across a
codebase, this warning may be more or less feasible to deploy. It also
has trouble on sentinel values such as ~0U.

Reviewers: rsmith, rtrieu, thakis

Reviewed By: thakis

Subscribers: hfinkel, voskresensky.vladimir, sashab, cfe-commits

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

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

7 years agoAdd more debugging code for the SystemZ bot.
Juergen Ributzka [Tue, 14 Mar 2017 17:46:26 +0000 (17:46 +0000)]
Add more debugging code for the SystemZ bot.

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

7 years agoFix misspelled enum
Jonathan Roelofs [Tue, 14 Mar 2017 17:29:33 +0000 (17:29 +0000)]
Fix misspelled enum

https://reviews.llvm.org/D30945

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

7 years ago[Driver] Fix arch-specific-libdir-rpath.c
Pirama Arumuga Nainar [Tue, 14 Mar 2017 17:26:56 +0000 (17:26 +0000)]
[Driver] Fix arch-specific-libdir-rpath.c

Summary: Fix the test by adding missing -target flags with a 'linux' triple.

Reviewers: rnk, srhines

Subscribers: cfe-commits

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

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

7 years ago[Driver] Add flag to request arch-specific-subdir in -rpath
Pirama Arumuga Nainar [Tue, 14 Mar 2017 16:58:07 +0000 (16:58 +0000)]
[Driver] Add flag to request arch-specific-subdir in -rpath

Summary:
This patch adds -f[no-]rtlib-add-rpath, which if enabled, embeds the
arch-specific subdirectory in resource directory using -rpath (instead
of doing so only during native compilation).

This patch also re-enables test arch-specific-libdir.c which was
silently unsupported because of the REQUIRES tag 'linux'.

Reviewers: bkramer, rnk, mgorny

Subscribers: srhines, cfe-commits

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

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

7 years ago[ubsan] Use the nicer nullability diagnostic handlers
Vedant Kumar [Tue, 14 Mar 2017 16:48:29 +0000 (16:48 +0000)]
[ubsan] Use the nicer nullability diagnostic handlers

This is a follow-up to r297700 (Add a nullability sanitizer).

It addresses some FIXME's re: using nullability-specific diagnostic
handlers from compiler-rt, now that the necessary handlers exist.

check-ubsan test updates to follow.

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

7 years agoAdd more clang-format changes to the 5.0 release notes
Krasimir Georgiev [Tue, 14 Mar 2017 10:34:39 +0000 (10:34 +0000)]
Add more clang-format changes to the 5.0 release notes

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

7 years agodescribe the recent changes in clang-format in the 5.0 release notes
Sylvestre Ledru [Tue, 14 Mar 2017 09:43:55 +0000 (09:43 +0000)]
describe the recent changes in clang-format in the 5.0 release notes

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

7 years ago[CodeGen][ObjC] Fix a bug where the type of an ivar wasn't encoded
Akira Hatanaka [Tue, 14 Mar 2017 04:00:52 +0000 (04:00 +0000)]
[CodeGen][ObjC] Fix a bug where the type of an ivar wasn't encoded
correctly.

This fixes PR30413.

Patch by David Lobron.

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

7 years ago[ubsan] Add a nullability sanitizer
Vedant Kumar [Tue, 14 Mar 2017 01:56:34 +0000 (01:56 +0000)]
[ubsan] Add a nullability sanitizer

Teach UBSan to detect when a value with the _Nonnull type annotation
assumes a null value. Call expressions, initializers, assignments, and
return statements are all checked.

Because _Nonnull does not affect IRGen, the new checks are disabled by
default. The new driver flags are:

  -fsanitize=nullability-arg      (_Nonnull violation in call)
  -fsanitize=nullability-assign   (_Nonnull violation in assignment)
  -fsanitize=nullability-return   (_Nonnull violation in return stmt)
  -fsanitize=nullability          (all of the above)

This patch builds on top of UBSan's existing support for detecting
violations of the nonnull attributes ('nonnull' and 'returns_nonnull'),
and relies on the compiler-rt support for those checks. Eventually we
will need to update the diagnostic messages in compiler-rt (there are
FIXME's for this, which will be addressed in a follow-up).

One point of note is that the nullability-return check is only allowed
to kick in if all arguments to the function satisfy their nullability
preconditions. This makes it necessary to emit some null checks in the
function body itself.

Testing: check-clang and check-ubsan. I also built some Apple ObjC
frameworks with an asserts-enabled compiler, and verified that we get
valid reports.

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

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

7 years agoclang-format: Make it very slighly more expensive to wrap between "= {".
Daniel Jasper [Tue, 14 Mar 2017 00:40:32 +0000 (00:40 +0000)]
clang-format: Make it very slighly more expensive to wrap between "= {".

This prevents unwanted fallout from r296664. Specifically in proto formatting,
this changed:
  optional Aaaaaaaa aaaaaaaa = 12 [
    (aaa) = aaaa,
    (bbbbbbbbbbbbbbbbbbbbbbbbbb) = {
      aaaaaaaaaaaaaaaaa: true,
      aaaaaaaaaaaaaaaa: true
    }
  ];

Into:
  optional Aaaaaaaa aaaaaaaa = 12 [
    (aaa) = aaaa,
    (bbbbbbbbbbbbbbbbbbbbbbbbbb) =
        {aaaaaaaaaaaaaaaaa: true, aaaaaaaaaaaaaaaa: true}
  ];

Which is considered less readable. Generally, it seems preferable to
format such dict literals as blocks rather than contract them to one
line.

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

7 years agoFix crash with interrupt attribute on ARM.
Eli Friedman [Tue, 14 Mar 2017 00:18:29 +0000 (00:18 +0000)]
Fix crash with interrupt attribute on ARM.

An indirect call has no associated function declaration.

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

7 years agoReapply [VFS] Ignore broken symlinks in the directory iterator.
Juergen Ributzka [Tue, 14 Mar 2017 00:14:40 +0000 (00:14 +0000)]
Reapply [VFS] Ignore broken symlinks in the directory iterator.

Modified the tests to accept any iteration order, to run only on Unix, and added
additional error reporting to investigate SystemZ bot issue.

The VFS directory iterator and recursive directory iterator behave differently
from the LLVM counterparts. Once the VFS iterators hit a broken symlink they
immediately abort. The LLVM counterparts don't stat entries unless they have to
descend into the next directory, which allows to recover from this issue by
clearing the error code and skipping to the next entry.

This change adds similar behavior to the VFS iterators. There should be no
change in current behavior in the current CLANG source base, because all
clients have loop exit conditions that also check the error code.

This fixes rdar://problem/30934619.

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

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

7 years agoFix -Wunused-lambda-capture warning in new code
Reid Kleckner [Mon, 13 Mar 2017 22:33:07 +0000 (22:33 +0000)]
Fix -Wunused-lambda-capture warning in new code

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

7 years agoWiden AST bitfields too small to represent all enumerators
Reid Kleckner [Mon, 13 Mar 2017 22:33:04 +0000 (22:33 +0000)]
Widen AST bitfields too small to represent all enumerators

All of these were found by a new warning that I am prototyping,
-Wbitfield-enum-conversion.

Stmt::ExprBits::ObjectKind - This was not wide enough to represent
OK_ObjSubscript, so this was a real, true positive bug.

ObjCDeclSpec::objCDeclQualifier - On Windows, setting DQ_CSNullability
would cause the bitfield to become negative because enum types are
always implicitly 'int' there. This would probably never be noticed
because this is a flag-style enum, so we only ever test one bit at a
time. Switching to 'unsigned' also makes this type pack smaller on
Windows.

FunctionDecl::SClass - Technically, we only need two bits for all valid
function storage classes. Functions can never have automatic or register
storage class. This seems a bit too clever, and we have a bit to spare,
so widening the bitfield seems like the best way to pacify the warning.
You could classify this as a false positive, but widening the bitfield
defends us from invalid ASTs.

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

7 years agoAMDGPU: Make 0 the private nullptr value
Matt Arsenault [Mon, 13 Mar 2017 19:47:53 +0000 (19:47 +0000)]
AMDGPU: Make 0 the private nullptr value

We can't actually pretend that 0 is valid for address space 0.
r295877 added a workaround to stop allocating user objects
there, so we can use 0 as the invalid pointer.

Some of the tests seemed to be using private as the non-0 null
test address space, so add copies using local to make sure
this is still stressed.

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

7 years agoModules: Use hash of PCM content for SIGNATURE
Duncan P. N. Exon Smith [Mon, 13 Mar 2017 18:45:08 +0000 (18:45 +0000)]
Modules: Use hash of PCM content for SIGNATURE

Change ASTFileSignature from a random 32-bit number to the hash of the
PCM content.

  - Move definition ASTFileSignature to Basic/Module.h so Module and
    ASTSourceDescriptor can use it.

  - Change the signature from uint64_t to std::array<uint32_t,5>.

  - Stop using (saving/reading) the size and modification time of PCM
    files when there is a valid SIGNATURE.

  - Add UNHASHED_CONTROL_BLOCK, and use it to store the SIGNATURE record
    and other records that shouldn't affect the hash.  Because implicit
    modules reuses the same file for multiple levels of -Werror, this
    includes DIAGNOSTIC_OPTIONS and DIAG_PRAGMA_MAPPINGS.

This helps to solve a PCH + implicit Modules dependency issue: PCH files
are handled by the external build system, whereas implicit modules are
handled by internal compiler build system.  This prevents invalidating a
PCH when the compiler overwrites a PCM file with the same content
(modulo the diagnostic differences).

Design and original patch by Manman Ren!

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

7 years agoWiden bitfield for type specifiers for OpenCL types
Reid Kleckner [Mon, 13 Mar 2017 18:42:30 +0000 (18:42 +0000)]
Widen bitfield for type specifiers for OpenCL types

Added a static_assert to catch this issue at compile time.

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

7 years ago[Linker] Provide callback for internalization
Jonas Devlieghere [Mon, 13 Mar 2017 18:08:11 +0000 (18:08 +0000)]
[Linker] Provide callback for internalization

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

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