]> granicus.if.org Git - clang/log
clang
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

5 years ago[opaque pointer types] Add a FunctionCallee wrapper type, and use it.
James Y Knight [Fri, 1 Feb 2019 02:28:03 +0000 (02:28 +0000)]
[opaque pointer types] Add a FunctionCallee wrapper type, and use it.

Recommit r352791 after tweaking DerivedTypes.h slightly, so that gcc
doesn't choke on it, hopefully.

Original Message:
The FunctionCallee type is effectively a {FunctionType*,Value*} pair,
and is a useful convenience to enable code to continue passing the
result of getOrInsertFunction() through to EmitCall, even once pointer
types lose their pointee-type.

Then:
- update the CallInst/InvokeInst instruction creation functions to
  take a Callee,
- modify getOrInsertFunction to return FunctionCallee, and
- update all callers appropriately.

One area of particular note is the change to the sanitizer
code. Previously, they had been casting the result of
`getOrInsertFunction` to a `Function*` via
`checkSanitizerInterfaceFunction`, and storing that. That would report
an error if someone had already inserted a function declaraction with
a mismatching signature.

However, in general, LLVM allows for such mismatches, as
`getOrInsertFunction` will automatically insert a bitcast if
needed. As part of this cleanup, cause the sanitizer code to do the
same. (It will call its functions using the expected signature,
however they may have been declared.)

Finally, in a small number of locations, callers of
`getOrInsertFunction` actually were expecting/requiring that a brand
new function was being created. In such cases, I've switched them to
Function::Create instead.

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

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

5 years ago[analyzer] [RetainCountChecker] Fix object type for CF/Obj-C bridged casts
George Karpenkov [Fri, 1 Feb 2019 02:13:02 +0000 (02:13 +0000)]
[analyzer] [RetainCountChecker] Fix object type for CF/Obj-C bridged casts

Having an incorrect type for a cast causes the checker to incorrectly
dismiss the operation under ARC, leading to a false positive
use-after-release on the test.

rdar://47709885

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

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

5 years agoRevert "[Sema] Make canPassInRegisters return true if the CXXRecordDecl passed"
Akira Hatanaka [Fri, 1 Feb 2019 00:12:06 +0000 (00:12 +0000)]
Revert "[Sema] Make canPassInRegisters return true if the CXXRecordDecl passed"

This reverts commit r350920 as it is not clear whether we should force a
class to be returned in registers when copy and move constructors are
both deleted.

For more background, see the following discussion:
http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20190128/259907.html

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

5 years ago[sanitizer-coverage] prune trace-cmp instrumentation for CMP isntructions that feed...
Kostya Serebryany [Thu, 31 Jan 2019 23:43:00 +0000 (23:43 +0000)]
[sanitizer-coverage] prune trace-cmp instrumentation for CMP isntructions that feed into the backedge branch. Instrumenting these CMP instructions is almost always useless (and harmful) for fuzzing

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

5 years agoRe-disable pch-from-libclang.c after 352803, some buildbots are still unhappy
Nico Weber [Thu, 31 Jan 2019 22:57:52 +0000 (22:57 +0000)]
Re-disable pch-from-libclang.c after 352803, some buildbots are still unhappy

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

5 years ago[ASTDump] Make template specialization tests more exact
Stephen Kelly [Thu, 31 Jan 2019 22:28:38 +0000 (22:28 +0000)]
[ASTDump] Make template specialization tests more exact

Reviewers: aaron.ballman

Subscribers: cfe-commits

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

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

5 years agoMake clang/test/Index/pch-from-libclang.c pass in more places
Nico Weber [Thu, 31 Jan 2019 22:15:32 +0000 (22:15 +0000)]
Make clang/test/Index/pch-from-libclang.c pass in more places

- fixes the test on macOS with LLVM_ENABLE_PIC=OFF
- together with D57343, gets the test to pass on Windows
- makes it run everywhere (it seems to just pass on Linux)

The main change is to pull out the resource directory computation into a
function shared by all 3 places that do it. In CIndexer.cpp, this now works no
matter if libclang is in lib/ or bin/ or statically linked to a binary in bin/.

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

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

5 years agoDo not copy long double and 128-bit fp format from aux target for AMDGPU
Yaxun Liu [Thu, 31 Jan 2019 21:57:51 +0000 (21:57 +0000)]
Do not copy long double and 128-bit fp format from aux target for AMDGPU

rC352620 caused regressions because it copied floating point format from
aux target.

floating point format decides whether extended long double is supported.
It is x86_fp80 on x86 but IEEE double on amdgcn.

Document usage of long doubel type in HIP programming guide
https://github.com/ROCm-Developer-Tools/HIP/pull/890

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

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

5 years agoRevert "[opaque pointer types] Add a FunctionCallee wrapper type, and use it."
James Y Knight [Thu, 31 Jan 2019 21:51:58 +0000 (21:51 +0000)]
Revert "[opaque pointer types] Add a FunctionCallee wrapper type, and use it."

This reverts commit f47d6b38c7a61d50db4566b02719de05492dcef1 (r352791).

Seems to run into compilation failures with GCC (but not clang, where
I tested it). Reverting while I investigate.

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

5 years ago[CUDA] add support for the new kernel launch API in CUDA-9.2+.
Artem Belevich [Thu, 31 Jan 2019 21:34:03 +0000 (21:34 +0000)]
[CUDA] add support for the new kernel launch API in CUDA-9.2+.

Instead of calling CUDA runtime to arrange function arguments,
the new API constructs arguments in a local array and the kernels
are launched with __cudaLaunchKernel().

The old API has been deprecated and is expected to go away
in the next CUDA release.

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

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

5 years ago[CUDA] Propagate detected version of CUDA to cc1
Artem Belevich [Thu, 31 Jan 2019 21:32:24 +0000 (21:32 +0000)]
[CUDA] Propagate detected version of CUDA to cc1

..and use it to control that parts of CUDA compilation
that depend on the specific version of CUDA SDK.

This patch has a placeholder for a 'new launch API' support
which is in a separate patch. The list will be further
extended in the upcoming patch to support CUDA-10.1.

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

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

5 years ago[WebAssembly] Add bulk memory target feature
Thomas Lively [Thu, 31 Jan 2019 21:02:19 +0000 (21:02 +0000)]
[WebAssembly] Add bulk memory target feature

Summary: Also clean up some preexisting target feature code.

Reviewers: aheejin

Subscribers: dschuff, sbc100, jgravelle-google, hiraditya, sunfish, jfb

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

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

5 years ago[opaque pointer types] Add a FunctionCallee wrapper type, and use it.
James Y Knight [Thu, 31 Jan 2019 20:35:56 +0000 (20:35 +0000)]
[opaque pointer types] Add a FunctionCallee wrapper type, and use it.

The FunctionCallee type is effectively a {FunctionType*,Value*} pair,
and is a useful convenience to enable code to continue passing the
result of getOrInsertFunction() through to EmitCall, even once pointer
types lose their pointee-type.

Then:
- update the CallInst/InvokeInst instruction creation functions to
  take a Callee,
- modify getOrInsertFunction to return FunctionCallee, and
- update all callers appropriately.

One area of particular note is the change to the sanitizer
code. Previously, they had been casting the result of
`getOrInsertFunction` to a `Function*` via
`checkSanitizerInterfaceFunction`, and storing that. That would report
an error if someone had already inserted a function declaraction with
a mismatching signature.

However, in general, LLVM allows for such mismatches, as
`getOrInsertFunction` will automatically insert a bitcast if
needed. As part of this cleanup, cause the sanitizer code to do the
same. (It will call its functions using the expected signature,
however they may have been declared.)

Finally, in a small number of locations, callers of
`getOrInsertFunction` actually were expecting/requiring that a brand
new function was being created. In such cases, I've switched them to
Function::Create instead.

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

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

5 years ago[CodeComplete] Propagate preferred types through parser in more cases
Ilya Biryukov [Thu, 31 Jan 2019 20:20:32 +0000 (20:20 +0000)]
[CodeComplete] Propagate preferred types through parser in more cases

Preferred types are used by code completion for ranking. This commit
considerably increases the number of points in code where those types
are propagated.

In order to avoid complicating signatures of Parser's methods, a
preferred type is kept as a member variable in the parser and updated
during parsing.

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

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

5 years agoAccomodate gcc 7.3.0's -Wdangling-else
Nico Weber [Thu, 31 Jan 2019 15:26:03 +0000 (15:26 +0000)]
Accomodate gcc 7.3.0's -Wdangling-else

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

5 years ago[OpenCL] Fixed addr space manging test.
Anastasia Stulova [Thu, 31 Jan 2019 15:23:48 +0000 (15:23 +0000)]
[OpenCL] Fixed addr space manging test.

Fixed typo in the Filecheck directive and changed the
test to verify output correctly.

Fixes PR40029!

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

5 years agoRevert "[Sanitizers] UBSan unreachable incompatible with ASan in the presence of...
Eric Liu [Thu, 31 Jan 2019 14:20:02 +0000 (14:20 +0000)]
Revert "[Sanitizers] UBSan unreachable incompatible with ASan in the presence of `noreturn` calls"

This reverts commit r352690. This causes clang to crash. Sent reproducer to the
author in the orginal commit.

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

5 years agoRevert "Support attribute used in member funcs of class templates"
Rafael Auler [Thu, 31 Jan 2019 13:31:33 +0000 (13:31 +0000)]
Revert "Support attribute used in member funcs of class templates"

This reverts commit 352740: broke swift build

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

5 years agoSupport attribute used in member funcs of class templates
Rafael Auler [Thu, 31 Jan 2019 09:38:31 +0000 (09:38 +0000)]
Support attribute used in member funcs of class templates

Summary:
As PR17480 describes, clang does not support the used attribute
for member functions of class templates. This means that if the member
function is not used, its definition is never instantiated. This patch
changes clang to emit the definition if it has the used attribute.

Test Plan: Added a testcase

Reviewed By: aaron.ballman

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

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

5 years agoRevert "[CMake] Unify scripts for generating VCS headers"
Petr Hosek [Thu, 31 Jan 2019 07:12:43 +0000 (07:12 +0000)]
Revert "[CMake] Unify scripts for generating VCS headers"

This reverts commits r352729 and r352731: this broke Sanitizer Windows bots

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

5 years ago[CMake] Unify scripts for generating VCS headers
Petr Hosek [Thu, 31 Jan 2019 06:21:01 +0000 (06:21 +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. 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 and Clang, 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@352729 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[analyzer] Make NullReturnedFromNonnullChecker depend on NullabilityBase
Kristof Umann [Wed, 30 Jan 2019 23:48:37 +0000 (23:48 +0000)]
[analyzer] Make NullReturnedFromNonnullChecker depend on NullabilityBase

Accidentally left this dependency out after D54438.

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

5 years ago[Sanitizers] UBSan unreachable incompatible with ASan in the presence of `noreturn...
Julian Lettner [Wed, 30 Jan 2019 23:42:13 +0000 (23:42 +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

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

5 years ago[CodeGenObjC] Handle exceptions when calling objc_alloc or objc_allocWithZone
Erik Pilkington [Wed, 30 Jan 2019 23:17:38 +0000 (23:17 +0000)]
[CodeGenObjC] Handle exceptions when calling objc_alloc or objc_allocWithZone

objc_alloc and objc_allocWithZone may throw exceptions if the
underlying method does. If we're in a @try block, then make sure we
emit an invoke instead of a call.

rdar://47610407

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

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

5 years ago[ASTDump] Inline traverse methods into class
Stephen Kelly [Wed, 30 Jan 2019 21:48:32 +0000 (21:48 +0000)]
[ASTDump] Inline traverse methods into class

This API will be extracted into a new template class.  This change will
make the follow-up commit easier to review.

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

5 years agoDon't define __has_feature(objc_fixed_enum) in non-objc mode
Erik Pilkington [Wed, 30 Jan 2019 21:14:08 +0000 (21:14 +0000)]
Don't define __has_feature(objc_fixed_enum) in non-objc mode

This is only a formal language feature in ObjC, otherwise its just an
extension. Making this change was also an ABI break.

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

5 years ago[OPENMP]Fix PR40536: Do not emit __kmpc_push_target_tripcount if not
Alexey Bataev [Wed, 30 Jan 2019 20:49:52 +0000 (20:49 +0000)]
[OPENMP]Fix PR40536: Do not emit __kmpc_push_target_tripcount if not
required.

Function __kmpc_push_target_tripcount should be emitted only if the
offloading entry is going to be emitted (for use in tgt_target...
functions). Otherwise, it should not be emitted.

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

5 years agoAdd a new builtin: __builtin_dynamic_object_size
Erik Pilkington [Wed, 30 Jan 2019 20:34:53 +0000 (20:34 +0000)]
Add a new builtin: __builtin_dynamic_object_size

This builtin has the same UI as __builtin_object_size, but has the
potential to be evaluated dynamically. It is meant to be used as a
drop-in replacement for libraries that use __builtin_object_size when
a dynamic checking mode is enabled. For instance,
__builtin_object_size fails to provide any extra checking in the
following function:

  void f(size_t alloc) {
    char* p = malloc(alloc);
    strcpy(p, "foobar"); // expands to __builtin___strcpy_chk(p, "foobar", __builtin_object_size(p, 0))
  }

This is an overflow if alloc < 7, but because LLVM can't fold the
object size intrinsic statically, it folds __builtin_object_size to
-1. With __builtin_dynamic_object_size, alloc is passed through to
__builtin___strcpy_chk.

rdar://32212419

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

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

5 years agoAdd a 'dynamic' parameter to the objectsize intrinsic
Erik Pilkington [Wed, 30 Jan 2019 20:34:35 +0000 (20:34 +0000)]
Add a 'dynamic' parameter to the objectsize intrinsic

This is meant to be used with clang's __builtin_dynamic_object_size.
When 'true' is passed to this parameter, the intrinsic has the
potential to be folded into instructions that will be evaluated
at run time. When 'false', the objectsize intrinsic behaviour is
unchanged.

rdar://32212419

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

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

5 years ago[ASTDump] Make method definition order matches declaration order
Stephen Kelly [Wed, 30 Jan 2019 20:06:52 +0000 (20:06 +0000)]
[ASTDump] Make method definition order matches declaration order

This will make follow-up changes easier to review.

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

5 years ago[ASTDump] Re-arrange method declarations to group Visit together
Stephen Kelly [Wed, 30 Jan 2019 20:03:47 +0000 (20:03 +0000)]
[ASTDump] Re-arrange method declarations to group Visit together

This will make follow-up commits easier to review.

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

5 years ago[ASTDump] Rename methods which are conceptually Visits
Stephen Kelly [Wed, 30 Jan 2019 19:49:49 +0000 (19:49 +0000)]
[ASTDump] Rename methods which are conceptually Visits

This is consistent with the TextNodeDumper, and is the appropriate name
for the traverser class which will be extracted.

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

5 years ago[ASTDump] NFC: Inline vestigial methods
Stephen Kelly [Wed, 30 Jan 2019 19:41:04 +0000 (19:41 +0000)]
[ASTDump] NFC: Inline vestigial methods

This was a porting aid.

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

5 years ago[ASTDump] Move Decl node dumping to TextNodeDumper
Stephen Kelly [Wed, 30 Jan 2019 19:32:48 +0000 (19:32 +0000)]
[ASTDump] Move Decl node dumping to TextNodeDumper

Reviewers: aaron.ballman

Subscribers: jfb, cfe-commits

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

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

5 years ago[ASTDumper][OpenMP] CapturedDecl has a 'nothrow' bit
Roman Lebedev [Wed, 30 Jan 2019 15:41:20 +0000 (15:41 +0000)]
[ASTDumper][OpenMP] CapturedDecl has a 'nothrow' bit

Summary:
Was trying to understand how complicated it would be to write
a clang-tidy `openmp-exception-escape`-ish check once D57100 lands.

Just so it happens, all the data is already there,
it is just conveniently omitted from AST dump.

Reviewers: aaron.ballman, steveire, ABataev

Reviewed By: ABataev

Subscribers: ABataev, guansong, cfe-commits

Tags: #openmp, #clang

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

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

5 years ago[clang-format] Fix line parsing for noexcept lambdas
Ben Hamilton [Wed, 30 Jan 2019 13:54:32 +0000 (13:54 +0000)]
[clang-format] Fix line parsing for noexcept lambdas

Summary:
> $ echo "int c = [b]() mutable noexcept { return [&b] { return b++; }(); }();" |clang-format

```
int c = [b]() mutable noexcept {
  return [&b] { return b++; }();
}
();
```
with patch:
> $ echo "int c = [b]() mutable noexcept { return [&b] { return b++; }(); }();" |bin/clang-format
```
int c = [b]() mutable noexcept { return [&b] { return b++; }(); }();
```

Contributed by hultman.

Reviewers: benhamilton, jolesiak, klimek, Wizard

Reviewed By: benhamilton

Subscribers: cfe-commits

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

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

5 years ago[HIP] Fix size_t for MSVC environment
Yaxun Liu [Wed, 30 Jan 2019 12:26:54 +0000 (12:26 +0000)]
[HIP] Fix size_t for MSVC environment

In 64 bit MSVC environment size_t is defined as unsigned long long.
In single source language like HIP, data layout should be consistent
in device and host compilation, therefore copy data layout controlling
fields from Aux target for AMDGPU target.

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

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

5 years ago[OpenGL] Fix test on PPC after r352540
Eric Liu [Wed, 30 Jan 2019 11:24:04 +0000 (11:24 +0000)]
[OpenGL] Fix test on PPC after r352540

Summary:
Specify -triple like test/SemaOpenCL/logical-ops.cl. Otherwise, this test fails
on PPC.

Reviewers: bkramer

Subscribers: Anastasia, cfe-commits

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

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

5 years ago[OpenCL] Add generic addr space to the return of implicit assignment.
Anastasia Stulova [Wed, 30 Jan 2019 11:18:08 +0000 (11:18 +0000)]
[OpenCL] Add generic addr space to the return of implicit assignment.

When creating the prototype of implicit assignment operators the
returned reference to the class should be qualified with the same
addr space as 'this' (i.e. __generic in OpenCL).

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

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

5 years ago[clang] [Driver] [NetBSD] Append -rpath for shared compiler-rt runtimes
Michal Gorny [Wed, 30 Jan 2019 08:20:24 +0000 (08:20 +0000)]
[clang] [Driver] [NetBSD] Append -rpath for shared compiler-rt runtimes

Append appropriate -rpath when using shared compiler-rt runtimes,
e.g. '-fsanitize=address -shared-libasan'.  There's already a similar
logic in CommonArgs.cpp but it uses non-standard arch-suffixed
installation directory while we want our driver to work with standard
installation paths.

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

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

5 years ago[ModuleDependencyCollector] Use llvm::sys::fs::real_path (NFC)
Jonas Devlieghere [Wed, 30 Jan 2019 06:26:26 +0000 (06:26 +0000)]
[ModuleDependencyCollector] Use llvm::sys::fs::real_path (NFC)

Use the real_path implementation from llvm::sys::fs::real_path instead
of having a custom implementation in the ModuleDependencyCollector.

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

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

5 years agoCleanup: replace uses of CallSite with CallBase.
James Y Knight [Wed, 30 Jan 2019 02:54:28 +0000 (02:54 +0000)]
Cleanup: replace uses of CallSite with CallBase.

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

5 years agoSimplify and modernize this code a little.
Richard Smith [Wed, 30 Jan 2019 02:23:34 +0000 (02:23 +0000)]
Simplify and modernize this code a little.

No functionality change intended.

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

5 years ago[analyzer] [RetainCountChecker] Bugfix for tracking top-level parameters of Objective...
George Karpenkov [Wed, 30 Jan 2019 02:11:04 +0000 (02:11 +0000)]
[analyzer] [RetainCountChecker] Bugfix for tracking top-level parameters of Objective-C methods

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

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

5 years ago[CMake][Fuchsia] Re-enable iOS runtimes for Fuchsia standard
Petr Hosek [Wed, 30 Jan 2019 02:06:06 +0000 (02:06 +0000)]
[CMake][Fuchsia] Re-enable iOS runtimes for Fuchsia standard

Turned out this is used by Flutter which uses Fuchsia Clang toolchain.

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

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