]> granicus.if.org Git - clang/log
clang
6 years agoRevert "CodeGen: annotate ObjC ARC functions with ABI constraints"
Akira Hatanaka [Tue, 30 Jan 2018 20:19:34 +0000 (20:19 +0000)]
Revert "CodeGen: annotate ObjC ARC functions with ABI constraints"

This reverts commit r294872.

Although this patch is correct, it caused the objc_autoreleaseRValue/objc_retainAutoreleasedReturnValue

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

6 years agoRevert "[coroutines] Fix application of NRVO to Coroutine "Gro" or return object."
Eric Fiselier [Tue, 30 Jan 2018 00:32:25 +0000 (00:32 +0000)]
Revert "[coroutines] Fix application of NRVO to Coroutine "Gro" or return object."

This reverts commit r323712. It's causing some test failures on certain machines.
Not sure why, will investigate.

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

6 years ago[CUDA] Added partial support for CUDA-9.1
Artem Belevich [Tue, 30 Jan 2018 00:00:12 +0000 (00:00 +0000)]
[CUDA] Added partial support for CUDA-9.1

Clang can use CUDA-9.1 now, though new APIs (are not implemented yet.

The major change is that headers in CUDA-9.1 went through substantial
changes that started in CUDA-9.0 which required substantial changes
in the cuda compatibility headers provided by clang.

There are two major issues:
* CUDA SDK no longer provides declarations for libdevice functions.
* A lot of device-side functions have become nvcc's builtins and
  CUDA headers no longer contain their implementations.

This patch changes the way CUDA headers are handled if we compile
with CUDA 9.x. Both 9.0 and 9.1 are affected.

* Clang provides its own declarations of libdevice functions.
* For CUDA-9.x clang now provides implementation of device-side
  'standard library' functions using libdevice.

This patch should not affect compilation with CUDA-8. There may be
some observable differences for CUDA-9.0, though they are not expected
to affect functionality.

Tested: CUDA test-suite tests for all supported combinations of:
        CUDA: 7.0,7.5,8.0,9.0,9.1
        GPU: sm_20, sm_35, sm_60, sm_70

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

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

6 years ago[coroutines] Fix application of NRVO to Coroutine "Gro" or return object.
Eric Fiselier [Mon, 29 Jan 2018 23:52:57 +0000 (23:52 +0000)]
[coroutines] Fix application of NRVO to Coroutine "Gro" or return object.

Summary:
Fix NRVO for Gro variable.

Previously, we only marked the GRO declaration as an NRVO variable
when its QualType and the function return's QualType matched exactly
(using operator==). However, this was incorrect for two reasons:

1. We were marking non-class types, such as ints, as being NRVO variables.

2. We failed to  handle cases where the canonical types were the same, but the actual `QualType` objects were different. For example, if  one was represented by a typedef. (Example: https://godbolt.org/g/3UFgsL)

This patch fixes these bugs by marking the Gro variable as supporting NRVO only
when `BuildReturnStmt` marks the Gro variable as a coroutine candidate.

Reviewers: rsmith, GorNishanov, nicholas

Reviewed By: GorNishanov

Subscribers: majnemer, cfe-commits

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

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

6 years ago[analyzer] Use stable filenames in analyzer testing infrastructure
George Karpenkov [Mon, 29 Jan 2018 21:45:07 +0000 (21:45 +0000)]
[analyzer] Use stable filenames in analyzer testing infrastructure

Makes finding the right file in test results easier.

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

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

6 years ago[analyzer] [NFC] Remove unused method visitItemsInWorkList
George Karpenkov [Mon, 29 Jan 2018 21:44:49 +0000 (21:44 +0000)]
[analyzer] [NFC] Remove unused method visitItemsInWorkList

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

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

6 years ago[clang-format] Add more tests for ObjC protocol list formatting behavior
Ben Hamilton [Mon, 29 Jan 2018 20:01:49 +0000 (20:01 +0000)]
[clang-format] Add more tests for ObjC protocol list formatting behavior

Summary:
The existing unit tests in FormatTestObjC.cpp didn't fully cover
all the cases for protocol confirmance list formatting.

This extends the unit tests to more cases of protocol
conformance list formatting, especially how the behavior changes
when `BinPackParameters` changes from `true` (the default) to `false`.

Test Plan: make -j12 FormatTests && \
  ./tools/clang/unittests/Format/FormatTests --gtest_filter=FormatTestObjC.\*

Reviewers: krasimir, jolesiak, stephanemoore

Reviewed By: krasimir

Subscribers: benhamilton, klimek, cfe-commits, hokein, Wizard

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

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

6 years ago[NFC] Fixup comment with function name, actually incorrect name!
Erich Keane [Mon, 29 Jan 2018 19:33:20 +0000 (19:33 +0000)]
[NFC] Fixup comment with function name, actually incorrect name!

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

6 years ago[clang-format] Disable some text proto delimiters and functions for google style
Krasimir Georgiev [Mon, 29 Jan 2018 19:28:05 +0000 (19:28 +0000)]
[clang-format] Disable some text proto delimiters and functions for google style

Summary:
This disables some of the most commonly used text proto delimiters and functions
for google style until we resolve several style options for that style.
In particular, wheter there should be a space surrounding braces ``msg { sub { key : value } }``
and the extent of packing of submessages on a same line.

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: klimek, cfe-commits

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

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

6 years ago[clang-format] Fix bug where -dump-config failed on ObjC header
Ben Hamilton [Mon, 29 Jan 2018 17:36:43 +0000 (17:36 +0000)]
[clang-format] Fix bug where -dump-config failed on ObjC header

Summary:
`clang-format -dump-config path/to/file.h` never passed
anything for the Code parameter to clang::format::getStyle().

This meant the logic to guess Objective-C from the contents
of a .h file never worked, because LibFormat didn't have the
code to work with.

With this fix, we now correctly read in the contents of the
file if possible with -dump-config.

I had to update the lit config for test/Format/ because
the default config ignores .h files.

Test Plan: make -j12 check-clang

Reviewers: jolesiak, krasimir

Reviewed By: jolesiak, krasimir

Subscribers: Wizard, klimek, cfe-commits, djasper

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

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

6 years ago[scan-build] Add an option to skip overriding CC and CXX make vars
Jonathan Roelofs [Mon, 29 Jan 2018 16:49:34 +0000 (16:49 +0000)]
[scan-build] Add an option to skip overriding CC and CXX make vars

Autoconf and some other systems tend to add essential compilation
options to CC (e.g. -std=gnu99). When running such an auto-generated
makefile, scan-build does not need to change CC and CXX as they are
already set to use ccc-analyzer by a configure script.

Implement a new option --keep-cc as was proposed in this discussion:
http://lists.llvm.org/pipermail/cfe-dev/2013-September/031832.html

Patch by Paul Fertser!

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

6 years ago[analyzer] Fix -x language argument for C preprocessed sources
Jonathan Roelofs [Mon, 29 Jan 2018 16:37:53 +0000 (16:37 +0000)]
[analyzer] Fix -x language argument for C preprocessed sources

clang's -x option doesn't accept c-cpp-output as a language (even though
463eb6ab was merged, the driver still doesn't handle that).

This bug prevents testing C language projects when ccache is used.

Fixes #25851.

Investigation and patch by Dave Rigby.

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

6 years ago[Lexer] Support adding working directory to relative search dir for #include shorteni...
Eric Liu [Mon, 29 Jan 2018 13:21:23 +0000 (13:21 +0000)]
[Lexer] Support adding working directory to relative search dir for #include shortening in HeaderSearch.

Reviewers: bkramer

Subscribers: mgorny, hintonda, cfe-commits

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

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

6 years ago[NFC] fix trivial typos in comments
Hiroshi Inoue [Mon, 29 Jan 2018 05:15:18 +0000 (05:15 +0000)]
[NFC] fix trivial typos in comments

"to to" -> "to"

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

6 years agoChange memcpy/memove/memset to have dest and source alignment attributes.
Daniel Neilson [Sun, 28 Jan 2018 17:27:45 +0000 (17:27 +0000)]
Change memcpy/memove/memset to have dest and source alignment attributes.

Summary:
  This change is step three in the series of changes to remove alignment argument from
memcpy/memmove/memset in favour of alignment attributes. Steps:

Step 1) Remove alignment parameter and create alignment parameter attributes for
memcpy/memmove/memset. ( rL322965, rC322964, rL322963 )
Step 2) Expand the IRBuilder API to allow creation of memcpy/memmove with differing
source and dest alignments. ( rL323597 )
Step 3) Update Clang to use the new IRBuilder API.
Step 4) Update Polly to use the new IRBuilder API.
Step 5) Update LLVM passes that create memcpy/memmove calls to use the new IRBuilder API,
and those that use use MemIntrinsicInst::[get|set]Alignment() to use getDestAlignment()
and getSourceAlignment() instead.
Step 6) Remove the single-alignment IRBuilder API for memcpy/memmove, and the
MemIntrinsicInst::[get|set]Alignment() methods.

Reference
   http://lists.llvm.org/pipermail/llvm-dev/2015-August/089384.html
   http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20151109/312083.html

Reviewers: rjmccall

Subscribers: jyknight, nemanjai, nhaehnle, javed.absar, sbc100, aheejin, kbarton, fedor.sergeev, cfe-commits

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

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

6 years ago[git-clang-format] Process CUDA files
Jonas Hahnfeld [Sun, 28 Jan 2018 10:11:25 +0000 (10:11 +0000)]
[git-clang-format] Process CUDA files

Clang supports compiling CUDA source files for some time,
format them by default as well.

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

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

6 years agoAttempt to make the PS4 build bot happy.
Gabor Horvath [Sat, 27 Jan 2018 16:38:56 +0000 (16:38 +0000)]
Attempt to make the PS4 build bot happy.

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

6 years ago[ASTImporter] Add support to import some AST nodes:
Gabor Horvath [Sat, 27 Jan 2018 16:11:45 +0000 (16:11 +0000)]
[ASTImporter] Add support to import some AST nodes:

* CXXOperatorCallExpr
* SizeOfPackExpr
* DependentTemplateSpecializationType
* DependentSizedArray
* CXXTypeidExpr
* Fix importing CXXTemporaryObjectExpr

Some of the changes are based on
https://github.com/haoNoQ/clang/blob/summary-ipa-draft/lib/AST/ASTImporter.cpp

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

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

6 years ago[CodeGen] Use the non-virtual alignment when emitting the base
Akira Hatanaka [Sat, 27 Jan 2018 00:34:09 +0000 (00:34 +0000)]
[CodeGen] Use the non-virtual alignment when emitting the base
constructor.

Previously, clang would emit an over-aligned (16-byte) store to
initialize B::x in B's base constructor when compiling the following
code:

struct A {
  __attribute__((aligned(16))) double data1;
};

struct B : public virtual A {
  B() : x(123) {}
  double a;
  int x;
};

struct C : public virtual B {};

void test() { B b; C c; }

This was happening because the code in IRGen that does member
initialization was using the alignment of a complete object instead of
the non-virtual alignment.

This commit fixes the bug.

rdar://problem/36382481

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

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

6 years agoAlways allow "#pragma region".
Matt Davis [Sat, 27 Jan 2018 00:25:29 +0000 (00:25 +0000)]
Always allow "#pragma region".

Summary:
Both MS and PS4 targets are capable of recognizing the
existence of:  #pragma region, #pragma endregion.

Since this pragma is only a hint for certain editors, and has no logic,
it seems helpful to permit this pragma in all cases, not just MS compatibility mode.

Reviewers: rnk, rsmith, majnemer

Reviewed By: majnemer

Subscribers: Quuxplusone, probinson, majnemer, cfe-commits

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

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

6 years agoTry to unbreak 32 bit builds after r323528.
Benjamin Kramer [Fri, 26 Jan 2018 20:01:13 +0000 (20:01 +0000)]
Try to unbreak 32 bit builds after r323528.

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

6 years ago[X86] Add 'rdrnd' feature to silvermont to match recent gcc bug fix.
Craig Topper [Fri, 26 Jan 2018 19:34:45 +0000 (19:34 +0000)]
[X86] Add 'rdrnd' feature to silvermont to match recent gcc bug fix.

gcc recently fixed this bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83546

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

6 years ago[index] Fix crash when indexing a C++14 PCH/module related to TemplateTemplateParmDec...
Argyrios Kyrtzidis [Fri, 26 Jan 2018 19:26:12 +0000 (19:26 +0000)]
[index] Fix crash when indexing a C++14 PCH/module related to TemplateTemplateParmDecls of alias templates

TemplateTemplateParmDecls of alias templates ended-up serialized as 'file-level decls' which was causing a crash while trying to index a PCH/module file that contained them.
Commit makes sure TemplateTemplateParmDecls are not recorded as such kind of decls.

Fixes crash of rdar://36608297

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

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

6 years agoAST: support protocol conformances on id/class/interfaces in MS ABI
Saleem Abdulrasool [Fri, 26 Jan 2018 19:08:26 +0000 (19:08 +0000)]
AST: support protocol conformances on id/class/interfaces in MS ABI

Add support for mangling ObjC protocol conformances in MS ABI as if they are
COM interfaces. By diverging from the itanium mangling of `objc_protocol`
prefixed names, this approach allows for a semi-reasonable, albeit of
questionable sanity, undecoration via existing tooling. There is also the
possibility of adding an extension and taking part of the namespace to add the
conformance via the `L` and `Z` "modifiers", but the existing tooling would not
be able to properly undecorated the symbol even though incidentally `undname`
currently produces something legible while wine's implementation is not able to
cope with the extension.

This allows for the disambiguation of overloads where the parameter differs
only in the protocol conformance of the ObjC type, e.g.

```
@protocol P;
void f(std::vector<id>);
void f(std::vector<id<P>>);
```

which clang would previously fail due to the mangling being identical as the
protocol conformance was ignored.

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

6 years ago[X86] Define __IBT__ when -mibt is specified.
Craig Topper [Fri, 26 Jan 2018 18:31:14 +0000 (18:31 +0000)]
[X86] Define __IBT__ when -mibt is specified.

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

6 years agoclang-format: [JS] Prevent ASI before [ and (.
Martin Probst [Fri, 26 Jan 2018 15:07:49 +0000 (15:07 +0000)]
clang-format: [JS] Prevent ASI before [ and (.

Summary:
JavaScript automatic semicolon insertion can trigger before [ and (, so
avoid breaking before them if the previous token is likely to terminate
an expression.

Reviewers: djasper

Subscribers: cfe-commits, klimek

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

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

6 years ago[AST] Use bit packing to reduce sizeof(TypedefNameDecl) from 88 to 80.
Benjamin Kramer [Fri, 26 Jan 2018 14:14:11 +0000 (14:14 +0000)]
[AST] Use bit packing to reduce sizeof(TypedefNameDecl) from 88 to 80.

We can stash the cached transparent tag bit in existing pointer padding.
Everything coming out of ASTContext is always aligned to a multiple of
8, so we have 8 spare bits.

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

6 years ago[ASTImporter] avoid warnings: unused var, switch covered
Sam McCall [Fri, 26 Jan 2018 12:06:44 +0000 (12:06 +0000)]
[ASTImporter] avoid warnings: unused var, switch covered

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

6 years ago[OpenCL] Add "cles_khr_int64" extension.
Alexey Bader [Fri, 26 Jan 2018 11:48:46 +0000 (11:48 +0000)]
[OpenCL] Add "cles_khr_int64" extension.

Summary:
For OpenCL 1.1 embedded profile 64 bit integers i.e. long,
ulong including the appropriate vector data types and operations
on 64-bit integers are optional. The "cles_khr_int64" extension
string will be reported if the embedded profile implementation
supports 64-bit integers.

Reviewers: Anastasia, bader

Reviewed By: Anastasia, bader

Subscribers: bader, yaxunl, Anastasia, cfe-commits

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

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

6 years ago[ASTImporter] Support LambdaExprs and improve template support
Aleksei Sidorin [Fri, 26 Jan 2018 11:36:54 +0000 (11:36 +0000)]
[ASTImporter] Support LambdaExprs and improve template support

Also, a number of style and bug fixes was done:

 *  ASTImporterTest: added sanity check for source node
 *  ExternalASTMerger: better lookup for template specializations
 *  ASTImporter: don't add templated declarations into DeclContext
 *  ASTImporter: introduce a helper, ImportTemplateArgumentListInfo getting SourceLocations
 *  ASTImporter: proper set ParmVarDecls for imported FunctionProtoTypeLoc

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

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

6 years ago[Tooling] Test more APIs of ToolExecutor. NFC.
Eric Liu [Fri, 26 Jan 2018 11:10:32 +0000 (11:10 +0000)]
[Tooling] Test more APIs of ToolExecutor. NFC.

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

6 years ago[NFC] fix trivial typos in comments and documents
Hiroshi Inoue [Fri, 26 Jan 2018 08:15:52 +0000 (08:15 +0000)]
[NFC] fix trivial typos in comments and documents

"in in" -> "in", "on on" -> "on" etc.

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

6 years ago[Driver] Add an -fexperimental-isel driver option to enable/disable GlobalISel.
Amara Emerson [Fri, 26 Jan 2018 00:27:22 +0000 (00:27 +0000)]
[Driver] Add an -fexperimental-isel driver option to enable/disable GlobalISel.

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

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

6 years agoDon't let test write to the source dir after r323426.
Nico Weber [Thu, 25 Jan 2018 21:49:03 +0000 (21:49 +0000)]
Don't let test write to the source dir after r323426.

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

6 years agoAST: inline a single-use variable (NFC)
Saleem Abdulrasool [Thu, 25 Jan 2018 19:54:31 +0000 (19:54 +0000)]
AST: inline a single-use variable (NFC)

Inline the single use variable into the only use.  NFC.

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

6 years agoUnused diagnostics can occur in tblgen.
Benjamin Kramer [Thu, 25 Jan 2018 15:57:22 +0000 (15:57 +0000)]
Unused diagnostics can occur in tblgen.

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

6 years ago[clang-cl] Add support for /arch:AVX512F and /arch:AVX512
Nico Weber [Thu, 25 Jan 2018 15:24:43 +0000 (15:24 +0000)]
[clang-cl] Add support for /arch:AVX512F and /arch:AVX512

For /arch:AVX512F:
clang-cl and cl.exe both defines __AVX512F__ __AVX512CD__.
clang-cl also defines __AVX512ER__ __AVX512PF__.
64-bit cl.exe also defines (according to /Bz) _NO_PREFETCHW.

For /arch:AVX512:
clang-cl and cl.exe both define
__AVX512F__ __AVX512CD__ __AVX512BW__ __AVX512DQ__ __AVX512VL__.
64-bit cl.exe also defines _NO_PREFETCHW.

So not 100% identical, but pretty close.

Also refactor the existing AVX / AVX2 code to not repeat itself in both the
32-bit and 64-bit cases.

https://reviews.llvm.org/D42538

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

6 years agoclang-cl: Simplify handling of /arch: flag.
Nico Weber [Thu, 25 Jan 2018 14:38:29 +0000 (14:38 +0000)]
clang-cl: Simplify handling of /arch: flag.

r213083 initially implemented /arch: support by mapping it to CPU features.
Then r241077 additionally mapped it to CPU, which made the feature flags
redundant (if harmless). This change here removes the redundant mapping to
feature flags, and rewrites test/Driver/cl-x86-flags.c to be a bit more of an
integration test that checks for preprocessor defines like AVX (like documented
on MSDN) instead of for driver flags.

To keep emitting warn_drv_unused_argument, use getLastArgNoClaim() followed by an explicit claim() if needed.

This is in preparation for adding support for /arch:AVX512(F).

No intended behavior change.

https://reviews.llvm.org/D42497

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

6 years ago[CodeGen] Decorate aggregate accesses with TBAA tags
Ivan A. Kosarev [Thu, 25 Jan 2018 14:21:55 +0000 (14:21 +0000)]
[CodeGen] Decorate aggregate accesses with TBAA tags

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

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

6 years ago[clang-format] Fixes indentation of inner text proto messages
Krasimir Georgiev [Thu, 25 Jan 2018 14:10:43 +0000 (14:10 +0000)]
[clang-format] Fixes indentation of inner text proto messages

Summary:
Consider the text proto:
```
message {
  sub { key: value }
}
```
Previously the first `{` was TT_Unknown, which caused the inner message to be
indented by the continuation width. This didn't happen for:
```
message {
  sub: { key: value }
}
```
This is because the code to mark the first `{` as a TT_DictLiteral was only
considering the case where it marches forward and reaches a `:`.

This patch updates this by looking not only for `:`, but also for `<` and `{`.

Reviewers: djasper

Reviewed By: djasper

Subscribers: klimek, cfe-commits

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

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

6 years ago[Driver] Add support for mips32 and scudo
Simon Dardis [Thu, 25 Jan 2018 10:09:33 +0000 (10:09 +0000)]
[Driver] Add support for mips32 and scudo

r317337 missed that scudo is supported on MIPS32, so permit that option for
MIPS32.

Reviewers: cryptoad, atanasyan

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

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

6 years agoFreeBSD needs also execinfo (in sanitizers)
Kamil Rytarowski [Wed, 24 Jan 2018 23:08:49 +0000 (23:08 +0000)]
FreeBSD needs also execinfo (in sanitizers)

Summary: As NetBSD, FreeBSD needs execinfo for backtrace's matters.

Patch by: David CARLIER.

Reviewers: joerg, vitalybuka

Reviewed By: vitalybuka

Subscribers: emaste, krytarowski, cfe-commits

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

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

6 years ago[analyzer] Do not attempt to get the pointee of void*
Alexander Shaposhnikov [Wed, 24 Jan 2018 22:17:30 +0000 (22:17 +0000)]
[analyzer] Do not attempt to get the pointee of void*

Do not attempt to get the pointee of void* while generating a bug report
(otherwise it will trigger an assert inside RegionStoreManager::getBinding
assert(!T->isVoidType() && "Attempting to dereference a void pointer!")).

Test plan: make check-all

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

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

6 years ago[coroutines] Pass coro func args to promise ctor
Brian Gesiak [Wed, 24 Jan 2018 22:15:42 +0000 (22:15 +0000)]
[coroutines] Pass coro func args to promise ctor

Summary:
Use corutine function arguments to initialize a promise type, but only
if the promise type defines a constructor that takes those arguments.
Otherwise, fall back to the default constructor.

Test Plan: check-clang

Reviewers: rsmith, GorNishanov, eric_niebler

Reviewed By: GorNishanov

Subscribers: toby-allsopp, lewissbaker, EricWF, cfe-commits

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

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

6 years ago[analyzer] NFC: Run many existing C++ tests with a custom operator new().
Artem Dergachev [Wed, 24 Jan 2018 21:24:10 +0000 (21:24 +0000)]
[analyzer] NFC: Run many existing C++ tests with a custom operator new().

In order to provide more test coverage for inlined operator new(), add more
run-lines to existing test cases, which would trigger our fake header
to provide a body for operator new(). Most of the code should still behave
reasonably. When behavior intentionally changes, #ifs are provided.

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

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

6 years ago[analyzer] Enable c++-allocator-inlining by default.
Artem Dergachev [Wed, 24 Jan 2018 20:59:40 +0000 (20:59 +0000)]
[analyzer] Enable c++-allocator-inlining by default.

This allows the analyzer to analyze ("inline") custom operator new() calls and,
even more importantly, inline constructors of objects that were allocated
by any operator new() - not necessarily a custom one.

All changes in the tests in the current commit are intended improvements,
even if they didn't carry any explicit FIXME flag.

It is possible to restore the old behavior via

  -analyzer-config c++-allocator-inlining=false

(this flag is supported by scan-build as well, and it can be into a clang
--analyze invocation via -Xclang .. -Xclang ..). There is no intention to
remove the old behavior for now.

Differential Revision: https://reviews.llvm.org/D42219
rdar://problem/12180598

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

6 years ago[analyzer] Assume that the allocated value is non-null before construction.
Artem Dergachev [Wed, 24 Jan 2018 20:32:26 +0000 (20:32 +0000)]
[analyzer] Assume that the allocated value is non-null before construction.

I.e. not after. In the c++-allocator-inlining=true mode, we need to make the
assumption that the conservatively evaluated operator new() has returned a
non-null value. Previously we did this on CXXNewExpr, but now we have to do that
before calling the constructor, because some clever constructors are sometimes
assuming that their "this" is null and doing weird stuff. We would also crash
upon evaluating CXXNewExpr when the allocator was inlined and returned null and
had a throw specification; this is UB even for custom allocators, but we still
need not to crash.

Added more FIXME tests to ensure that eventually we fix calling the constructor
for null return values.

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

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

6 years agoRevert r323051 "[cmake] Use CLANG_BINARY_DIR to determine the build directory."
Vassil Vassilev [Wed, 24 Jan 2018 19:26:50 +0000 (19:26 +0000)]
Revert r323051 "[cmake] Use CLANG_BINARY_DIR to determine the build directory."

This broke swift builds.

Thanks for the post-commit review of Chris Bieneman and Davide Italiano!

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

6 years agoIRGen: Emit an inline implementation of __builtin_wmemcmp on MSVCRT platforms.
Peter Collingbourne [Wed, 24 Jan 2018 18:59:58 +0000 (18:59 +0000)]
IRGen: Emit an inline implementation of __builtin_wmemcmp on MSVCRT platforms.

The MSVC runtime library does not provide a definition of wmemcmp,
so we need an inline implementation.

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

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

6 years agoDon't create hidden dllimport global values.
Rafael Espindola [Wed, 24 Jan 2018 18:58:32 +0000 (18:58 +0000)]
Don't create hidden dllimport global values.

Hidden visibility is almost the opposite of dllimport. We were
producing them before (dllimport wins in the existing llvm
implementation), but now the llvm verifier produces an error.

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

6 years ago[Hexagon] Accept lowercase b in -hvx-length=64b and -hvx-length=128b
Krzysztof Parzyszek [Wed, 24 Jan 2018 18:42:19 +0000 (18:42 +0000)]
[Hexagon] Accept lowercase b in -hvx-length=64b and -hvx-length=128b

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

6 years ago[CodeComplete] only respect LoadExternal hint at namespace/tu scope
Sam McCall [Wed, 24 Jan 2018 17:50:20 +0000 (17:50 +0000)]
[CodeComplete] only respect LoadExternal hint at namespace/tu scope

Reviewers: ilya-biryukov

Subscribers: cfe-commits

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

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

6 years ago[CUDA] Disable PGO and coverage instrumentation in NVPTX.
Artem Belevich [Wed, 24 Jan 2018 17:41:02 +0000 (17:41 +0000)]
[CUDA] Disable PGO and coverage instrumentation in NVPTX.

NVPTX does not have runtime support necessary for profiling to work
and even call arc collection is prohibitively expensive. Furthermore,
there's no easy way to collect the samples. NVPTX also does not
support global constructors that clang generates if sample/arc collection
is enabled.

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

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

6 years agoclang-cl: Parse /permissive-, /Bt, Bt+ (PR32672)
Hans Wennborg [Wed, 24 Jan 2018 15:18:12 +0000 (15:18 +0000)]
clang-cl: Parse /permissive-, /Bt, Bt+ (PR32672)

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

6 years ago[clang-format] Disable string literal breaking for text protos
Krasimir Georgiev [Wed, 24 Jan 2018 11:18:39 +0000 (11:18 +0000)]
[clang-format] Disable string literal breaking for text protos

Summary:
Commonly string literals in protos are already multiline, so breaking them
further is undesirable.

Reviewers: djasper

Reviewed By: djasper

Subscribers: klimek, cfe-commits

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

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

6 years agoFix typos of occurred and occurrence
Malcolm Parsons [Wed, 24 Jan 2018 10:26:09 +0000 (10:26 +0000)]
Fix typos of occurred and occurrence

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

6 years agoRefactor RecursiveASTVisitor test for post-order traversal
Raphael Isemann [Wed, 24 Jan 2018 09:40:16 +0000 (09:40 +0000)]
Refactor RecursiveASTVisitor test for post-order traversal

Summary:
The new test is now in the right directory with the other ASTVisitor tests and uses
now the provided TestVisitor framework.

Subscribers: hintonda, v.g.vassilev, klimek, cfe-commits, mgorny

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

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

6 years agoAttempt to fix implicit-fallthrough warning after r323218.
Nico Weber [Wed, 24 Jan 2018 01:47:22 +0000 (01:47 +0000)]
Attempt to fix implicit-fallthrough warning after r323218.

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

6 years agoFix typo in comment.
Nico Weber [Wed, 24 Jan 2018 01:45:57 +0000 (01:45 +0000)]
Fix typo in comment.

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

6 years agoFix test Driver/solaris-ld.c for Windows.
Douglas Yung [Wed, 24 Jan 2018 00:05:01 +0000 (00:05 +0000)]
Fix test Driver/solaris-ld.c for Windows.

- Test needs to be able to handle "clang.exe" on Windows
- Test needs to be able to handle either '/' or '\\' used as the path separator

Reviewed by Paul Robinson

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

6 years agoAdjust MaxAtomicInlineWidth for i386/i486 targets.
Wei Mi [Tue, 23 Jan 2018 23:27:57 +0000 (23:27 +0000)]
Adjust MaxAtomicInlineWidth for i386/i486 targets.

This is to fix the bug reported in https://bugs.llvm.org/show_bug.cgi?id=34347#c6.
Currently, all  MaxAtomicInlineWidth of x86-32 targets are set to 64. However,
i386 doesn't support any cmpxchg related instructions. i486 only supports cmpxchg.
So in this patch MaxAtomicInlineWidth is reset as follows:
For i386, the MaxAtomicInlineWidth should be 0 because no cmpxchg is supported.
For i486, the MaxAtomicInlineWidth should be 32 because it supports cmpxchg.
For others 32 bits x86 cpu, the MaxAtomicInlineWidth should be 64 because of cmpxchg8b.

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

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

6 years agoFix test Driver/solaris-ld.c
Richard Trieu [Tue, 23 Jan 2018 21:58:56 +0000 (21:58 +0000)]
Fix test Driver/solaris-ld.c

Allow test to accept calls to ld without full path.

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

6 years agoAST: correct mangling for SEL on MS ABI
Saleem Abdulrasool [Tue, 23 Jan 2018 20:56:52 +0000 (20:56 +0000)]
AST: correct mangling for SEL on MS ABI

We would previously treat `SEL` as a pointer-only type.  This is not the
case.  It should be treated similarly to `id` and `Class`.  Add some
test cases to ensure that it will be properly handled as well.

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

6 years ago[WebAssembly] Factor out settings common to wasm32 and wasm64. NFC.
Dan Gohman [Tue, 23 Jan 2018 20:22:12 +0000 (20:22 +0000)]
[WebAssembly] Factor out settings common to wasm32 and wasm64. NFC.

MaxAtomicPromoteWidth and MaxAtomicInlineWidth are 64 on both
wasm32 and wasm64, so they can be set in shared code.

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

6 years ago[analyzer] Mark lines as relevant even if they weren't executed but have a label...
George Karpenkov [Tue, 23 Jan 2018 20:01:31 +0000 (20:01 +0000)]
[analyzer] Mark lines as relevant even if they weren't executed but have a label attached

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

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

6 years agoCodeGen: use `llvm.used` for ObjC protocols
Saleem Abdulrasool [Tue, 23 Jan 2018 19:35:51 +0000 (19:35 +0000)]
CodeGen: use `llvm.used` for ObjC protocols

These symbols are supposed to be preserved even by the linker.  Use the
`llvm.used` to ensure that the symbols are not removed by DCE in the
linker.  This should be a no-op change on MachO since the symbols are
annotated as `no_dead_strip`.

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

6 years ago[analyzer] Show full analyzer invocation for reproducibility in HTML reports
George Karpenkov [Tue, 23 Jan 2018 19:28:52 +0000 (19:28 +0000)]
[analyzer] Show full analyzer invocation for reproducibility in HTML reports

Analyzing problems which appear in scan-build results can be very
difficult, as after the launch no exact invocation is stored, and it's
super-hard to launch the debugger.
With this patch, the exact analyzer invocation appears in the footer,
and can be copied to debug/check reproducibility/etc.

rdar://35980230

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

6 years ago[html] [NFC] Use raw strings to dump the style table.
George Karpenkov [Tue, 23 Jan 2018 19:28:43 +0000 (19:28 +0000)]
[html] [NFC] Use raw strings to dump the style table.

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

6 years agoAST: adjust ObjC MS mangling to work with typedefs
Saleem Abdulrasool [Tue, 23 Jan 2018 19:17:25 +0000 (19:17 +0000)]
AST: adjust ObjC MS mangling to work with typedefs

Rather than hardcode the pointerness of the `id` and `class` types,
handle them generically.  This allows for the template type
specialization of `remove_pointer<id>` which would look through the `id`
type and deal with the `objc_object` structure without the pointer.

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

6 years ago[CUDA] CUDA has no device-side library builtins.
Artem Belevich [Tue, 23 Jan 2018 19:08:18 +0000 (19:08 +0000)]
[CUDA] CUDA has no device-side library builtins.

We should (almost) never consider a device-side declaration to match a
library builtin functio.  Otherwise clang may ignore the implementation
provided by the CUDA headers and emit clang's idea of the builtin.

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

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

6 years ago[OPENMP] Replace call of EmitLoadOfLValue() by EmitLoadOfScalar(), NFC.
Alexey Bataev [Tue, 23 Jan 2018 18:44:14 +0000 (18:44 +0000)]
[OPENMP] Replace call of EmitLoadOfLValue() by EmitLoadOfScalar(), NFC.

Replace calls of EmitLoadOfLValue() by EmitLoadOfScalar() functions if
it is known that the value is scalar.

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

6 years ago[Docs] Re-generate command line documentation.
Craig Topper [Tue, 23 Jan 2018 18:40:15 +0000 (18:40 +0000)]
[Docs] Re-generate command line documentation.

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

6 years ago[OPENMP] Remove more empty SourceLocations() from the code.
Alexey Bataev [Tue, 23 Jan 2018 18:12:38 +0000 (18:12 +0000)]
[OPENMP] Remove more empty SourceLocations() from the code.

Removed more empty SourceLocations() from the OpenMP code and replaced
with the correct locations for better debug info emission.

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

6 years agotest/Driver: Add some --stdlib=platform, NFC.
Jonas Hahnfeld [Tue, 23 Jan 2018 18:12:12 +0000 (18:12 +0000)]
test/Driver: Add some --stdlib=platform, NFC.

This fixes the failing test when building with CLANG_DEFAULT_CXX_STDLIB.

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

6 years agotest: simplify the matching logic a bit (NFC)
Saleem Abdulrasool [Tue, 23 Jan 2018 17:57:04 +0000 (17:57 +0000)]
test: simplify the matching logic a bit (NFC)

Use CHECK-SAME directives to simplify the test conditions a bit.  This
makes it easier to see what is being checked.  NFC.

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

6 years agoName two bool parameters. No behavior change.
Nico Weber [Tue, 23 Jan 2018 17:29:41 +0000 (17:29 +0000)]
Name two bool parameters. No behavior change.

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

6 years agoclang-format: Support macros in front of @interface / @protocol for ObjC code.
Nico Weber [Tue, 23 Jan 2018 17:10:25 +0000 (17:10 +0000)]
clang-format: Support macros in front of @interface / @protocol for ObjC code.

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

6 years agotest: adjust the target for some Windows tests
Saleem Abdulrasool [Tue, 23 Jan 2018 17:05:57 +0000 (17:05 +0000)]
test: adjust the target for some Windows tests

The tests are targeting Windows but do not specify an environment.  When
executed on Linux, they would use an ELF output rather than the COFF
output.  Explicitly provide an environment.

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

6 years ago[WebAssembly] Add mem.* builtin functions.
Dan Gohman [Tue, 23 Jan 2018 17:04:04 +0000 (17:04 +0000)]
[WebAssembly] Add mem.* builtin functions.

This corresponds to r323222 in LLVM. The new names are not yet
finalized, so use them at your own risk.

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

6 years agoclang-format: Support formatting Java 8 interface default methods.
Nico Weber [Tue, 23 Jan 2018 16:30:56 +0000 (16:30 +0000)]
clang-format: Support formatting Java 8 interface default methods.

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

6 years agoFix Driver/solaris-ld.c test on Windows
Fedor Sergeev [Tue, 23 Jan 2018 13:59:11 +0000 (13:59 +0000)]
Fix Driver/solaris-ld.c test on Windows

Fixing failure introduced with r323193.

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

6 years ago[Tooling] Added a VFS parameter to ClangTool
Ilya Biryukov [Tue, 23 Jan 2018 12:30:02 +0000 (12:30 +0000)]
[Tooling] Added a VFS parameter to ClangTool

Summary:
The parameter overrides the underlying vfs used by ClangTool for
filesystem operations.

Patch by Vladimir Plyashkun.

Reviewers: alexfh, ilya-biryukov

Reviewed By: ilya-biryukov

Subscribers: klimek, cfe-commits

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

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

6 years ago[Solaris] Make RHEL devtoolsets handling Linux-specific
Fedor Sergeev [Tue, 23 Jan 2018 12:24:01 +0000 (12:24 +0000)]
[Solaris] Make RHEL devtoolsets handling Linux-specific

Summary:
This patch is meant to address the last outstanding review comment on the already approved
(but not yet commited) https://reviews.llvm.org/D35755, namely making the handling of the RHEL
devtoolsets Linux-specific.

Don't know if it's best integrated into the former or applied subsequently.

Tested on i386-pc-solaris2.11 and x86_64-pc-linux-gnu.

Reviewers: fedor.sergeev, tstellar, jyknight

Reviewed By: fedor.sergeev

Subscribers: cfe-commits

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

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

6 years ago[Solaris] gcc toolchain handling revamp
Fedor Sergeev [Tue, 23 Jan 2018 12:23:52 +0000 (12:23 +0000)]
[Solaris] gcc toolchain handling revamp

Summary:
General idea is to utilize generic (mostly Generic_GCC) code
and get rid of Solaris-specific handling as much as possible.

In particular:
- scanLibDirForGCCTripleSolaris was removed, relying on generic
  CollectLibDirsAndTriples

- findBiarchMultilibs is now properly utilized to switch between
   m32 and m64 include & lib paths on Solaris

- C system include handling copied from Linux (bar multilib hacks)

Fixes PR24606.

Reviewers: dlj, rafael, jyknight, theraven, tstellar

Reviewed By: jyknight

Subscribers: aaron.ballman, mgorny, krytarowski, ro, joerg, cfe-commits

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

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

6 years ago[clang-format] Ignore UnbreakableTailLength sometimes during breaking
Krasimir Georgiev [Tue, 23 Jan 2018 11:26:19 +0000 (11:26 +0000)]
[clang-format] Ignore UnbreakableTailLength sometimes during breaking

Summary:
This patch fixes an issue where the UnbreakableTailLength would be counted towards
the length of a token during breaking, even though we can break after the token.

For example, this proto text with column limit 20
```
# ColumnLimit: 20  V
foo: {
  bar: {
    bazoo: "aaaaaaa"
  }
}
```
was broken:
```
# ColumnLimit: 20  V
foo: {
  bar: {
    bazoo:
        "aaaaaaa"
  }
}
```
because the 2 closing `}` were counted towards the string literal's `UnbreakableTailLength`.

Reviewers: djasper

Reviewed By: djasper

Subscribers: klimek, cfe-commits

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

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

6 years ago[ARM] Pass _Float16 as int or float
Sjoerd Meijer [Tue, 23 Jan 2018 10:13:49 +0000 (10:13 +0000)]
[ARM] Pass _Float16 as int or float

Pass and return _Float16 as if it were an int or float for ARM, but with the
top 16 bits unspecified, similarly like we already do for __fp16.

We will implement proper half-precision function argument lowering in the ARM
backend soon, but want to use this workaround in the mean time.

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

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

6 years ago[NFC] fix trivial typos in comments
Hiroshi Inoue [Tue, 23 Jan 2018 05:50:06 +0000 (05:50 +0000)]
[NFC] fix trivial typos in comments

"the the" -> "the"

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

6 years agoNewPM: Improve/fix GCOV - which needs to run early in the pass pipeline.
David Blaikie [Tue, 23 Jan 2018 01:25:24 +0000 (01:25 +0000)]
NewPM: Improve/fix GCOV - which needs to run early in the pass pipeline.

Using a new extension point in the new PM, register GCOV at the start of
the pipeline rather than the end.

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

6 years agoAdd hasTrailingReturn AST matcher
Julie Hockett [Mon, 22 Jan 2018 22:45:23 +0000 (22:45 +0000)]
Add hasTrailingReturn AST matcher

Adds AST matcher for a FunctionDecl that has a trailing return type.

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

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

6 years ago[ASTMatchers] [NFC] Fix code examples
Fangrui Song [Mon, 22 Jan 2018 22:34:15 +0000 (22:34 +0000)]
[ASTMatchers] [NFC] Fix code examples

Subscribers: klimek, cfe-commits

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

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

6 years agoReland "[CodeGen] Fix crash when a function taking transparent union is redeclared."
Volodymyr Sapsai [Mon, 22 Jan 2018 22:29:24 +0000 (22:29 +0000)]
Reland "[CodeGen] Fix crash when a function taking transparent union is redeclared."

When a function taking transparent union is declared as taking one of
union members earlier in the translation unit, clang would hit an
"Invalid cast" assertion during EmitFunctionProlog. This case
corresponds to function f1 in test/CodeGen/transparent-union-redecl.c.
We decided to cast i32 to union because after merging function
declarations function parameter type becomes int,
CGFunctionInfo::ArgInfo type matches with ABIArgInfo type, so we decide
it is a trivial case. But these types should also be castable to
parameter declaration type which is not the case here.

Now the fix is in converting from ABIArgInfo type to VarDecl type and using
argument demotion when necessary.

Additional tests in Sema/transparent-union.c capture current behavior and make
sure there are no regressions.

rdar://problem/34949329

Reviewers: rjmccall, rafael

Reviewed By: rjmccall

Subscribers: aemerson, cfe-commits, kristof.beyls, ahatanak

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

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

6 years agoIntroduce the "retpoline" x86 mitigation technique for variant #2 of the speculative...
Chandler Carruth [Mon, 22 Jan 2018 22:05:25 +0000 (22:05 +0000)]
Introduce the "retpoline" x86 mitigation technique for variant #2 of the speculative execution vulnerabilities disclosed today, specifically identified by CVE-2017-5715, "Branch Target Injection", and is one of the two halves to Spectre..

Summary:
First, we need to explain the core of the vulnerability. Note that this
is a very incomplete description, please see the Project Zero blog post
for details:
https://googleprojectzero.blogspot.com/2018/01/reading-privileged-memory-with-side.html

The basis for branch target injection is to direct speculative execution
of the processor to some "gadget" of executable code by poisoning the
prediction of indirect branches with the address of that gadget. The
gadget in turn contains an operation that provides a side channel for
reading data. Most commonly, this will look like a load of secret data
followed by a branch on the loaded value and then a load of some
predictable cache line. The attacker then uses timing of the processors
cache to determine which direction the branch took *in the speculative
execution*, and in turn what one bit of the loaded value was. Due to the
nature of these timing side channels and the branch predictor on Intel
processors, this allows an attacker to leak data only accessible to
a privileged domain (like the kernel) back into an unprivileged domain.

The goal is simple: avoid generating code which contains an indirect
branch that could have its prediction poisoned by an attacker. In many
cases, the compiler can simply use directed conditional branches and
a small search tree. LLVM already has support for lowering switches in
this way and the first step of this patch is to disable jump-table
lowering of switches and introduce a pass to rewrite explicit indirectbr
sequences into a switch over integers.

However, there is no fully general alternative to indirect calls. We
introduce a new construct we call a "retpoline" to implement indirect
calls in a non-speculatable way. It can be thought of loosely as
a trampoline for indirect calls which uses the RET instruction on x86.
Further, we arrange for a specific call->ret sequence which ensures the
processor predicts the return to go to a controlled, known location. The
retpoline then "smashes" the return address pushed onto the stack by the
call with the desired target of the original indirect call. The result
is a predicted return to the next instruction after a call (which can be
used to trap speculative execution within an infinite loop) and an
actual indirect branch to an arbitrary address.

On 64-bit x86 ABIs, this is especially easily done in the compiler by
using a guaranteed scratch register to pass the target into this device.
For 32-bit ABIs there isn't a guaranteed scratch register and so several
different retpoline variants are introduced to use a scratch register if
one is available in the calling convention and to otherwise use direct
stack push/pop sequences to pass the target address.

This "retpoline" mitigation is fully described in the following blog
post: https://support.google.com/faqs/answer/7625886

We also support a target feature that disables emission of the retpoline
thunk by the compiler to allow for custom thunks if users want them.
These are particularly useful in environments like kernels that
routinely do hot-patching on boot and want to hot-patch their thunk to
different code sequences. They can write this custom thunk and use
`-mretpoline-external-thunk` *in addition* to `-mretpoline`. In this
case, on x86-64 thu thunk names must be:
```
  __llvm_external_retpoline_r11
```
or on 32-bit:
```
  __llvm_external_retpoline_eax
  __llvm_external_retpoline_ecx
  __llvm_external_retpoline_edx
  __llvm_external_retpoline_push
```
And the target of the retpoline is passed in the named register, or in
the case of the `push` suffix on the top of the stack via a `pushl`
instruction.

There is one other important source of indirect branches in x86 ELF
binaries: the PLT. These patches also include support for LLD to
generate PLT entries that perform a retpoline-style indirection.

The only other indirect branches remaining that we are aware of are from
precompiled runtimes (such as crt0.o and similar). The ones we have
found are not really attackable, and so we have not focused on them
here, but eventually these runtimes should also be replicated for
retpoline-ed configurations for completeness.

For kernels or other freestanding or fully static executables, the
compiler switch `-mretpoline` is sufficient to fully mitigate this
particular attack. For dynamic executables, you must compile *all*
libraries with `-mretpoline` and additionally link the dynamic
executable and all shared libraries with LLD and pass `-z retpolineplt`
(or use similar functionality from some other linker). We strongly
recommend also using `-z now` as non-lazy binding allows the
retpoline-mitigated PLT to be substantially smaller.

When manually apply similar transformations to `-mretpoline` to the
Linux kernel we observed very small performance hits to applications
running typical workloads, and relatively minor hits (approximately 2%)
even for extremely syscall-heavy applications. This is largely due to
the small number of indirect branches that occur in performance
sensitive paths of the kernel.

When using these patches on statically linked applications, especially
C++ applications, you should expect to see a much more dramatic
performance hit. For microbenchmarks that are switch, indirect-, or
virtual-call heavy we have seen overheads ranging from 10% to 50%.

However, real-world workloads exhibit substantially lower performance
impact. Notably, techniques such as PGO and ThinLTO dramatically reduce
the impact of hot indirect calls (by speculatively promoting them to
direct calls) and allow optimized search trees to be used to lower
switches. If you need to deploy these techniques in C++ applications, we
*strongly* recommend that you ensure all hot call targets are statically
linked (avoiding PLT indirection) and use both PGO and ThinLTO. Well
tuned servers using all of these techniques saw 5% - 10% overhead from
the use of retpoline.

We will add detailed documentation covering these components in
subsequent patches, but wanted to make the core functionality available
as soon as possible. Happy for more code review, but we'd really like to
get these patches landed and backported ASAP for obvious reasons. We're
planning to backport this to both 6.0 and 5.0 release streams and get
a 5.0 release with just this cherry picked ASAP for distros and vendors.

This patch is the work of a number of people over the past month: Eric, Reid,
Rui, and myself. I'm mailing it out as a single commit due to the time
sensitive nature of landing this and the need to backport it. Huge thanks to
everyone who helped out here, and everyone at Intel who helped out in
discussions about how to craft this. Also, credit goes to Paul Turner (at
Google, but not an LLVM contributor) for much of the underlying retpoline
design.

Reviewers: echristo, rnk, ruiu, craig.topper, DavidKreitzer

Subscribers: sanjoy, emaste, mcrosier, mgorny, mehdi_amini, hiraditya, llvm-commits

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

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

6 years ago[CodeComplete] Omit templated constructors from member list too.
Sam McCall [Mon, 22 Jan 2018 20:44:47 +0000 (20:44 +0000)]
[CodeComplete] Omit templated constructors from member list too.

Also avoid printing a 'void' return type for constructor expressions.

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

6 years ago[analyzer] Protect against dereferencing a null pointer
Alexander Shaposhnikov [Mon, 22 Jan 2018 20:18:42 +0000 (20:18 +0000)]
[analyzer] Protect against dereferencing a null pointer

The check (inside StackHintGeneratorForSymbol::getMessage)
if (!N)
    return getMessageForSymbolNotFound()
is moved to the beginning of the function.

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

Test plan: make check-all

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

6 years ago[CodeComplete] Fix completion in the middle of idents in macro calls
Ilya Biryukov [Mon, 22 Jan 2018 17:18:28 +0000 (17:18 +0000)]
[CodeComplete] Fix completion in the middle of idents in macro calls

Summary:
This patch removes IdentifierInfo from completion token after remembering
the identifier in the preprocessor.

Prior to this patch, completion token had the IdentifierInfo set to null when
completing at the start of identifier and to the II for completion prefix
when in the middle of identifier.

This patch unifies how code completion token is handled when it is insterted
before the identifier and in the middle of the identifier.

The actual IdentifierInfo can still be obtained from the Preprocessor.

Reviewers: bkramer, arphaman

Reviewed By: bkramer

Subscribers: cfe-commits

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

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

6 years ago[DOCS] Mention OpenMP Tools Interface in runtime library
Jonas Hahnfeld [Mon, 22 Jan 2018 15:27:45 +0000 (15:27 +0000)]
[DOCS] Mention OpenMP Tools Interface in runtime library

Also list supported configurations (architectures + operating
systems).

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

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

6 years ago[modules] Correctly overload getModule in the MultiplexExternalSemaSource
Raphael Isemann [Mon, 22 Jan 2018 15:27:25 +0000 (15:27 +0000)]
[modules] Correctly overload getModule in the MultiplexExternalSemaSource

Summary:
The MultiplexExternalSemaSource doesn't correctly overload the `getModule` function,
causing the multiplexer to not forward this call as intended.

Reviewers: v.g.vassilev

Reviewed By: v.g.vassilev

Subscribers: cfe-commits

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

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

6 years ago[analyzer] Model and check unrepresentable left shifts
Gabor Horvath [Mon, 22 Jan 2018 13:32:10 +0000 (13:32 +0000)]
[analyzer] Model and check unrepresentable left shifts

Patch by: Reka Nikolett Kovacs

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

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

6 years ago[NFC] fix trivial typos in comments
Hiroshi Inoue [Mon, 22 Jan 2018 07:44:38 +0000 (07:44 +0000)]
[NFC] fix trivial typos in comments

"the the" -> "the"

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

6 years ago[analyzer] Provide a check name when MallocChecker enables CStringChecker
Devin Coughlin [Sat, 20 Jan 2018 23:11:17 +0000 (23:11 +0000)]
[analyzer] Provide a check name when MallocChecker enables CStringChecker

Fix an assertion failure caused by a missing CheckName. The malloc checker
enables "basic" support in the CStringChecker, which causes some CString
bounds checks to be enabled. In this case, make sure that we have a
valid CheckName for the BugType.

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