]> granicus.if.org Git - clang/log
clang
6 years agoSilence unused variable warnings. NFC
Richard Trieu [Tue, 30 Oct 2018 23:01:15 +0000 (23:01 +0000)]
Silence unused variable warnings.  NFC

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

6 years ago[clang][ubsan] Implicit Conversion Sanitizer - integer sign change - clang part
Roman Lebedev [Tue, 30 Oct 2018 21:58:56 +0000 (21:58 +0000)]
[clang][ubsan] Implicit Conversion Sanitizer - integer sign change - clang part

This is the second half of Implicit Integer Conversion Sanitizer.
It completes the first half, and finally makes the sanitizer
fully functional! Only the bitfield handling is missing.

Summary:
C and C++ are interesting languages. They are statically typed, but weakly.
The implicit conversions are allowed. This is nice, allows to write code
while balancing between getting drowned in everything being convertible,
and nothing being convertible. As usual, this comes with a price:

```
void consume(unsigned int val);

void test(int val) {
  consume(val);
  // The 'val' is `signed int`, but `consume()` takes `unsigned int`.
  // If val is negative, then consume() will be operating on a large
  // unsigned value, and you may or may not have a bug.

  // But yes, sometimes this is intentional.
  // Making the conversion explicit silences the sanitizer.
  consume((unsigned int)val);
}
```

Yes, there is a `-Wsign-conversion`` diagnostic group, but first, it is kinda
noisy, since it warns on everything (unlike sanitizers, warning on an
actual issues), and second, likely there are cases where it does **not** warn.

The actual detection is pretty easy. We just need to check each of the values
whether it is negative, and equality-compare the results of those comparisons.
The unsigned value is obviously non-negative. Zero is non-negative too.
https://godbolt.org/g/w93oj2

We do not have to emit the check *always*, there are obvious situations
where we can avoid emitting it, since it would **always** get optimized-out.
But i do think the tautological IR (`icmp ult %x, 0`, which is always false)
should be emitted, and the middle-end should cleanup it.

This sanitizer is in the `-fsanitize=implicit-conversion` group,
and is a logical continuation of D48958 `-fsanitize=implicit-integer-truncation`.
As for the ordering, i'we opted to emit the check **after**
`-fsanitize=implicit-integer-truncation`. At least on these simple 16 test cases,
this results in 1 of the 12 emitted checks being optimized away,
as compared to 0 checks being optimized away if the order is reversed.

This is a clang part.
The compiler-rt part is D50251.

Finishes fixing [[ https://bugs.llvm.org/show_bug.cgi?id=21530 | PR21530 ]], [[ https://bugs.llvm.org/show_bug.cgi?id=37552 | PR37552 ]], [[ https://bugs.llvm.org/show_bug.cgi?id=35409 | PR35409 ]].
Finishes partially fixing [[ https://bugs.llvm.org/show_bug.cgi?id=9821 | PR9821 ]].
Finishes fixing https://github.com/google/sanitizers/issues/940.

Only the bitfield handling is missing.

Reviewers: vsk, rsmith, rjmccall, #sanitizers, erichkeane

Reviewed By: rsmith

Subscribers: chandlerc, filcab, cfe-commits, regehr

Tags: #sanitizers, #clang

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

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

6 years agoChanging the command line parameters sent to diff for this test.
Aaron Ballman [Tue, 30 Oct 2018 20:55:18 +0000 (20:55 +0000)]
Changing the command line parameters sent to diff for this test.

On some systems, -U 1 was being interpreted as -U -1. Trying -U1 to see if that's the universally accepted approach instead.

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

6 years agoNFC: Merge KEYOBJC and KEYARC
Erik Pilkington [Tue, 30 Oct 2018 20:51:28 +0000 (20:51 +0000)]
NFC: Merge KEYOBJC and KEYARC

We used to only define ARC keywords in -fobjc-arc mode, but now that we define
them in ObjC mode, there isn't any reason to keep them seperate.

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

6 years agoRevert "[ASTImporter] Reorder fields after structure import is finished"
Davide Italiano [Tue, 30 Oct 2018 20:46:29 +0000 (20:46 +0000)]
Revert "[ASTImporter] Reorder fields after structure import is finished"

This reverts commit r345545 because it breaks some lldb tests.

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

6 years agoNFC: Remove the ObjC1/ObjC2 distinction from clang (and related projects)
Erik Pilkington [Tue, 30 Oct 2018 20:31:30 +0000 (20:31 +0000)]
NFC: Remove the ObjC1/ObjC2 distinction from clang (and related projects)

We haven't supported compiling ObjC1 for a long time (and never will again), so
there isn't any reason to keep these separate. This patch replaces
LangOpts::ObjC1 and LangOpts::ObjC2 with LangOpts::ObjC.

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

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

6 years agoSpeculatively attempt to fix a failing testbot.
Aaron Ballman [Tue, 30 Oct 2018 19:49:17 +0000 (19:49 +0000)]
Speculatively attempt to fix a failing testbot.

A testbot ( http://green.lab.llvm.org/green/job/clang-stage1-cmake-RA-incremental/54690/) was failing with a complaint about an obsolete option that wasn't present in the command line in the first place. This replaces my guess at the "obsolete option" with a different spelling that will hopefully be more acceptable to this bot without breaking other bots.

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

6 years agoSilencing a -Wunused-variable warning; NFC.
Aaron Ballman [Tue, 30 Oct 2018 19:23:06 +0000 (19:23 +0000)]
Silencing a -Wunused-variable warning; NFC.

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

6 years agoFixing some build bot failures from r345628; NFC intended.
Aaron Ballman [Tue, 30 Oct 2018 19:06:58 +0000 (19:06 +0000)]
Fixing some build bot failures from r345628; NFC intended.

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

6 years agoAdd the ability to output static analysis results to SARIF.
Aaron Ballman [Tue, 30 Oct 2018 18:55:38 +0000 (18:55 +0000)]
Add the ability to output static analysis results to SARIF.

This allows users to specify SARIF (https://github.com/oasis-tcs/sarif-spec) as the output from the clang static analyzer so that the results can be read in by other tools, such as extensions to Visual Studio and VSCode, as well as static analyzers like CodeSonar.

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

6 years ago[OPENMP] Support for mapping of the lambdas in target regions.
Alexey Bataev [Tue, 30 Oct 2018 15:50:12 +0000 (15:50 +0000)]
[OPENMP] Support for mapping of the lambdas in target regions.

Added support for mapping of lambdas in the target regions. It scans all
the captures by reference in the lambda, implicitly maps those variables
in the target region and then later reinstate the addresses of
references in lambda to the correct addresses of the captured|privatized
variables.

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

6 years ago[AST] Only store data for the NRVO candidate in ReturnStmt if needed
Bruno Ricci [Tue, 30 Oct 2018 14:40:49 +0000 (14:40 +0000)]
[AST] Only store data for the NRVO candidate in ReturnStmt if needed

Only store the NRVO candidate if needed in ReturnStmt.
A good chuck of all of the ReturnStmt have no NRVO candidate
(more than half when parsing all of Boost). For all of them
this saves one pointer. This has no impact on children().

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

Reviewed By: rsmith

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

6 years ago[AST] Only store the needed data in WhileStmt
Bruno Ricci [Tue, 30 Oct 2018 13:42:41 +0000 (13:42 +0000)]
[AST] Only store the needed data in WhileStmt

Don't store the data for the condition variable if not needed.
This cuts the size of WhileStmt by up to a pointer.
The order of the children is kept the same.

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

Reviewed By: rjmccall

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

6 years ago[clang] Move two utility functions into SourceManager
Roman Lebedev [Tue, 30 Oct 2018 12:37:16 +0000 (12:37 +0000)]
[clang] Move two utility functions into SourceManager

Summary: So we can keep that not-so-great logic in one place.

Reviewers: rsmith, aaron.ballman

Reviewed By: rsmith

Subscribers: nemanjai, kbarton, cfe-commits

Tags: #clang

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

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

6 years ago[CodeGen] Disable the machine verifier on a ThinLTO test
Francis Visoiu Mistrih [Tue, 30 Oct 2018 12:18:33 +0000 (12:18 +0000)]
[CodeGen] Disable the machine verifier on a ThinLTO test

This allows us to turn the machine verifier on by default on X86.

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

6 years agoRemove trailing space from clang/Basic/LangOptions.h
Takuto Ikuta [Tue, 30 Oct 2018 09:42:49 +0000 (09:42 +0000)]
Remove trailing space from clang/Basic/LangOptions.h

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

6 years ago[OPENMP] Fix for "error: unused variable 'CED'"
Bjorn Pettersson [Tue, 30 Oct 2018 08:49:26 +0000 (08:49 +0000)]
[OPENMP] Fix for "error: unused variable 'CED'"

Quick fix to make code compile with -Werror,-Wunused-variable.

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

6 years agoPR23833, DR2140: an lvalue-to-rvalue conversion on a glvalue of type
Richard Smith [Tue, 30 Oct 2018 02:02:49 +0000 (02:02 +0000)]
PR23833, DR2140: an lvalue-to-rvalue conversion on a glvalue of type
nullptr_t does not access memory.

We now reuse CK_NullToPointer to represent a conversion from a glvalue
of type nullptr_t to a prvalue of nullptr_t where necessary.

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

6 years ago[analyzer] Allow padding checker to traverse simple class hierarchies
Alexander Shaposhnikov [Tue, 30 Oct 2018 01:20:37 +0000 (01:20 +0000)]
[analyzer] Allow padding checker to traverse simple class hierarchies

The existing padding checker skips classes that have any base classes.
This patch allows the checker to traverse very simple cases:
classes that have no fields and have exactly one base class.
This is important mostly in the case of array declarations.

Patch by Max Bernstein!

Test plan: make check-all

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

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

6 years ago[CMake][Fuchsia] Drop the LIBCXX_HIDE_FROM_ABI_PER_TU_BY_DEFAULT
Petr Hosek [Mon, 29 Oct 2018 23:10:49 +0000 (23:10 +0000)]
[CMake][Fuchsia] Drop the LIBCXX_HIDE_FROM_ABI_PER_TU_BY_DEFAULT

Now that libc++ uses __exclude_from_explicit_instantiation__ attribute,
this is no longer needed.

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

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

6 years ago[ASTImporter] Reorder fields after structure import is finished
Aleksei Sidorin [Mon, 29 Oct 2018 21:46:18 +0000 (21:46 +0000)]
[ASTImporter] Reorder fields after structure import is finished

There are multiple reasons why field structures can be imported
in wrong order. The simplest is the ability of field initializers
and method bodies to refer fields not in order they are listed in.
Unfortunately, there is no clean solution for that currently
so I'm leaving a FIXME.

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

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

6 years ago[Driver] Include missing touch files for sanitized library paths
Petr Hosek [Mon, 29 Oct 2018 21:04:12 +0000 (21:04 +0000)]
[Driver] Include missing touch files for sanitized library paths

These were forgotten in r345537 causing test failures on Clang builders.

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

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

6 years ago[Driver] Support sanitized libraries on Fuchsia
Petr Hosek [Mon, 29 Oct 2018 20:37:52 +0000 (20:37 +0000)]
[Driver] Support sanitized libraries on Fuchsia

When using sanitizers, add <resource_dir>/<target>/lib/<sanitizer>
to the list of library paths to support using sanitized version of
runtime libraries if available.

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

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

6 years agoIn swiftcall, don't merge FP/vector types within a chunk.
John McCall [Mon, 29 Oct 2018 20:32:36 +0000 (20:32 +0000)]
In swiftcall, don't merge FP/vector types within a chunk.

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

6 years ago[OPENMP]Fix PR39372: Does not complain about loop bound variable not
Alexey Bataev [Mon, 29 Oct 2018 20:17:42 +0000 (20:17 +0000)]
[OPENMP]Fix PR39372: Does not complain about loop bound variable not
being shared.

According to the standard, the variables with unspecified data-sharing
attributes in presence of `default(none)` clause must be reported to
users. Compiler did not generate error reports for the variables used in
other OpenMP regions. Patch fixes this.

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

6 years ago[analyzer][NFC] Refactor PlistDiagnostics to use a class instead of passing 9 paramet...
Kristof Umann [Mon, 29 Oct 2018 20:06:30 +0000 (20:06 +0000)]
[analyzer][NFC] Refactor PlistDiagnostics to use a class instead of passing 9 parameters around

This has been a long time coming. Note the usage of AnalyzerOptions: I'll need
it for D52742, and added it in rC343620. The main motivation for this was that
I'll need to add yet another parameter to every single function, and some
functions would reach their 10th parameter with that change.

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

6 years ago[OpenMP] Fix condition.
Gheorghe-Teodor Bercea [Mon, 29 Oct 2018 19:44:25 +0000 (19:44 +0000)]
[OpenMP] Fix condition.

Summary: Iteration variable must be strictly less than the number of iterations. This fixes a bug introduced by previous patch D53448.

Reviewers: ABataev, caomhin

Reviewed By: ABataev

Subscribers: guansong, cfe-commits

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

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

6 years agoRevert "Revert "Support for groups of attributes in #pragma clang attribute""
Erik Pilkington [Mon, 29 Oct 2018 17:38:42 +0000 (17:38 +0000)]
Revert "Revert "Support for groups of attributes in #pragma clang attribute""

This reverts commit r345487, which reverted r345486. I think the crashes were
caused by an OOM on the builder, trying again to confirm...

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

6 years ago[AST] Only store the needed data in SwitchStmt
Bruno Ricci [Mon, 29 Oct 2018 16:12:37 +0000 (16:12 +0000)]
[AST] Only store the needed data in SwitchStmt

Don't store the data for the init statement and condition variable
if not needed. This cuts the size of SwitchStmt by up to 2 pointers.
The order of the children is intentionally kept the same.

Also use the newly available space in the bit-fields of Stmt
to store the bit representing whether all enums have been covered
instead of using a PointerIntPair.

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

Reviewed By: rjmccall

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

6 years ago[OpenMP][NVPTX] Use single loops when generating code for distribute parallel for
Gheorghe-Teodor Bercea [Mon, 29 Oct 2018 15:45:47 +0000 (15:45 +0000)]
[OpenMP][NVPTX] Use single loops when generating code for distribute parallel for

Summary: This patch adds a new code generation path for bound sharing directives containing distribute parallel for. The new code generation scheme applies to chunked schedules on distribute and parallel for directives. The scheme simplifies the code that is being generated by eliminating the need for an outer for loop over chunks for both distribute and parallel for directives. In the case of distribute it applies to any sized chunk while in the parallel for case it only applies when chunk size is 1.

Reviewers: ABataev, caomhin

Reviewed By: ABataev

Subscribers: jholewinski, guansong, cfe-commits

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

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

6 years ago[OpenMP][NVPTX] Enable default scheduling for parallel for in non-SPMD cases.
Gheorghe-Teodor Bercea [Mon, 29 Oct 2018 15:23:23 +0000 (15:23 +0000)]
[OpenMP][NVPTX] Enable default scheduling for parallel for in non-SPMD cases.

Summary: This patch enables the choosing of the default schedule for parallel for loops even in non-SPMD cases.

Reviewers: ABataev, caomhin

Reviewed By: ABataev

Subscribers: jholewinski, guansong, cfe-commits

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

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

6 years ago[AST] Check that GNU range case statements are correctly imported.
Bruno Ricci [Mon, 29 Oct 2018 15:04:19 +0000 (15:04 +0000)]
[AST] Check that GNU range case statements are correctly imported.

The test for case statements did not cover GNU range case statements.

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

Reviewed By: rjmccall

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

6 years ago[OPENMP] Do not capture private loop counters.
Alexey Bataev [Mon, 29 Oct 2018 15:01:58 +0000 (15:01 +0000)]
[OPENMP] Do not capture private loop counters.

If the loop counter is not declared in the context of the loop and it is
private, such loop counters should not be captured in the outlined
regions.

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

6 years agoAdd the isStaticLocal() AST matcher for matching on local static variables.
Aaron Ballman [Mon, 29 Oct 2018 13:47:56 +0000 (13:47 +0000)]
Add the isStaticLocal() AST matcher for matching on local static variables.

Patch by Joe Ranieri.

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

6 years ago[OpenCL] Fix serialization of OpenCLExtensionDecls
Andrew Savonichev [Mon, 29 Oct 2018 11:14:01 +0000 (11:14 +0000)]
[OpenCL] Fix serialization of OpenCLExtensionDecls

Summary:
I recently discovered that adding the following code into `opencl-c.h` causes
failure of `test/Headers/opencl-c-header.cl`:
```
#pragma OPENCL EXTENSION cl_my_ext : begin
void cl_my_ext_foobarbaz();
#pragma OPENCL EXTENSIOn cl_my_ext : end
```

Clang crashes at the assertion is `ASTReader::getGlobalSubmoduleID()`:
```
assert(I != M.SubmoduleRemap.end() && "Invalid index into submodule index remap");
```

The root cause of the problem that to deserialize `OPENCL_EXTENSION_DECLS`
section `ASTReader` needs to deserialize a Decl contained in it. In turn,
deserializing a Decl requires information about whether this declaration is
part of a (sub)module, but this information is not read yet because it is
located further in a module file.

Reviewers: Anastasia, yaxunl, JDevlieghere

Reviewed By: Anastasia

Subscribers: sidorovd, cfe-commits, asavonic

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

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

6 years ago[ASTImporter] Import overrides before importing the rest of the chain
Gabor Marton [Mon, 29 Oct 2018 10:18:28 +0000 (10:18 +0000)]
[ASTImporter] Import overrides before importing the rest of the chain

Summary:
During method import we check for structural eq of two methods.
In the structural eq check we check for their isVirtual() flag. That
flag, however, may depend on the number of overrides. Before this
change we imported the overrides *after* we had imported the rest of the
redecl chain.  So, during the import of another decl from the chain
IsVirtual() gave false result.

Writing tests for this is not really possible, because there is no way
to remove an overridden method via the AST API.
(We should access the private ASTContext::OverriddenMethods container.)
Also, we should do the remove in the middle of the import process.

Reviewers: a_sidorin, a.sidorin

Subscribers: rnkovacs, dkrupp, Szelethus, cfe-commits

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

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

6 years agoRevert "Support for groups of attributes in #pragma clang attribute"
Erik Pilkington [Mon, 29 Oct 2018 03:24:16 +0000 (03:24 +0000)]
Revert "Support for groups of attributes in #pragma clang attribute"

This reverts commit r345486.

Looks like it causes some old versions of GCC to crash, I'll see if I can
work around it and recommit...

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

6 years agoSupport for groups of attributes in #pragma clang attribute
Erik Pilkington [Mon, 29 Oct 2018 02:29:21 +0000 (02:29 +0000)]
Support for groups of attributes in #pragma clang attribute

This commit enables pushing an empty #pragma clang attribute push, then adding
multiple attributes to it, then popping them all with #pragma clang attribute
pop, just like #pragma clang diagnostic. We still support the current way of
adding these, #pragma clang attribute push(__attribute__((...))), by treating it
like a combined push/attribute. This is needed to create macros like:

DO_SOMETHING_BEGIN(attr1, attr2, attr3)
// ...
DO_SOMETHING_END

rdar://45496947

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

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

6 years agoAST: extend MS decoration handling for extended vectors
Saleem Abdulrasool [Sun, 28 Oct 2018 18:05:20 +0000 (18:05 +0000)]
AST: extend MS decoration handling for extended vectors

We correctly handled extended vectors of non-floating point types.
However, we have the Intel style builtins which MSVC also supports which
do overlap in sizes with the floating point extended vectors.  This
would result in overloading of floating point extended vector types
which matched sizes (e.g. <3 x float> would be backed by a <4 x float>
and thus match sizes) to be mangled similarly.  Extended vectors are a
clang extension which live outside of the builtins, so mangle them all
similarly.  This change just extends the current scheme to treat
floating point types similar to the way that we treat other types
currently.

This now allows the swift runtime to be built for Windows again.

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

6 years ago[AST] Fix an use-of-uninitialized bug introduced in CaseStmt
Bruno Ricci [Sun, 28 Oct 2018 14:14:06 +0000 (14:14 +0000)]
[AST] Fix an use-of-uninitialized bug introduced in CaseStmt

SwitchCaseBits.CaseStmtIsGNURange needs to be initialized first.

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

6 years ago[AST] Don't store data for GNU range case statement if not needed
Bruno Ricci [Sun, 28 Oct 2018 12:30:53 +0000 (12:30 +0000)]
[AST] Don't store data for GNU range case statement if not needed

Don't store the data for case statements of the form LHS ... RHS if not
needed. This cuts the size of CaseStmt by 1 pointer + 1 SourceLocation in
the common case.

Also use the newly available space in the bit-fields of Stmt to store the
keyword location of SwitchCase and move the small accessor
SwitchCase::getSubStmt to the header.

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

Reviewed By: rjmccall

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

6 years agoReapply Pass the nopie flag to the linker when linking with -pg.
Brad Smith [Sun, 28 Oct 2018 03:30:18 +0000 (03:30 +0000)]
Reapply Pass the nopie flag to the linker when linking with -pg.

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

6 years ago[AST] Only store the needed data in IfStmt
Bruno Ricci [Sat, 27 Oct 2018 21:12:20 +0000 (21:12 +0000)]
[AST] Only store the needed data in IfStmt

Only store the needed data in IfStmt. This cuts the size of IfStmt
by up to 3 pointers + 1 SourceLocation. The order of the children
is intentionally kept the same even though it would be more
convenient to put the optional trailing objects last. Additionally
use the newly available space in the bit-fields of Stmt to store
the location of the "if".

The result of this is that for the common case of an
if statement of the form:

if (some_cond)
  some_statement

the size of IfStmt is brought down to 8 bytes + 2 pointers,
instead of 8 bytes + 5 pointers + 2 SourceLocation.

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

Reviewed By: rjmccall

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

6 years ago[AST] Refactor PredefinedExpr
Bruno Ricci [Sat, 27 Oct 2018 19:21:19 +0000 (19:21 +0000)]
[AST] Refactor PredefinedExpr

Make the following changes to PredefinedExpr:

1. Move PredefinedExpr below StringLiteral so that it can use its definition.
2. Rename IdentType to IdentKind to be more in line with clang's conventions,
   and propagate the change to its users.
3. Move the location and the IdentKind into the newly available space of
   the bit-fields of Stmt.
4. Only store the function name when needed. When parsing all of Boost,
   of the 1357 PredefinedExpr 919 have no function name.

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

Reviewed By: rjmccall

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

6 years ago[AST] Widen the bit-fields of Stmt to 8 bytes.
Bruno Ricci [Sat, 27 Oct 2018 18:43:27 +0000 (18:43 +0000)]
[AST] Widen the bit-fields of Stmt to 8 bytes.

Although some classes are using the tail padding of Stmt, most of
them are not. In particular the expression classes are not using it
since there is Expr in between, and Expr contains a single pointer.

This patch widen the bit-fields to Stmt to 8 bytes and move some
data from NullStmt, CompoundStmt, LabelStmt, AttributedStmt, SwitchStmt,
WhileStmt, DoStmt, ForStmt, GotoStmt, ContinueStmt, BreakStmt
and ReturnStmt to the newly available space.

In itself this patch do not achieve much but I plan to go through each of
the classes in the statement/expression hierarchy and use this newly
available space. A quick estimation gives me that this should shrink the
size of the statement/expression hierarchy by >10% when parsing all of Boost.

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

Reviewed By: rjmccall

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

6 years agoAST: fix a typo in a comment (NFC)
Saleem Abdulrasool [Sat, 27 Oct 2018 06:12:52 +0000 (06:12 +0000)]
AST: fix a typo in a comment (NFC)

Fix a typo spotted by Akira!  NFC

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

6 years agoRevert r345170 [along with its llvm counterpart r345169] as it makes Halide builds...
Alina Sbirlea [Sat, 27 Oct 2018 04:51:09 +0000 (04:51 +0000)]
Revert r345170 [along with its llvm counterpart r345169] as it makes Halide builds timeout.

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

6 years agoRevert "Pass the nopie flag to the linker when linking with -pg." until
Brad Smith [Sat, 27 Oct 2018 01:14:22 +0000 (01:14 +0000)]
Revert "Pass the nopie flag to the linker when linking with -pg." until
one of the tests can be fixed on !OpenBSD hosts.

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

6 years agoUpdate the other test.
Brad Smith [Sat, 27 Oct 2018 00:46:12 +0000 (00:46 +0000)]
Update the other test.

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

6 years agoPass the nopie flag to the linker when linking with -pg.
Brad Smith [Sat, 27 Oct 2018 00:23:28 +0000 (00:23 +0000)]
Pass the nopie flag to the linker when linking with -pg.

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

6 years agoRevert "[PassManager/Sanitizer] Enable usage of ported AddressSanitizer passes with...
Leonard Chan [Fri, 26 Oct 2018 22:51:51 +0000 (22:51 +0000)]
Revert "[PassManager/Sanitizer] Enable usage of ported AddressSanitizer passes with -fsanitize=address"

This reverts commit 8d6af840396f2da2e4ed6aab669214ae25443204 and commit
b78d19c287b6e4a9abc9fb0545de9a3106d38d3d which causes slower build times
by initializing the AddressSanitizer on every function run.

The corresponding revisions are https://reviews.llvm.org/D52814 and
https://reviews.llvm.org/D52739.

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

6 years ago[VFS] Add property 'fallthrough' that controls fallback to real file system.
Volodymyr Sapsai [Fri, 26 Oct 2018 22:16:24 +0000 (22:16 +0000)]
[VFS] Add property 'fallthrough' that controls fallback to real file system.

Default property value 'true' preserves current behavior. Value 'false' can be
used to create VFS "root", file system that gives better control over which
files compiler can use during compilation as there are no unpredictable
accesses to real file system.

Non-fallthrough use case changes how we treat multiple VFS overlay
files. Instead of all of them being at the same level just above a real
file system, now they are nested and subsequent overlays can refer to
files in previous overlays.

Change is done both in LLVM and Clang, corresponding LLVM commit is r345431.

rdar://problem/39465552

Reviewers: bruno, benlangmuir

Reviewed By: bruno

Subscribers: dexonsmith, cfe-commits, hiraditya

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

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

6 years agoFix test expectation to match reality.
Richard Smith [Fri, 26 Oct 2018 19:42:43 +0000 (19:42 +0000)]
Fix test expectation to match reality.

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

6 years agoFix typo.
Richard Smith [Fri, 26 Oct 2018 19:35:39 +0000 (19:35 +0000)]
Fix typo.

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

6 years agoPR26547: alignof should return ABI alignment, not preferred alignment
Richard Smith [Fri, 26 Oct 2018 19:26:45 +0000 (19:26 +0000)]
PR26547: alignof should return ABI alignment, not preferred alignment

Summary:
- Add `UETT_PreferredAlignOf` to account for the difference between `__alignof` and `alignof`
- `AlignOfType` now returns ABI alignment instead of preferred alignment iff clang-abi-compat > 7, and one uses _Alignof or alignof

Patch by Nicole Mazzuca!

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

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

6 years ago[NFC][OpenMP] Add new test for parallel for code generation.
Gheorghe-Teodor Bercea [Fri, 26 Oct 2018 18:59:52 +0000 (18:59 +0000)]
[NFC][OpenMP] Add new test for parallel for code generation.

Summary:
This is a simple test of the parallel for code generation. It will be used to showcase the change introduced by patch D53443.

Reviewers: ABataev, caomhin

Reviewed By: ABataev

Subscribers: guansong, cfe-commits

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

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

6 years ago[Fixed Point Arithmetic] Refactor fixed point casts
Bjorn Pettersson [Fri, 26 Oct 2018 16:12:12 +0000 (16:12 +0000)]
[Fixed Point Arithmetic] Refactor fixed point casts

Summary:
- Added names for some emitted values (such as "tobool" for
  the result of a cast to boolean).
- Replaced explicit IRBuilder request for doing sext/zext/trunc
  by using CreateIntCast instead.
- Simplify code for emitting satuation into one if-statement
  for clamping to max, and one if-statement for clamping to min.

Reviewers: leonardchan, ebevhan

Reviewed By: leonardchan

Subscribers: cfe-commits

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

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

6 years agoRevert r345330 "Add MS ABI mangling for operator<=>."
Hans Wennborg [Fri, 26 Oct 2018 13:05:45 +0000 (13:05 +0000)]
Revert r345330 "Add MS ABI mangling for operator<=>."

The generated MS manglings differ between 32- and 64-bit, and the test only
expects the latter. See also the commit email thread.

> Thanks to Cameron DaCamara at Microsoft for letting us know what their
> chosen mangling is here!

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

6 years agoRevert "Reapply: [Driver] Use forward slashes in most linker arguments"
Martin Storsjo [Fri, 26 Oct 2018 08:33:29 +0000 (08:33 +0000)]
Revert "Reapply: [Driver] Use forward slashes in most linker arguments"

This reverts commit r345370, as it uncovered even more issues in
tests with partial/inconsistent path normalization:
http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win/builds/13562
http://lab.llvm.org:8011/builders/clang-x64-windows-msvc/builds/886
http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/20994

In particular, these tests seem to have failed:
    Clang :: CodeGen/thinlto-diagnostic-handler-remarks-with-hotness.ll
    Clang :: CodeGen/thinlto-multi-module.ll
    Clang :: Driver/cuda-external-tools.cu
    Clang :: Driver/cuda-options.cu
    Clang :: Driver/hip-toolchain-no-rdc.hip
    Clang :: Driver/hip-toolchain-rdc.hip
    Clang :: Driver/openmp-offload-gpu.c

At least the Driver tests could potentially be fixed by extending
the path normalization to even more places, but the issues with the
CodeGen tests are still unknown.

In addition, a number of other tests seem to have been broken in
other clang dependent tools such as clang-tidy and clangd.

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

6 years agoUpdate the example of BS_Stroustrup to match what is done by clang-format
Sylvestre Ledru [Fri, 26 Oct 2018 07:25:37 +0000 (07:25 +0000)]
Update the example of BS_Stroustrup to match what is done by clang-format

Summary:
reported here https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=911561

clang-format-7 -style="{BreakBeforeBraces: Stroustrup}" wasn't doing
the same as the doc

Reviewers: krasimir

Reviewed By: krasimir

Subscribers: cfe-commits

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

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

6 years agoReapply: [Driver] Use forward slashes in most linker arguments
Martin Storsjo [Fri, 26 Oct 2018 07:01:59 +0000 (07:01 +0000)]
Reapply: [Driver] Use forward slashes in most linker arguments

libtool inspects the output of $CC -v to detect what object files and
libraries are linked in by default. When clang is built as a native
windows executable, all paths are formatted with backslashes, and
the backslashes cause each argument to be enclosed in quotes. The
backslashes and quotes break further processing within libtool (which
is implemented in shell script, running in e.g. msys) pretty badly.

Between unix style pathes (that only work in tools that are linked
to the msys runtime, essentially the same as cygwin) and proper windows
style paths (with backslashes, that can easily break shell scripts
and msys environments), the best compromise is to use windows style
paths (starting with e.g. c:) but with forward slashes, which both
msys based tools, shell scripts and native windows executables can
cope with. This incidentally turns out to be the form of paths that
GCC prints out when run with -v on windows as well.

This change potentially makes the output from clang -v a bit more
inconsistent, but it is isn't necessarily very consistent to begin with.

Compared to the previous attempt in SVN r345004, this now does
the same transformation on more paths, hopefully on the right set
of paths so that all tests pass (previously some tests failed, where
path fragments that were required to be identical turned out to
use different path separators in different places). This now also
is done only for non-windows, or cygwin/mingw targets, to preserve
all backslashes for MSVC cases (where the paths can end up e.g. embedded
into PDB files. (The transformation function itself,
llvm::sys::path::convert_to_slash only has an effect when run on windows.)

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

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

6 years agoPR31978: Don't crash if CodeGen sees a top-level BindingDecl.
Richard Smith [Fri, 26 Oct 2018 03:21:20 +0000 (03:21 +0000)]
PR31978: Don't crash if CodeGen sees a top-level BindingDecl.

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

6 years agoCodeGen: correct the case for swift 4.2, 5.0
Saleem Abdulrasool [Fri, 26 Oct 2018 03:16:16 +0000 (03:16 +0000)]
CodeGen: correct the case for swift 4.2, 5.0

This corrects the leader for the swift names.  The encoding for 4.2 and
5.0 differ by a single bit on the second character and were swapped.

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

6 years ago[AArch64] Support Windows stack probe command-line arguments.
Eli Friedman [Fri, 26 Oct 2018 01:31:57 +0000 (01:31 +0000)]
[AArch64] Support Windows stack probe command-line arguments.

Adds support for -mno-stack-arg-probe and -mstack-probe-size.

(Not really happy copy-pasting code, but that's what we do for all the
other Windows targets.)

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

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

6 years ago[AArch64] Implement FP16FML intrinsics
Bryan Chan [Thu, 25 Oct 2018 23:47:00 +0000 (23:47 +0000)]
[AArch64] Implement FP16FML intrinsics

Generate the FP16FML intrinsics into arm_neon.h (AArch64 only for now).
Add two new type modifiers to NeonEmitter to handle the new prototypes.
Define __ARM_FEATURE_FP16FML when +fp16fml is enabled and guard the
intrinsics with the macro in arm_neon.h.

Based on a patch by Gao Yiling.

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

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

6 years ago[analyzer] Fix a bug in "collapsed" graph viewer
George Karpenkov [Thu, 25 Oct 2018 23:38:58 +0000 (23:38 +0000)]
[analyzer] Fix a bug in "collapsed" graph viewer

Nodes which have only one predecessor and only one successor can not
always be hidden, even if all states are the same.
An additional condition is needed: the predecessor may have only one successor.
This can be seen on this example:

```
  A
 / \
B   C
 \ /
  D
```

Nodes B and C can not be hidden even if all nodes in the graph have the
same state.

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

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

6 years ago[analyzer] [RetainCountChecker] Do not invalidate references passed to constructors...
George Karpenkov [Thu, 25 Oct 2018 23:38:41 +0000 (23:38 +0000)]
[analyzer] [RetainCountChecker] Do not invalidate references passed to constructors and operators

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

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

6 years ago[analyzer] Remove custom rule for OSIterator in RetainCountChecker
George Karpenkov [Thu, 25 Oct 2018 23:38:24 +0000 (23:38 +0000)]
[analyzer] Remove custom rule for OSIterator in RetainCountChecker

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

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

6 years ago[analyzer] Correct modelling of OSDynamicCast: eagerly state split
George Karpenkov [Thu, 25 Oct 2018 23:38:07 +0000 (23:38 +0000)]
[analyzer] Correct modelling of OSDynamicCast: eagerly state split

Previously, OSDynamicCast was modeled as an identity.

This is not correct: the output of OSDynamicCast may be zero even if the
input was not zero (if the class is not of desired type), and thus the
modeling led to false positives.

Instead, we are doing eager state split:
in one branch, the returned value is identical to the input parameter,
and in the other branch, the returned value is zero.

This patch required a substantial refactoring of canEval infrastructure,
as now it can return different function summaries, and not just true/false.

rdar://45497400

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

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

6 years agoAdd MS ABI mangling for operator<=>.
Richard Smith [Thu, 25 Oct 2018 22:51:16 +0000 (22:51 +0000)]
Add MS ABI mangling for operator<=>.

Thanks to Cameron DaCamara at Microsoft for letting us know what their
chosen mangling is here!

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

6 years agoAvoid std::map&vector in hexagon builtin code to save code size
Reid Kleckner [Thu, 25 Oct 2018 22:37:30 +0000 (22:37 +0000)]
Avoid std::map&vector in hexagon builtin code to save code size

Constructing a global std::map requires clang to generate a linear
amount of code to construct the initializer list if the elements are not
constexpr-constructible. std::vector is not constexpr-constructible, so
this code pattern was generating large amounts of code.

Also, because of PR38829, LLVM is pathologically slow on large basic
blocks, and this causes slow compilation. This works around the bug and
reduces code size.

SemaChecking.cpp -debug-info-kind=limited:
        time      objsize
before: 1m45.023s 9.8M
after:  0m25.205s 6.9M

So, a 42% obj size reduction and 3.2x speedup.

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

6 years agoAvoid STMT_ and DECL_ bitcodes overlapping.
Richard Smith [Thu, 25 Oct 2018 22:35:16 +0000 (22:35 +0000)]
Avoid STMT_ and DECL_ bitcodes overlapping.

This doesn't appear to matter for deserialization purposes, because we
always know what kind of entity (declaration or statement/expression)
we're trying to load, but it makes the llvm-bcanalyzer output a lot less
mysterious.

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

6 years ago[C++17] Reject shadowing of capture by parameter in lambda
Nicolas Lesser [Thu, 25 Oct 2018 20:15:03 +0000 (20:15 +0000)]
[C++17] Reject shadowing of capture by parameter in lambda

Summary:
This change rejects the shadowing of a capture by a parameter in lambdas in C++17.

```
int main() {
  int a;
  auto f = [a](int a) { return a; };
}
```

results in:

```
main.cpp:3:20: error: a lambda parameter cannot shadow an explicitly captured entity
  auto f = [a](int a) { return a; };
                   ^
main.cpp:3:13: note: variable a is explicitly captured here
  auto f = [a](int a) { return a; };
            ^
```

Reviewers: rsmith

Reviewed By: rsmith

Subscribers: lebedev.ri, erik.pilkington, cfe-commits

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

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

6 years agoRevert "[SemaCXX] Unconfuse Clang when std::align_val_t is unscoped in C++03"
Eric Fiselier [Thu, 25 Oct 2018 19:50:43 +0000 (19:50 +0000)]
Revert "[SemaCXX] Unconfuse Clang when std::align_val_t is unscoped in C++03"

This reverts commit b5d8d0de744d2c212bdb17d5c5fd4447dd14dbd2.

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

6 years agoRebase defect report list.
Nicolas Lesser [Thu, 25 Oct 2018 19:27:57 +0000 (19:27 +0000)]
Rebase defect report list.

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

6 years agoChange keep-static-consts to work on static storage duration, not
Erich Keane [Thu, 25 Oct 2018 19:13:46 +0000 (19:13 +0000)]
Change keep-static-consts to work on static storage duration, not
storage class.

To be more in line with what GCC does, switch the condition to be based
on the Static Storage duration instead of the storage class.

Change-Id: I8e959d762433cda48855099353bf3c950b9d54b8

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

6 years ago[WebAssembly] Bitselect and min/max builtins
Thomas Lively [Thu, 25 Oct 2018 19:11:41 +0000 (19:11 +0000)]
[WebAssembly] Bitselect and min/max builtins

Reviewers: aheejin, dschuff

Subscribers: sbc100, jgravelle-google, sunfish, cfe-commits

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

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

6 years ago[WebAssembly] Lower to target-independent saturating add
Thomas Lively [Thu, 25 Oct 2018 19:06:15 +0000 (19:06 +0000)]
[WebAssembly] Lower to target-independent saturating add

Summary: Goes along with D53721.

Reviewers: aheejin, dschuff

Subscribers: sbc100, jgravelle-google, sunfish, cfe-commits

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

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

6 years agoImplement Function Multiversioning for Non-ELF Systems.
Erich Keane [Thu, 25 Oct 2018 18:57:19 +0000 (18:57 +0000)]
Implement Function Multiversioning for Non-ELF Systems.

Similar to how ICC handles CPU-Dispatch on Windows, this patch uses the
resolver function directly to forward the call to the proper function.
This is not nearly as efficient as IFuncs of course, but is still quite
useful for large functions specifically developed for certain
processors.

This is unfortunately still limited to x86, since it depends on
__builtin_cpu_supports and __builtin_cpu_is, which are x86 builtins.

The naming for the resolver/forwarding function for cpu-dispatch was
taken from ICC's implementation, which uses the unmodified name for this
(no mangling additions).  This is possible, since cpu-dispatch uses '.A'
for the 'default' version.

In 'target' multiversioning, this function keeps the '.resolver'
extension in order to keep the default function keeping the default
mangling.

Change-Id: I4731555a39be26c7ad59a2d8fda6fa1a50f73284

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

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

6 years ago[SemaCXX] Unconfuse Clang when std::align_val_t is unscoped in C++03
Eric Fiselier [Thu, 25 Oct 2018 18:16:16 +0000 (18:16 +0000)]
[SemaCXX] Unconfuse Clang when std::align_val_t is unscoped in C++03

Summary:
When -faligned-allocation is specified in C++03 libc++ defines std::align_val_t as an unscoped enumeration type (because Clang didn't provide scoped enumerations as an extension until 8.0).
Unfortunately Clang confuses the `align_val_t` overloads of delete with the sized deallocation overloads which aren't enabled. This caused Clang to call the aligned deallocation function as if it were the sized deallocation overload.

For example: https://godbolt.org/z/xXJELh

This patch fixes the confusion.

Reviewers: rsmith, EricWF

Reviewed By: EricWF

Subscribers: cfe-commits

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

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

6 years agoCodeGen: alter CFConstantString class name for swift 5.0
Saleem Abdulrasool [Thu, 25 Oct 2018 17:52:13 +0000 (17:52 +0000)]
CodeGen: alter CFConstantString class name for swift 5.0

Swift 5.0 has changed the name decoration for swift symbols, using a 'S' sigil
rather than 's' as in 4.2.  Adopt the new convention.

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

6 years ago[analyzer] Move canReasonAbout from Z3ConstraintManager to SMTConstraintManager
Mikhail R. Gadelha [Thu, 25 Oct 2018 17:27:42 +0000 (17:27 +0000)]
[analyzer] Move canReasonAbout from Z3ConstraintManager to SMTConstraintManager

Summary:
This patch moves the last method in `Z3ConstraintManager` to `SMTConstraintManager`: `canReasonAbout()`.

The `canReasonAbout()` method checks if a given `SVal` can be encoded in SMT. I've added a new method to the SMT API to return true if a solver can encode floating-point arithmetics and it was enough to make `canReasonAbout()` solver independent.

As an annoying side-effect, `Z3ConstraintManager` is pretty empty now and only (1) creates the Z3 solver object by calling `CreateZ3Solver()` and (2) instantiates `SMTConstraintManager`. Maybe we can get rid of this class altogether in the future: a `CreateSMTConstraintManager()` method that does (1) and (2) and returns the constraint manager object?

Reviewers: george.karpenkov, NoQ

Reviewed By: george.karpenkov

Subscribers: mehdi_amini, xazax.hun, szepet, a.sidorin, dexonsmith, Szelethus, donat.nagy, dkrupp

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

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

6 years ago[analyzer] Fixed bitvector from model always being unsigned
Mikhail R. Gadelha [Thu, 25 Oct 2018 17:27:36 +0000 (17:27 +0000)]
[analyzer] Fixed bitvector from model always being unsigned

Summary:
Getting an `APSInt` from the model always returned an unsigned integer because of the unused parameter.

This was not breaking any test case because no code relies on the actual value of the integer returned here, but rather it is only used to check if a symbol has more than one solution in `getSymVal`.

Reviewers: NoQ, george.karpenkov

Reviewed By: george.karpenkov

Subscribers: xazax.hun, szepet, a.sidorin, Szelethus, donat.nagy, dkrupp

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

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

6 years ago[OPENMP]Fix PR39422: variables are not firstprivatized in task context.
Alexey Bataev [Thu, 25 Oct 2018 15:35:27 +0000 (15:35 +0000)]
[OPENMP]Fix PR39422: variables are not firstprivatized in task context.

According to the OpenMP standard, In a task generating construct, if no
default clause is present, a variable for which the data-sharing
attribute is not determined by the rules above is firstprivatized.
Compiler tries to implement this, but if the variable is not directly
used in the task context, this variable may not be firstprivatized.
Patch fixes this problem.

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

6 years ago[AArch64] Branch Protection and Return Address Signing B Key Support
Luke Cheeseman [Thu, 25 Oct 2018 15:23:49 +0000 (15:23 +0000)]
[AArch64] Branch Protection and Return Address Signing B Key Support

- Add support for -mbranch-protection=<type>[+<type>]* where
  - <type> ::= [standard, none, bti, pac-ret[+b-key,+leaf]*]
- The protection emits relevant function attributes
  - sign-return-address=<scope>
  - sign-return-address-key=<key>
  - branch-protection

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

6 years agoupdate the clang doc about contributions
Sylvestre Ledru [Thu, 25 Oct 2018 14:19:06 +0000 (14:19 +0000)]
update the clang doc about contributions

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

6 years ago[ms] Prevent explicit constructor name lookup if scope is missing
Will Wilson [Thu, 25 Oct 2018 11:45:32 +0000 (11:45 +0000)]
[ms] Prevent explicit constructor name lookup if scope is missing

MicrosoftExt allows explicit constructor calls. Prevent lookup of constructor name unless the name has explicit scope.
This avoids a compile-time crash due to confusing a member access for a constructor name.

Test case included. All tests pass.

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

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

6 years ago[clang-format] Break before next parameter after a formatted multiline raw string...
Krasimir Georgiev [Thu, 25 Oct 2018 07:39:30 +0000 (07:39 +0000)]
[clang-format] Break before next parameter after a formatted multiline raw string parameter

Summary:
Currently clang-format breaks before the next parameter after multiline parameters (also recursively for the parent expressions of multiline parameters). However, it fails to do so for formatted multiline raw string literals:
```
$ cat test.cc
// Examples

// Regular multiline tokens
int x = f(R"(multi
             line)", 2);
}

int y = g(h(R"(multi
              line)"), 2);

// Formatted multiline tokens
int z = f(R"pb(multi: 1  #
               line: 2)pb", 2);

int w = g(h(R"pb(multi: 1  #
                 line: 2)pb"), 2);
$ clang-format -style=google test.cc
// Examples

// Regular multiline tokens
int x = f(R"(multi
             line)",
          2);
}

int y = g(h(R"(multi
              line)"),
          2);

// Formatted multiline tokens
int z = f(R"pb(multi: 1  #
               line: 2)pb", 2);

int w = g(h(R"pb(multi: 1  #
                 line: 2)pb"), 2);
```

This patch addresses this inconsistency by forcing breaking after multiline formatted raw string literals. This requires a little tweak to the indentation chosen for the contents of a formatted raw string literal: in case when that's a parameter and not the last one, the indentation is based off of the uniform indentation of all of the parameters.

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: cfe-commits

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

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

6 years ago[CodeGen] Always emit the 'min-legal-vector-width' attribute even when the value...
Craig Topper [Thu, 25 Oct 2018 05:04:35 +0000 (05:04 +0000)]
[CodeGen] Always emit the 'min-legal-vector-width' attribute even when the value is 0.

The X86 backend will need to see the attribute to make decisions. If it isn't present the backend will have to assume large vectors may be present.

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

6 years ago[Sema] Fix -Wcomma for C89
Richard Trieu [Thu, 25 Oct 2018 01:08:00 +0000 (01:08 +0000)]
[Sema] Fix -Wcomma for C89

There is a small difference in the scope flags for C89 versus the other C/C++
dialects.  This change ensures that the -Wcomma warning won't be duplicated or
issued in the wrong location.  Also, the test case is refactored into C and C++
parts, with the C++ parts guarded by a #ifdef to allow the test to run in both
modes.

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

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

6 years agoRevert "[SemaCXX] Unconfuse Clang when std::align_val_t is unscoped in C++03"
Eric Fiselier [Wed, 24 Oct 2018 23:47:04 +0000 (23:47 +0000)]
Revert "[SemaCXX] Unconfuse Clang when std::align_val_t is unscoped in C++03"

This reverts commit 6f47cdd51341344c0e32630e19e72c94cd25f34e.

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

6 years agoDriver,CodeGen: introduce support for Swift CFString layout
Saleem Abdulrasool [Wed, 24 Oct 2018 23:28:28 +0000 (23:28 +0000)]
Driver,CodeGen: introduce support for Swift CFString layout

Add a new driver level flag `-fcf-runtime-abi=` that allows one to specify the
runtime ABI for CoreFoundation.  This controls the language interoperability.
In particular, this is relevant for generating the CFConstantString classes
(primarily through the `__builtin___CFStringMakeConstantString` builtin) which
construct a reference to the "CFObject"'s `isa` field.  This type differs
between swift 4.1 and 4.2+.

Valid values for the new option include:
  - objc [default behaviour] - enable ObjectiveC interoperability
  - swift-4.1 - enable interoperability with swift 4.1
  - swift-4.2 - enable interoperability with swift 4.2
  - swift-5.0 - enable interoperability with swift 5.0
  - swift [alias] - target the latest swift ABI

Furthermore, swift 4.2+ changed the layout for the CFString when building
CoreFoundation *without* ObjectiveC interoperability.  In such a case, a field
was added to the CFObject base type changing it from: <{ const int*, int }> to
<{ uintptr_t, uintptr_t, uint64_t }>.

In swift 5.0, the CFString type will be further adjusted to change the length
from a uint32_t on everything but BE LP64 targets to uint64_t.

Note that the default behaviour for clang remains unchanged and the new layout
must be explicitly opted into via `-fcf-runtime-abi=swift*`.

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

6 years ago[VFS] Remove 'ignore-non-existent-contents' attribute for YAML-based VFS.
Volodymyr Sapsai [Wed, 24 Oct 2018 22:39:38 +0000 (22:39 +0000)]
[VFS] Remove 'ignore-non-existent-contents' attribute for YAML-based VFS.

'ignore-non-existent-contents' stopped working after r342232 in a way
that the actual attribute value isn't used and it works as if it is
always `true`.

Common use case for VFS iteration is iterating through files in umbrella
directories for modules. Ability to detect if some VFS entries point to
non-existing files is nice but non-critical. Instead of adding back
support for `'ignore-non-existent-contents': false` I am removing the
attribute, because such scenario isn't used widely enough and stricter
checks don't provide enough value to justify the maintenance.

rdar://problem/45176119

Reviewers: bruno

Reviewed By: bruno

Subscribers: hiraditya, dexonsmith, sammccall, cfe-commits

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

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

6 years ago[SemaCXX] Unconfuse Clang when std::align_val_t is unscoped in C++03
Eric Fiselier [Wed, 24 Oct 2018 22:38:49 +0000 (22:38 +0000)]
[SemaCXX] Unconfuse Clang when std::align_val_t is unscoped in C++03

Summary:
When -faligned-allocation is specified in C++03 libc++ defines std::align_val_t as an unscoped enumeration type (because Clang didn't provide scoped enumerations as an extension until 8.0).
Unfortunately Clang confuses the `align_val_t` overloads of delete with the sized deallocation overloads which aren't enabled. This caused Clang to call the aligned deallocation function as if it were the sized deallocation overload.

For example: https://godbolt.org/z/xXJELh

This patch fixes the confusion.

Reviewers: rsmith, EricWF

Reviewed By: EricWF

Subscribers: cfe-commits

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

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

6 years agoAdd gfx909 to GPU Arch
Tim Renouf [Wed, 24 Oct 2018 21:19:02 +0000 (21:19 +0000)]
Add gfx909 to GPU Arch

Subscribers: jholewinski, cfe-commits

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

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

6 years agoAMDGPU: Handle gfx909 in AMDGPUTargetInfo::initFeatureMap
Konstantin Zhuravlyov [Wed, 24 Oct 2018 19:07:56 +0000 (19:07 +0000)]
AMDGPU: Handle gfx909 in AMDGPUTargetInfo::initFeatureMap

+ add required tests

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

6 years agoDo not always request an implicit taskgroup region inside the kmpc_taskloop function
Alexey Bataev [Wed, 24 Oct 2018 19:06:37 +0000 (19:06 +0000)]
Do not always request an implicit taskgroup region inside the kmpc_taskloop function

Summary:
For the following code:
```
    int i;
    #pragma omp taskloop
    for (i = 0; i < 100; ++i)
    {}

    #pragma omp taskloop nogroup
    for (i = 0; i < 100; ++i)
    {}
```

Clang emits the following LLVM IR:

```
 ...
  call void @__kmpc_taskgroup(%struct.ident_t* @0, i32 %0)
  %2 = call i8* @__kmpc_omp_task_alloc(%struct.ident_t* @0, i32 %0, i32 1, i64 80, i64 8, i32 (i32, i8*)* bitcast (i32 (i32, %struct.kmp_task_t_with_privates*)* @.omp_task_entry. to i32 (i32, i8*)*))
  ...
  call void @__kmpc_taskloop(%struct.ident_t* @0, i32 %0, i8* %2, i32 1, i64* %8, i64* %9, i64 %13, i32 0, i32 0, i64 0, i8* null)
  call void @__kmpc_end_taskgroup(%struct.ident_t* @0, i32 %0)

  ...
  %15 = call i8* @__kmpc_omp_task_alloc(%struct.ident_t* @0, i32 %0, i32 1, i64 80, i64 8, i32 (i32, i8*)* bitcast (i32 (i32, %struct.kmp_task_t_with_privates.1*)* @.omp_task_entry..2 to i32 (i32, i8*)*))
  ...
  call void @__kmpc_taskloop(%struct.ident_t* @0, i32 %0, i8* %15, i32 1, i64* %21, i64* %22, i64 %26, i32 0, i32 0, i64 0, i8* null)

```

The first set of instructions corresponds to the first taskloop construct. It is important to note that the implicit taskgroup region associated with the taskloop construct has been materialized in our IR:  the `__kmpc_taskloop` occurs inside a taskgroup region. Note also that this taskgroup region does not exist in our second taskloop because we are using the `nogroup` clause.

The issue here is the 4th argument of the kmpc_taskloop call, starting from the end,  is always a zero. Checking the LLVM OpenMP RT implementation, we see that this argument corresponds to the nogroup parameter:

```
void __kmpc_taskloop(ident_t *loc, int gtid, kmp_task_t *task, int if_val,
                     kmp_uint64 *lb, kmp_uint64 *ub, kmp_int64 st, int nogroup,
                     int sched, kmp_uint64 grainsize, void *task_dup);
```

So basically we always tell to the RT to do another taskgroup region. For the first taskloop, this means that we create two taskgroup regions. For the second example, it means that despite the fact we had a nogroup clause we are going to have a taskgroup region, so we unnecessary wait until all descendant tasks have been executed.

Reviewers: ABataev

Reviewed By: ABataev

Subscribers: rogfer01, cfe-commits

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

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

6 years ago[OPENMP]Fix PR39366: do not try to private field if it is not captured.
Alexey Bataev [Wed, 24 Oct 2018 18:53:12 +0000 (18:53 +0000)]
[OPENMP]Fix PR39366: do not try to private field if it is not captured.

The compiler is crashing if we trying to post-capture the fields
implicitly captured inside of the task constructs. Seems, this kind of
processing is not supported and such fields should not be
firstprivatized.

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

6 years ago[CodeGen] Update test checks missed in r345168.
Craig Topper [Wed, 24 Oct 2018 18:45:44 +0000 (18:45 +0000)]
[CodeGen] Update test checks missed in r345168.

These tests don't run unless the aarch64 target is registered and my testing had been on an x86 only build directory.

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

6 years ago[Hexagon] Flip hexagon-autohvx to be true by default
Krzysztof Parzyszek [Wed, 24 Oct 2018 17:55:18 +0000 (17:55 +0000)]
[Hexagon] Flip hexagon-autohvx to be true by default

This will allow other generators of LLVM IR to use the auto-vectorizer
without having to change that flag.

Note: on its own, this patch will disable auto-vectorization on Hexagon
in all cases, regardless of the -fvectorize flag. There is a companion
LLVM patch that together with this one forms an NFC for clang users.

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