]> granicus.if.org Git - clang/log
clang
6 years ago[FrontEnd] Allow overriding the default C/C++ -std via CMake vars
Michal Gorny [Tue, 6 Mar 2018 21:26:28 +0000 (21:26 +0000)]
[FrontEnd] Allow overriding the default C/C++ -std via CMake vars

Provide two new CMake cache variables -- CLANG_DEFAULT_STD_C
and CLANG_DEFAULT_STD_CXX -- that can be used to override the default
C/ObjC and C++/ObjC++ standards appropriately. They can be set to one of
the identifiers from LangStandards.def, or left unset (the default) to
respect the current platform default.

This option is mostly intended for compiler vendors that may wish
to adjust the defaults their compilers are using. For example, Gentoo
planned to use it to set clang and gcc to matching standards, so that
we could maintain as much compatibility between different compilers
as possible.

The code relies on explicit identifiers rather than the string aliases
for simplicity. This saves us from the necessity of parsing aliases at
build-time or adding additional processing at runtime. For the latter
case, it also adds trivial value check -- if incorrect value is passed,
the code simply fails to compile through referencing an undefined
constant.

If the variable is used to redefine the default standard, the explicit
value overrides the special case for PS4. It is done this way mostly
following other kinds of variables where 'platform defaults' are
redefined.

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

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

6 years ago[OPENMP] Fix generation of the unique names for task reduction
Alexey Bataev [Tue, 6 Mar 2018 18:59:43 +0000 (18:59 +0000)]
[OPENMP] Fix generation of the unique names for task reduction
variables.

If the task has reduction construct and this construct for some variable
requires unique threadprivate storage, we may generate different names
for variables used in taskgroup task_reduction clause and in task
  in_reduction clause. Patch fixes this problem.

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

6 years agoTableGen: Give up on exact fixits for diagnostic groups
Nicolai Haehnle [Tue, 6 Mar 2018 17:55:00 +0000 (17:55 +0000)]
TableGen: Give up on exact fixits for diagnostic groups

With recent changes in the TableGen frontend, we no longer have usable
location information for anonymous defs.

Fixes test breakage caused by r326788.

The normal, non-error TableGen output is not affected by this change.

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

6 years ago[clang-format] Improve detection of ObjC for-in statements
Ben Hamilton [Tue, 6 Mar 2018 17:21:42 +0000 (17:21 +0000)]
[clang-format] Improve detection of ObjC for-in statements

Summary:
Previously, clang-format would detect the following as an
Objective-C for-in statement:

  for (int x = in.value(); ...) {}

because the logic only decided a for-loop was definitely *not*
an Objective-C for-in loop after it saw a semicolon or a colon.

To fix this, I delayed the decision of whether this was a for-in
statement until after we found the matching right-paren, at which
point we know if we've seen a semicolon or not.

Test Plan: New tests added. Ran tests with:
  make -j12 FormatTests && ./tools/clang/unittests/Format/FormatTests

Reviewers: krasimir, jolesiak

Reviewed By: jolesiak

Subscribers: djasper, cfe-commits, klimek

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

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

6 years ago[X86] Fix typo in cpuid.h, bit_AVX51SER->bit_AVX512ER.
Craig Topper [Tue, 6 Mar 2018 16:06:44 +0000 (16:06 +0000)]
[X86] Fix typo in cpuid.h, bit_AVX51SER->bit_AVX512ER.

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

6 years ago[clang-format] fix handling of consecutive unary operators
Krasimir Georgiev [Tue, 6 Mar 2018 13:56:28 +0000 (13:56 +0000)]
[clang-format] fix handling of consecutive unary operators

Summary:
Code that used to be formatted as `if (! + object) {` is now formatted as `if (!+object) {`
(we have a particular object in our codebase where unary `operator+` is overloaded to return the underlying value, which in this case is a `bool`)

We still preserve the TypeScript behavior where `!` is a trailing non-null operator. (This is already tested by an existing unit test in `FormatTestJS.cpp`)

It doesn't appear like handling of consecutive unary operators are tested in general, so I added another test for completeness

Patch contributed by @kevinl!

Reviewers: krasimir

Reviewed By: krasimir

Subscribers: klimek, cfe-commits

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

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

6 years ago[analyzer] CStringChecker.cpp: Remove the duplicated check about null dereference...
Henry Wong [Tue, 6 Mar 2018 13:38:42 +0000 (13:38 +0000)]
[analyzer] CStringChecker.cpp: Remove the duplicated check about null dereference on dest-buffer or src-buffer.

Summary: `CheckBufferAccess()` calls `CheckNonNull()`, so there are some calls to `CheckNonNull()` that are useless.

Reviewers: dcoughlin, NoQ, xazax.hun, cfe-commits, george.karpenkov

Reviewed By: NoQ

Subscribers: szepet, rnkovacs, MTC, a.sidorin

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

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

6 years ago[clang-format] Fix documentation for SpaceAfterCStyleCast option
Krasimir Georgiev [Tue, 6 Mar 2018 13:24:01 +0000 (13:24 +0000)]
[clang-format] Fix documentation for SpaceAfterCStyleCast option

Patch contributed by @EricMarti!

Summary: I noticed that the example for SpaceAfterCStyleCast does not match its description. I fixed the example after testing it out.

Reviewers: rsmith, krasimir

Reviewed By: krasimir

Subscribers: klimek, cfe-commits

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

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

6 years ago[Analyzer] More accurate modeling about the increment operator of the operand with...
Henry Wong [Tue, 6 Mar 2018 12:29:09 +0000 (12:29 +0000)]
[Analyzer] More accurate modeling about the increment operator of the operand with type bool.

Summary:
There is a problem with analyzer that a wrong value is given when modeling the increment operator of the operand with type bool. After `rL307604` is applied, a unsigned overflow may occur.

Example:
```
void func() {
  bool b = true;
  // unsigned overflow occur, 2 -> 0 U1b
  b++;
}
```

The use of an operand of type bool with the ++ operators is deprecated but valid untill C++17. And if the operand of the increment operator is of type bool, it is set to true.

This patch includes two parts:

  - If the operand of the increment operator is of type bool or type _Bool, set to true.
  - Modify `BasicValueFactory::getTruthValue()`, use `getIntWidth()` instead `getTypeSize()` and use `unsigned` instead `signed`.

Reviewers: alexshap, NoQ, dcoughlin, george.karpenkov

Reviewed By: NoQ

Subscribers: xazax.hun, szepet, a.sidorin, cfe-commits, MTC

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

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

6 years agoMove test/gcdasyncsemaphorechecker_test.m to a subdirectory
Alexander Kornienko [Tue, 6 Mar 2018 10:40:11 +0000 (10:40 +0000)]
Move test/gcdasyncsemaphorechecker_test.m to a subdirectory

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

6 years agoFix an unused variable warning; NFC
George Burgess IV [Tue, 6 Mar 2018 07:45:11 +0000 (07:45 +0000)]
Fix an unused variable warning; NFC

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

6 years ago[ExprConstant] Look through ExprWithCleanups for `allocsize`
George Burgess IV [Tue, 6 Mar 2018 07:42:36 +0000 (07:42 +0000)]
[ExprConstant] Look through ExprWithCleanups for `allocsize`

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

6 years ago[StaticAnalyzer] Fix some Clang-tidy modernize and Include What You Use warnings...
Eugene Zelenko [Tue, 6 Mar 2018 00:47:41 +0000 (00:47 +0000)]
[StaticAnalyzer] 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@326757 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[analyzer] [quickfix] Prevent a crash in NamedDecl::getName()
George Karpenkov [Tue, 6 Mar 2018 00:18:21 +0000 (00:18 +0000)]
[analyzer] [quickfix] Prevent a crash in NamedDecl::getName()

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

6 years ago[analyzer] AST-matching checker to detect global central dispatch performance anti...
George Karpenkov [Mon, 5 Mar 2018 22:03:32 +0000 (22:03 +0000)]
[analyzer] AST-matching checker to detect global central dispatch performance anti-pattern

rdar://37312818

NB: The checker does not care about the ordering of callbacks, see the
relevant FIXME in tests.

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

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

6 years ago[msvc] Allow MSVC toolchain driver to find the aarch64 / arm64 cross-compiler.
Reid Kleckner [Mon, 5 Mar 2018 21:36:23 +0000 (21:36 +0000)]
[msvc] Allow MSVC toolchain driver to find the aarch64 / arm64 cross-compiler.

Starting with the Fall Creators Update, Windows 10 Desktop can run on
machines that are powered by aarch64 processors.

Microsoft call the aarch64 architecture "arm64". This patch maps
ArchType::aarch64 to "arm64" to allow the MSVC toolchain driver to find
the aarch64 / arm64 cross-compiler.

Patch by Chris January

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

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

6 years agoFix typo in comment.
Richard Smith [Mon, 5 Mar 2018 20:54:34 +0000 (20:54 +0000)]
Fix typo in comment.

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

6 years ago[AMDGPU] Clean up old address space mapping and fix constant address space value
Yaxun Liu [Mon, 5 Mar 2018 17:50:10 +0000 (17:50 +0000)]
[AMDGPU] Clean up old address space mapping and fix constant address space value

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

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

6 years ago[analyzer] Improves the logic of GenericTaintChecker identifying stdin.
Henry Wong [Mon, 5 Mar 2018 15:41:15 +0000 (15:41 +0000)]
[analyzer] Improves the logic of GenericTaintChecker identifying stdin.

Summary:
GenericTaintChecker can't recognize stdin in some cases. The reason is that `if (PtrTy->getPointeeType() == C.getASTContext().getFILEType()` does not hold when stdin is encountered.

My platform is ubuntu16.04 64bit, gcc 5.4.0, glibc 2.23. The definition of stdin is as follows:
```
__BEGIN_NAMESPACE_STD
/* The opaque type of streams.  This is the definition used elsewhere.  */
typedef struct _IO_FILE FILE;
___END_NAMESPACE_STD

  ...

/* The opaque type of streams.  This is the definition used elsewhere.  */
typedef struct _IO_FILE __FILE;

  ...

/* Standard streams.  */
extern struct _IO_FILE *stdin;      /* Standard input stream.  */
extern struct _IO_FILE *stdout;     /* Standard output stream.  */
extern struct _IO_FILE *stderr;     /* Standard error output stream.  */
```

The type of stdin is as follows AST:
```
ElaboratedType 0xc911170'struct _IO_FILE'sugar
`-RecordType 0xc911150'struct _IO_FILE'
 `-CXXRecord 0xc923ff0'_IO_FILE'
```

`C.getASTContext().GetFILEType()` is as follows AST:
```
TypedefType 0xc932710 'FILE' sugar
|-Typedef 0xc9111c0 'FILE'
`-ElaboratedType 0xc911170 'struct _IO_FILE' sugar
  `-RecordType 0xc911150 'struct _IO_FILE'
      `-CXXRecord 0xc923ff0 '_IO_FILE'
```

So I think it's better to use `getCanonicalType()`.

Reviewers: zaks.anna, NoQ, george.karpenkov, a.sidorin

Reviewed By: zaks.anna, a.sidorin

Subscribers: a.sidorin, cfe-commits, xazax.hun, szepet, MTC

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

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

6 years ago[x86][CET] Introduce _get_ssp, _inc_ssp intrinsics
Alexander Ivchenko [Mon, 5 Mar 2018 11:30:28 +0000 (11:30 +0000)]
[x86][CET] Introduce _get_ssp, _inc_ssp intrinsics

Summary:
The _get_ssp intrinsic can be used to retrieve the
shadow stack pointer, independent of the current arch -- in
contract with the rdsspd and the rdsspq intrinsics.
Also, this intrinsic returns zero on CPUs which don't
support CET. The rdssp[d|q] instruction is decoded as nop,
essentially just returning the input operand, which is zero.
Example result of compilation:

```
xorl    %eax, %eax
movl    %eax, %ecx
rdsspq  %rcx         # NOP when CET is not supported
movq    %rcx, %rax   # return zero
```

Reviewers: craig.topper

Subscribers: cfe-commits

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

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

6 years ago[Bash-autocompletion] Fixed formatting
Yuka Takahashi [Mon, 5 Mar 2018 09:01:31 +0000 (09:01 +0000)]
[Bash-autocompletion] Fixed formatting

Fixed a trivial formatting and indent.

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

6 years ago[Bash-autocompletion] Pass all flags in shell command-line to Clang
Yuka Takahashi [Mon, 5 Mar 2018 08:54:20 +0000 (08:54 +0000)]
[Bash-autocompletion] Pass all flags in shell command-line to Clang

Previously, we passed "#" to --autocomplete to indicate to enable cc1
flags. For example, when -cc1 or -Xclang was passed to bash, bash
executed `clang --autocomplete=#-<flag they want to complete>`.

However, this was not a good implementation because it depends -Xclang
and -cc1 parsing to shell. So I changed this to pass all flags shell
has, so that Clang can handle them internally.

I had to change many testcases because API spec changed quite a lot.

Reviewers: teemperor, v.g.vassilev

Subscribers: cfe-commits

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

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

6 years agoAmend r326665 to print out the `used` attribute subjects in a different order.
Aaron Ballman [Sun, 4 Mar 2018 16:24:10 +0000 (16:24 +0000)]
Amend r326665 to print out the `used` attribute subjects in a different order.

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

6 years agoReplace the custom handling for several attributes; NFC.
Aaron Ballman [Sun, 4 Mar 2018 15:32:01 +0000 (15:32 +0000)]
Replace the custom handling for several attributes; NFC.

These attributes were only customized because of the need to check for attribute mutual exclusion, but we now have the handleSimpleAttributeWithExclusions() helper function to handle these scenarios.

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

6 years agoCreate a subject list for the `used` attribute rather than use custom checking logic.
Aaron Ballman [Sat, 3 Mar 2018 21:02:09 +0000 (21:02 +0000)]
Create a subject list for the `used` attribute rather than use custom checking logic.

This changes the diagnostic wording somewhat, but otherwise intends no functional change to the attribute.

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

6 years agoDisable tests of -fsanitize on OpenBSD
Kamil Rytarowski [Sat, 3 Mar 2018 12:28:54 +0000 (12:28 +0000)]
Disable tests of -fsanitize on OpenBSD

This causes failures on buildbots:
/export/users/atombot/llvm/clang-atom-d525-fedora-rel/llvm/tools/clang/test/Driver/fsanitize.c:18:29: error: expected string not found in input
// CHECK-UNDEFINED-OPENBSD: "-fsanitize={{((signed-integer-overflow|integer-divide-by-zero|float-divide-by-zero|shift-base|shift-exponent|unreachable|return|vla-bound|alignment|null|pointer-overflow|float-cast-overflow|array-bounds|enum|bool|builtin|returns-nonnull-attribute|nonnull-attribute),?){18}"}}
                            ^
<stdin>:1:1: note: scanning from here
clang version 7.0.0 (trunk 326648)
^

This will be investigated.

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

6 years agoOpenBSD Driver basic sanitiser support
Kamil Rytarowski [Sat, 3 Mar 2018 11:52:52 +0000 (11:52 +0000)]
OpenBSD Driver basic sanitiser support

Summary:
Basic support of Sanitiser to follow-up ubsan support in compiler-rt.
Needs to use lld instead of base ld to be fully workable.

Patch by: David CARLIER

Reviewers: krytarowski, vitalybuka, kettenis

Reviewed By: vitalybuka

Subscribers: cfe-commits

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

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

6 years agoBetter OpenBSD frontend support
Kamil Rytarowski [Sat, 3 Mar 2018 11:47:27 +0000 (11:47 +0000)]
Better OpenBSD frontend support

Summary:
- Like other *BSD, conditioning certain flags to pass
- To prepare future OpenBSD sanitisers.

Patch by: David CARLIER

Reviewers: dlj, krytarowski, vitalybuka

Reviewed By: vitalybuka

Subscribers: krytarowski, cfe-commits

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

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

6 years agoDo not generate calls to fentry with __attribute__((no_instrument_function))
Manoj Gupta [Fri, 2 Mar 2018 23:52:44 +0000 (23:52 +0000)]
Do not generate calls to fentry with __attribute__((no_instrument_function))

Summary:
Currently only calls to mcount were suppressed with
no_instrument_function attribute.
Linux kernel requires that calls to fentry should also not be
generated.
This is an extended fix for PR PR33515.

Reviewers: hfinkel, rengolin, srhines, rnk, rsmith, rjmccall, hans

Reviewed By: rjmccall

Subscribers: cfe-commits

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

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

6 years ago[StaticAnalyzer] Fix some Clang-tidy modernize and Include What You Use warnings...
Eugene Zelenko [Fri, 2 Mar 2018 23:11:49 +0000 (23:11 +0000)]
[StaticAnalyzer] 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@326633 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoPR36581: Support data recursion over Stmts in AST matchers.
Richard Smith [Fri, 2 Mar 2018 21:55:03 +0000 (21:55 +0000)]
PR36581: Support data recursion over Stmts in AST matchers.

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

6 years agoRemove -i command line option, add -imultilib
Erich Keane [Fri, 2 Mar 2018 21:53:25 +0000 (21:53 +0000)]
Remove -i command line option, add -imultilib

I discovered that '-i' is a command line option for the driver,
however it actually does not do anything and is not supported by any
other compiler. In fact, it is completely undocumented for Clang.

I found a couple of instances of people confusing it with one of
the variety of other command line options that control the driver.
Because of this, we should delete this option so that it is clear
that it isn't valid.

HOWEVER, I found that GCC DOES support -imultilib, which the -i
was hiding our lack of support for. We currently only use imultilib
for the purpose of forwarding to gfortran (in a specific test written
  by chandlerc for this purpose).

  imultilib is a rarely used (if ever?) feature that I could find no
  references to on the internet, and in fact, my company's massive test
  suite has zero references to it ever being used.

  SO, this patch removes the -i option so that we will now give an error
  on its usage (so that it won't be confused with -I), and replaces it with
  -imultilib, which is now specified as a gfortran_group option.

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

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

6 years agoDon't claim that va_start has special semantic checks
Reid Kleckner [Fri, 2 Mar 2018 21:41:08 +0000 (21:41 +0000)]
Don't claim that va_start has special semantic checks

We don't have special checks for BI_va_start in
Sema::CheckBuiltinFunctionCall, so setting the 't' flag for va_start in
Builtins.def disables semantic checking for it. That's not desired, and
IRGen crashes when it tries to generate a call to va_start that doesn't
have at least one argument.

Follow-up to r322573

Fixes PR36565

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

6 years ago[analyzer] Don't throw NSNumberObjectConversion warning on object initialization...
George Karpenkov [Fri, 2 Mar 2018 21:34:24 +0000 (21:34 +0000)]
[analyzer] Don't throw NSNumberObjectConversion warning on object initialization in if-expression

```
if (NSNumber* x = ...)
```
is a reasonable pattern in objc++, we should not warn on it.

rdar://35152234

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

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

6 years agoRange-ify a for loop. NFC
George Burgess IV [Fri, 2 Mar 2018 20:10:38 +0000 (20:10 +0000)]
Range-ify a for loop. NFC

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

6 years agoFix the hasType() AST matcher to not assert when the QualType is invalid.
Aaron Ballman [Fri, 2 Mar 2018 19:14:21 +0000 (19:14 +0000)]
Fix the hasType() AST matcher to not assert when the QualType is invalid.

There's not a particularly good way to test this with the AST matchers unit tests because the only way to get an invalid type (that I can devise) involves creating parse errors, which the test harness always treats as a failure. Instead, a clang-tidy test case will be added in a follow-up commit based on the original bug report.

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

6 years ago[Attr] Use -fsyntax-only in test
Joel E. Denny [Fri, 2 Mar 2018 19:03:27 +0000 (19:03 +0000)]
[Attr] Use -fsyntax-only in test

Suggested at: https://reviews.llvm.org/D43248

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

6 years ago[Attr] Fix parameter indexing for several attributes
Joel E. Denny [Fri, 2 Mar 2018 19:03:22 +0000 (19:03 +0000)]
[Attr] Fix parameter indexing for several attributes

The patch fixes a number of bugs related to parameter indexing in
attributes:

* Parameter indices in some attributes (argument_with_type_tag,
  pointer_with_type_tag, nonnull, ownership_takes, ownership_holds,
  and ownership_returns) are specified in source as one-origin
  including any C++ implicit this parameter, were stored as
  zero-origin excluding any this parameter, and were erroneously
  printing (-ast-print) and confusingly dumping (-ast-dump) as the
  stored values.

* For alloc_size, the C++ implicit this parameter was not subtracted
  correctly in Sema, leading to assert failures or to silent failures
  of __builtin_object_size to compute a value.

* For argument_with_type_tag, pointer_with_type_tag, and
  ownership_returns, the C++ implicit this parameter was not added
  back to parameter indices in some diagnostics.

This patch fixes the above bugs and aims to prevent similar bugs in
the future by introducing careful mechanisms for handling parameter
indices in attributes.  ParamIdx stores a parameter index and is
designed to hide the stored encoding while providing accessors that
require each use (such as printing) to make explicit the encoding that
is needed.  Attribute declarations declare parameter index arguments
as [Variadic]ParamIdxArgument, which are exposed as ParamIdx[*].  This
patch rewrites all attribute arguments that are processed by
checkFunctionOrMethodParameterIndex in SemaDeclAttr.cpp to be declared
as [Variadic]ParamIdxArgument.  The only exception is xray_log_args's
argument, which is encoded as a count not an index.

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

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

6 years ago[OPENMP] Scan all redeclarations looking for `declare simd` attribute.
Alexey Bataev [Fri, 2 Mar 2018 18:07:00 +0000 (18:07 +0000)]
[OPENMP] Scan all redeclarations looking for `declare simd` attribute.

Patch fixes the problem with the functions marked as `declare simd`. If
the canonical declaration does not have associated `declare simd`
construct, we may not generate required code even if other
redeclarations are marked as `declare simd`.

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

6 years ago[OPENMP] Treat local variables in CUDA mode as thread local.
Alexey Bataev [Fri, 2 Mar 2018 17:17:12 +0000 (17:17 +0000)]
[OPENMP] Treat local variables in CUDA mode as thread local.

In CUDA mode all local variables are actually thread
local|threadprivate, not private, and, thus, they cannot be shared
between threads|lanes.

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

6 years agoAdd possibility to specify output stream for CompilerInstance
Alexey Sotkin [Fri, 2 Mar 2018 12:11:40 +0000 (12:11 +0000)]
Add possibility to specify output stream for CompilerInstance

Patch by: krisb

Reviewers: teemperor

Reviewed By: teemperor

Subscribers: klimek, mgorny, cfe-commits

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

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

6 years ago[Sema] Improve test coverage of narrowing conversion diagnostics
Mikhail Maltsev [Fri, 2 Mar 2018 10:03:02 +0000 (10:03 +0000)]
[Sema] Improve test coverage of narrowing conversion diagnostics

Summary:
This patch adds tests of narrowing conversion diagnostics for the
'unscoped enum -> integer' case.

Reviewers: faisalv, rsmith, rogfer01

Reviewed By: rogfer01

Subscribers: cfe-commits, rogfer01

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

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

6 years ago[Frontend] Avoid including default system header paths on Fuchsia
Petr Hosek [Fri, 2 Mar 2018 07:19:42 +0000 (07:19 +0000)]
[Frontend] Avoid including default system header paths on Fuchsia

These paths aren't used and don't make sense on Fuchsia.

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

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

6 years agoRemove debugging code I accidentally committed in r326530.
Akira Hatanaka [Fri, 2 Mar 2018 02:03:21 +0000 (02:03 +0000)]
Remove debugging code I accidentally committed in r326530.

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

6 years agoAdd an option to disable tail-call optimization for escaping blocks.
Akira Hatanaka [Fri, 2 Mar 2018 01:53:15 +0000 (01:53 +0000)]
Add an option to disable tail-call optimization for escaping blocks.

This makes it easier to debug crashes and hangs in block functions since
users can easily find out where the block is called from. The option
doesn't disable tail-calls from non-escaping blocks since non-escaping
blocks are not as hard to debug as escaping blocks.

rdar://problem/35758207

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

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

6 years ago[analyzer] [tests] Again, make tests more resilient to changes in exploration strategy
George Karpenkov [Fri, 2 Mar 2018 01:41:19 +0000 (01:41 +0000)]
[analyzer] [tests] Again, make tests more resilient to changes in exploration strategy

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

6 years agoAlways set dso_local in CodeGenModule::setDSOLocal.
Rafael Espindola [Fri, 2 Mar 2018 01:29:51 +0000 (01:29 +0000)]
Always set dso_local in CodeGenModule::setDSOLocal.

This shouldn't change any results for now, but is more consistent with
how we set dllimport/dllexport and will make future changes easier.

Since clang produces IR as it parses, it can find out mid file that
something is dllimport. When that happens we have to drop
dso_local. This is not a problem right now because
CodeGenModule::setDSOLocal is called from relatively few places at
the moment.

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

6 years ago[analyzer] Prevent crashing in NonNullParamChecker
George Karpenkov [Fri, 2 Mar 2018 00:55:59 +0000 (00:55 +0000)]
[analyzer] Prevent crashing in NonNullParamChecker

https://bugs.llvm.org/show_bug.cgi?id=36381
rdar://37543426

Turns out, the type passed for the lambda capture was incorrect.
One more argument to abandon the getSVal overload which does not require the
type information.

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

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

6 years ago[StaticAnalyzer] Fix some Clang-tidy modernize and Include What You Use warnings...
Eugene Zelenko [Fri, 2 Mar 2018 00:54:51 +0000 (00:54 +0000)]
[StaticAnalyzer] 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@326519 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[analyzer] [NFC] [tests] Make test more resilient to changes in exploration strategy
George Karpenkov [Fri, 2 Mar 2018 00:54:05 +0000 (00:54 +0000)]
[analyzer] [NFC] [tests] Make test more resilient to changes in exploration strategy

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

6 years ago[WebAssembly] Add exception handling option
Heejin Ahn [Fri, 2 Mar 2018 00:39:16 +0000 (00:39 +0000)]
[WebAssembly] Add exception handling option

Summary: Add exception handling option to clang.

Reviewers: dschuff

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

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

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

6 years ago[NFC] Move CommentOpts checks to the call sites that depend on it. (Re-applying r326501.)
David L. Jones [Fri, 2 Mar 2018 00:07:45 +0000 (00:07 +0000)]
[NFC] Move CommentOpts checks to the call sites that depend on it. (Re-applying r326501.)

When parsing comments, for example, for -Wdocumentation, slightly different
behaviour occurs when -fparse-all-comments is specified. However, these
differences are subtle:

1. All comments are saved during parsing, regardless of whether they are doc
   comments or not.
2. "Maybe-doc" comments, like <, !, etc, are saved as such, instead of marking
   them as ordinary comments. The maybe-doc type of comment is never saved
   otherwise. (Warning on these is the impetus of -Wdocumentation.)
3. All comments are treated as doc comments in ASTContext, even if they are ordinary.

This change moves the logic for checking CommentOptions.ParseAllComments closer
to where it has an effect. The overall logic is unchanged, but checks of the
ParseAllComments flag are now done where the effect will be clearer.

Subscribers: cfe-commits

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

6 years agoRevert r326501 due to buildbot breakage.
David L. Jones [Thu, 1 Mar 2018 23:14:00 +0000 (23:14 +0000)]
Revert r326501 due to buildbot breakage.

Original change:

[NFC] Move CommentOpts checks to the call sites that depend on it.

When parsing comments, for example, for -Wdocumentation, slightly different
behaviour occurs when -fparse-all-comments is specified. However, these
differences are subtle:

1. All comments are saved during parsing, regardless of whether they are doc comments or not.
2. "Maybe-doc" comments, like //<, //!, etc, are saved as such, instead of marking them as ordinary comments. The maybe-doc type of comment is never saved otherwise. (Warning on these is the impetus of -Wdocumentation.)
3. All comments are treated as doc comments in ASTContext, even if they are ordinary.

This change moves the logic for checking CommentOptions.ParseAllComments closer
to where it has an effect. The overall logic is unchanged, but checks of the
ParseAllComments flag are now done where the effect will be clearer.

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

6 years ago[NFC] Move CommentOpts checks to the call sites that depend on it.
David L. Jones [Thu, 1 Mar 2018 22:41:53 +0000 (22:41 +0000)]
[NFC] Move CommentOpts checks to the call sites that depend on it.

When parsing comments, for example, for -Wdocumentation, slightly different
behaviour occurs when -fparse-all-comments is specified. However, these
differences are subtle:

 1. All comments are saved during parsing, regardless of whether they are doc
    comments or not.
 2. "Maybe-doc" comments, like //<, //!, etc, are saved as such, instead of
    marking them as ordinary comments. The maybe-doc type of comment is never
    saved otherwise. (Warning on these is the impetus of -Wdocumentation.)
 3. All comments are treated as doc comments in ASTContext, even if they are
    ordinary.

This change moves the logic for checking CommentOptions.ParseAllComments closer
to where it has an effect. The overall logic is unchanged, but checks of the
ParseAllComments flag are now done where the effect will be clearer.

Reviewers: rsmith

Subscribers: cfe-commits

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

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

6 years ago[Driver] Pass -f[no-]emulated-tls and set up ExplicitEmulatedTLS
Chih-Hung Hsieh [Thu, 1 Mar 2018 22:26:19 +0000 (22:26 +0000)]
[Driver] Pass -f[no-]emulated-tls and set up ExplicitEmulatedTLS

Since LLVM r326341, default EmulatedTLS mode is decided in backend
according to target triple. Any front-end should pass -f[no]-emulated-tls
to backend and set up ExplicitEmulatedTLS only when the flags are used.

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

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

6 years ago[modules] Don't diagnose "redefinition" of a friend with a pending definition
Richard Smith [Thu, 1 Mar 2018 22:20:13 +0000 (22:20 +0000)]
[modules] Don't diagnose "redefinition" of a friend with a pending definition
if the other definition is a merged copy of the same function.

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

6 years ago[www] Capitalize "Clang" when referring to the project, and generalize the
Richard Smith [Thu, 1 Mar 2018 22:01:06 +0000 (22:01 +0000)]
[www] Capitalize "Clang" when referring to the project, and generalize the
introduction on the front page page.

We still use the lowercase "clang" spelling when referring to the driver binary.

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

6 years ago[RecordLayout] Only assert that fundamental type sizes are power of two on MSVC
Martin Storsjo [Thu, 1 Mar 2018 20:22:57 +0000 (20:22 +0000)]
[RecordLayout] Only assert that fundamental type sizes are power of two on MSVC

Make types with sizes that aren't a power of two an error (that can
be disabled) in structs with ms_struct layout, except on mingw where
the situation is quite likely to occur and GCC handles it silently.

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

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

6 years agoDriver: hoist `-fno-rtti-data` to a driver flag
Saleem Abdulrasool [Thu, 1 Mar 2018 19:13:43 +0000 (19:13 +0000)]
Driver: hoist `-fno-rtti-data` to a driver flag

This is needed for building with the GNU driver (`clang++`) when
targeting Windows and using msvcprt.  This flag is the equivalent of
`/GR-`.

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

6 years ago[analyzer] Enable cfg-temporary-dtors by default.
Artem Dergachev [Thu, 1 Mar 2018 18:53:13 +0000 (18:53 +0000)]
[analyzer] Enable cfg-temporary-dtors by default.

Don't enable c++-temp-dtor-inlining by default yet, due to this reference
counting pointe problem.

Otherwise the new mode seems stable and allows us to incrementally fix C++
problems in much less hacky ways.

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

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

6 years agoResubmit [analyzer] Support for naive cross translation unit analysis
Ilya Biryukov [Thu, 1 Mar 2018 14:54:16 +0000 (14:54 +0000)]
Resubmit [analyzer] Support for naive cross translation unit analysis

Originally submitted as r326323 and r326324.
Reverted in r326432.

Reverting the commit was a mistake.
The breakage was due to invalid build files in our internal buildsystem,
CMakeLists did not have any cyclic dependencies.

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

6 years agoUsersManual: improve the clang-cl text some more
Hans Wennborg [Thu, 1 Mar 2018 14:48:19 +0000 (14:48 +0000)]
UsersManual: improve the clang-cl text some more

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

6 years agoUsersManual: beef up the clang-cl text a little
Hans Wennborg [Thu, 1 Mar 2018 14:00:19 +0000 (14:00 +0000)]
UsersManual: beef up the clang-cl text a little

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

6 years agoRevert "[analyzer] Support for naive cross translation unit analysis"
Ilya Biryukov [Thu, 1 Mar 2018 12:43:39 +0000 (12:43 +0000)]
Revert "[analyzer] Support for naive cross translation unit analysis"

Also revert "[analyzer] Fix a compiler warning"
This reverts commits r326323 and r326324.

Reason: the commits introduced a cyclic dependency in the build graph.
This happens to work with cmake, but breaks out internal integrate.

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

6 years ago[clang-format] Add SpaceBeforeColon option
Francois Ferrand [Thu, 1 Mar 2018 10:09:13 +0000 (10:09 +0000)]
[clang-format] Add SpaceBeforeColon option

Summary:
When disabled, this option allows removing the space before colon,
making it act more like the semi-colon. When enabled (default), the
current behavior is not affected.

This mostly affects C++11 loop, initializer list, inheritance list and
container literals:

  class Foo: Bar {}
  Foo::Foo(): a(a) {}
  for (auto i: myList) {}
  f({a: 1, b: 2, c: 3});

Reviewers: krasimir, djasper

Reviewed By: djasper

Subscribers: xvallspl, teemperor, karies, cfe-commits, klimek

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

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

6 years agoFunction definition may have uninstantiated body
Serge Pavlov [Thu, 1 Mar 2018 07:04:11 +0000 (07:04 +0000)]
Function definition may have uninstantiated body

Current implementation of `FunctionDecl::isDefined` does not take into
account redeclarations that do not have bodies, but the bodies can be
instantiated from corresponding templated definition. This behavior does
not allow to detect function redefinition in the cases where friend
functions is defined in class templates. For instance, the code:
```
    template<typename T> struct X { friend void f() {} };
    X<int> xi;
    void f() {}
```
compiles successfully but must fail due to redefinition of `f`. The
declaration of the friend `f` is created when the containing template
`X` is instantiated, but it does not have a body as per 14.5.4p4
because `f` is not odr-used.

With this change the function `Sema::CheckForFunctionRedefinition`
considers functions with uninstantiated bodies as definitions.

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

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

6 years agoRemove redundant casts. NFC
George Burgess IV [Thu, 1 Mar 2018 05:43:23 +0000 (05:43 +0000)]
Remove redundant casts. NFC

So I wrote a clang-tidy check to lint out redundant `isa`, `cast`, and
`dyn_cast`s for fun. This is a portion of what it found for clang; I
plan to do similar cleanups in LLVM and other subprojects when I find
time.

Because of the volume of changes, I explicitly avoided making any change
that wasn't highly local and obviously correct to me (e.g. we still have
a number of foo(cast<Bar>(baz)) that I didn't touch, since overloading
is a thing and the cast<Bar> did actually change the type -- just up the
class hierarchy).

I also tried to leave the types we were cast<>ing to somewhere nearby,
in cases where it wasn't locally obvious what we were dealing with
before.

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

6 years ago[analyzer] [tests] Create a directory for the log file
George Karpenkov [Thu, 1 Mar 2018 02:18:54 +0000 (02:18 +0000)]
[analyzer] [tests] Create a directory for the log file

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

6 years ago[analyzer] Add a checker for mmap()s which are both writable and executable.
Artem Dergachev [Thu, 1 Mar 2018 01:27:46 +0000 (01:27 +0000)]
[analyzer] Add a checker for mmap()s which are both writable and executable.

This is a security check that warns when both PROT_WRITE and PROT_EXEC are
set during mmap(). If mmap()ed memory is both writable and executable, it makes
it easier for the attacker to execute arbitrary code when contents of this
memory are compromised. Some applications require such mmap()s though, such as
different sorts of JIT.

Re-applied after a revert in r324167.

Temporarily stays in the alpha package because it needs a better way of
determining macro values that are not immediately available in the AST.

Patch by David Carlier!

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

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

6 years ago[CFG] [analyzer] Recall that we only skip NoOp casts in construction contexts.
Artem Dergachev [Thu, 1 Mar 2018 01:09:24 +0000 (01:09 +0000)]
[CFG] [analyzer] Recall that we only skip NoOp casts in construction contexts.

For now. We should also add support for ConstructorConversion casts as presented
in the attached test case, but this requires more changes because AST around
them seems different.

The check was originally present but was accidentally lost during r326021.

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

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

6 years agoStart setting dllimport/dllexport in setGVProperties.
Rafael Espindola [Thu, 1 Mar 2018 00:35:47 +0000 (00:35 +0000)]
Start setting dllimport/dllexport in setGVProperties.

This is the next step in setting dso_local for COFF.

The patches changes setGVProperties to first set dllimport/dllexport
and changes a few cases that were setting dllimport/dllexport
manually. With this a few more GVs are marked dso_local.

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

6 years agoPass a GlobalDecl to SetCommonAttributes. NFC.
Rafael Espindola [Thu, 1 Mar 2018 00:06:55 +0000 (00:06 +0000)]
Pass a GlobalDecl to SetCommonAttributes. NFC.

Part of D43900.

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

6 years agoInline a trivial function. NFC.
Rafael Espindola [Thu, 1 Mar 2018 00:00:02 +0000 (00:00 +0000)]
Inline a trivial function. NFC.

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

6 years agoPass a GlobalDecl to setNonAliasAttributes. NFC.
Rafael Espindola [Wed, 28 Feb 2018 23:54:23 +0000 (23:54 +0000)]
Pass a GlobalDecl to setNonAliasAttributes. NFC.

Also part of D43900.

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

6 years agoPass a GlobalDecl to SetInternalFunctionAttributes. NFC.
Rafael Espindola [Wed, 28 Feb 2018 23:46:35 +0000 (23:46 +0000)]
Pass a GlobalDecl to SetInternalFunctionAttributes. NFC.

This just reduces the noise in a followup patch.

Part of D43900.

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

6 years ago[hwasan] update the asm snippet in the docs to match the current default behaviour
Kostya Serebryany [Wed, 28 Feb 2018 21:58:19 +0000 (21:58 +0000)]
[hwasan] update the asm snippet in the docs to match the current default behaviour

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

6 years agoAttempt to fix cl-include.c on Windows.
Nico Weber [Wed, 28 Feb 2018 20:58:06 +0000 (20:58 +0000)]
Attempt to fix cl-include.c on Windows.

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

6 years ago[OpenMP] Extend NVPTX SPMD implementation of combined constructs
Carlo Bertolli [Wed, 28 Feb 2018 20:48:35 +0000 (20:48 +0000)]
[OpenMP] Extend NVPTX SPMD implementation of combined constructs

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

This patch extends the SPMD implementation to all target constructs and guards this implementation under a new flag.

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

6 years ago[Hexagon] Add -ffixed-r19 driver option and translate it to +reserved-r19
Krzysztof Parzyszek [Wed, 28 Feb 2018 20:31:55 +0000 (20:31 +0000)]
[Hexagon] Add -ffixed-r19 driver option and translate it to +reserved-r19

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

6 years agoCodeGenObjCXX: handle inalloca appropriately for msgSend variant
Saleem Abdulrasool [Wed, 28 Feb 2018 20:16:12 +0000 (20:16 +0000)]
CodeGenObjCXX: handle inalloca appropriately for msgSend variant

objc_msgSend_stret takes a hidden parameter for the returned structure's
address for the construction.  When the function signature is rewritten
for the inalloca passing, the return type is no longer marked as
indirect but rather inalloca stret.  This enhances the test for the
indirect return to check for that case as well.  This fixes the
incorrect return classification for Windows x86.

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

6 years ago[clang-cl] Implement /X
Nico Weber [Wed, 28 Feb 2018 19:49:07 +0000 (19:49 +0000)]
[clang-cl] Implement /X

/X makes cl stop looking in %INCLUDE%. Implement this for clang-cl.

As it turns out, the return in ToolChains/MSVC.cpp, AddClangSystemIncludeArgs()
for -nostdlibinc is already in the right place (but -nostdlibinc isn't exposed
by clang-cl), so just alias /X to that.

https://reviews.llvm.org/D43888

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

6 years agoFix gcc -Wreturn-type warnings after r326307.
Nico Weber [Wed, 28 Feb 2018 19:28:47 +0000 (19:28 +0000)]
Fix gcc -Wreturn-type warnings after r326307.

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

6 years ago[CUDA] Include single GPU binary, NFCI.
Jonas Hahnfeld [Wed, 28 Feb 2018 17:53:46 +0000 (17:53 +0000)]
[CUDA] Include single GPU binary, NFCI.

Binaries for multiple architectures are combined by fatbinary,
so the current code was effectively not needed.

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

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

6 years agoTest commit access: apply clang-format suggestion
Joel E. Denny [Wed, 28 Feb 2018 16:57:33 +0000 (16:57 +0000)]
Test commit access: apply clang-format suggestion

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

6 years ago[analyzer] Fix a compiler warning
Gabor Horvath [Wed, 28 Feb 2018 14:01:48 +0000 (14:01 +0000)]
[analyzer] Fix a compiler warning

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

6 years ago[analyzer] Support for naive cross translation unit analysis
Gabor Horvath [Wed, 28 Feb 2018 13:23:10 +0000 (13:23 +0000)]
[analyzer] Support for naive cross translation unit analysis

The aim of this patch is to be minimal to enable incremental development of
the feature on the top of the tree. This patch should be an NFC when the
feature is turned off. It is turned off by default and still considered as
experimental.

Technical details are available in the EuroLLVM Talk:
http://llvm.org/devmtg/2017-03//2017/02/20/accepted-sessions.html#7

Note that the initial prototype was done by A. Sidorin et al.: http://lists.llvm.org/pipermail/cfe-dev/2015-October/045730.html

Contributions to the measurements and the new version of the code: Peter Szecsi, Zoltan Gera, Daniel Krupp, Kareem Khazem.

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

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

6 years ago[ObjC] Allow declaring __strong pointer fields in structs in Objective-C
Akira Hatanaka [Wed, 28 Feb 2018 07:15:55 +0000 (07:15 +0000)]
[ObjC] Allow declaring __strong pointer fields in structs in Objective-C
ARC mode.

Declaring __strong pointer fields in structs was not allowed in
Objective-C ARC until now because that would make the struct non-trivial
to default-initialize, copy/move, and destroy, which is not something C
was designed to do. This patch lifts that restriction.

Special functions for non-trivial C structs are synthesized that are
needed to default-initialize, copy/move, and destroy the structs and
manage the ownership of the objects the __strong pointer fields point
to. Non-trivial structs passed to functions are destructed in the callee
function.

rdar://problem/33599681

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

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

6 years agoFix a couple of cases where we would fail to correctly parse deduced class template...
Richard Smith [Wed, 28 Feb 2018 03:02:23 +0000 (03:02 +0000)]
Fix a couple of cases where we would fail to correctly parse deduced class template specialization types.

Specifically, we would not properly parse these types within template arguments
(for non-type template parameters), and in tentative parses. Fixing both of
these essentially requires that we parse deduced template specialization types
as types in all contexts, even in template argument lists -- in particular,
tentative parsing may look ahead and annotate a deduced template specialization
type before we figure out that we're actually supposed to treat the tokens as a
template-name. We deal with this by simply permitting deduced template
specialization types when parsing template arguments, and converting them to
template template arguments.

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

6 years agoUpdate cxx_status to mark "SVN" items as "Clang 6" instead.
Richard Smith [Wed, 28 Feb 2018 03:02:07 +0000 (03:02 +0000)]
Update cxx_status to mark "SVN" items as "Clang 6" instead.

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

6 years ago[analyzer] [tests] Write to logfile instead of stdout while updating
George Karpenkov [Wed, 28 Feb 2018 01:55:23 +0000 (01:55 +0000)]
[analyzer] [tests] Write to logfile instead of stdout while updating

reference results

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

6 years ago[StaticAnalyzer] Fix some Clang-tidy modernize and Include What You Use warnings...
Eugene Zelenko [Wed, 28 Feb 2018 01:10:04 +0000 (01:10 +0000)]
[StaticAnalyzer] 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@326292 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoAMDGPU: Move run and check lines around to match processor order in AMDGPU.h
Konstantin Zhuravlyov [Wed, 28 Feb 2018 00:27:00 +0000 (00:27 +0000)]
AMDGPU: Move run and check lines around to match processor order in AMDGPU.h

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

6 years agoInline trivial function. NFC.
Rafael Espindola [Wed, 28 Feb 2018 00:14:18 +0000 (00:14 +0000)]
Inline trivial function. NFC.

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

6 years agoPass a GlobalDecl to setAliasAttributes. NFC.
Rafael Espindola [Wed, 28 Feb 2018 00:06:01 +0000 (00:06 +0000)]
Pass a GlobalDecl to setAliasAttributes. NFC.

This just makes a followup change easier to read.

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

6 years agoImprove the way attribute argument printing happens for omitted optional arguments...
Aaron Ballman [Tue, 27 Feb 2018 23:49:28 +0000 (23:49 +0000)]
Improve the way attribute argument printing happens for omitted optional arguments when pretty printing.

Patch by Joel Denny.

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

6 years agoPass a GlobalDecl to setFunctionDefinitionAttributes. NFC.
Rafael Espindola [Tue, 27 Feb 2018 23:44:36 +0000 (23:44 +0000)]
Pass a GlobalDecl to setFunctionDefinitionAttributes. NFC.

This just makes a followup patch easier to read.

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

6 years ago[analyzer] UndefinedAssignmentChecker: Better warning message in implicit ctors.
Artem Dergachev [Tue, 27 Feb 2018 22:05:55 +0000 (22:05 +0000)]
[analyzer] UndefinedAssignmentChecker: Better warning message in implicit ctors.

When a class forgets to initialize a field in the constructor, and then gets
copied around, a warning is emitted that the value assigned to a specific field
is undefined.

When the copy/move constructor is implicit (not written out in the code) but not
trivial (is not a trivial memory copy, eg. because members have an explicit copy
constructor), the body of such constructor is auto-generated in the AST.
In this case the checker's warning message is squeezed at the top of
the class declaration, and it gets hard to guess which field is at fault.

Fix the warning message to include the name of the field.

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

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

6 years agoAMDGPU: Define FP_FAST_FMA{F} macros for amdgcn
Konstantin Zhuravlyov [Tue, 27 Feb 2018 21:48:05 +0000 (21:48 +0000)]
AMDGPU: Define FP_FAST_FMA{F} macros for amdgcn

- Expand GK_*s (i.e. GFX6 -> GFX600, GFX601, etc.)
  - This allows us to choose features correctly in some cases (for example, fast fmaf is available on gfx600, but not gfx601)
- Move HasFMAF, HasFP64, HasLDEXPF to GPUInfo tables
- Add HasFastFMA, HasFastFMAF to GPUInfo tables
- Add missing tests

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

6 years ago[OPENMP] Emit warning for non-trivial types in map clauses.
Alexey Bataev [Tue, 27 Feb 2018 21:31:11 +0000 (21:31 +0000)]
[OPENMP] Emit warning for non-trivial types in map clauses.

If the mapped type is non-trivial, the warning message is emitted for
better user experience.

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

6 years ago[analyzer] MallocChecker: Suppress false positives in shared pointers.
Artem Dergachev [Tue, 27 Feb 2018 21:19:33 +0000 (21:19 +0000)]
[analyzer] MallocChecker: Suppress false positives in shared pointers.

Throw away MallocChecker warnings that occur after releasing a pointer within a
destructor (or its callees) after performing C11 atomic fetch_add or fetch_sub
within that destructor (or its callees).

This is an indication that the destructor's class is likely a
reference-counting pointer. The analyzer is not able to understand that the
original reference count is usually large enough to avoid most use-after-frees.

Even when the smart pointer is a local variable, we still have these false
positives that this patch suppresses, because the analyzer doesn't currently
support atomics well enough.

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

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