22399 Commits

Author SHA1 Message Date
Chuanqi Xu
8a5b97a720 Revert "[clang] [modules] Add err_main_in_named_module (#146247)"
This reverts commit 473769ec9b2f860813229eb449fb4298dfc7ff94.

It breaks test in libc++

See https://github.com/llvm/llvm-project/pull/146247
2025-06-30 23:22:31 +08:00
Devon Loehr
5ab3114bd1
Expand annotation check for -Wunique-object-duplication on Windows. (#145944)
Since dllexport/dllimport annotations don't propagate the same way as
visibility, the unique object duplication warning needs to check both
the object in question and its containing class. Previously, we
restricted this check to static data members, but it applies to all
objects inside a class, including functions. Not checking functions
leads to false positives, so remove that restriction.
2025-06-30 10:51:04 -04:00
Samarth Narang
1cdc7f8724
[clang] [Sema] Suggest [[noreturn]] for void functions that always throw (#146234)
Implements https://github.com/llvm/llvm-project/issues/146223.
2025-06-30 10:46:51 -04:00
Yanzuo Liu
7a3e555353
[Clang][Sema] Require BaseClass:: (not other classes) in member using-declaration in C++98 mode (#143492)
[CWG400](https://wg21.link/cwg400) rejects member using-declaration
whose nested-name-specifier doesn't refer to a base class of the current
class.

```cpp
struct A {};
struct B {
  using B::A; // error
};
```

Clang didn't reject this case in C++98 mode. This patch fixes this
issue.
2025-06-30 19:00:52 +08:00
Ashwin Banwari
473769ec9b
[clang] [modules] Add err_main_in_named_module (#146247)
Close https://github.com/llvm/llvm-project/issues/146229

As the issue said, main shouldn't be in any modules.

new diagnostic output:
```
/my/code/directory/main.cpp:3:1: warning: 'main' should not be attached to a named module; consider adding C++ language linkage [-Wmain]
    3 | int main() {
      | ^
      | extern "C++" 
1 warning generated.
```
2025-06-30 17:09:03 +08:00
Nikolas Klauser
713839729c
[Clang] Add __builtin_invoke and use it in libc++ (#116709)
`std::invoke` is currently quite heavy compared to a function call,
since it involves quite heavy SFINAE. This can be done significantly
more efficient by the compiler, since most calls to `std::invoke` are
simple function calls and 6 out of the seven overloads for `std::invoke`
exist only to support member pointers. Even these boil down to a few
relatively simple checks.

Some real-world testing with this patch revealed some significant
results. For example, instantiating `std::format("Banane")` (and its
callees) went down from ~125ms on my system to ~104ms.
2025-06-29 17:52:50 +02:00
Kazu Hirata
c9cdc33dd6
[clang] Remove unused includes (NFC) (#146254)
These are identified by misc-include-cleaner.  I've filtered out those
that break builds.  Also, I'm staying away from llvm-config.h,
config.h, and Compiler.h, which likely cause platform- or
compiler-specific build failures.
2025-06-28 20:41:46 -07:00
Sirui Mu
3c4e730802
[Sema][clangd] add noexcept to override functions during code completion (#75937)
If a virtual function is declared with `noexcept`, functions that
override this function in the derived classes must be declared with
`noexcept` as well. This PR updates code completion in clang Sema. It
adds `noexcept` specifier to override functions in the code completion
result if the functions override a `noexcept` virtual function.
2025-06-28 14:37:20 +08:00
Kazu Hirata
a460aa1071 [Sema] Fix a warning
This patch fixes:

  clang/lib/Sema/AnalysisBasedWarnings.cpp:686:23: error: variable
  'FD' set but not used [-Werror,-Wunused-but-set-variable]
2025-06-27 08:15:06 -07:00
Samarth Narang
794edd187c
[clang] Suppress noreturn warning if last statement in a function is a throw (#145166)
Fixes https://github.com/llvm/llvm-project/issues/144952
2025-06-27 10:52:22 -04:00
Egor Zhdan
d8ca77e2b9
[Clang][Sema] Allow qualified type names in swift_name attribute
This allows adding `__attribute__((swift_name("MyNamespace.MyType.my_method()")))` on standalone C++ functions to make Swift import them as member functions of a type that is nested in a C++ namespace.

rdar://138934888
2025-06-27 13:21:37 +01:00
Ziqing Luo
5f2b9dd90d Re-land "[-Wunterminated-string-initialization] Handle C string literals ending with explicit '\0' (#143487)"
In C, a char array needs no "nonstring" attribute, if its initializer is
a string literal that 1) explicitly ends with '\0' and 2) fits in the
array after a possible truncation.

For example
`char a[4] = "ABC\0"; // fine, needs no "nonstring" attr`

rdar://152506883

This reland disables the test for linux so that it will not block the
buildbot: https://lab.llvm.org/buildbot/#/builders/144/builds/28591.
2025-06-27 17:41:14 +08:00
Kazu Hirata
8f71650baa
[clang] Use a new constructor of ArrayRef (NFC) (#146007)
ArrayRef now has a new constructor that takes a parameter whose type
has data() and size().  This patch migrates:

  ArrayRef<T>(X.data(), X.size()

to:

  ArrayRef<T>(X)
2025-06-26 23:38:05 -07:00
Adam Glass
9a0a9764f3
[Clang][AArch64] _interlockedbittestand{set,reset}64_{acq,rel,nf} support for AArch64 (#145980)
Adds _interlockedbittestand{set,reset}64_{acq,rel,nf} support for
AArch64
2025-06-26 17:20:27 -07:00
Matheus Izvekov
a9ed84b618
[clang] ms-abi: member pointer inheritance model lock-down fix (#145958)
Lock down the inheritance model for member pointers even when converting
from nullptr.

This fixes a regression introduced in
https://github.com/llvm/llvm-project/pull/131966

There are no release notes, since the regression was never released.

Fixes https://github.com/llvm/llvm-project/issues/144081
2025-06-26 17:30:43 -03:00
erichkeane
0a2b6f6c1c [OpenACC] Fix 'copyout' allowed modifiers alwaysin vs alwaysout
While doing lowering, I discovered that the restriction onthe allowed
modifiers for 'copyout' didn't make sense! After discussion on the
OpenACC standards mailing list I discovered that this was a copy/paste
error during standardization that they intend to fix, and really meant
for copyout to allow alwaysout instead of alwaysin.

When implementing, I blindly followed the standard :)

This patch corrects the implementation to do what was meant.
2025-06-26 10:26:20 -07:00
Steven Perron
08964d69b0
[HLSL][SPIRV] Handle uint type for spec constant (#145577)
The testing only tried `unsigned int` and not `uint`. We want to
correctly handle these surgared types as specialization constants.
2025-06-26 11:19:02 -04:00
Akira Hatanaka
5bbe1536df
Cap IntRange::Width to MaxWidth (#145356)
This commit addresses a fallout introduced by #126846.

Previously, TryGetExprRange would return an IntRange that has an active
range exceeding the maximum representable range for the expression's
underlying type. This led to clang erroneously issuing warnings about
implicit conversions losing integer precision.

This commit fixes the bug by capping IntRange::Width to MaxWidth.

rdar://149444029
2025-06-26 08:03:32 -07:00
Haojian Wu
0b6ddb02ef
[clang] NFC: Add alias for std::pair<FileID, unsigned> used in SourceLocation (#145711)
Introduce a type alias for the commonly used `std::pair<FileID,
unsigned>` to improve code readability, and make it easier for future
updates (64-bit source locations).
2025-06-26 14:12:51 +02:00
Aaron Ballman
d3fd7921d4
Clarify some code based on static analysis complaints; NFC (#145679)
In one case, we have a null pointer check that's unnecessary because the
only caller of the function already asserts the value is non-null.

In the other case, we've got an anti-pattern of `is` followed by `get`.
The logic was easier to repair by changing `get` to `cast`.

Neither case is a functional change.

Fixes #145525
2025-06-26 06:55:48 -04:00
Weaver
30de98c283 Revert "[-Wunterminated-string-initialization] Handle C string literals ending with explicit '\0' (#143487)"
This reverts commit 9903c1936a5d174cfc7d38f77f40ed460e344db6.

Caused the following buildbot failure:
https://lab.llvm.org/buildbot/#/builders/144/builds/28591

Please fix before recommitting.
2025-06-26 11:51:42 +01:00
Younan Zhang
d144eb1d8c
[Clang] Back out the source location workaround for CXXConstructExpr (#145260)
This removes the workaround introduced in 3e1a9cf3b8 and 1ba7dc38d.

The workaround overwrote the right parenthesis location of the sub
expression, which could be wrong when a CXXTemporaryObjectExpr occurs
within a nested expression, e.g. `A(A(1, 2))`.

To completely take it down, we now propagate the left parenthesis source
location throughout SemaCast, such that the ParenOrBraceRange can be
properly set at the point of its creation.

Fixes https://github.com/llvm/llvm-project/issues/143711
2025-06-26 17:02:13 +08:00
Ziqing Luo
9903c1936a
[-Wunterminated-string-initialization] Handle C string literals ending with explicit '\0' (#143487)
In C, a char array needs no "nonstring" attribute, if its initializer is
a string literal that 1) explicitly ends with '\0' and 2) fits in the
array after a possible truncation.

For example
`char a[4] = "ABC\0"; // fine, needs no "nonstring" attr`

rdar://152506883
2025-06-26 16:39:09 +08:00
Ilya Biryukov
78b7f6a03d
[Sema] Avoid deep recursion in AnalyzeImplicitConversions (#145734)
The function already exposes a work list to avoid deep recursion, this
commit starts utilizing it in a helper that could also lead to a deep
recursion.

We have observed this crash on `clang/test/C/C99/n590.c` with our
internal builds that enable aggressive optimizations and hit the limit
earlier than default release builds of Clang.

See the added test for an example with a deeper recursion that used to
crash in upstream Clang before this change with the following stack
trace:

```
  #0 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /usr/local/google/home/ibiryukov/code/llvm-project/llvm/lib/Support/Unix/Signals.inc:804:13
  #1 llvm::sys::RunSignalHandlers() /usr/local/google/home/ibiryukov/code/llvm-project/llvm/lib/Support/Signals.cpp:106:18
  #2 SignalHandler(int, siginfo_t*, void*) /usr/local/google/home/ibiryukov/code/llvm-project/llvm/lib/Support/Unix/Signals.inc:0:3
  #3 (/lib/x86_64-linux-gnu/libc.so.6+0x3fdf0)
  #4 AnalyzeImplicitConversions(clang::Sema&, clang::Expr*, clang::SourceLocation, bool) /usr/local/google/home/ibiryukov/code/llvm-project/clang/lib/Sema/SemaChecking.cpp:12772:0
  #5 CheckCommaOperand /usr/local/google/home/ibiryukov/code/llvm-project/clang/lib/Sema/SemaChecking.cpp:0:3
  #6 AnalyzeImplicitConversions /usr/local/google/home/ibiryukov/code/llvm-project/clang/lib/Sema/SemaChecking.cpp:12644:7
  #7 AnalyzeImplicitConversions(clang::Sema&, clang::Expr*, clang::SourceLocation, bool) /usr/local/google/home/ibiryukov/code/llvm-project/clang/lib/Sema/SemaChecking.cpp:12776:5
  #8 CheckCommaOperand /usr/local/google/home/ibiryukov/code/llvm-project/clang/lib/Sema/SemaChecking.cpp:0:3
  #9 AnalyzeImplicitConversions /usr/local/google/home/ibiryukov/code/llvm-project/clang/lib/Sema/SemaChecking.cpp:12644:7
 #10 AnalyzeImplicitConversions(clang::Sema&, clang::Expr*, clang::SourceLocation, bool) /usr/local/google/home/ibiryukov/code/llvm-project/clang/lib/Sema/SemaChecking.cpp:12776:5
 #11 CheckCommaOperand /usr/local/google/home/ibiryukov/code/llvm-project/clang/lib/Sema/SemaChecking.cpp:0:3
 #12 AnalyzeImplicitConversions /usr/local/google/home/ibiryukov/code/llvm-project/clang/lib/Sema/SemaChecking.cpp:12644:7
 #13 AnalyzeImplicitConversions(clang::Sema&, clang::Expr*, clang::SourceLocation, bool) /usr/local/google/home/ibiryukov/code/llvm-project/clang/lib/Sema/SemaChecking.cpp:12776:5
 #14 CheckCommaOperand /usr/local/google/home/ibiryukov/code/llvm-project/clang/lib/Sema/SemaChecking.cpp:0:3
 #15 AnalyzeImplicitConversions /usr/local/google/home/ibiryukov/code/llvm-project/clang/lib/Sema/SemaChecking.cpp:12644:7
 #16 AnalyzeImplicitConversions(clang::Sema&, clang::Expr*, clang::SourceLocation, bool) /usr/local/google/home/ibiryukov/code/llvm-project/clang/lib/Sema/SemaChecking.cpp:12776:5
 #17 CheckCommaOperand /usr/local/google/home/ibiryukov/code/llvm-project/clang/lib/Sema/SemaChecking.cpp:0:3
 #18 AnalyzeImplicitConversions /usr/local/google/home/ibiryukov/code/llvm-project/clang/lib/Sema/SemaChecking.cpp:12644:7
 #19 AnalyzeImplicitConversions(clang::Sema&, clang::Expr*, clang::SourceLocation, bool) /usr/local/google/home/ibiryukov/code/llvm-project/clang/lib/Sema/SemaChecking.cpp:12776:5
... 700+ more stack frames.
```
2025-06-26 09:51:25 +02:00
Jim Lin
2f9eee849f
[RISCV] Implement intrinsics for XAndesVBFHCVT (#145634)
This patch implements clang intrinsic support for XAndesVBFHCVT.

The clang intrinsicis for XAndesVBFHCVT is similar to Zvfbfmin, but it
doesn't have mask variants.

The document for the intrinsics can be found at:
https://github.com/andestech/andes-vector-intrinsic-doc/tree/ast-v5_4_0-release-v5/auto-generated/andes-v5

Co-authored-by: Tony Chuan-Yue Yuan <yuan593@andestech.com>
2025-06-26 08:58:36 +08:00
yronglin
0529a34600
[clang][Preprocessor] Handle the first pp-token in EnterMainSourceFile (#145244)
Depends on [[clang][Preprocessor] Add peekNextPPToken, makes look ahead
next token without
side-effects](https://github.com/llvm/llvm-project/pull/143898).

This PR fix the performance regression that introduced in
https://github.com/llvm/llvm-project/pull/144233.
The original PR(https://github.com/llvm/llvm-project/pull/144233) handle
the first pp-token in the main source file in the macro
definition/expansion and `Lexer::Lex`, but the lexer is almost always on
the hot path, we may hit a performance regression. In this PR, we handle
the first pp-token in `Preprocessor::EnterMainSourceFile`.

---------

Signed-off-by: yronglin <yronglin777@gmail.com>
2025-06-26 08:49:43 +08:00
Samarth Narang
d760f97387
[Clang] Implement diagnostics for why std::is_standard_layout is false (#144161) 2025-06-25 14:49:15 -04:00
Corentin Jabot
a76448c27d
[Clang] Fix replaceability/relocatability computation (#145655)
for eligible classes with user provided constructor or `operator=`

Fixes #144232
2025-06-25 17:49:15 +02:00
Samarth Narang
b8e8ff3dd6
[Clang] Implement diagnostics for why is_empty is false (#145044)
Expands on https://github.com/llvm/llvm-project/issues/141911
2025-06-25 10:34:51 -04:00
Ross Kirsling
3ef796b981
[Clang] Diagnose unsatisfied std::is_assignable. (#144836)
Part of the work for #141911.

Checking `is_assignable<T, U>` boils down to checking the
well-formedness of `declval<T>() = declval<U>()`; this PR recycles logic
from EvaluateBinaryTypeTrait in order to produce the relevant
diagnostics.
2025-06-25 14:34:46 +02:00
Himadhith
32febe60f3
[PowerPC] Support for Packed BCD conversion builtins (#142723)
Support the following packed BCD builtins for PowerPC.
  
```
__builtin_national2packed - Conversion of National format to Packed decimal format.
__builtin_packed2national - Conversion of Packed decimal format to national format.
__builtin_packed2zoned    - Conversion of Packed decimal format to Zoned decimal format.
__builtin_zoned2packed    - Conversion of Zoned decimal format to Packed decimal format.
```
### Prototypes: 
`vector unsigned char __builtin_national2packed(vector unsigned char a,
unsigned char b);`
`vector unsigned char __builtin_packed2zoned(vector unsigned char,
unsigned char);`
`vector unsigned char __builtin_zoned2packed(vector unsigned char,
unsigned char);`

The condition for the 2nd parameter is consistent over all the 3
prototypes (0 or 1 only).

`vector unsigned char __builtin_packed2national(vector unsigned char);`

Co-authored-by: himadhith <himadhith.v@ibm.com>
Co-authored-by: Tony Varghese <tonypalampalliyil@gmail.com>
2025-06-25 14:47:38 +05:30
Finn Plummer
e93a0d0d1e
[HLSL][RootSignature] Add fdx-rootsignature-version option to specify root signature version (#144813)
This pr provides the ability to specify the root signature version as a
compiler option and to retain this in the root signature decl.

It also updates the methods to serialize the version when dumping the
declaration and to output the version when generating the metadata.

- Update `DXContainer.hI` to define the root signature versions
- Update `Options.td` and `LangOpts.h` to define the
`fdx-rootsignature-version` compiler option
- Update `Options.td` to provide an alias `force-rootsig-ver` in
clang-dxc
- Update `Decl.[h|cpp]` and `SeamHLSL.cpp` so that `RootSignatureDecl`
will retain its version type
- Updates `CGHLSLRuntime.cpp` to generate the extra metadata field
- Add tests to illustrate

Resolves https://github.com/llvm/llvm-project/issues/126557.

Note: this does not implement validation based on versioning.
https://github.com/llvm/llvm-project/issues/129940 is required to
retrieve the version and use it for validations.
2025-06-24 16:21:24 -07:00
Robert Imschweiler
f624ba2d9d
[OpenMP][clang] 6.0: parsing/sema for num_threads 'strict' modifier (#145490)
Implement parsing and semantic analysis support for the optional
'strict' modifier of the num_threads clause. This modifier has been
introduced in OpenMP 6.0, section 12.1.2.

Note: this is basically 1:1 https://reviews.llvm.org/D138328.
2025-06-24 21:12:40 +02:00
Eli Friedman
cb4fb3aa18
[NFC] Move areCompatibleSveTypes etc. from ASTContext to SemaARM. (#145429)
In preparation for making these functions interact with the current
context; see #144611.
2025-06-24 09:46:37 -07:00
Finn Plummer
6a8899cee7
[HLSL][RootSignature] Enable resource range analysis for remaining RootElements (#145109)
As implemented previously
https://github.com/llvm/llvm-project/pull/140962.

We now have a validation pass to ensure that there is no overlap in the
register ranges of the associated resources. However, in the previous
pr, for the sake of brevity, we only "collected `RangeInfo`" for Root
Descriptors. This means the analysis is not run on any other
`RootElement` type.

This pr simply implements the collection of `RangeInfo` for the
remaining types so that the analysis is run account for all
`RootElement` types.

Additionally, we improve the diagnostics message to display `unbounded`
ranges.

Part 3 of and Resolves
https://github.com/llvm/llvm-project/issues/129942.
2025-06-24 09:11:24 -07:00
Henrik G. Olsson
37eb465710
Reland "[Modules] Record whether VarDecl initializers contain side effects" (#145447)
This reverts commit 329ae86 and adds an early exit for EvaluateInPlace when the expression's type is null.
2025-06-23 20:20:15 -07:00
Jonas Devlieghere
329ae868cb
Revert "[Modules] Record whether VarDecl initializers contain side effects" (#145407)
Reverts llvm/llvm-project#143739 because it triggers an assert:

```
Assertion failed: (!isNull() && "Cannot retrieve a NULL type pointer"), function getCommonPtr, file Type.h, line 952.
```
2025-06-23 16:01:58 -05:00
Henrik G. Olsson
319a51a5ff
[Modules] Record whether VarDecl initializers contain side effects (#143739)
Calling `DeclMustBeEmitted` should not lead to more deserialization, as
it may occur before previous deserialization has finished.
When passed a `VarDecl` with an initializer however, `DeclMustBeEmitted`
needs to know whether that initializer contains side effects. When the
`VarDecl` is deserialized but the initializer is not, this triggers
deserialization of the initializer. To avoid this we add a bit to the
serialization format for `VarDecl`s, indicating whether its initializer
contains side effects or not, so that the `ASTReader` can query this
information directly without deserializing the initializer.

rdar://153085264
2025-06-23 10:16:31 -07:00
Rahul Joshi
6d17eb5126
[NFC][Clang][AST] Use llvm::copy instead of memcpy in StringLiteral (#145187) 2025-06-23 07:09:48 -07:00
Steven Perron
cccb82e552
[HLSL][SPIRV] Allow large z value in numthreads (#144934)
The current validation checks for numthreads assume that the target is
DXIL so the version checks inadvertently issue error when targeting
SPIR-V.
2025-06-23 09:36:12 -04:00
Chuanqi Xu
fccc6ee702 [C++20] [Modules] Don't make enum constant members always visible
Close https://github.com/llvm/llvm-project/issues/131058

See the comments in
ASTWriter.cpp:ASTDeclContextNameLookupTrait::getLookupVisibility and
SemaLookup.cpp:Sema::makeMergedDefinitionVisible for details.
2025-06-23 14:39:08 +08:00
yronglin
ea321392eb
[C++][Modules] A module directive may only appear as the first preprocessing tokens in a file (#144233)
This PR is 2nd part of
[P1857R3](https://github.com/llvm/llvm-project/pull/107168)
implementation, and mainly implement the restriction `A module directive
may only appear as the first preprocessing tokens in a file (excluding
the global module fragment.)`:
[cpp.pre](https://eel.is/c++draft/cpp.pre):
```
module-file:
    pp-global-module-fragment[opt] pp-module group[opt] pp-private-module-fragment[opt]
```

We also refine tests use `split-file` instead of conditional macro.

Signed-off-by: yronglin <yronglin777@gmail.com>
2025-06-21 18:58:56 +08:00
Finn Plummer
e6ee2c7c7b
[HLSL][RootSignature] Implement validation of resource ranges for RootDescriptors (#140962)
As was established
[previously](https://github.com/llvm/llvm-project/pull/140957), we
created a structure to model a resource range and to detect an overlap
in a given set of these.

However, a resource range only overlaps with another resource range if
they have:
- equivalent ResourceClass (SRV, UAV, CBuffer, Sampler)
- equivalent resource name-space
- overlapping shader visibility

For instance, the following don't overlap even though they have the same
register range:
- `CBV(b0)` and `SRV(t0)` (different resource class)
- `CBV(b0, space = 0)` and `CBV(b0, space = 1)` (different space)
- `CBV(b0, visibility = Pixel)` and `CBV(b0, visibility = Domain)`
(non-overlapping visibility)

The first two clauses are naturally modelled by grouping all the
`RangeInfo`s that have the equivalent `ResourceClass` and `Space` values
together and check if there is any overlap on a `ResourceRange` for all
these `RangeInfo`s. However, `Visibility` is not quite as easily mapped
(`Visibility = All` would overlap with any other visibility). So we will
instead need to track a `ResourceRange` for each of the `Visibility`
types in a group. Then we can determine when inserting a range of the
same group if it would overlap with any overlapping visibilities.

The collection of `RangeInfo` for `RootDescriptor`s, sorting of the
`RangeInfo`s into the groups and finally the insertion of each point
into their respective `ResourceRange`s are implemented. Furthermore, we
integrate this into `SemaHLSL` to provide a diagnostic for each entry
function that uses the invalid root signature.

- Implements collection of `RangeInfo` for `RootDescriptors`
- Implements resource range validation in `SemaHLSL`
- Add diagnostic testing of error production in
`RootSignature-resource-ranges-err.hlsl`
- Add testing to ensure no errors are raised in valid root signatures
`RootSignature-resource-ranges.hlsl`

Part 2 of https://github.com/llvm/llvm-project/issues/129942

A final pr will be produced to integrate the analysis of
`DescriptorTable`, `StaticSampler` and `RootConstants` by defining how
to construct the `RangeInfo` from their elements respectively.
2025-06-20 14:54:58 -07:00
Chuanqi Xu
14e89b061f [C++20] [Modules] Add exported modules as transitive imported modules
Close https://github.com/llvm/llvm-project/issues/144230

The root cause of the problem is, when we decide the transitive imports,
we didn't deal with exported imports.
2025-06-20 17:03:29 +08:00
Kazu Hirata
7cbb141155
[clang] Migrate away from ArrayRef(std::nullopt) (NFC) (#144982)
ArrayRef has a constructor that accepts std::nullopt.  This
constructor dates back to the days when we still had llvm::Optional.

Since the use of std::nullopt outside the context of std::optional is
kind of abuse and not intuitive to new comers, I would like to move
away from the constructor and eventually remove it.

This patch takes care of the clang side of the migration.
2025-06-19 23:29:50 -07:00
Steven Perron
01d648a429
[HLSL][SPIRV] Reapply "[HLSL][SPIRV] Add vk::constant_id attribute." (#144902)
- **Reapply "[HLSL][SPIRV] Add vk::constant_id attribute." (#144812)**
- **Fix memory leak.**
2025-06-19 11:52:55 -04:00
Steven Perron
5f69d680e2
Revert "[HLSL][SPIRV] Add vk::constant_id attribute." (#144812)
Reverts llvm/llvm-project#143544
2025-06-18 19:30:43 -04:00
Walter J.T.V
8c3fbaf0ee
[Clang][OpenMP][LoopTransformations] Fix incorrect number of generated loops for Tile and Reverse directives (#140532)
This patch is closely related to #139293 and addresses an existing issue
in the loop transformation codebase. Specifically, it corrects the
handling of the `NumGeneratedLoops` variable in
`OMPLoopTransformationDirective` AST nodes and its inheritors (such as
OMPUnrollDirective, OMPTileDirective, etc.).

Previously, this variable was inaccurately set for certain
transformations like reverse or tile. While this did not lead to
functional bugs, since the value was only checked to determine whether
it was greater than zero or equal to zero, the inconsistency could
introduce problems when supporting more complex directives in the
future.
2025-06-18 20:52:41 +02:00
Akira Hatanaka
40d2f39210
[Sema][ObjC] Loosen restrictions on reinterpret_cast involving indirect ARC-managed pointers (#144458)
Allow using reinterpret_cast for conversions between indirect ARC
pointers and other pointer types.

rdar://152905399
2025-06-18 07:08:32 -07:00
Steven Perron
acde20b560
[HLSL][SPIRV] Add vk::constant_id attribute. (#143544)
The vk::constant_id attribute is used to indicate that a global const
variable
represents a specialization constant in SPIR-V. This PR adds this
attribute to clang.

The documentation for the attribute is
[here](https://github.com/microsoft/DirectXShaderCompiler/blob/main/docs/SPIR-V.rst#specialization-constants).

The strategy is to to modify the initializer to get the value of a
specialize constant for a builtin defined in the SPIR-V backend.

Implements https://github.com/llvm/wg-hlsl/pull/287

Fixes https://github.com/llvm/llvm-project/issues/142448

---------

Co-authored-by: Nathan Gauër <github@keenuts.net>
2025-06-18 06:39:52 -04:00