Commit Graph

72534 Commits

Author SHA1 Message Date
Alexey Bataev 1c44e15f6d [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.

llvm-svn: 326827
2018-03-06 18:59:43 +00:00
Nicolai Haehnle 846e578e71 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.

llvm-svn: 326822
2018-03-06 17:55:00 +00:00
Ben Hamilton 1d6c6ee1cf [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

llvm-svn: 326815
2018-03-06 17:21:42 +00:00
Craig Topper 260ed8647a [X86] Fix typo in cpuid.h, bit_AVX51SER->bit_AVX512ER.
llvm-svn: 326807
2018-03-06 16:06:44 +00:00
Krasimir Georgiev 446d6ec996 [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

llvm-svn: 326792
2018-03-06 13:56:28 +00:00
Henry Wong 945a84a03c [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

llvm-svn: 326782
2018-03-06 13:38:42 +00:00
Krasimir Georgiev c5be6aff54 [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

llvm-svn: 326781
2018-03-06 13:24:01 +00:00
Henry Wong e47b89d1f8 [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

llvm-svn: 326776
2018-03-06 12:29:09 +00:00
Alexander Kornienko d8ec6e73c8 Move test/gcdasyncsemaphorechecker_test.m to a subdirectory
llvm-svn: 326772
2018-03-06 10:40:11 +00:00
George Burgess IV a47e1b7304 Fix an unused variable warning; NFC
llvm-svn: 326767
2018-03-06 07:45:11 +00:00
George Burgess IV 9753b7903d [ExprConstant] Look through ExprWithCleanups for `allocsize`
llvm-svn: 326766
2018-03-06 07:42:36 +00:00
Eugene Zelenko b8b9af2ad4 [StaticAnalyzer] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).
llvm-svn: 326757
2018-03-06 00:47:41 +00:00
George Karpenkov 15e814f687 [analyzer] [quickfix] Prevent a crash in NamedDecl::getName()
llvm-svn: 326755
2018-03-06 00:18:21 +00:00
George Karpenkov 436d5cc7ee [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

llvm-svn: 326746
2018-03-05 22:03:32 +00:00
Reid Kleckner ce30b76b1d [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

llvm-svn: 326744
2018-03-05 21:36:23 +00:00
Richard Smith 9c1526e75c Fix typo in comment.
llvm-svn: 326741
2018-03-05 20:54:34 +00:00
Yaxun Liu 1578a0a55d [AMDGPU] Clean up old address space mapping and fix constant address space value
Differential Revision: https://reviews.llvm.org/D43911

llvm-svn: 326725
2018-03-05 17:50:10 +00:00
Henry Wong cb2ad24c5c [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

llvm-svn: 326709
2018-03-05 15:41:15 +00:00
Alexander Ivchenko 9d3b45301f [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

llvm-svn: 326689
2018-03-05 11:30:28 +00:00
Yuka Takahashi 503da8ff1f [Bash-autocompletion] Fixed formatting
Fixed a trivial formatting and indent.

llvm-svn: 326685
2018-03-05 09:01:31 +00:00
Yuka Takahashi 41789e46a6 [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

llvm-svn: 326684
2018-03-05 08:54:20 +00:00
Aaron Ballman 5302604c32 Amend r326665 to print out the `used` attribute subjects in a different order.
llvm-svn: 326676
2018-03-04 16:24:10 +00:00
Aaron Ballman 3cfa9d1d61 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.

llvm-svn: 326675
2018-03-04 15:32:01 +00:00
Aaron Ballman 1a3901c69f 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.

llvm-svn: 326665
2018-03-03 21:02:09 +00:00
Kamil Rytarowski 51965f877b 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.

llvm-svn: 326652
2018-03-03 12:28:54 +00:00
Kamil Rytarowski 3f7f960a34 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

llvm-svn: 326648
2018-03-03 11:52:52 +00:00
Kamil Rytarowski 150a377704 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

llvm-svn: 326645
2018-03-03 11:47:27 +00:00
Manoj Gupta 886b4505f2 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

llvm-svn: 326639
2018-03-02 23:52:44 +00:00
Eugene Zelenko e029a2ff23 [StaticAnalyzer] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).
llvm-svn: 326633
2018-03-02 23:11:49 +00:00
Richard Smith cbf060f9dd PR36581: Support data recursion over Stmts in AST matchers.
llvm-svn: 326624
2018-03-02 21:55:03 +00:00
Erich Keane 0c4457b952 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

llvm-svn: 326623
2018-03-02 21:53:25 +00:00
Reid Kleckner a991695e49 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

llvm-svn: 326622
2018-03-02 21:41:08 +00:00
George Karpenkov 8dad0e6cce [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

llvm-svn: 326619
2018-03-02 21:34:24 +00:00
George Burgess IV 8b93a591e7 Range-ify a for loop. NFC
llvm-svn: 326607
2018-03-02 20:10:38 +00:00
Aaron Ballman 66a9268a2a 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.

llvm-svn: 326604
2018-03-02 19:14:21 +00:00
Joel E. Denny 9010ee6376 [Attr] Use -fsyntax-only in test
Suggested at: https://reviews.llvm.org/D43248

llvm-svn: 326603
2018-03-02 19:03:27 +00:00
Joel E. Denny 4925445958 [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

llvm-svn: 326602
2018-03-02 19:03:22 +00:00
Alexey Bataev 20cf67c233 [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`.

llvm-svn: 326594
2018-03-02 18:07:00 +00:00
Alexey Bataev 852525de25 [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.

llvm-svn: 326590
2018-03-02 17:17:12 +00:00
Alexey Sotkin aba98fc92e 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

llvm-svn: 326566
2018-03-02 12:11:40 +00:00
Mikhail Maltsev 2373516cad [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

llvm-svn: 326551
2018-03-02 10:03:02 +00:00
Petr Hosek 1aea1e7c24 [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

llvm-svn: 326542
2018-03-02 07:19:42 +00:00
Akira Hatanaka 1cc47eadf1 Remove debugging code I accidentally committed in r326530.
llvm-svn: 326531
2018-03-02 02:03:21 +00:00
Akira Hatanaka 627586b850 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

llvm-svn: 326530
2018-03-02 01:53:15 +00:00
George Karpenkov 7d0f5ab6aa [analyzer] [tests] Again, make tests more resilient to changes in exploration strategy
llvm-svn: 326529
2018-03-02 01:41:19 +00:00
Rafael Espindola 796d4a885d 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.

llvm-svn: 326527
2018-03-02 01:29:51 +00:00
George Karpenkov 0ffcaf7437 [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

llvm-svn: 326520
2018-03-02 00:55:59 +00:00
Eugene Zelenko 534673a560 [StaticAnalyzer] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).
llvm-svn: 326519
2018-03-02 00:54:51 +00:00
George Karpenkov 7596b82102 [analyzer] [NFC] [tests] Make test more resilient to changes in exploration strategy
llvm-svn: 326518
2018-03-02 00:54:05 +00:00
Heejin Ahn 8b6af22e60 [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

llvm-svn: 326517
2018-03-02 00:39:16 +00:00