]> granicus.if.org Git - clang/log
clang
6 years ago[analyzer] Extend NoStoreFuncVisitor to follow fields.
George Karpenkov [Thu, 2 Aug 2018 02:02:40 +0000 (02:02 +0000)]
[analyzer] Extend NoStoreFuncVisitor to follow fields.

rdar://39701823

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

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

6 years agoPass triple to RUN line to fix failing bots.
Akira Hatanaka [Thu, 2 Aug 2018 01:52:17 +0000 (01:52 +0000)]
Pass triple to RUN line to fix failing bots.

This is a follow-up to r338656.

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

6 years agoSerialize DoesNotEscape.
Akira Hatanaka [Wed, 1 Aug 2018 23:51:53 +0000 (23:51 +0000)]
Serialize DoesNotEscape.

I forgot to commit this in r326530.

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

6 years ago[AST] Remove the static_assert check in ObjCMethodDecl::ObjCMethodDecl
Vlad Tsyrklevich [Wed, 1 Aug 2018 22:41:03 +0000 (22:41 +0000)]
[AST] Remove the static_assert check in ObjCMethodDecl::ObjCMethodDecl

Summary:
This check was introduced by r338641
but this broke some builds. For now remove it.

Subscribers: cfe-commits

Tags: #clang

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

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

6 years agoFix -Wcovered-switch-default uncovered after r338630
Reid Kleckner [Wed, 1 Aug 2018 22:10:03 +0000 (22:10 +0000)]
Fix -Wcovered-switch-default uncovered after r338630

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

6 years ago[AST][4/4] Move the bit-fields from ObjCMethodDecl and ObjCContainerDecl into DeclContext
Erich Keane [Wed, 1 Aug 2018 21:31:08 +0000 (21:31 +0000)]
[AST][4/4] Move the bit-fields from ObjCMethodDecl and ObjCContainerDecl into DeclContext

This patch follows https://reviews.llvm.org/D49729,
https://reviews.llvm.org/D49732 and
https://reviews.llvm.org/D49733.

Move the bits from ObjCMethodDecl and ObjCContainerDecl
into DeclContext.

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

Patch By: bricci

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

6 years ago[NFC][CodeGenCXX] Use -emit-llvm-only instead of -emit-llvm and ignoring it.
Roman Lebedev [Wed, 1 Aug 2018 21:20:58 +0000 (21:20 +0000)]
[NFC][CodeGenCXX] Use -emit-llvm-only instead of -emit-llvm and ignoring it.

As pointed out by Richard Smith in post-review of r338489.

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

6 years ago[AST][3/4] Move the bit-fields from BlockDecl, LinkageSpecDecl and OMPDeclareReductio...
Erich Keane [Wed, 1 Aug 2018 21:16:54 +0000 (21:16 +0000)]
[AST][3/4] Move the bit-fields from BlockDecl, LinkageSpecDecl and OMPDeclareReductionDecl into DeclContext

This patch follows https://reviews.llvm.org/D49729
and https://reviews.llvm.org/D49732, and is
followed by https://reviews.llvm.org/D49734.

Move the bits from BlockDecl, LinkageSpecDecl and
OMPDeclareReductionDecl into DeclContext.

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

Patch By: bricci

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

6 years ago[AST][2/4] Move the bit-fields from FunctionDecl and CXXConstructorDecl into DeclContext
Erich Keane [Wed, 1 Aug 2018 21:02:40 +0000 (21:02 +0000)]
[AST][2/4] Move the bit-fields from FunctionDecl and CXXConstructorDecl into DeclContext

This patch follows https://reviews.llvm.org/D49729
and is followed by https://reviews.llvm.org/D49733
and https://reviews.llvm.org/D49734.

Move the bits from FunctionDecl and CXXConstructorDecl
into DeclContext.

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

Patch By: bricci

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

6 years ago[AST][1/4] Move the bit-fields from TagDecl, EnumDecl and RecordDecl into DeclContext
Erich Keane [Wed, 1 Aug 2018 20:48:16 +0000 (20:48 +0000)]
[AST][1/4] Move the bit-fields from TagDecl, EnumDecl and RecordDecl into DeclContext

DeclContext has a little less than 8 bytes free due to the alignment
requirements on 64 bits archs. This set of patches moves the
bit-fields from classes deriving from DeclContext into DeclContext.

On 32 bits archs this increases the size of DeclContext by 4 bytes
but this is balanced by an equal or larger reduction in the size
of the classes deriving from it.

On 64 bits archs the size of DeclContext stays the same but
most of the classes deriving from it shrink by 8/16 bytes.
(-print-stats diff here https://reviews.llvm.org/D49728)
When doing an -fsyntax-only on all of Boost this result
in a 3.6% reduction in the size of all Decls and
a 1% reduction in the run time due to the lower cache
miss rate.

For now CXXRecordDecl is not touched but there is
an easy 6 (if I count correctly) bytes gain available there
by moving some bits from DefinitionData into the free
space of DeclContext. This will be the subject of another patch.

This patch sequence also enable the possibility of refactoring
FunctionDecl: To save space some bits from classes deriving from
FunctionDecl were moved to FunctionDecl. This resulted in a
lot of stuff in FunctionDecl which do not belong logically to it.
After this set of patches however it is just a simple matter of
adding a SomethingDeclBitfields in DeclContext and moving the
bits to it from FunctionDecl.

This first patch introduces the anonymous union in DeclContext
and all the *DeclBitfields classes holding the bit-fields, and moves
the bits from TagDecl, EnumDecl and RecordDecl into DeclContext.

This patch is followed by https://reviews.llvm.org/D49732,
https://reviews.llvm.org/D49733 and https://reviews.llvm.org/D49734.

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

Patch By: bricci

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

6 years ago[test] Fix %hmaptool path for standalone builds
Michal Gorny [Wed, 1 Aug 2018 20:38:22 +0000 (20:38 +0000)]
[test] Fix %hmaptool path for standalone builds

Fix %hmaptool path to refer to clang_tools_dir instead of
llvm_tools_dir, in order to fix standalone builds.  The tool is built
as part of clang, so it won't be found in installed LLVM tools.

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

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

6 years ago[Android] Increase default new alignment for Android
Pirama Arumuga Nainar [Wed, 1 Aug 2018 17:55:34 +0000 (17:55 +0000)]
[Android] Increase default new alignment for Android

Summary:
Android's memory allocators also guarantee 8-byte alignment for 32-bit
architectures and 16-byte alignment for 64-bit.

Reviewers: rsmith

Subscribers: cfe-commits, srhines, enh

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

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

6 years agoRevert r338455 "[constexpr] Support for constant evaluation of __builtin_memcpy and...
Hans Wennborg [Wed, 1 Aug 2018 17:51:23 +0000 (17:51 +0000)]
Revert r338455 "[constexpr] Support for constant evaluation of __builtin_memcpy and __builtin_memmove (in non-type-punning cases)."

It caused asserts during Chromium builds, see reply on the cfe-commits thread.

> This is intended to permit libc++ to make std::copy etc constexpr
> without sacrificing the optimization that uses memcpy on
> trivially-copyable types.
>
> __builtin_strcpy and __builtin_wcscpy are not handled by this change.
> They'd be straightforward to add, but we haven't encountered a need for
> them just yet.

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

6 years ago[Format] Fix for bug 35641
Ilya Biryukov [Wed, 1 Aug 2018 15:32:56 +0000 (15:32 +0000)]
[Format] Fix for bug 35641

Summary:
Bug was caused due to comments at the start of scope. For a code like:
```
int func() { //
  int b;
  int c;
}
```
the comment at the first line gets IndentAndNestingLevel (1,1) whereas
the following declarations get only (0,1) which prevents them from insertion
of a new scope. So, I changed the AlignTokenSequence to look at previous
*non-comment* token when deciding whether to introduce a new scope into
stack or not.

Patch by Kadir Cetinkaya!

Reviewers: rsmith, djasper

Reviewed By: djasper

Subscribers: lebedev.ri, cfe-commits, klimek

Tags: #clang

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

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

6 years ago[UnrollAndJam] Add unroll_and_jam pragma handling
David Green [Wed, 1 Aug 2018 14:36:12 +0000 (14:36 +0000)]
[UnrollAndJam] Add unroll_and_jam pragma handling

This adds support for the unroll_and_jam pragma, to go with the recently
added unroll and jam pass. The name of the pragma is the same as is used
in the Intel compiler, and most of the code works the same as for unroll.

#pragma clang loop unroll_and_jam has been separated into a different
patch. This part adds #pragma unroll_and_jam with an optional count, and
#pragma no_unroll_and_jam to disable the transform.

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

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

6 years agoUpdate docs version and clear release notes after 8.0.0 version bump
Hans Wennborg [Wed, 1 Aug 2018 14:01:27 +0000 (14:01 +0000)]
Update docs version and clear release notes after 8.0.0 version bump

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

6 years agoUse a dummy target so the test passes when default target is for a toolchain implemen...
Filipe Cabecinhas [Wed, 1 Aug 2018 13:41:42 +0000 (13:41 +0000)]
Use a dummy target so the test passes when default target is for a toolchain implements useIntegratedAs() -> true

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

6 years agoAdd REQUIRES: native to a test that assumes it
Filipe Cabecinhas [Wed, 1 Aug 2018 13:41:11 +0000 (13:41 +0000)]
Add REQUIRES: native to a test that assumes it

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

6 years ago[NFC] Silence warning about ptr-to-func to ptr-to-obj cast in clang-fuzzer/handle...
Andrei Elovikov [Wed, 1 Aug 2018 13:34:18 +0000 (13:34 +0000)]
[NFC] Silence warning about ptr-to-func to ptr-to-obj cast in clang-fuzzer/handle-llvm/handle_llvm.cpp.

Summary:
I don't have the whole list of GCC binaries available so I determined the exact
version where the warning disappeared via:

https://github.com/gcc-mirror/gcc/blob/gcc-4_9_0-release/gcc/cp/typeck.c#L6863
https://github.com/gcc-mirror/gcc/blob/gcc-4_8_5-release/gcc/cp/typeck.c#L6652

Reviewers: emmettneyman, erichkeane

Reviewed By: emmettneyman, erichkeane

Subscribers: cfe-commits

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

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

6 years agoMake test/Frontend/clang-abi-compat.cpp pass when the version goes to 8
Hans Wennborg [Wed, 1 Aug 2018 13:19:14 +0000 (13:19 +0000)]
Make test/Frontend/clang-abi-compat.cpp pass when the version goes to 8

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

6 years agoUserManual: Update with the latest clang-cl flags
Hans Wennborg [Wed, 1 Aug 2018 12:58:57 +0000 (12:58 +0000)]
UserManual: Update with the latest clang-cl flags

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

6 years ago[AArch64][ARM] Add Armv8.4-A tests
Sjoerd Meijer [Wed, 1 Aug 2018 12:41:10 +0000 (12:41 +0000)]
[AArch64][ARM] Add Armv8.4-A tests

This adds tests for Armv8.4-A, and also some v8.2 and v8.3 tests that were
missing.

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

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

6 years ago[clang-format] Add some text proto functions to Google style
Krasimir Georgiev [Wed, 1 Aug 2018 12:35:23 +0000 (12:35 +0000)]
[clang-format] Add some text proto functions to Google style

Summary: Adds 2 functions taking a text proto argument.

Reviewers: djasper, klimek

Reviewed By: djasper

Subscribers: acoomans, cfe-commits

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

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

6 years agowrap to 80 cols, no behavior change
Nico Weber [Wed, 1 Aug 2018 11:56:20 +0000 (11:56 +0000)]
wrap to 80 cols, no behavior change

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

6 years ago[clang-format] Add @private to the list of jsdoc annotations
Krasimir Georgiev [Wed, 1 Aug 2018 11:48:04 +0000 (11:48 +0000)]
[clang-format] Add @private to the list of jsdoc annotations

Reviewers: mprobst

Reviewed By: mprobst

Subscribers: acoomans, cfe-commits

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

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

6 years agoAdd missing semicolon.
Simon Pilgrim [Wed, 1 Aug 2018 10:34:13 +0000 (10:34 +0000)]
Add missing semicolon.

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

6 years agoReplace 'FALL-THROUGH' comment with LLVM_FALLTHROUGH to silence warning. NFCI.
Simon Pilgrim [Wed, 1 Aug 2018 10:26:04 +0000 (10:26 +0000)]
Replace 'FALL-THROUGH' comment with LLVM_FALLTHROUGH to silence warning. NFCI.

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

6 years ago[Modules] Do not emit relocation error when -fno-validate-pch is set
Yuka Takahashi [Wed, 1 Aug 2018 09:50:02 +0000 (09:50 +0000)]
[Modules] Do not emit relocation error when -fno-validate-pch is set

Summary:
Clang emits error when implicit modules was relocated from the
first build directory. However this was biting our usecase where we copy
the contents of build directory to another directory in order to
distribute.

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

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

6 years agoFix "not all control paths return a value" MSVC warning.
Simon Pilgrim [Wed, 1 Aug 2018 09:45:21 +0000 (09:45 +0000)]
Fix "not all control paths return a value" MSVC warning.

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

6 years ago[AST] CastExpr: BasePathSize is not large enough.
Roman Lebedev [Wed, 1 Aug 2018 06:06:16 +0000 (06:06 +0000)]
[AST] CastExpr: BasePathSize is not large enough.

Summary:
rC337815 / D49508 had to cannibalize one bit of `CastExprBitfields::BasePathSize` in order to squeeze `PartOfExplicitCast` boolean.
That reduced the maximal value of `PartOfExplicitCast` from 9 bits (~512) down to 8 bits (~256).
Apparently, that mattered. Too bad there weren't any tests.
It caused [[ https://bugs.llvm.org/show_bug.cgi?id=38356 | PR38356 ]].

So we need to increase `PartOfExplicitCast` back at least to 9 bits, or a bit more.
For obvious reasons, we can't do that in `CastExprBitfields` - that would blow up the size of every `Expr`.
So we need to either just add a variable into the `CastExpr` (as done here),
or use `llvm::TrailingObjects`. The latter does not seem to be straight-forward.
Perhaps, that needs to be done not for the `CastExpr` itself, but for all of it's `final` children.

Reviewers: rjmccall, rsmith, erichkeane

Reviewed By: rjmccall

Subscribers: bricci, hans, cfe-commits, waddlesplash

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

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

6 years ago[OpenEmbedded] Explicitly specify -rtlib in tests
Petr Hosek [Wed, 1 Aug 2018 03:30:06 +0000 (03:30 +0000)]
[OpenEmbedded] Explicitly specify -rtlib in tests

Tests added in r338294 implicitly assume that libgcc is the runtime library,
but that's not the case when the user configures Clang to use compiler-rt in
which case these tests will break. Explicitly request libgcc when invoking
clang in these tests to avoid that.

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

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

6 years agoWork around GCC miscompile exposed by r338464.
Richard Smith [Wed, 1 Aug 2018 02:27:18 +0000 (02:27 +0000)]
Work around GCC miscompile exposed by r338464.

See gcc.gnu.org/PR86769 for details of the bug.

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

6 years ago[analyzer] CallEvent: Add helper methods for obtaining the callee stack frame.
Artem Dergachev [Wed, 1 Aug 2018 01:58:15 +0000 (01:58 +0000)]
[analyzer] CallEvent: Add helper methods for obtaining the callee stack frame.

Newly added methods allow reasoning about the stack frame of the call (as
opposed to the stack frame on which the call was made, which was always
available) - obtain the stack frame context, obtain parameter regions - even if
the call is not going to be (or was not) inlined, i.e. even if the analysis
has never actually entered the stack frame.

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

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

6 years agoSpeculative fix for buildbot failures after r338464.
Richard Smith [Wed, 1 Aug 2018 01:57:49 +0000 (01:57 +0000)]
Speculative fix for buildbot failures after r338464.

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

6 years agoAMDGPU: Add clamp bit to dot builtins
Konstantin Zhuravlyov [Wed, 1 Aug 2018 01:32:21 +0000 (01:32 +0000)]
AMDGPU: Add clamp bit to dot builtins

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

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

6 years agoAvoid exposing name for range-based for '__range' variables in lifetime warnings.
Richard Smith [Wed, 1 Aug 2018 01:03:33 +0000 (01:03 +0000)]
Avoid exposing name for range-based for '__range' variables in lifetime warnings.

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

6 years ago[P0936R0] add [[clang::lifetimebound]] attribute
Richard Smith [Wed, 1 Aug 2018 00:33:25 +0000 (00:33 +0000)]
[P0936R0] add [[clang::lifetimebound]] attribute

This patch adds support for a new attribute, [[clang::lifetimebound]], that
indicates that the lifetime of a function result is related to one of the
function arguments. When walking an initializer to make sure that the lifetime
of the initial value is at least as long as the lifetime of the initialized
object, we step through parameters (including the implicit object parameter of
a non-static member function) that are marked with this attribute.

There's nowhere to write an attribute on the implicit object parameter, so in
lieu of that, it may be applied to a function type (where it appears
immediately after the cv-qualifiers and ref-qualifier, which is as close to a
declaration of the implicit object parameter as we have). I'm currently
modeling this in the AST as the attribute appertaining to the function type.

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

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

6 years ago[constexpr] Support for constant evaluation of __builtin_memcpy and
Richard Smith [Tue, 31 Jul 2018 23:35:09 +0000 (23:35 +0000)]
[constexpr] Support for constant evaluation of __builtin_memcpy and
__builtin_memmove (in non-type-punning cases).

This is intended to permit libc++ to make std::copy etc constexpr
without sacrificing the optimization that uses memcpy on
trivially-copyable types.

__builtin_strcpy and __builtin_wcscpy are not handled by this change.
They'd be straightforward to add, but we haven't encountered a need for
them just yet.

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

6 years agoRevert r337635 "[Driver] Sanitizer support based on runtime library presence"
Reid Kleckner [Tue, 31 Jul 2018 21:57:35 +0000 (21:57 +0000)]
Revert r337635 "[Driver] Sanitizer support based on runtime library presence"

This change causes issues with distributed build systems, which may only
have compiler binaries without any runtime libraries. See discussion
about this on https://reviews.llvm.org/D15225.

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

6 years ago[analyzer] Fix eliding the same destructor twice due to buggy default arguments.
Artem Dergachev [Tue, 31 Jul 2018 21:17:40 +0000 (21:17 +0000)]
[analyzer] Fix eliding the same destructor twice due to buggy default arguments.

Because of incomplete support for CXXDefaultArgExpr, we cannot yet commit to
asserting that the same destructor won't be elided twice.

Suppress the assertion failure for now. Proper support is still an open problem.

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

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

6 years ago[CFG] [analyzer] NFC: Enumerate construction context layer kinds.
Artem Dergachev [Tue, 31 Jul 2018 21:12:42 +0000 (21:12 +0000)]
[CFG] [analyzer] NFC: Enumerate construction context layer kinds.

This is a refactoring patch; no functional change intended.

The common part of ConstructionContextLayer and ConstructedObjectKey is
factored out into a new structure, ConstructionContextItem.

Various sub-kinds of ConstructionContextItem are enumerated in order to
provide richer information about construction contexts.

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

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

6 years ago[serialization] PR34728: Don't assume that only a suffix of template
Richard Smith [Tue, 31 Jul 2018 21:01:53 +0000 (21:01 +0000)]
[serialization] PR34728: Don't assume that only a suffix of template
parameters can have default arguments.

At least for function templates and class template partial
specializations, it's possible for a template parameter with a default
argument to be followed by a non-pack template parameter with no default
argument, and this case was not properly handled here.

Testcase by Steve O'Brien!

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

6 years ago[CFG] [analyzer] Implement function argument construction contexts.
Artem Dergachev [Tue, 31 Jul 2018 20:45:53 +0000 (20:45 +0000)]
[CFG] [analyzer] Implement function argument construction contexts.

In r330377 and r338425 we have already identified what constitutes function
argument constructors and added stubs in order to prevent confusing them
with other temporary object constructors.

Now we implement a ConstructionContext sub-class to carry all the necessary
information about the construction site, namely call expression and argument
index.

On the analyzer side, the patch interacts with the recently implemented
pre-C++17 copy elision support in an interesting manner. If on the CFG side we
didn't find a construction context for the elidable constructor, we build
the CFG as if the elidable constructor is not elided, and the non-elided
constructor within it is a simple temporary. But the same problem may occur
in the analyzer: if the elidable constructor has a construction context but
the analyzer doesn't implement such context yet, the analyzer should also
try to skip copy elision and still inline the non-elided temporary constructor.
This was implemented by adding a "roll back" mechanism: when elision fails,
roll back the changes and proceed as if it's a simple temporary. The approach
is wonky, but i'm fine with that as long as it's merely a defensive mechanism
that should eventually go away once all construction contexts become supported.

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

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

6 years ago[analyzer] Move InnerPointerChecker out of alpha.
Reka Kovacs [Tue, 31 Jul 2018 20:27:11 +0000 (20:27 +0000)]
[analyzer] Move InnerPointerChecker out of alpha.

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

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

6 years ago[OpenCL] Forbid size dependent types used as kernel arguments
Alexey Sotkin [Tue, 31 Jul 2018 20:26:43 +0000 (20:26 +0000)]
[OpenCL] Forbid size dependent types used as kernel arguments

Summary:
Size_t, intptr_t, uintptr_t and ptrdiff_t cannot be used as kernel
arguments, according to OpenCL Specification s6.9k:
The size in bytes of these types are implementation-defined and in
addition can also be different for the OpenCL device and the host
processor making it difficult to allocate buffer objects to be passed
as arguments to a kernel declared as pointer to these types.

Patch by: Andrew Savonichev

Reviewers: Anastasia, yaxunl

Subscribers: yaxunl, Anastasia, cfe-commits

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

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

6 years ago[OpenCL] Check for invalid kernel arguments in array types
Alexey Sotkin [Tue, 31 Jul 2018 19:47:19 +0000 (19:47 +0000)]
[OpenCL] Check for invalid kernel arguments in array types

Summary:
OpenCL specification forbids use of several types as kernel arguments.
This patch improves existing diagnostic to look through arrays.

Patch by: Andrew Savonichev

Reviewers: Anastasia, yaxunl

Subscribers: yaxunl, Anastasia, cfe-commits

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

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

6 years ago[CFG] [analyzer] Add construction contexts for returning C++ objects in ObjC++.
Artem Dergachev [Tue, 31 Jul 2018 19:46:14 +0000 (19:46 +0000)]
[CFG] [analyzer] Add construction contexts for returning C++ objects in ObjC++.

Like any normal funciton, Objective-C message can return a C++ object
in Objective-C++. Such object would require a construction context.

This patch, therefore, is an extension of r327343 onto Objective-C++.

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

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

6 years ago[CFG] [analyzer] Add stubs for constructor and message argument constructors.
Artem Dergachev [Tue, 31 Jul 2018 19:39:37 +0000 (19:39 +0000)]
[CFG] [analyzer] Add stubs for constructor and message argument constructors.

CFG now correctly identifies construction context for temporaries constructed
for the purpose of passing into a function as an argument.

Such context is still not fully implemented because the information it provides
is not rich enough: it doens't contain information about argument index.
It will be addresssed later.

This patch is an extension of r330377 to C++ construct-expressions and
Objective-C message expressions which aren't call-expressions but require
similar handling. C++ new-expressions with placement arguments still remain to
be handled.

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

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

6 years ago[analyzer] Reuse some code in simplifySVal().
Artem Dergachev [Tue, 31 Jul 2018 19:29:25 +0000 (19:29 +0000)]
[analyzer] Reuse some code in simplifySVal().

No functional change intended.

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

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

6 years ago[analyzer] Don't try to simplify mixed Loc/NonLoc expressions.
Artem Dergachev [Tue, 31 Jul 2018 19:26:34 +0000 (19:26 +0000)]
[analyzer] Don't try to simplify mixed Loc/NonLoc expressions.

This fix is similar to r337769 and addresses a regression caused by r337167.

When an operation between a nonloc::LocAsInteger and a non-pointer symbol
is performed, the LocAsInteger-specific part of information is lost.
When the non-pointer symbol is collapsing into a constant, we cannot easily
re-evaluate the result, because we need to recover the missing
LocAsInteger-specific information (eg., integer type, or the very fact that
this pointer was at some point converted to an integer).

Add one more defensive check to prevent crashes on trying to simplify a
SymSymExpr with different Loc-ness of operands.

Differential Revision:

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

6 years agoFix riscv32-toolchain.c with CLANG_DEFAULT_CXX_STDLIB
Jonas Hahnfeld [Tue, 31 Jul 2018 18:47:48 +0000 (18:47 +0000)]
Fix riscv32-toolchain.c with CLANG_DEFAULT_CXX_STDLIB

This configuration was (again) broken after r338385 because Clang
might be configured to always use libc++.

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

6 years ago[OPENMP] Change linkage of offloading symbols to support dropping
Alexey Bataev [Tue, 31 Jul 2018 18:27:42 +0000 (18:27 +0000)]
[OPENMP] Change linkage of offloading symbols to support dropping
offload targets.

Changed the linkage of omp_offloading.img_start.<triple> and omp_offloading.img_end.<triple> symbols from external to external weak to allow dropping of some targets during linking.

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

6 years ago[COFF, ARM64] Enable SEH for ARM64 Windows
Mandeep Singh Grang [Tue, 31 Jul 2018 17:42:05 +0000 (17:42 +0000)]
[COFF, ARM64] Enable SEH for ARM64 Windows

Reviewers: rnk, mstorsjo, ssijaric, haripul, TomTan

Reviewed By: rnk

Subscribers: kristof.beyls, chrib, cfe-commits

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

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

6 years ago[OPENMP] Prevent problems with linking of the static variables.
Alexey Bataev [Tue, 31 Jul 2018 16:40:15 +0000 (16:40 +0000)]
[OPENMP] Prevent problems with linking of the static variables.

No need to change the linkage, we can avoid the problem using special variable. That points to the original variable and, thus, prevent some of the optimizations that might break the compilation.

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

6 years ago[RISCV] Add driver for riscv32-unknown-elf baremetal target
David Bolvansky [Tue, 31 Jul 2018 14:21:46 +0000 (14:21 +0000)]
[RISCV] Add driver for riscv32-unknown-elf baremetal target

Summary:
This patch adds a driver for the baremetal RISC-V target (i.e. riscv32-unknown-elf). For reference, D39963 added basic target info and added support for riscv32-linux-unknown-elf.

Patch by: asb (Alex Bradbury)

Reviewers: efriedma, phosek, apazos, espindola, mgrang

Reviewed By: mgrang

Subscribers: jrtc27, rogfer01, MartinMosbeck, brucehoult, the_o, rkruppe, emaste, mgorny, arichardson, rbar, johnrusso, simoncook, jordy.potman.lists, sabuasal, niosHD, kito-cheng, shiva0217, zzheng, edward-jones, mgrang, cfe-commits

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

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

6 years agoclang-format: try to make the doc for ConstructorInitializerAllOnOneLineOrOnePerLine...
Hans Wennborg [Tue, 31 Jul 2018 12:42:02 +0000 (12:42 +0000)]
clang-format: try to make the doc for ConstructorInitializerAllOnOneLineOrOnePerLine more clear

PR38080 complained that the "OnePerLine" case wasn't previously shown.

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

6 years agoFix linux-header-search.cpp with CLANG_DEFAULT_CXX_STDLIB
Jonas Hahnfeld [Tue, 31 Jul 2018 11:36:14 +0000 (11:36 +0000)]
Fix linux-header-search.cpp with CLANG_DEFAULT_CXX_STDLIB

This configuration was broken after r338294 because Clang might
be configured to always use libc++.

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

6 years agoImprove support of PDB as an external layout source
Aleksandr Urakov [Tue, 31 Jul 2018 08:27:06 +0000 (08:27 +0000)]
Improve support of PDB as an external layout source

Summary:
This patch improves support of PDB as an external layout source
in the next cases:

- Multiple non-virtual inheritance from packed base classes. When using
  external layout, there's no need to align `NonVirtualSize` of a base class.
  It may cause an overlapping when the next base classes will be layouted
  (but there is a slightly different case in the test because I can't find
  a way to specify a base offset);
- Support of nameless structs and unions. There is no info about nameless child
  structs and unions in Microsoft cl-emitted PDBs. Instead all its fields
  are just treated as outer structure's (union's) fields. This also causes
  a fields overlapping, and makes it possible for unions to have fields located
  at a non-zero offset.

Reviewers: rsmith, zturner, rnk, mstorsjo, majnemer

Reviewed By: rnk

Subscribers: cfe-commits

Tags: #clang

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

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

6 years ago[coroutines] Fix handling of dependent co_await in StmtProfiler.
Richard Smith [Tue, 31 Jul 2018 00:47:41 +0000 (00:47 +0000)]
[coroutines] Fix handling of dependent co_await in StmtProfiler.

Fix "Invalid operator call kind" error (llvm_unreachable) in
DecodeOperatorCall when profiling a dependent co_await.

Patch by Victor Zverovich!

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

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

6 years ago[analyzer] Rename test: cxx17-mandatory-elision.cpp -> copy-elision.cpp
Artem Dergachev [Tue, 31 Jul 2018 00:18:35 +0000 (00:18 +0000)]
[analyzer] Rename test: cxx17-mandatory-elision.cpp -> copy-elision.cpp

It reflects its contents more accurately. No functional change intended.

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

6 years ago[Sema] Relax a failing assert in TemplateArgumentLoc
Erik Pilkington [Tue, 31 Jul 2018 00:18:30 +0000 (00:18 +0000)]
[Sema] Relax a failing assert in TemplateArgumentLoc

Any of these template argument kinds can be represented with an expression, so
accept them in this constructor.

Patch by Balaji Iyer!

rdar://41459965

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

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

6 years ago[analyzer] CStringChecker: Remember to highlight the argument expression range.
Artem Dergachev [Mon, 30 Jul 2018 23:44:37 +0000 (23:44 +0000)]
[analyzer] CStringChecker: Remember to highlight the argument expression range.

When emitting a bug report, it is important to highlight which argument of the
call-expression is causing the problem.

Before:
warning: Null pointer argument in call to string comparison function
ā€‚ā€‚strcmp(a, b);
ā€‚ā€‚^~~~~~~~~~~~

After:
warning: Null pointer argument in call to string comparison function
ā€‚ā€‚strcmp(a, b);
ā€‚ā€‚^ā€‚ā€‚ā€‚ā€‚ā€‚ā€‚~

Affects other output modes as well, not just text.

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

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

6 years agoRevert "Add a definition for FieldSize that seems to make sense here."
Eric Christopher [Mon, 30 Jul 2018 23:21:51 +0000 (23:21 +0000)]
Revert "Add a definition for FieldSize that seems to make sense here."

This reverts commit r338327, the problem was previously fixed in r338321.

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

6 years agoAdd a definition for FieldSize that seems to make sense here.
Eric Christopher [Mon, 30 Jul 2018 23:17:27 +0000 (23:17 +0000)]
Add a definition for FieldSize that seems to make sense here.
This could be sunk out of the if statements, but fix the warning for now.

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

6 years ago[analyzer] [tests] Add an option for showing statistics after running tests.
George Karpenkov [Mon, 30 Jul 2018 23:01:47 +0000 (23:01 +0000)]
[analyzer] [tests] Add an option for showing statistics after running tests.

Do not show statistics by default.

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

6 years ago[analyzer] [tests] Style fixes for testing harness.
George Karpenkov [Mon, 30 Jul 2018 23:01:20 +0000 (23:01 +0000)]
[analyzer] [tests] Style fixes for testing harness.

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

6 years agoFix use of uninitialized variable in r338299
Scott Linder [Mon, 30 Jul 2018 22:52:07 +0000 (22:52 +0000)]
Fix use of uninitialized variable in r338299

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

6 years ago[analyzer] [NFC] Simplify some visitors by giving a convenient getter from state...
George Karpenkov [Mon, 30 Jul 2018 22:18:47 +0000 (22:18 +0000)]
[analyzer] [NFC] Simplify some visitors by giving a convenient getter from state to analysis manager

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

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

6 years ago[analyzer] Bugfix for autorelease + main run loop leak checker
George Karpenkov [Mon, 30 Jul 2018 22:18:21 +0000 (22:18 +0000)]
[analyzer] Bugfix for autorelease + main run loop leak checker

Do not warn when the other message-send-expression is correctly wrapped
in a different autorelease pool.

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

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

6 years ago[analyzer] Fix crash in RunLoopAutoreleaseChecker on empty children
George Karpenkov [Mon, 30 Jul 2018 21:44:15 +0000 (21:44 +0000)]
[analyzer] Fix crash in RunLoopAutoreleaseChecker on empty children

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

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

6 years ago[docs] UndefinedBehaviorSanitizer.rst: {,un}signed-integer-overflow: tune docs
Roman Lebedev [Mon, 30 Jul 2018 21:11:32 +0000 (21:11 +0000)]
[docs] UndefinedBehaviorSanitizer.rst: {,un}signed-integer-overflow: tune docs

Yes, i erroneously assumed that the "after" was meant,
but i was wrong:
> I really meant "performed before", for cases like 4u / -2,
> where -2 is implicitly converted to UINT_MAX - 2 before
> the computation. Conversions that are performed after
> a computation aren't part of the computation at all,
> so I think it's much clearer that they're not in scope
> for this sanitizer.

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

6 years agoAvoid returning an invalid end source loc
Stephen Kelly [Mon, 30 Jul 2018 20:39:14 +0000 (20:39 +0000)]
Avoid returning an invalid end source loc

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

6 years ago[DebugInfo][OpenCL] Generate correct block literal debug info for OpenCL
Scott Linder [Mon, 30 Jul 2018 20:31:11 +0000 (20:31 +0000)]
[DebugInfo][OpenCL] Generate correct block literal debug info for OpenCL

OpenCL block literal structs have different fields which are now correctly
identified in the debug info.

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

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

6 years ago[OpenEmbedded] Fix lib paths for OpenEmbedded targets
Mandeep Singh Grang [Mon, 30 Jul 2018 19:44:13 +0000 (19:44 +0000)]
[OpenEmbedded] Fix lib paths for OpenEmbedded targets

Summary:
The lib paths are not correctly picked up for OpenEmbedded sysroots (like arm-oe-linux-gnueabi) for 2 reasons:

1. OpenEmbedded sysroots are of the form <sysroot>/usr/lib/<triple>/x.y.z. This form is handled in clang but only for Freescale vendor.

2. 64-bit OpenEmbedded sysroots may not have a /usr/lib dir. So they cannot find /usr/lib64 as it is referenced as /usr/lib/../lib64 in clang.

This is a follow-up to the llvm patch: D48861

Reviewers: dlj, rengolin, fedor.sergeev, javed.absar, hfinkel, rsmith

Reviewed By: rsmith

Subscribers: rsmith, kristof.beyls, cfe-commits

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

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

6 years agoRemove trailing space
Fangrui Song [Mon, 30 Jul 2018 19:24:48 +0000 (19:24 +0000)]
Remove trailing space

sed -Ei 's/[[:space:]]+$//' include/**/*.{def,h,td} lib/**/*.{cpp,h}

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

6 years agoMake test/Driver/baremetal.cpp work with linkers other than lld
David Greene [Mon, 30 Jul 2018 19:08:20 +0000 (19:08 +0000)]
Make test/Driver/baremetal.cpp work with linkers other than lld

This test fails if clang is configure with, for example, gold as the
default linker. It does not appear that this test really relies on lld
so make the checks accept ld, ld.gold and ld.bfd too.

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

6 years ago[clang][ubsan] Implicit Conversion Sanitizer - integer truncation - clang part
Roman Lebedev [Mon, 30 Jul 2018 18:58:30 +0000 (18:58 +0000)]
[clang][ubsan] Implicit Conversion Sanitizer - integer truncation  - clang part

Summary:
C and C++ are interesting languages. They are statically typed, but weakly.
The implicit conversions are allowed. This is nice, allows to write code
while balancing between getting drowned in everything being convertible,
and nothing being convertible. As usual, this comes with a price:

```
unsigned char store = 0;

bool consume(unsigned int val);

void test(unsigned long val) {
  if (consume(val)) {
    // the 'val' is `unsigned long`, but `consume()` takes `unsigned int`.
    // If their bit widths are different on this platform, the implicit
    // truncation happens. And if that `unsigned long` had a value bigger
    // than UINT_MAX, then you may or may not have a bug.

    // Similarly, integer addition happens on `int`s, so `store` will
    // be promoted to an `int`, the sum calculated (0+768=768),
    // and the result demoted to `unsigned char`, and stored to `store`.
    // In this case, the `store` will still be 0. Again, not always intended.
    store = store + 768; // before addition, 'store' was promoted to int.
  }

  // But yes, sometimes this is intentional.
  // You can either make the conversion explicit
  (void)consume((unsigned int)val);
  // or mask the value so no bits will be *implicitly* lost.
  (void)consume((~((unsigned int)0)) & val);
}
```

Yes, there is a `-Wconversion`` diagnostic group, but first, it is kinda
noisy, since it warns on everything (unlike sanitizers, warning on an
actual issues), and second, there are cases where it does **not** warn.
So a Sanitizer is needed. I don't have any motivational numbers, but i know
i had this kind of problem 10-20 times, and it was never easy to track down.

The logic to detect whether an truncation has happened is pretty simple
if you think about it - https://godbolt.org/g/NEzXbb - basically, just
extend (using the new, not original!, signedness) the 'truncated' value
back to it's original width, and equality-compare it with the original value.

The most non-trivial thing here is the logic to detect whether this
`ImplicitCastExpr` AST node is **actually** an implicit conversion, //or//
part of an explicit cast. Because the explicit casts are modeled as an outer
`ExplicitCastExpr` with some `ImplicitCastExpr`'s as **direct** children.
https://godbolt.org/g/eE1GkJ

Nowadays, we can just use the new `part_of_explicit_cast` flag, which is set
on all the implicitly-added `ImplicitCastExpr`'s of an `ExplicitCastExpr`.
So if that flag is **not** set, then it is an actual implicit conversion.

As you may have noted, this isn't just named `-fsanitize=implicit-integer-truncation`.
There are potentially some more implicit conversions to be warned about.
Namely, implicit conversions that result in sign change; implicit conversion
between different floating point types, or between fp and an integer,
when again, that conversion is lossy.

One thing i know isn't handled is bitfields.

This is a clang part.
The compiler-rt part is D48959.

Fixes [[ https://bugs.llvm.org/show_bug.cgi?id=21530 | PR21530 ]], [[ https://bugs.llvm.org/show_bug.cgi?id=37552 | PR37552 ]], [[ https://bugs.llvm.org/show_bug.cgi?id=35409 | PR35409 ]].
Partially fixes [[ https://bugs.llvm.org/show_bug.cgi?id=9821 | PR9821 ]].
Fixes https://github.com/google/sanitizers/issues/940. (other than sign-changing implicit conversions)

Reviewers: rjmccall, rsmith, samsonov, pcc, vsk, eugenis, efriedma, kcc, erichkeane

Reviewed By: rsmith, vsk, erichkeane

Subscribers: erichkeane, klimek, #sanitizers, aaron.ballman, RKSimon, dtzWill, filcab, danielaustin, ygribov, dvyukov, milianw, mclow.lists, cfe-commits, regehr

Tags: #sanitizers

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

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

6 years ago[analyzer] Store ValueDecl in DeclRegion
George Karpenkov [Mon, 30 Jul 2018 18:57:13 +0000 (18:57 +0000)]
[analyzer] Store ValueDecl in DeclRegion

All use cases of DeclRegion actually have ValueDecl there,
and getting the name from declaration comes in very handy.

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

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

6 years agoDelete some unreachable AST printing code.
Richard Smith [Mon, 30 Jul 2018 18:05:19 +0000 (18:05 +0000)]
Delete some unreachable AST printing code.

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

6 years ago[ARM, AArch64]: Use unadjusted alignment when passing composites as arguments
Momchil Velikov [Mon, 30 Jul 2018 17:48:23 +0000 (17:48 +0000)]
[ARM, AArch64]: Use unadjusted alignment when passing composites as arguments

The "Procedure Call Procedure Call Standard for the ARMĀ® Architecture"
(https://static.docs.arm.com/ihi0042/f/IHI0042F_aapcs.pdf), specifies that
composite types are passed according to their "natural alignment", i.e. the
alignment before alignment adjustment on the entire composite is applied.

The same applies for AArch64 ABI.

Clang, however, used the adjusted alignment.

GCC already implements the ABI correctly. With this patch Clang becomes
compatible with GCC and passes such arguments in accordance with AAPCS.

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

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

6 years ago[analyzer] Add missing state transition in IteratorChecker.
Reka Kovacs [Mon, 30 Jul 2018 16:14:59 +0000 (16:14 +0000)]
[analyzer] Add missing state transition in IteratorChecker.

After cleaning up program state maps in `checkDeadSymbols()`,
a transition should be added to generate the new state.

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

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

6 years ago[analyzer] Add support for more invalidating functions in InnerPointerChecker.
Reka Kovacs [Mon, 30 Jul 2018 15:43:45 +0000 (15:43 +0000)]
[analyzer] Add support for more invalidating functions in InnerPointerChecker.

According to the standard, pointers referring to the elements of a
`basic_string` may be invalidated if they are used as an argument to
any standard library function taking a reference to non-const
`basic_string` as an argument. This patch makes InnerPointerChecker warn
for these cases.

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

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

6 years ago[CodeComplete] Fix the crash in code completion on access checking
Ilya Biryukov [Mon, 30 Jul 2018 15:19:05 +0000 (15:19 +0000)]
[CodeComplete] Fix the crash in code completion on access checking

Started crashing in r337453. See the added test case for the crash repro.

The fix reverts part of r337453 that causes the crash and does
not actually break anything when reverted.

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

6 years ago[OPENMP] Modify the info about OpenMP support in UsersManual, NFC.
Alexey Bataev [Mon, 30 Jul 2018 14:44:29 +0000 (14:44 +0000)]
[OPENMP] Modify the info about OpenMP support in UsersManual, NFC.

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

6 years ago[mips64][clang] Adjust tests to account for changes in r338239
Stefan Maksimovic [Mon, 30 Jul 2018 12:27:40 +0000 (12:27 +0000)]
[mips64][clang] Adjust tests to account for changes in r338239

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

6 years ago[clang-format] Silence -Wdocumentation warnings
Krasimir Georgiev [Mon, 30 Jul 2018 12:22:41 +0000 (12:22 +0000)]
[clang-format] Silence -Wdocumentation warnings

introduced in r338232

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

6 years ago[mips64][clang] Provide the signext attribute for i32 return values
Stefan Maksimovic [Mon, 30 Jul 2018 10:44:46 +0000 (10:44 +0000)]
[mips64][clang] Provide the signext attribute for i32 return values

Additional info: see r338019.

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

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

6 years agoFix -Wdocumentation warning. NFCI.
Simon Pilgrim [Mon, 30 Jul 2018 10:07:47 +0000 (10:07 +0000)]
Fix -Wdocumentation warning. NFCI.

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

6 years ago[Analyzer] Iterator Checker Hotfix: Defer deletion of container data until its last...
Adam Balogh [Mon, 30 Jul 2018 08:52:21 +0000 (08:52 +0000)]
[Analyzer] Iterator Checker Hotfix: Defer deletion of container data until its last iterator is cleaned up

The analyzer may consider a container region as dead while it still has live
iterators. We must defer deletion of the data belonging to such containers
until all its iterators are dead as well to be able to compare the iterator
to the begin and the end of the container which is stored in the container
data.

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

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

6 years ago[clang-format] Indent after breaking Javadoc annotated line
Krasimir Georgiev [Mon, 30 Jul 2018 08:45:45 +0000 (08:45 +0000)]
[clang-format] Indent after breaking Javadoc annotated line

Summary:
This patch makes clang-format indent the subsequent lines created by breaking a
long javadoc annotated line.

Reviewers: mprobst

Reviewed By: mprobst

Subscribers: acoomans, cfe-commits

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

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

6 years agoPR38355 Prevent infinite recursion when checking initializer lifetime if
Richard Smith [Mon, 30 Jul 2018 07:19:54 +0000 (07:19 +0000)]
PR38355 Prevent infinite recursion when checking initializer lifetime if
an initializer is self-referential.

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

6 years agoRevert r337456: [CodeGen] Disable aggressive structor optimizations at -O0, take 3
Chandler Carruth [Sun, 29 Jul 2018 03:05:07 +0000 (03:05 +0000)]
Revert r337456: [CodeGen] Disable aggressive structor optimizations at -O0, take 3

This commit increases the number of sections and overall output size of
.o files by 10% and sometimes a bit more. This alone is challenging for
some users, but it also appears to trigger an as-yet unexplained
behavior in the Gold linker where the memory usage increases
considerably more than 10% (we think).

The increase is also frustrating because in many (if not all) cases we
end up with almost all of the growth coming from the ELF overhead of
-ffunction-sections and such, not from actual extra code being emitted.

Richard Smith and Eric Christopher are both going to investigate this
and try to get to the bottom of what is triggering this and whether the
kinds of increases here are sustainable or what options we might have to
minimize the impact they have. However, this is currently breaking
a pretty large number of our users' builds so reverting it while we sort
out how to make progress here. I've seen a longer and more detailed
update to the commit thread.

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

6 years ago[UBSan] Strengthen pointer checks in 'new' expressions
Serge Pavlov [Sat, 28 Jul 2018 15:33:03 +0000 (15:33 +0000)]
[UBSan] Strengthen pointer checks in 'new' expressions

With this change compiler generates alignment checks for wider range
of types. Previously such checks were generated only for the record types
with non-trivial default constructor. So the types like:

    struct alignas(32) S2 { int x; };
    typedef __attribute__((ext_vector_type(2), aligned(32))) float float32x2_t;

did not get checks when allocated by 'new' expression.

This change also optimizes the checks generated for the arrays created
in 'new' expressions. Previously the check was generated for each
invocation of type constructor. Now the check is generated only once
for entire array.

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

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

6 years ago[Sema][ObjC] Warn when a method declared in a protocol takes a
Akira Hatanaka [Sat, 28 Jul 2018 04:06:13 +0000 (04:06 +0000)]
[Sema][ObjC] Warn when a method declared in a protocol takes a
non-escaping parameter but the implementation's method takes an escaping
parameter.

rdar://problem/39548196

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

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

6 years ago[CUDA][HIP] Allow function-scope static const variable
Yaxun Liu [Sat, 28 Jul 2018 03:05:25 +0000 (03:05 +0000)]
[CUDA][HIP] Allow function-scope static const variable

CUDA 8.0 E.3.9.4 says: Within the body of a __device__ or __global__
function, only __shared__ variables or variables without any device
memory qualifiers may be declared with static storage class.

It is unclear how a function-scope non-const static variable
without device memory qualifier is implemented, therefore only static
const variable without device memory qualifier is allowed, which
can be emitted as a global variable in constant address space.

Currently clang only allows function-scope static variable with
__shared__ qualifier.

This patch also allows function-scope static const variable without
device memory qualifier and emits it as a global variable in constant
address space.

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

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

6 years ago[AST] Add a convenient getter from QualType to RecordDecl
George Karpenkov [Sat, 28 Jul 2018 02:16:13 +0000 (02:16 +0000)]
[AST] Add a convenient getter from QualType to RecordDecl

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

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

6 years agoCompile SemaTemplate.cpp with /bigobj on MSVC
Erik Pilkington [Sat, 28 Jul 2018 01:29:31 +0000 (01:29 +0000)]
Compile SemaTemplate.cpp with /bigobj on MSVC

This should fix some bot failures introduced by r338165.

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

6 years ago[CFG] Remove duplicate function/class names at the beginning of comments
Fangrui Song [Sat, 28 Jul 2018 00:48:05 +0000 (00:48 +0000)]
[CFG] Remove duplicate function/class names at the beginning of comments

Some functions/classes have renamed while the comments still use the old names. Delete them per coding style.

Also some whitespace cleanup.

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

6 years agoParse a possible trailing postfix expression suffix after a fold expression
Nicolas Lesser [Fri, 27 Jul 2018 21:55:12 +0000 (21:55 +0000)]
Parse a possible trailing postfix expression suffix after a fold expression

Summary:
This patch allows the parsing of a postfix expression involving a fold expression, which is legal as a fold-expression is a primary-expression.

See also https://llvm.org/pr38282

Reviewers: rsmith

Reviewed By: rsmith

Subscribers: cfe-commits

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

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

6 years ago[Sema] Use a TreeTransform to extract deduction guide parameter types
Erik Pilkington [Fri, 27 Jul 2018 21:23:48 +0000 (21:23 +0000)]
[Sema] Use a TreeTransform to extract deduction guide parameter types

Previously, we just canonicalized the type, but this lead to crashes with
parameter types that referred to ParmVarDecls of the constructor. There may be
more cases that this TreeTransform needs to handle though, such as a constructor
parameter type referring to a member in an unevaluated context. Canonicalization
doesn't address these cases either though, so we can address them as-needed in
follow-up commits.

rdar://41330135

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

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