Commit Graph

73132 Commits

Author SHA1 Message Date
XDeme
8097a5d37b [clang-format] Fix operator overload inconsistency in BreakAfterAttributes: Always (#74943)
Fixes llvm/llvm-project#74901
2023-12-22 23:02:47 -08:00
Owen Pan
f8f8926054 [clang-format] Fix a bug in annotating function declaration names (#76206)
Annotates function declaration names having unnamed parameters.
2023-12-22 22:51:00 -08:00
smanna12
bbe1b06fbb [NFC][CLANG] Fix static analyzer bugs about unnecessary object copies with auto keyword (#75082)
Reported by Static Analyzer Tool:

In ​EmitAssemblyHelper::​RunOptimizationPipeline(): Using the auto
keyword without an & causes the copy of an object of type function.

 /// List of pass builder callbacks ("CodeGenOptions.h").
std::vector<std::function<void(llvm::PassBuilder &)>>
PassBuilderCallbacks;
2023-12-22 20:39:22 -06:00
Vitaly Buka
2205d2334f Revert "[Sema] Fix crash on invalid code with parenthesized aggregate initialization" (#76272)
Reverts llvm/llvm-project#76232 and
7ab16fb520 to recover build bots.

Breaks libc++ tests, details in #76232

#76228
2023-12-22 15:20:00 -08:00
Kazu Hirata
0e039fc39e [APINotes] Use DenseMap::contains (NFC) 2023-12-22 14:23:25 -08:00
Fangrui Song
dd85c6cce4 [Sema] Add -Wc++11-narrowing-const-reference (#76094)
https://github.com/llvm/llvm-project/pull/75332 diagnosed narrowing
involving const reference. Our depot has hundreds if not thousands of
breakages

(https://github.com/llvm/llvm-project/pull/75332#issuecomment-1864757240).
Add a subgroup of -Wc++11-narrowing to help users gradually fix their
issues without regressing the existing -Wc++11-narrowing diagnostics.
2023-12-22 11:28:07 -05:00
Ilya Biryukov
efeb546865 [clang-format] Add common attribute macros to Google style (#76239)
We have found that 199fc973ce regresses
formatting of our codebases because we do not properly configure the
names of attribute macros.

`GUARDED_BY` and `ABSL_GUARDED_BY` are very commoon in Google codebases
so it is reasonable to include them by default to avoid the need for
extra configuration in every Google repository.
2023-12-22 15:07:43 +01:00
Ilya Biryukov
d03beb9419 [clang-format] Do not break on JS fields like on goto labels (#76233)
This regressions was introduced in
70d7ea0ceb.
The commit moved some code and correctly picked up an explicit check for
not running on Verilog.
However, the moved code also never ran for JavaScript and after the
commit we run it there and
this causes the wrong formatting of:

```js
export type Params = Config&{
  columns: Column[];
};
```
into
```js
export type Params = Config&{
columns:
  Column[];
};
```
2023-12-22 14:41:38 +01:00
Ilya Biryukov
86dc6e15f2 [Sema] Fix crash on invalid code with parenthesized aggregate initialization (#76232)
Fixes #76228.
Use the same logic as braced init lists, also adds a test that puts
incomplete types in various positions to check for regressions in the
future.
2023-12-22 13:11:27 +01:00
Ilya Biryukov
95b423e44f [Sema] NFC. Simplify code in a few places of TryOrBuildParenListInitialization 2023-12-22 12:41:52 +01:00
Qizhi Hu
625197d39c [clang][ASTImporter] Support Importer of BuiltinBitCastExpr (#74813)
Since import `ExplicitCastExpr` lacks of processing
`BuiltinBitCastExprClass` type, it would reach to the 'unreachable' code
and produce the crash. This patch aims to fix the
[crash](https://github.com/llvm/llvm-project/issues/74774) and try to
handle `BuiltinBitCastExpr`.

Co-authored-by: huqizhi <836744285@qq.com>
2023-12-22 18:06:59 +08:00
Balázs Kéri
0d903b689a [clang][ASTImporter] Import AlignValueAttr correctly. (#75308)
Expression of attribute `align_value` was not imported. Import of the
attribute is corrected, a test for it is added, other related tests with
FIXME are updated.
Fixes #75054.
2023-12-22 10:07:38 +01:00
Ben Shi
e2d0f50cd6 [clang][NFC] Remove trailing whitespace characters 2023-12-22 15:34:13 +08:00
hstk30-hw
033ec098be [Clang][Sema] Fix Wswitch-default bad warning in template (#76007)
https://github.com/llvm/llvm-project/pull/73077 added -Wswitch-default
diagnostic but it produced false positives in templates. This PR will
address that. https://github.com/llvm/llvm-project/issues/75943
2023-12-22 09:00:41 +08:00
Dinar Temirbulatov
809f2f3d7d [AArch64][SME2] Add builtins for FDOT, BFDOT, SUDOT, USDOT, SDOT, UDOT. (#75737)
Add SME2 DOT builtins.
2023-12-21 19:41:24 +00:00
Tomas Matheson
7bd17212ef Re-land "[AArch64] Codegen support for FEAT_PAuthLR" (#75947)
This reverts commit 9f0f558742.

Fix expensive checks failure by properly marking register def for ADR.
2023-12-21 18:32:55 +00:00
Dinar Temirbulatov
77c5c44b01 [AArch64][SME2] Add SME2 MLA/MLS builtins. (#75584)
Add SME2 MLA/MLS builtins.
2023-12-21 16:42:24 +00:00
Tomas Matheson
9f0f558742 Revert "[AArch64] Codegen support for FEAT_PAuthLR"
This reverts commit 5992ce90b8.

Builtbot failures with expensive checks enabled.
2023-12-21 16:25:55 +00:00
madanial0
6b505406a3 [Flang] remove whole-archive option for AIX linker (#76039)
The AIX linker does not support the `--whole-archive` option, removing
the option if the OS is AIX.

---------

Co-authored-by: Mark Danial <mark.danial@ibm.com>
2023-12-21 10:22:30 -05:00
Tomas Matheson
5992ce90b8 [AArch64] Codegen support for FEAT_PAuthLR
- Adds a new +pc option to -mbranch-protection that will enable
  the use of PC as a diversifier in PAC branch protection code.

- When +pauth-lr is enabled (-march=armv9.5a+pauth-lr) in combination
  with -mbranch-protection=pac-ret+pc, the new 9.5-a instructions
  (pacibsppc, retaasppc, etc) are used.

Documentation for the relevant instructions can be found here:
https://developer.arm.com/documentation/ddi0602/2023-09/Base-Instructions/

Co-authored-by: Lucas Prates <lucas.prates@arm.com>
2023-12-21 14:18:33 +00:00
madanial0
11c2c0940b [Flang] Add fortran runtime libraries to AIX driver (#75921)
Add fortran runtime libraries to flang-new on AIX

Co-authored-by: Mark Danial <mark.danial@ibm.com>
2023-12-21 08:59:21 -05:00
Ben Shi
73948ec6b2 [clang][analyzer] Support fflush in the StreamChecker (#74296) 2023-12-21 17:57:06 +08:00
Chuanqi Xu
2203a4e6e0 [NFC] [Serialization] Improve AST serialization by reordering packed
bits and extract big bits from packed bits

Previously I tried to improve the size of .pcm files by introducing
packed bits. And I find we can improve it further by reordering the
bits.

The secret comes from the VBR format. We can find the formal definition
of VBR format in the doc of LLVM. The VBR format will be pretty
efficicent for small numbers.

For example, if we need to pack 8 bits into a value and the stored value
is 0xf0, the actual stored value will be 0b000111'110000, which takes 12
bits actually. However, if we changed the order to be 0x0f, then we
can store it as 0b001111, which takes 6 bits only now.

So we can improve the size by placing bits with lower probability to be
1 in the higher bits and extract bit bigs from the packed bits to make
it possible to be optimized by VBR.

After this patch, the size of std module becomes to 27.7MB from 28.1MB.
2023-12-21 16:35:20 +08:00
martinboehme
469374e5c4 [clang][dataflow] Disallow setting properties on RecordValues. (#76042)
Instead, synthetic fields should now be used for the same purpose. These
have a
number of advantages, as described in
https://github.com/llvm/llvm-project/pull/73860, and longer-term, we
want to
eliminate `RecordValue` entirely.

As `RecordValue`s cannot have properties any more, I have replaced the
`OptionalIntAnalysis` with an equivalent analysis that tracks nullness
of
pointers (instead of whether an optional has a value). This serves the
same
purpose, namely to check whether the framework applies a custom
`merge()`
operation to widen properties.
2023-12-21 09:21:24 +01:00
martinboehme
2ee396b0b1 [clang][dataflow] Add Environment::get<>(). (#76027)
This template function casts the result of `getValue()` or
`getStorageLocation()` to a given subclass of `Value` or
`StorageLocation` (using `cast_or_null`).

It's a common pattern to do something like this:

```cxx
auto *Val = cast_or_null<PointerValue>(Env.getValue(E));
```

This can now be expressed more concisely like this:

```cxx
auto *Val = Env.get<PointerValue>(E);
```

Instead of adding a new method `get()`, I had originally considered
simply adding a template parameter to `getValue()` and
`getStorageLocation()` (with a default argument of `Value` or
`StorageLocation`), but this results in an undesirable repetition at the
callsite, e.g. `getStorageLocation<RecordStorageLocation>(...)`. The
`Value` and `StorageLocation` in the method name adds nothing of value
when the template argument already contains this information, so it
seemed best to shorten the method name to simply `get()`.
2023-12-21 09:02:20 +01:00
Qizhi Hu
72e8ab7d44 [clang][ASTImporter] add processing of SubstNonTypeTemplateParmExpr in isAncestorDeclContextOf (#74991)
Lack of processing of `SubstNonTypeTemplateParmExpr` in
`isAncestorDeclContextOf` would make `hasAutoReturnTypeDeclaredInside`
returns false and lead to infinite recursion. This patch adds the
processor and try to fix [this
issue](https://github.com/llvm/llvm-project/issues/74839)

Co-authored-by: huqizhi <836744285@qq.com>
2023-12-21 15:05:33 +08:00
Timm Bäder
d5c98e7837 [clang][AST][NFC] const-qualify some local references 2023-12-21 06:32:32 +01:00
Chuanqi Xu
565e5e861f Recommit [NFC] [Serialization] Packing more bits and refactor AbbrevToUse
This patch tries to pack more bits into a value to reduce the size of
.pcm files. Also, after we introduced BitsPackers, it may slightly
better to adjust the way we use Abbrev.

After this patch, the size of the BMI for std module reduce from 28.94MB
to 28.1 MB.

This was reverted due to it broke the build of lldb. The reason that we
skip the serialization of a source location incorrectly. And this patch
now fixes that.
2023-12-21 10:30:12 +08:00
Max Winkler
0ea87560cc [clang] Separate Intel ADC instrinsics from ADX intrinsics (#75992)
See https://github.com/llvm/llvm-project/pull/75711 for discussion.

As a summary from the PR above, `<adxintrin.h>` includes adc intrinsics
and adx intrinsics.
To support MSVC STL we need to expose the adc intrinsics inside the
currently proposed `<intrin0.h>` header.
Move the processor agnostic adc intrinsics into a separate file that can
be included from `<immintrin.h>` and the currently proposed
`<intrin0.h>`.
2023-12-21 08:43:46 +08:00
Dimitry Andric
2c27013fa9 [clang] Add getClangVendor() and use it in CodeGenModule.cpp (#75935)
In 9a38a72f1d `ProductId` was assigned from the stringified value of
`CLANG_VENDOR`, if that macro was defined. However, `CLANG_VENDOR` is
supposed to be a string, as it is defined (optionally) as such in the
top-level clang `CMakeLists.txt`.

Furthermore, `CLANG_VENDOR` is only passed as a build-time define when
compiling `Version.cpp`, so add a `getClangVendor()` function to
`Version.h`, and use it in `CodegGenModule.cpp`, instead of relying on
the macro.

Fixes: 9a38a72f1d
2023-12-20 20:09:39 +01:00
Dimitry Andric
5c1a41f8ad Revert "[clang] Add getClangVendor() and use it in CodeGenModule.cpp (#75935)"
This reverts commit 9055519103, due to an
incorrectly chosen commit message.
2023-12-20 20:07:22 +01:00
Dimitry Andric
9055519103 [clang] Add getClangVendor() and use it in CodeGenModule.cpp (#75935)
In 9a38a72f1d `ProductId` was assigned from the stringified value of
`CLANG_VENDOR`, if that macro was defined. However, `CLANG_VENDOR` is
supposed to be a string, as it is defined (optionally) as such in the
top-level clang `CMakeLists.txt`.

Move the addition of `-DCLANG_VENDOR` to the compiler flags from
`clang/lib/Basic/CMakeLists.txt` to the top-level `CMakeLists.txt`, so
it is consistent across the whole clang codebase. Then remove the
stringification from `CodeGenModule.cpp`, to make it work correctly.

Fixes:		9a38a72f1d
2023-12-20 20:03:19 +01:00
Brandon Wu
379d32dab8 Recommit [RISCV] Implement multi-lib reuse rule for RISC-V bare-metal toolchain (#73765) (#75890)
Extend the multi-lib re-use selection mechanism for RISC-V.
This funciton will try to re-use multi-lib if they are compatible.
Definition of compatible:
  - ABI must be the same.
  - multi-lib is a subset of current arch, e.g. multi-lib=march=rv32im
    is a subset of march=rv32imc.
  - march that contains atomic extension can't reuse multi-lib that
    doesn't has atomic, vice versa. e.g. multi-lib=march=rv32im and
    march=rv32ima are not compatible, because software and hardware
    atomic operation can't work together correctly.
2023-12-20 14:42:11 +08:00
cor3ntin
c853676061 [Clang] Fix a crash when incorrectly calling an explicit object member function template (#75913)
Fixes #75732
2023-12-20 07:41:24 +01:00
Fangrui Song
207cbbd710 DiagnosticHandler: refactor error checking (#75889)
In LLVMContext::diagnose, set `HasErrors` for `DS_Error` so that all
derived `DiagnosticHandler` have correct `HasErrors` information.

An alternative is to set `HasErrors` in
`DiagnosticHandler::handleDiagnostics`, but all derived
`handleDiagnostics` would have to call the base function.
2023-12-19 21:51:26 -08:00
Kazu Hirata
8c296d58c5 [Interpreter] Fix warnings
This patch fixes:

  clang/lib/Interpreter/CodeCompletion.cpp:126:35: error: 'startswith'
  is deprecated: Use starts_with instead
  [-Werror,-Wdeprecated-declarations]

  clang/lib/Interpreter/CodeCompletion.cpp:189:42: error: 'startswith'
  is deprecated: Use starts_with instead
  [-Werror,-Wdeprecated-declarations]
2023-12-19 12:57:10 -08:00
Fred Fu
35b366ace7 [ClangRepl] Reland Semanic Code Completion (#75556)
This patch contains changes from
002d471a4a, in
addition to a bug fix that added a virtual destructor to
`CompletionContextHandler`

The original changes in the orginal commit piggybacks on clang's
semantic modules to enable semantic completion.  In particular, we use
`CodeCompletionContext` to differentiate two types of code completion.
We also
extract the relevant type information from it.
2023-12-19 22:53:02 +02:00
Timm Bäder
6905438204 [clang][Sema][NFC] Simplify ActOnCXXThrow 2023-12-19 14:47:48 +01:00
Haojian Wu
32aa7d823c [clang] Fix CTAD not work for C++ explicit type conversion (functional annotation). (#75779)
This fixes https://github.com/llvm/llvm-project/issues/64347.

The CTAD for an aggregate class is missing to handle the explicit type
conversion case, e.g. `TemplateFooClass(1, 2);`. Per C++ expr.type.conv
p1, the deduced type is the return type of the deduction guide selected
by the CTAD for the reminder.

In the deduction implementation
`DeduceTemplateSpecializationFromInitializer`, the parenthesized
express-list case relies on the `ParenListExpr` parameter (default is
nullptr), the AST `ParenListExpr` node is not built for all variant
initializer cases (`BuildCXXTypeConstructorExpr`, `BuildCXXNew` etc),
thus the deduction doesn't perform for these cases. This patch fixes it
by removing the `ParenListExpr` and using the `Inits` instead (which
also simplifies the interface and implementation).
2023-12-19 14:35:37 +01:00
Nikita Popov
a3d2d34e84 [Clang] Use poison as base for vector literals
When constructing vectors from elements, use poison instead of
undef as the base value. These literals always initialize all
elements (padding the remainder with zero), so that the choice
of base value does not affect semantics.
2023-12-19 11:53:18 +01:00
Timm Bäder
c52a46a53b [clang][AST][NFC] Remove a local variable
The reference could be const, but this is even better.
2023-12-19 10:54:58 +01:00
Timm Bäder
17fa04e32f [clang][AST][NFC] Make declarationReplaces()'s first parameter const
And const qualify some local variables
2023-12-19 10:19:52 +01:00
Timm Bäder
b0ac829d71 [clang][AST][NFC] const-qualify a few locals in isPlaceholderVar 2023-12-19 09:46:06 +01:00
Timm Bäder
42e5214a9b [clang][Sema][NFC] Clean up ShouldDiagnoseUnusedDecl
Const qualify a few locals, merge two if statements and use
dyn_cast_if_present instead of _or_null.
2023-12-19 09:46:06 +01:00
Timm Bäder
258c2ae9df [clang][Sema][NFC] Merge two if statements 2023-12-19 09:46:06 +01:00
Eric Biggers
09058654f6 [RISCV] Remove experimental from Vector Crypto extensions (#74213)
The RISC-V vector crypto extensions have been ratified. This patch
updates the Clang and LLVM support for these extensions to be
non-experimental, while leaving the C intrinsics as experimental since
the C intrinsics are not yet standardized.

Co-authored-by: Brandon Wu <brandon.wu@sifive.com>
2023-12-18 22:04:22 -08:00
Erich Keane
fdee0a35d9 [OpenACC] Add 'clause' parsing infrastructure plus a few clauses (#75052)
As we've now finished parsing the constructs, we're moving onto
implementing 'clause' parsing. While some are complicated and require
their own patch, the handful added here are simple to parse (that is,
    they are a single identifier).

This patch adds the infrastructure to parse these and a clause-list in
its entirety. This adds some complication to how we are diagnosing
parsing errors elsewhere, so a few changes were made to better recover
from errors.
2023-12-18 18:53:37 -08:00
Colin Cross
d9d20bd81f Honor -fno-sanitize-link-runtime for libclang_rt.asan_static (#66414)
https://reviews.llvm.org/D122407 added a static link against
libclang_rt.asan_static whenever ASAN is linked, but ignored the
-fno-sanitize-link-runtime flag. Every other conditional in
collectSanitizerRuntimes is already checking for SanArgs.linkRuntimes(),
move it to the top of the function so that newly added conditionals
don't need to remember to check it.
2023-12-18 17:15:41 -08:00
Bill Wendling
cca4d6cfd2 Revert counted_by attribute feature (#75857)
There are many issues that popped up with the counted_by feature. The
patch #73730 has grown too large and approval is blocking Linux testing.

Includes reverts of:
commit 769bc11f68 ("[Clang] Implement the 'counted_by' attribute
(#68750)")
commit bc09ec6962 ("[CodeGen] Revamp counted_by calculations
(#70606)")
commit 1a09cfb2f3 ("[Clang] counted_by attr can apply only to C99
flexible array members (#72347)")
commit a76adfb992 ("[NFC][Clang] Refactor code to calculate flexible
array member size (#72790)")
commit d8447c78ab ("[Clang] Correct handling of negative and
out-of-bounds indices (#71877)")
Partial commit b31cd07de5 ("[Clang] Regenerate test checks (NFC)")

Closes #73168
Closes #75173
2023-12-18 15:16:09 -08:00
Paul Kirth
d1e2b96b60 [clang][fatlto] Don't set ThinLTO module flag with FatLTO (#75079)
Since FatLTO now uses the UnifiedLTO pipeline, we should not set the
ThinLTO module flag to true, since it may cause an assertion failure.
See https://github.com/llvm/llvm-project/issues/70703 for context.
2023-12-18 13:03:13 -08:00