Commit Graph

17901 Commits

Author SHA1 Message Date
Melanie Blower e773216f46 [clang][patch] Add builtin __arithmetic_fence and option fprotect-parens
This patch adds a new clang builtin, __arithmetic_fence. The purpose of the
builtin is to provide the user fine control, at the expression level, over
floating point optimization when -ffast-math (-ffp-model=fast) is enabled.
The builtin prevents the optimizer from rearranging floating point expression
evaluation. The new option fprotect-parens has the same effect on
parenthesized expressions, forcing the optimizer to respect the parentheses.

Reviewed By: aaron.ballman, kpn

Differential Revision: https://reviews.llvm.org/D100118
2021-06-30 09:58:06 -04:00
Alexey Bataev 7fab1146e4 [OPENMP]Fix PR50929: Ignored initializer clause in user-defined reduction.
No need to try to create the default constructor for private copy, it
will be called automatically in the initializer of the declare
reduction. Fixes balance between constructors/destructors calls.

Differential Revision: https://reviews.llvm.org/D105143
2021-06-30 04:55:38 -07:00
Zhouyi Zhou 2fd75507d1 [clang] NFC: add line break at the end of if expressions
Hi,

In function TransformTemplateArgument,
would it be better to add line break at the end of "if" expressions?

I use clang-format to do the job for me.

Thanks a lot

Reviewed By: pengfei

Differential Revision: https://reviews.llvm.org/D104604
2021-06-30 19:48:24 +08:00
Stefan Pintilie 90dfd05919 [Clang] Add option to handle behaviour of vector bool/vector pixel.
Added the option `-altivec-src-compat=[mixed,gcc,xl]`. The default at this time is `mixed`.

The default behavior for clang is for all vector compares to return a scalar unless the vectors being
compared are vector bool or vector pixel. In that case the compare returns a
vector. With the gcc case all vector compares return vectors and in the xl case
all vector compares return scalars.

This patch does not change the default behavior of clang.

This option will be used in future patches to implement behaviour compatibility for the vector bool/pixel types.

Reviewed By: bmahjour

Differential Revision: https://reviews.llvm.org/D103615
2021-06-29 14:07:12 -05:00
Ole Strohm 78d309ce19 [OpenCL] Fix qualifiers check on binding references to temporaries
Fix the qualifiers check from PR49733.

Fixes: PR49733

Reviewed By: Anastasia

Differential Revision: https://reviews.llvm.org/D103962
2021-06-29 10:03:57 +01:00
David Blaikie e1b8fde1cb Revert "[Clang] Add option to handle behaviour of vector bool/vector pixel."
This reverts commit c3fe847f9d.

Tests fail in non-asserts builds because they assume named IR, by the
looks of it (testing for the "entry" label, for instance). I don't know
enough about the update_cc_test_checks.py stuff to know how to manually
fix these tests, so reverting for now.
2021-06-28 22:57:21 -07:00
Melanie Blower c27e5a2a8e Revert "[clang][patch][fpenv] Add builtin __arithmetic_fence and option fprotect-parens"
This reverts commit 4f1238e44d.
Buildbot fails on predecessor patch
2021-06-28 12:42:59 -04:00
Melanie Blower 4f1238e44d [clang][patch][fpenv] Add builtin __arithmetic_fence and option fprotect-parens
This patch adds a new clang builtin, __arithmetic_fence. The purpose of the
builtin is to provide the user fine control, at the expression level, over
floating point optimization when -ffast-math (-ffp-model=fast) is enabled.
The builtin prevents the optimizer from rearranging floating point expression
evaluation. The new option fprotect-parens has the same effect on
parenthesized expressions, forcing the optimizer to respect the parentheses.

Reviewed By: aaron.ballman, kpn

Differential Revision: https://reviews.llvm.org/D100118
2021-06-28 12:26:53 -04:00
Stefan Pintilie c3fe847f9d [Clang] Add option to handle behaviour of vector bool/vector pixel.
Added the option `-altivec-src-compat=[mixed,gcc,xl]`. The default at this time is `mixed`.

The default behavior for clang is for all vector compares to return a scalar unless the vectors being
compared are vector bool or vector pixel. In that case the compare returns a
vector. With the gcc case all vector compares return vectors and in the xl case
all vector compares return scalars.

This patch does not change the default behavior of clang.

This option will be used in future patches to implement behaviour compatibility for the vector bool/pixel types.

Reviewed By: bmahjour

Differential Revision: https://reviews.llvm.org/D103615
2021-06-28 11:16:37 -05:00
Corentin Jabot 22aa3680ea [C++20] Support for lambdas in unevaluated context
Partially implement P0315R4.

This patch allow lambda in unevaluated context.
It does not implement temp.deduct/9.
2021-06-28 09:01:56 -04:00
Matheus Izvekov ad14b5b008 [clang] Stop providing builtin overload candidate for relational function pointer comparisons
Word on the grapevine was that the committee had some discussion that
ended with unanimous agreement on eliminating relational function pointer comparisons.

We wanted to be bold and just ban all of them cold turkey.
But then we chickened out at the last second and are going for
eliminating just the spaceship overload candidate instead, for now.

See D104680 for reference.

This should be fine and "safe", because the only possible semantic change this
would cause is that overload resolution could possibly be ambiguous if
there was another viable candidate equally as good.

But to save face a little we are going to:
* Issue an "error" for three-way comparisons on function pointers.
  But all this is doing really is changing one vague error message,
  from an "invalid operands to binary expression" into an
  "ordered comparison of function pointers", which sounds more like we mean business.
* Otherwise "warn" that comparing function pointers like that is totally
  not cool (unless we are told to keep quiet about this).

Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>

Reviewed By: rsmith

Differential Revision: https://reviews.llvm.org/D104892
2021-06-26 00:08:02 +02:00
Craig Topper f225367305 [RISCV] Add vget/vset intrinsics for inserting and extracting between different lmuls.
These allow getting a whole register from a larger lmul. Or
inserting a whole register into a larger lmul register. Fractional
lmuls are not supported as they would require a vslide.

Based on this update to the intrinsic doc
https://github.com/riscv/rvv-intrinsic-doc/pull/99

Reviewed By: HsiangKai

Differential Revision: https://reviews.llvm.org/D104822
2021-06-24 18:06:36 -07:00
Martin Storsjö e5c7c171e5 [clang] Rename StringRef _lower() method calls to _insensitive()
This is mostly a mechanical change, but a testcase that contains
parts of the StringRef class (clang/test/Analysis/llvm-conventions.cpp)
isn't touched.
2021-06-25 00:22:01 +03:00
Yaxun (Sam) Liu 82e03e494f [HIP] Defer operator overloading errors
Although clang is able to defer overloading resolution
diagnostics for common functions. It does not defer
overloading resolution caused diagnostics for overloaded
operators.

This patch extends the existing deferred
diagnostic mechanism and defers a diagnostic caused
by overloaded operator.

Reviewed by: Artem Belevich

Differential Revision: https://reviews.llvm.org/D104505
2021-06-23 23:39:59 -04:00
serge-sans-paille a0d05ed848 Handle interactions between reserved identifier and user-defined suffixes
According to https://eel.is/c++draft/over.literal

> double operator""_Bq(long double);  // OK: does not use the reserved identifier _­Bq ([lex.name])
> double operator"" _Bq(long double); // ill-formed, no diagnostic required: uses the reserved identifier _­Bq ([lex.name])

Obey that rule by keeping track of the operator literal name status wrt. leading whitespace.

Fix: https://bugs.llvm.org/show_bug.cgi?id=50644

Differential Revision: https://reviews.llvm.org/D104299
2021-06-23 15:38:42 +02:00
Bruno Cardoso Lopes c9aaf34b8d [SemaCXX] Handle lack of TypeSourceInfo on special member functions in templated lambdas
During template instantiation involving templated lambdas, clang
could hit an assertion in `TemplateDeclInstantiator::SubstFunctionType`
since the functions are not associated with any `TypeSourceInfo`:

`assert(OldTInfo && "substituting function without type source info");`

This path is triggered when using templated lambdas like the one added as
a test to this patch. To fix this:

- Create `TypeSourceInfo`s for special members and make sure the template
instantiator can get through all patterns.
- Introduce a `SpecialMemberTypeInfoRebuilder` tree transform to rewrite
such member function arguments. Without this, we get errors like:

`error: only special member functions and comparison operators may be defaulted`

since `getDefaultedFunctionKind` can't properly recognize these functions
as special members as part of `SetDeclDefaulted`.

Fixes PR45828 and PR44848

Differential Revision: https://reviews.llvm.org/D88327
2021-06-22 17:26:05 -07:00
Lei Huang b259740801 [PowerPC][NFC] Clean up builtin sema checks
Cleanup sema checking for 64bit builtins or builtins that require
         specific feature support.

Reviewed By: NeHuang

Differential Revision: https://reviews.llvm.org/D104664
2021-06-22 16:06:28 -05:00
Alexandru Octavian Butiu 78d404a11d [clang][c++20] Fix false warning for unused private fields when a class has only defaulted comparison operators.
Fixes bug 50263

When "unused-private-field" flag is on if you have a struct with private
members and only defaulted comparison operators clang will warn about
unused private fields.

If you where to write the comparison operators by hand no warning is
produced.

This is a bug since defaulting a comparison operator uses all private
members .

The fix is simple, in CheckExplicitlyDefaultedFunction just clear the
list of unused private fields if the defaulted function is a comparison
function.

Differential revision: https://reviews.llvm.org/D102186
2021-06-22 18:40:16 +02:00
Erich Keane b3634d3e88 Revert "[SYCL][NFC] Ensure SYCL kernel for unique-stable-name is unqualified."
This reverts commit 5013131875.

This patch didn't end up being the solution to the problem.  It "fixed"
our issue but the actual correct solution is something else.  Reverting
as this ends up being unnecessary/extra noise.
2021-06-21 13:23:52 -07:00
Erich Keane 5013131875 [SYCL][NFC] Ensure SYCL kernel for unique-stable-name is unqualified.
Discovered in our downstream, this function that is used to get the type
of the kernel parameter type needs to be unqualified, otherwise when our
downstream uses this function in a slightly different way, the kernel
types no longer match.
2021-06-21 12:51:23 -07:00
Anton Zabaznov a427390558 [OpenCL] Add support of __opencl_c_images feature macro
Reviewed By: svenvh

Differential Revision: https://reviews.llvm.org/D103911
2021-06-21 18:24:07 +03:00
Bradley Smith 325b670794 [Sema][SVE] Properly match builtin ID when using aux target
Differential Revision: https://reviews.llvm.org/D104539
2021-06-21 12:52:18 +01:00
Zhouyi Zhou 735ad67a4c [clang] NFC: adjust indentation of statements with more than one lines
Hi,

I think it will be more beautiful to adjust indentation of statements with more than one lines.

In function TreeTransform<Derived>::TransformDependentScopeDeclRefExpr
the second line of statement
NestedNameSpecifierLoc QualifierLoc \newline = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc());
is no more indent than the first line

There is a similar case in function TreeTransform<Derived>::TransformUnresolvedMemberExpr

Also I use clang-format to fix above functions

Thanks alot

Reviewed By: pengfei

Differential Revision: https://reviews.llvm.org/D104145
2021-06-21 10:17:10 +08:00
Matheus Izvekov ced6b204d1 [clang] Implement P2266 Simpler implicit move
This Implements [[http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p2266r1.html|P2266 Simpler implicit move]].

Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>

Reviewed By: Quuxplusone

Differential Revision: https://reviews.llvm.org/D99005
2021-06-18 17:08:59 +02:00
Matheus Izvekov 7ddd15cd5d [clang] Exclude function pointers on DefaultedComparisonAnalyzer
This implements a more comprehensive fix than was done at D95409.
Instead of excluding just function pointer subobjects, we also
exclude any user-defined function pointer conversion operators.

Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>

Reviewed By: rsmith

Differential Revision: https://reviews.llvm.org/D103855
2021-06-18 13:07:47 +02:00
eahcmrh fc6ec9b98c [Sema] Fix for PR50741
Fixed crash when doing pointer math on a void pointer.

Also, reworked test to use -verify rather than FileCheck.

Reviewed By: erichkeane

Differential Revision: https://reviews.llvm.org/D104424
2021-06-17 16:16:59 +02:00
Matheus Izvekov b88eb855b5 [clang] use correct builtin type for defaulted comparison analyzer
Fixes PR50591.

When analyzing classes with members which have user-defined conversion
operators to builtin types, the defaulted comparison analyzer was
picking the member type instead of the type for the builtin operator
which was selected as the best match.

This could either result in wrong comparison category being selected,
or a crash when runtime checks are enabled.

Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>

Reviewed By: rsmith

Differential Revision: https://reviews.llvm.org/D103760
2021-06-17 02:08:31 +02:00
Matheus Izvekov 12c90e2e25 [clang] NRVO: Improvements and handling of more cases.
This expands NRVO propagation for more cases:

Parse analysis improvement:
* Lambdas and Blocks with dependent return type can have their variables
  marked as NRVO Candidates.

Variable instantiation improvements:
* Fixes crash when instantiating NRVO variables in Blocks.
* Functions, Lambdas, and Blocks which have auto return type have their
  variables' NRVO status propagated. For Blocks with non-auto return type,
  as a limitation, this propagation does not consider the actual return
  type.

This also implements exclusion of VarDecls which are references to
dependent types.

Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>

Reviewed By: Quuxplusone

Differential Revision: https://reviews.llvm.org/D99696
2021-06-17 01:56:38 +02:00
Alexey Bataev 45ae766e78 [OPENMP]Fix PR50699: capture locals in combine directrives for aligned clause.
Need to capture locals in aligned clauses for the combined directives to
be fix the crash in the codegen.

Differential Revision: https://reviews.llvm.org/D104258
2021-06-15 04:58:02 -07:00
Yaxun (Sam) Liu 79f9cfbc21 Do not merge LocalInstantiationScope for template specialization
A lambda in a function template may be recursively instantiated. The recursive
lambda will cause a lambda function instantiated multiple times, one inside another.
The inner LocalInstantiationScope should not be marked as MergeWithParentScope
since it already has references to locals properly substituted, otherwise it causes
assertion due to the check for duplicate locals in merged LocalInstantiationScope.

Reviewed by: Richard Smith

Differential Revision: https://reviews.llvm.org/D98068
2021-06-14 23:28:04 -04:00
Alexey Bataev 4e15560879 [OPENMP][C++20]Add support for CXXRewrittenBinaryOperator in ranged for loops.
Added support for CXXRewrittenBinaryOperator as a condition in ranged
for loops. This is a new kind of expression, need to extend support for
  C++20 constructs.
It fixes PR49970: range-based for compilation fails for libstdc++ vector
with -std=c++20.

Differential Revision: https://reviews.llvm.org/D104240
2021-06-14 11:50:27 -07:00
Hans Wennborg c60dd3b262 Revert "[clang] NRVO: Improvements and handling of more cases."
This change caused build errors related to move-only __block variables,
see discussion on https://reviews.llvm.org/D99696

> This expands NRVO propagation for more cases:
>
> Parse analysis improvement:
> * Lambdas and Blocks with dependent return type can have their variables
>   marked as NRVO Candidates.
>
> Variable instantiation improvements:
> * Fixes crash when instantiating NRVO variables in Blocks.
> * Functions, Lambdas, and Blocks which have auto return type have their
>   variables' NRVO status propagated. For Blocks with non-auto return type,
>   as a limitation, this propagation does not consider the actual return
>   type.
>
> This also implements exclusion of VarDecls which are references to
> dependent types.
>
> Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>
>
> Reviewed By: Quuxplusone
>
> Differential Revision: https://reviews.llvm.org/D99696

This also reverts the follow-on change which was hard to tease apart
form the one above:

> "[clang] Implement P2266 Simpler implicit move"
>
> This Implements [[http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p2266r1.html|P2266 Simpler implicit move]].
>
> Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>
>
> Reviewed By: Quuxplusone
>
> Differential Revision: https://reviews.llvm.org/D99005

This reverts commits 1e50c3d785 and
bf20631782.
2021-06-14 16:46:58 +02:00
Stephan Bergmann b5b9489b24 Only consider built-in compound assignment operators for -Wunused-but-set-*
At least LibreOffice has, for mainly historic reasons that would be hard to
change now, a class Any with an overloaded operator >>= that semantically does
not assign to the LHS but rather extracts into the (by-reference) RHS.  Which
thus caused false positive -Wunused-but-set-parameter and
-Wunused-but-set-variable after those have been introduced recently.

This change is more conservative about the assumed semantics of overloaded
operators, excluding compound assignment operators but keeping plain operator =
ones.  At least for LibreOffice, that strikes a good balance of not producing
false positives but still finding lots of true ones.

(The change to the BinaryOperator case in MaybeDecrementCount is necessary
because e.g. the template f4 test code in warn-unused-but-set-variables-cpp.cpp
turns the += into a BinaryOperator.)

Differential Revision: https://reviews.llvm.org/D103949
2021-06-14 08:04:03 +02:00
Matheus Izvekov bf20631782 [clang] Implement P2266 Simpler implicit move
This Implements [[http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p2266r1.html|P2266 Simpler implicit move]].

Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>

Reviewed By: Quuxplusone

Differential Revision: https://reviews.llvm.org/D99005
2021-06-13 12:10:56 +02:00
Matheus Izvekov 1e50c3d785 [clang] NRVO: Improvements and handling of more cases.
This expands NRVO propagation for more cases:

Parse analysis improvement:
* Lambdas and Blocks with dependent return type can have their variables
  marked as NRVO Candidates.

Variable instantiation improvements:
* Fixes crash when instantiating NRVO variables in Blocks.
* Functions, Lambdas, and Blocks which have auto return type have their
  variables' NRVO status propagated. For Blocks with non-auto return type,
  as a limitation, this propagation does not consider the actual return
  type.

This also implements exclusion of VarDecls which are references to
dependent types.

Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>

Reviewed By: Quuxplusone

Differential Revision: https://reviews.llvm.org/D99696
2021-06-12 16:43:32 +02:00
Alex Lorenz 22dea69231 [clang][ObjC] allow the use of NSAttributedString * argument type with format attribute
This is useful for APIs that want to accept an attributed NSString as their format string

rdar://79163229
2021-06-11 13:24:32 -07:00
eahcmrh ce44fe199b [Sema] Address-space sensitive check for unbounded arrays (v2)
Check applied to unbounded (incomplete) arrays and pointers to spot
cases where the computed address is beyond the largest possible
addressable extent of the array, based on the address space in which the
array is delcared, or which the pointer refers to.

Check helps to avoid cases of nonsense pointer math and array indexing
which could lead to linker failures or runtime exceptions.  Of
particular interest when building for embedded systems with small
address spaces.

This is version 2 of this patch -- version 1 had some testing issues
due to a sign error in existing code.  That error is corrected and
lit test for this chagne is extended to verify the fix.

Originally reviewed/accepted by: aaron.ballman
Original revision: https://reviews.llvm.org/D86796

Reviewed By: aaron.ballman, ebevhan

Differential Revision: https://reviews.llvm.org/D88174
2021-06-11 19:34:03 +02:00
eahcmrh 7e9822cc55 Revert "[Sema] Address-space sensitive check for unbounded arrays (v2)"
This reverts commit e42a347b74.
2021-06-11 17:44:06 +02:00
eahcmrh e42a347b74 [Sema] Address-space sensitive check for unbounded arrays (v2)
Check applied to unbounded (incomplete) arrays and pointers to spot
cases where the computed address is beyond the largest possible
addressable extent of the array, based on the address space in which the
array is delcared, or which the pointer refers to.

Check helps to avoid cases of nonsense pointer math and array indexing
which could lead to linker failures or runtime exceptions.  Of
particular interest when building for embedded systems with small
address spaces.

This is version 2 of this patch -- version 1 had some testing issues
due to a sign error in existing code.  That error is corrected and
lit test for this chagne is extended to verify the fix.

Originally reviewed/accepted by: aaron.ballman
Original revision: https://reviews.llvm.org/D86796

Reviewed By: aaron.ballman, ebevhan

Differential Revision: https://reviews.llvm.org/D88174
2021-06-11 17:36:16 +02:00
Zahira Ammarguellat 150f7cedfb Referencing a static function defined in an opnemp clause, is
generating an erroneous warning.

See here: https://godbolt.org/z/ajKPc36M7
2021-06-11 06:56:01 -07:00
Simon Pilgrim 61cdaf66fe [ADT] Remove APInt/APSInt toString() std::string variants
<string> is currently the highest impact header in a clang+llvm build:

https://commondatastorage.googleapis.com/chromium-browser-clang/llvm-include-analysis.html

One of the most common places this is being included is the APInt.h header, which needs it for an old toString() implementation that returns std::string - an inefficient method compared to the SmallString versions that it actually wraps.

This patch replaces these APInt/APSInt methods with a pair of llvm::toString() helpers inside StringExtras.h, adjusts users accordingly and removes the <string> from APInt.h - I was hoping that more of these users could be converted to use the SmallString methods, but it appears that most end up creating a std::string anyhow. I avoided trying to use the raw_ostream << operators as well as I didn't want to lose having the integer radix explicit in the code.

Differential Revision: https://reviews.llvm.org/D103888
2021-06-11 13:19:15 +01:00
Nathan Sidwell 691ba0f8ac [clang][NFC] Avoid assignment in condition
Refactor to avoid assignment inside condition by using 'if
(init-decl)'.  Also remove some unnecessary braces on a separate
if-nest.

Differential Revision: https://reviews.llvm.org/D104039
2021-06-11 03:53:55 -07:00
Ole Strohm b102e6880a [OpenCL] Fix overloading resolution of addrspace constructors
This fixes the prioritization of address spaces when choosing a
constructor, stopping them from being considered equally good,
which made the construction of types that could be constructed
by more than one of the constructors.

It does this by preferring the most specific address space,
which is decided by seeing if one of the address spaces is
a superset of the other, and preferring the other.

Fixes: PR50329

Reviewed By: Anastasia

Differential Revision: https://reviews.llvm.org/D102850
2021-06-11 11:12:33 +01:00
Arthur Eubanks 85ca7e424f Revert "[clang] NRVO: Improvements and handling of more cases."
This reverts commit 667fbcdd0b.

Causes crashes on a stage 2 build on Windows.
2021-06-10 20:37:01 -07:00
Arthur Eubanks db26615aa6 Revert "[clang] Implement P2266 Simpler implicit move"
This reverts commit cbd0054b9e.
2021-06-10 19:54:50 -07:00
Matheus Izvekov cbd0054b9e [clang] Implement P2266 Simpler implicit move
This Implements [[http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p2266r1.html|P2266 Simpler implicit move]].

Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>

Reviewed By: Quuxplusone

Differential Revision: https://reviews.llvm.org/D99005
2021-06-11 00:56:06 +02:00
Matheus Izvekov 667fbcdd0b [clang] NRVO: Improvements and handling of more cases.
This expands NRVO propagation for more cases:

Parse analysis improvement:
* Lambdas and Blocks with dependent return type can have their variables
  marked as NRVO Candidates.

Variable instantiation improvements:
* Fixes crash when instantiating NRVO variables in Blocks.
* Functions, Lambdas, and Blocks which have auto return type have their
  variables' NRVO status propagated. For Blocks with non-auto return type,
  as a limitation, this propagation does not consider the actual return
  type.

This also implements exclusion of VarDecls which are references to
dependent types.

Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>

Reviewed By: Quuxplusone

Differential Revision: https://reviews.llvm.org/D99696
2021-06-10 23:02:51 +02:00
Michael Kruse a22236120f [OpenMP] Implement '#pragma omp unroll'.
Implementation of the unroll directive introduced in OpenMP 5.1. Follows the approach from D76342 for the tile directive (i.e. AST-based, not using the OpenMPIRBuilder). Tries to use `llvm.loop.unroll.*` metadata where possible, but has to fall back to an AST representation of the outer loop if the partially unrolled generated loop is associated with another directive (because it needs to compute the number of iterations).

Reviewed By: ABataev

Differential Revision: https://reviews.llvm.org/D99459
2021-06-10 14:30:17 -05:00
Adam Czachorowski 49eba8bf17 [clang] Do not crash when ArgTy is null in CheckArgAlignment
This can happen around RecoveryExpr.

Differential Revision: https://reviews.llvm.org/D103825
2021-06-10 16:54:15 +02:00
Aaron Ballman c92f505346 Correct the behavior of va_arg checking in C++
Clang checks whether the type given to va_arg will automatically cause
undefined behavior, but this check was issuing false positives for
enumerations in C++. The issue turned out to be because
typesAreCompatible() in C++ checks whether the types are *the same*, so
this uses custom logic if the type compatibility check fails.

This issue was found by a user on code like:

typedef enum {
  CURLINFO_NONE,
  CURLINFO_EFFECTIVE_URL,
  CURLINFO_LASTONE = 60
} CURLINFO;

...

__builtin_va_arg(list, CURLINFO); // false positive warning

Given that C++ defers to C for the rules around va_arg, the behavior
should be the same in both C and C++ and not diagnose because int and
CURLINFO are "compatible enough" types for va_arg.
2021-06-09 07:18:32 -04:00
Matheus Izvekov c25572bf29 [clang] NFC: rename SK_CastDerivedToBaseRValue to SK_CastDerivedToBasePRValue
This is a follow up to the "rvalue-to-prvalue" rename at D103720.

Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>

Depends on D103720

Reviewed By: rsmith

Differential Revision: https://reviews.llvm.org/D103933
2021-06-09 12:38:59 +02:00
Matheus Izvekov aef5d8fdc7 [clang] NFC: Rename rvalue to prvalue
This renames the expression value categories from rvalue to prvalue,
keeping nomenclature consistent with C++11 onwards.

C++ has the most complicated taxonomy here, and every other language
only uses a subset of it, so it's less confusing to use the C++ names
consistently, and mentally remap to the C names when working on that
context (prvalue -> rvalue, no xvalues, etc).

Renames:
* VK_RValue -> VK_PRValue
* Expr::isRValue -> Expr::isPRValue
* SK_QualificationConversionRValue -> SK_QualificationConversionPRValue
* JSON AST Dumper Expression nodes value category: "rvalue" -> "prvalue"

Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>

Reviewed By: rsmith

Differential Revision: https://reviews.llvm.org/D103720
2021-06-09 12:27:10 +02:00
Nathan Sidwell b2d0c16e91 [clang] p1099 using enum part 2
This implements the 'using enum maybe-qualified-enum-tag ;' part of
1099. It introduces a new 'UsingEnumDecl', subclassed from
'BaseUsingDecl'. Much of the diff is the boilerplate needed to get the
new class set up.

There is one case where we accept ill-formed, but I believe this is
merely an extended case of an existing bug, so consider it
orthogonal. AFAICT in class-scope the c++20 rule is that no 2 using
decls can bring in the same target decl ([namespace.udecl]/8). But we
already accept:

struct A { enum { a }; };
struct B : A { using A::a; };
struct C : B { using A::a;
using B::a; }; // same enumerator

this patch permits mixtures of 'using enum Bob;' and 'using Bob::member;' in the same way.

Differential Revision: https://reviews.llvm.org/D102241
2021-06-08 11:11:46 -07:00
Nathan Sidwell 012898b92c [clang] p1099 using enum part 1
This adds support for p1099's 'using SCOPED_ENUM::MEMBER;'
functionality, bringing a member of an enumerator into the current
scope. The novel feature here, is that there need not be a class
hierarchical relationship between the current scope and the scope of
the SCOPED_ENUM. That's a new thing, the closest equivalent is a
typedef or alias declaration. But this means that
Sema::CheckUsingDeclQualifier needs adjustment. (a) one can't call it
until one knows the set of decls that are being referenced -- if
exactly one is an enumerator, we're in the new territory. Thus it
needs calling later in some cases. Also (b) there are two ways we hold
the set of such decls. During parsing (or instantiating a dependent
scope) we have a lookup result, and during instantiation we have a set
of shadow decls. Thus two optional arguments, at most one of which
should be non-null.

Differential Revision: https://reviews.llvm.org/D100276
2021-06-08 04:40:42 -07:00
Nathan Sidwell ade4662c44 [clang] Remove inadvertent commit
Oops, missed this pattern in my .gitignore.  Sorry.

Differential Revision: https://reviews.llvm.org/D101777
2021-06-07 07:17:08 -07:00
Nathan Sidwell 9e43e7ec11 [clang] Fix using-enum breakage
This fixes a build breakage.  I managed to attach this particular
change to the wrong diff in the stack when rebasing.  And flubbed
testing :(

Differential Revision: https://reviews.llvm.org/D101777
2021-06-07 07:12:34 -07:00
Nathan Sidwell 84ab315574 [clang][NFC] Break out enum completion from other type context completion
This prepatch for using-enum breaks out the enum completion that that
will need from the existing scope completion logic.

Differential Revision: https://reviews.llvm.org/D102239
2021-06-07 06:29:29 -07:00
Nathan Sidwell ddda05add5 [clang][NFC] Break out BaseUsingDecl from UsingDecl
This is a pre-patch for adding using-enum support.  It breaks out
the shadow decl handling of UsingDecl to a new intermediate base
class, BaseUsingDecl, altering the decl hierarchy to

def BaseUsing : DeclNode<Named, "", 1>;
  def Using : DeclNode<BaseUsing>;
def UsingPack : DeclNode<Named>;
def UsingShadow : DeclNode<Named>;
  def ConstructorUsingShadow : DeclNode<UsingShadow>;

Differential Revision: https://reviews.llvm.org/D101777
2021-06-07 06:29:28 -07:00
Adam Czachorowski 721476e6b2 [clang] Fix a crash during code completion
During code completion, lookupInDeclContext() calls
CodeCompletionDeclConsumer::FoundDecl(),which can mutate StoredDeclsMap,
over which lookupInDeclContext() iterates. This can lead to invalidation
of iterators and an assert()-crash.

Example code where this happens:
 #include <list>
 int main() {
   std::list<int>;
   std::^
 }
with code completion on ^ with -std=c++20.

I do not have a repro case that does not need standard library.

This fix stores pointers to NamedDecls in a temporary vector, then
visits them outside of the main loop, when StoredDeclsMap iterators are
gone.

Differential Revision: https://reviews.llvm.org/D103472
2021-06-07 13:29:58 +02:00
Stuart Brady 9b14670f3c [OpenCL] Add const attribute to ctz() builtins
Reviewed By: svenvh

Differential Revision: https://reviews.llvm.org/D97725
2021-06-07 11:41:52 +01:00
Ole Strohm 438cf5577e [OpenCL] Fix missing addrspace on implicit move assignment operator
This fixes the missing address space on `this` in the implicit move
assignment operator.
The function called here is an abstraction around the lines that have
been removed which also sets the address space correctly.
This is copied from CopyConstructor, CopyAssignment and MoveConstructor,
all of which use this function, and now MoveAssignment does too.

Fixes: PR50259

Reviewed By: svenvh

Differential Revision: https://reviews.llvm.org/D103252
2021-06-07 09:37:53 +01:00
Michael Kruse c41a8fbfbb [Clang][OpenMP] Refactor checking for mutually exclusive clauses. NFC.
Multiple clauses are mutually exclusive. This patch refactors the functions that check for pairs of mutually exclusive clauses into a generalized function which also also accepts a list of clause types if which at most one can appear.

NFC patch extracted out of D99459 by request.

Reviewed By: ABataev

Differential Revision: https://reviews.llvm.org/D103666
2021-06-06 09:49:46 -05:00
Aaron Ballman ca68f3bc48 Fix a diagnoses-valid bug with using declarations
The following was found by a customer and is accepted by the other primary
C++ compilers, but fails to compile in Clang:

namespace sss {
double foo(int, double);
template <class T>
T foo(T); // note: target of using declaration
}  // namespace sss

namespace oad {
void foo();
}

namespace oad {
using ::sss::foo;
}

namespace sss {
using oad::foo; // note: using declaration
}

namespace sss {
double foo(int, double) { return 0; }
template <class T>
T foo(T t) { // error: declaration conflicts with target of using
  return t;
}
}  // namespace sss

I believe the issue is that MergeFunctionDecl() was calling
checkUsingShadowRedecl() but only considering a FunctionDecl as a
possible shadow and not FunctionTemplateDecl. The changes in this patch
largely mirror how variable declarations were being handled by also
catching FunctionTemplateDecl.
2021-06-04 15:52:07 -04:00
Alexey Bataev 827b5c2154 [OPENMP]Fix PR49790: Constexpr values not handled in `omp declare mapper` clause.
Patch allows using of constexpr vars evaluatable to constant calue to be
used in declare mapper construct.

Differential Revision: https://reviews.llvm.org/D103642
2021-06-04 07:32:14 -07:00
ShihPo Hung fcf8827a98 [Sema][RISCV][SVE] Allow ?: to select Typedef BuiltinType in C
This patch solves an error such as:
  incompatible operand types ('vbool4_t' (aka '__rvv_bool4_t') and '__rvv_bool4_t')
when one of the value is a TypedefType of the other value in ?:.

Reviewed By: rjmccall

Differential Revision: https://reviews.llvm.org/D103603
2021-06-04 15:33:14 +08:00
Michael Kruse 07a6beb402 [Clang][OpenMP] Emit dependent PreInits before directive.
The PreInits of a loop transformation (atm moment only tile) include the computation of the trip count. The trip count is needed by any loop-associated directives that consumes the transformation-generated loop. Hence, we must ensure that the PreInits of consumed loop transformations are emitted with the consuming directive.

This is done by addinging the inner loop transformation's PreInits to the outer loop-directive's PreInits. The outer loop-directive will consume the de-sugared AST such that the inner PreInits are not emitted twice. The PreInits of a loop transformation are still emitted directly if its generated loop(s) are not associated with another loop-associated directive.

Reviewed By: ABataev

Differential Revision: https://reviews.llvm.org/D102180
2021-06-02 16:59:35 -05:00
Erich Keane 8beaca8c14 Remove unused function from a previous iteration of unique-stable-name 2021-06-02 12:15:16 -07:00
Erik Pilkington 369c648399 [clang] Implement the using_if_exists attribute
This attribute applies to a using declaration, and permits importing a
declaration without knowing if that declaration exists. This is useful
for libc++ C wrapper headers that re-export declarations in std::, in
cases where the base C library doesn't provide all declarations.

This attribute was proposed in http://lists.llvm.org/pipermail/cfe-dev/2020-June/066038.html.

rdar://69313357

Differential Revision: https://reviews.llvm.org/D90188
2021-06-02 10:30:24 -04:00
Yaxun (Sam) Liu 04caa7c3e0 [CUDA][HIP] Promote const variables to constant
Recently we added diagnosing ODR-use of host variables
in device functions, which includes ODR-use of const
host variables since they are not really emitted on
device side. This caused regressions since we used
to allow ODR-use of const host variables in device
functions.

This patch allows ODR-use of const variables in device
functions if the const variables can be statically initialized
and have an empty dtor. Such variables are marked with
implicit constant attrs and emitted on device side. This is
in line with what clang does for constexpr variables.

Reviewed by: Artem Belevich

Differential Revision: https://reviews.llvm.org/D103108
2021-06-01 21:28:41 -04:00
Michael Benfield cf49cae278 [Clang] -Wunused-but-set-parameter and -Wunused-but-set-variable
These are intended to mimic warnings available in gcc.

Differential Revision: https://reviews.llvm.org/D100581
2021-06-01 15:38:48 -07:00
Nathan Sidwell c138f3ce5c [clang] Fix ICE with typeid & polymorphic class (pr50497)
This addresses pr50497. The argument of a typeid expression is
unevaluated, *except* when it's a polymorphic type. We handle this by
parsing as unevaluated and then transforming to evaluated if we
discover it should have been an evaluated context.

We do the same in TreeTransform<Derived>::TransformCXXTypeidExpr,
entering unevaluated context before transforming and rebuilding the
typeid. But that's incorrect and can lead us to converting to
evaluated context twice -- and hitting an assert.

During normal template instantiation we're always cloning the
expression, but during generic lambda processing we do not necessarily
AlwaysRebuild, and end up with TransformDeclRefExpr unconditionally
calling MarkDeclRefReferenced around line 10226. That triggers the
assert.

// Mark it referenced in the new context regardless.
// FIXME: this is a bit instantiation-specific.
SemaRef.MarkDeclRefReferenced(E);

This patch makes 2 changes.

a) TreeTransform<Derived>::TransformCXXTypeidExpr only enters
unevaluated context if the typeid's operand is not a polymorphic
glvalue. If it is, it keeps the same evaluation context.

b) Sema::BuildCXXTypeId is altered to only transform to evaluated, if
the current context is unevaluated.

Differential Revision: https://reviews.llvm.org/D103258
2021-06-01 12:55:29 -07:00
David Goldman 13a8aa3ee1 [clang] RecursiveASTVisitor visits ObjCPropertyRefExpr's class receiver
We now make up a TypeLoc for the class receiver to simplify visiting,
notably for indexing, availability, and clangd.

Differential Revision: https://reviews.llvm.org/D101645
2021-06-01 14:45:25 -04:00
Louis Dionne 97d234935f [clang][Parse] Add parsing support for C++ attributes on using-declarations
This is a re-application of dc67299 which was reverted in f63adf5b because
it broke the build. The issue should now be fixed.

Attribution note: The original author of this patch is Erik Pilkington.
I'm only trying to land it after rebasing.

Differential Revision: https://reviews.llvm.org/D91630
2021-06-01 08:47:50 -04:00
Ole Strohm 94b0aec0f5 [OpenCL] Fix ICE with invalid use of half
Because half is limited to the `cl_khr_fp16` extension being enabled,
`DefaultLvalueConversion` can fail when it's not enabled.
The original assumption that it will never fail is therefore wrong now.

Fixes: PR47976

Reviewed By: Anastasia

Differential Revision: https://reviews.llvm.org/D103175
2021-06-01 13:43:07 +01:00
Abbas Sabra 116179c2ee Re-commit [clang] Add support for the "abstract" contextual keyword of MSVC
https://docs.microsoft.com/en-us/cpp/extensions/abstract-cpp-component-extensions?view=msvc-160
Note: like the already supported "sealed" keyword, the "abstract"
keyword is supported by MSVC by default.

This re-commits 818338add7 with added
initialization of Parser::Ident_abstract.

Differential revision: https://reviews.llvm.org/D102517
2021-05-31 18:45:26 +02:00
Mikhail Goncharov c36ff6424f Revert "[clang] Add support for the "abstract" contextual keyword of MSVC"
This reverts commit 818338add7.

Tests fail under sanitizer: https://lab.llvm.org/buildbot/#/builders/5/builds/8150
2021-05-31 15:34:20 +02:00
Abbas Sabra 818338add7 [clang] Add support for the "abstract" contextual keyword of MSVC
https://docs.microsoft.com/en-us/cpp/extensions/abstract-cpp-component-extensions?view=msvc-160
Note: like the already supported "sealed" keyword, the "abstract"
keyword is supported by MSVC by default.

Differential revision: https://reviews.llvm.org/D102517
2021-05-31 10:44:53 +02:00
Nico Weber f63adf5b67 Revert "[clang][Parse] Add parsing support for C++ attributes on using-declarations"
This reverts commit dc672999a9.
Breaks check-clang everywhere, see https://reviews.llvm.org/D91630
2021-05-28 14:49:18 -04:00
Erik Pilkington dc672999a9 [clang][Parse] Add parsing support for C++ attributes on using-declarations
Differential Revision: https://reviews.llvm.org/D91630
2021-05-28 12:00:33 -04:00
Florian Hahn 5bccdde070
[Matrix] Move C++ matrix cast checks to TryStaticCast.
At the moment, the matrix support in CheckCXXCStyleCast (added in
D101696) breaks function-style constructor calls that take a
single matrix value, because it is treated as matrix cast.

Instead, unify the C++ matrix cast handling by moving the logic to
TryStaticCast and only handle the case where both types are matrix
types. Otherwise, fall back to the generic mis-match detection.

Suggested by @rjmccall

Reviewed By: SaurabhJha

Differential Revision: https://reviews.llvm.org/D103163
2021-05-28 13:00:28 +01:00
Tim Northover e94fada045 SwiftAsync: add Clang attribute to apply the LLVM `swiftasync` one.
Expected to be used by Swift runtime developers.
2021-05-28 12:31:12 +01:00
Erich Keane eba69b59d1 Reimplement __builtin_unique_stable_name-
The original version of this was reverted, and @rjmcall provided some
advice to architect a new solution.  This is that solution.

This implements a builtin to provide a unique name that is stable across
compilations of this TU for the purposes of implementing the library
component of the unnamed kernel feature of SYCL.  It does this by
running the Itanium mangler with a few modifications.

Because it is somewhat common to wrap non-kernel-related lambdas in
macros that aren't present on the device (such as for logging), this
uniquely generates an ID for all lambdas involved in the naming of a
kernel. It uses the lambda-mangling number to do this, except replaces
this with its own number (starting at 10000 for readabililty reasons)
for lambdas used to name a kernel.

Additionally, this implements itself as constexpr with a slight catch:
if a name would be invalidated by the use of this lambda in a later
kernel invocation, it is diagnosed as an error (see the Sema tests).

Differential Revision: https://reviews.llvm.org/D103112
2021-05-27 07:12:20 -07:00
Aaron Ballman 8edd3464af Add support for #elifdef and #elifndef
WG14 adopted N2645 and WG21 EWG has accepted P2334 in principle (still
subject to full EWG vote + CWG review + plenary vote), which add
support for #elifdef as shorthand for #elif defined and #elifndef as
shorthand for #elif !defined. This patch adds support for the new
preprocessor directives.
2021-05-27 08:57:47 -04:00
Momchil Velikov 21aa107eb7 Reland "Do not create LLVM IR `constant`s for objects with dynamic initialisation"
This relands commit 13dd65b3a1.

The original commit contained a test, which failed when compiled
for a MACH-O target.

This patch changes the test to run for x86_64-linux instead of
`%itanium_abi_triple`, to avoid having invalid syntax for MACH-O
sections. The patch itself does not care about section attribute
syntax and a x86 backend does not even need to be included in the
build.

Differential Revision: https://reviews.llvm.org/D102693
2021-05-25 15:54:40 +01:00
Marco Elver 280333021e [SanitizeCoverage] Add support for NoSanitizeCoverage function attribute
We really ought to support no_sanitize("coverage") in line with other
sanitizers. This came up again in discussions on the Linux-kernel
mailing lists, because we currently do workarounds using objtool to
remove coverage instrumentation. Since that support is only on x86, to
continue support coverage instrumentation on other architectures, we
must support selectively disabling coverage instrumentation via function
attributes.

Unfortunately, for SanitizeCoverage, it has not been implemented as a
sanitizer via fsanitize= and associated options in Sanitizers.def, but
rolls its own option fsanitize-coverage. This meant that we never got
"automatic" no_sanitize attribute support.

Implement no_sanitize attribute support by special-casing the string
"coverage" in the NoSanitizeAttr implementation. To keep the feature as
unintrusive to existing IR generation as possible, define a new negative
function attribute NoSanitizeCoverage to propagate the information
through to the instrumentation pass.

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

Reviewed By: vitalybuka, morehouse

Differential Revision: https://reviews.llvm.org/D102772
2021-05-25 12:57:14 +02:00
Logan Smith a5a3efa82a [Sema] Always search the full function scope context if a potential availability violation is encountered
This fixes both https://bugs.llvm.org/show_bug.cgi?id=50309 and https://bugs.llvm.org/show_bug.cgi?id=50310.

Previously, lambdas inside functions would mark their own bodies for later analysis when encountering a potentially unavailable decl, without taking into consideration that the entire lambda itself might be correctly guarded inside an @available check. The same applied to inner class member functions. Blocks happened to work as expected already, since Sema::getEnclosingFunction() skips through block scopes.

This patch instead simply and conservatively marks the entire outermost function scope for search, and removes some special-case logic that prevented DiagnoseUnguardedAvailabilityViolations from traversing down into lambdas and nested functions. This correctly accounts for arbitrarily nested lambdas, inner classes, and blocks that may be inside appropriate @available checks at any ancestor level. It also treats all potential availability violations inside functions consistently, without being overly sensitive to the current DeclContext, which previously caused issues where e.g. nested struct members were warned about twice.

DiagnoseUnguardedAvailabilityViolations now has more work to do in some cases, particularly in functions with many (possibly deeply) nested lambdas and classes, but the big-O is the same, and the simplicity of the approach and the fact that it fixes at least two bugs feels like a strong win.

Differential Revision: https://reviews.llvm.org/D102338
2021-05-24 21:13:30 -07:00
Nico Weber d881319cc5 Revert "Do not create LLVM IR `constant`s for objects with dynamic initialisation"
This reverts commit 13dd65b3a1.
Breaks check-clang on macOS, see https://reviews.llvm.org/D102693
2021-05-24 21:22:07 -04:00
Momchil Velikov 13dd65b3a1 Do not create LLVM IR `constant`s for objects with dynamic initialisation
When a const-qualified object has a section attribute, that
section is set to read-only and clang outputs a LLVM IR constant
for that object. This is incorrect for dynamically initialised
objects.

For example:

    int init() { return 15; }

    __attribute__((section("SA")))
    const int a = init();

a is allocated to a read-only section and is left
unintialised (zero-initialised).

This patch adds checks if an initialiser is a constant expression
and allocates objects to sections as follows:

* const-qualified objects
  - no initialiser or constant initialiser: .rodata
  - dynamic initializer: .bss
* non const-qualified objects
  - no initialiser or dynamic initialiser: .bss
  - constant initialiser: .data

(".rodata", ".data", and ".bss" names used just for explanatory
purpose)

Differential Revision: https://reviews.llvm.org/D102693
2021-05-24 22:04:15 +01:00
Anastasia Stulova 237c6924bd [OpenCL] Add clang extension for bit-fields.
Allow use of bit-fields as a clang extension
in OpenCL. The extension can be enabled using
pragma directives.

This fixes PR45339!

Differential Revision: https://reviews.llvm.org/D101843
2021-05-24 12:42:17 +01:00
Anton Zabaznov 826905787a [OpenCL] Add support of OpenCL C 3.0 __opencl_c_fp64
There already exists cl_khr_fp64 extension. So OpenCL C 3.0
and higher should use the feature, earlier versions still
use the extension. OpenCL C 3.0 API spec states that extension
will be not described in the option string if corresponding
optional functionality is not supported (see 4.2. Querying Devices).
Due to that fact the usage of features for OpenCL C 3.0 must
be as follows:

```
$ clang -Xclang -cl-ext=+cl_khr_fp64,+__opencl_c_fp64 ...

$ clang -Xclang -cl-ext=-cl_khr_fp64,-__opencl_c_fp64 ...
```

e.g. the feature and the equivalent extension (if exists)
must be set to the same values

Reviewed By: Anastasia

Differential Revision: https://reviews.llvm.org/D96524
2021-05-21 15:01:19 +03:00
Zhouyi Zhou e6ec7ab582 NFC: TreeTransform.h: make the function TransformNestedNameSpecifierLoc more beautiful
Hi,
I am new to LLVM, and I really want to get involved in LLVM community.

I guess if the following switch case of function
TransformNestedNameSpecifierLoc could possibly made more beautiful with
'break' stmt moved inside of the right brace.

I think move of 'break' stmt will not change the invoking destructor of
IdInfo.

Thanks for your effort.

I have done make check-all on x86_64-linux
Signed-off-by: Zhouyi Zhou <zhouzhouyi@gmail.com>

Reviewed By: pengfei

Differential Revision: https://reviews.llvm.org/D102577
2021-05-21 18:27:23 +08:00
Wei Wang e6b8320c0a [clang][AST] Improve AST Reader/Writer memory footprint
Reduce memory footprint of AST Reader/Writer:
1. Adjust internal data containers' element type.
2. Switch to set for deduplication of deferred diags.

Differential Revision: https://reviews.llvm.org/D101793
2021-05-20 15:34:29 -07:00
Yaxun (Sam) Liu 4cb42564ec [CUDA][HIP] Fix device variables used by host
variables emitted on both host and device side with different addresses
when ODR-used by host function should not cause device side counter-part
to be force emitted.

This fixes the regression caused by https://reviews.llvm.org/D102237

Reviewed by: Artem Belevich

Differential Revision: https://reviews.llvm.org/D102801
2021-05-20 17:04:29 -04:00
Haojian Wu 80c1adfd18 [clang] Invalidate a non-dependent-type RecordDecl when it has any dependent-type base class specifier.
This happens during the error-recovery, and it would esacpe all
dependent-type check guards in getTypeInfo/constexpr-evaluator code
paths, which lead to crashes.

Differential Revision: https://reviews.llvm.org/D102773
2021-05-20 15:33:05 +02:00
Richard Smith 2f8ac0758b PR50402: Use proper constant evaluation rules for checking constraint
satisfaction.

Previously we used the rules for constant folding in a non-constant
context, meaning that we'd incorrectly accept foldable non-constant
expressions and that std::is_constant_evaluated() would evaluate to
false.
2021-05-19 16:02:53 -07:00
Richard Smith d38057f3ec Treat implicit deduction guides as being equivalent to their
corresponding constructor for access checking purposes.
2021-05-19 13:31:53 -07:00
Alex Lorenz 50be48b0f3 [clang][ObjC] Allow different availability annotation on a method
when implementing an optional protocol requirement

When an Objective-C method implements an optional protocol requirement,
allow the method to use a newer introduced or older obsoleted
availability version than what's specified on the method in the protocol
itself. This allows SDK adopters to adopt an optional method from a
protocol later than when the method is introduced in the protocol. The users
that call an optional method on an object that conforms to this protocol
are supposed to check whether the object implements the method or not,
so a lack of appropriate `if (@available)` check for a new OS version
is not a cause of concern as there's already another runtime check that's required.

Differential Revision: https://reviews.llvm.org/D102459
2021-05-19 12:13:57 -07:00
Melanie Blower d30dfa8676 [clang][patch] Add support for option -fextend-arguments={32,64}: widen integer arguments to int64 in unprototyped function calls
Reviewed By: Aaron Ballman

Differential Revision: https://reviews.llvm.org/D101640
2021-05-19 10:59:56 -04:00
Haojian Wu f5b5426433 [clang] Fix a crash on CheckArgAlignment.
We might encounter an undeduced type before calling getTypeAlignInChars.

NOTE: this retrieves the fix from
8f80c66bd2, which was removed in Adam's
followup fix fbfcfdbf68. We originally
thought the crash was caused by recovery-ast, but it turns out it can
occur for other cases, e.g. typo-correction.

Differential Revision: https://reviews.llvm.org/D102750
2021-05-19 13:29:28 +02:00
Ole Strohm 642d2f000b [OpenCL] Fix initialization of __constant constructors without arguments
This fixes the initialization of objects in the __constant
address space that occurs when declaring the object.

Fixes part of PR42566

Reviewed By: Anastasia

Differential Revision: https://reviews.llvm.org/D102248
2021-05-18 10:59:53 +01:00
Ten Tzen 797ad70152 [Windows SEH]: HARDWARE EXCEPTION HANDLING (MSVC -EHa) - Part 1
This patch is the Part-1 (FE Clang) implementation of HW Exception handling.

This new feature adds the support of Hardware Exception for Microsoft Windows
SEH (Structured Exception Handling).
This is the first step of this project; only X86_64 target is enabled in this patch.

Compiler options:
For clang-cl.exe, the option is -EHa, the same as MSVC.
For clang.exe, the extra option is -fasync-exceptions,
plus -triple x86_64-windows -fexceptions and -fcxx-exceptions as usual.

NOTE:: Without the -EHa or -fasync-exceptions, this patch is a NO-DIFF change.

The rules for C code:
For C-code, one way (MSVC approach) to achieve SEH -EHa semantic is to follow
three rules:
* First, no exception can move in or out of _try region., i.e., no "potential
  faulty instruction can be moved across _try boundary.
* Second, the order of exceptions for instructions 'directly' under a _try
  must be preserved (not applied to those in callees).
* Finally, global states (local/global/heap variables) that can be read
  outside of _try region must be updated in memory (not just in register)
  before the subsequent exception occurs.

The impact to C++ code:
Although SEH is a feature for C code, -EHa does have a profound effect on C++
side. When a C++ function (in the same compilation unit with option -EHa ) is
called by a SEH C function, a hardware exception occurs in C++ code can also
be handled properly by an upstream SEH _try-handler or a C++ catch(...).
As such, when that happens in the middle of an object's life scope, the dtor
must be invoked the same way as C++ Synchronous Exception during unwinding
process.

Design:
A natural way to achieve the rules above in LLVM today is to allow an EH edge
added on memory/computation instruction (previous iload/istore idea) so that
exception path is modeled in Flow graph preciously. However, tracking every
single memory instruction and potential faulty instruction can create many
Invokes, complicate flow graph and possibly result in negative performance
impact for downstream optimization and code generation. Making all
optimizations be aware of the new semantic is also substantial.

This design does not intend to model exception path at instruction level.
Instead, the proposed design tracks and reports EH state at BLOCK-level to
reduce the complexity of flow graph and minimize the performance-impact on CPP
code under -EHa option.

One key element of this design is the ability to compute State number at
block-level. Our algorithm is based on the following rationales:

A _try scope is always a SEME (Single Entry Multiple Exits) region as jumping
into a _try is not allowed. The single entry must start with a seh_try_begin()
invoke with a correct State number that is the initial state of the SEME.
Through control-flow, state number is propagated into all blocks. Side exits
marked by seh_try_end() will unwind to parent state based on existing
SEHUnwindMap[].
Note side exits can ONLY jump into parent scopes (lower state number).
Thus, when a block succeeds various states from its predecessors, the lowest
State triumphs others.  If some exits flow to unreachable, propagation on those
paths terminate, not affecting remaining blocks.
For CPP code, object lifetime region is usually a SEME as SEH _try.
However there is one rare exception: jumping into a lifetime that has Dtor but
has no Ctor is warned, but allowed:

Warning: jump bypasses variable with a non-trivial destructor

In that case, the region is actually a MEME (multiple entry multiple exits).
Our solution is to inject a eha_scope_begin() invoke in the side entry block to
ensure a correct State.

Implementation:
Part-1: Clang implementation described below.

Two intrinsic are created to track CPP object scopes; eha_scope_begin() and eha_scope_end().
_scope_begin() is immediately added after ctor() is called and EHStack is pushed.
So it must be an invoke, not a call. With that it's also guaranteed an
EH-cleanup-pad is created regardless whether there exists a call in this scope.
_scope_end is added before dtor(). These two intrinsics make the computation of
Block-State possible in downstream code gen pass, even in the presence of
ctor/dtor inlining.

Two intrinsic, seh_try_begin() and seh_try_end(), are added for C-code to mark
_try boundary and to prevent from exceptions being moved across _try boundary.
All memory instructions inside a _try are considered as 'volatile' to assure
2nd and 3rd rules for C-code above. This is a little sub-optimized. But it's
acceptable as the amount of code directly under _try is very small.

Part-2 (will be in Part-2 patch): LLVM implementation described below.

For both C++ & C-code, the state of each block is computed at the same place in
BE (WinEHPreparing pass) where all other EH tables/maps are calculated.
In addition to _scope_begin & _scope_end, the computation of block state also
rely on the existing State tracking code (UnwindMap and InvokeStateMap).

For both C++ & C-code, the state of each block with potential trap instruction
is marked and reported in DAG Instruction Selection pass, the same place where
the state for -EHsc (synchronous exceptions) is done.
If the first instruction in a reported block scope can trap, a Nop is injected
before this instruction. This nop is needed to accommodate LLVM Windows EH
implementation, in which the address in IPToState table is offset by +1.
(note the purpose of that is to ensure the return address of a call is in the
same scope as the call address.

The handler for catch(...) for -EHa must handle HW exception. So it is
'adjective' flag is reset (it cannot be IsStdDotDot (0x40) that only catches
C++ exceptions).
Suppress push/popTerminate() scope (from noexcept/noTHrow) so that HW
exceptions can be passed through.

Original llvm-dev [RFC] discussions can be found in these two threads below:
https://lists.llvm.org/pipermail/llvm-dev/2020-March/140541.html
https://lists.llvm.org/pipermail/llvm-dev/2020-April/141338.html

Differential Revision: https://reviews.llvm.org/D80344/new/
2021-05-17 22:42:17 -07:00
Arthur Eubanks 3a0b6dc3e8 Revert "[Clang] -Wunused-but-set-parameter and -Wunused-but-set-variable"
This reverts commit 14dfb3831c.

More false positives, see D100581.
2021-05-17 12:16:10 -07:00
Michael Benfield 14dfb3831c [Clang] -Wunused-but-set-parameter and -Wunused-but-set-variable
These are intended to mimic warnings available in gcc.

Reviewed By: aeubanks

Differential Revision: https://reviews.llvm.org/D100581
2021-05-17 11:02:26 -07:00
Ole Strohm 66b112d624 [OpenCL] Fix reinterpret_cast of vectors
Fixes issues with vectors in reinterpret_cast in C++ for OpenCL
and adds tests to make sure they both pass without errors and
generate the correct code.

Fixes: PR47977

Reviewed By: Anastasia

Differential Revision: https://reviews.llvm.org/D101519
2021-05-17 12:42:21 +01:00
Anastasia Stulova 3549466ac0 [OpenCL] Drop pragma handling for extension types/decls.
Drop non-conformant extension pragma implementation as
it does not properly disable anything and therefore
enabling non-disabled logic has no meaning.

This simplifies clang code and user interface to the extension
functionality. With this patch extension pragma 'begin'/'end'
and 'enable'/'disable' are only accepted for backward
compatibility and no longer have any default behavior.

Differential Revision: https://reviews.llvm.org/D101043
2021-05-17 12:09:43 +01:00
Saurabh Jha ecb235d940 [Matrix] Implement static cast for matrix types
This patch implements static casts for matrix types. This patch finishes all the work needed for https://bugs.llvm.org/show_bug.cgi?id=47141

Reviewed By: fhahn

Differential Revision: https://reviews.llvm.org/D102125
2021-05-16 08:09:12 +01:00
Anastasia Stulova 769cc335e6 [OpenCL] Simplify use of C11 atomic types.
Remove requirements on extension pragma in atomic types
because it has not respected the spec wrt disabling types
and hasn't been useful either. With this change, the
developers can use atomic types from the extensions if they
are supported without enabling the pragma just like the builtin
functions

This patch does not break backward compatibility since the
extension pragma is still supported and it makes the behavior of
the compiler less strict by accepting code without needless and
inconsistent pragma statements.

Differential Revision: https://reviews.llvm.org/D100976
2021-05-14 17:43:00 +01:00
Reid Kleckner d2f4b7d778 Use enum comparison instead of generated switch/case, NFC
Clang's coverage data for auto-generated switch cases is really, really
large. Before this change, when I enable code coverage, SemaDeclAttr.obj
is 4.0GB. Naturally, this fails to link.

Replacing the RISCV builtin id check with a comparison reduces object
file size from 4.0GB to 330MB. Replacing the AArch64 SVE range check
reduces the size again down to 17MB, which is reasonable.

I think the RISCV switch is larger in coverage data because it uses more
levels of macro expansion, while the SVE intrinsics only use one. In any
case, please try to avoid switches with 1000+ cases, they usually don't
optimize well.
2021-05-13 20:26:50 -07:00
cynecx 8ec9fd4839 Support unwinding from inline assembly
I've taken the following steps to add unwinding support from inline assembly:

1) Add a new `unwind` "attribute" (like `sideeffect`) to the asm syntax:

```
invoke void asm sideeffect unwind "call thrower", "~{dirflag},~{fpsr},~{flags}"()
    to label %exit unwind label %uexit
```

2.) Add Bitcode writing/reading support + LLVM-IR parsing.

3.) Emit EHLabels around inline assembly lowering (SelectionDAGBuilder + GlobalISel) when `InlineAsm::canThrow` is enabled.

4.) Tweak InstCombineCalls/InlineFunction pass to not mark inline assembly "calls" as nounwind.

5.) Add clang support by introducing a new clobber: "unwind", which lower to the `canThrow` being enabled.

6.) Don't allow unwinding callbr.

Reviewed By: Amanieu

Differential Revision: https://reviews.llvm.org/D95745
2021-05-13 19:13:03 +01:00
Yaxun (Sam) Liu ce6cc87ce9 [clang] Minor fix for MarkVarDeclODRUsed
Merge two if as follow up of https://reviews.llvm.org/D102270
2021-05-12 22:32:10 -04:00
Richard Smith e1aa528d3a Handle unexpanded packs appearing in type-constraints.
For a type-constraint in a lambda signature, this makes the lambda
contain an unexpanded pack; for requirements in a requires-expressions
it makes the requires-expression contain an unexpanded pack; otherwise
it's invalid.
2021-05-12 18:45:34 -07:00
Richard Smith e0acfed7ed Clean up handling of constrained parameters in lambdas.
No functionality change intended.
2021-05-12 18:45:33 -07:00
Erich Keane 08ba9ce1ef Suppress Deferred Diagnostics in discarded statements.
It doesn't really make sense to emit language specific diagnostics
in a discarded statement, and suppressing these diagnostics results in a
programming pattern that many users will feel is quite useful.

Basically, this makes sure we only emit errors from the 'true' side of a
'constexpr if'.

It does this by making the ExprEvaluatorBase type have an opt-in option
as to whether it should visit discarded cases.

Differential Revision: https://reviews.llvm.org/D102251
2021-05-12 12:48:47 -07:00
Pratyush Das 99d63ccff0 Add type information to integral template argument if required.
Non-comprehensive list of cases:
 * Dumping template arguments;
 * Corresponding parameter contains a deduced type;
 * Template arguments are for a DeclRefExpr that hadMultipleCandidates()

Type information is added in the form of prefixes (u8, u, U, L),
suffixes (U, L, UL, LL, ULL) or explicit casts to printed integral template
argument, if MSVC codeview mode is disabled.

Differential revision: https://reviews.llvm.org/D77598
2021-05-12 19:00:08 +00:00
Nico Weber d8c227ba05 Revert "Produce warning for performing pointer arithmetic on a null pointer."
This reverts commit dfc1e31d49.
See discussion on https://reviews.llvm.org/D98798
2021-05-12 14:53:50 -04:00
Yaxun (Sam) Liu 98575708da [CUDA][HIP] Fix device template variables
Currently clang does not emit device template variables
instantiated only in host functions, however, nvcc is
able to do that:

https://godbolt.org/z/fneEfferY

This patch fixes this issue by refactoring and extending
the existing mechanism for emitting static device
var ODR-used by host only. Basically clang records
device variables ODR-used by host code and force
them to be emitted in device compilation. The existing
mechanism makes sure these device variables ODR-used
by host code are added to llvm.compiler-used, therefore
they are guaranteed not to be deleted.

It also fixes non-ODR-use of static device variable by host code
causing static device variable to be emitted and registered,
which should not.

Reviewed by: Artem Belevich

Differential Revision: https://reviews.llvm.org/D102237
2021-05-12 11:13:29 -04:00
Victor Huang 46475a79f8 [AIX][TLS] Diagnose use of unimplemented TLS models
Add front end diagnostics to report error for unimplemented TLS models set by
- compiler option `-ftls-model`
- attributes like `__thread int __attribute__((tls_model("local-exec"))) var_name;`

Reviewed by: aaron.ballman, nemanjai, PowerPC

Differential Revision: https://reviews.llvm.org/D102070
2021-05-11 17:21:08 -05:00
Mike Rice f90abac6ca [OpenMP] Use compound operators for reduction combiner if available.
The OpenMP spec seems to require the compound operators be used for
+, *, &, |, and ^ reduction.  So use these if a class has those operators.
If not try the simple operators as we did previously to limit the impact
to existing code.

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

Differential Revision: https://reviews.llvm.org/D101941
2021-05-11 11:39:12 -07:00
Jamie Schmeiser dfc1e31d49 Produce warning for performing pointer arithmetic on a null pointer.
Summary:
Test and produce warning for subtracting a pointer from null or subtracting
null from a pointer.  Reuse existing warning that this is undefined
behaviour.  Also add unit test for both warnings.

Reformat to satisfy clang-format.

Respond to review comments:  add additional test.

Respond to review comments:  Do not issue warning for nullptr - nullptr
in C++.

Fix indenting to satisfy clang-format.

Respond to review comments:  Add C++ tests.

Author: Jamie Schmeiser <schmeise@ca.ibm.com>
Reviewed By: efriedma (Eli Friedman), nickdesaulniers (Nick Desaulniers)
Differential Revision: https://reviews.llvm.org/D98798
2021-05-11 11:29:50 -04:00
Anastasia Stulova 13ea238b1e [OpenCL] Allow use of double type without extension pragma.
Simply use of extensions by allowing the use of supported
double types without the pragma. Since earlier standards
instructed that the pragma is used explicitly a new warning
is introduced in pedantic mode to indicate that use of
type without extension pragma enable can be non-portable.

This patch does not break backward compatibility since the
extension pragma is still supported and it makes the behavior
of the compiler less strict by accepting code without extra
pragma statements.

Differential Revision: https://reviews.llvm.org/D100980
2021-05-11 12:54:38 +01:00
Craig Topper 18f3a14e13 [RISCV] Validate the SEW and LMUL operands to __builtin_rvv_vsetvli(max)
These are required to be constants, this patch makes sure they
are in the accepted range of values.

These are usually created by wrappers in the riscv_vector.h header
which should always be correct. This patch protects against a user
using the builtin directly.

Reviewed By: khchen

Differential Revision: https://reviews.llvm.org/D102086
2021-05-10 12:11:13 -07:00
Ahsan Saghir 25bbff632d [PowerPC] Provide MMA builtins for compatibility
Vector pair intrinsics and builtins were renamed in
https://reviews.llvm.org/D91974 to replace the _mma_ prefix by _vsx_.
However, some projects used the _mma_ version, so this patch adds
these intrinsics to provide compatibility.

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

Reviewed By: nemanjai, amyk

Differential Revision: https://reviews.llvm.org/D100482
2021-05-07 09:10:16 -05:00
Anastasia Stulova 76f1de10f4 [OpenCL] Fix optional image types.
This change allows the use of identifiers for image types
from `cl_khr_gl_msaa_sharing` freely in the kernel code if
the extension is not supported since they are not in the
list of the reserved identifiers.

This change also removed the need for pragma for the types
in the extensions since the spec does not require the pragma
uses.

Differential Revision: https://reviews.llvm.org/D100983
2021-05-07 13:29:28 +01:00
Anastasia Stulova c28a602329 [OpenCL] Remove subgroups pragma in enqueue kernel and pipe builtins.
This patch simplifies the parser and makes the language semantics
consistent. There is no extension pragma requirement in the spec
for the subgroup functions in enqueue kernel or pipes and all other
builtin functions are available without the pragama.

Differential Revision: https://reviews.llvm.org/D100984
2021-05-06 13:59:38 +01:00
Johannes Doerfert df729e2b82 [OpenMP] Overhaul `declare target` handling
This patch fixes various issues with our prior `declare target` handling
and extends it to support `omp begin declare target` as well.

This started with PR49649 in mind, trying to provide a way for users to
avoid the "ref" global use introduced for globals with internal linkage.
From there it went down the rabbit hole, e.g., all variables, even
`nohost` ones, were emitted into the device code so it was impossible to
determine if "ref" was needed late in the game (based on the name only).
To make it really useful, `begin declare target` was needed as it can
carry the `device_type`. Not emitting variables eagerly had a ripple
effect. Finally, the precedence of the (explicit) declare target list
items needed to be taken into account, that meant we cannot just look
for any declare target attribute to make a decision. This caused the
handling of functions to require fixup as well.

I tried to clean up things while I was at it, e.g., we should not "parse
declarations and defintions" as part of OpenMP parsing, this will always
break at some point. Instead, we keep track what region we are in and
act on definitions and declarations instead, this is what we do for
declare variant and other begin/end directives already.

Highlights:
  - new diagnosis for restrictions specificed in the standard,
  - delayed emission of globals not mentioned in an explicit
    list of a declare target,
  - omission of `nohost` globals on the host and `host` globals on the
    device,
  - no explicit parsing of declarations in-between `omp [begin] declare
    variant` and the corresponding end anymore, regular parsing instead,
  - precedence for explicit mentions in `declare target` lists over
    implicit mentions in the declaration-definition-seq, and
  - `omp allocate` declarations will now replace an earlier emitted
    global, if necessary.

---

Notes:

The patch is larger than I hoped but it turns out that most changes do
on their own lead to "inconsistent states", which seem less desirable
overall.

After working through this I feel the standard should remove the
explicit declare target forms as the delayed emission is horrible.
That said, while we delay things anyway, it seems to me we check too
often for the current status even though that is often not sufficient to
act upon. There seems to be a lot of duplication that can probably be
trimmed down. Eagerly emitting some things seems pretty weak as an
argument to keep so much logic around.

---

Reviewed By: ABataev

Differential Revision: https://reviews.llvm.org/D101030
2021-05-06 02:10:41 -05:00
Johannes Doerfert 3f14596700 [OpenMP] Ensure the DefaultMapperId has a location
A user reported an assertion (below) but without a reproducer. I failed to
create a test myself but from the assertion one can derive the problem.
I set the DefaultMapperId location now to make sure this doesn't cause
trouble.

```
clang-13: .../DeclTemplate.h:1940:
void clang::ClassTemplateSpecializationDecl::setPointOfInstantiation(clang::SourceLocation):
Assertion `Loc.isValid() && "point of instantiation must be valid!"' failed.
```

Reviewed By: JonChesterfield

Differential Revision: https://reviews.llvm.org/D100621
2021-05-06 02:10:36 -05:00
Richard Smith 6bbfa0fd40 When performing template argument deduction to select a partial
specialization while substituting a partial template parameter pack,
don't try to extend the existing deduction.

This caused us to select the wrong partial specialization in some rare
cases. A recent change to libc++ caused this to happen in practice for
code using std::conjunction.
2021-05-05 14:47:18 -07:00
Anastasia Stulova e994e74bca [OpenCL] Add clang extension for non-portable kernel parameters.
Added __cl_clang_non_portable_kernel_param_types extension that
allows using non-portable types as kernel parameters. This allows
bypassing the portability guarantees from the restrictions specified
in C++ for OpenCL v1.0 s2.4.

Currently this only disables the restrictions related to the data
layout. The programmer should ensure the compiler generates the same
layout for host and device or otherwise the argument should only be
accessed on the device side. This extension could be extended to other
case (e.g. permitting size_t) if desired in the future.

Patch by olestrohm (Ole Strohm)!

https://reviews.llvm.org/D101168
2021-05-05 14:58:23 +01:00
Jennifer Yu 5285748c2c Fix assert on the variable which is used in omp clause is not marked
as used.

The problem only happens with constexpr variable, for constexpr variable,
variable is not marked during parser variable.   This is because compiler
might find some var's associate expressions may not actully an odr-used
later,  the variables get kept in MaybeODRUseExprs, in normal case, at
end of process fullExpr, the variable will be marked during the call to
CleanupVarDeclMarking(). Since we are processing expression of OpenMP
clauses, and the ActOnFinishFullExpr is not getting called that casue
variable is not get marked.

One way to fix this is to call CleanupVarDeclMarking() in EndOpenMPClause
for each omp directive.

This to fix https://bugs.llvm.org/show_bug.cgi?id=50206

Differential Revision: https://reviews.llvm.org/D101781
2021-05-04 09:07:35 -07:00
Saurabh Jha db210bc69b [Matrix] Implement C-style explicit type conversions in CXX for matrix types
This patch implements C-style explicit type conversions in CXX for matrix types. It is part of fixing https://bugs.llvm.org/show_bug.cgi?id=47141

Reviewed By: fhahn

Differential Revision: https://reviews.llvm.org/D101696
2021-05-04 15:27:57 +01:00
serge-sans-paille b83b23275b Introduce -Wreserved-identifier
Warn when a declaration uses an identifier that doesn't obey the reserved
identifier rule from C and/or C++.

Differential Revision: https://reviews.llvm.org/D93095
2021-05-04 11:19:01 +02:00
Nathan Sidwell fe4c9b3cb0 [clang] Remove libstdc++ friend template hack
this hack is for a now-unsupported version of libstdc++

Differential Revision: https://reviews.llvm.org/D101392
2021-05-03 04:19:30 -07:00
Nathan Sidwell e90792d8c7 [clang] Update comments on another libstdc++ HACK
Document relevant gcc versions and dates.

Differential Revision: https://reviews.llvm.org/D101530
2021-04-30 09:29:26 -07:00
Adam Czachorowski fbfcfdbf68 [clang] Fix assert() crash when checking undeduced arg alignment
There already was a check for undeduced and incomplete types, but it
failed to trigger when outer type (SubstTemplateTypeParm in test) looked
fine, but inner type was not.

Differential Revision: https://reviews.llvm.org/D100667
2021-04-30 16:24:33 +02:00
Akira Hatanaka 809435e390 [Sema] Don't set BlockDecl's DoesNotEscape bit if the parameter type of
the function the block is passed to isn't a block pointer type

This patch fixes a bug where a block passed to a function taking a
parameter that doesn't have a block pointer type (e.g., id or reference
to a block pointer) was marked as noescape.

This partially fixes PR50043.

rdar://77030453

Differential Revision: https://reviews.llvm.org/D101097
2021-04-29 16:19:48 -07:00
Nathan Sidwell 0ff41c2ebc Update libstdc++ hack comment
This libstc++ hack isn't ready for removal. Updating the comment to
note what I found. While I have not proven Ville's
__is_throw_swappable patch made this go away, that patch did remove
the use of noexcept(noexcept(swap(....))). I'm not sure when gcc grew
deferred noexcept parsing.

Differential Revision: https://reviews.llvm.org/D101441
2021-04-29 03:57:10 -07:00
Arthur Eubanks 6d8d133862 Revert "[Clang] -Wunused-but-set-parameter and -Wunused-but-set-variable"
This reverts commit 9b0501abc7.

False positives reported in D100581.
2021-04-28 12:47:18 -07:00
Nico Weber 671f0e2e18 [clang] Make libBasic not depend on MC
Reduces numbers of files built for clang-format from 575 to 449.

Requires two small changes:

1. Don't use llvm::ExceptionHandling in LangOptions. This isn't
   even quite the right type since we don't use all of its values.
   Tweaks the changes made in:
   - https://reviews.llvm.org/D93215
   - https://reviews.llvm.org/D93216

2. Move section name validation code added (long ago) in commit 30ba67439 out
   of libBasic into Sema and base the check on the triple. This is a bit less
   OOP-y, but completely in line with what we do in many other places in Sema.

No behavior change.

Differential Revision: https://reviews.llvm.org/D101463
2021-04-28 12:16:22 -04:00
Nico Weber 5d493291bd [clang] remove dead code after 2a1332245f
Commit 2a1332245f extracted this code to a new function checkSectionName() and
added a call to it, but didn't remove the original code. The original code
is dead since the checkSectionName() early return would fire when it would
trigger. (If it weren't dead, it'd make clang crash since
err_attribute_section_invalid_for_target now takes two args instead of just the
one that's passed.)

No behavior change.

Differential Revision: https://reviews.llvm.org/D101457
2021-04-28 10:27:31 -04:00
Alexey Bataev c835630c25 [OPENMP]Fix PR49098: respect firstprivate of declare target variable.
Need to respect mapping/privatization of declare target variables in the
target regions if explicitly specified by the user.

Differential Revision: https://reviews.llvm.org/D99530
2021-04-28 05:39:10 -07:00
Anastasia Stulova 6a92c19f3b [C++4OpenCL] Add diagnostics for OpenCL types in templates.
Refactored diagnostics for OpenCL types to allow their
reuse for templates.

Patch by olestrohm (Ole Strohm)!

Differential Revision: https://reviews.llvm.org/D100860
2021-04-27 13:04:25 +01:00
Yonghong Song a2a3ca8d97 BPF: emit debuginfo for Function of DeclRefExpr if requested
Commit e3d8ee35e4 ("reland "[DebugInfo] Support to emit debugInfo
for extern variables"") added support to emit debugInfo for
extern variables if requested by the target. Currently, only
BPF target enables this feature by default.

As BPF ecosystem grows, callback function started to get
support, e.g., recently bpf_for_each_map_elem() is introduced
(https://lwn.net/Articles/846504/) with a callback function as an
argument. In the future we may have something like below as
a demonstration of use case :
    extern int do_work(int);
    long bpf_helper(void *callback_fn, void *callback_ctx, ...);
    long prog_main() {
        struct { ... } ctx = { ... };
        return bpf_helper(&do_work, &ctx, ...);
    }
Basically bpf helper may have a callback function and the
callback function is defined in another file or in the kernel.
In this case, we would like to know the debuginfo types for
do_work(), so the verifier can proper verify the safety of
bpf_helper() call.

For the following example,
    extern int do_work(int);
    long bpf_helper(void *callback_fn);
    long prog() {
        return bpf_helper(&do_work);
    }

Currently, there is no debuginfo generated for extern function do_work().
In the IR, we have,
    ...
    define dso_local i64 @prog() local_unnamed_addr #0 !dbg !7 {
    entry:
      %call = tail call i64 @bpf_helper(i8* bitcast (i32 (i32)* @do_work to i8*)) #2, !dbg !11
      ret i64 %call, !dbg !12
    }
    ...
    declare dso_local i32 @do_work(i32) #1
    ...

This patch added support for the above callback function use case, and
the generated IR looks like below:
    ...
    declare !dbg !17 dso_local i32 @do_work(i32) #1
    ...
    !17 = !DISubprogram(name: "do_work", scope: !1, file: !1, line: 1, type: !18, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)
    !18 = !DISubroutineType(types: !19)
    !19 = !{!20, !20}
    !20 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)

The TargetInfo.allowDebugInfoForExternalVar is renamed to
TargetInfo.allowDebugInfoForExternalRef as now it guards
both extern variable and extern function debuginfo generation.

Differential Revision: https://reviews.llvm.org/D100567
2021-04-26 16:53:25 -07:00
Michael Benfield 9b0501abc7 [Clang] -Wunused-but-set-parameter and -Wunused-but-set-variable
These are intended to mimic warnings available in gcc.

-Wunused-but-set-variable is triggered in the case of a variable which
appears on the LHS of an assignment but not otherwise used.

For instance:

  void f() {
    int x;
    x = 0;
  }

-Wunused-but-set-parameter works similarly, but for function parameters
instead of variables.

In C++, they are triggered only for scalar types; otherwise, they are
triggered for all types. This is gcc's behavior.

-Wunused-but-set-parameter is controlled by -Wextra, while
-Wunused-but-set-variable is controlled by -Wunused. This is slightly
different from gcc's behavior, but seems most consistent with clang's
behavior for -Wunused-parameter and -Wunused-variable.

Reviewed By: aeubanks

Differential Revision: https://reviews.llvm.org/D100581
2021-04-26 15:09:03 -07:00
Alexey Bader 7818906ca1 [SYCL] Implement SYCL address space attributes handling
Default address space (applies when no explicit address space was
specified) maps to generic (4) address space.

Added SYCL named address spaces `sycl_global`, `sycl_local` and
`sycl_private` defined as sub-sets of the default address space.

Static variables without address space now reside in global address
space when compile for SPIR target, unless they have an explicit address
space qualifier in source code.

Differential Revision: https://reviews.llvm.org/D89909
2021-04-26 13:44:10 +03:00
Sven van Haastregt 18772de1ec [OpenCL] Add inc/dec/cmpxchg C++ legacy atomics with generic
Mirror the remaining C++ for OpenCL specific builtins from opencl-c.h
to the TableGen builtin functions.

Fixes PR50041 (part 2).
2021-04-26 09:46:11 +01:00
Hsiangkai Wang 108864397d [Clang] Add clang attribute `clang_builtin_alias`.
In some cases, we want to provide the alias name for the clang builtins.
For example, the arguments must be constant integers for some RISC-V builtins.
If we use wrapper functions, we could not constrain the arguments be constant
integer. This attribute is used to achieve the purpose.

Besides this, use `clang_builtin_alias` is more efficient than using
wrapper functions. We use this attribute to deal with test time issue
reported in https://bugs.llvm.org/show_bug.cgi?id=49962.

In our downstream testing, it could decrease the testing time from 6.3
seconds to 3.7 seconds for vloxei.c test.

Differential Revision: https://reviews.llvm.org/D100611
2021-04-25 08:49:19 +08:00
Johannes Doerfert cbe8b57a67 [Clang] Allow the combination of loader_uninitialized and address spaces
When an object is allocated in a non-default address space we do not
need to check for a constructor if it is not initialized and has a
trivial constructor (which we won't call then).

Reviewed By: JonChesterfield

Differential Revision: https://reviews.llvm.org/D100929
2021-04-23 11:21:52 -05:00
Adam Czachorowski ddfbdbfefa [clang] Do not crash on template specialization following a fatal error
There was a missing isInvalid() check leading to an attempt to
instantiate template with an empty instantiation stack.

Differential Revision: https://reviews.llvm.org/D100675
2021-04-23 13:34:05 +02:00
Richard Smith 40beb1f84a CWG2076: Permit implicit conversions within a single level of braces
during overload resolution, even when calling a copy constructor.
2021-04-22 16:49:39 -07:00
Dávid Bolvanský abf3ca61e3 [Diagnostics] Restore -Wdeprecated warning when user-declared copy assignment operator is defined as deleted (PR45634)
Solves https://bugs.llvm.org/show_bug.cgi?id=45634
Be more agressive than GCC with -Wdeprecated-copy. Also provide -W(no-)deprecated-copy-user-provided-copy/dtor options to on/off this behaviour.

Reviewed By: Quuxplusone

Differential Revision: https://reviews.llvm.org/D79714
2021-04-22 20:35:41 +02:00
Anastasia Stulova 362958ac73 [C++4OpenCL] Add extra diagnostics for kernel argument types
Add restrictions on type layout (PR48099):
- Types passed by pointer or reference must be standard layout types.
- Types passed by value must be POD types.

Patch by olestrohm (Ole Strohm)!

Differential Revision: https://reviews.llvm.org/D100471
2021-04-22 15:28:04 +01:00
Sven van Haastregt 4138e7bd76 [OpenCL] Add missing C++ legacy atomics with generic
https://reviews.llvm.org/D62335 added some C++ for OpenCL specific
builtins to opencl-c.h, but these were not mirrored to the TableGen
builtin functions yet.

The TableGen builtins machinery does not have dedicated version
handling for C++ for OpenCL at the moment: all builtin versioning is
tied to `LangOpts.OpenCLVersion` (i.e., the OpenCL C version).  As a
workaround, to add builtins that are only available in C++ for OpenCL,
we define a function extension guarded by the __cplusplus macro.

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

Fixes PR50041.
2021-04-22 15:08:36 +01:00
Nathan Sidwell 6ad7e87806 clang: libstdc++ LWM is 4.8.3
Document oldest libstdc++ as 4.8.3, remove a hack for a 4.6 issue.

Differential Revision: https://reviews.llvm.org/D100465
2021-04-22 05:26:07 -07:00
Valeriy Savchenko 5780dbeee6 [-Wcalled-once] Do not run analysis on Obj-C++
Objective-C++ is not yet suppoerted.

rdar://76729552

Differential Revision: https://reviews.llvm.org/D100955
2021-04-22 15:20:52 +03:00
Aaron Ballman a63c9b2562 Do not pass null attributes to BuildAttributedStmt during instantiation
When transforming an attribute during template instantiation, if the
transformation fails, it may result in a null attribute being returned.
This null attribute should not be passed in as one of the attributes
used to create an attributed statement.

If all of the attributes fail to transform, we do not create an
attributed statement at all.

There are no attributes that return null currently, so there is no easy
way to test this currently. However, this fixes a crash caused by
8344675908.
2021-04-21 09:30:56 -04:00
Sven van Haastregt e2b3b89bf1 [OpenCL] Do not add builtins with unavailable types
Add functionality to assign extensions to types in OpenCLBuiltins.td
and use that information to filter candidates that should not be
exposed if a type is not available.

Differential Revision: https://reviews.llvm.org/D100209
2021-04-21 11:59:29 +01:00
Sven van Haastregt fdcb9c2728 [OpenCL] Refactor shuffle builtin decls
The shuffle and shuffle2 builtins relied on processing two TypeLists
for different arguments in sync.  This will no longer work when a type
(e.g. double) in one of the TypeLists is optional.

Rewrite the declarations using explicit types instead of GenericTypes.
2021-04-21 11:59:24 +01:00
Nathan Sidwell 057b6f5d0b clang: Update libstdc++ issue workaround
Add some specificity to libstdc++ hack, perhaps we can remove it at a
later date.
2021-04-20 11:34:12 -07:00
Yaxun (Sam) Liu d8805574c1 [CUDA][HIP] Allow non-ODR use of host var in device
Reviewed by: Artem Belevich, Richard Smith

Differential Revision: https://reviews.llvm.org/D98193
2021-04-19 14:45:24 -04:00
Jan Svoboda 6a72ed239c [clang] NFC: Fix range-based for loop warnings related to decl lookup 2021-04-19 18:31:31 +02:00
Sven van Haastregt 6cb7631df3 [OpenCL] Change OpenCL builtin version encoding
Instead of using a MinVersion and MaxVersion field, encode the version
of a builtin using a mask that aligns better with version handling in
OpenCLOptions.h.  In addition, this saves a field in the BuiltinTable.

This change allows a finer-grained control over the OpenCL versions in
which a builtin is available: instead of a range, we can now toggle
each version individually.

The fine-grained version control is not yet exposed on the TableGen
definitions side, as changes for OpenCL 3 feature optionality still
need to be defined and will affect how we want to expose these.

Differential Revision: https://reviews.llvm.org/D100492
2021-04-19 10:23:13 +01:00
Alexey Bataev 10c7b9f64f [OPENMP]Fix PR49115: Incorrect results for scan directive.
For combined worksharing directives need to emit the temp arrays outside
of the parallel region and update them in the master thread only.

Differential Revision: https://reviews.llvm.org/D100187
2021-04-16 06:25:35 -07:00
Joshua Haberman 8344675908 Implemented [[clang::musttail]] attribute for guaranteed tail calls.
This is a Clang-only change and depends on the existing "musttail"
support already implemented in LLVM.

The [[clang::musttail]] attribute goes on a return statement, not
a function definition. There are several constraints that the user
must follow when using [[clang::musttail]], and these constraints
are verified by Sema.

Tail calls are supported on regular function calls, calls through a
function pointer, member function calls, and even pointer to member.

Future work would be to throw a warning if a users tries to pass
a pointer or reference to a local variable through a musttail call.

Reviewed By: rsmith

Differential Revision: https://reviews.llvm.org/D99517
2021-04-15 17:12:21 -07:00
Melanie Blower 938b863bb5 [clang][patch] Modify diagnostic level from err to warn: anyx86_interrupt_regsave
Reviewed By: Aaron Ballman

Differential Revision: https://reviews.llvm.org/D100511
2021-04-15 13:11:33 -04:00
Eli Friedman dc1ab590a0 [Sema] Fold VLA types in compound literals to constant arrays.
Similar to variables with an initializer, this is never valid in
standard C, so we can safely constant-fold as an extension.  I ran into
this construct in a couple proprietary codebases.

While I'm here, drive-by fix for 090dd647: we should only fold variables
with VLA types, not arbitrary variably modified types.

Differential Revision: https://reviews.llvm.org/D98363
2021-04-14 17:09:59 -07:00
Erich Keane 92aba5ae49 CPUDispatch- allow out of line member definitions
ICC permits this, and after some extensive testing it looks like we can
support this with very little trouble.  We intentionally don't choose to
do this with attribute-target (despite it likely working as well!)
  because GCC does not support that, and introducing said
  incompatibility doesn't seem worth it.
2021-04-14 06:19:49 -07:00
Anton Bikineev 69545154cc [Sema] Move 'char-expression-as-unsigned < 0' into a separate diagnostic
This change splits '-Wtautological-unsigned-zero-compare' by reporting
char-expressions-interpreted-as-unsigned under a separate diagnostic
'-Wtautological-unsigned-char-zero-compare'. This is beneficial for
projects that want to enable '-Wtautological-unsigned-zero-compare' but at
the same time want to keep code portable for platforms with char being
signed or unsigned, such as Chromium.

Differential Revision: https://reviews.llvm.org/D99808
2021-04-14 01:01:40 +02:00
Hana Dusíková 64c24f493e Remove warning "suggest braces" for aggregate initialization of an empty class with an aggregate base class.
I recently ran into issues with aggregates and inheritance, I'm using
it for creating a type-safe library where most of the types are build
over "tagged" std::array. After bit of cleaning and enabling -Wall
-Wextra -pedantic I noticed clang only in my pipeline gives me warning.
After a bit of focusing on it I found it's not helpful, and contemplate
disabling the warning all together. After a discussion with other
library authors I found it's bothering more people and decided to fix
it.

Removes this warning:

template<typename T, int N> struct StdArray {
    T contents[N];
  };

template<typename T, int N> struct AggregateAndEmpty : StdArray<T,N> { };

AggregateAndEmpty<int, 3> p = {1, 2, 3}; // <-- warning here about omitted braces
2021-04-13 15:45:09 -04:00
Aaron Ballman c058a71227 Correct the tablegen for checking mutually exclusive stmt attrs
The previous implementation was insufficient for checking statement
attribute mutual exclusion because attributed statements do not collect
their attributes one-at-a-time in the same way that declarations do. So
the design that was attempting to check for mutual exclusion as each
attribute was processed would not ever catch a mutual exclusion in a
statement. This was missed due to insufficient test coverage, which has
now been added for the [[likely]] and [[unlikely]] attributes.

The new approach is to check all of attributes that are to be applied
to the attributed statement in a group. This required generating
another DiagnoseMutualExclusions() function into AttrParsedAttrImpl.inc.
2021-04-13 15:20:30 -04:00
Artem Belevich 38cf112a6b Allow applying attributes to subset of allowed subjects.
Differential Revision: https://reviews.llvm.org/D100136
2021-04-12 09:33:33 -07:00
Sander de Smalen 6bf806b3e2 [AArch64] ACLE: Fix issue for mismatching enum types with builtins.
This patch fixes an issue with the SVE prefetch and qinc/qdec intrinsics
that take an `enum` argument, but where the builtin prototype encodes
these as `int`. Some code in SemaDecl found the mismatch and chose
to forget about the builtin altogether, which meant that any future
code using that builtin would fail. The code that forgets about the
builtin was actually obsolete after D77491 and should have been removed.
This patch now removes that code.

This patch also fixes another issue with the SVE prefetch intrinsic
when built with C++, where the builtin didn't accept the correct
pointer type, which should be `const void *`.

Reviewed By: tambre

Differential Revision: https://reviews.llvm.org/D100046
2021-04-12 11:16:28 +01:00
Sven van Haastregt 731bf28a60 [OpenCL] Accept .rgba in OpenCL 3.0
The .rgba vector component accessors are supported in OpenCL C 3.0.

Previously, the diagnostic would check `OpenCLVersion` for version 2.2
(value 220) and report those accessors are an OpenCL 2.2 feature.
However, there is no "OpenCL C version 2.2", so change the check and
diagnostic text to 3.0 only.

A spurious `OpenCLVersion` argument was passed into the diagnostic;
remove that.

Differential Revision: https://reviews.llvm.org/D99969
2021-04-12 09:30:06 +01:00
Saurabh Jha 71ab6c98a0
[Matrix] Implement C-style explicit type conversions for matrix types.
This implements C-style type conversions for matrix types, as specified
in clang/docs/MatrixTypes.rst.

Fixes PR47141.

Reviewed By: fhahn

Differential Revision: https://reviews.llvm.org/D99037
2021-04-10 11:48:41 +01:00
cchen 1a43fd2769 [OpenMP51] Initial support for masked directive and filter clause
Adds basic parsing/sema/serialization support for the #pragma omp masked
directive.

Reviewed By: ABataev

Differential Revision: https://reviews.llvm.org/D99995
2021-04-09 14:00:36 -05:00
Alex Richardson dc4abca766 Handle alloc_size attribute on function pointers
I have been trying to statically find and analyze all calls to heap
allocation functions to determine how many of them use sizes known at
compile time vs only at runtime. While doing so I saw that quite a few
projects use replaceable function pointers for heap allocation and noticed
that clang was not able to annotate functions pointers with alloc_size.
I have changed the Sema checks to allow alloc_size on all function pointers
and typedefs for function pointers now and added checks that these
attributes are propagated to the LLVM IR correctly.

With this patch we can also compute __builtin_object_size() for calls to
allocation function pointers with the alloc_size attribute.

Reviewed By: aaron.ballman, erik.pilkington
Differential Revision: https://reviews.llvm.org/D55212
2021-04-09 18:49:38 +01:00
Yaxun (Sam) Liu f9264ac0fd [HIP] Workaround ICE compiling SemaChecking.cpp with gcc 5
Change-Id: I6c6213bc6b90365bfb78636ce7fb0700a58807cf
2021-04-09 10:40:07 -04:00
Yaxun (Sam) Liu 25942d7c49 [AMDGPU] Allow relaxed/consume memory order for atomic inc/dec
Reviewed by: Jon Chesterfield

Differential Revision: https://reviews.llvm.org/D100144
2021-04-09 09:23:41 -04:00
Sven van Haastregt af67deb005 [OpenCL] Simplify InsertOCLBuiltinDeclarationsFromTable
- Use a range-based for loop.  This will help a later patch to skip
   prototypes that use an unavailable return type or argument type.

 - Replace a dyn_cast with a cast, as we are only dealing with
   FunctionProtoType Types here.
2021-04-09 11:54:15 +01:00
Xiangling Liao d508561798 [AIX] Support init priority attribute
Differential Revision: https://reviews.llvm.org/D99291
2021-04-08 15:40:09 -04:00
Craig Topper 02ef9963e1 [RISCV] Prevent __builtin_riscv_orc_b_64 from being compiled RV32 target.
The backend can't handle this and will throw a fatal error from
type legalization. It's easy enough to fix that for this intrinsic
by just splitting the IR intrinsic since it works on individual bytes.

There will be other intrinsics in the future that would be harder
to support through splitting, for example grev, gorc, and shfl. Those
would require a compare and a select be inserted to check the MSB of
their control input.

This patch adds support for preventing this in the frontend with
a nice diagnostic.

Reviewed By: frasercrmck

Differential Revision: https://reviews.llvm.org/D99984
2021-04-08 11:34:56 -07:00
Sven van Haastregt 8fcb114d00 [OpenCL] Fix mipmap read_image return types
The return type did not match the function name.
2021-04-08 09:51:44 +01:00
Jennifer Yu ebf2dc3328 Fix missing generate capture expression for novariants condition. 2021-04-07 12:35:49 -07:00
Yaxun (Sam) Liu 61d065e21f Let clang atomic builtins fetch add/sub support floating point types
Recently atomicrmw started to support fadd/fsub:

https://reviews.llvm.org/D53965

However clang atomic builtins fetch add/sub still does not support
emitting atomicrmw fadd/fsub.

This patch adds that.

Reviewed by: John McCall, Artem Belevich, Matt Arsenault, JF Bastien,
James Y Knight, Louis Dionne, Olivier Giroux

Differential Revision: https://reviews.llvm.org/D71726
2021-04-06 15:44:00 -04:00
Erik Pilkington b660abc80d [ObjC] Add a command line flag that disables recognition of objc_direct for testability
Programmers would like to be able to test direct methods by calling them from a
different linkage unit or mocking them, both of which are impossible. This
patch adds a flag that effectively disables the attribute, which will fix this
when enabled in testable builds. rdar://71190891

Differential revision: https://reviews.llvm.org/D95845
2021-04-06 11:17:01 -04:00
Simon Pilgrim 2901dc7575 Don't directly dereference getAs<> casts to avoid potential null dereferences. NFCI.
Replace with castAs<> which asserts the cast is valid.

Fixes a number of static analyzer warnings.
2021-04-06 12:24:19 +01:00
Aaron Ballman 9711118d2e Rework the way statement attributes are processed; NFC
This changes our approach to processing statement attributes to be more
similar to how we process declaration attributes. Namely,
ActOnAttributedStmt() now calls ProcessStmtAttributes() instead of
vice-versa, and there is now an interface split between building an
attributed statement where you already have a list of semantic
attributes and building an attributed statement with attributes from
the parser.

This should make it easier to support statement attributes that are
dependent on a template. In that case, you would add a
TransformFooAttr() function in TreeTransform.h to perform the semantic
checking (morally similar to how Sema::InstantiateAttrs() already works
for declaration attributes) when transforming the semantic attribute at
instantiation time.
2021-04-05 17:52:17 -04:00
Jennifer Yu 7078ef4722 [OPENMP51]Initial support for nocontext clause.
Added basic parsing/sema/serialization support for the 'nocontext' clause.

Differential Revision: https://reviews.llvm.org/D99848
2021-04-05 11:45:49 -07:00
Erik Pilkington 803b79221e [SemaObjC] Fix a -Wbridge-cast false-positive
Clang used to emit a bad -Wbridge-cast diagnostic on the cast in the attached
test. This was because, after 09abecef7, struct __CFString was not added to
lookup, so the objc_bridge attribute wasn't getting duplicated onto the most
recent declaration, causing us to fail to find it in getObjCBridgeAttr. This
patch fixes this by instead walking through the redeclarations to find an
appropriate bridge attribute. rdar://72823399

Differential revision: https://reviews.llvm.org/D99661
2021-04-05 11:41:40 -04:00
Aaron Ballman 4be8a26951 Use tablegen to diagnose mutually exclusive attributes
Currently, when one or more attributes are mutually exclusive, the
developer adding the attribute has to manually emit diagnostics. In
practice, this is highly error prone, especially for declaration
attributes, because such checking is not trivial. Redeclarations
require you to write a "merge" function to diagnose mutually exclusive
attributes and most attributes get this wrong.

This patch introduces a table-generated way to specify that a group of
two or more attributes are mutually exclusive:

def : MutualExclusions<[Attr1, Attr2, Attr3]>;

This works for both statement and declaration attributes (but not type
attributes) and the checking is done either from the common attribute
diagnostic checking code or from within mergeDeclAttribute() when
merging redeclarations.
2021-04-02 16:34:42 -04:00
Jennifer Yu cb424fee3d [OPENMP5.1]Initial support for novariants clause.
Added basic parsing/sema/serialization support for the 'novariants' clause.
2021-04-02 13:19:01 -07:00
Craig Topper be7358df1e Revert "[RISCV] Try using toupper instead of std::toupper to make the build bots happy."
This reverts commit 5311abc7a2.

jrtc27 included the proper header in 1bd4986e7c
while I was trying to figure out what llvm/clang usually used.
2021-04-02 12:30:23 -07:00
Craig Topper 5311abc7a2 [RISCV] Try using toupper instead of std::toupper to make the build bots happy. 2021-04-02 12:29:07 -07:00
Jessica Clarke 1bd4986e7c [Sema] Fix Windows build after b001d574d7 2021-04-02 20:27:58 +01:00
Levy Hsu 944adbf285 Recommit "[RISCV] Add IR intrinsic for Zbb extension"
Forgot to amend the Author.

Original commit message:

Header files are included in a separate patch in case the name needs to be changed.

RV32 / 64:
orc.b

Differential Revision: https://reviews.llvm.org/D99320
2021-04-02 11:50:19 -07:00
Craig Topper 1f0b309f24 Revert "[RISCV] Add IR intrinsic for Zbb extension"
This reverts commit 1808194590.

I forgot to change the author.
2021-04-02 11:47:02 -07:00
Craig Topper 1808194590 [RISCV] Add IR intrinsic for Zbb extension
Header files are included in a separate patch in case the name needs to be changed.

RV32 / 64:
orc.b
2021-04-02 11:23:57 -07:00
Levy Hsu b001d574d7 [RISCV] Add IR intrinsic for Zbr extension
Implementation for RISC-V Zbr extension intrinsic.

Header files are included in separate patch in case the name needs to be changed

RV32 / 64:
        crc32b
        crc32h
        crc32w
        crc32cb
        crc32ch
        crc32cw

RV64 Only:
        crc32d
        crc32cd

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D99009
2021-04-02 10:58:45 -07:00
Aaron Ballman 3ebfa363f3 Remove attribute handling code for simple attributes; NFC
Attributes that set the SimpleHandler flag in Attr.td don't need to be
explicitly handled in SemaDeclAttr.cpp.
2021-04-02 11:35:10 -04:00
Marek Kurdej 2ec7f639c4 [clang-cl] [Sema] Do not prefer integral conversion over floating-to-integral for MS compatibility 19.28 and higher.
As of MSVC 19.28 (2019 Update 8), integral conversion is no longer preferred over floating-to-integral, and so MSVC is more standard conformant and will generate a compiler error on ambiguous call.
Cf. https://godbolt.org/z/E8xsdqKsb.
Initially found during the review of D99641.

Reviewed By: rnk

Differential Revision: https://reviews.llvm.org/D99663
2021-04-02 08:58:22 +02:00
cchen cba422264c [OpenMP51] Accept `primary` as proc bind affinity policy in Clang
Reviewed By: ABataev

Differential Revision: https://reviews.llvm.org/D99622
2021-04-01 18:07:12 -05:00
Anton Bikineev dc7ebd2cb0 [C++2b] Support size_t literals
This adds support for C++2b's z/uz suffixes for size_t literals (P0330).
2021-03-31 13:36:23 +00:00
Sven van Haastregt b5995fced4 [OpenCL] Limit popcount to OpenCL 1.2 and above
s6.15.3 of the OpenCL C Specification v3.0.6 states that OpenCL 1.2 or
newer is required.
2021-03-31 09:54:18 +01:00
Ta-Wei Tu 99fd066227 [clang][Sema] Don't try to initialize implicit variable of invalid anonymous union/struct
This fixes https://bugs.llvm.org/show_bug.cgi?id=49534, where the call to the constructor
of the anonymous union is checked and triggers assertion failure when trying to retrieve
the alignment of the `this` argument (which is a union with virtual function).

The extra check for alignment was introduced in D97187.

Reviewed By: tmatheson

Differential Revision: https://reviews.llvm.org/D98548
2021-03-31 09:05:45 +08:00
Mike Rice b7899ba0e8 [OPENMP51]Initial support for the dispatch directive.
Added basic parsing/sema/serialization support for dispatch directive.

Differential Revision: https://reviews.llvm.org/D99537
2021-03-30 14:12:53 -07:00
Matheus Izvekov 3ad6dd5d8f [clang] Use decltype((E)) for compound requirement type constraint
See PR45088.

Compound requirement type constraints were using decltype(E) instead of
decltype((E)), as per `[expr.prim.req]p1.3.3`.

Since neither instantiation nor type dependence should matter for
the constraints, this uses an approach where a `decltype` type is not built,
and just the canonical type of the expression after template instantiation
is used on the requirement.

Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>

Reviewed By: rsmith

Differential Revision: https://reviews.llvm.org/D98160
2021-03-30 22:00:33 +02:00
Alexey Bataev 1696b8ae96 [OPENMP]Fix PR48740: OpenMP declare reduction in C does not require an initializer
If no initializer-clause is specified, the private variables will be
initialized following the rules for initialization of objects with static
storage duration.

Need to adjust the implementation to the current version of the
standard.

Differential Revision: https://reviews.llvm.org/D99539
2021-03-30 05:38:20 -07:00
Richard Smith 622f8de4f2 PR49724: Fix deduction of null member pointers.
Previously we created an implicit cast of the wrong kind, which we'd
later fail to constant-evaluate, resulting in deduction failure.
2021-03-25 13:47:22 -07:00
Yaxun (Sam) Liu cc9477166a [CUDA][HIP] add __builtin_get_device_side_mangled_name
Add builtin function __builtin_get_device_side_mangled_name
to get device side manged name for functions and global
variables, which can be used to get symbol address of kernels
or variables by mangled name in dynamically loaded
bundled code objects at run time.

Reviewed by: Artem Belevich

Differential Revision: https://reviews.llvm.org/D99301
2021-03-25 15:25:29 -04:00
Yuanfang Chen 217f0f735a [Clang][Sema] Implement GCC -Wcast-function-type
```
Warn when a function pointer is cast to an incompatible function
pointer. In a cast involving function types with a variable argument
list only the types of initial arguments that are provided are
considered. Any parameter of pointer-type matches any other
pointer-type. Any benign differences in integral types are ignored, like
int vs. long on ILP32 targets. Likewise type qualifiers are ignored. The
function type void (*) (void) is special and matches everything, which
can be used to suppress this warning. In a cast involving pointer to
member types this warning warns whenever the type cast is changing the
pointer to member type. This warning is enabled by -Wextra.
```

Reviewed By: rsmith

Differential Revision: https://reviews.llvm.org/D97831
2021-03-24 16:04:18 -07:00
Nathan James 279ea930fa
[clang] Add fixit for Wreorder-ctor
Create fix-it hints to fix the order of constructors.
To make this a lot simpler, I've grouped all the warnings for each out of order initializer into 1.
This is necessary as fixing one initializer would often interfere with other initializers.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D98745
2021-03-24 19:22:53 +00:00
Aaron Puchert a6a1c3051d Fix false negative in -Wthread-safety-attributes
The original implementation didn't fire on non-template classes when a
base class was an instantiation of a template with a dependent base.
In that case the base of the base is dependent as seen from the base,
but not from the class we're interested in, which isn't a template.

Also it simplifies the code a lot.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D98724
2021-03-24 17:45:25 +01:00
Arthur O'Dwyer 5f1de9cab1 [C++20] [P1825] Fix bugs with implicit-move from variables of reference type.
Review D88220 turns out to have some pretty severe bugs, but I *think*
this patch fixes them.

Paper P1825 is supposed to enable implicit move from "non-volatile objects
and rvalue references to non-volatile object types." Instead, what was committed
seems to have enabled implicit move from "non-volatile things of all kinds,
except that if they're rvalue references then they must also refer to non-volatile
things." In other words, D88220 accidentally enabled implicit move from
lvalue object references (super yikes!) and also from non-object references
(such as references to functions).

These two cases are now fixed and regression-tested.

Differential Revision: https://reviews.llvm.org/D98971
2021-03-23 14:12:06 -04:00
Kadir Cetinkaya 8f80c66bd2
[clang] Fix a crash when CTAD fails
Differential Revision: https://reviews.llvm.org/D99145
2021-03-23 13:03:30 +01:00
Joshua Haberman c3134d7c44 [clang] Replaced some manual pointer tagging with llvm::PointerIntPair.
There is no functional change here (hence no new tests). The only change
is to replace a couple uintptr_t members with llvm::PointerIntPair<> to
clean up the code, making it more readable and less error prone.

This cleanup highlighted that the old code was effectively casting away
const. This is fixed by changing some function signatures.

Reviewed By: rsmith

Differential Revision: https://reviews.llvm.org/D98889
2021-03-22 14:13:42 -07:00
Sven van Haastregt 2bbc9bccf0 [OpenCL] Support template parameters for as_type
Implement the TreeTransform for AsTypeExpr.  Split `BuildAsTypeExpr`
out of `ActOnAsTypeExpr`, such that we can call the Build method from
the TreeTransform.

Fixes PR47979.

Differential Revision: https://reviews.llvm.org/D98855
2021-03-22 11:59:05 +00:00
Aaron Ballman fa4e72971e Automate common diagnostic checking for statement attributes
Clang currently automates a fair amount of diagnostic checking for
declaration attributes based on the declarations in Attr.td. It checks
for things like subject appertainment, number of arguments, language
options, etc. This patch uses the same machinery to perform diagnostic
checking on statement attributes.
2021-03-19 08:35:38 -04:00
Mike Rice c2f8e158f5 [OPENMP51]Support for the 'destroy' clause with interop variable.
Added basic parsing/sema/serialization support to extend the
existing 'destroy' clause for use with the 'interop' directive.

Differential Revision: https://reviews.llvm.org/D98834
2021-03-18 09:12:56 -07:00
Sven van Haastregt c5c4a88a84 [OpenCL] Remove spurious atomic_fetch tablegen builtins
The `int` and `long` versions of these builtins already provide the
necessary overloads for `intptr_t` and `uintptr_t` arguments, as
`ASTContext` defines `atomic_(u)intptr_t` in terms of the `int` or
`long` types.

Prior to this patch, calls to those builtins with particular argument
types resulted in call-is-ambiguous errors.

Differential Revision: https://reviews.llvm.org/D98520
2021-03-18 12:17:12 +00:00
Elizabeth Andrews d8b8f544d9 [Reland] "Do not apply calling conventions to MSVC entry points"
This patch is a second attempt at fixing a link error for MSVC
entry points when calling conventions are specified using a flag.

Calling conventions specified using flags should not be applied to MSVC
entry points. The default calling convention is set in this case. The
default calling convention for MSVC entry points main and wmain is cdecl.
For WinMain, wWinMain and DllMain, the default calling convention is
stdcall on 32 bit Windows.

Explicitly specified calling conventions are applied to MSVC entry points.

For MinGW, the default calling convention for all MSVC entry points is
cdecl.

First attempt: 4cff1b40da
Revert of first attempt: bebfc3b92d

Differential Revision: https://reviews.llvm.org/D97941
2021-03-18 04:26:47 -07:00
Valeriy Savchenko f1a7d5a7b0 [-Wcalled-once-parameter] Harden analysis in terms of block use
This patch introduces a very simple inter-procedural analysis
between blocks and enclosing functions.

We always analyze blocks first (analysis is done as part of semantic
analysis that goes side-by-side with the parsing process), and at the
moment of reporting we don't know how that block will be actually
used.

This patch introduces new logic delaying reports of the "never called"
warnings on blocks.  If we are not sure that the block will be called
exactly once, we shouldn't warn our users about that.  Double calls,
however, don't require such delays.  While analyzing the enclosing
function, we can actually decide what we should do with those
warnings.

Additionally, as a side effect, we can be more confident about blocks
in such context and can treat them not as escapes, but as direct
calls.

rdar://74090107

Differential Revision: https://reviews.llvm.org/D98688
2021-03-18 12:12:18 +03:00
Richard Smith a875721d8a PR49585: Emit the jump destination for a for loop 'continue' from within the scope of the condition variable.
The condition variable is in scope in the loop increment, so we need to
emit the jump destination from wthin the scope of the condition
variable.

For GCC compatibility (and compatibility with real-world 'FOR_EACH'
macros), 'continue' is permitted in a statement expression within the
condition of a for loop, though, so there are two cases here:

* If the for loop has no condition variable, we can emit the jump
  destination before emitting the condition.

* If the for loop has a condition variable, we must defer emitting the
  jump destination until after emitting the variable. We diagnose a
  'continue' appearing in the initializer of the condition variable,
  because it would jump past the initializer into the scope of that
  variable.

Reviewed By: rjmccall

Differential Revision: https://reviews.llvm.org/D98816
2021-03-17 16:24:04 -07:00
Mike Rice c615927c8e [OPENMP51]Initial support for the use clause.
Added basic parsing/sema/serialization support for the 'use' clause.

Differential Revision: https://reviews.llvm.org/D98815
2021-03-17 15:46:14 -07:00
Mike Rice 410f09af09 [OPENMP51]Initial support for the interop directive.
Added basic parsing/sema/serialization support for interop directive.
Support for the 'init' clause.

Differential Revision: https://reviews.llvm.org/D98558
2021-03-17 09:42:07 -07:00
Vassil Vassilev 0cb7e7ca0c Make iteration over the DeclContext::lookup_result safe.
The idiom:
```
DeclContext::lookup_result R = DeclContext::lookup(Name);
for (auto *D : R) {...}
```

is not safe when in the loop body we trigger deserialization from an AST file.
The deserialization can insert new declarations in the StoredDeclsList whose
underlying type is a vector. When the vector decides to reallocate its storage
the pointer we hold becomes invalid.

This patch replaces a SmallVector with an singly-linked list. The current
approach stores a SmallVector<NamedDecl*, 4> which is around 8 pointers.
The linked list is 3, 5, or 7. We do better in terms of memory usage for small
cases (and worse in terms of locality -- the linked list entries won't be near
each other, but will be near their corresponding declarations, and we were going
to fetch those memory pages anyway). For larger cases: the vector uses a
doubling strategy for reallocation, so will generally be between half-full and
full. Let's say it's 75% full on average, so there's N * 4/3 + 4 pointers' worth
of space allocated currently and will be 2N pointers with the linked list. So we
break even when there are N=6 entries and slightly lose in terms of memory usage
after that. We suspect that's still a win on average.

Thanks to @rsmith!

Differential revision: https://reviews.llvm.org/D91524
2021-03-17 08:59:04 +00:00
Aaron Puchert 1cb15b10ea Correct Doxygen syntax for inline code
There is no syntax like {@code ...} in Doxygen, @code is a block command
that ends with @endcode, and generally these are not enclosed in braces.
The correct syntax for inline code snippets is @c <code>.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D98665
2021-03-16 15:17:45 +01:00
Sam McCall 128ce70eef [CodeCompletion] Avoid spurious signature help for init-list args
Somewhat surprisingly, signature help is emitted as a side-effect of
computing the expected type of a function argument.
The reason is that both actions require enumerating the possible
function signatures and running partial overload resolution, and doing
this twice would be wasteful and complicated.

Change #1: document this, it's subtle :-)

However, sometimes we need to compute the expected type without having
reached the code completion cursor yet - in particular to allow
completion of designators.
eb4ab3358c did this but introduced a
regression - it emits signature help in the wrong location as a side-effect.

Change #2: only emit signature help if the code completion cursor was reached.

Currently there is PP.isCodeCompletionReached(), but we can't use it
because it's set *after* running code completion.
It'd be nice to set this implicitly when the completion token is lexed,
but ConsumeCodeCompletionToken() makes this complicated.

Change #3: call cutOffParsing() *first* when seeing a completion token.

After this, the fact that the Sema::Produce*SignatureHelp() functions
are even more confusing, as they only sometimes do that.
I don't want to rename them in this patch as it's another large
mechanical change, but we should soon.

Change #4: prepare to rename ProduceSignatureHelp() to GuessArgumentType() etc.

Differential Revision: https://reviews.llvm.org/D98488
2021-03-16 12:46:40 +01:00
Sam McCall a92693dac4 [CodeCompletion] Don't track preferred types if code completion is disabled.
Some of this work isn't quite trivial.

(As requested in D96058)

Differential Revision: https://reviews.llvm.org/D98459
2021-03-16 12:16:10 +01:00
Matheus Izvekov d4a8c7359b [clang] Fix ICE on invalid type parameters for concepts
See PR48593.

Constraints with invalid type parameters were causing a null pointer
dereference.

Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>

Reviewed By: rsmith

Differential Revision: https://reviews.llvm.org/D98095
2021-03-13 01:23:02 +01:00
Matheus Izvekov c9fd92d573 [clang] Improve diagnostics on implicitly deleted defaulted comparisons
This patch just makes the error message clearer by reinforcing the cause
was a lack of viable **three-way** comparison function for the
**complete object**.

Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>

Reviewed By: rsmith

Differential Revision: https://reviews.llvm.org/D97990
2021-03-13 01:13:52 +01:00
Anton Zabaznov 840643bbe1 [OpenCL] Refactor diagnostic for OpenCL extension/feature
There is no need to check for enabled pragma for core or optional core features,
thus this check is removed

Reviewed By: Anastasia

Differential Revision: https://reviews.llvm.org/D97058
2021-03-12 11:43:53 +03:00
Florian Hahn c92ec0dd92
[Matrix] Add support for matrix-by-scalar division.
This patch extends the matrix spec to allow matrix-by-scalar division.

Originally support for `/` was left out to avoid ambiguity for the
matrix-matrix version of `/`, which could either be elementwise or
specified as matrix multiplication M1 * (1/M2).

For the matrix-scalar version, no ambiguity exists; `*` is also
an elementwise operation in that case. Matrix-by-scalar division
is commonly supported by systems including Matlab, Mathematica
or NumPy.

Reviewed By: rjmccall

Differential Revision: https://reviews.llvm.org/D97857
2021-03-11 22:21:23 +00:00
Simon Pilgrim df2a6ee324 [Sema] Use castAs<> instead getAs<> for dereferenced pointer casts. NFCI.
getAs<> returns null for missed casts, resulting in null dereferences - use castAs<> instead which will assert the cast is correct.
2021-03-11 14:51:25 +00:00
Nathan James cb559c8d5e
[Sema] Add some basic lambda capture fix-its
Adds fix-its when users forget to explicitly capture variables or this in lambdas

Addresses https://github.com/clangd/clangd/issues/697

Reviewed By: kbobyrev

Differential Revision: https://reviews.llvm.org/D96975
2021-03-11 13:46:25 +00:00
Sven van Haastregt dcdd476c46 [OpenCL] Add missing atomic_xchg overload 2021-03-11 10:20:29 +00:00
zoecarver a89ac0dd18 Update __is_unsigned builtin to match the Standard.
Updates __is_unsigned to have the same behavior as the standard
specifies. This is in line with 511dbd8, which applied the same change
to __is_signed.

Refs D67897.

Differential Revision: https://reviews.llvm.org/D98104
2021-03-10 15:00:26 -08:00
Sven van Haastregt 6f912a2cd4 [OpenCL] Set calling convention for -fdeclare-opencl-builtins
IR produced using TableGen builtin function declarations
(`fdeclare-opencl-builtins.cl`) did not have the target's calling
convention applied to builtin calls.

Fix this, and update the codegen test to check that IR produced using
opencl-c.h and `-fdeclare-opencl-builtins` is identical with respect
to the builtin calls.

Differential Revision: https://reviews.llvm.org/D98039
2021-03-10 10:03:57 +00:00
Alex Lorenz 2de0a18a89 [clang][ObjC] allow the use of NSAttributedString * return type with format_arg attribute
This is useful for APIs that want to produce an attributed NSString as a result of
some formatting API call.
2021-03-09 13:36:57 -08:00
Aaron Ballman 8bb8d65e16 Move some attribute diagnostic helper functions; NFC.
These functions were local to SemaDeclAttr.cpp, but these functions are
useful in general (for instance, for statement or type attribute
processing). This refactoring is in advance of beginning to tablegen
diagnostic checks for statement attributes the way we already do for
declaration attributes.

There is one functional change in here as a drive-by. The
external_source_symbol attribute had one of its diagnostic checks
inside of an assert, which was corrected.
2021-03-09 14:57:00 -05:00
Adam Czachorowski 4e1c487004 [clang] Fix crash when creating deduction guide.
We used to trigger assertion when transforming c-tor with unparsed
default argument. Now we ignore such constructors for this purpose.

Differential Revision: https://reviews.llvm.org/D97965
2021-03-09 16:57:56 +01:00
Anton Bikineev 4f8e299785 [Sema] Fix diagnostics for one-byte length modifier
In case a char-literal of type int (C/ObjectiveC) corresponds to a
format specifier with the %hh length modifier, don't treat the literal
as of type char for issuing diagnostics, as otherwise this results in:

printf("%hhd", 'e');
warning: format specifies type 'char' but the argument has type 'char'.

Differential revision: https://reviews.llvm.org/D97951
2021-03-09 16:56:20 +01:00
Timm Bäder 272bcd0eef [clang][sema][NFC] Remove a superfluous semicolon
Silences a GCC warning:

clang/lib/Sema/SemaChecking.cpp:4506:2: warning: extra ‘;’ [-Wpedantic]
 };
  ^
2021-03-09 16:14:07 +01:00
Florian Hahn fc8d3766d7
[ExtVectorType] Support conditional select operator for C++.
This patch implements the conditional select operator for
ext_vector_types in C++. It does so by using the same semantics as for
C.

D71463 added support for the conditional select operator for VectorType
in C++. Unfortunately the semantics between ext_vector_type in C are
different to VectorType in C++. Select for ext_vector_type is based on
the MSB of the condition vector, whereas for VectorType it is `!= 0`.

This unfortunately means that the behavior is inconsistent between
ExtVectorType and VectorType, but I think using the C semantics for
ExtVectorType in C++ as well should be less surprising for users.

Reviewed By: erichkeane, aaron.ballman

Differential Revision: https://reviews.llvm.org/D98055
2021-03-09 13:08:52 +00:00
Sven van Haastregt 13c77f2046 [OpenCL] Fix builtins that require multiple extensions
Builtins that require multiple extensions, such as certain
`write_imagef` forms, were not exposed because of the Sema check not
splitting the extension string.

Differential Revision: https://reviews.llvm.org/D97930
2021-03-09 11:37:26 +00:00
Tomas Matheson 7e5cea5b50 [Clang][Sema] Warn when function argument is less aligned than parameter
See https://bugs.llvm.org/show_bug.cgi?id=42154.

GCC's __attribute__((align)) can reduce the alignment of a type when applied to
a typedef.  However, functions which take a pointer or reference to the
original type are compiled assuming the original alignment.  Therefore when any
such function is passed an object of the new, less-aligned type, an alignment
fault can occur.  In particular, this applies to the constructor, which is
defined for the original type and called for the less-aligned object.

This change adds a warning whenever an pointer or reference to an object is
passed to a function that was defined for a more-aligned type.

The calls to ASTContext::getTypeAlignInChars seem change the order in which
record layouts are evaluated, which caused changes to the output of
-fdump-record-layouts. As such some tests needed to be updated:

  * Use CHECK-LABEL rather than counting the number of "Dumping AST Record
    Layout" headers.

  * Check for end of line in labels, so that struct B1 doesn't match struct B
    etc.

  * Add --strict-whitespace, since the whitespace shows meaningful structure.

  * The order in which record layouts are printed has changed in some cases.

  * clang-format for regions changed

Differential Revision: https://reviews.llvm.org/D97187
2021-03-09 10:37:32 +00:00
Min-Yih Hsu 5eb7a5814a [cfe][M68k](7/8) Clang basic support
This is the first patch supporting M68k in Clang
 - Register M68k as a target
 - Target specific CodeGen support
 - Target specific attribute support

Authors: myhsu, m4yers, glaubitz

Differential Revision: https://reviews.llvm.org/D88393
2021-03-08 12:30:57 -08:00
Saurabh Jha 63851a701e
[Matrix] Implement += and -= for MatrixType.
Make sure CompLHSTy is set correctly for += and -= and matrix type
operands.

Bugzilla ticket is here https://bugs.llvm.org/show_bug.cgi?id=46164

Patch by Saurabh Jha <saurabh.jhaa@gmail.com>

Reviewed By: fhahn

Differential Revision: https://reviews.llvm.org/D98075
2021-03-08 09:32:11 +00:00
Matheus Izvekov 71e6e82746 [clang] Fix constrained decltype(auto) deduction
Prior to this fix, constrained decltype(auto) behaves exactly the same
as constrained regular auto.
This fixes it so it deduces like decltype(auto).

Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>

Reviewed By: rsmith

Differential Revision: https://reviews.llvm.org/D98087
2021-03-05 18:20:09 -08:00
Richard Smith abbe42d8b5 PR49260: Improve diagnostics for no matching 'operator new'.
Fix duplicate diagnostic for an over-aligned allocation with no matching
function, and add custom diagnostic for the case where the
non-allocating placement new was intended but <new> was not included.
2021-03-05 15:53:10 -08:00
PremAnand Rao c2de5aff1a [OpenMP] Handle non-function context before checking for diagnostic
emission

Ensure that we are in a function declaration context before checking
the diagnostic emission status, to avoid dereferencing a NULL function
declaration.

Differential Revision: https://reviews.llvm.org/D97573
2021-03-05 12:37:49 -08:00
Simon Pilgrim ed951293af Fix Wdocumentation unknown parameter warning. NFCI. 2021-03-05 15:58:20 +00:00