Commit Graph

72689 Commits

Author SHA1 Message Date
Akira Hatanaka 9f9d766037 [Driver] Pass Default=false to hasFlag.
I forgot to do this in r326530.

llvm-svn: 327204
2018-03-10 05:55:21 +00:00
Richard Smith 007cb6df58 Revert r326946. It caused stack overflows by significantly increasing the size of a CallArgList.
llvm-svn: 327195
2018-03-10 01:47:22 +00:00
George Burgess IV 56e5a2e13e [CodeGen] Try to not call a dtor after lifetime.end
If CodeGenFunction::EmitCall is:
- asked to emit a call with an indirectly returned value,
- given an invalid return value slot, and
- told the return value of the function it's calling is unused

then it'll make its own temporary, and add lifetime markers so that the
temporary's lifetime ends immediately after the call.

The early lifetime.end becomes problematic when we need to run a
destructor on the result of the function.

Instead of unconditionally saying that results of all calls are used
here (which would be correct, but would also cause us to never emit
lifetime markers for these temporaries), we just build our own temporary
to pass in when a dtor has to be run.

llvm-svn: 327192
2018-03-10 01:11:17 +00:00
Abderrazek Zaafrani 5bd68cf742 [ARM] Add ARMv8.2-A FP16 vector intrinsic
Add the fp16 neon vector intrinsic for ARM as described in the ARM ACLE document.

Reviews in https://reviews.llvm.org/D43650

llvm-svn: 327189
2018-03-09 23:39:34 +00:00
Saleem Abdulrasool 813b619329 test: repair windows build after SVN r327105
Thanks to Nico Weber for pointing out the failure.  Add an explicit
target for the test.

llvm-svn: 327183
2018-03-09 23:00:29 +00:00
Peter Collingbourne a2f10056d1 Fix Clang test case.
llvm-svn: 327166
2018-03-09 19:37:28 +00:00
Evgeniy Stepanov d48c0cd910 Don't use -pie in relocatable link.
Summary:
Android, in particular, got PIE enabled by default in r316606. It resulted in
relocatable links passing both -r and -pie to the linker, which is not allowed.

Reviewers: srhines

Subscribers: cfe-commits

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

llvm-svn: 327165
2018-03-09 19:35:16 +00:00
Alexey Bataev 21dab12453 [OPENMP] Fix the address of the original variable in task reductions.
If initialization of the task reductions requires pointer to original
variable, which is stored in the threadprivate storage, we used the
address of this pointer instead.

llvm-svn: 327136
2018-03-09 15:20:30 +00:00
Ilya Biryukov 1a1dffd275 [SemaOverload] Fixed crash on code completion
Summary:
The relevant failing assertion message is:
../tools/clang/lib/Sema/SemaInit.cpp:8411: PerformCopyInitialization(): Assertion `InitE && "No initialization expression?"' failed.

See the added test case for a repro.

Reviewers: bkramer, sammccall, ioeric, hokein

Reviewed By: sammccall

Subscribers: cfe-commits

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

llvm-svn: 327134
2018-03-09 14:43:29 +00:00
Saleem Abdulrasool 3e70132753 CodeGen: simplify and validate exception personalities
Simplify the dispatching for the personality routines.  This really had
no test coverage previously, so add test coverage for the various cases.
This turns out to be pretty complicated as the various languages and
models interact to change personalities around.

You really should feel bad for the compiler if you are using exceptions.
There is no reason for this type of cruelty.

llvm-svn: 327105
2018-03-09 07:06:42 +00:00
Richard Smith 69cf59ed26 PR36645: Go looking for an appropriate array bound when constant-evaluating a
name of an array object.

llvm-svn: 327099
2018-03-09 02:00:01 +00:00
Artem Dergachev ce5f2d3d42 [analyzer] MmapWriteExecChecker: Add support for mprotect().
mprotect() allows setting memory access flags similarly to mmap(),
causing similar security issues if these flags are needlessly broad.

Patch by David Carlier!

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

llvm-svn: 327098
2018-03-09 01:47:24 +00:00
Artem Dergachev 13f9664d2b [CFG] [analyzer] Add construction context for implicit constructor conversions.
Implicit constructor conversions such as A a = B() are represented by
surrounding the constructor for B() with an ImplicitCastExpr of
CK_ConstructorConversion kind, similarly to how explicit constructor conversions
are surrounded by a CXXFunctionalCastExpr. Support this syntax pattern when
extracting the construction context for the implicit constructor that
performs the conversion.

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

llvm-svn: 327096
2018-03-09 01:39:59 +00:00
Douglas Yung 17d2ef90e0 [DOXYGEN] Fix doxygen and content issues in mmintrin.h
- Fix instruction mappings/listings for various intrinsics

This patch was made by Craig Flores

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

llvm-svn: 327090
2018-03-09 00:38:51 +00:00
Adrian Prantl 69fce12c38 Add a debug info testcase for the trvial_abi attribute.
llvm-svn: 327078
2018-03-08 23:11:46 +00:00
Eugene Zelenko 9f103a1a27 [StaticAnalyzer] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).
llvm-svn: 327074
2018-03-08 22:45:13 +00:00
Alexey Bataev 2e0cbe5092 [OPENMP] Emit sizes/init ptrs etc. data for task reductions before
using.

We may emit the code in wrong order because of incorrect implementation
of the runtime functions for task reductions. Threadprivate storages may
be initialized after real initialization of the reduction items. Patch
fixes this problem.

llvm-svn: 327008
2018-03-08 15:24:08 +00:00
Krasimir Georgiev a71f626eac [clang-format] Use NestedBlockIndent as a 0 column in formatted raw strings
Summary:
This makes the formatter of raw string literals use NestedBlockIndent for
determining the 0 column of the content inside. This makes the formatting use
less horizonal space and fixes a case where two newlines before and after the
raw string prefix were selected instead of a single newline after it:

Before:
```
aaaa = ffff(
    R"pb(
      key: value)pb");
```

After:
```
aaaa = ffff(R"pb(
    key: value)pb");
```

Reviewers: djasper, sammccall

Reviewed By: sammccall

Subscribers: klimek, cfe-commits

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

llvm-svn: 326996
2018-03-08 11:29:27 +00:00
Stephan Bergmann 0feb0b9059 Propagate DLLAttr to friend re-declarations of member functions
...that have already been constructed (e.g., in inner classes) while parsing the
class definition.  They would otherwise lack any DLLAttr inherited from the
class, which are only set here (called from Sema::CheckCompletedClass) after the
class definition has been parsed completely.

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

llvm-svn: 326990
2018-03-08 07:34:40 +00:00
George Burgess IV 003be7cbf4 [CodeGen] Emit lifetime.ends in both EH and non-EH blocks
Before this, we'd only emit lifetime.ends for these temps in
non-exceptional paths. This potentially made our stack larger than it
needed to be for any code that follows an EH cleanup. e.g. in

```
struct Foo { char cs[32]; };

void escape(void *);

struct Bar { ~Bar() { char cs[64]; escape(cs); } };

Foo getFoo();

void baz() {
  Bar b;
  getFoo();
}
```

baz() would require 96 bytes of stack, since the temporary from getFoo()
only had a lifetime.end on the non-exceptional path.

This also makes us keep hold of the Value* returned by
EmitLifetimeStart, so we don't have to remake it later.

llvm-svn: 326988
2018-03-08 05:32:30 +00:00
George Karpenkov 04b9dc58b8 [analyzer] Correctly model iteration through "nil" objects
Previously, iteration through nil objects which resulted from
objc-messages being set to nil were modeled incorrectly.

There are a couple of notes about this patch:

In principle, ExprEngineObjC might be left untouched IFF osx.loops
checker is enabled.
I however think that we should not do something
completely incorrect depending on what checkers are left on.
We should evaluate and potentially remove altogether the isConsumedExpr
performance heuristic, as it seems very fragile.

rdar://22205149

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

llvm-svn: 326982
2018-03-08 02:53:39 +00:00
George Burgess IV e4f47b4c63 Fix an unused variable warning; NFC
llvm-svn: 326980
2018-03-08 02:15:12 +00:00
Eugene Zelenko d02f3e9673 [Documentation] Fix Release notes problems introduced in r326889. Add highlighting.
llvm-svn: 326979
2018-03-08 01:37:39 +00:00
Reid Kleckner 8d485b845b Revert "[Sema] Make getCurFunction() return null outside function parsing"
This reverts r326965. It seems to have caused repeating test failures in
clang/test/Sema/diagnose_if.c on some buildbots.

I cannot reproduce the problem, and it's not immediately obvious what
the problem is, so let's revert to green.

llvm-svn: 326974
2018-03-08 01:12:22 +00:00
Richard Smith 5d3310208a When substituting previously-checked template arguments into a template
template parameter that is an expanded parameter pack, only substitute into the
current slice, not the entire pack.

This reduces the checking of N template template arguments for an expanded
parameter pack containing N parameters from quadratic time to linear time in
the length of the pack. This is important because one (and possibly the only?)
general technique for splitting a template parameter pack in linear time
depends on doing this.

llvm-svn: 326973
2018-03-08 01:07:33 +00:00
Reid Kleckner 267589a966 [MS] Pass CVRU qualifiers properly in Itanium mangler
We already have a mangling for the __unaligned qualifier, we just have
to call Qualifiers::getFromCVRUMask instead of getFromCVRMask.

PR36638

llvm-svn: 326971
2018-03-08 00:55:09 +00:00
George Burgess IV ab1e5a187d Fix a doc typo; NFC
llvm-svn: 326968
2018-03-08 00:22:04 +00:00
Reid Kleckner c2fd352963 [Sema] Make getCurFunction() return null outside function parsing
Summary:
Before this patch, Sema pre-allocated a FunctionScopeInfo and kept it in
the first, always present element of the FunctionScopes stack. This
meant that Sema::getCurFunction would return a pointer to this
pre-allocated object when parsing code outside a function body. This is
pretty much always a bug, so this patch moves the pre-allocated object
into a separate unique_ptr. This should make bugs like PR36536 a lot
more obvious.

As you can see from this patch, there were a number of places that
unconditionally assumed they were always called inside a function.
However, there are also many places that null checked the result of
getCurFunction(), so I think this is a reasonable direction.

Reviewers: rsmith

Subscribers: cfe-commits

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

llvm-svn: 326965
2018-03-08 00:14:34 +00:00
Reid Kleckner c6663b7c45 [MS] Accept __unaligned as a qualifier on member function pointers
We need to treat __unaligned like the other 'cvr' qualifiers when it
appears at the end of a function prototype. We weren't doing that in
some tentative parsing.

Fixes PR36638.

llvm-svn: 326962
2018-03-07 23:26:02 +00:00
Rafael Espindola abdb322438 Set dso_local on tls init functions.
We copy the visibility, so copying the dso_local flag seems the
natural thing to do.

llvm-svn: 326961
2018-03-07 23:18:06 +00:00
Nico Weber 91af2747f2 [ms] Emit vtordisp initializers in a deterministic order.
No effective behavior change, just for cleanliness.
Analysis and typing by me, actual patch mostly by Reid.

Fixes PR36159.
https://reviews.llvm.org/D44223

llvm-svn: 326960
2018-03-07 23:15:20 +00:00
Reid Kleckner 04f9bcaa6d Avoid including ScopeInfo.h from Sema.h
Summary:
This provides no measurable build speedup, but it reinstates an
optimization from r112038 that was lost in r179618.  It requires moving
CapturedScopeInfo::Capture out to clang::sema, which might be too
general since we have plenty of other Capture records in BlockDecl and
other AST nodes.

Reviewers: rjmccall

Subscribers: cfe-commits

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

llvm-svn: 326957
2018-03-07 22:48:35 +00:00
George Karpenkov 8e3a659105 [analyzer] [PointerArithChecker] do not warn on indexes into vector types
rdar://35041502

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

llvm-svn: 326952
2018-03-07 22:20:39 +00:00
George Karpenkov 065962375d [analyzer] Don't crash with assertion failure on structured bindings
Proper modeling still remains to be done.
Note that BindingDecl#getHoldingVar() is almost always null, and this
should probably be handled by dealing with DecompositionDecl beforehand.

rdar://36852163

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

llvm-svn: 326951
2018-03-07 22:20:35 +00:00
Gheorghe-Teodor Bercea 7d80da15a0 [OpenMP] Remove implicit data sharing code gen that aims to use device shared memory
Summary: Remove this scheme for now since it will be covered by another more generic scheme using global memory. This code will be worked into an optimization for the generic data sharing scheme. Removing this completely and then adding it via future patches will make all future data sharing patches cleaner.

Reviewers: ABataev, carlo.bertolli, caomhin

Reviewed By: ABataev

Subscribers: jholewinski, guansong, cfe-commits

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

llvm-svn: 326948
2018-03-07 21:59:50 +00:00
Yaxun Liu 06dd81149f CodeGen: Fix address space of indirect function argument
The indirect function argument is in alloca address space in LLVM IR. However,
during Clang codegen for C++, the address space of indirect function argument
should match its address space in the source code, i.e., default addr space, even
for indirect argument. This is because destructor of the indirect argument may
be called in the caller function, and address of the indirect argument may be
taken, in either case the indirect function argument is expected to be in default
addr space, not the alloca address space.

Therefore, the indirect function argument should be mapped to the temp var
casted to default address space. The caller will cast it to alloca addr space
when passing it to the callee. In the callee, the argument is also casted to the
default address space and used.

CallArg is refactored to facilitate this fix.

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

llvm-svn: 326946
2018-03-07 21:45:40 +00:00
Krasimir Georgiev 9ad7af6423 [clang-format] Break consecutive string literals in text protos
Summary:
This patch fixes a bug where consecutive string literals in text protos were
put on the same line.

Reviewers: alexfh

Reviewed By: alexfh

Subscribers: klimek, cfe-commits

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

llvm-svn: 326945
2018-03-07 21:30:38 +00:00
Matthew Voss 0a6a701f36 Correct the alignment for the PS4 target
https://reviews.llvm.org/D44218

llvm-svn: 326942
2018-03-07 20:48:16 +00:00
Yaxun Liu cb35e9fa94 [OpenCL] Remove block invoke function from emitted block literal struct
OpenCL runtime tracks the invoke function emitted for
any block expression. Due to restrictions on blocks in
OpenCL (v2.0 s6.12.5), it is always possible to know the
block invoke function when emitting call of block expression
or __enqueue_kernel builtin functions. Since __enqueu_kernel
already has an argument for the invoke function, it is redundant
to have invoke function member in the llvm block literal structure.

This patch removes invoke function from the llvm block literal
structure. It also removes the bitcast of block invoke function
to the generic block literal type which is useless for OpenCL.

This will save some space for the kernel argument, and also
eliminate some store instructions.

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

llvm-svn: 326937
2018-03-07 19:32:58 +00:00
George Karpenkov 65e64917e3 [analyzer] [NFC] Minor refactoring of NonNullParamChecker
Differential Revision: https://reviews.llvm.org/D43917

llvm-svn: 326935
2018-03-07 19:27:32 +00:00
Reid Kleckner b2da086103 Push a function scope when parsing function bodies without a declaration
Summary:
This is PR36536.

There are a few ways to reach Sema::ActOnStartOfFunctionDef with a null
Decl. Currently, the parser continues on to attempt to parse the
statements in the function body without pushing a function scope or
declaration context. However, lots of statement parsing logic relies on
getCurFunction() returning something reasonable. It turns out that
getCurFunction() will never return null today because of an optimization
where Sema pre-allocates one FunctionScopeInfo and reuses it when
possible. This goes wrong when something inside the function body causes
us to push another function scope, such as requiring an implicit
definition of a special member function. Reusing the state clears it
out, which will lead to bugs. In PR36536, we found that the SwitchStack
gets unbalanced, because we push a switch, clear out the stack, and then
try to pop a switch that isn't there.

As a follow-up, I plan to move the pre-allocated FunctionScopeInfo out
of the FunctionScopes stack. This means the FunctionScopes stack will
often be empty, and callers of getCurFunction() will need to check for
null.

Reviewers: thakis

Subscribers: cfe-commits

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

llvm-svn: 326926
2018-03-07 18:55:10 +00:00
Alexey Bataev ab4ea225fe [OPENMP] Fix lifetime of the loop counters.
We may emit incorrect lifetime info during codegen for loop counters in
OpenMP constructs because of automatic scope cleanup when we needed
temporarily locations for private loop counters.

llvm-svn: 326922
2018-03-07 18:17:06 +00:00
Yuka Takahashi ba900ab93d Add Clang ReleaseNotes that --autocomplete breaks backward compatibily
Summary:
--autocomplete flag now handles all the flags passed to shell, and this
implementation breaks backward compatibily before Clang 6.0.

Reviewers: teemperor, v.g.vassilev

Subscribers: cfe-commits

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

llvm-svn: 326889
2018-03-07 11:34:02 +00:00
George Burgess IV f11efc6daa Remove a placeholder
...Running tests in the wrong directory will often make them seem to
pass. Oops. :)

llvm-svn: 326873
2018-03-07 05:02:27 +00:00
George Burgess IV 4763876f4b Reland r326766 (with a slightly modified test)
The original revert was done in r326869, since reverting r326602 broke
the test added by this.

The new test should be less dependent on r326602.

llvm-svn: 326872
2018-03-07 04:52:34 +00:00
Nico Weber b2ecd46ae4 Revert 326766 too, after r326862 the test fails and I don't know how to fix.
llvm-svn: 326869
2018-03-07 03:00:25 +00:00
George Karpenkov 4cbeeb1695 [analyzer] Fix the checker for the performance anti-pattern to accept messages
send to ObjC objects.

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

llvm-svn: 326868
2018-03-07 02:54:01 +00:00
Petr Hosek fdcbcfb040 [Driver] Enable SafeStack by default on Fuchsia
This is already used throughout the entire system, so make it a default.

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

llvm-svn: 326867
2018-03-07 02:49:58 +00:00
George Karpenkov a763fdfadd [ASTMatcher] Extend hasAnyArgument to ObjCMessageExpr
Currently hasArgument works with both ObjC messages and function calls,
but not hasAnyArgument.
This patch fixes that discrepancy, as it's often more convenient to use
hasAnyArgument.

On a more general note, it would be great to have a common superclass
for objc-call and function call, and a matcher matching that, but that's
probably a job for another commit.

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

llvm-svn: 326865
2018-03-07 02:32:44 +00:00
Nico Weber bbf648253d Revert r326602, it caused PR36620.
llvm-svn: 326862
2018-03-07 02:22:41 +00:00
Petr Hosek a14b46073e [Driver] Automatically disable incompatible default sanitizers
When a sanitizer incompatible with one of the default sanitizers
is explicitly enabled, automatically disable all the conflicting
default sanitizers.

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

llvm-svn: 326860
2018-03-07 01:27:03 +00:00
Eugene Zelenko 6a58efdf76 [StaticAnalyzer] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).
llvm-svn: 326856
2018-03-07 00:17:48 +00:00
George Burgess IV 5701606165 Fix a typo from r326844; NFC
llvm-svn: 326845
2018-03-06 23:09:01 +00:00
George Burgess IV 7e03f350e8 [CodeGen] Don't emit lifetime.end without lifetime.start
EmitLifetimeStart returns a non-null `size` pointer if it actually
emits a lifetime.start. Later in this function, we use `tempSize`'s
nullness to determine whether or not we should emit a lifetime.end.

llvm-svn: 326844
2018-03-06 23:07:00 +00:00
Michal Gorny 4289f4cecf [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

llvm-svn: 326836
2018-03-06 21:26:28 +00:00
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
David L. Jones 13d5a87658 [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
llvm-svn: 326512
2018-03-02 00:07:45 +00:00
David L. Jones e78dfe5f55 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.

llvm-svn: 326508
2018-03-01 23:14:00 +00:00
David L. Jones 40388bdfb9 [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

llvm-svn: 326501
2018-03-01 22:41:53 +00:00
Chih-Hung Hsieh ca552b8d31 [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

llvm-svn: 326499
2018-03-01 22:26:19 +00:00
Richard Smith 05ce1d3944 [modules] Don't diagnose "redefinition" of a friend with a pending definition
if the other definition is a merged copy of the same function.

llvm-svn: 326496
2018-03-01 22:20:13 +00:00
Richard Smith d9d42f9cc6 [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.

llvm-svn: 326493
2018-03-01 22:01:06 +00:00
Martin Storsjo 87c2ad29ee [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

llvm-svn: 326476
2018-03-01 20:22:57 +00:00
Saleem Abdulrasool cc6238158a 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-`.

llvm-svn: 326469
2018-03-01 19:13:43 +00:00
Artem Dergachev 61199443fe [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

llvm-svn: 326461
2018-03-01 18:53:13 +00:00
Ilya Biryukov 8b9b3bd07c 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.

llvm-svn: 326439
2018-03-01 14:54:16 +00:00
Hans Wennborg 1bab70109b UsersManual: improve the clang-cl text some more
llvm-svn: 326438
2018-03-01 14:48:19 +00:00
Hans Wennborg 69d6d7a4d8 UsersManual: beef up the clang-cl text a little
llvm-svn: 326434
2018-03-01 14:00:19 +00:00
Ilya Biryukov d49e75afbd 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.

llvm-svn: 326432
2018-03-01 12:43:39 +00:00
Francois Ferrand 2a9ea781f3 [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

llvm-svn: 326426
2018-03-01 10:09:13 +00:00
Serge Pavlov e6e534ca22 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

llvm-svn: 326419
2018-03-01 07:04:11 +00:00
George Burgess IV 00f70bd933 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.

llvm-svn: 326416
2018-03-01 05:43:23 +00:00
George Karpenkov dc0abcb87b [analyzer] [tests] Create a directory for the log file
llvm-svn: 326408
2018-03-01 02:18:54 +00:00
Artem Dergachev 4579bad86c [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

llvm-svn: 326405
2018-03-01 01:27:46 +00:00
Artem Dergachev 6603052235 [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

llvm-svn: 326402
2018-03-01 01:09:24 +00:00
Rafael Espindola b735004615 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.

llvm-svn: 326397
2018-03-01 00:35:47 +00:00
Rafael Espindola 75c649c960 Pass a GlobalDecl to SetCommonAttributes. NFC.
Part of D43900.

llvm-svn: 326392
2018-03-01 00:06:55 +00:00
Rafael Espindola e4e78135ac Inline a trivial function. NFC.
llvm-svn: 326391
2018-03-01 00:00:02 +00:00
Rafael Espindola 285271cb78 Pass a GlobalDecl to setNonAliasAttributes. NFC.
Also part of D43900.

llvm-svn: 326388
2018-02-28 23:54:23 +00:00
Rafael Espindola 51ec5a9ce3 Pass a GlobalDecl to SetInternalFunctionAttributes. NFC.
This just reduces the noise in a followup patch.

Part of D43900.

llvm-svn: 326385
2018-02-28 23:46:35 +00:00
Kostya Serebryany f19c797531 [hwasan] update the asm snippet in the docs to match the current default behaviour
llvm-svn: 326373
2018-02-28 21:58:19 +00:00
Nico Weber 926bbc0256 Attempt to fix cl-include.c on Windows.
llvm-svn: 326370
2018-02-28 20:58:06 +00:00
Carlo Bertolli 79712097c7 [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.

llvm-svn: 326368
2018-02-28 20:48:35 +00:00
Krzysztof Parzyszek fde8b04235 [Hexagon] Add -ffixed-r19 driver option and translate it to +reserved-r19
llvm-svn: 326366
2018-02-28 20:31:55 +00:00
Saleem Abdulrasool f181f1a6a2 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.

llvm-svn: 326362
2018-02-28 20:16:12 +00:00
Nico Weber 07f0a52c7f [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

llvm-svn: 326357
2018-02-28 19:49:07 +00:00
Nico Weber b3897eb6f2 Fix gcc -Wreturn-type warnings after r326307.
llvm-svn: 326355
2018-02-28 19:28:47 +00:00
Jonas Hahnfeld e768132f94 [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

llvm-svn: 326342
2018-02-28 17:53:46 +00:00
Joel E. Denny 6053ec22eb Test commit access: apply clang-format suggestion
llvm-svn: 326332
2018-02-28 16:57:33 +00:00
Gabor Horvath 7260932459 [analyzer] Fix a compiler warning
llvm-svn: 326324
2018-02-28 14:01:48 +00:00
Gabor Horvath eb0584bee4 [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

llvm-svn: 326323
2018-02-28 13:23:10 +00:00
Akira Hatanaka 7275da0f2e [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

llvm-svn: 326307
2018-02-28 07:15:55 +00:00
Richard Smith 77a9c60aa6 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.

llvm-svn: 326299
2018-02-28 03:02:23 +00:00
Richard Smith c1a40220b4 Update cxx_status to mark "SVN" items as "Clang 6" instead.
llvm-svn: 326298
2018-02-28 03:02:07 +00:00
George Karpenkov 3f560daf37 [analyzer] [tests] Write to logfile instead of stdout while updating
reference results

llvm-svn: 326295
2018-02-28 01:55:23 +00:00
Eugene Zelenko 5bc81eb980 [StaticAnalyzer] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).
llvm-svn: 326292
2018-02-28 01:10:04 +00:00
Konstantin Zhuravlyov 419889e266 AMDGPU: Move run and check lines around to match processor order in AMDGPU.h
llvm-svn: 326278
2018-02-28 00:27:00 +00:00
Rafael Espindola bb333c26ed Inline trivial function. NFC.
llvm-svn: 326272
2018-02-28 00:14:18 +00:00
Rafael Espindola fa2fc906d2 Pass a GlobalDecl to setAliasAttributes. NFC.
This just makes a followup change easier to read.

llvm-svn: 326270
2018-02-28 00:06:01 +00:00
Aaron Ballman 48a533d005 Improve the way attribute argument printing happens for omitted optional arguments when pretty printing.
Patch by Joel Denny.

llvm-svn: 326266
2018-02-27 23:49:28 +00:00
Rafael Espindola 64393cfca0 Pass a GlobalDecl to setFunctionDefinitionAttributes. NFC.
This just makes a followup patch easier to read.

llvm-svn: 326265
2018-02-27 23:44:36 +00:00