]> granicus.if.org Git - clang/log
clang
5 years agoFix typo
Adrian Prantl [Fri, 8 Feb 2019 21:13:25 +0000 (21:13 +0000)]
Fix typo

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

5 years ago[analyzer] Opt-in C Style Cast Checker for OSObject pointers
George Karpenkov [Fri, 8 Feb 2019 21:09:00 +0000 (21:09 +0000)]
[analyzer] Opt-in C Style Cast Checker for OSObject pointers

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

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

5 years agoPass the base element type of an array type to the visit method instead
Akira Hatanaka [Fri, 8 Feb 2019 19:46:53 +0000 (19:46 +0000)]
Pass the base element type of an array type to the visit method instead
of the array type itself.

This fixes a bug found by inspection that was introduced in r353459. I
don't have a test case for this since we don't yet have types that would
make the containing C struct non-trivial to copy/move but wouldn't make
it non-trivial to default-initialize or destruct.

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

5 years ago[X86] Add explicit alignment to __m128/__m128i/__m128d/etc. to allow matching of...
Craig Topper [Fri, 8 Feb 2019 19:45:08 +0000 (19:45 +0000)]
[X86] Add explicit alignment to __m128/__m128i/__m128d/etc. to allow matching of MSVC behavior with #pragma pack.

Summary:
With MSVC, #pragma pack is ignored when there is explicit alignment. This differs from gcc. Clang emulates this difference when compiling for Windows.

It appears that MSVC and its headers consider the __m128/__m128i/__m128d/etc. types to be explicitly aligned and ignores #pragma pack for them. Since we don't have explicit alignment on them in our headers, we don't match the MSVC behavior here.

This patch adds explicit alignment to match this behavior. I'm hoping this won't cause any problems when we're not emulating MSVC. But if someone knows of something that would be different we can swith to conditionally adding the alignment based on _MSC_VER.

I had to add explicitly unaligned types as well so we could use them in the loadu/storeu intrinsics which use __attribute__(__packed__). Using the now explicitly aligned types wouldn't produce align 1 accesses when targeting Windows.

Reviewers: rnk, erichkeane, spatel, RKSimon

Subscribers: cfe-commits

Tags: #clang

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

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

5 years ago[OPENMP]Delay emission of the error messages for the exceptions.
Alexey Bataev [Fri, 8 Feb 2019 18:02:25 +0000 (18:02 +0000)]
[OPENMP]Delay emission of the error messages for the exceptions.

Fixed diagnostic emission for the exceptions support in case of the
compilation of OpenMP code for the devices. From now on, it uses delayed
diagnostics mechanism, previously used for CUDA only. It allow to
diagnose not allowed used of exceptions only in functions that are going
to be codegen'ed.

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

5 years agoRevert "[OPENMP]Initial support for the delayed diagnostics."
Alexey Bataev [Fri, 8 Feb 2019 17:42:00 +0000 (17:42 +0000)]
Revert "[OPENMP]Initial support for the delayed diagnostics."

This reverts commit r353540. Erroneously committed, need to fix the
message and description.

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

5 years ago[OPENMP]Initial support for the delayed diagnostics.
Alexey Bataev [Fri, 8 Feb 2019 17:38:09 +0000 (17:38 +0000)]
[OPENMP]Initial support for the delayed diagnostics.

It is important to delay the emission of the diagnostic messages for the
functions unless it is proved that the function is going to be used on
the device side. It is required to support compilation with some of the
target-specific system headers.

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

5 years ago[ASTMatchers][NFC] Update comments on assorted `CXXMemberCallExpr` matchers.
Yitzhak Mandelbaum [Fri, 8 Feb 2019 16:00:44 +0000 (16:00 +0000)]
[ASTMatchers][NFC] Update comments on assorted `CXXMemberCallExpr` matchers.

Specifically:

* fixes the comments on `hasObjectExpression`,
* clarifies comments on `thisPointerType` and `on`,
* adds comments to `onImplicitObjectArgument`.

It also updates associated reference docs (using the doc tool).

Reviewers: alexfh, steveire, aaron.ballman

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

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

5 years ago[Format/ObjC] Fix [foo bar]->baz formatting as lambda arrow
Ben Hamilton [Fri, 8 Feb 2019 15:55:18 +0000 (15:55 +0000)]
[Format/ObjC] Fix [foo bar]->baz formatting as lambda arrow

Summary:
Currently, `UnwrappedLineParser` thinks an arrow token after
an ObjC method expression is a C++ lambda arrow, so it formats:

```
[foo bar]->baz
```

as:

```
[foo bar] -> baz
```

Because `UnwrappedLineParser` runs before `TokenAnnotator`, it can't
know if the arrow token is after an ObjC method expression or not.

This diff makes `TokenAnnotator` remove the TT_LambdaArrow on
the arrow token if it follows an ObjC method expression.

Test Plan: New test added. Ran test with:
  % ninja FormatTests && ./tools/clang/unittests/Format/FormatTests
  Confirmed test failed before diff and passed after diff.

Reviewers: krasimir, djasper, sammccall

Reviewed By: sammccall

Subscribers: cfe-commits

Tags: #clang

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

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

5 years ago[opaque pointer types] Cleanup CGBuilder's Create*GEP.
James Y Knight [Fri, 8 Feb 2019 15:34:12 +0000 (15:34 +0000)]
[opaque pointer types] Cleanup CGBuilder's Create*GEP.

Some of these functions take some extraneous arguments, e.g. EltSize,
Offset, which are computable from the Type and DataLayout.

Add some asserts to ensure that the computed values are consistent
with the passed-in values, in preparation for eliminating the
extraneous arguments. This also asserts that the Type is an Array for
the calls named "Array" and a Struct for the calls named "Struct".

Then, correct a couple of errors:

1. Using CreateStructGEP on an array type. (this causes the majority
   of the test differences, as struct GEPs are created with i32
   indices, while array GEPs are created with i64 indices)

2. Passing the wrong Offset to CreateStructGEP in TargetInfo.cpp on
   x86-64 NACL (which uses 32-bit pointers).

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

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

5 years ago[ASTImporter][ASTImporterSpecificLookup] Add test for different operators
Gabor Marton [Fri, 8 Feb 2019 09:19:34 +0000 (09:19 +0000)]
[ASTImporter][ASTImporterSpecificLookup] Add test for different operators

Summary:
This is to check that operators are handled properly in
`ASTImporterSpecificLookup`.  Note, this lookup table is not used in LLDB, only
in CTU.

Reviewers: a_sidorin, shafik, a.sidorin

Subscribers: rnkovacs, dkrupp, Szelethus, gamesh411, cfe-commits

Tags: #clang

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

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

5 years ago[AST] Fix structural inequivalence of operators
Gabor Marton [Fri, 8 Feb 2019 08:55:32 +0000 (08:55 +0000)]
[AST] Fix structural inequivalence of operators

Summary: Operators kind was not checked, so we reported e.g. op- to be equal with op+

Reviewers: shafik, a_sidorin, aaron.ballman

Subscribers: rnkovacs, dkrupp, Szelethus, gamesh411, cfe-commits

Tags: #clang

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

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

5 years agoVariable auto-init: fix __block initialization
JF Bastien [Fri, 8 Feb 2019 01:29:17 +0000 (01:29 +0000)]
Variable auto-init: fix __block initialization

Summary:
Automatic initialization [1] of __block variables was trampling over the block's
headers after they'd been initialized, which caused self-init usage to crash,
such as here:

  typedef struct XYZ { void (^block)(); } *xyz_t;
  __attribute__((noinline))
  xyz_t create(void (^block)()) {
    xyz_t myself = malloc(sizeof(struct XYZ));
    myself->block = block;
    return myself;
  }
  int main() {
    __block xyz_t captured = create(^(){ (void)captured; });
  }

This type of code shouldn't be broken by variable auto-init, even if it's
sketchy.

[1] With -ftrivial-auto-var-init=pattern

<rdar://problem/47798396>

Reviewers: rjmccall, pcc, kcc

Subscribers: jkorous, dexonsmith, cfe-commits

Tags: #clang

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

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

5 years ago[COFF, ARM64] Fix types for _ReadStatusReg, _WriteStatusReg
Eli Friedman [Fri, 8 Feb 2019 01:17:49 +0000 (01:17 +0000)]
[COFF, ARM64] Fix types for _ReadStatusReg, _WriteStatusReg

r344765 added those intrinsics, but used the wrong types.

Patch by Mike Hommey

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

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

5 years ago[NFC] Variable auto-init: use getAsVariableArrayType helper
JF Bastien [Fri, 8 Feb 2019 00:51:05 +0000 (00:51 +0000)]
[NFC] Variable auto-init: use getAsVariableArrayType helper

As suggested by @rjmccall in D57797.

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

5 years agobpf: teach BPF driver about the new CPU "v3"
Jiong Wang [Thu, 7 Feb 2019 22:51:56 +0000 (22:51 +0000)]
bpf: teach BPF driver about the new CPU "v3"

This patch simply teach BPF driver about the new CPU "v3" introduced in
LLVM backend.

Acked-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Jiong Wang <jiong.wang@netronome.com>
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@353479 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[Sema][ObjC] Disallow non-trivial C struct fields in unions.
Akira Hatanaka [Thu, 7 Feb 2019 20:21:46 +0000 (20:21 +0000)]
[Sema][ObjC] Disallow non-trivial C struct fields in unions.

This patch fixes a bug where clang doesn’t reject union fields of
non-trivial C struct types. For example:

```
// This struct is non-trivial under ARC.
struct S0 {
  id x;
};

union U0 {
  struct S0 s0; // clang should reject this.
  struct S0 s1; // clang should reject this.
};

void test(union U0 a) {
  // Previously, both 'a.s0.x' and 'a.s1.x' were released in this
  // function.
}
```

rdar://problem/46677858

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

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

5 years ago[SEMA]Generalize deferred diagnostic interface, NFC.
Alexey Bataev [Thu, 7 Feb 2019 19:46:42 +0000 (19:46 +0000)]
[SEMA]Generalize deferred diagnostic interface, NFC.

Summary:
Deferred diagnostic interface is going to be used for OpenMP device
compilation. Generalized previously existed deferred diagnostic
interface for CUDA to be used with OpenMP and, possibly, other models.

Reviewers: rjmccall, tra

Subscribers: caomhin, cfe-commits, kkwli0

Tags: #clang

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

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

5 years ago[OpenCL][PR40603] In C++ preserve compatibility with OpenCL C v2.0
Anastasia Stulova [Thu, 7 Feb 2019 17:32:37 +0000 (17:32 +0000)]
[OpenCL][PR40603] In C++ preserve compatibility with OpenCL C v2.0

Valid OpenCL C code should still compile in C++ mode.

This change enables extensions and OpenCL types.

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

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

5 years ago[ASTImporter] Refactor unittests to be able to parameterize them in a more flexible way
Gabor Marton [Thu, 7 Feb 2019 16:52:48 +0000 (16:52 +0000)]
[ASTImporter] Refactor unittests to be able to parameterize them in a more flexible way

Summary:
Currently `TestImportBase` is derived from `ParameterizedTestsFixture`
which explicitly states that the gtest parameter can be only an
`ArgVector`. This is a limitation when we want to create tests which may
have different parameters.
E.g. we would like to create tests where we can combine different test
parameters. So, for example we'd like gtest to be able to provide
parameters of `<std::tuple<ArgVector, const char *>` instead of a simple
`ArgVector`.

Reviewers: a_sidorin, shafik, a.sidorin

Subscribers: rnkovacs, dkrupp, Szelethus, gamesh411, cfe-commits

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

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

5 years agoFix r350643 to limit COFF emission to <= 32 BYTES instead of BITS.
Erich Keane [Thu, 7 Feb 2019 15:14:11 +0000 (15:14 +0000)]
Fix r350643 to limit COFF emission to <= 32 BYTES instead of BITS.

The patch in r350643 incorrectly sets the COFF emission based on bits
instead of bytes. This patch converts the 32 via CharUnits to bits to
compare the correct values.

Change-Id: Icf38a16470ad5ae3531374969c033557ddb0d323

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

5 years ago[clang-cl] support /Oy- on aarch64
Martin Storsjo [Thu, 7 Feb 2019 12:46:49 +0000 (12:46 +0000)]
[clang-cl] support /Oy- on aarch64

MSVC supports /Oy- on aarch64, so clang-cl should too.

Patch by Nathan Froyd!

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

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

5 years agoTypo: s/follwing/following
Hans Wennborg [Thu, 7 Feb 2019 11:13:28 +0000 (11:13 +0000)]
Typo: s/follwing/following

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

5 years agoMove the SMT API to LLVM
Mikhail R. Gadelha [Thu, 7 Feb 2019 03:19:45 +0000 (03:19 +0000)]
Move the SMT API to LLVM

Moved everything SMT-related to LLVM and updated the cmake scripts.

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

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

5 years agoMoved the whole SMT API to a single file. NFC.
Mikhail R. Gadelha [Thu, 7 Feb 2019 03:18:21 +0000 (03:18 +0000)]
Moved the whole SMT API to a single file. NFC.

There is no advantage in having them in separate files, I doubt some will ever use them separately.

This also makes it easier to move the API to LLVM.

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

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

5 years agoGot rid of the `Z3ConstraintManager` class
Mikhail R. Gadelha [Thu, 7 Feb 2019 03:18:10 +0000 (03:18 +0000)]
Got rid of the `Z3ConstraintManager` class

Now, instead of passing the reference to a shared_ptr, we pass the shared_ptr instead.

I've also removed the check if Z3 is present in CreateZ3ConstraintManager as this function already calls CreateZ3Solver that performs the exactly same check.

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

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

5 years agoGeneralised the SMT state constraints
Mikhail R. Gadelha [Thu, 7 Feb 2019 03:17:36 +0000 (03:17 +0000)]
Generalised the SMT state constraints

This patch moves the ConstraintSMT definition to the SMTConstraintManager header to make it easier to move the Z3 backend around.

We achieve this by not using shared_ptr  anymore, as llvm::ImmutableSet doesn't seem to like it.

The solver specific exprs and sorts are cached in the Z3Solver object now and we move pointers to those objects around.

As a nice side-effect, SMTConstraintManager doesn't have to be a template anymore. Yay!

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

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

5 years ago[opaque pointer types] Make EmitCall pass Function Types to
James Y Knight [Thu, 7 Feb 2019 01:15:41 +0000 (01:15 +0000)]
[opaque pointer types] Make EmitCall pass Function Types to
CreateCall/Invoke.

Also, remove the getFunctionType() function from CGCallee, since it
accesses the pointee type of the value. The only use was in EmitCall,
so just inline it into the debug assertion.

This is the last of the changes for Call and Invoke in clang.

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

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

5 years ago[opaque pointer types] Pass through function types for TLS
James Y Knight [Thu, 7 Feb 2019 01:14:17 +0000 (01:14 +0000)]
[opaque pointer types] Pass through function types for TLS
initialization and global destructor calls.

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

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

5 years ago[analyzer] Canonicalize declarations within variable regions.
Artem Dergachev [Thu, 7 Feb 2019 00:30:20 +0000 (00:30 +0000)]
[analyzer] Canonicalize declarations within variable regions.

Memory region that correspond to a variable is identified by the variable's
declaration and, in case of local variables, the stack frame it belongs to.

The declaration needs to be canonical, otherwise we'd have two different
memory regions that correspond to the same variable.

Fix such bug for global variables with forward declarations and assert
that no other problems of this kind happen.

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

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

5 years agoRevert "[analyzer] Remove the "postponed" hack, deal with derived symbols..."
Artem Dergachev [Wed, 6 Feb 2019 23:56:43 +0000 (23:56 +0000)]
Revert "[analyzer] Remove the "postponed" hack, deal with derived symbols..."

This reverts commit r341722.

The "postponed" mechanism turns out to be necessary in order to handle
situations when a symbolic region is only kept alive by implicit bindings
in the Store. Otherwise the region is never scanned by the Store's worklist
and the binding gets dropped despite being live, as demonstrated
by the newly added tests.

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

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

5 years ago[COFF, ARM64] Add ARM64 support for MS intrinsic _fastfail
Tom Tan [Wed, 6 Feb 2019 20:08:26 +0000 (20:08 +0000)]
[COFF, ARM64] Add ARM64 support for MS intrinsic _fastfail

The MSDN document was also updated to reflect this, but it probably will take a few days to show in below link.

https://docs.microsoft.com/en-us/cpp/intrinsics/fastfail

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

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

5 years agoTest commit. NFC
Patrick Lyster [Wed, 6 Feb 2019 18:18:02 +0000 (18:18 +0000)]
Test commit. NFC

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

5 years agoSwitch to cantFail(), since it does the same assertion.
Stephen Hines [Wed, 6 Feb 2019 17:59:39 +0000 (17:59 +0000)]
Switch to cantFail(), since it does the same assertion.

Reviewers: cfe-commits, lhames

Reviewed By: lhames

Subscribers: hintonda, klimek, pirama

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

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

5 years ago[CMake] Unify scripts for generating VCS headers
Petr Hosek [Wed, 6 Feb 2019 03:51:00 +0000 (03:51 +0000)]
[CMake] Unify scripts for generating VCS headers

Previously, there were two different scripts for generating VCS headers:
one used by LLVM and one used by Clang and lldb. They were both similar,
but different. They were both broken in their own ways, for example the
one used by Clang didn't properly handle monorepo resulting in an
incorrect version information reported by Clang.

This change unifies two the scripts by introducing a new script that's
used from both LLVM, Clang and lldb, ensures that the new script
supports both monorepo and standalone SVN and Git setups, and removes
the old scripts.

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

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

5 years ago[WebAssembly] Add atomics target option
Heejin Ahn [Wed, 6 Feb 2019 01:41:26 +0000 (01:41 +0000)]
[WebAssembly] Add atomics target option

Reviewers: tlively

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

Tags: #clang

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

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

5 years agoFix MSVC constructor call extension after b92d290e48e9 (r353181).
James Y Knight [Wed, 6 Feb 2019 00:06:03 +0000 (00:06 +0000)]
Fix MSVC constructor call extension after b92d290e48e9 (r353181).

The assert added to EmitCall there was triggering in Windows Chromium
builds, due to a mismatch of the return type.

The MSVC constructor call extension (`this->Foo::Foo()`) was emitting
the constructor call from 'EmitCXXMemberOrOperatorMemberCallExpr' via
calling 'EmitCXXMemberOrOperatorCall', instead of
'EmitCXXConstructorCall'. On targets where HasThisReturn is true, that
was failing to set the proper return type in the call info.

Switching to calling EmitCXXConstructorCall also allowed removing some
code e.g. the trivial copy/move support, which is already handled in
EmitCXXConstructorCall.

Ref: https://bugs.chromium.org/p/chromium/issues/detail?id=928861
Differential Revision: https://reviews.llvm.org/D57794

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

5 years ago[modules] Fix handling of initializers for templated global variables.
Richard Smith [Tue, 5 Feb 2019 23:37:13 +0000 (23:37 +0000)]
[modules] Fix handling of initializers for templated global variables.

For global variables with unordered initialization that are instantiated
within a module, we previously did not emit the global (or its
initializer) at all unless it was used in the importing translation unit
(and sometimes not even then!), leading to misbehavior and link errors.

We now emit the initializer for an instantiated global variable with
unordered initialization with side-effects in a module into every
translation unit that imports the module. This is unfortunate, but
mostly matches the behavior of a non-modular compilation and seems to be
the best that we can reasonably do.

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

5 years agoBasic CUDA-10 support.
Artem Belevich [Tue, 5 Feb 2019 22:38:58 +0000 (22:38 +0000)]
Basic CUDA-10 support.

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

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

5 years ago[Preprocessor] Add a note with framework location for "file not found" error.
Volodymyr Sapsai [Tue, 5 Feb 2019 22:34:55 +0000 (22:34 +0000)]
[Preprocessor] Add a note with framework location for "file not found" error.

When a framework with the same name is available at multiple framework
search paths, we use the first matching location. If a framework at this
location doesn't have all the headers, it can be confusing for
developers because they see only an error `'Foo/Foo.h' file not found`,
can find the complete framework with required header, and don't know the
incomplete framework was used instead.

Add a note explaining a framework without required header was found.
Also mention framework directory path to make it easier to find the
incomplete framework.

rdar://problem/39246514

Reviewers: arphaman, erik.pilkington, jkorous

Reviewed By: jkorous

Subscribers: jkorous, dexonsmith, cfe-commits

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

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

5 years ago[analyzer] Document RetainCountChecker behavior and annotations
George Karpenkov [Tue, 5 Feb 2019 22:27:10 +0000 (22:27 +0000)]
[analyzer] Document RetainCountChecker behavior and annotations

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

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

5 years ago[analyzer] [testing] Inside CmpRuns.py output also print the filename of the first...
George Karpenkov [Tue, 5 Feb 2019 22:26:57 +0000 (22:26 +0000)]
[analyzer] [testing] Inside CmpRuns.py output also print the filename of the first item in the path

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

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

5 years ago[analyzer] [RetainCountChecker] Bugfix: in non-OSObject-mode, do not track CXX method...
George Karpenkov [Tue, 5 Feb 2019 22:26:44 +0000 (22:26 +0000)]
[analyzer] [RetainCountChecker] Bugfix: in non-OSObject-mode, do not track CXX method calls

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

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

5 years agoFix a missing word in comment
Adrian Prantl [Tue, 5 Feb 2019 21:21:01 +0000 (21:21 +0000)]
Fix a missing word in comment

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

5 years ago[DOCS]Support for emission of the debug info for the Cuda devices, NFC.
Alexey Bataev [Tue, 5 Feb 2019 20:38:36 +0000 (20:38 +0000)]
[DOCS]Support for emission of the debug info for the Cuda devices, NFC.

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

5 years agoDo not use frame pointer by default for MSP430
Anton Korobeynikov [Tue, 5 Feb 2019 20:15:03 +0000 (20:15 +0000)]
Do not use frame pointer by default for MSP430

This is suggested by 3.3.9 of MSP430 EABI document.
We do allow user to manually enable frame pointer. GCC toolchain uses the same behavior.

Patch by Dmitry Mikushev!

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

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

5 years ago[DEBUG_INFO][NVPTX] Generate correct data about variable address class.
Alexey Bataev [Tue, 5 Feb 2019 19:45:57 +0000 (19:45 +0000)]
[DEBUG_INFO][NVPTX] Generate correct data about variable address class.

Summary:
Added ability to generate correct debug info data about the variable
address class. Currently, for all the locals and globals the default
values are used, ADDR_local_space(6) for locals and ADDR_global_space(5)
for globals. The values are taken from the table in
  https://docs.nvidia.com/cuda/archive/10.0/ptx-writers-guide-to-interoperability/index.html#cuda-specific-dwarf.
  We need to emit correct data for address classes of, at least, shared
  and constant globals. Currently, all these variables are treated by
  the cuda-gdb debugger as the variables in the global address space
  and, thus, it require manual data type casting.

Reviewers: echristo, probinson

Subscribers: jholewinski, aprantl, cfe-commits

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

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

5 years ago[opaque pointer types] More trivial changes to pass FunctionType to CallInst.
James Y Knight [Tue, 5 Feb 2019 19:17:50 +0000 (19:17 +0000)]
[opaque pointer types] More trivial changes to pass FunctionType to CallInst.

Change various functions to use FunctionCallee or Function*.

Pass function type through __builtin_dump_struct's dumpRecord helper.

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

5 years agoMinor cleanup: remove CGBuild::CreateConst*ByteGEP overloads taking a Value*.
James Y Knight [Tue, 5 Feb 2019 19:01:33 +0000 (19:01 +0000)]
Minor cleanup: remove CGBuild::CreateConst*ByteGEP overloads taking a Value*.

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

5 years ago[OPENMP] issue error messages for multiple teams contructs in a target construct
Kelvin Li [Tue, 5 Feb 2019 16:43:00 +0000 (16:43 +0000)]
[OPENMP] issue error messages for multiple teams contructs in a target construct

The fix is to issue error messages if there are more than one
teams construct inside a target constructs.

#pragma omp target
{
  #pragma omp teams
  {  ...  }

  #pragma omp teams
  { ... }
}

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

5 years ago[opaque pointer types] Pass function types for runtime function calls.
James Y Knight [Tue, 5 Feb 2019 16:42:33 +0000 (16:42 +0000)]
[opaque pointer types] Pass function types for runtime function calls.

Emit{Nounwind,}RuntimeCall{,OrInvoke} have been modified to take a
FunctionCallee as an argument, and CreateRuntimeFunction has been
modified to return a FunctionCallee. All callers have been updated.

Additionally, CreateBuiltinFunction is removed, as it was redundant
with CreateRuntimeFunction after some previous changes.

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

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

5 years ago[opaque pointer types] Fix the CallInfo passed to EmitCall in some
James Y Knight [Tue, 5 Feb 2019 16:05:50 +0000 (16:05 +0000)]
[opaque pointer types] Fix the CallInfo passed to EmitCall in some
edge cases.

Currently, EmitCall emits a call instruction with a function type
derived from the pointee-type of the callee. This *should* be the same
as the type created from the CallInfo parameter, but in some cases an
incorrect CallInfo was being passed.

All of these fixes were discovered by the addition of the assert in
EmitCall which verifies that the passed-in CallInfo matches the
Callee's function type.

As far as I know, these issues caused no bugs at the moment, as the
correct types were ultimately being emitted. But, some would become
problematic when pointee types are removed.

List of fixes:

* arrangeCXXConstructorCall was passing an incorrect value for the
  number of Required args, when calling an inheriting constructor
  where the inherited constructor is variadic. (The inheriting
  constructor doesn't actually get passed any of the user's args, but
  the code was calculating it as if it did).

* arrangeFreeFunctionLikeCall was not including the count of the
  pass_object_size arguments in the count of required args.

* OpenCL uses other address spaces for the "this" pointer. However,
  commonEmitCXXMemberOrOperatorCall was not annotating the address
  space on the "this" argument of the call.

* Destructor calls were being created with EmitCXXMemberOrOperatorCall
  instead of EmitCXXDestructorCall in a few places. This was a problem
  because the calling convention sometimes has destructors returning
  "this" rather than void, and the latter function knows about that,
  and sets up the types properly (through calling
  arrangeCXXStructorDeclaration), while the former does not.

* generateObjCGetterBody: the 'objc_getProperty' function returns type
  'id', but was being called as if it returned the particular
  property's type. (That is of course the *dynamic* return type, and
  there's a downcast immediately after.)

* OpenMP user-defined reduction functions (#pragma omp declare
  reduction) can be called with a subclass of the declared type. In
  such case, the call was being setup as if the function had been
  actually declared to take the subtype, rather than the base type.

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

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

5 years ago[NFC] Explicitly add -std=c++14 option to tests that rely on the C++14 default
Nemanja Ivanovic [Tue, 5 Feb 2019 12:05:53 +0000 (12:05 +0000)]
[NFC] Explicitly add -std=c++14 option to tests that rely on the C++14 default

When Clang/LLVM is built with the CLANG_DEFAULT_STD_CXX CMake macro that sets
the default standard to something other than C++14, there are a number of lit
tests that fail as they rely on the C++14 default.
This patch just adds the language standard option explicitly to such test cases.

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

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

5 years agoFix ICE on reference binding with mismatching addr spaces.
Anastasia Stulova [Tue, 5 Feb 2019 11:32:58 +0000 (11:32 +0000)]
Fix ICE on reference binding with mismatching addr spaces.

When we attempt to add an addr space qual to a type already
qualified by an addr space ICE is triggered. Before creating
a type with new address space, remove the old addr space.

Fixing PR38614!

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

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

5 years agoFix the sphinx buildbot after D54429
Kristof Umann [Tue, 5 Feb 2019 10:19:39 +0000 (10:19 +0000)]
Fix the sphinx buildbot after D54429

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

5 years ago[X86] Change MS inline asm clobber list filter to check for 'fpsr' instead of 'fpsw...
Craig Topper [Tue, 5 Feb 2019 06:13:14 +0000 (06:13 +0000)]
[X86] Change MS inline asm clobber list filter to check for 'fpsr' instead of 'fpsw' after D57641.

Summary: The backend used to print the x87 FPSW register as 'fpsw', but gcc inline asm uses 'fpsr'. After D57641, the backend now uses 'fpsr' to match.

Reviewers: rnk

Reviewed By: rnk

Subscribers: eraman, cfe-commits, llvm-commits

Tags: #clang

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

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

5 years ago[analyzer] Creating standard Sphinx documentation
Kristof Umann [Tue, 5 Feb 2019 00:39:33 +0000 (00:39 +0000)]
[analyzer] Creating standard Sphinx documentation

The lack of documentation has been a long standing issue in the Static Analyzer,
and one of the leading reasons behind this was a lack of good documentation
infrastucture.

This lead serious drawbacks, such as
* Not having proper release notes for years
* Not being able to have a sensible auto-generated checker documentations (which
lead to most of them not having any)
* The HTML website that has to updated manually is a chore, and has been
outdated for a long while
* Many design discussions are now hidden in phabricator revisions

This patch implements a new documentation infrastucture using Sphinx, like most
of the other subprojects in LLVM. It transformed some pages as a proof-of-
concept, with many others to follow in later patches. The eventual goal is to
preserve the original website's (https://clang-analyzer.llvm.org/) frontpage,
but move everything else to the new format.

Some other ideas, like creating a unipage for each checker (similar to how
clang-tidy works now), are also being discussed.

Patch by Dániel Krupp!

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

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

5 years ago[Sanitizers] UBSan unreachable incompatible with Kernel ASan
Julian Lettner [Mon, 4 Feb 2019 23:37:50 +0000 (23:37 +0000)]
[Sanitizers] UBSan unreachable incompatible with Kernel ASan

Summary:
This is a follow up for https://reviews.llvm.org/D57278. The previous
revision should have also included Kernel ASan.

rdar://problem/40723397

Subscribers: cfe-commits

Tags: #clang

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

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

5 years ago[OBJC] Add attribute to mark Objective C class as non-lazy
Joe Daniels [Mon, 4 Feb 2019 23:32:55 +0000 (23:32 +0000)]
[OBJC] Add attribute to mark Objective C class as non-lazy

A non-lazy class will be initialized eagerly when the Objective-C runtime is
loaded. This is required for certain system classes which have instances allocated in
non-standard ways, such as the classes for blocks and constant strings.
Adding this attribute is essentially equivalent to providing a trivial
+load method but avoids the (fairly small) load-time overheads associated
with defining and calling such a method.

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

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

5 years ago[SemaObjC] Don't infer the availabilty of +new from -init if the receiver has Class...
Erik Pilkington [Mon, 4 Feb 2019 23:30:57 +0000 (23:30 +0000)]
[SemaObjC] Don't infer the availabilty of +new from -init if the receiver has Class type

rdar://47713266

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

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

5 years ago[NewPM][MSan] Add Options Handling
Philip Pfaffe [Mon, 4 Feb 2019 21:02:49 +0000 (21:02 +0000)]
[NewPM][MSan] Add Options Handling

Summary: This patch enables passing options to msan via the passes pipeline, e.e., -passes=msan<recover;kernel;track-origins=4>.

Reviewers: chandlerc, fedor.sergeev, leonardchan

Subscribers: hiraditya, bollu, llvm-commits

Tags: #llvm

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

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

5 years agoGeneralize pthread callback test case
Johannes Doerfert [Mon, 4 Feb 2019 20:42:38 +0000 (20:42 +0000)]
Generalize pthread callback test case

Changes suggested by Eli Friedman <efriedma@quicinc.com>

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

5 years ago[clang-format] Fix breaking of qualified operator
Krasimir Georgiev [Mon, 4 Feb 2019 09:56:16 +0000 (09:56 +0000)]
[clang-format] Fix breaking of qualified operator

Summary:
From https://bugs.llvm.org/show_bug.cgi?id=40516
```
$ cat a.cpp
const NamespaceName::VeryLongClassName &NamespaceName::VeryLongClassName::myFunction() {
  // do stuff
}

const NamespaceName::VeryLongClassName &NamespaceName::VeryLongClassName::operator++() {
  // do stuff
}
$ ~/ll/build/opt/bin/clang-format -style=LLVM a.cpp
const NamespaceName::VeryLongClassName &
NamespaceName::VeryLongClassName::myFunction() {
  // do stuff
}

const NamespaceName::VeryLongClassName &NamespaceName::VeryLongClassName::
operator++() {
  // do stuff
}
```
What was happening is that the split penalty before `operator` was being set to
a smaller value by a prior if block. Moved checks around to fix this and added a
regression test.

Reviewers: djasper

Reviewed By: djasper

Tags: #clang

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

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

5 years ago[clang] Add getCommentHandler to PreambleCallbacks
Kadir Cetinkaya [Mon, 4 Feb 2019 09:42:33 +0000 (09:42 +0000)]
[clang] Add getCommentHandler to PreambleCallbacks

Summary:
Enables users to add comment handlers to preprocessor when building
preambles.

Reviewers: ilya-biryukov, ioeric

Subscribers: cfe-commits

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

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

5 years ago[OpenMP] Adding support to the mutexinoutset dep-type
Sergi Mateo Bellido [Mon, 4 Feb 2019 07:33:19 +0000 (07:33 +0000)]
[OpenMP] Adding support to the mutexinoutset dep-type

Summary: this commit adds support to a new dependence type introduced in OpenMP
5.0. The LLVM OpenMP RTL already supports this feature, so we  only need to
modify CLANG to take advantage of them.

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

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

5 years ago[opaque pointer types] Trivial changes towards CallInst requiring
James Y Knight [Sun, 3 Feb 2019 21:53:49 +0000 (21:53 +0000)]
[opaque pointer types] Trivial changes towards CallInst requiring
explicit function types.

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

5 years ago[AST] Update the comments of the various Expr::Ignore* + Related cleanups
Bruno Ricci [Sun, 3 Feb 2019 19:50:56 +0000 (19:50 +0000)]
[AST] Update the comments of the various Expr::Ignore* + Related cleanups

The description of what the various Expr::Ignore* do has drifted from the
actual implementation.

Inspection reveals that IgnoreParenImpCasts() is not equivalent to doing
IgnoreParens() + IgnoreImpCasts() until reaching a fixed point, but
IgnoreParenCasts() is equivalent to doing IgnoreParens() + IgnoreCasts()
until reaching a fixed point. There is also a fair amount of duplication
in the various Expr::Ignore* functions which increase the chance of further
future inconsistencies. In preparation for the next patch which will factor
out the implementation of the various Expr::Ignore*, do the following cleanups:

Remove Stmt::IgnoreImplicit, in favor of Expr::IgnoreImplicit. IgnoreImplicit
is the only function among all of the Expr::Ignore* which is available in Stmt.
There are only a few users of Stmt::IgnoreImplicit. They can just use instead
Expr::IgnoreImplicit like they have to do for the other Ignore*.

Move Expr::IgnoreImpCasts() from Expr.h to Expr.cpp. This made no difference
in the run-time with my usual benchmark (-fsyntax-only on all of Boost).

While we are at it, make IgnoreParenNoopCasts take a const reference to the
ASTContext for const correctness.

Update the comments to match what the Expr::Ignore* are actually doing.
I am not sure that listing exactly what each Expr::Ignore* do is optimal,
but it certainly looks better than the current state which is in my opinion
between misleading and just plain wrong.

The whole patch is NFC (if you count removing Stmt::IgnoreImplicit as NFC).

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

Reviewed By: aaron.ballman

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

5 years ago[ASTDump] Add a flag indicating whether a CXXThisExpr is implicit
Bruno Ricci [Sun, 3 Feb 2019 18:20:27 +0000 (18:20 +0000)]
[ASTDump] Add a flag indicating whether a CXXThisExpr is implicit

There is currently no way to distinguish implicit from explicit
CXXThisExpr in the AST dump output.

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

Reviewed By: steveire

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

5 years agoHot fix two test regressions (%T vs %t)
David Zarzycki [Sun, 3 Feb 2019 15:49:11 +0000 (15:49 +0000)]
Hot fix two test regressions (%T vs %t)

Different Unix "errno" values are returned for the following scenarios:

$ echo test > /tmp/existingFile/impossibleDir/impossibleFile
"Not a directory"
$ echo test > /tmp/nonexistentDir/impossibleFile
"No such file or directory"

This fixes the regression introduced by r352971 / D57592.

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

5 years ago[objc-gnustep] Fix encoding of ivar size for _Bool.
David Chisnall [Sun, 3 Feb 2019 15:05:52 +0000 (15:05 +0000)]
[objc-gnustep] Fix encoding of ivar size for _Bool.

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

5 years ago[AST] Extract ASTNodeTraverser class from ASTDumper
Stephen Kelly [Sun, 3 Feb 2019 14:06:54 +0000 (14:06 +0000)]
[AST] Extract ASTNodeTraverser class from ASTDumper

Summary:
This new traverser class allows clients to re-use the traversal logic
which was previously part of ASTDumper.  This means that alternative
visit logic may be implemented, such as

* Dump to alternative data formats such as JSON
* Implement AST Matcher parent/child visitation matching AST dumps

Reviewers: aaron.ballman

Subscribers: jfb, cfe-commits

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

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

5 years agoCorrect test my *really really* overaligning a type.
Eric Fiselier [Sun, 3 Feb 2019 04:10:38 +0000 (04:10 +0000)]
Correct test my *really really* overaligning a type.

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

5 years agoFix handling of usual deallocation functions in various configuratios.
Eric Fiselier [Sun, 3 Feb 2019 03:44:31 +0000 (03:44 +0000)]
Fix handling of usual deallocation functions in various configuratios.

Clang allows users to enable or disable various types of allocation
and deallocation regardless of the C++ dialect. When extended new/delete
overloads are enabled in older dialects, we need to treat them as if
they're usual.

Also, disabling one usual deallocation form shouldn't
disable any others. For example, disabling aligned allocation in C++2a
should have no effect on destroying delete.

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

5 years ago[NewPM] Add support for new-PM plugins to clang
Philip Pfaffe [Sat, 2 Feb 2019 23:19:32 +0000 (23:19 +0000)]
[NewPM] Add support for new-PM plugins to clang

Summary:
This adds support for new-PM plugin loading to clang. The option
`-fpass-plugin=` may be used to specify a dynamic shared object file
that adheres to the PassPlugin API.

Tested: created simple plugin that registers an EP callback; with optimization level > 0, the pass is run as expected.

Committed on behalf of Marco Elver

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

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

5 years agoReplace uses of %T with %t in from previous frontend test differential
Nico Weber [Sat, 2 Feb 2019 23:16:30 +0000 (23:16 +0000)]
Replace uses of %T with %t in from previous frontend test differential

After committing a change I had made to a few frontend tests, it was pointed
out to me that %T is being deprecated in LLVM in favor of %t. This change
simply converts usages of %T to %t while maintaining the integrity of the test.

Previous revision where this discussion took place:
https://reviews.llvm.org/D50563

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

Patch from Justice Adams <justice.adams@sony.com>!

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

5 years ago[analyzer][UninitializedObjectChecker] New flag to ignore guarded uninitialized fields
Kristof Umann [Sat, 2 Feb 2019 14:50:04 +0000 (14:50 +0000)]
[analyzer][UninitializedObjectChecker] New flag to ignore guarded uninitialized fields

This patch is an implementation of the ideas discussed on the mailing list[1].

The idea is to somewhat heuristically guess whether the field that was confirmed
to be uninitialized is actually guarded with ifs, asserts, switch/cases and so
on. Since this is a syntactic check, it is very much prone to drastically
reduce the amount of reports the checker emits. The reports however that do not
get filtered out though have greater likelihood of them manifesting into actual
runtime errors.

[1] http://lists.llvm.org/pipermail/cfe-dev/2018-September/059255.html

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

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

5 years ago[ASTImporter] Fix up test that only works on X86.
David Green [Sat, 2 Feb 2019 08:31:22 +0000 (08:31 +0000)]
[ASTImporter] Fix up test that only works on X86.

The test will fail if the default target triple is not X86,
even if the host platform is. So move the check into the
test at runtime.

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

5 years ago[Sema][ObjC] Allow declaring ObjC pointer members with non-trivial
Akira Hatanaka [Sat, 2 Feb 2019 02:23:40 +0000 (02:23 +0000)]
[Sema][ObjC] Allow declaring ObjC pointer members with non-trivial
ownership qualifications in C++ unions under ARC.

An ObjC pointer member with non-trivial ownership qualifications causes
all of the defaulted special functions of the enclosing union to be
defined as deleted, except when the member has an in-class initializer,
the default constructor isn't defined as deleted.

rdar://problem/34213306

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

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

5 years ago[ASan] Do not instrument other runtime functions with `__asan_handle_no_return`
Julian Lettner [Sat, 2 Feb 2019 02:05:16 +0000 (02:05 +0000)]
[ASan] Do not instrument other runtime functions with `__asan_handle_no_return`

Summary:
Currently, ASan inserts a call to `__asan_handle_no_return` before every
`noreturn` function call/invoke. This is unnecessary for calls to other
runtime funtions. This patch changes ASan to skip instrumentation for
functions calls marked with `!nosanitize` metadata.

Reviewers: TODO

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

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

5 years agoRemove redundant FunctionDecl argument from a couple functions.
James Y Knight [Sat, 2 Feb 2019 01:48:23 +0000 (01:48 +0000)]
Remove redundant FunctionDecl argument from a couple functions.

This argument was added in r254554 in order to support the
pass_object_size attribute. However, in r296076, the attribute's
presence is now also represented in FunctionProtoType's
ExtParameterInfo, and thus it's unnecessary to pass along a separate
FunctionDecl.

The functions modified are:
 RequiredArgs::forPrototype{,Plus}, and
 CodeGenTypes::ConvertFunctionType.

After this, it's also (again) unnecessary to have a separate
ConvertFunctionType function ConvertType, so convert callers back to
the latter, leaving the former as an internal helper function.

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

5 years ago[analyzer] Hotfix for RetainCountChecker: assert was too strong.
George Karpenkov [Fri, 1 Feb 2019 23:06:44 +0000 (23:06 +0000)]
[analyzer] Hotfix for RetainCountChecker: assert was too strong.

Bridged casts can happen to non-CF objects as well.

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

5 years ago[WebAssembly] Fix ImportName's position in this test.
Dan Gohman [Fri, 1 Feb 2019 22:52:29 +0000 (22:52 +0000)]
[WebAssembly] Fix ImportName's position in this test.

This is a follow-up to r352930.

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

5 years agoRevert "[AST][OpenMP] OpenMP Sections / Section constructs contain Structured blocks"
Roman Lebedev [Fri, 1 Feb 2019 22:43:08 +0000 (22:43 +0000)]
Revert "[AST][OpenMP] OpenMP Sections / Section constructs contain Structured blocks"

Further reviews (D57594, D57615) have revealed that this was not reviewed,
and that the differential's description was not read during the review,
thus rendering this commit invalid.

This reverts commit r352882.

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

5 years ago[WebAssembly] Add an import_field function attribute
Dan Gohman [Fri, 1 Feb 2019 22:25:23 +0000 (22:25 +0000)]
[WebAssembly] Add an import_field function attribute

This is similar to import_module, but sets the import field name
instead.

By default, the import field name is the same as the C/asm/.o symbol
name. However, there are situations where it's useful to have it be
different. For example, suppose I have a wasm API with a module named
"pwsix" and a field named "read". There's no risk of namespace
collisions with user code at the wasm level because the generic name
"read" is qualified by the module name "pwsix". However in the C/asm/.o
namespaces, the module name is not used, so if I have a global function
named "read", it is intruding on the user's namespace.

With the import_field module, I can declare my function (in libc) to be
"__read", and then set the wasm import module to be "pwsix" and the wasm
import field to be "read". So at the C/asm/.o levels, my symbol is
outside the user namespace.

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

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

5 years agoImprove diagnostic to tell you a type is incomplete.
Eric Fiselier [Fri, 1 Feb 2019 22:06:02 +0000 (22:06 +0000)]
Improve diagnostic to tell you a type is incomplete.

I recently ran into this code:
```
\#include <iostream>
void foo(const std::string &s, const std::string& = "");
\#include <string>
void test() { foo(""); }
```

The diagnostic produced said it can't bind char[1] to std::string
const&. It didn't mention std::string is incomplete. The user had to
infer that.

This patch causes the diagnostic to now say "incomplete type".

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

5 years agoFactor out duplication between ExprIterator and ConstExprIterator.
Richard Smith [Fri, 1 Feb 2019 21:58:17 +0000 (21:58 +0000)]
Factor out duplication between ExprIterator and ConstExprIterator.

This also exposes a more general iterator cast mechanism suitable for
use in http://reviews.llvm.org/D56571.

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

5 years agoDon't use ASTContext in DeclOpenMP.h because it's still incomplete.
Eric Fiselier [Fri, 1 Feb 2019 21:19:20 +0000 (21:19 +0000)]
Don't use ASTContext in DeclOpenMP.h because it's still incomplete.

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

5 years ago[OpenMP 5.0] Parsing/sema support for "omp declare mapper" directive.
Michael Kruse [Fri, 1 Feb 2019 20:25:04 +0000 (20:25 +0000)]
[OpenMP 5.0] Parsing/sema support for "omp declare mapper" directive.

This patch implements parsing and sema for "omp declare mapper"
directive. User defined mapper, i.e., declare mapper directive, is a new
feature in OpenMP 5.0. It is introduced to extend existing map clauses
for the purpose of simplifying the copy of complex data structures
between host and device (i.e., deep copy). An example is shown below:

    struct S {  int len;  int *d; };
    #pragma omp declare mapper(struct S s) map(s, s.d[0:s.len]) // Memory region that d points to is also mapped using this mapper.

Contributed-by: Lingda Li <lildmh@gmail.com>
Differential Revision: https://reviews.llvm.org/D56326

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

5 years agoUpdate SanitizerCoverage doc regarding the issue with pc-table and gc-sections.
Max Moroz [Fri, 1 Feb 2019 17:12:35 +0000 (17:12 +0000)]
Update SanitizerCoverage doc regarding the issue with pc-table and gc-sections.

Summary:
There is a bug for this: https://bugs.llvm.org/show_bug.cgi?id=34636
But it would be also helpful to leave a note in the docs to prevent users from
running into issues, e.g. https://crbug.com/926588.

Reviewers: morehouse

Reviewed By: morehouse

Subscribers: cfe-commits, llvm-commits, kcc

Tags: #clang

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

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

5 years agoFix some sphinx doc errors.
James Y Knight [Fri, 1 Feb 2019 17:06:41 +0000 (17:06 +0000)]
Fix some sphinx doc errors.

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

5 years ago[AST][OpenMP] OpenMP Sections / Section constructs contain Structured blocks
Roman Lebedev [Fri, 1 Feb 2019 15:41:54 +0000 (15:41 +0000)]
[AST][OpenMP] OpenMP Sections / Section constructs contain Structured blocks

Summary:
I'm working on a clang-tidy check, much like existing [[ http://clang.llvm.org/extra/clang-tidy/checks/bugprone-exception-escape.html | bugprone-exception-escape ]],
to detect when an exception might escape out of an OpenMP construct it isn't supposed to escape from.
For that i will be using the `nothrow` bit of `CapturedDecl`s.

While that bit is already correctly set for some constructs, e.g. `#pragma omp parallel`: https://godbolt.org/z/2La7pv
it isn't set for the `#pragma omp sections`, or `#pragma omp section`: https://godbolt.org/z/qZ-EbP

If i'm reading [[ https://www.openmp.org/wp-content/uploads/OpenMP-API-Specification-5.0.pdf | `OpenMP Application Programming Interface Version 5.0 November 2018` ]] correctly,
they should be, as per `2.8.1 sections Construct`, starting with page 86:
* The sections construct is a non-iterative worksharing construct that contains a set of **structured blocks**
  that are to be distributed among and executed by the threads in a team. Each **structured block** is executed
  once by one of the threads in the team in the context of its implicit task.
* The syntax of the sections construct is as follows:
  #pragma omp sections [clause[ [,] clause] ... ] new-line
    {
      [#pragma omp section new-line]
        **structured-block**
   ...
* Description
  Each **structured block** in the sections construct is preceded by a section directive except
  possibly **the first block**, for which a preceding section directive is optional.

* Restrictions
  • The code enclosed in a sections construct must be a **structured block**.
  * A throw executed inside a sections region must cause execution to resume within the same
    section of the sections region, and the same thread that threw the exception must catch it.

Reviewers: ABataev, #openmp

Reviewed By: ABataev

Subscribers: guansong, openmp-commits, cfe-commits

Tags: #clang, #openmp

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

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

5 years ago[CMake] External compiler-rt-configure requires LLVMTestingSupport when including...
Stefan Granitz [Fri, 1 Feb 2019 15:35:25 +0000 (15:35 +0000)]
[CMake] External compiler-rt-configure requires LLVMTestingSupport when including tests

Summary:
Apparently `LLVMTestingSupport` must be built before `llvm-config` can be asked for it. Symptom with `LLVM_INCLUDE_TESTS=ON` is:
```
$ ./path/to/llvm-build/bin/llvm-config --ldflags --libs testingsupport
-L/path/to/llvm-build/lib -Wl,-search_paths_first -Wl,-headerpad_max_install_names
llvm-config: error: component libraries and shared library

llvm-config: error: missing: /path/to/llvm-build/lib/libLLVMTestingSupport.a
```

With `LLVMTestingSupport` as dependency of `compiler-rt-configure` we get the expected behavior:
```
$ ./path/to/llvm-build/bin/llvm-config --ldflags --libs testingsupport
-L/path/to/llvm-build/lib -Wl,-search_paths_first -Wl,-headerpad_max_install_names
-lLLVMTestingSupport -lLLVMSupport -lLLVMDemangle
```

Reviewers: ab, beanz

Subscribers: dberris, mgorny, erik.pilkington, llvm-commits, cfe-commits

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

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

5 years ago[libclang] Fix -DBUILD_SHARED_LIBS=on build after rC352803
Fangrui Song [Fri, 1 Feb 2019 14:31:01 +0000 (14:31 +0000)]
[libclang] Fix -DBUILD_SHARED_LIBS=on build after rC352803

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

5 years ago[CUDA] Relax lit test condition after r352798.
Eric Liu [Fri, 1 Feb 2019 11:36:23 +0000 (11:36 +0000)]
[CUDA] Relax lit test condition after r352798.

Clang executable doesn't match clang.* in all test environment.

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

5 years agoDisable tidy checks with too many hits
Ilya Biryukov [Fri, 1 Feb 2019 11:20:13 +0000 (11:20 +0000)]
Disable tidy checks with too many hits

Summary:
Some tidy checks have too many hits in the codebase, making it hard to spot
other results from clang-tidy, therefore rendering the tool less useful.

Two checks were disabled:
  - misc-non-private-member-variable-in-classes in the whole LLVM monorepo,
    it is very common to have those in LLVM and the style guide does not forbid
    them.
  - readability-identifier-naming in the clang subtree. There are thousands of
    violations in 'Sema.h' alone.

Before the change, 'Sema.h' had >1000 tidy warnings, after the change the number
dropped to 3 warnings (unterminated namespace comments).

Reviewers: alexfh, hokein

Reviewed By: hokein

Subscribers: llvm-commits, cfe-commits

Tags: #clang, #llvm

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

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

5 years agoProvide reason messages for unviable inlining
Yevgeny Rouban [Fri, 1 Feb 2019 10:44:43 +0000 (10:44 +0000)]
Provide reason messages for unviable inlining

InlineCost's isInlineViable() is changed to return InlineResult
instead of bool. This provides messages for failure reasons and
allows to get more specific messages for cases where callsites
are not viable for inlining.

Reviewed By: xbolva00, anemet

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

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

5 years agoTest commit: fix typo
Sergi Mateo Bellido [Fri, 1 Feb 2019 08:39:01 +0000 (08:39 +0000)]
Test commit: fix typo

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

5 years agoFix isInSystemMacro to handle pasted macros
Serge Guelton [Fri, 1 Feb 2019 06:11:44 +0000 (06:11 +0000)]
Fix isInSystemMacro to handle pasted macros

Token pasted by the preprocessor (through ##) have a Spelling pointing to scratch buffer.
As a result they are not recognized at system macro, even though the pasting happened in
a system macro. Fix that by looking into the parent macro if the original lookup finds a
scratch buffer.

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

This effectively fixes https://bugs.llvm.org/show_bug.cgi?id=35268,

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

5 years ago[SemaCXX] Param diagnostic matches overload logic
Brian Gesiak [Fri, 1 Feb 2019 03:30:29 +0000 (03:30 +0000)]
[SemaCXX] Param diagnostic matches overload logic

Summary:
Given the following test program:

```
class C {
public:
  int A(int a, int& b);
};

int C::A(const int a, int b) {
  return a * b;
}
```

Clang would produce an error message that correctly diagnosed the
redeclaration of `C::A` to not match the original declaration (the
parameters to the two declarations do not match -- the original takes an
`int &` as its 2nd parameter, but the redeclaration takes an `int`). However,
it also produced a note diagnostic that inaccurately pointed to the
first parameter, claiming that `const int` in the redeclaration did not
match the unqualified `int` in the original. The diagnostic is
misleading because it has nothing to do with why the program does not
compile.

The logic for checking for a function overload, in
`Sema::FunctionParamTypesAreEqual`, discards cv-qualifiers before
checking whether the types are equal. Do the same when producing the
overload diagnostic.

Reviewers: rsmith

Reviewed By: rsmith

Subscribers: cpplearner, cfe-commits

Tags: #clang

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

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

5 years ago[Sanitizers] UBSan unreachable incompatible with ASan in the presence of `noreturn...
Julian Lettner [Fri, 1 Feb 2019 02:51:00 +0000 (02:51 +0000)]
[Sanitizers] UBSan unreachable incompatible with ASan in the presence of `noreturn` calls

Summary:
UBSan wants to detect when unreachable code is actually reached, so it
adds instrumentation before every unreachable instruction. However, the
optimizer will remove code after calls to functions marked with
noreturn. To avoid this UBSan removes noreturn from both the call
instruction as well as from the function itself. Unfortunately, ASan
relies on this annotation to unpoison the stack by inserting calls to
_asan_handle_no_return before noreturn functions. This is important for
functions that do not return but access the the stack memory, e.g.,
unwinder functions *like* longjmp (longjmp itself is actually
"double-proofed" via its interceptor). The result is that when ASan and
UBSan are combined, the noreturn attributes are missing and ASan cannot
unpoison the stack, so it has false positives when stack unwinding is
used.

Changes:
Clang-CodeGen now directly insert calls to `__asan_handle_no_return`
when a call to a noreturn function is encountered and both
UBsan-unreachable and ASan are enabled. This allows UBSan to continue
removing the noreturn attribute from functions without any changes to
the ASan pass.

Previously generated code:
```
  call void @longjmp
  call void @__asan_handle_no_return
  call void @__ubsan_handle_builtin_unreachable
```

Generated code (for now):
```
  call void @__asan_handle_no_return
  call void @longjmp
  call void @__asan_handle_no_return
  call void @__ubsan_handle_builtin_unreachable
```

rdar://problem/40723397

Reviewers: delcypher, eugenis, vsk

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

llvm-svn: 352690

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