Commit Graph

15782 Commits

Author SHA1 Message Date
Richard Smith 0d923af492 Add missing diagnostic for explicit instantiation declarations naming
internal linkage entities.

Such constructs are ill-formed by [temp.explicit]p13. We make a special
exception to permit an invalid construct used by libc++ in some build
modes: its <valarray> header declares some functions with the
internal_linkage attribute and then (meaninglessly) provides explicit
instantiation declarations for them. Luckily, Clang happens to
effectively ignore the explicit instantiation declaration when
generating code in this case, and this change codifies that behavior.

This reinstates part of r359048, reverted in r359076. (The libc++ issue
triggering the rollback has been addressed.)

llvm-svn: 359259
2019-04-26 01:51:07 +00:00
Alexey Bataev 2f9ef332d1 [OPENMP] Improved check for the linear dependency in the non-rectangular
loop nests.

Added a checks that the initializer/condition expressions depend only
only of the single previous loop iteration variable.

llvm-svn: 359200
2019-04-25 16:21:13 +00:00
Alexey Bataev 622af1d282 [OPENMP]Initial support for non-rectangular loop nest.
Added basic semantic analysis for the non-rectangular loop nests for
OpenMP 5.0 support.

llvm-svn: 359132
2019-04-24 19:58:30 +00:00
Fangrui Song 899d13926d Use llvm::stable_sort
llvm-svn: 359098
2019-04-24 14:43:05 +00:00
Ilya Biryukov b8292c955c Revert r359048: C++ DR2387: a variable template declared wthi
The change breaks libc++ with the follwing error:

In file included from valarray:4:
.../include/c++/v1/valarray:1062:60: error: explicit instantiation declaration of 'valarray<_Tp>' with internal linkage
_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS valarray<size_t>::valarray(size_t))
                                                           ^
.../include/c++/v1/valarray:1063:60: error: explicit instantiation declaration of '~valarray<_Tp>' with internal linkage
_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS valarray<size_t>::~valarray())

llvm-svn: 359076
2019-04-24 08:50:24 +00:00
Richard Smith 42a22370f2 Revert r350917 "[Sema] If CheckPlaceholderExpr rewrites the initializer
of an auto"

This commit changed the initializer expression passed into
initialization (stripping off an enclosing pair of parentheses or
braces) and subtly changing the meaning of programs, typically by
inserting bogus calls to copy constructors.

See the added testcase in test/SemaCXX/cxx1y-init-captures.cpp for an
example of the breakage.

llvm-svn: 359066
2019-04-24 02:22:38 +00:00
Richard Smith 0b098754b7 Fix interactions between __builtin_constant_p and constexpr to match
current trunk GCC.

GCC permits information from outside the operand of
__builtin_constant_p (but in the same constant evaluation context) to be
used within that operand; clang now does so too. A few other minor
deviations from GCC's behavior showed up in my testing and are also
fixed (matching GCC):
 * Clang now supports nullptr_t as the argument type for
   __builtin_constant_p
 * Clang now returns true from __builtin_constant_p if called with a
   null pointer
 * Clang now returns true from __builtin_constant_p if called with an
   integer cast to pointer type

llvm-svn: 359059
2019-04-24 01:29:28 +00:00
Richard Smith 3ac3e9ce04 Add missing diagnostic for anonymous struct/union definitions that don't
introduce any names.

llvm-svn: 359051
2019-04-24 00:08:02 +00:00
Akira Hatanaka 53796d9439 Improve -Wuninitialized warning under ARC for block variables that are
recursively captured.

Under ARC, a block variable is zero-initialized when it is recursively
captured by the block literal initializer.

rdar://problem/11022762

llvm-svn: 359049
2019-04-23 23:52:02 +00:00
Richard Smith eeab4518e1 C++ DR2387: a variable template declared wtih (or instantiated with) a
const-qualified type is not implicitly given internal linkage. But a
variable template declared 'static' is.

llvm-svn: 359048
2019-04-23 23:48:00 +00:00
Richard Smith e181de7f4f [c++2a] Implement semantic restrictions for 'export' declarations.
llvm-svn: 358932
2019-04-22 22:50:11 +00:00
Matt Davis 55043e2336 [sema][objc] Minor refactor to OverrideSearch. NFCI.
Summary:
* Removed a member that was only used during construction.
* Use range-based for iteration when accessing the result of the search.
* Require an `ObjCMethodDecl` reference upon construction of an
* Constify.

Reviewers: rjmccall

Reviewed By: rjmccall

Subscribers: llvm-commits

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

llvm-svn: 358898
2019-04-22 16:04:44 +00:00
Bruno Ricci af3e50ad40 [Sema] ADL: Associated namespaces for class types and enumeration types (CWG 1691)
CWG 1691 changed the definition of the namespaces associated with a class
type or enumeration type.

For a class type, the associated namespaces are the innermost enclosing
namespaces of the associated classes. For an enumeration type, the associated
namespace is the innermost enclosing namespace of its declaration.

This also fixes CWG 1690 and CWG 1692.

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

Reviewed By: rjmccall, rsmith

llvm-svn: 358882
2019-04-22 12:19:00 +00:00
Bruno Ricci ba7ffae0c5 [Sema][MSVC] Fix bogus microsoft-pure-definition warning on member function of class template
Clang emits a warning when using a pure specifier =0 in a function definition
at class scope (a MS-specific construct), when using -fms-extensions.
However, to detect this, it was using FD->isCanonicalDecl() on function
declaration, which was also detecting out-of-class definition of member
functions of class templates. Fix this by using !FD->isOutOfLine() instead.

Fixes PR21334.

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

Reviewed By: riccibruno

Reviewers: rnk, riccibruno

Patch By: Rudy Pons

llvm-svn: 358849
2019-04-21 13:12:10 +00:00
David Blaikie aa3bf6ce72 Modules: Search for a visible definition of the decl context when computing visibility of a default template parameter
The code is/was already correct for the case where a parameter is a
parameter of its enclosing lexical DeclContext (functions and classes).
But for other templates (alias and variable templates) they don't create
their own scope to be members of - in those cases, they parameter should
be considered visible if any definition of the lexical decl context is
visible.

[this should cleanup the failure on the libstdc++ modules buildbot]
[this doesn't actually fix the variable template case for a
secondary/compounding reason (its lexical decl context is incorrectly
considered to be the translation unit)]

Test covers all 4 kinds of templates with default args, including a
regression test for the still broken variable template case.

Reviewers: rsmith

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

llvm-svn: 358795
2019-04-19 23:02:30 +00:00
Richard Smith a5bbbfef15 [c++2a] Add semantic support for private module fragments.
llvm-svn: 358713
2019-04-18 21:12:54 +00:00
Gheorghe-Teodor Bercea 411a62403f [OpenMP] Add checks for requires and target directives.
Summary: The requires directive containing target related clauses must appear before any target region in the compilation unit.

Reviewers: ABataev, AlexEichenberger, caomhin

Reviewed By: ABataev

Subscribers: guansong, jfb, jdoerfert, cfe-commits

Tags: #clang

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

llvm-svn: 358709
2019-04-18 19:53:43 +00:00
Fangrui Song 0b826f193f [Sema] Delete unused parameters/variables
llvm-svn: 358661
2019-04-18 12:35:02 +00:00
Richard Smith b7bdb8cf33 Split out modules-specific declaration handling from SemaDecl.cpp into a
new SemaModule.cpp.

llvm-svn: 358633
2019-04-18 00:57:02 +00:00
Richard Smith e867e98314 [c++2a] Improve diagnostic for use of declaration from another TU's
global module fragment.

We know that the declaration in question should have been introduced by
a '#include', so try to figure out which one and suggest it. Don't
suggest importing the global module fragment itself!

llvm-svn: 358631
2019-04-18 00:56:58 +00:00
Akira Hatanaka ac57af3284 [Sema][ObjC] Don't warn about an implicitly retained self if the
retaining block and all of the enclosing blocks are non-escaping.

If the block implicitly retaining self doesn't escape, there is no risk
of creating retain cycles, so clang shouldn't diagnose it and force
users to add self-> to silence the diagnostic.

Also, fix a bug where clang was failing to diagnose an implicitly
retained self inside a c++ lambda nested inside a block.

rdar://problem/25059955

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

llvm-svn: 358624
2019-04-17 23:14:44 +00:00
Leonard Chan 5c09f8d6c1 [NFC] Remove unused function (Sema::pushExternalDeclIntoScope)
llvm-svn: 358538
2019-04-16 22:59:39 +00:00
Richard Smith d652bdd05f [c++20] Parsing support for module-declarations, import-declarations,
and the global and private module fragment.

For now, the private module fragment introducer is ignored, but use of
the global module fragment introducer should be properly enforced.

llvm-svn: 358353
2019-04-14 08:06:59 +00:00
Erik Pilkington c5a0583400 Add support for attributes on @implementations in Objective-C
We want to make objc_nonlazy_class apply to implementations, but ran into this.
There doesn't seem to be any reason that this isn't supported.

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

llvm-svn: 358200
2019-04-11 17:55:30 +00:00
Dmitri Gribenko 66b6bb1766 Check i < FD->getNumParams() before querying
Summary:
As was already stated in a previous comment, the parameter isn't
necessarily referring to one of the DeclContext's parameter. We
should check the index is within the range to avoid out-of-boundary
access.

Reviewers: gribozavr, rsmith, lebedev.ri

Reviewed By: gribozavr, rsmith

Subscribers: lebedev.ri, cfe-commits

Tags: #clang

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

Patch by Violet.

llvm-svn: 358134
2019-04-10 20:25:07 +00:00
Alexey Bataev 366f4d45c0 [OPENMP]Allow allocate directive on parameters.
Patch allows to use allocate directives on the function parameters.

llvm-svn: 358016
2019-04-09 16:31:37 +00:00
Craig Topper 1b62c758d0 [X86] Add some fp to integer conversion intrinsics to Sema::CheckX86BuiltinRoundingOrSAE so their rounding controls will be checked.
If we don't check this in the frontend we'll get an isel error in the backend later. This is far less friendly to users.

llvm-svn: 357924
2019-04-08 17:05:57 +00:00
Alexey Bataev 0923266be5 [OPENMP]Fix lookup of the user-defined reductions in C.
Fixed the regression of the lookup of user-defined reductions for C.

llvm-svn: 357708
2019-04-04 17:28:22 +00:00
Sam McCall bc7ff89964 [CodeComplete] Fix crash when completing ObjC block parameter with a broken type
Summary:
The fix isn't great, but it's hard to fix properly because the completion
code sensibly uses ParmVarDecl to represent parameters, but the AST-building
code sensibly doesn't synthesize them if the type is broken.
Also this case is apparently really rare, so it's probably not worth bending
over backwards for.

Reviewers: ilya-biryukov

Subscribers: javed.absar, kristof.beyls, arphaman, cfe-commits

Tags: #clang

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

llvm-svn: 357686
2019-04-04 11:34:18 +00:00
Anastasia Stulova 9b4c6b8c7b [PR41157][OpenCL] Prevent implicit init of local addr space var in C++ mode.
Prevent adding initializers implicitly to variables declared in
local address space. This happens when they get converted into
global variables and therefore theoretically have to be default
initialized in C++.

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

llvm-svn: 357684
2019-04-04 11:08:51 +00:00
Anastasia Stulova 094c72660a [PR41276] Fixed incorrect generation of addr space cast for 'this' in C++.
Improved classification of address space cast when qualification
conversion is performed - prevent adding addr space cast for
non-pointer and non-reference types. Take address space correctly
from the pointee.

Also pass correct address space from 'this' object using
AggValueSlot when generating addrspacecast in the constructor
call.

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

llvm-svn: 357682
2019-04-04 10:48:36 +00:00
Erik Pilkington af91315668 [Sema] Fix a use-after-deallocate of a ParsedAttr
moveAttrFromListToList only makes sense when moving an attribute to a list with
a pool that's either equivalent, or has a shorter lifetime. Therefore, using it
to move a ParsedAttr from a declarator to a declaration specifier doesn't make
sense, since the declaration specifier's pool outlives the declarator's. The
patch adds a new function, ParsedAttributes::takeOneFrom, which transfers the
attribute from one pool to another, fixing the use-after-deallocate.

rdar://49175426

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

llvm-svn: 357516
2019-04-02 19:48:11 +00:00
Alexey Bataev 84c8baeef7 [OPENMP]Allocate clause allocator in target region.
According to OpenMP 5.0, 2.11.4 allocate Clause, Restrictions, allocate
clauses that appear on a target construct or on constructs in a target
region must specify an allocator expression unless a requires directive
with the dynamic_allocators clause is present in the same compilation
unit. Patch adds a check for this restriction.

llvm-svn: 357412
2019-04-01 16:56:59 +00:00
Alexey Bataev e106f25f05 [OPENMP] Check that allocated variables are used in private clauses.
According to OpenMP 5.0 standard, 2.11.4 allocate Clause, Restrictions,
For any list item that is specified in the allocate clause on a
directive, a data-sharing attribute clause that may create a private
copy of that list item must be specified on the same directive. Patch
adds the checks for this restriction.

llvm-svn: 357390
2019-04-01 14:25:31 +00:00
Fangrui Song 75e74e077c Range-style std::find{,_if} -> llvm::find{,_if}. NFC
llvm-svn: 357359
2019-03-31 08:48:19 +00:00
Anton Afanasyev d880de2d19 Adds `-ftime-trace` option to clang that produces Chrome `chrome://tracing` compatible JSON profiling output dumps.
This change adds hierarchical "time trace" profiling blocks that can be visualized in Chrome, in a "flame chart" style. Each profiling block can have a "detail" string that for example indicates the file being processed, template name being instantiated, function being optimized etc.

This is taken from GitHub PR: https://github.com/aras-p/llvm-project-20170507/pull/2

Patch by Aras Pranckevičius.

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

llvm-svn: 357340
2019-03-30 08:42:48 +00:00
Erik Pilkington 233ff94212 [Sema] Avoid sending a dependent expression to the constant evaluator.
Fixes llvm.org/PR41286

llvm-svn: 357304
2019-03-29 19:53:41 +00:00
Volodymyr Sapsai 9e911f3a64 [Sema] Fix assertion when `auto` parameter in lambda has an attribute.
Fixes the assertion
> no Attr* for AttributedType*
> UNREACHABLE executed at llvm-project/clang/lib/Sema/SemaType.cpp:298!

In `TypeProcessingState::getAttributedType` we put into `AttrsForTypes`
types with `auto` but later in
`TypeProcessingState::takeAttrForAttributedType` we use transformed
types and that's why cannot find `Attr` corresponding to
`AttributedType`.

Fix by keeping `AttrsForTypes` up to date after replacing `AutoType`.

rdar://problem/47689465

Reviewers: rsmith, arphaman, aaron.ballman

Reviewed By: aaron.ballman

Subscribers: jkorous, dexonsmith, jdoerfert, cfe-commits

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

llvm-svn: 357298
2019-03-29 18:47:07 +00:00
Michael Liao ce38992a30 [Sema] Fix a crash when nonnull checking
Summary:
- If a parameter is used, nonnull checking needs function prototype to
  retrieve the corresponding parameter's attributes. However, at the
  prototype substitution phase when a template is being instantiated,
  expression may be created and checked without a fully specialized
  prototype. Under such a scenario, skip nonnull checking on that
  argument.

Reviewers: rjmccall, tra, yaxunl

Subscribers: javed.absar, kristof.beyls, cfe-commits

Tags: #clang

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

llvm-svn: 357236
2019-03-29 03:55:52 +00:00
Alexey Bataev 471171c4c9 [OPENMP]Add check for undefined behavior with thread allocators on
target and task-based directives.

According to OpenMP 5.0, 2.11.4 allocate Clause, Restrictions, For task,
taskloop or target directives, allocation requests to memory allocators
with the trait access set to thread result in unspecified behavior.
Patch introduces a check for omp_thread_mem_alloc predefined allocator
on target- and trask-based directives.

llvm-svn: 357205
2019-03-28 19:15:36 +00:00
Benjamin Kramer ba2ea93ad1 Make helper functions static. NFC.
llvm-svn: 357187
2019-03-28 17:18:42 +00:00
Alexey Bataev e04483ee35 [OPENMP]Initial support for 'allocate' clause.
Added parsing/sema analysis of the allocate clause.

llvm-svn: 357068
2019-03-27 14:14:31 +00:00
Erik Pilkington 818698010c Emit -Wfortify-source using DiagRuntimeBehaviour
This fixes a false positive on the following, where st is configured to have
different sizes based on some preprocessor logic:

  if (sizeof(buf) == sizeof(*st))
    memcpy(&buf, st, sizeof(*st));

llvm-svn: 357041
2019-03-26 23:21:22 +00:00
Erik Pilkington 14f6d1527c [Sema] Fix an assert when a block captures a constexpr local
MarkVarDeclODRUsed indirectly calls captureInBlock, which creates a copy
expression. The copy expression is insulated in it's own
ExpressionEvaluationContext, so it saves, mutates, and restores MaybeODRUseExprs
as CleanupVarDeclMarking is iterating through it, leading to a crash. Fix this
by iterating through a local copy of MaybeODRUseExprs.

rdar://47493525

https://reviews.llvm.org/D59670

llvm-svn: 357040
2019-03-26 23:21:19 +00:00
Duncan P. N. Exon Smith db8a742206 Basic: Return a reference from FileManager::getVirtualFileSystem, NFC
FileManager constructs a VFS in its constructor if it isn't passed one,
and there's no way to reset it.  Make that contract clear by returning a
reference from its accessor.

https://reviews.llvm.org/D59388

llvm-svn: 357038
2019-03-26 22:32:06 +00:00
Reid Kleckner 1181c9f45d [MS] Add frontend support for __declspec(allocator)
The intention is to add metadata to direct call sites of functions
marked with __declspec(allocator), which will ultimately result in some
S_HEAPALLOCSITE debug info records when emitting codeview.

This is a piece of PR38491

llvm-svn: 356964
2019-03-25 23:20:18 +00:00
Bruno Ricci 95550e412f [Sema] Don't check for array bounds when the types in the base expression are dependent
Bail-out of CheckArrayAccess when the types of the base expression before
and after eventual casts are dependent. We will get another chance to check
for array bounds during instantiation. Fixes PR41087.

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

Reviewed By: efriedma

llvm-svn: 356957
2019-03-25 21:37:10 +00:00
Bruno Ricci 70ad396bc4 [Sema][NFCI] Don't allocate storage for the various CorrectionCandidateCallback unless we are going to do some typo correction
The various CorrectionCandidateCallbacks are currently heap-allocated
unconditionally. This was needed because of delayed typo correction.
However these allocations represent currently 15.4% of all allocations
(number of allocations) when parsing all of Boost (!), mostly because
of ParseCastExpression, ParseStatementOrDeclarationAfterAttrtibutes
and isCXXDeclarationSpecifier. Note that all of these callback objects
are small. Let's not do this.

Instead initially allocate the callback on the stack, and only do a
heap allocation if we are going to do some typo correction. Do this by:

1. Adding a clone function to each callback, which will do a polymorphic
   clone of the callback. This clone function is required to be implemented
   by every callback (of which there is a fair amount). Make sure this is
   the case by making it pure virtual.

2. Use this clone function when we are going to try to correct a typo.

This additionally cut the time of -fsyntax-only on all of Boost by 0.5%
(not that much, but still something). No functional changes intended.

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

Reviewed By: rnk

llvm-svn: 356925
2019-03-25 17:08:51 +00:00
Brian Gesiak b15c35aff8 Un-revert "[coroutines][PR40978] Emit error for co_yield within catch block"
Summary:
https://reviews.llvm.org/D59076 added a new coroutine error that
prevented users from using 'co_await' or 'co_yield' within a exception
handler. However, it was reverted in https://reviews.llvm.org/rC356774
because it caused a regression in nested scopes in C++ catch statements,
as documented by https://bugs.llvm.org/show_bug.cgi?id=41171.

The issue was due to an incorrect use of a `clang::ParseScope`. To fix:

1. Add a regression test for catch statement parsing that mimics the bug
   report from https://bugs.llvm.org/show_bug.cgi?id=41171.
2. Re-apply the coroutines error patch from
   https://reviews.llvm.org/D59076, but this time with the correct
   ParseScope behavior.

Reviewers: GorNishanov, tks2103, rsmith, riccibruno, jbulow

Reviewed By: riccibruno

Subscribers: EricWF, jdoerfert, lewissbaker, cfe-commits

Tags: #clang

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

llvm-svn: 356865
2019-03-25 00:53:10 +00:00
Brian Gesiak e8b3d63dd5 Revert "[coroutines][PR40978] Emit error for co_yield within catch block"
The commit https://reviews.llvm.org/rC356296 is causing a regression in nested
catch scopes, https://bugs.llvm.org/show_bug.cgi?id=41171. Revert this change
for now in order to un-break that problem report.

llvm-svn: 356774
2019-03-22 16:08:29 +00:00
Alexey Bataev f493607d43 [OPENMP]Add missing comment, NFC.
llvm-svn: 356759
2019-03-22 15:32:02 +00:00
Alexey Bataev 318f431beb [OPENMP]Allow no allocator clause in target regions with requires
dynamic_allocators.

According to the OpenMP 5.0, 2.11.3 allocate Directive, Restrictions,
allocate directives that appear in a target region must specify an
allocator clause unless a requires directive with the dynamic_allocators
clause is present in the same compilation unit. Patch adds a check for a
presence of the requires directive with the dynamic_allocators clause.

llvm-svn: 356758
2019-03-22 15:25:12 +00:00
Alexey Bataev 2213dd61d6 [OPENMP]Emit error message for allocate directive without allocator
clause in target region.

According to the OpenMP 5.0, 2.11.3 allocate Directive, Restrictions,
allocate directives that appear in a target region must specify an
allocator clause unless a requires directive with the dynamic_allocators
clause is present in the same compilation unit.

llvm-svn: 356752
2019-03-22 14:41:39 +00:00
Alexey Bataev 441510ef54 [OPENMP]Simplify the check for the predefined allocators, NFC.
Previously implemented check required the reevaluation of the already
evaluated predefined allocator kind for the global variables. Patch
simplifies this evaluation and removes extra code.

llvm-svn: 356699
2019-03-21 19:05:07 +00:00
Erich Keane 505427cb2f Permit redeclarations of a builtin to specify calling convention.
After https://reviews.llvm.org/rL355317 we noticed that quite a decent
amount of code redeclares builtins (memcpy in particular, I believe
reduced from an MSVC header) with a calling convention specified.
This gets particularly troublesome when the user specifies a new
'default' calling convention on the command line.

When looking to add a diagnostic for this case, it was noticed that we
had 3 other diagnostics that differed only slightly.  This patch ALSO
unifies those under a 'select'.  Unfortunately, the order of words in
ONE of these diagnostics was reversed ("'thiscall' calling convention"
vs "calling convention 'thiscall'"), so this patch also standardizes on
the former.

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

Change-Id: I79f99fe7c2301640755ffdd774b46eb44526bb22
llvm-svn: 356663
2019-03-21 13:30:56 +00:00
Alexey Bataev 27ef9518de [OPENMP]Improve detection of omp_allocator_handle_t type and predefined
allocators.

It is better to deduce omp_allocator_handle_t type from the predefined
allocators, because omp.h header might not define it explicitly. Plus,
it allows to identify the predefined allocators correctly when trying to
build the allcoator for the global variables.

llvm-svn: 356607
2019-03-20 20:14:22 +00:00
Alex Lorenz 0b4364847d Fix implicit ios -> watchOS availability version mapping for
versions that have the major number only

rdar://48018651

llvm-svn: 356605
2019-03-20 20:02:00 +00:00
Erik Pilkington 13ee62f7d7 [Sema] Deduplicate some availability checking logic
Before this commit, we emit unavailable errors for calls to functions during
overload resolution, and for references to all other declarations in
DiagnoseUseOfDecl. The early checks during overload resolution aren't as good as
the DiagnoseAvailabilityOfDecl based checks, as they error on the code from
PR40991. This commit fixes this by removing the early checking.

llvm.org/PR40991
rdar://48564179

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

llvm-svn: 356599
2019-03-20 19:26:33 +00:00
Rafael Auler 9dde31ecc1 Recommit "Support attribute used in member funcs of class templates"
This diff previously exposed a bug in LLVM's IRLinker, breaking
buildbots that tried to self-host LLVM with monolithic LTO.
The bug is now in LLVM by D59552

Original commit message:
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

llvm-svn: 356598
2019-03-20 19:22:24 +00:00
Roman Lebedev b570060fd8 [clang][OpeMP] Model OpenMP structured-block in AST (PR40563)
Summary:
https://www.openmp.org/wp-content/uploads/OpenMP-API-Specification-5.0.pdf, page 3:
```
structured block

For C/C++, an executable statement, possibly compound, with a single entry at the
top and a single exit at the bottom, or an OpenMP construct.

COMMENT: See Section 2.1 on page 38 for restrictions on structured
blocks.
```
```
2.1 Directive Format

Some executable directives include a structured block. A structured block:
• may contain infinite loops where the point of exit is never reached;
• may halt due to an IEEE exception;
• may contain calls to exit(), _Exit(), quick_exit(), abort() or functions with a
_Noreturn specifier (in C) or a noreturn attribute (in C/C++);
• may be an expression statement, iteration statement, selection statement, or try block, provided
that the corresponding compound statement obtained by enclosing it in { and } would be a
structured block; and

Restrictions
Restrictions to structured blocks are as follows:
• Entry to a structured block must not be the result of a branch.
• The point of exit cannot be a branch out of the structured block.
C / C++
• The point of entry to a structured block must not be a call to setjmp().
• longjmp() and throw() must not violate the entry/exit criteria.
```

Of particular note here is the fact that OpenMP structured blocks are as-if `noexcept`,
in the same sense as with the normal `noexcept` functions in C++.
I.e. if throw happens, and it attempts to travel out of the `noexcept` function
(here: out of the current structured-block), then the program terminates.

Now, one of course can say that since it is explicitly prohibited by the Specification,
then any and all programs that violate this Specification contain undefined behavior,
and are unspecified, and thus no one should care about them. Just don't write broken code /s

But i'm not sure this is a reasonable approach.
I have personally had oss-fuzz issues of this origin - exception thrown inside
of an OpenMP structured-block that is not caught, thus causing program termination.
This issue isn't all that hard to catch, it's not any particularly different from
diagnosing the same situation with the normal `noexcept` function.

Now, clang static analyzer does not presently model exceptions.
But clang-tidy has a simplisic [[ https://clang.llvm.org/extra/clang-tidy/checks/bugprone-exception-escape.html | bugprone-exception-escape ]] check,
and it is even refactored as a `ExceptionAnalyzer` class for reuse.
So it would be trivial to use that analyzer to check for
exceptions escaping out of OpenMP structured blocks. (D59466)

All that sounds too great to be true. Indeed, there is a caveat.
Presently, it's practically impossible to do. To check a OpenMP structured block
you need to somehow 'get' the OpenMP structured block, and you can't because
it's simply not modelled in AST. `CapturedStmt`/`CapturedDecl` is not it's representation.

Now, it is of course possible to write e.g. some AST matcher that would e.g.
match every OpenMP executable directive, and then return the whatever `Stmt` is
the structured block of said executable directive, if any.
But i said //practically//. This isn't practical for the following reasons:
1. This **will** bitrot. That matcher will need to be kept up-to-date,
   and refreshed with every new OpenMP spec version.
2. Every single piece of code that would want that knowledge would need to
   have such matcher. Well, okay, if it is an AST matcher, it could be shared.
   But then you still have `RecursiveASTVisitor` and friends.
   `2 > 1`, so now you have code duplication.

So it would be reasonable (and is fully within clang AST spirit) to not
force every single consumer to do that work, but instead store that knowledge
in the correct, and appropriate place - AST, class structure.

Now, there is another hoop we need to get through.
It isn't fully obvious //how// to model this.
The best solution would of course be to simply add a `OMPStructuredBlock` transparent
node. It would be optimal, it would give us two properties:
* Given this `OMPExecutableDirective`, what's it OpenMP structured block?
* It is trivial to  check whether the `Stmt*` is a OpenMP structured block (`isa<OMPStructuredBlock>(ptr)`)

But OpenMP structured block isn't **necessarily** the first, direct child of `OMP*Directive`.
(even ignoring the clang's `CapturedStmt`/`CapturedDecl` that were inserted inbetween).
So i'm not sure whether or not we could re-create AST statements after they were already created?
There would be other costs to a new AST node: https://bugs.llvm.org/show_bug.cgi?id=40563#c12
```
1. You will need to break the representation of loops. The body should be replaced by the "structured block" entity.
2. You will need to support serialization/deserialization.
3. You will need to support template instantiation.
4. You will need to support codegen and take this new construct to account in each OpenMP directive.
```

Instead, there **is** an functionally-equivalent, alternative solution, consisting of two parts.

Part 1:
* Add a member function `isStandaloneDirective()` to the `OMPExecutableDirective` class,
  that will tell whether this directive is stand-alone or not, as per the spec.
  We need it because we can't just check for the existance of associated statements,
  see code comment.
* Add a member function `getStructuredBlock()` to the OMPExecutableDirective` class itself,
  that assert that this is not a stand-alone directive, and either return the correct loop body
  if this is a loop-like directive, or the captured statement.
This way, given an `OMPExecutableDirective`, we can get it's structured block.
Also, since the knowledge is ingrained into the clang OpenMP implementation,
it will not cause any duplication, and //hopefully// won't bitrot.

Great we achieved 1 of 2 properties of `OMPStructuredBlock` approach.

Thus, there is a second part needed:
* How can we check whether a given `Stmt*` is `OMPStructuredBlock`?
Well, we can't really, in general. I can see this workaround:
```
class FunctionASTVisitor : public RecursiveASTVisitor<FunctionASTVisitor> {
  using Base = RecursiveASTVisitor<FunctionASTVisitor>;
public:
  bool VisitOMPExecDir(OMPExecDir *D) {
    OmpStructuredStmts.emplace_back(D.getStructuredStmt());
  }
  bool VisitSOMETHINGELSE(???) {
    if(InOmpStructuredStmt)
      HI!
  }
  bool TraverseStmt(Stmt *Node) {
    if (!Node)
      return Base::TraverseStmt(Node);
    if (OmpStructuredStmts.back() == Node)
      ++InOmpStructuredStmt;
    Base::TraverseStmt(Node);
    if (OmpStructuredStmts.back() == Node) {
      OmpStructuredStmts.pop_back();
      --InOmpStructuredStmt;
    }
    return true;
  }
  std::vector<Stmt*> OmpStructuredStmts;
  int InOmpStructuredStmt = 0;
};
```
But i really don't see using it in practice.
It's just too intrusive; and again, requires knowledge duplication.

.. but no. The solution lies right on the ground.
Why don't we simply store this `i'm a openmp structured block` in the bitfield of the `Stmt` itself?
This does not appear to have any impact on the memory footprint of the clang AST,
since it's just a single extra bit in the bitfield. At least the static assertions don't fail.
Thus, indeed, we can achieve both of the properties without a new AST node.

We can cheaply set that bit right in sema, at the end of `Sema::ActOnOpenMPExecutableDirective()`,
by just calling the `getStructuredBlock()` that we just added.
Test coverage that demonstrates all this has been added.

This isn't as great with serialization though. Most of it does not use abbrevs,
so we do end up paying the full price (4 bytes?) instead of a single bit.
That price, of course, can be reclaimed by using abbrevs.
In fact, i suspect that //might// not just reclaim these bytes, but pack these PCH significantly.

I'm not seeing a third solution. If there is one, it would be interesting to hear about it.
("just don't write code that would require `isa<OMPStructuredBlock>(ptr)`" is not a solution.)

Fixes [[ https://bugs.llvm.org/show_bug.cgi?id=40563 | PR40563 ]].

Reviewers: ABataev, rjmccall, hfinkel, rsmith, riccibruno, gribozavr

Reviewed By: ABataev, gribozavr

Subscribers: mgorny, aaron.ballman, steveire, guansong, jfb, jdoerfert, cfe-commits

Tags: #clang, #openmp

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

llvm-svn: 356570
2019-03-20 16:32:36 +00:00
Erik Pilkington 02d5fb1a6e Add a spelling of pass_object_size that uses __builtin_dynamic_object_size
The attribute pass_dynamic_object_size(n) behaves exactly like
pass_object_size(n), but instead of evaluating __builtin_object_size on calls,
it evaluates __builtin_dynamic_object_size, which has the potential to produce
runtime code when the object size can't be determined statically.

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

llvm-svn: 356515
2019-03-19 20:44:18 +00:00
Alexey Bataev 282555ad82 [OPENMP]Warn if the different allocator is used for the variable.
If the allocator was specified for the variable and next one is found
with the different allocator, the warning is emitted, and the allocator
is ignored.

llvm-svn: 356513
2019-03-19 20:33:44 +00:00
Alexey Bataev d2fc965f1b [OPENMP]Check that global vars require predefined allocator.
According to OpenMP, 2.11.3 allocate Directive, Restrictions, C / C++,
if a list item has a static storage type, the allocator expression in
  the allocator clause must be a constant expression that evaluates to
  one of the predefined memory allocator values. Added check for this
  restriction.

llvm-svn: 356496
2019-03-19 18:39:11 +00:00
Anastasia Stulova 4ce581e5a9 [Sema] Adjust addr space of reference operand in compound assignment
When we create overloads for the builtin compound assignment operators
we need to preserve address space for the reference operand taking it
from the argument that is passed in.

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

llvm-svn: 356475
2019-03-19 16:50:21 +00:00
Aaron Ballman 165435ffa0 Ensure that const variables declared at namespace scope correctly have external linkage when marked as dllexport and targeting the MSVC ABI.
Patch thanks to Zahira Ammarguellat.

llvm-svn: 356458
2019-03-19 14:53:52 +00:00
Don Hinton f170dff3c1 Refactor cast<>'s in if conditionals, which can only assert on failure.
Summary:
This patch refactors several instances of cast<> used in if
conditionals.  Since cast<> asserts on failure, the else branch can
never be taken.

In some cases, the fix is to replace cast<> with dyn_cast<>.  While
others required the removal of the conditional and some minor
refactoring.

A discussion can be seen here: http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20190318/265044.html

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

llvm-svn: 356441
2019-03-19 06:14:14 +00:00
Aaron Puchert dc087de14c Minor renaming as suggested in review [NFC]
See D59455.

llvm-svn: 356430
2019-03-19 00:14:46 +00:00
Aaron Puchert ad4d52a501 Thread safety analysis: Add note for unlock kind mismatch
Summary:
Similar to D56967, we add the existing diag::note_locked_here to tell
the user where we saw the locking that isn't matched correctly.

Reviewers: aaron.ballman, delesley

Reviewed By: aaron.ballman

Subscribers: cfe-commits

Tags: #clang

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

llvm-svn: 356427
2019-03-18 23:26:54 +00:00
Erik Pilkington b6e16ea006 [Sema] Add some compile time _FORTIFY_SOURCE diagnostics
These diagnose overflowing calls to subset of fortifiable functions. Some
functions, like sprintf or strcpy aren't supported right not, but we should
probably support these in the future. We previously supported this kind of
functionality with -Wbuiltin-memcpy-chk-size, but that diagnostic doesn't work
with _FORTIFY implementations that use wrapper functions. Also unlike that
diagnostic, we emit these warnings regardless of whether _FORTIFY_SOURCE is
actually enabled, which is nice for programs that don't enable the runtime
checks.

Why not just use diagnose_if, like Bionic does? We can get better diagnostics in
the compiler (i.e. mention the sizes), and we have the potential to diagnose
sprintf and strcpy which is impossible with diagnose_if (at least, in languages
that don't support C++14 constexpr). This approach also saves standard libraries
from having to add diagnose_if.

rdar://48006655

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

llvm-svn: 356397
2019-03-18 19:23:45 +00:00
Brian Gesiak 9db9b1a175 [coroutines][PR40978] Emit error for co_yield within catch block
Summary:
As reported in https://bugs.llvm.org/show_bug.cgi?id=40978, it's an
error to use the `co_yield` or `co_await` keywords outside of a valid
"suspension context" as defined by [expr.await]p2 of
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/n4775.pdf.

Whether or not the current scope was in a function-try-block's
(https://en.cppreference.com/w/cpp/language/function-try-block) handler
could be determined using scope flag `Scope::FnTryCatchScope`. No
such flag existed for a simple C++ catch statement, so this commit adds
one.

Reviewers: GorNishanov, tks2103, rsmith

Reviewed By: GorNishanov

Subscribers: EricWF, jdoerfert, cfe-commits, lewissbaker

Tags: #clang

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

llvm-svn: 356296
2019-03-15 20:25:49 +00:00
Richard Trieu ef1e06df6f Remove an assert in template pack deduction during nested instantiation.
llvm-svn: 356231
2019-03-15 04:26:02 +00:00
Alexey Bataev 0d8fcdf11a [OPENMP]Fix crash for the ordered(n) clause.
If the doacross lop construct is used and the loop counter is declare
outside of the loop, the compiler might crash trying to get the address
of the loop counter. Patch fixes this problem.

llvm-svn: 356198
2019-03-14 20:36:00 +00:00
Erik Pilkington 3689caebec [Sema] Fix a use-after-free of a _Nonnull ParsedAttr
We were allocating the implicit attribute in the declarator's attribute pool,
but putting into the declaration specifier's ParsedAttributesView. If there are
multiple declarators, then we'll use the attribute from the declaration
specifier after clearing out the declarators attribute pool. Fix this by
allocating the attribute in the declaration specifier's pool.

rdar://48529718

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

llvm-svn: 356187
2019-03-14 18:38:02 +00:00
Nico Weber 98dd085d1f Objective-C++11: Support static_assert() in @interface/@implementation ivar lists and method declarations
This adds support for static_assert() (and _Static_assert()) in
@interface/@implementation ivar lists and in @interface method declarations.

It was already supported in @implementation blocks outside of the ivar lists.

The assert AST nodes are added at file scope, matching where other
(non-Objective-C) declarations at @interface / @implementation level go (cf
`allTUVariables`).

Also add a `__has_feature(objc_c_static_assert)` that's true in C11 (and
`__has_extension(objc_c_static_assert)` that's always true) and
`__has_feature(objc_cxx_static_assert)` that's true in C++11 modea fter this
patch, so it's possible to check if this is supported.

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

llvm-svn: 356148
2019-03-14 14:18:56 +00:00
Erik Pilkington 02886e5476 Revert "Add a new attribute, fortify_stdlib"
This reverts commit r353765. After talking with our c stdlib folks, we decided
to use the existing pass_object_size attribute to implement _FORTIFY_SOURCE
wrappers, like Bionic does (I didn't realize that pass_object_size could be used
for this purpose). Sorry for the flip/flop, and thanks to James Y. Knight for
pointing this out to me.

llvm-svn: 356103
2019-03-13 21:37:01 +00:00
Alexey Bataev 74a04e80c8 [OPENMP]Disable ADL in C for user-defined reductions.
C does not support ADL, disable it for C to prevent compiler crash.

llvm-svn: 356089
2019-03-13 19:31:34 +00:00
Alexey Bataev 9cc10fc926 [OPENMP 5.0]Initial support for 'allocator' clause.
Added parsing/sema analysis/serialization/deserialization for the
'allocator' clause of the 'allocate' directive.

llvm-svn: 355952
2019-03-12 18:52:33 +00:00
Anastasia Stulova 47a2c3305a [PR41007][OpenCL] Allow printf in C++ mode.
As for OpenCL C, we need to allow using printf and toolchain variadic
functions (prefixed by "__") in C++ mode.

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

llvm-svn: 355915
2019-03-12 12:46:56 +00:00
Alexey Bataev a495c6403b [OPENMP]Fix codegen for declare target link in target regions.
If the declare target link global is used in the target region
indirectly (used in the inner parallel, teams, etc. regions), we may
miss this variable and it leads to incorrect codegen.

llvm-svn: 355858
2019-03-11 19:51:42 +00:00
Rafael Auler 94b575b23b Revert "Recommit "Support attribute used in member funcs of class templates""
There is nontrivial bug caused in lld that I need to further
investigate. Meanwhile, I'll revert this.

This reverts commit 8297e93480c636dc90fd14653c5a66406193363f.

llvm-svn: 355721
2019-03-08 20:23:57 +00:00
Akira Hatanaka 1488ee4bd5 [ObjC] Emit a boxed expression as a compile-time constant if the
expression inside the parentheses is a valid UTF-8 string literal.

Previously clang emitted an expression like @("abc") as a message send
to stringWithUTF8String. This commit makes clang emit the boxed
expression as a compile-time constant instead.

This commit also has the effect of silencing the nullable-to-nonnull
conversion warning clang started emitting after r317727, which
originally motivated this commit (see https://oleb.net/2018/@keypath).

rdar://problem/42684601

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

llvm-svn: 355662
2019-03-08 04:45:37 +00:00
Rafael Auler 2ead8e8993 Recommit "Support attribute used in member funcs of class templates"
The patch originally broke code that was incompatible with GCC, but
we want to follow GCC behavior here according to the discussion in
https://reviews.llvm.org/D58216

Original commit message:
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

llvm-svn: 355627
2019-03-07 19:14:30 +00:00
Alexey Bataev 25ed0c07c1 [OPENMP 5.0]Add initial support for 'allocate' directive.
Added parsing/sema analysis/serialization/deserialization support for
'allocate' directive.

llvm-svn: 355614
2019-03-07 17:54:44 +00:00
Anastasia Stulova 6f7c536e08 [Sema] Change addr space diagnostics in casts to follow C++ style.
This change adds a new diagnostic for mismatching address spaces
to be used for C++ casts (only enabled in C style cast for now,
the rest will follow!).

The change extends C-style cast rules to account for address spaces.
It also adds a separate function for address space cast checking that
can be used to map from a separate address space cast operator
addrspace_cast (to be added as a follow up patch).

Note, that after this change clang will no longer allows arbitrary
address space conversions in reinterpret_casts because they can lead
to accidental errors. The implicit safe conversions would still be
allowed.

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

llvm-svn: 355609
2019-03-07 17:06:30 +00:00
Anastasia Stulova 27e5c212ee [PR40778][Sema] Adjust addr space of operands in builtin operators.
Adjust address space for references and pointer operands of builtin operators.

Currently this change only fixes addr space in assignment (= and |=) operator,
that is needed for the test case reported in the bug. Wider support for all
other operations will follow.

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

llvm-svn: 355608
2019-03-07 16:43:41 +00:00
Anastasia Stulova 9404955416 [PR40778] Preserve addr space in Derived to Base cast.
The address space for the Base class pointer when up-casting
from Derived should be taken from the Derived class pointer.

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

llvm-svn: 355606
2019-03-07 16:23:15 +00:00
Anastasia Stulova d3ae87ee0d [PR40778] Add addr space conversion when binding reference to a temporary.
This change fixes temporary materialization to happen in the right
(default) address space when binding to it a reference of different type.

It adds address space conversion afterwards to match the addr space
of a reference.

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

llvm-svn: 355499
2019-03-06 13:02:41 +00:00
Hans Wennborg dd1ea8abb7 Inline asm constraints: allow ICE-like pointers for the "n" constraint (PR40890)
Apparently GCC allows this, and there's code relying on it (see bug).

The idea is to allow expression that would have been allowed if they
were cast to int. So I based the code on how such a cast would be done
(the CK_PointerToIntegral case in IntExprEvaluator::VisitCastExpr()).

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

llvm-svn: 355491
2019-03-06 10:26:19 +00:00
Roman Lebedev 0457388125 [clang][OpenMP] Revert "OMPFlushClause is synthetic, no such clause exists"
Summary:
This reverts rL352390 / D57280.

As discussed in https://reviews.llvm.org/D57112#inline-506781,
'flush' clause does not exist in the OpenMP spec, it can not be
specified, and `OMPFlushClause` class is just a helper class.

Now, here's the caveat. I have read @ABataev's
> Well, I think it would be good to filter out OMPC_flush somehow
> because there is no such clause actually, it is a pseudo clause
> for better handling of the flush directive.
as if that clause is pseudo clause that only exists for the sole
purpose of simplifying the parser. As in, it never reaches AST.

I did not however try to verify that. Too bad, i was wrong.
It absolutely *does* reach AST. Therefore my understanding/justification
for the change was flawed, which makes the patch a regression which **must** be reverted.

@gribozavr has brought that up again in https://reviews.llvm.org/D57112#inline-521238

> > ...
> Sorry to be late for this discussion, but I don't think this conclusion
> follows. ASTMatchers are supposed to match the AST as it is.
> Even if OMPC_flush is synthetic, it exists in the AST, and users might
> want to match it. I think users would find anything else (trying to filter
> out AST nodes that are not in the source code) to be surprising. For example,
> there's a matcher materializeTemporaryExpr even though this AST node is a
> Clang invention and is not a part of the C++ spec.
>
> Matching only constructs that appear in the source code is not feasible with
> ASTMatchers, because they are based on Clang's AST that exposes tons of semantic
> information, and its design is dictated by the structure of the semantic information.
> See "RFC: Tree-based refactorings with Clang" in cfe-dev for a library that will
> focus on representing source code as faithfully as possible.
>
> Not to even mention that this code is in ASTTypeTraits, a general library for
> handling AST nodes, not specifically for AST Matchers...

Reviewers: gribozavr, ABataev, rjmccall, aaron.ballman

Reviewed By: gribozavr, ABataev

Subscribers: dylanmckay, guansong, arphaman, jdoerfert, cfe-commits, gribozavr, ABataev

Tags: #clang, #openmp

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

llvm-svn: 355486
2019-03-06 07:45:10 +00:00
Leonard Chan 8f7caae00a [Fixed Point Arithmetic] Fixed Point and Integer Conversions
This patch includes the necessary code for converting between a fixed point type and integer.
This also includes constant expression evaluation for conversions with these types.

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

llvm-svn: 355462
2019-03-06 00:28:43 +00:00
Yaxun Liu c5be267003 [CUDA][HIP][Sema] Fix template kernel with function as template parameter
If a kernel template has a function as its template parameter, a device function should be
allowed as template argument since a kernel can call a device function. However,
currently if the kernel template is instantiated in a host function, clang will emit an error
message saying the device function is an invalid candidate for the template parameter.

This happens because clang checks the reference to the device function during parsing
the template arguments. At this point, the template is not instantiated yet. Clang incorrectly
assumes the device function is called by the host function and emits the error message.

This patch fixes the issue by disabling checking of device function during parsing template
arguments and deferring the check to the instantion of the template. At that point, the
template decl is already available, therefore the check can be done against the instantiated
function template decl.

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

llvm-svn: 355421
2019-03-05 18:19:35 +00:00
Erich Keane 881e83d8b9 Give builtins and alloc/dealloc operators the default calling convention.
On SPIR targets, the default calling convention is SpirFunction.
However, operator new/delete and builtins were being created with CC_C.
The result is indirect references to new/delete (or builtins that are permitted
to be called indirectly have a mismatched type, as well as questionable codegen
in some cases.

This patch sets both to the default calling convention, so that it
properly matches the calling convention of the target.

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

Change-Id: I52065bb00bc2655945caea8f29c409ba1e0ac24a
llvm-svn: 355317
2019-03-04 14:54:52 +00:00
Pierre Gousseau ae5303d010 [Driver] Allow enum SanitizerOrdinal to represent more than 64 different sanitizer checks, NFC.
enum SanitizerOrdinal has reached maximum capacity, this change extends the capacity to 128 sanitizer checks.
This can eventually allow us to add gcc 8's options "-fsanitize=pointer-substract" and "-fsanitize=pointer-compare".

This is a recommit of r354873 but with a fix for unqualified lookup error in lldb cmake build bot.

Fixes: https://llvm.org/PR39425

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

llvm-svn: 355190
2019-03-01 10:05:15 +00:00
Fangrui Song 524b3c1810 Fix file headers. NFC
llvm-svn: 355176
2019-03-01 06:49:51 +00:00
Akira Hatanaka 78be8b6d53 [Sema][ObjC] Allow silencing -Wobjc-designated-initializers warnings by
declaring an unavailable method in the subclass's extension that
overrides the designated initializer in the base class.

r243676 made changes to allow declaring the unavailable method in the
subclass interface to silence the warning. This commit additionally
allows declaring the unavailable method in the class extension.

rdar://problem/42731306

llvm-svn: 355175
2019-03-01 06:43:20 +00:00
Alexey Bataev 123ad19691 [OPENMP]Delay emission of the error for unsupported types.
If the type is unsupported on the device side, it still must be emitted,
but we should emit errors for operations with such types.

llvm-svn: 355027
2019-02-27 20:29:45 +00:00
Akira Hatanaka c5792aa90f Avoid needlessly copying a block to the heap when a block literal
initializes a local auto variable or is assigned to a local auto
variable that is declared in the scope that introduced the block
literal.

rdar://problem/13289333

https://reviews.llvm.org/D58514

llvm-svn: 355012
2019-02-27 18:17:16 +00:00
David Goldman 3e804d2581 Support framework import/include auto-completion
Frameworks filesystem representations:
  UIKit.framework/Headers/%header%

Framework import format:
  #import <UIKit/%header%>

Thus the completion code must map the input format of <UIKit/> to
the path of UIKit.framework/Headers as well as strip the
".framework" suffix when auto-completing the framework name.

llvm-svn: 355008
2019-02-27 17:40:33 +00:00
Yaxun Liu 785cbd850b [NFC] minor revision of r354929 [CUDA][HIP] Check calling convention based on function target
Add comments and move a variable to if block.

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

llvm-svn: 354990
2019-02-27 15:46:29 +00:00
Yaxun Liu fa49c3a888 [CUDA][HIP] Check calling convention based on function target
MSVC header files using vectorcall to differentiate overloaded functions, which
causes failure for AMDGPU target. This is because clang does not check function
calling convention based on function target.

This patch checks calling convention using the proper target info.

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

llvm-svn: 354929
2019-02-26 22:24:49 +00:00
Alexey Bataev 305b6b9647 [OPENMP][CUDA]Do not emit warnings for variables in late-reported asm
statements.

If the assembler instruction is not generated and the delayed diagnostic
is emitted, we may end up with extra warning message for variables used
in the asm statement. Since the asm statement is not built, the
variables may be left non-referenced and it may produce a warning about
a use of the non-initialized variables.

llvm-svn: 354928
2019-02-26 21:51:16 +00:00
Alexey Bataev ddc181d256 [OPENMP]Delay emission for unsupported va_arg expression.
If the OpenMP device is NVPTX and va_arg is used, delay emission of the
error for va_arg unless it is used in the device code.

llvm-svn: 354925
2019-02-26 20:52:16 +00:00
Michael Liao 7557afa000 [AMDGPU] Allow using integral non-type template parameters
Summary:
- Allow using integral non-type template parameters in the following
  attributes

  __attribute__((amdgpu_flat_work_group_size(<min>, <max>)))
  __attribute__((amdgpu_waves_per_eu(<min>[, <max>])))

Reviewers: kzhuravl, yaxunl

Subscribers: jvesely, wdng, nhaehnle, dstuttard, tpr, t-tye, jdoerfert, cfe-commits

Tags: #clang

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

llvm-svn: 354909
2019-02-26 18:49:36 +00:00
Pierre Gousseau 40ad3d2aa4 revert r354873 as this breaks lldb builds.
llvm-svn: 354875
2019-02-26 13:50:29 +00:00
Pierre Gousseau 44fad947a5 [Driver] Allow enum SanitizerOrdinal to represent more than 64 different sanitizer checks, NFC.
enum SanitizerOrdinal has reached maximum capacity, this change extends the capacity to 128 sanitizer checks.
This can eventually allow us to add gcc 8's options "-fsanitize=pointer-substract" and "-fsanitize=pointer-compare".

Fixes: https://llvm.org/PR39425

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

llvm-svn: 354873
2019-02-26 13:30:14 +00:00
Ilya Biryukov ff2a99752f [CodeComplete] Propagate preferred type for function arguments in more cases
Summary:
See the added test for some new cases.
This change also removes special code completion calls inside the
ParseExpressionList function now that we properly propagate expected
type to the function responsible for parsing elements of the expression list
(ParseAssignmentExpression).

Reviewers: kadircet

Reviewed By: kadircet

Subscribers: xbolva00, jdoerfert, cfe-commits

Tags: #clang

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

llvm-svn: 354864
2019-02-26 11:01:50 +00:00
Alexander Kornienko 5858764f31 Reapply "Make static counters in ASTContext non-static." with fixes.
This reverts commit e50038e4dc.

llvm-svn: 354827
2019-02-25 22:22:09 +00:00
Michael Kruse 0336c75c36 [OpenMP 5.0] Parsing/sema support for from clause with mapper modifier.
This patch implements the parsing and sema support for the OpenMP
'from'-clause with potential user-defined mappers attached.
User-defined mappers are a new feature in OpenMP 5.0. A 'from'-clause
can have an explicit or implicit associated mapper, which instructs the
compiler to generate and use customized mapping functions. An example is
shown below:

    struct S { int len; int *d; };
    #pragma omp declare mapper(id: struct S s) map(s, s.d[0:s.len])
    struct S ss;
    #pragma omp target update from(mapper(id): ss) // use the mapper with name 'id' to map ss from device

Contributed-by: Lingda Li <lildmh@gmail.com>

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

llvm-svn: 354817
2019-02-25 20:34:15 +00:00
Vlad Tsyrklevich e50038e4dc Revert "Make static counters in ASTContext non-static."
This reverts commit r354795, I suspect it is causing test failures
on MSan sanitizer bots.

llvm-svn: 354812
2019-02-25 19:53:13 +00:00
Alexander Kornienko 00c22db89f Make static counters in ASTContext non-static.
Summary:
Fixes a data race and makes it possible to run clang-based tools in
multithreaded environment with TSan.

Reviewers: ilya-biryukov, riccibruno

Reviewed By: riccibruno

Subscribers: riccibruno, jfb, cfe-commits

Tags: #clang

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

llvm-svn: 354795
2019-02-25 16:08:46 +00:00
Richard Smith 10ab78e854 Enable coroutines under -std=c++2a.
llvm-svn: 354736
2019-02-23 21:06:26 +00:00
Michael Kruse 01f670df8f [OpenMP 5.0] Parsing/sema support for to clause with mapper modifier.
This patch implements the parsing and sema support for OpenMP to clause
with potential user-defined mappers attached. User defined mapper is a
new feature in OpenMP 5.0. A to/from clause can have an explicit or
implicit associated mapper, which instructs the compiler to generate and
use customized mapping functions. An example is shown below:

    struct S { int len; int *d; };
    #pragma omp declare mapper(id: struct S s) map(s, s.d[0:s.len])
    struct S ss;
    #pragma omp target update to(mapper(id): ss) // use the mapper with name 'id' to map ss to device

Contributed-by: <lildmh@gmail.com>

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

llvm-svn: 354698
2019-02-22 22:29:42 +00:00
Alexey Bataev e69f94e022 [OPENMP] Delayed diagnostics for VLA support.
Generalized processing of the deferred diagnostics for OpenMP/CUDA code.

llvm-svn: 354690
2019-02-22 20:36:10 +00:00
Alexey Bataev bbd5c55c66 Revert "[OPENMP] Delayed diagnostics for VLA support."
This reverts commit r354679 to fix the problem with the Windows
buildbots

llvm-svn: 354680
2019-02-22 17:16:50 +00:00
Alexey Bataev b09bcf8efd [OPENMP] Delayed diagnostics for VLA support.
Generalized processing of the deferred diagnostics for OpenMP/CUDA code.

llvm-svn: 354679
2019-02-22 16:49:13 +00:00
Alexey Bataev 3167b3035e [CUDA]Delayed diagnostics for the asm instructions.
Adapted targetDiag for the CUDA and used for the delayed diagnostics in
asm constructs. Works for both host and device compilation sides.

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

llvm-svn: 354671
2019-02-22 14:42:48 +00:00
Alexey Bataev 12a21e4b69 Revert "[CUDA]Delayed diagnostics for the asm instructions."
This reverts commit r354593 to fix the problem with the crash on
windows.

llvm-svn: 354596
2019-02-21 16:40:21 +00:00
Alexey Bataev 16d3e1a4d2 [CUDA]Delayed diagnostics for the asm instructions.
Summary:
Adapted targetDiag for the CUDA and used for the delayed diagnostics in
asm constructs. Works for both host and device compilation sides.

Reviewers: tra, jlebar

Subscribers: jdoerfert, cfe-commits

Tags: #clang

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

llvm-svn: 354593
2019-02-21 15:51:30 +00:00
Eric Liu 206740e756 [CodeComplete] Collect visited contexts when scope specifier is invalid.
Summary:
This will allow completion consumers to guess the specified scope by
putting together scopes in the context with the specified scope (e.g. when the
specified namespace is not imported yet).

Reviewers: ilya-biryukov

Subscribers: jdoerfert, cfe-commits

Tags: #clang

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

llvm-svn: 354570
2019-02-21 11:22:58 +00:00
Artem Dergachev c333d77563 [attributes] Add an attribute for server routines in Mach kernel and extensions.
The new __attribute__ ((mig_server_routine)) is going to be used for annotating
Mach Interface Generator (MIG) callback functions as such, so that additional
static analysis could be applied to their implementations. It can also be
applied to regular functions behavior of which is supposed to be identical to
that of a MIG server routine.

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

llvm-svn: 354530
2019-02-21 00:01:02 +00:00
Alexey Bataev 7feae05858 [OPENMP] Use targetDiag for diagnostics of unsupported exceptions, NFC.
llvm-svn: 354509
2019-02-20 19:37:17 +00:00
Alexey Bataev 5c96c1c5aa [OPENMP] Delay emission of the asm target-specific error messages.
Summary:
Added the ability to emit target-specific builtin assembler error
messages only in case if the function is really is going to be emitted
for the device.

Reviewers: rjmccall

Subscribers: guansong, jdoerfert, cfe-commits

Tags: #clang

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

llvm-svn: 354486
2019-02-20 17:42:57 +00:00
Michael Kruse 4304e9d143 [OpenMP 5.0] Parsing/sema support for map clause with mapper modifier.
This patch implements the parsing and sema support for OpenMP map
clauses with potential user-defined mapper attached. User defined mapper
is a new feature in OpenMP 5.0. A map clause can have an explicit or
implicit associated mapper, which instructs the compiler to generate
extra data mapping. An example is shown below:

    struct S { int len; int *d; };
    #pragma omp declare mapper(id: struct S s) map(s, s.d[0:s.len])
    struct S ss;
    #pragma omp target map(mapper(id) tofrom: ss) // use the mapper with name 'id' to map ss

Contributed-by: Lingda Li <lildmh@gmail.com>

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

llvm-svn: 354347
2019-02-19 16:38:20 +00:00
Erik Pilkington eac7c3ffaf [Sema] Diagnose floating point conversions based on target semantics
...instead of just comparing rank. Also, fix a bad warning about
_Float16, since its declared out of order in BuiltinTypes.def,
meaning comparing rank using BuiltinType::getKind() is incorrect.

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

llvm-svn: 354190
2019-02-16 01:11:47 +00:00
Richard Smith afcfb6bc3a Fix implementation of [temp.local]p4.
When a template-name is looked up, we need to give injected-class-name
declarations of class templates special treatment, as they denote a
template rather than a type.

Previously we achieved this by applying a filter to the lookup results
after completing name lookup, but that is incorrect in various ways, not
least of which is that it lost all information about access and how
members were named, and the filtering caused us to generally lose
all ambiguity errors between templates and non-templates.

We now preserve the lookup results exactly, and the few places that need
to map from a declaration found by name lookup into a declaration of a
template do so explicitly. Deduplication of repeated lookup results of
the same injected-class-name declaration is done by name lookup instead
of after the fact.

This reinstates r354091, which was previously reverted in r354097
because it exposed bugs in lldb and compiler-rt. Those bugs were fixed
in r354173 and r354174 respectively.

llvm-svn: 354176
2019-02-15 21:53:07 +00:00
Anastasia Stulova 2c4730ded8 [OpenCL][PR40707] Allow OpenCL C types in C++ mode.
Allow all OpenCL types to be parsed in C++ mode.

llvm-svn: 354121
2019-02-15 12:07:57 +00:00
Francis Visoiu Mistrih 0650f897a4 Revert "Fix implementation of [temp.local]p4."
This reverts commit 40bd10b770.

This seems to now emit an error when building the sanitizer tests:
http://green.lab.llvm.org/green/job/clang-stage1-configure-RA/53965/consoleFull.

llvm-svn: 354097
2019-02-15 03:06:15 +00:00
Richard Smith 40bd10b770 Fix implementation of [temp.local]p4.
When a template-name is looked up, we need to give injected-class-name
declarations of class templates special treatment, as they denote a
template rather than a type.

Previously we achieved this by applying a filter to the lookup results
after completing name lookup, but that is incorrect in various ways, not
least of which is that it lost all information about access and how
members were named, and the filtering caused us to generally lose
all ambiguity errors between templates and non-templates.

We now preserve the lookup results exactly, and the few places that need
to map from a declaration found by name lookup into a declaration of a
template do so explicitly. Deduplication of repeated lookup results of
the same injected-class-name declaration is done by name lookup instead
of after the fact.

llvm-svn: 354091
2019-02-15 00:29:04 +00:00
Richard Smith a6e8d5e554 PR40642: Fix determination of whether the final statement of a statement
expression is a discarded-value expression.

Summary:
We used to get this wrong in three ways:

1) During parsing, an expression-statement followed by the }) ending a
   statement expression was always treated as producing the value of the
   statement expression. That's wrong for ({ if (1) expr; })
2) During template instantiation, various kinds of statement (most
   statements not appearing directly in a compound-statement) were not
   treated as discarded-value expressions, resulting in missing volatile
   loads (etc).
3) In all contexts, an expression-statement with attributes was not
   treated as producing the value of the statement expression, eg
   ({ [[attr]] expr; }).

Also fix incorrect enforcement of OpenMP rule that directives can "only
be placed in the program at a position where ignoring or deleting the
directive would result in a program with correct syntax". In particular,
a label (be it goto, case, or default) should not affect whether
directives are permitted.

Reviewers: aaron.ballman, rjmccall

Subscribers: cfe-commits

Tags: #clang

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

llvm-svn: 354090
2019-02-15 00:27:53 +00:00
Erik Pilkington d5b017d601 [Sema] Fix-up a -Wfloat-conversion diagnostic
We were warning on valid ObjC property reference exprs, and passing
in the wrong arguments to DiagnoseFloatingImpCast (leading to a badly
worded diagnostic).

rdar://47644670

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

llvm-svn: 354074
2019-02-14 22:48:01 +00:00
Bruno Ricci c39f8dfa73 [Sema] Fix a regression introduced in "[AST][Sema] Remove CallExpr::setNumArgs"
D54902 removed CallExpr::setNumArgs in preparation of tail-allocating the
arguments of CallExpr. It did this by allocating storage for
max(number of arguments, number of parameters in the prototype). The
temporarily nulled arguments however causes issues in BuildResolvedCallExpr
when typo correction is done just after the creation of the call expression.

This was unfortunately missed by the tests /:

To fix this, delay setting the number of arguments to
max(number of arguments, number of parameters in the prototype) until we are
ready for it. It would be nice to have this encapsulated in CallExpr but this
is the best I can come up with under the constraint that we cannot add
anything the CallExpr.

Fixes PR40286.

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

Reviewed By: aaron.ballman

llvm-svn: 354035
2019-02-14 15:43:17 +00:00
Clement Courbet 8c3343dfd5 [Builtins] Treat `bcmp` as a builtin.
Summary:
This makes it consistent with `memcmp` and `__builtin_bcmp`.

Also see the discussion in https://reviews.llvm.org/D56593.

Reviewers: jyknight

Subscribers: kristina, cfe-commits

Tags: #clang

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

llvm-svn: 354023
2019-02-14 12:00:34 +00:00
Robert Widmann 04306d62a0 Restore Check for Unreachable Exit Block in -Winfinite-recursion
Summary:
When this was rewritten in D43737, the logic changed to better explore infinite loops. The check for a reachable exit block was deleted which accidentally introduced false positives in case the exit node was unreachable.

We were testing for cases like this, but @steven_wu provided an additional test case that I've included in the regression tests for this patch.

Reviewers: steven_wu, rtrieu

Reviewed By: steven_wu, rtrieu

Subscribers: cfe-commits, steven_wu

Tags: #clang

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

llvm-svn: 353984
2019-02-13 22:22:23 +00:00
Erik Pilkington 81d3f45137 [Sema] Delay checking whether objc_designated_initializer is being applied to an init method
This fixes a regression that was caused by r335084, which reversed
the order that attributes are applied. objc_method_family can change
whether a method is an init method, so the order that these
attributes are applied matters. The commit fixes this by delaying the
init check until after all attributes have been applied.

rdar://47829358

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

llvm-svn: 353976
2019-02-13 20:32:37 +00:00
Ilya Biryukov 6597fdd508 [Sema] Fix a crash in access checking for deduction guides
Summary: See the added test for a repro.

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: cfe-commits

Tags: #clang

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

llvm-svn: 353840
2019-02-12 14:21:44 +00:00
Aaron Ballman ce667f6df9 Renaming yet another diagnostic to not conflict; NFC.
llvm-svn: 353839
2019-02-12 13:19:02 +00:00
Aaron Ballman 76126c01b0 Renaming this diagnostic to not conflict with another; NFC.
Amends r353837 which renamed the diagnostics to conflict.

llvm-svn: 353838
2019-02-12 13:13:35 +00:00
Aaron Ballman 52c9ad2001 Fixing a typo; NFC.
llvm-svn: 353837
2019-02-12 13:04:11 +00:00
Erik Pilkington e3cd735ea6 Add a new attribute, fortify_stdlib
This attribute applies to declarations of C stdlib functions
(sprintf, memcpy...) that have known fortified variants
(__sprintf_chk, __memcpy_chk, ...). When applied, clang will emit
calls to the fortified variant functions instead of calls to the
defaults.

In GCC, this is done by adding gnu_inline-style wrapper functions,
but that doesn't work for us for variadic functions because we don't
support __builtin_va_arg_pack (and have no intention to).

This attribute takes two arguments, the first is 'type' argument
passed through to __builtin_object_size, and the second is a flag
argument that gets passed through to the variadic checking variants.

rdar://47905754

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

llvm-svn: 353765
2019-02-11 23:21:39 +00:00
Eli Friedman 88fccbdea7 [Sema] Mark GNU compound literal array init as an rvalue.
Basically the same issue as string init, except it didn't really have
any visible consequences before I removed the implicit lvalue-to-rvalue
conversion from CodeGen.

While I'm here, a couple minor drive-by cleanups: IgnoreParens never
returns a ConstantExpr, and there was a potential crash with string init
involving a ChooseExpr.

The analyzer test change maybe indicates we could simplify the analyzer
code a little with this fix?  Apparently a hack was added to support
lvalues in initializers in r315750, but I'm not really familiar with the
relevant code.

Fixes regression reported in the kernel build at
https://bugs.llvm.org/show_bug.cgi?id=40430#c6 .

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

llvm-svn: 353762
2019-02-11 22:54:27 +00:00
Benjamin Kramer 756ecb8e44 Make some helper functions static. NFC.
llvm-svn: 353705
2019-02-11 14:52:15 +00:00
Eli Friedman 3bf72d7d64 [Sema] Make string literal init an rvalue.
This allows substantially simplifying the expression evaluation code,
because we don't have to special-case lvalues which are actually string
literal initialization.

This currently throws away an optimization where we would avoid creating
an array APValue for string literal initialization.  If we really want
to optimize this case, we should fix APValue so it can store simple
arrays more efficiently, like llvm::ConstantDataArray.  This shouldn't
affect the memory usage for other string literals.  (Not sure if this is
a blocker; I don't think string literal init is common enough for this
to be a serious issue, but I could be wrong.)

The change to test/CodeGenObjC/encode-test.m is a weird side-effect of
these changes: we currently don't constant-evaluate arrays in C, so the
strlen call shouldn't be folded, but lvalue string init managed to get
around that check.  I this this is fine.

Fixes https://bugs.llvm.org/show_bug.cgi?id=40430 .

llvm-svn: 353569
2019-02-08 21:18:46 +00:00
Alexey Bataev c416e64731 [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.

llvm-svn: 353542
2019-02-08 18:02:25 +00:00
Alexey Bataev 346fb4bbcd Revert "[OPENMP]Initial support for the delayed diagnostics."
This reverts commit r353540. Erroneously committed, need to fix the
message and description.

llvm-svn: 353541
2019-02-08 17:42:00 +00:00
Alexey Bataev 5e62adad0d [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.

llvm-svn: 353540
2019-02-08 17:38:09 +00:00
Akira Hatanaka 5fbdccd834 [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

llvm-svn: 353459
2019-02-07 20:21:46 +00:00
Alexey Bataev 8972133989 [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

llvm-svn: 353456
2019-02-07 19:46:42 +00:00
Anastasia Stulova e88e2b9935 [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

llvm-svn: 353431
2019-02-07 17:32:37 +00:00
Patrick Lyster 16471947f5 Test commit. NFC
llvm-svn: 353320
2019-02-06 18:18:02 +00:00
Kelvin Li 620ba6035e [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
  { ... }
}

llvm-svn: 353186
2019-02-05 16:43:00 +00:00