]> granicus.if.org Git - clang/log
clang
6 years agoUse InitLLVM in clang as well.
Rui Ueyama [Fri, 13 Apr 2018 20:57:57 +0000 (20:57 +0000)]
Use InitLLVM in clang as well.

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

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

6 years ago[Analyzer] Fix for SValBuilder expressions rearrangement
Adam Balogh [Fri, 13 Apr 2018 20:23:02 +0000 (20:23 +0000)]
[Analyzer] Fix for SValBuilder expressions rearrangement

Expression rearrangement in SValBuilder (see rL329780) crashes with an assert if the type of the integer is different from the type of the symbol. This fix adds a check that prevents rearrangement in such cases.

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

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

6 years agohwasan: add -fsanitize=kernel-hwaddress flag
Andrey Konovalov [Fri, 13 Apr 2018 18:05:21 +0000 (18:05 +0000)]
hwasan: add -fsanitize=kernel-hwaddress flag

This patch adds -fsanitize=kernel-hwaddress flag, that essentially enables
-hwasan-kernel=1 -hwasan-recover=1 -hwasan-match-all-tag=0xff.

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

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

6 years ago[OPENMP] Replace push_back by emplace_back, NFC.
Alexey Bataev [Fri, 13 Apr 2018 17:48:43 +0000 (17:48 +0000)]
[OPENMP] Replace push_back by emplace_back, NFC.

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

6 years agoFix evaluation of `__has_include_next` during -frewrite-includes.
Volodymyr Sapsai [Fri, 13 Apr 2018 17:43:15 +0000 (17:43 +0000)]
Fix evaluation of `__has_include_next` during -frewrite-includes.

`__has_include_next` requires correct DirectoryLookup for being
evaluated correctly. We were using Preprocessor::GetCurDirLookup() but
we were calling it after the preprocessor finished its work. And in this
case CurDirLookup is always nullptr which makes `__has_include_next`
behave as `__has_include`.

Fix by storing and using CurDirLookup when preprocessor enters a file,
not when we rewrite the includes.

rdar://problem/36305026

Reviewers: bkramer

Reviewed By: bkramer

Subscribers: jkorous-apple, cfe-commits

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

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

6 years ago[OPENMP] Code cleanup + formatting, NFC.
Alexey Bataev [Fri, 13 Apr 2018 17:31:06 +0000 (17:31 +0000)]
[OPENMP] Code cleanup + formatting, NFC.

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

6 years ago[clang-format] Improve Incomplete detection for (text) protos
Krasimir Georgiev [Fri, 13 Apr 2018 13:37:09 +0000 (13:37 +0000)]
[clang-format] Improve Incomplete detection for (text) protos

Summary:
This patch improves detection of incomplete code for protos and text protos.
This is especially important for text protos in raw string literals, since they
might be partial strings concatenated, and we'd like to disable formatting in
these cases.

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: klimek, cfe-commits

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

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

6 years ago[NEON] Support vrndns_f32 intrinsic
Ivan A. Kosarev [Fri, 13 Apr 2018 12:46:02 +0000 (12:46 +0000)]
[NEON] Support vrndns_f32 intrinsic

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

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

6 years ago[analyzer] Fix null deref in AnyFunctionCall::getRuntimeDefinition
Gabor Horvath [Fri, 13 Apr 2018 12:36:08 +0000 (12:36 +0000)]
[analyzer] Fix null deref in AnyFunctionCall::getRuntimeDefinition

Patch by: Rafael Stahl!

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

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

6 years ago[X86] Fix cldemote builtin signature
Gabor Buella [Fri, 13 Apr 2018 08:14:21 +0000 (08:14 +0000)]
[X86] Fix cldemote builtin signature

Fix for r329993

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

6 years ago[X86] Introduce cldemote intrinsic
Gabor Buella [Fri, 13 Apr 2018 07:37:24 +0000 (07:37 +0000)]
[X86] Introduce cldemote intrinsic

Reviewers: craig.topper, zvi

Reviewed By: craig.topper

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

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

6 years ago[XRay][clang] Make -fxray-modes= additive
Dean Michael Berris [Fri, 13 Apr 2018 05:59:57 +0000 (05:59 +0000)]
[XRay][clang] Make -fxray-modes= additive

Summary:
This allows us to do the following:

  clang -fxray-modes=none ... -fxray-modes=xray-basic

It's important to be able to do this in cases where we'd like to
specialise the configuration for the invocation of the compiler, in
various scripting environments.

This is related to llvm.org/PR37066, a follow-up to D45474.

Reviewers: eizan, kpw, pelikan

Subscribers: cfe-commits

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

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

6 years ago[XRay][clang] Add flag to choose instrumentation bundles
Dean Michael Berris [Fri, 13 Apr 2018 02:31:58 +0000 (02:31 +0000)]
[XRay][clang] Add flag to choose instrumentation bundles

Summary:
This change addresses http://llvm.org/PR36926 by allowing users to pick
which instrumentation bundles to use, when instrumenting with XRay. In
particular, the flag `-fxray-instrumentation-bundle=` has four valid
values:

- `all`: the default, emits all instrumentation kinds
- `none`: equivalent to -fnoxray-instrument
- `function`: emits the entry/exit instrumentation
- `custom`: emits the custom event instrumentation

These can be combined either as comma-separated values, or as
repeated flag values.

Reviewers: echristo, kpw, eizan, pelikan

Reviewed By: pelikan

Subscribers: mgorny, cfe-commits

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

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

6 years ago[CMake][Fuchsia] Don't specify libc++ ABI version for Fuchsia
Petr Hosek [Fri, 13 Apr 2018 02:02:13 +0000 (02:02 +0000)]
[CMake][Fuchsia] Don't specify libc++ ABI version for Fuchsia

This is now set automatically in libc++ config header.

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

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

6 years agoFix test failure caused by r329965.
Eli Friedman [Thu, 12 Apr 2018 22:50:50 +0000 (22:50 +0000)]
Fix test failure caused by r329965.

"-mllvm" options get parsed slightly earlier, and -arm-restrict-it is
only available if the ARM target is compiled in. Invoke "clang -cc1"
directly to avoid the issue.

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

6 years agoRemove -cc1 option "-backend-option".
Eli Friedman [Thu, 12 Apr 2018 22:21:36 +0000 (22:21 +0000)]
Remove -cc1 option "-backend-option".

It means the same thing as -mllvm; there isn't any reason to have two
options which do the same thing.

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

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

6 years ago[NFC] Fix terrible formatting of CGRecordLower constructor.
Erich Keane [Thu, 12 Apr 2018 20:46:31 +0000 (20:46 +0000)]
[NFC] Fix terrible formatting of CGRecordLower constructor.

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

6 years ago[MinGW] Look for libc++ headers in a triplet prefixed path as well
Martin Storsjo [Thu, 12 Apr 2018 20:07:38 +0000 (20:07 +0000)]
[MinGW] Look for libc++ headers in a triplet prefixed path as well

This makes it consistent with libstdc++ and the other default
include directories.

If these headers are found in both locations and one isn't a
symlink to the other, this will cause errors due to libc++ headers
having wrapper headers for some standard C headers, wrappers that
do #include_next the actual one.

If the same libc++ standard C wrapper header exists in more than one
include directory before the real system one, the header include
guard will stop it from doing another #include_next to pick up the
real one, breaking things.

As this is a rather uncommon situation, this should be acceptable
and toolchain maintainers can adapt accordingly if necessary.

Also simplify some of the existing code with a local variable.

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

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

6 years agoFix doc typo
Vlad Tsyrklevich [Thu, 12 Apr 2018 19:35:39 +0000 (19:35 +0000)]
Fix doc typo

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

6 years ago[RISCV] Fix logic to check if frame pointer should be used
Mandeep Singh Grang [Thu, 12 Apr 2018 19:31:37 +0000 (19:31 +0000)]
[RISCV] Fix logic to check if frame pointer should be used

Summary: The logic was broken for Linux triples as it returns true in the switch for Triple.isOSLinux().

Reviewers: asb, apazos

Reviewed By: asb

Subscribers: kito-cheng, shiva0217, cfe-commits

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

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

6 years ago[X86] Introduce wbinvd intrinsic
Gabor Buella [Thu, 12 Apr 2018 18:42:02 +0000 (18:42 +0000)]
[X86] Introduce wbinvd intrinsic

A previously missing intrinsic for an old instruction.

Reviewers: craig.topper, echristo

Reviewed By: craig.topper

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

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

6 years agoNFC - Indentation fixes in predefined-arch-macros.c
Gabor Buella [Thu, 12 Apr 2018 18:15:39 +0000 (18:15 +0000)]
NFC - Indentation fixes in predefined-arch-macros.c

Consistently separating tests with empty lines.
Helps while navigating this file.

Reviewers: craig.topper

Reviewed By: craig.topper

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

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

6 years agoFix the try_acquire_capability attribute to behave like the other try-lock functions...
Aaron Ballman [Thu, 12 Apr 2018 17:53:21 +0000 (17:53 +0000)]
Fix the try_acquire_capability attribute to behave like the other try-lock functions. Fixes PR32954.

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

6 years agoCorrectly diagnose when a conversion function is declared with a type qualifier in...
Aaron Ballman [Thu, 12 Apr 2018 16:41:55 +0000 (16:41 +0000)]
Correctly diagnose when a conversion function is declared with a type qualifier in the declaration specifiers rather than in the conversion type id. Fixes PR30595.

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

6 years ago[Hexagon] Enable auto-vectorization only when -fvectorize was given
Krzysztof Parzyszek [Thu, 12 Apr 2018 16:25:35 +0000 (16:25 +0000)]
[Hexagon] Enable auto-vectorization only when -fvectorize was given

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

6 years ago[Test Fix] Fix broken test Index/comment-objc-parameterized-classes.m
Ben Hamilton [Thu, 12 Apr 2018 16:00:05 +0000 (16:00 +0000)]
[Test Fix] Fix broken test Index/comment-objc-parameterized-classes.m

I broke this test in D45498 when I changed the formatter to remove
spaces before Objective-C lightweight generics.

This fixes the test.

Test Plan:
  % make -j16 check-llvm-tools-llvm-lit && ./bin/llvm-lit -sv ../llvm/tools/clang/test/Index/comment-objc-parameterized-classes.m

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

6 years ago[clang-format] Do not break after ObjC category open paren
Ben Hamilton [Thu, 12 Apr 2018 15:11:55 +0000 (15:11 +0000)]
[clang-format] Do not break after ObjC category open paren

Summary:
Previously, `clang-format` would break Objective-C
category extensions after the opening parenthesis to avoid
breaking the protocol list:

```
% echo "@interface ccccccccccccc (ccccccccccc) <ccccccccccccc> { }" | \
  clang-format -assume-filename=foo.h -style="{BasedOnStyle: llvm, \
  ColumnLimit: 40}"
@interface ccccccccccccc (
    ccccccccccc) <ccccccccccccc> {
}
```

This looks fairly odd, as we could have kept the category extension
on the previous line.

Category extensions are a single item, so they are generally very
short compared to protocol lists. We should prefer breaking after the
opening `<` of the protocol list over breaking after the opening `(`
of the category extension.

With this diff, we now avoid breaking after the category extension's
open paren, which causes us to break after the protocol list's
open angle bracket:

```
% echo "@interface ccccccccccccc (ccccccccccc) <ccccccccccccc> { }" | \
  ./bin/clang-format -assume-filename=foo.h -style="{BasedOnStyle: llvm, \
  ColumnLimit: 40}"
@interface ccccccccccccc (ccccccccccc) <
    ccccccccccccc> {
}
```

Test Plan: New test added. Confirmed test failed before diff and
  passed after diff by running:
  % make -j16 FormatTests && ./tools/clang/unittests/Format/FormatTests

Reviewers: djasper, jolesiak

Reviewed By: djasper

Subscribers: klimek, cfe-commits

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

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

6 years ago[clang-format] Improve ObjC guessing heuristic by supporting all @keywords
Ben Hamilton [Thu, 12 Apr 2018 15:11:53 +0000 (15:11 +0000)]
[clang-format] Improve ObjC guessing heuristic by supporting all @keywords

Summary:
This diff improves the Objective-C guessing heuristic by
replacing the hard-coded list of a subset of Objective-C @keywords
with a general check which supports all @keywords.

I also added a few more Foundation keywords which were missing from
the heuristic.

Test Plan: Unit tests updated. Ran tests with:
  % make -j16 FormatTests && ./tools/clang/unittests/Format/FormatTests

Reviewers: djasper, jolesiak

Reviewed By: djasper

Subscribers: klimek, cfe-commits

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

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

6 years ago[clang-format] Don't insert space between ObjC class and lightweight generic
Ben Hamilton [Thu, 12 Apr 2018 15:11:51 +0000 (15:11 +0000)]
[clang-format] Don't insert space between ObjC class and lightweight generic

Summary:
In D45185, I added clang-format parser support for Objective-C
generics. However, I didn't touch the whitespace logic, so they
got the same space logic as Objective-C protocol lists.

In every example in the Apple SDK and in the documentation,
there is no space between the class name and the opening `<`
for the lightweight generic specification, so this diff
removes the space and updates the tests.

Test Plan: Tests updated. Ran tests with:
  % make -j16 FormatTests && ./tools/clang/unittests/Format/FormatTests

Reviewers: djasper, jolesiak

Reviewed By: djasper

Subscribers: klimek, cfe-commits

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

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

6 years ago[clang-format] Always indent wrapped Objective-C selector names
Ben Hamilton [Thu, 12 Apr 2018 15:11:48 +0000 (15:11 +0000)]
[clang-format] Always indent wrapped Objective-C selector names

Summary:
Currently, indentation of Objective-C method names which are wrapped
onto the next line due to a long return type is controlled by the
style option `IndentWrappedFunctionNames`.

This diff changes the behavior so we always indent wrapped Objective-C
selector names.

NOTE: I partially reverted https://github.com/llvm-mirror/clang/commit/6159c0fbd1876c7f5f984b4830c664cc78f16e2e / rL242484, as it was causing wrapped selectors to be double-indented. Its tests in FormatTestObjC.cpp still pass.

Test Plan: Tests updated. Ran tests with:
  % make -j12 FormatTests && ./tools/clang/unittests/Format/FormatTests

Reviewers: djasper, jolesiak, stephanemoore, thakis

Reviewed By: djasper

Subscribers: stephanemoore, klimek, cfe-commits

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

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

6 years agoDiagnose cases of "return x" that should be "return std::move(x)" for efficiency
Malcolm Parsons [Thu, 12 Apr 2018 14:48:48 +0000 (14:48 +0000)]
Diagnose cases of "return x" that should be "return std::move(x)" for efficiency

Summary:
This patch adds two new diagnostics, which are off by default:

**-Wreturn-std-move**

This diagnostic is enabled by `-Wreturn-std-move`, `-Wmove`, or `-Wall`.
Diagnose cases of `return x` or `throw x`, where `x` is the name of a local variable or parameter, in which a copy operation is performed when a move operation would have been available. The user probably expected a move, but they're not getting a move, perhaps because the type of "x" is different from the return type of the function.
A place where this comes up in the wild is `stdext::inplace_function<Sig, N>` which implements conversion via a conversion operator rather than a converting constructor; see https://github.com/WG21-SG14/SG14/issues/125#issue-297201412
Another place where this has come up in the wild, but where the fix ended up being different, was

    try { ... } catch (ExceptionType ex) {
        throw ex;
    }

where the appropriate fix in that case was to replace `throw ex;` with `throw;`, and incidentally to catch by reference instead of by value. (But one could contrive a scenario where the slicing was intentional, in which case throw-by-move would have been the appropriate fix after all.)
Another example (intentional slicing to a base class) is dissected in https://github.com/accuBayArea/Slides/blob/master/slides/2018-03-07.pdf

**-Wreturn-std-move-in-c++11**

This diagnostic is enabled only by the exact spelling `-Wreturn-std-move-in-c++11`.
Diagnose cases of "return x;" or "throw x;" which in this version of Clang *do* produce moves, but which prior to Clang 3.9 / GCC 5.1 produced copies instead. This is useful in codebases which care about portability to those older compilers.
The name "-in-c++11" is not technically correct; what caused the version-to-version change in behavior here was actually CWG 1579, not C++14. I think it's likely that codebases that need portability to GCC 4.9-and-earlier may understand "C++11" as a colloquialism for "older compilers." The wording of this diagnostic is based on feedback from @rsmith.

**Discussion**

Notice that this patch is kind of a negative-space version of Richard Trieu's `-Wpessimizing-move`. That diagnostic warns about cases of `return std::move(x)` that should be `return x` for speed. These diagnostics warn about cases of `return x` that should be `return std::move(x)` for speed. (The two diagnostics' bailiwicks do not overlap: we don't have to worry about a `return` statement flipping between the two states indefinitely.)

I propose to write a paper for San Diego that would relax the implicit-move rules so that in C++2a the user //would// see the moves they expect, and the diagnostic could be re-worded in a later version of Clang to suggest explicit `std::move` only "in C++17 and earlier." But in the meantime (and/or forever if that proposal is not well received), this diagnostic will be useful to detect accidental copy operations.

Reviewers: rtrieu, rsmith

Reviewed By: rsmith

Subscribers: lebedev.ri, Rakete1111, rsmith, cfe-commits

Tags: #clang

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

Patch by Arthur O'Dwyer.

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

6 years ago[OpenCL] Added -std/-cl-std=c++
Anastasia Stulova [Thu, 12 Apr 2018 14:17:04 +0000 (14:17 +0000)]
[OpenCL] Added -std/-cl-std=c++

This is std option for OpenCL C++ v1.0.

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

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

6 years agoAllow [[maybe_unused]] on static data members; these are considered variables and...
Aaron Ballman [Thu, 12 Apr 2018 12:21:41 +0000 (12:21 +0000)]
Allow [[maybe_unused]] on static data members; these are considered variables and the attribute should appertain to them.

Patch by S. B. Tam.

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

6 years agoObjCGNU: Fix empty v3 protocols being emitted two fields short
David Chisnall [Thu, 12 Apr 2018 06:46:15 +0000 (06:46 +0000)]
ObjCGNU: Fix empty v3 protocols being emitted two fields short

Summary:
Protocols that were being referenced but could not be fully realized were being emitted without `properties`/`optional_properties`. Since all v3 protocols must be 9 processor words wide, the lack of these fields is catastrophic for the runtime.

As an example, the runtime cannot know [here](https://github.com/gnustep/libobjc2/blob/master/protocol.c#L73) that `properties` and `optional_properties` are invalid.

Reviewers: rjmccall, theraven

Reviewed By: rjmccall, theraven

Subscribers: cfe-commits

Tags: #clang

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

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

6 years ago[Sema][ObjC] Ensure that the return type of an ObjC method is a complete
Akira Hatanaka [Thu, 12 Apr 2018 06:01:41 +0000 (06:01 +0000)]
[Sema][ObjC] Ensure that the return type of an ObjC method is a complete
type.

Copy the code in ActOnStartOfFunctionDef that checks a function's return
type to ActOnStartOfObjCMethodDef. This fixes an assertion failure in
IRGen caused by an uninstantiated return type.

rdar://problem/38691818

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

6 years ago[ODRHash] Skip more types hashing TypedefType
Richard Trieu [Thu, 12 Apr 2018 02:26:49 +0000 (02:26 +0000)]
[ODRHash] Skip more types hashing TypedefType

To get the underlying type for TypedefType's, also skip ElaboratedType's.

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

6 years agoLex: make `clang::Preprocessor::macros` work on MSVC
Saleem Abdulrasool [Wed, 11 Apr 2018 23:47:25 +0000 (23:47 +0000)]
Lex: make `clang::Preprocessor::macros` work on MSVC

The order of argument construction is reversed on MS ABI on Windows.
When `macros` was invoked, the `end` call is made prior to `begin`.  In
such a case, the DenseMap (`ModuleMap`) is populated after the `end`
iterator is constructed.  This reversal results in the invalidation of
the end iterator, resulting in a failure at runtime (assertion failure
in `DenseMap<T>::operator!=` that "handles are not in sync!").  Ensure
that the end iterator is constructed after the begin iterator.  This
fixes the use of `macros(bool)`, which symptomized as an assertion
failure in the swift compiler in the clang importer.

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

6 years agoDriver: Add gcc search path for RHEL devtoolset-7
Tom Stellard [Wed, 11 Apr 2018 22:29:35 +0000 (22:29 +0000)]
Driver:  Add gcc search path for RHEL devtoolset-7

Reviewers: bruno

Reviewed By: bruno

Subscribers: bruno, cfe-commits

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

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

6 years ago[Serialization] Fix some Clang-tidy modernize and Include What You Use warnings;...
Eugene Zelenko [Wed, 11 Apr 2018 20:57:28 +0000 (20:57 +0000)]
[Serialization] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).

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

6 years ago[x86] wbnoinvd intrinsic
Gabor Buella [Wed, 11 Apr 2018 20:09:09 +0000 (20:09 +0000)]
[x86] wbnoinvd intrinsic

The WBNOINVD instruction writes back all modified
cache lines in the processor’s internal cache to main memory
but does not invalidate (flush) the internal caches.

Reviewers: craig.topper, zvi, ashlykov

Reviewed By: craig.topper

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

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

6 years ago[OPENMP] Code cleanup, NFC.
Alexey Bataev [Wed, 11 Apr 2018 19:21:00 +0000 (19:21 +0000)]
[OPENMP] Code cleanup, NFC.

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

6 years ago[CodeGen] Handle __func__ inside __finally
Shoaib Meenai [Wed, 11 Apr 2018 18:17:35 +0000 (18:17 +0000)]
[CodeGen] Handle __func__ inside __finally

When we enter a __finally block, the CGF's CurCodeDecl will be null
(because CodeGenFunction::StartFunction is given an empty GlobalDecl for
a __finally block), and so the dyn_cast here will result in an assertion
failure. Change it to dyn_cast_or_null to handle this case.

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

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

6 years ago[NVPTX] Removed 'satom' feature which is no longer used.
Artem Belevich [Wed, 11 Apr 2018 17:51:33 +0000 (17:51 +0000)]
[NVPTX] Removed 'satom' feature which is no longer used.

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

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

6 years ago[NVPTX, CUDA] Improved feature constraints on NVPTX target builtins.
Artem Belevich [Wed, 11 Apr 2018 17:51:19 +0000 (17:51 +0000)]
[NVPTX, CUDA] Improved feature constraints on NVPTX target builtins.

When NVPTX TARGET_BUILTIN specifies sm_XX or ptxYY as required feature,
consider those features available if we're compiling for GPU >= sm_XX or have
enabled PTX version >= ptxYY.

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

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

6 years agoDocument -std= values for different languages
Dimitry Andric [Wed, 11 Apr 2018 17:21:52 +0000 (17:21 +0000)]
Document -std= values for different languages

Summary:
After a remark on a FreeBSD mailing list that the clang man page did
not have any list of possible values for the `-std=` flag, I have now
attempted to exhaustively list those, for each available language.

I also documented the default standard for each language, if there was
more than one choice.

Reviewers: rsmith, dexonsmith, sylvestre.ledru, mgorny

Reviewed By: rsmith

Subscribers: fhahn, emaste, cfe-commits, krytarowski

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

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

6 years agobpf: accept all asm register names
Yonghong Song [Wed, 11 Apr 2018 16:08:00 +0000 (16:08 +0000)]
bpf: accept all asm register names

Sometimes when people compile bpf programs with
"clang ... -target bpf ...", the kernel header
files may contain host arch inline assembly codes
as in the patch https://patchwork.kernel.org/patch/10119683/
by Arnaldo Carvaldo de Melo.

The current workaround in the above patch
is to guard the inline assembly with "#ifndef __BPF__"
marco. So when __BPF__ is defined, these macros will
have no use.

Such a method is not extensible. As a matter of fact,
most of these inline assembly codes will be thrown away
at the end of clang compilation.

So for bpf target, this patch accepts all asm register
names in clang AST stage. The name will be checked
again during llc code generation if the inline assembly
code is indeed for bpf programs.

With this patch, the above "#ifndef __BPF__" is not needed
any more in https://patchwork.kernel.org/patch/10119683/.

Signed-off-by: Yonghong Song <yhs@fb.com>
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@329823 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoFix bugs around handling C++11 attributes.
Manuel Klimek [Wed, 11 Apr 2018 14:51:54 +0000 (14:51 +0000)]
Fix bugs around handling C++11 attributes.

Previously, we would format:
  int a() { ... }
  [[unused]] int b() { ... }
as...
  int a() {} [[unused] int b() {}
Now we correctly format each on its own line.

Similarly, we would detect:
  [[unused]] int b() { return 42; }
As a lambda and leave it on a single line, even if that was disallowed
by the format style.

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

6 years ago[NEON] Support vfma_n and vfms_n intrinsics
Ivan A. Kosarev [Wed, 11 Apr 2018 14:43:11 +0000 (14:43 +0000)]
[NEON] Support vfma_n and vfms_n intrinsics

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

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

6 years ago[Driver] Don't forward -m[no-]unaligned-access options to GCC when assembling/linking
Chad Rosier [Wed, 11 Apr 2018 14:20:37 +0000 (14:20 +0000)]
[Driver] Don't forward -m[no-]unaligned-access options to GCC when assembling/linking

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

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

6 years ago[Sema] Fix built-in decrement operator overload resolution
Jan Korous [Wed, 11 Apr 2018 13:36:29 +0000 (13:36 +0000)]
[Sema] Fix built-in decrement operator overload resolution

C++ [over.built] p4:

"For every pair (T, VQ), where T is an arithmetic type other than bool, and VQ is either volatile or empty, there exist candidate operator functions of the form

  VQ T&      operator--(VQ T&);
  T          operator--(VQ T&, int);
"
The bool type is in position LastPromotedIntegralType in BuiltinOperatorOverloadBuilder::getArithmeticType::ArithmeticTypes, but addPlusPlusMinusMinusArithmeticOverloads() was expecting it at position 0.

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

rdar://problem/34255516

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

6 years ago[PowerPC] Option for secure plt mode
Strahinja Petrovic [Wed, 11 Apr 2018 12:24:44 +0000 (12:24 +0000)]
[PowerPC] Option for secure plt mode

This patch enables option for secure plt mode in
clang (-msecure-plt).

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

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

6 years ago[Tooling] Correct the "-std" compile command option.
Haojian Wu [Wed, 11 Apr 2018 09:18:18 +0000 (09:18 +0000)]
[Tooling] Correct the "-std" compile command option.

Summary:
"-std c++11" is not valid in compiler, we have to use "-std=c++11".

Test in vscode with this patch, code completion for header works as expected.

Reviewers: sammccall

Subscribers: cfe-commits, klimek

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

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

6 years ago[Tooling] Optimize memory usage in InMemoryToolResults.
Haojian Wu [Wed, 11 Apr 2018 08:13:07 +0000 (08:13 +0000)]
[Tooling] Optimize memory usage in InMemoryToolResults.

Avoid storing duplicated "std::string"s.

clangd's global-symbol-builder takes 20+GB memory running across LLVM
repository. With this patch, the used memory is ~10GB (running on 48
threads, most of meory are AST-related).

Subscribers: klimek, cfe-commits

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

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

6 years ago[Analyzer] SValBuilder Comparison Rearrangement (with Restrictions and Analyzer Option)
Adam Balogh [Wed, 11 Apr 2018 06:21:12 +0000 (06:21 +0000)]
[Analyzer] SValBuilder Comparison Rearrangement (with Restrictions and Analyzer Option)

Since the range-based constraint manager (default) is weak in handling comparisons where symbols are on both sides it is wise to rearrange them to have symbols only on the left side. Thus e.g. A + n >= B + m becomes A - B >= m - n which enables the constraint manager to store a range m - n .. MAX_VALUE for the symbolic expression A - B. This can be used later to check whether e.g. A + k == B + l can be true, which is also rearranged to A - B == l - k so the constraint manager can check whether l - k is in the range (thus greater than or equal to m - n).

The restriction in this version is the the rearrangement happens only if both the symbols and the concrete integers are within the range [min/4 .. max/4] where min and max are the minimal and maximal values of their type.

The rearrangement is not enabled by default. It has to be enabled by using -analyzer-config aggressive-relational-comparison-simplification=true.

Co-author of this patch is Artem Dergachev (NoQ).

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

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

6 years agoAdding fuzzer flags support to OpenBSD driver
Dean Michael Berris [Wed, 11 Apr 2018 05:40:47 +0000 (05:40 +0000)]
Adding fuzzer flags support to OpenBSD driver

Summary: - Following-up the sanitizer's part commit https://reviews.llvm.org/rCRT329631, we enable fuzzer flags.

Reviewers: brad, thakis, dberris

Reviewed By: dberris

Subscribers: cfe-commits

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

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

6 years ago[X86] Fix typo in intrinsic header file __mask16->__mmask16 from r329775.
Craig Topper [Wed, 11 Apr 2018 05:17:14 +0000 (05:17 +0000)]
[X86] Fix typo in intrinsic header file __mask16->__mmask16 from r329775.

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

6 years ago[X86] Replace 512-bit masked pmaddubsw and pmaddwd intrinsic with unmasked intrinsic...
Craig Topper [Wed, 11 Apr 2018 04:55:10 +0000 (04:55 +0000)]
[X86] Replace 512-bit masked pmaddubsw and pmaddwd intrinsic with unmasked intrinsic and a select.

This makes it consistent with the 128/256-bit functions.

Someday maybe we'll have all the masking moved to selects.

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

6 years ago[XRay][clang] Only enable test for supported platforms
Dean Michael Berris [Wed, 11 Apr 2018 01:47:40 +0000 (01:47 +0000)]
[XRay][clang] Only enable test for supported platforms

This is a follow-up to D45474.

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

6 years ago[XRay][clang+compiler-rt] Support build-time mode selection
Dean Michael Berris [Wed, 11 Apr 2018 01:28:25 +0000 (01:28 +0000)]
[XRay][clang+compiler-rt] Support build-time mode selection

Summary:
This patch implements the `-fxray-modes=` flag which allows users
building with XRay instrumentation to decide which modes to pre-package
into the binary being linked. The default is the status quo, which will
link all the available modes.

For this to work we're also breaking apart the mode implementations
(xray-fdr and xray-basic) from the main xray runtime. This gives more
granular control of which modes are pre-packaged, and picked from
clang's invocation.

This fixes llvm.org/PR37066.

Note that in the future, we may change the default for clang to only
contain the profiling implementation under development in D44620, when
that implementation is ready.

Reviewers: echristo, eizan, chandlerc

Reviewed By: echristo

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

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

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

6 years ago[AST] Fix some Clang-tidy modernize-use-auto and Include What You Use warnings; other...
Eugene Zelenko [Tue, 10 Apr 2018 22:54:42 +0000 (22:54 +0000)]
[AST] Fix some Clang-tidy modernize-use-auto and Include What You Use warnings; other minor fixes (NFC).

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

6 years agoIntroduce a new builtin, __builtin_dump_struct, that is useful for dumping structure...
Aaron Ballman [Tue, 10 Apr 2018 21:58:13 +0000 (21:58 +0000)]
Introduce a new builtin, __builtin_dump_struct, that is useful for dumping structure contents at runtime in circumstances where debuggers may not be easily available (such as in kernel work).

Patch by Paul Semel.

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

6 years agoRevert "Handle the default case"
Petr Hosek [Tue, 10 Apr 2018 21:29:18 +0000 (21:29 +0000)]
Revert "Handle the default case"

This reverts commit r329758.

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

6 years agoHandle the default case
Petr Hosek [Tue, 10 Apr 2018 21:19:05 +0000 (21:19 +0000)]
Handle the default case

This was omitted in D45422 resulting in a warning.

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

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

6 years ago[Driver] Handle the default case missed in r329748.
Chad Rosier [Tue, 10 Apr 2018 20:30:16 +0000 (20:30 +0000)]
[Driver] Handle the default case missed in r329748.

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

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

6 years ago[OPENMP] Additional attributes for the pointer parameters.
Alexey Bataev [Tue, 10 Apr 2018 20:10:53 +0000 (20:10 +0000)]
[OPENMP] Additional attributes for the pointer parameters.

Added attributes for better optimization of the OpenMP code.

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

6 years ago[Driver] Allow drivers to add multiple libc++ include paths
Petr Hosek [Tue, 10 Apr 2018 19:55:55 +0000 (19:55 +0000)]
[Driver] Allow drivers to add multiple libc++ include paths

This allows toolchain drivers to add multiple libc++ include paths akin
to libstdc++. This is useful in multiarch setup when some headers might
be in target specific include directory. There should be no functional
change.

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

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

6 years ago[X86] Split up -march=icelake to -client & -server
Gabor Buella [Tue, 10 Apr 2018 18:58:26 +0000 (18:58 +0000)]
[X86] Split up -march=icelake to -client & -server

Reviewers: craig.topper, zvi, echristo

Reviewed By: craig.topper

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

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

6 years agoRevert r329684 (and follow-ups 329693, 329714). See discussion on https://reviews...
Nico Weber [Tue, 10 Apr 2018 18:53:28 +0000 (18:53 +0000)]
Revert r329684 (and follow-ups 329693, 329714). See discussion on https://reviews.llvm.org/D43578.

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

6 years ago[X86] Add test case for llvm change r329734
Craig Topper [Tue, 10 Apr 2018 18:43:44 +0000 (18:43 +0000)]
[X86] Add test case for llvm change r329734

This test ensures the popfd instruction in MS inline assembly can properly find a clobber name for the dirflag register. Previously the register was named 'DF', but it needs to be named 'dirflag' to match the name in the GCC register name list.

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

6 years ago[CUDA] Added --[no-]cuda-include-ptx=sm_XX|all option.
Artem Belevich [Tue, 10 Apr 2018 18:38:22 +0000 (18:38 +0000)]
[CUDA] Added --[no-]cuda-include-ptx=sm_XX|all option.

Currently we always include PTX into the fatbin along
with the GPU code.It about doubles the size of the GPU binary
we need to carry in the executable. These options allow control
inclusion of PTX into GPU binary.

This patch does not change the defaults, though we may consider
making no-PTX the default in the future.

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

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

6 years ago[Parser] Fix assertion-on-invalid for unexpected typename.
Volodymyr Sapsai [Tue, 10 Apr 2018 18:29:47 +0000 (18:29 +0000)]
[Parser] Fix assertion-on-invalid for unexpected typename.

In `ParseDeclarationSpecifiers` for the code

    class A typename A;

we were able to annotate token `kw_typename` because it refers to
existing type. But later during processing token `annot_typename` we
failed to `SetTypeSpecType` and exited switch statement leaving
annotation token unconsumed. The code after the switch statement failed
because it didn't expect a special token.

The fix is not to assume that switch statement consumes all special
tokens and consume any token, not just non-special.

rdar://problem/37099386

Reviewers: rsmith, arphaman

Reviewed By: rsmith

Subscribers: jkorous-apple, cfe-commits

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

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

6 years agoI removed the failed test.
Andrew V. Tischenko [Tue, 10 Apr 2018 15:45:43 +0000 (15:45 +0000)]
I removed the failed test.

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

6 years ago[X86] Disable SGX for Skylake Server - CPP test
Gabor Buella [Tue, 10 Apr 2018 15:03:03 +0000 (15:03 +0000)]
[X86] Disable SGX for Skylake Server - CPP test

Summary: Fix test case - corresponding to r329701

Reviewers: craig.topper, davezarzycki

Reviewed By: davezarzycki

Subscribers: cfe-commits

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

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

6 years agoAttempt to fix Windows build after r329698.
Nico Weber [Tue, 10 Apr 2018 14:08:25 +0000 (14:08 +0000)]
Attempt to fix Windows build after r329698.

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

6 years ago[X86] Disable SGX for Skylake Server
Gabor Buella [Tue, 10 Apr 2018 14:04:21 +0000 (14:04 +0000)]
[X86] Disable SGX for Skylake Server

Reviewers: craig.topper, zvi, echristo

Reviewed By: craig.topper

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

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

6 years agoUse llvm::sys::fs::real_path() in clang.
Nico Weber [Tue, 10 Apr 2018 13:36:38 +0000 (13:36 +0000)]
Use llvm::sys::fs::real_path() in clang.

No expected behavior change.
https://reviews.llvm.org/D45165

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

6 years agoThe test was fixed.
Andrew V. Tischenko [Tue, 10 Apr 2018 12:17:01 +0000 (12:17 +0000)]
The test was fixed.

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

6 years agoCodeGen tests - typo fixes NFC
Gabor Buella [Tue, 10 Apr 2018 11:20:05 +0000 (11:20 +0000)]
CodeGen tests - typo fixes NFC

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

6 years ago[Tooling] fix UB when interpolating compile commands with an empty index
Sam McCall [Tue, 10 Apr 2018 10:36:46 +0000 (10:36 +0000)]
[Tooling] fix UB when interpolating compile commands with an empty index

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

6 years ago-ftime-report switch support in Clang.
Andrew V. Tischenko [Tue, 10 Apr 2018 10:34:13 +0000 (10:34 +0000)]
-ftime-report switch support in Clang.
The current support of the feature produces only 2 lines in report:
 -Some general Code Generation Time;
 -Total time of Backend Consumer actions.
This patch extends Clang time report with new lines related to Preprocessor, Include Filea Search, Parsing, etc.
Differential Revision: https://reviews.llvm.org/D43578

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

6 years ago[ExprConstant] Use an AST node and a version number as a key to create
Akira Hatanaka [Tue, 10 Apr 2018 05:15:01 +0000 (05:15 +0000)]
[ExprConstant] Use an AST node and a version number as a key to create
an APValue and retrieve it from map Temporaries.

The version number is needed when a single AST node is visited multiple
times and is used to create APValues that are required to be distinct
from each other (for example, MaterializeTemporaryExprs in default
arguments and VarDecls in loops).

rdar://problem/36505742

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

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

6 years ago[AST] Attempt to fix buildbot warnings + appease MSVC; NFCI
George Burgess IV [Tue, 10 Apr 2018 01:11:26 +0000 (01:11 +0000)]
[AST] Attempt to fix buildbot warnings + appease MSVC; NFCI

GCC 4.8.4 on a bot was warning about `ArgPassingKind` not fitting in
`ArgPassingRestrictions`, which appears to be incorrect, since
`ArgPassingKind` only has three potential values:

"warning: 'clang::RecordDecl::ArgPassingRestrictions' is too small to
hold all values of 'enum clang::RecordDecl::ArgPassingKind'"

Additionally, I remember hearing (though my knowledge may be outdated)
that MSVC won't merge adjacent bitfields if their types are different.

Try to fix both issues by turning these into `uint8_t`s.

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

6 years ago[ObjC++] Never pass structs that transitively contain __weak fields in
Akira Hatanaka [Mon, 9 Apr 2018 22:48:22 +0000 (22:48 +0000)]
[ObjC++] Never pass structs that transitively contain __weak fields in
registers.

This patch fixes a bug in r328731 that caused structs transitively
containing __weak fields to be passed in registers. The patch replaces
the flag RecordDecl::CanPassInRegisters with a 2-bit enum that indicates
whether the struct or structs containing the struct are forced to be
passed indirectly.

This reapplies r329617. r329617 didn't specify the underlying type for
enum ArgPassingKind, which caused regression tests to fail on a windows
bot.

rdar://problem/39194693

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

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

6 years ago[AST] Fix some Clang-tidy modernize-use-auto warnings; other minor fixes (NFC).
Eugene Zelenko [Mon, 9 Apr 2018 22:14:10 +0000 (22:14 +0000)]
[AST] Fix some Clang-tidy modernize-use-auto warnings; other minor fixes (NFC).

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

6 years ago[AST] Fix some Clang-tidy modernize and Include What You Use warnings; other minor...
Eugene Zelenko [Mon, 9 Apr 2018 21:54:38 +0000 (21:54 +0000)]
[AST] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).

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

6 years agoRevert "[ObjC++] Never pass structs that transitively contain __weak fields in"
Akira Hatanaka [Mon, 9 Apr 2018 21:47:58 +0000 (21:47 +0000)]
Revert "[ObjC++] Never pass structs that transitively contain __weak fields in"

This reverts commit r329617. It broke a windows bot.

http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/16372/steps/test/logs/stdio

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

6 years ago[ObjC++] Never pass structs that transitively contain __weak fields in
Akira Hatanaka [Mon, 9 Apr 2018 20:39:47 +0000 (20:39 +0000)]
[ObjC++] Never pass structs that transitively contain __weak fields in
registers.

This patch fixes a bug in r328731 that caused structs transitively
containing __weak fields to be passed in registers. The patch replaces
the flag RecordDecl::CanPassInRegisters with a 2-bit enum that indicates
whether the struct or structs containing the struct are forced to be
passed indirectly.

rdar://problem/39194693

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

6 years agoasan: kernel: make no_sanitize("address") attribute work with -fsanitize=kernel-address
Vitaly Buka [Mon, 9 Apr 2018 20:10:29 +0000 (20:10 +0000)]
asan: kernel: make no_sanitize("address") attribute work with -fsanitize=kernel-address

Summary:
Right now to disable -fsanitize=kernel-address instrumentation, one needs to use no_sanitize("kernel-address"). Make either no_sanitize("address") or no_sanitize("kernel-address")  disable both ASan and KASan instrumentation. Also remove redundant test.

Patch by Andrey Konovalov

Reviewers: eugenis, kcc, glider, dvyukov, vitalybuka

Reviewed By: eugenis, vitalybuka

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

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

6 years agoRevert "[ObjC] Make C++ triviality type traits available to non-trivial C"
Akira Hatanaka [Mon, 9 Apr 2018 19:39:27 +0000 (19:39 +0000)]
Revert "[ObjC] Make C++ triviality type traits available to non-trivial C"

This reverts commit r329289.

It was decided that we shouldn't expose the __has_* traits to C since
they are deprecated and useless.

See the discussion here:

http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20180402/thread.html#223921

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

6 years ago[X86] Emit native IR for pmuldq/pmuludq builtins.
Craig Topper [Mon, 9 Apr 2018 19:17:54 +0000 (19:17 +0000)]
[X86] Emit native IR for pmuldq/pmuludq builtins.

I believe all the pieces are now in place in the backend to make this work correctly. We can either mask the input to 32 bits for pmuludg or shl/ashr for pmuldq and use a regular mul instruction. The backend should combine this to PMULUDQ/PMULDQ and then SimplifyDemandedBits will remove the and/shifts.

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

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

6 years ago[CUDA] Revert defining __CUDA_ARCH__ for amdgcn targets
Yaxun Liu [Mon, 9 Apr 2018 15:43:01 +0000 (15:43 +0000)]
[CUDA] Revert defining __CUDA_ARCH__ for amdgcn targets

amdgcn targets only support HIP, which does not define __CUDA_ARCH__.

this is a partial unroll of r329232 / D45277.

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

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

6 years ago[Tooling] A CompilationDatabase wrapper that infers header commands.
Sam McCall [Mon, 9 Apr 2018 15:17:39 +0000 (15:17 +0000)]
[Tooling] A CompilationDatabase wrapper that infers header commands.

Summary:
The wrapper finds the closest matching compile command using filename heuristics
and makes minimal tweaks so it can be used with the header.

Subscribers: klimek, mgorny, cfe-commits

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

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

6 years ago[Index] Return SourceLocation to consumers, not FileID/Offset pair.
Sam McCall [Mon, 9 Apr 2018 14:12:51 +0000 (14:12 +0000)]
[Index] Return SourceLocation to consumers, not FileID/Offset pair.

Summary:
The FileID/Offset conversion is lossy. The code takes the fileLoc, which loses
e.g. the spelling location in some macro cases.
Instead, pass the original SourceLocation which preserves all information, and
update consumers to match current behavior.

This allows us to fix two bugs in clangd that need the spelling location.

Reviewers: akyrtzi, arphaman

Subscribers: ilya-biryukov, ioeric, cfe-commits

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

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

6 years agoTry to fix libclang reproducer tests after r329465
Hans Wennborg [Mon, 9 Apr 2018 12:21:12 +0000 (12:21 +0000)]
Try to fix libclang reproducer tests after r329465

They were failing on Windows because the output YAML didn't parse:

  YAML:1:664: error: Unrecognized escape code!

  {"toolchain":"D:\\buildslave\\clang-x64-ninja-win7\\stage1",
    "libclang.operation":"complete", "libclang.opts":1, "args":["clang",
    "-fno-spell-checking",
    "D:\buildslave\clang-x64-ninja-win7\llvm\tools\clang\test\Index\create-libclang-completion-reproducer.c",
    "-Xclang", "-detailed-preprocessing-record",
    "-fallow-editor-placeholders"],
    "invocation-args":["-code-completion-at=D:\buildslave\clang-x64-ninja-win7\llvm\tools\clang\test\Index\create-libclang-completion-reproducer.c:10:1"],
    "unsaved_file_hashes":[{"name":"D:\\buildslave\\clang-x64-ninja-win7\\llvm\\tools\\clang\\test\\Index\\create-libclang-completion-reproducer.c",
      "md5":"aee23773de90e665992b48209351d70e"}]}

This adds some more escaping to try to make it work.

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

6 years ago[XRay][llvm+clang] Consolidate attribute list files
Dean Michael Berris [Mon, 9 Apr 2018 04:02:09 +0000 (04:02 +0000)]
[XRay][llvm+clang] Consolidate attribute list files

Summary:
This change consolidates the always/never lists that may be provided to
clang to externally control which functions should be XRay instrumented
by imbuing attributes. The files follow the same format as defined in
https://clang.llvm.org/docs/SanitizerSpecialCaseList.html for the
sanitizer blacklist.

We also deprecate the existing `-fxray-instrument-always=` and
`-fxray-instrument-never=` flags, in favour of `-fxray-attr-list=`.

This fixes http://llvm.org/PR34721.

Reviewers: echristo, vlad.tsyrklevich, eugenis

Reviewed By: vlad.tsyrklevich

Subscribers: llvm-commits, cfe-commits

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

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

6 years ago[Sema] Fix PR35832 - Ambiguity accessing anonymous struct/union with multiple bases.
Eric Fiselier [Sun, 8 Apr 2018 06:21:33 +0000 (06:21 +0000)]
[Sema] Fix PR35832 - Ambiguity accessing anonymous struct/union with multiple bases.

Summary:
Currently clang doesn't do qualified lookup when building indirect field decl references. This causes ambiguity when the field is in a base class to which there are multiple valid paths  even though a qualified name is used.

For example:
```
class B {
protected:
 int i;
 union { int j; };
};

class X : public B { };
class Y : public B { };

class Z : public X, public Y {
 int a() { return X::i; } // works
 int b() { return X::j; } // fails
};
```

Reviewers: rsmith, aaron.ballman, rjmccall

Reviewed By: rjmccall

Subscribers: cfe-commits

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

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

6 years agoRevert "[Sema] Fix PR35832 - Ambiguity accessing anonymous struct/union with multiple...
Eric Fiselier [Sun, 8 Apr 2018 06:05:33 +0000 (06:05 +0000)]
Revert "[Sema] Fix PR35832 - Ambiguity accessing anonymous struct/union with multiple bases."

This reverts commit r329519. There are some unaddressed test failures.

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

6 years ago[Sema] Fix PR35832 - Ambiguity accessing anonymous struct/union with multiple bases.
Eric Fiselier [Sun, 8 Apr 2018 05:50:01 +0000 (05:50 +0000)]
[Sema] Fix PR35832 - Ambiguity accessing anonymous struct/union with multiple bases.

Summary:
Currently clang doesn't do qualified lookup when building indirect field decl references. This causes ambiguity when the field is in a base class to which there are multiple valid paths  even though a qualified name is used.

For example:
```
class B {
protected:
 int i;
 union { int j; };
};

class X : public B { };
class Y : public B { };

class Z : public X, public Y {
 int a() { return X::i; } // works
 int b() { return X::j; } // fails
};
```

Reviewers: rsmith, aaron.ballman, rjmccall

Reviewed By: rjmccall

Subscribers: cfe-commits

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

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

6 years ago[Sema] Remove dead code in BuildAnonymousStructUnionMemberReference. NFCI
Eric Fiselier [Sun, 8 Apr 2018 05:12:55 +0000 (05:12 +0000)]
[Sema] Remove dead code in BuildAnonymousStructUnionMemberReference. NFCI

Summary:
This patch cleans up a bunch of dead or unused code in BuildAnonymousStructUnionMemberReference.

The dead code was a branch that built a new CXXThisExpr when we weren't given a base object expression or base variable.
However, BuildAnonymousFoo has only two callers. One of which always builds a base object expression first, the second only calls when the IndirectFieldDecl is not a C++ class member. Even within C this branch seems entirely unused.

I tried diligently to write a test which hit it with no success.

This patch removes the branch and replaces it with an assertion that we were given either a base object expression or a base variable.

Reviewers: rsmith, aaron.ballman, majnemer, rjmccall

Reviewed By: rjmccall

Subscribers: cfe-commits

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

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

6 years ago[Sema] Fix PR22637 - IndirectFieldDecl's discard qualifiers during template instantia...
Eric Fiselier [Sun, 8 Apr 2018 05:11:59 +0000 (05:11 +0000)]
[Sema] Fix PR22637 - IndirectFieldDecl's discard qualifiers during template instantiation.

Summary:
Currently Clang fails to propagate qualifiers from the `CXXThisExpr` to the rebuilt `FieldDecl` for IndirectFieldDecls. For example:

```
template <class T> struct Foo {
  struct { int x; };
  int y;
  void foo() const {
      static_assert(__is_same(int const&, decltype((y))));
      static_assert(__is_same(int const&, decltype((x)))); // assertion fails
  }
};
template struct Foo<int>;
```

The fix is to delegate rebuilding of the MemberExpr to `BuildFieldReferenceExpr` which correctly propagates the qualifiers.

Reviewers: rsmith, lebedev.ri, aaron.ballman, bkramer, rjmccall

Reviewed By: rjmccall

Subscribers: cfe-commits

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

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