Commit Graph

96532 Commits

Author SHA1 Message Date
Jonathan Camilleri 4cd7529e4c [clang][DebugInfo] Emit access specifiers for typedefs
The accessibility level of a typedef or using declaration in a
struct or class was being lost when producing debug information.

Reviewed By: dblaikie

Differential Revision: https://reviews.llvm.org/D134339
2022-09-22 17:08:41 +00:00
Aaron Ballman 9018fa1745 Update the C status page for WG14 N2359
We don't yet implement this paper, so this adds a basic test
demonstrating that.
2022-09-22 13:05:49 -04:00
Anastasia Stulova db664a666c [Doc][OpenCL] Fixed typos in code examples 2022-09-22 17:46:47 +01:00
Joe Loser cf77333da9 [clang][docs] Fix supported element types for __builtin_reduce_(add|mul)
The docs mention that `__builtin_reduce_add` and `__builtin_reduce_mul` support
both integer and floating point element types, but only integer element types
are actually supported. See https://github.com/llvm/llvm-project/issues/57847,
and specifically,
00874c48ea/clang/lib/Sema/SemaChecking.cpp (L2631) for the fact that floating point element types are not supported yet.

Fix the docs to only mention support for integer element types.
2022-09-22 07:52:22 -06:00
Erich Keane babdef27c5 Re-apply "Deferred Concept Instantiation Implementation"
This reverts commit 95d94a6775.

This implements the deferred concepts instantiation, which should allow
the libstdc++ ranges to properly compile, and for the CRTP to work for
constrained functions.

Since the last attempt, this has fixed the issues from @wlei and
@mordante.

Differential Revision: https://reviews.llvm.org/D126907
2022-09-22 05:53:59 -07:00
Haojian Wu e0cdafe8d4 [AST] Better recovery on an expression refers to an invalid decl.
Prior to the patch, we didn't build a DeclRefExpr if the Decl being
referred to is invalid, because many clang downstream AST consumers
assume it, violating it will cause many diagnostic regressions.

With this patch, we build a DeclRefExpr enven for an invalid decl (when the
AcceptInvalidDecl is true), and wrap it with a dependent-type
RecoveryExpr (to prevent follow-up semantic analysis, and diagnostic
regressions).

This is a revised version of https://reviews.llvm.org/D76831

Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D121599
2022-09-22 14:23:47 +02:00
serge-sans-paille dad36245a5 [clang] Rework IsTailPaddedMemberArray into isFlexibleArrayMemberExpr
This fixes a bunch of FIXME within IsTailPaddedMemberArray related code.

As a side effect, this now also triggers a warning when trying to access a
"struct hack" member with an index above address space index range.

Differential Revision: https://reviews.llvm.org/D133108
2022-09-22 14:04:35 +02:00
Tim Northover 677da09d02 AArch64: add support for newer Apple CPUs
They're roughly ARMv8.6. This works in the .td file, but in
AArch64TargetParser.def, marking them v8.6 brings in support for the SM4
cryptographic hash and we don't actually have that. So TargetParser side
they're marked as v8.5, with the extra features (BF16 and I8MM added manually).

Finally, A16 supports the HCX extension in addition to v8.6. This has no
TargetParser implications.
2022-09-22 11:58:51 +01:00
serge-sans-paille d442040292 [clang] Fix interaction between asm labels and inline builtins
One must pick the same name as the one referenced in CodeGenFunction when
generating .inline version of an inline builtin, otherwise they are not
correctly replaced.

Differential Revision: https://reviews.llvm.org/D134362
2022-09-22 09:24:47 +02:00
Craig Topper 182aa0cbe0 [RISCV] Remove support for the unratified Zbp extension.
This extension does not appear to be on its way to ratification.

Still need some follow up to simplify the RISCVISD nodes.
2022-09-21 21:22:42 -07:00
Chuanqi Xu 327141fb1d [C++] [Coroutines] Prefer aligned (de)allocation for coroutines -
implement the option2 of P2014R0

This implements the option2 of
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p2014r0.pdf.

This also fixes https://github.com/llvm/llvm-project/issues/56671.

Although wg21 didn't get consensus for the direction of the problem,
we're happy to have some implementation and user experience first. And
from issue56671, the option2 should be the pursued one.

Reviewed By: ychen

Differential Revision: https://reviews.llvm.org/D133341
2022-09-22 11:28:29 +08:00
Corentin Jabot c932cef32a Update Unicode to 15.0
Unicode 15.0 adds 4,489 characters, for a total of 149,186 characters.
These additions include 2 new scripts along with 20 new emoji characters,
and 4,193 CJK ideographs.

This changes modify most existing tables including
 - XID_Start/XID_Continue in Clang
 - The character name database (used by \N{} in Clang)
 - The list of formattable/printable codepoints
 - The case folding algorithm (which we had not updated since Unicode 9)
 - The list of nonspacing/enclosing marks used by the column width
   computation algorithm. The rest of the column width algorithm
   is not updated.

Reviewed By: tahonermann

Differential Revision: https://reviews.llvm.org/D133807
2022-09-22 05:03:01 +02:00
Jan Korous 85d97aac80 [analyzer] Support implicit parameter 'self' in path note
showBRParamDiagnostics assumed stores happen only via function parameters while that
can also happen via implicit parameters like 'self' or 'this'.
The regression test caused a failed assert in the original cast to ParmVarDecl.

Differential Revision: https://reviews.llvm.org/D133815
2022-09-21 17:26:09 -07:00
Fangrui Song 8edeedfb21 [test] Fix CodeGen/arm-crc32.c to not write an output to CWD
CWD may be read-only in some testing environments.
2022-09-21 16:13:25 -07:00
Michael Wyman aa4bcaab96 Remove the unused/undefined `_cmd` parameter in `objc_direct` methods.
When `objc_direct` methods were implemented, the implicit `_cmd` parameter was left as an argument to the method implementation function, but was unset by callers; if the method body referenced the `_cmd` variable, a selector load would be emitted inside the body. However, this leaves an unused argument in the ABI, and is unnecessary.

This change removes the empty/unset argument, and if `_cmd` is referenced inside an `objc_direct` method it will emit local storage for the implicit variable. From the ABI perspective, `objc_direct` methods will have the implicit `self` parameter, immediately followed by whatever explicit arguments are defined on the method, rather than having one unset/undefined register in the middle.

Differential Revision: https://reviews.llvm.org/D131424
2022-09-21 15:37:48 -07:00
Fangrui Song 23e4299261 [Driver] Add --gcc-install-dir=
This option specifies a GCC installation directory such as
/usr/lib/gcc/x86_64-linux-gnu/12, /usr/lib/gcc/x86_64-gentoo-linux-musl/11.2.0 .

It is intended to replace --gcc-toolchain=, which specifies a directory where
`lib/gcc{,-cross}` can be found. When --gcc-toolchain= is specified, the
selected `lib/gcc/$triple/$version` installation uses complex logic and the
largest GCC version is picked. There is no way to specify another version in the
presence of multiple GCC versions.

D25661 added gcc-config detection for Gentoo: `ScanGentooConfigs`.
The implementation may be simplified by using --gcc-install-dir=.

Reviewed By: mgorny

Differential Revision: https://reviews.llvm.org/D133329
2022-09-21 14:11:15 -07:00
owenca e347c0fc9b [clang-format][NFC] Reformat the clang/unittests/Format directory
Also add a .clang-format file to clang/include/clang/Format and
clang/unittests/Format to keep the directories formatted.
2022-09-21 13:26:59 -07:00
Evgeny Shulgin 3285f9a239 [Clang] Support case and default labels at end of compound statement
Direct continuation of https://reviews.llvm.org/D133887

Reviewed By: #clang-language-wg, aaron.ballman

Differential Revision: https://reviews.llvm.org/D134207
2022-09-21 19:37:22 +00:00
Aaron Ballman b63b4d8966 Add tests & update the C99 DR statuses for dr315 and dr316 2022-09-21 15:33:03 -04:00
Xiang Li 52d7ce0cc1 [HLSL] Allow SV_GroupIndex for lib profile.
Lib profile could include all kind of entry functions.

Reviewed By: beanz

Differential Revision: https://reviews.llvm.org/D134326
2022-09-21 12:29:58 -07:00
owenca 3d62139862 [clang-format][NFC] Reformat clang/lib/Format using 6257832bf9
Fix braces and add .clang-format to keep the directory formatted.

Differential Revision: https://reviews.llvm.org/D134329
2022-09-21 12:02:49 -07:00
Aaron Ballman 1ae5310ebb Changing some strange code into an assert; NFC
This code was added in b65b1f322b, but it
was not noticed that the [[fallthrough]] behavior was very wrong. In C
mode, we would set the ParenExprType to CompoundLiteral and then
promptly overwrite that information by falling through.

After some investigation, I convinced myself that it is not possible to
hit this code path in C, only in C++. I've switched it to be an
assertion; I don't expect to hit it, but if we do hit it, that will at
least give us a code example we can use to reason about the intent of
the original code.
2022-09-21 14:59:51 -04:00
Fangrui Song efd97c716b [libclang] Fix -Wswitch after D129883 2022-09-21 11:55:14 -07:00
Fangrui Song 069ecd0c6e [ARM] Check target feature support for __builtin_arm_crc*
`__builtin_arm_crc*` requires the target feature crc which is available on armv8
and above. Calling the fuctions for armv7 leads to a SelectionDAG crash.

```
% clang -c --target=armv7-unknown-linux-gnueabi -c a.c
fatal error: error in backend: Cannot select: intrinsic %llvm.arm.crc32b
PLEASE submit a bug report to ...
```

Add `TARGET_BUILTIN` and define required features for these builtins to
report an error in `CodeGenFunction::checkTargetFeatures`. The problem is quite widespread.
I will add `TARGET_BUILTIN` for more builtins later.

Fix https://github.com/llvm/llvm-project/issues/57802

Differential Revision: https://reviews.llvm.org/D134127
2022-09-21 11:50:15 -07:00
Xiang Li a7e3de2450 [NFC] Fix build error ignored by MSVC. 2022-09-21 10:57:43 -07:00
Xiang Li 782ac2182c [HLSL] Support cbuffer/tbuffer for hlsl.
This is first part for support cbuffer/tbuffer.

The format for cbuffer/tbuffer is
BufferType [Name] [: register(b#)] { VariableDeclaration [: packoffset(c#.xyzw)]; ... };

More details at https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-constants

New keyword 'cbuffer' and 'tbuffer' are added.
New AST node HLSLBufferDecl is added.
Build AST for simple cbuffer/tbuffer without attribute support.

The special thing is variables declared inside cbuffer is exposed into global scope.
So isTransparentContext should return true for HLSLBuffer.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D129883
2022-09-21 10:07:43 -07:00
Akira Hatanaka adaf62ced2 [Sema] Reject array element types whose sizes aren't a multiple of their
alignments

In the following code, the first element is aligned on a 16-byte
boundary, but the remaining elements aren't:

```
typedef char int8_a16 __attribute__((aligned(16)));
int8_a16 array[4];
```

Currently clang doesn't reject the code, but it should since it can
cause crashes at runtime. This patch also fixes assertion failures in
CodeGen caused by the changes in https://reviews.llvm.org/D123649.

Differential Revision: https://reviews.llvm.org/D133711
2022-09-21 09:15:03 -07:00
Joel E. Denny 28412d1800 [lit] Implement DEFINE and REDEFINE directives
These directives define per-test lit substitutions.  The concept was
discussed at
<https://discourse.llvm.org/t/iterating-lit-run-lines/62596/10>.

For example, the following directives can be inserted into a test file
to define `%{cflags}` and `%{fcflags}` substitutions with empty
initial values, which serve as the parameters of another newly defined
`%{check}` substitution:

```
// DEFINE: %{cflags} =
// DEFINE: %{fcflags} =

// DEFINE: %{check} = %clang_cc1 %{cflags} -emit-llvm -o - %s | \
// DEFINE:            FileCheck %{fcflags} %s
```

The following directives then redefine the parameters before each use
of `%{check}`:

```
// REDEFINE: %{cflags} = -foo
// REDEFINE: %{fcflags} = -check-prefix=FOO
// RUN: %{check}

// REDEFINE: %{cflags} = -bar
// REDEFINE: %{fcflags} = -check-prefix=BAR
// RUN: %{check}
```

Of course, `%{check}` would typically be more elaborate, increasing
the benefit of the reuse.

One issue is that the strings `DEFINE:` and `REDEFINE:` already appear
in 5 tests.  This patch adjusts those tests not to use those strings.
Our prediction is that, in the vast majority of cases, if a test
author mistakenly uses one of those strings for another purpose, the
text appearing after the string will not happen to have the syntax
required for these directives.  Thus, the test author will discover
the mistake immediately when lit reports the syntax error.

This patch also expands the documentation on existing lit substitution
behavior.

Reviewed By: jhenderson, MaskRay, awarzynski

Differential Revision: https://reviews.llvm.org/D132513
2022-09-21 11:32:05 -04:00
Chris Bieneman bc97751a23 [NFC] Add GitHub issues to HLSL FIXME comments
In order to make this easier to track I've filed issues for each of the
HLSL FIXME comments that I can find. I may have missed some, but I want
this to be the new default mode.
2022-09-21 10:31:25 -05:00
Anders Langlands bc14ed7de0 Add clang_CXXMethod_isDeleted function
Adds a function to check if a method has been deleted by copy-pasting
the existing implementation of clang_CXXMethod_isDefaulted and changing
it to call CXXMethod::isDeleted() instead.

Differential Revision: https://reviews.llvm.org/D133924
2022-09-21 11:12:48 -04:00
zhijian d47f0be0e8 [AIX] change "llvm-nm" to "env OBJECT_MODE=any llvm-nm" in clang/test for AIX OS
Summary:
   since default object mode of llvm-nm is change to -X32 (from default -Xany) in patch https://reviews.llvm.org/D132494.In order not effect the test cases in clang/test we need to change "llvm-nm" to "env OBJECT_MODE=any llvm-nm" in clang/test for AIX OS

Reviewers: James Henderson,David Tenty, Hubert Tong
Differential Revision: https://reviews.llvm.org/D134284
2022-09-21 09:38:13 -04:00
Matheus Izvekov ef4bbfe338
[clang] AST: SubstTemplateTypeParmType support for non-canonical underlying type
This change allows us to represent in the AST some specific
circumstances where we substitute a template parameter type
which is part of the underlying type of a previous substitution.

This presently happens in some circumstances dealing with
substitution of defaulted parameters of template template
parameters, and in some other cases during concepts substitution.

The main motivation for this change is for the future use in the
implementation of template specialization resugaring, as this will
allow us to represent a substitution with sugared types.

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

Differential Revision: https://reviews.llvm.org/D132816
2022-09-21 14:22:19 +02:00
Michał Górny 8a774c35e9 [clang] [Driver] Support multiple configuration files
Support specifying multiple configuration files via multiple `--config`
options.  When multiple files are specified, the options from subsequent
files are appended to the options from the initial file.

While at it, remove the incorrect assertion about CfgFileName being
non-empty.  It can be empty if `--config ""` is passed, and it makes
sense to report it as non-existing file rather than crash.

Differential Revision: https://reviews.llvm.org/D134270
2022-09-21 13:14:36 +02:00
Wei Yi Tee 94747094c7 [clang][dataflow] Remove deprecated `transfer(const Stmt *, ...)` API.
Reviewed By: gribozavr2

Differential Revision: https://reviews.llvm.org/D134318
2022-09-21 11:06:21 +00:00
Wei Yi Tee 003566cb1f [clang][dataflow] Remove deprecated overloads of `checkDataflow` in `TestingSupport.h`.
Reviewed By: gribozavr2

Differential Revision: https://reviews.llvm.org/D134081
2022-09-21 10:36:44 +00:00
Michał Górny 3db2917e27 [clang] [docs] Improve formatting & fix typo in config docs
Fix teletype formatting in configuration file documentation to use
double backticks rather than single backticks.  Cover some more names
with this formatting.  Correct the name of config file for `clang-cl`
invocation.

Differential Revision: https://reviews.llvm.org/D134271
2022-09-21 07:26:56 +02:00
Jennifer Yu 48ffd40ba2 [Clang][OpenMP] Codegen generation for has_device_addr claues.
This patch add codegen support for the has_device_addr clause. It use
the same logic of is_device_ptr. But passing &var instead pointer to var
to kernal.

Differential Revision: https://reviews.llvm.org/D134268
2022-09-20 21:12:30 -07:00
Craig Topper 70a64fe7b1 [RISCV] Remove support for the unratified Zbt extension.
This extension does not appear to be on its way to ratification.

Out of the unratified bitmanip extensions, this one had the
largest impact on the compiler.

Posting this patch to start a discussion about whether we should
remove these extensions. We'll talk more at the RISC-V sync meeting this
Thursday.

Reviewed By: asb, reames

Differential Revision: https://reviews.llvm.org/D133834
2022-09-20 20:26:48 -07:00
Fangrui Song 669e508772 [Driver] Fix -f[no-]unwind-tables -Wunused-command-line-argument after 4388b56d52 2022-09-20 20:13:30 -07:00
Volodymyr Sapsai e12f6c26c3 [modules] Fix error "malformed or corrupted AST file: 'SourceLocation remap refers to unknown module...'".
When a framework can be found at a new location, all references to it in
the module cache become outdated. When we try to load such outdated .pcm
file, we shouldn't change any already loaded and processed modules.

If `Module` has `ASTFile`, it means we've read its AST block already and
it is too late to undo that. If `ASTFile` is `None`, there is no value
in setting it to `None` again. So we don't reset `ASTFile` in
`ModuleManager::removeModules` at all.

rdar://97216258

Differential Revision: https://reviews.llvm.org/D134249
2022-09-20 17:55:37 -07:00
Kazu Hirata 7a239200e6 [clang] Fix an unused variable warning
This patch fixes:

  clang/lib/Driver/ToolChains/PS4CPU.cpp:159:14: error: unused
  variable 'IsPS5' [-Werror,-Wunused-variable]
2022-09-20 17:41:58 -07:00
Matheus Izvekov c493d49cef
[clang] Fix missing template arguments in AST of access to member variable template
Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>

Differential Revision: https://reviews.llvm.org/D134295
2022-09-21 00:46:18 +02:00
Xiang Li 079a5ffb0a [HLSL] Support PCH for cc1 mode
Add HLSLExternalSemaSource as ExternalSemaSource instead of ASTContext::ExternalSource when PCH is included.

This allows a different external source to be set for the AST context.

Reviewed By: beanz

Differential Revision: https://reviews.llvm.org/D132421
2022-09-20 15:13:43 -07:00
Matthew Voss 45c7da241f [PS4] Always enable the .debug_aranges section when using LTO
This flag enables the .debug_aranges section by passing a flag to LLD
and our internal linker. This also adds a new routine that will generate
the correct flag for our internal linker or set of flags for LLD when
given a list of LLVM options. That ensures multiple LLVM codegen options
can be passed to either linker consistently.

Differential Revision: https://reviews.llvm.org/D134296
2022-09-20 14:44:56 -07:00
Joshua Batista d76c654d02 [HLSL] remove unnecessary abs attributes
remove abs non-elementwise attribute statements, stick to elementwise.

Reviewed By: beanz

Differential Revision: https://reviews.llvm.org/D134312
2022-09-20 16:04:21 -05:00
Joshua Batista b95c57444a [HLSL] add sqrt library function
This change exposes the sqrt library function for HLSL scalar types,
excluding long and long long doubles. Sqrt is supported for all scalar, vector,
and matrix types. This patch only adds a subset of scalar type support.

Long and long long double support is missing in this patch because that type
doesn't exist in HLSL.

The full documentation of the HLSL asin function is available here:
https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-sqrt

Reviewed By: beanz

Differential Revision: https://reviews.llvm.org/D132711
2022-09-20 15:42:08 -05:00
Craig Topper 549231d38e [RISCV] Support -mno-implicit-float.
This can be used to disable vectorization and memcpy/memset
expansion for things like OS kernels. It also disables implicit
uses of scalar FP, but I don't know if we have any of those for
RISC-V.

NOTE: Without this patch you can still do -Xclang -no-implicit-float

Reviewed By: rui.zhang

Differential Revision: https://reviews.llvm.org/D134077
2022-09-20 13:32:40 -07:00
owenca 6257832bf9 [clang-format] Wrap inserted braces only if preceded by comments
Fixes #57805.

Differential Revision: https://reviews.llvm.org/D134233
2022-09-20 12:09:39 -07:00
Douglas Yung f2949febf3 Add explicit tests for the PS4/PS5 C/C++ standards version defaults. 2022-09-20 11:31:38 -07:00
Alex Brachet 16f735d2fb [Driver] Make --execute-only the default for aarch64-fuchsia
Clang already generates code that doesn't use writeable data in executable
sections so the linker flag is all that is necessary.

-Wl,--no-execute-only can be used to turn this default off.

Differential Revision: https://reviews.llvm.org/D134289
2022-09-20 18:25:16 +00:00