3132 Commits

Author SHA1 Message Date
Oleksandr T.
28649f2117
[Clang] accept @tparam on variable template partial specializations (#147219)
Fixes #144775

--- 

This patch addresses a false-positive `-Wdocumentation` warning on
`@tparam` comments attached to _variable template partial
specializations_
2025-07-07 18:27:08 +03:00
Aaron Ballman
60630310e9
[clang-cl] Support /std:clatest (#147284)
cl.exe has /std:clatest, analogous to /std:c++latest, which sets the
language mode to the latest standard. For C, that's C23. This adds
support for the option.

Fixes #147233
2025-07-07 09:15:23 -04:00
Aaron Ballman
8a5458c79a
[C23] Fix typeof handling in enum declarations (#146394)
We have a parsing helper function which parses either a parenthesized
expression or a parenthesized type name. This is used when parsing a
unary operator such as sizeof, for example.

The problem this solves is when that construct is ambiguous. Consider:

	enum E : typeof(int) { F };

After we've parsed the 'typeof', what ParseParenExpression() is
responsible for is '(int) { F }' which looks like a compound literal
expression when it's actually the parens and operand for 'typeof'
followed by the enumerator list for the enumeration declaration. Then
consider:

	sizeof (int){ 0 };

After we've parsed 'sizeof', ParseParenExpression is responsible for
parsing something grammatically similar to the problematic case.

The solution is to recognize that the expression form of 'typeof' is
required to have parentheses. So we know the open and close parens that
ParseParenExpression handles must be part of the grammar production for
the operator, not part of the operand expression itself.

Fixes #146351
2025-07-07 07:09:09 -04:00
Yanzuo Liu
3d6f4fb5f7
[Clang][Sema] Do not perform error recovery for invalid member using-declaration in C++20+ mode (#147003)
Previously, Clang tried to perform error recovery for invalid member
using-declaration whose nested-name-specifier refers to its own class in
C++20+ mode, which causes crash.

```cpp
template <typename...> struct V {};
struct S : V<> {
  using S::V; // error recovery here
  V<> v; // crash
};
```

This PR disables the error recovery to fix the crash.

Fixes #63254
2025-07-05 14:30:28 +08:00
Corentin Jabot
af2bb8f826
[Clang] Correctly handle allocations in the condition of a if constexpr (#146890)
Deal with the following scenario

```cpp
struct S {
    char* c = new char;
    constexpr ~S() {
        delete c;
    }
};
if constexpr((S{}, true)){};
```

There were two issues
- We need to produce a full expression _before_ evaluating the condition
(otherwise, automatic variables are never destroyed)
- We need to preserve the evaluation context of the condition while
doing the semantics analysis for it (lest it is evaluated in a
non-constant-evaluated context)

Fixes #120197
Fixes #134820
2025-07-04 16:40:29 +03:00
Eli Friedman
2aa0f0a3bd
[AArch64] Add option -msve-streaming-vector-bits= . (#144611)
This is similar to -msve-vector-bits, but for streaming mode: it
constrains the legal values of "vscale", allowing optimizations based on
that constraint.

This also fixes conversions between SVE vectors and fixed-width vectors
in streaming functions with -msve-vector-bits and
-msve-streaming-vector-bits.

This rejects any use of arm_sve_vector_bits types in streaming
functions; if it becomes relevant, we could add
arm_sve_streaming_vector_bits types in the future.

This doesn't touch the __ARM_FEATURE_SVE_BITS define.
2025-07-03 13:44:38 -07:00
Ashwin Kishin Banwari
cc801b6570
[clang] [modules] Add err_main_in_named_module (#146635)
Revival of https://github.com/llvm/llvm-project/pull/146247 which got
reverted for broken test.

Now that https://github.com/llvm/llvm-project/pull/146461 is merged to
allow `extern "C++"` for main, we can merge this change.
2025-07-03 10:03:43 +08:00
Ashwin Banwari
2599a9aeb5
[clang] [modules] Implement P3618R0: Allow attaching main to the global module (#146461)
Remove the prior warning for attaching extern "C++" to main.
2025-07-02 09:52:10 +08:00
Ami-zhang
3deed4211a
[docs] Add clang release notes for LoongArch (#146481) 2025-07-02 09:21:33 +08:00
Baranov Victor
96b9b2e21d
[Clang] Fix '-Wformat-overflow' FP when floats had field-width and plus prefix (#144274)
If field width is specified, the sign/space is already accounted for
within the field width, so no additional size is needed.

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

---------

Co-authored-by: Aaron Ballman <aaron@aaronballman.com>
2025-06-30 22:43:47 +03:00
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
Jonathan Marriott
44ec3e8f9c
[clang][AST] Fix AST IgnoreUnlessSpelledInSource traversal nullptr dereference (#146103)
In summary dumping a `catch(...)` statement using
IgnoreUnlessSpelledInSource AST traversal causes a seg fault, as the
variable declaration of the catch is `nullptr`.

Diagnosed the cause by attaching the debugger to `clang-query`, this PR
adds a fix to check for `nullptr` before accessing the `isImplicit()`
method of the `Decl` pointee in the AST node traverser visitor

Fixes #146101
2025-06-30 10:48:26 -04:00
Matheus Izvekov
51dfe28f87
[clang] odr-checker fix for conversion operators (#146153)
This fixes an issue with the ODR checker not using the as-written type
of conversion operators.

The odr-checker in general should not have to deal with canonical types,
as its purpose is to compare same definitions across TUs, and these need
to be same as written, with few exceptions.

Using canonical types is specially problematic when expressions are
involved, as the types which refer to them generally pick an arbitrary
representative expression, and this can lead to false mismatches.

This patch makes sure that when hashing the names of declarations, if a
DeclarationNameInfo is available, its type source info is used, instead
of the type contained in the DeclarationName, which otherwise is always
canonical.

This patch supersedes #144796, as it fixes the problem without weakening
the ODR checker.

Fixes https://github.com/llvm/llvm-project/issues/143152
2025-06-30 10:19:29 -03: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
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
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
Erich Keane
d699fbd203
[OpenACC][Docs] Add a release note for Clang 21 (#145938)
This patch adds a release note that explains the current status of
OpenACC in Clang. Currently we cannot actually make an executable
because the OpenACC dialect of MLIR doesn't support any amount of
lowering to LLVM-IR, so the usefulness of OpenACC is entirely for
front-end related uses, such as tooling or semantic checking.
2025-06-26 13:17:22 -07:00
Eli Friedman
6bdfecaea8
[clang] Revise relnote for int->enum conversion. (#145755)
Include more specifics from recent discussion on #143034.
2025-06-26 08:45:50 -07: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
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
wieDasDing
d76fdf7f53
[clang-c] introduce queries on GCC-style inline assembly statements (#143424)
[Discourse
link](https://discourse.llvm.org/t/a-small-proposal-for-extraction-of-inline-assembly-block-information/86658)

We strive for exposing such information using existing stable ABIs. In
doing so, queries are limited to what the original source holds or the
LLVM IR `asm` block would expose in connection with attributes that the
queries are concerned.

These APIs opens new opportunities for `rust-bindgen` to translate
inline assemblies in reasonably cases into Rust inline assembly blocks,
which would further aid better interoperability with other existing
code.

---------

Signed-off-by: Xiangfei Ding <dingxiangfei2009@protonmail.ch>
2025-06-25 10:08:56 -04:00
Baranov Victor
de2ec228c0
[analyzer] Fix crash when modelling 'getline' function in checkers (#145229)
Fixes #144884
2025-06-24 20:18:15 +02:00
yronglin
8b0d112478
[Clang][Preprocessor] Expand UCNs in macro concatenation (#145351)
Fixs https://github.com/llvm/llvm-project/issues/145240.

The UCN in preprocessor pasted identifier not resolved to unicode, it
may cause the following issue:
```c
#define CAT(a,b) a##b

char foo\u00b5;
char*p = &CAT(foo, \u00b5); // error: use of undeclared identifier 'foo\u00b5'
```
The real identifier after paste is `fooµ`. This PR fix this issue in
`TokenLexer::pasteTokens`, if there has any UCN in pasting tokens, the
final pasted token should have a Token::HasUCN flag. Then
`Preprocessor::LookUpIdentifierInfo` will expand UCNs in this token.

Signed-off-by: yronglin <yronglin777@gmail.com>
2025-06-25 00:56:01 +08:00
yronglin
bd6ee6ac21
[C23][Parser] Accept single variadic parameter function declarator in type name (#145362)
Fixs: https://github.com/llvm/llvm-project/issues/145250.

This PR makes clang accept single variadic parameter function declarator
in type name.
Eg.
```c
int va_fn(...); // ok

// As typeof() argument
typeof(int(...))*fn_ptr = &va_fn;  // ok

// As _Generic association type
int i = _Generic(typeof(va_fn), int(...):1); // ok
```

Signed-off-by: yronglin <yronglin777@gmail.com>
2025-06-24 09:40:01 +08:00
Stephen Tozer
36af7345df Reapply "[Clang] Enable -fextend-variable-liveness at -Og (#118026)"
Relands this feature after several fixes:

* Force fake uses to be emitted before musttail calls (#136867)
* Added soften-float legalization for fake uses (#142714)
* Treat fake uses as size-less instructions in a SystemZ assert (#144390)

If further issues with fake uses are found then this may be reverted again,
but all currently-known issues are resolved.

This reverts commit 2dc6e98169baeb1f73036da0ea50fd828d8323d0.
2025-06-19 16:22:50 +01:00
Younan Zhang
2c2ad9a096
Reapply "[Clang] Profile singly-resolved UnresolvedLookupExpr with the declaration" (#140680)
For a dependent variable template specialization, we don't build a
dependent Decl node or a DeclRefExpr to represent it. Instead, we
preserve the UnresolvedLookupExpr until instantiation.

However, this approach isn't ideal for constraint normalization. We
consider the qualifier during profiling, but since that's based on the
written code, it can introduce confusing differences, even when the
expressions resolve to the same declaration.

This change profiles the underlying VarTemplateDecl if
UnresolvedLookupExpr is used to model a dependent use of it.

Fixes https://github.com/llvm/llvm-project/issues/139476
2025-06-19 14:59:32 +08: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
Eli Friedman
3f33c8482f
[clang] Add release note for int->enum conversion change. (#144407)
This seems to be having some practical impact, so we should let people
know.
2025-06-17 15:27:41 -07:00
Vincent
977d8a4bcd
[clang][Sema] Fixed Compound Literal is not Constant Expression (#143852)
Added a check for a compound literal hiding inside a function.

fixes #87867
2025-06-17 09:20:41 -04:00
Mary Kassayova
c377ce1216
[AArch64][VecLib] Add libmvec support for AArch64 targets (#143696)
This patch adds support for the `libmvec` vector library on AArch64
targets. Currently, all `libmvec` functions in GLIBC version 2.40 are
supported. The full list of math functions enabled can be found
[here](96abd59bf2/sysdeps/aarch64/fpu/Versions)
(up to GLIBC 2.40).

Previously, `libmvec` was only supported on x86_64 targets. Attempts to
use it on AArch64 resulted in the following error from Clang:
`unsupported option 'libmvec' for target 'aarch64'`.
2025-06-17 11:07:43 +01:00
Ying Yi
6f29837659
Reland: "[Frontend][PCH]-Add support for ignoring PCH options (-ignore-pch). (#142409)" (#143614)
Visual Studio has an argument to ignore all PCH related switches.
clang-cl has also support option /Y-. Having the same option in clang
would be helpful. This commit is to add support for ignoring PCH options
(-ignore-pch).

The commit includes:
  1. Implement -ignore-pch as a Driver option.
  2. Add a Driver test and a PCH test.
  3. Add a section of -ignore-pch to user manual.
  4. Add a release note for the new option '-ignore-pch'.

The change since the original landing:
  1. preprocessing-only mode doesn't imply that -include-pch is disabled.

Co-authored-by: Matheus Izvekov <mizvekov@gmail.com>
2025-06-17 10:54:22 +01:00
Iris Shi
f0373295e8
[clang][Parser] Fix crash on malformed using declaration in constexpr function (#144286) 2025-06-16 23:17:47 +08:00
Zhikai Zeng
892513e518
[clang] fix infinite recursion (#143244)
fix https://github.com/llvm/llvm-project/issues/141789

The direct cause of infinite recursion is that `T` is changing from
`struct X` and `S<X>` infinitely, this pr add a check that if `T`
visited before then return false directly.

```plaintext
/home/backlight/llvm-project/clang/lib/Sema/SemaDeclCXX.cpp:7196] FD->getType().getAsString()=struct X, T.getAsString()=S<X>, FD->getType().getCanonicalType().getUnqualifiedType().getAsString()=struct X, CanUnqualT.getAsString()=struct S<struct X>, 
/home/backlight/llvm-project/clang/lib/Sema/SemaDeclCXX.cpp:7196] FD->getType().getAsString()=S<X>, T.getAsString()=struct X, FD->getType().getCanonicalType().getUnqualifiedType().getAsString()=struct S<struct X>, CanUnqualT.getAsString()=struct X,
```

https://github.com/llvm/llvm-project/pull/104829 fix similar infinite
recursion, but I think it is no longer needed so I kind of revert it.
2025-06-14 17:14:16 +08:00
Aaron Ballman
9eef4d1c5f
Remove delayed typo expressions (#143423)
This removes the delayed typo correction functionality from Clang
(regular typo correction still remains) due to fragility of the
solution.

An RFC was posted here:
https://discourse.llvm.org/t/rfc-removing-support-for-delayed-typo-correction/86631
and while that RFC was asking for folks to consider stepping up to be
maintainers, and we did have a few new contributors show some interest,
experiments show that it's likely worth it to remove this functionality
entirely and focus efforts on improving regular typo correction.

This removal fixes ~20 open issues (quite possibly more), improves
compile time performance by roughly .3-.4%
(https://llvm-compile-time-tracker.com/?config=Overview&stat=instructions%3Au&remote=AaronBallman&sortBy=date),
and does not appear to regress diagnostic behavior in a way we wouldn't
find acceptable.

Fixes #142457
Fixes #139913
Fixes #138850
Fixes #137867
Fixes #137860
Fixes #107840
Fixes #93308
Fixes #69470
Fixes #59391
Fixes #58172
Fixes #46215
Fixes #45915
Fixes #45891
Fixes #44490
Fixes #36703
Fixes #32903
Fixes #23312
Fixes #69874
2025-06-13 06:45:40 -04:00
Oleksandr T.
d7e7f22626
[Clang] fix missing source location for errors in macro-expanded (#143460)
Fixes #143216

--- 

This patch fixes diagnostic locations for tokens from macro expansions.
2025-06-11 14:19:25 -07:00
Abhinav Gaba
02b6849cf1
[Clang][OpenMP] Fix mapping of arrays of structs with members with mappers (#142511)
This builds upon #101101 from @jyu2-git, which used compiler-generated
mappers when mapping an array-section of structs with members that have
user-defined default mappers.

Now we do the same when mapping arrays of structs.
2025-06-11 19:03:55 +00:00
Dmitry Polukhin
9797b5fcfb
[C++20][Modules] Fix false compilation error with constexpr (#143168)
Use declaresSameEntity when evaluating constexpr to avoid resetting
computed union value due to using different instances of the merged
field decl.
2025-06-11 10:35:06 +01:00
CHANDRA GHALE
afbcf9529a
[OpenMP 6.0 ]Codegen for Reduction over private variables with reduction clause (#134709)
Codegen support for reduction over private variable with reduction
clause. Section 7.6.10 in in OpenMP 6.0 spec.
- An internal shared copy is initialized with an initializer value.
- The shared copy is updated by combining its value with the values from
the private copies created by the clause.
- Once an encountering thread verifies that all updates are complete,
its original list item is updated by merging its value with that of the
shared copy and then broadcast to all threads.

Sample Test Case from OpenMP 6.0 Example 
```
#include <assert.h>
#include <omp.h>
#define N 10

void do_red(int n, int *v, int &sum_v)
{
    sum_v = 0; // sum_v is private
    #pragma omp for reduction(original(private),+: sum_v)
    for (int i = 0; i < n; i++) 
    {
        sum_v += v[i];
    }
}

int main(void)
{
    int v[N];
    for (int i = 0; i < N; i++)
        v[i] = i;
    #pragma omp parallel num_threads(4)
    {
        int s_v; // s_v is private
        do_red(N, v, s_v);
        assert(s_v == 45);
    }
    return 0;
}
```
Expected Codegen:
```
 // A shared global/static variable is introduced for the reduction result.
 // This variable is initialized (e.g., using memset or a UDR initializer)
 // e.g., .omp.reduction.internal_private_var

 // Barrier before any thread performs combination
  call void @__kmpc_barrier(...)

 // Initialization block (executed by thread 0)
 // e.g., call void @llvm.memset.p0.i64(...) or call @udr_initializer(...)

  call void @__kmpc_critical(...)
    // Inside critical section:
    // Load the current value from the shared variable
    // Load the thread-local private variable's value
    // Perform the reduction operation 
    // Store the result back to the shared variable

  call void @__kmpc_end_critical(...)
  // Barrier after all threads complete their combinations

  call void @__kmpc_barrier(...)
 // Broadcast phase:
 // Load the final result from the shared variable)
 // Store the final result to the original private variable in each thread
 // Final barrier after broadcast

  call void @__kmpc_barrier(...)
```

---------

Co-authored-by: Chandra Ghale <ghale@pe31.hpc.amslabs.hpecorp.net>
2025-06-11 14:01:31 +05:30
Zhikai Zeng
46b7a88548
fix access checking about function overloading (#107768)
fix https://github.com/llvm/llvm-project/issues/107629

After some more debugging, I find out that we will check access here at
8e010ac5a1/clang/lib/Sema/SemaInit.cpp (L7807)

And for `f()` inside code below, `Found.getAccess()` is `AS_none` hence
`CheckAddressOfMemberAccess` return `AR_accessible` directly.

```cpp
struct Base {
public:
  int f(int);
private:
  int f();  // expect-note {{declared private here}}
};

struct Derived : public Base {};

void f() {
  int(Derived::* public_f)(int) = &Derived::f;
  int(Derived::* private_f)() = &Derived::f;  // expect-error {{'f' is a private member of 'Base'}}
}
```

I think the `Found.getAccess()` is intended to be `AS_none` so I just
add one more access check for the `UnresolvedLookupExpr` when
`Found.getAccess()` is `AS_none`. If add the check unconditionally clang
will report lots of duplicate errors and cause several unit tests to
fail.

I also test the UB mentioned in
https://github.com/llvm/llvm-project/issues/107629 and clang now display
4 `false` as expecetd.

Co-authored-by: Erich Keane <ekeane@nvidia.com>
2025-06-10 11:50:22 -07:00
Ying Yi
c926bff560 Revert "[Frontend][PCH]-Add support for ignoring PCH options (-ignore-pch). (#142409)"
This reverts commit 4fb81f11cea0fce9f1f5409fcd55ae3aba70d368.
2025-06-10 17:19:58 +01:00
MaggieYingYi
4fb81f11ce
[Frontend][PCH]-Add support for ignoring PCH options (-ignore-pch). (#142409)
Visual Studio has an argument to ignore all PCH related switches. clang-cl has also support option /Y-. Having the same option in clang would be helpful. This commit is to add support for ignoring PCH options (-ignore-pch).

The commit includes:
    1. Implement -ignore-pch as a Driver option.
    2. Add a Driver test and a PCH test.
    3. Add a section of -ignore-pch to user manual.
    4. Add a release note for the new option '-ignore-pch'.

Code reviewed by: Matheus Izvekov <mizvekov@gmail.com>
2025-06-10 12:52:44 +01:00
Corentin Jabot
c8009797d3
[Clang] Implement CWG2496 (#142975)
https://cplusplus.github.io/CWG/issues/2496.html

We failed to diagnose the following in C++23 mode

```
struct S {
    virtual void f(); // expected-note {{previous declaration is here}}
};

struct T : S {
    virtual void f() &;
};
```
2025-06-09 21:16:57 +02:00
Guillot Tony
b896d262eb
[C23][N3006] Documented behavior of underspecified object declarations (#140911)
This PR is documenting the behavior of Clang towards underspecified
object declarations in C23 as advised by @AaronBallman.
2025-06-09 11:02:20 -04:00
Matheus Izvekov
366f48890d
[clang] AST: fix dependency calculation for TypedefTypes (#143291)
The dependency from the type sugar of the underlying type of a Typedef
were not being considered for the dependency of the TypedefType itself.

A TypedefType should be instantiation dependent if it involves
non-instantiated template parameters, even if they don't contribute to
the canonical type.

Besides, a TypedefType should be instantiation dependent if it is
declared in a dependent context, but fixing that would have performance
consequences, as otherwise non-dependent typedef declarations would need
to be transformed during instantiation as well.

This removes the workaround added in
https://github.com/llvm/llvm-project/pull/90032

Fixes https://github.com/llvm/llvm-project/issues/89774
2025-06-08 17:07:36 -03:00
Nick Sarnie
56b98449c8
[clang][AST] Fix spaces in TypePrinter for some calling convs (#143160)
There needs to be a space as the first character, otherwise the printed
function prototype will have the CC attribute attached to the final `)`.

I noticed this looking at the AST for a function with
`__attribute__((device_kernel))`

---------

Signed-off-by: Sarnie, Nick <nick.sarnie@intel.com>
2025-06-07 16:47:28 +00:00
Imad Aldij
bc931318a2
[Clang] Implement CWG2517 Useless restriction on use of parameter in constraint-expression (#132919)
Remove `[expr.prim.req.nested]` check which restrict that local
parameters in constraint-expressions can only appear as unevaluated
operands. This change makes the treatment of examples like `requires`
expressions and other constant expression contexts uniform, consistent
with the adoption of P2280.

References: https://cplusplus.github.io/CWG/issues/2517.html
Fixes  #132825

---------

Co-authored-by: cor3ntin <corentinjabot@gmail.com>
2025-06-07 11:31:04 +02:00