1753 Commits

Author SHA1 Message Date
Luohao Wang
0cd50b0d3b
[Clang][Sema] Avoid crash in overload diagnostics for invalid static deducing-this (#177783)
Fix #177741

Overload candidate diagnostics reserve a conversion slot for the object
argument. For static methods this slot does not correspond to a real
parameter, and for ill-formed declarations with an explicit object
parameter we could index past the parameter list and crash in assert
builds.

Use isExplicitObjectMemberFunction() when mapping conversion slots to
parameters and guard parameter-range computation to keep notes robust.
2026-01-29 09:13:16 +08:00
Younan Zhang
53ae317ed2
[Clang] Check enable_if attribute without delayed diagnostics (#176080)
We ensure immediate access control checking when evaluating the
enable_if attribute to rule out inaccessible constructors during
potential overload resolution, treating them as SFINAE errors rather
than hard errors, making the behavior more preferable with the nature of
the enable_if attribute.

Compared to the last patch, we now avoid switching the DC directly
because there are cases where we're checking enable_if attribute within
a lambda and getCurLambda() requires a lambda context to distinguish
from template instantiation.

This reapplies #175899

Fixes https://github.com/llvm/llvm-project/issues/175895
2026-01-20 10:13:41 +08:00
gulfemsavrun
2b838431fd
Revert "[Clang] Check enable_if attribute in the DC of current function" (#176024)
Reverts llvm/llvm-project#175899 as it caused an assertion error.

https://ci.chromium.org/ui/p/fuchsia/builders/global.ci/clang_toolchain.ci.core.x64-debug-tot-build_only/b8692683882729058145/overview
2026-01-14 13:12:04 -08:00
Younan Zhang
28009c8880
[Clang] Check enable_if attribute in the DC of current function (#175899)
A ContextRAII here ensures immediate access control checking within the
current context, allowing us to rule out inaccessible constructors
during potential overload resolution, where access diagnostics are
converted from hard errors into SFINAE errors, making the behavior more
preferrable with the nature of the enable_if attribute.

Fixes https://github.com/llvm/llvm-project/issues/175895
2026-01-14 23:16:15 +08:00
Oleksandr T.
8380b57b7e
[Clang] prevent an assertion failure caused by C++ constant expression checks in C23 floating conversions (#174113)
Fixes #173847

---

This patch addresses an assertion failure during compilation of C23 code
involving floating-point conversions.

As part of the C23 constexpr support introduced in PR #73099, Clang
began reusing parts of the C++ constant evaluation and narrowing logic.
In C23 mode, a failed constant evaluation caused the condition to
proceed to C++ constant-expression checks, resulting in an assertion
failure.

This change evaluates constants using `EvaluateAsRValue` in C23 mode and
restricts C++ constant-expression checks to C++ mode.
2026-01-12 15:50:05 +02:00
Victor Chernyakin
c438773432
[LLVM][ADT] Migrate users of make_scope_exit to CTAD (#174030)
This is a followup to #173131, which introduced the CTAD functionality.
2026-01-02 20:42:56 -08:00
Farzon Lotfi
0d53746eaa
[HLSL][Matrix] Add support for ICK_HLSL_Matrix_Splat to add splat cast of scalars (#170885)
fixes #168960

Adds `ICK_HLSL_Matrix_Splat` and hooks it up to
`PerformImplicitConversion` and `IsMatrixConversion`. Map these to
`CK_HLSLAggregateSplatCast`.
2025-12-12 15:29:19 -05:00
Farzon Lotfi
dd1b4abfb7
[HLSL][Matrix] Add support for Matrix element and trunc Casts (#168915)
fixes #168737
fixes #168755

This change fixes adds support for Matrix truncations via the
ICK_HLSL_Matrix_Truncation enum. That ends up being most of the files
changed.

It also allows Matrix as an HLSL Elementwise cast as long as the cast
does not perform a shape transformation ie 3x2 to 2x3.

Tests for the new elementwise and truncation behavior were added. As
well as sema tests to make sure we error n the shape transformation
cast.

I am punting right now on the ConstExpr Matrix support. That will need
to be addressed later. Will file a seperate issue for that if reviewers
agree it can wait.
2025-12-02 19:02:25 -05:00
Helena Kotas
19fe9b477b
[HLSL][TableGen] Add __hlsl_resource_t to known built-in function types (#163465)
This change adds resource handle type `__hlsl_resource_t` to the list of types recognized in the Clang's built-in functions prototype string.

HLSL has built-in resource classes and some of them have many methods, such as
[Texture2D](https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/sm5-object-texture2d).
Most of these methods will be implemented by built-in functions that will take resource handle as an argument. This change enables us to move from generic `void(...)` prototype string for these methods and explicit argument checking in `SemaHLSL.cpp` to a prototype string with explicit argument types. Argument checking in `SemaHLSL.cpp` can be reduced to handle just the rules that cannot be expressed in the prototype string (for example verifying that the offset value in `__builtin_hlsl_buffer_update_counter` is `1` or `-1`).

In order to make this work, we now allow conversions from attributed resource handle type such as `__hlsl_resource_t [[hlsl::resource_class(UAV)]] [[hlsl::contained_type(float)]]` to a plain non-attributed `__hlsl_resource_t` type.
2025-11-19 14:56:49 -08:00
Bruno De Fraine
e07aef9dde
[clang][Sema] close IsStandardConversion hole when adding cfi_unchecked_callee (#164592)
Commit b194cf1e401a changed this function for the case where attribute
`cfi_unchecked_callee` is added in a function conversion. But this
introduces a hole (issue #162798), and it seems the change was
unnecessary: the preceding `TryFunctionConversion` will already allow
adding the `cfi_unchecked_callee` attribute, and will update `FromType`
if it succeeds. So we revert the changes to `IsStandardConversion`. We
also remove the helper function `AddingCFIUncheckedCallee` which is no
longer needed, and simplify the corresponding
`DiscardingCFIUncheckedCallee`.

Fixes: #162798
2025-10-24 23:33:25 +02:00
Juan Manuel Martinez Caamaño
554ea40b57
[NFC][Clang][Diagnostics] Remove the DeferHint parameter of Diags(...) in favour of DeferHintRAII (#161517)
The `DeferHint` was misused at several callsites, where a `Decl*` was
implicitly casted to `bool`.

This patch proposes removing the `DeferHint` parameter and relying on
`DeferDiagsRAII` to set if Clang should defer the diagnostics.
2025-10-21 17:43:39 +02:00
Matheus Izvekov
b516dcc998
[clang] NFC: rename TagType::getOriginalDecl back to getDecl (#163271)
This rename was made as part of
https://github.com/llvm/llvm-project/pull/147835 in order to ease
rebasing the PR, and give a nice window for other patches to get rebased
as well.

It has been a while already, so lets go ahead and rename it back.
2025-10-15 16:11:17 -03:00
Bruno De Fraine
a03aef4fae
[Clang] [Sema] Fix incomplete C mode incompatible ExtInfo/ExtProtoInfo conversion diagnostic (#160477)
To raise -Wincompatible-function-pointer-type for extended function type
information conversions in C mode, checkPointerTypesForAssignment
contained an invocation of IsFunctionConversion that is quite dubious:
it verifies the conversion from LHS to RHS, while we are converting from
RHS to LHS. Presumably, this was done because result and argument types
don't have to match exactly in C mode (compatible types is sufficient),
while IsFunctionConversion checks that an exact match in function types
can be obtained by transforming extended function type information. As a
result of the dubious invocation, the diagnostic for incompatible
extended function type changes was incomplete and would illogically
disappear when other changes to the function type were involved (this
was already raised in 2019 but left unsolved). Newer additions of
extended function type information such as "cfi_unchecked_callee", ARM
CMSE attributes, ARM SME attributes, and function effect attributes,
worked around the issue by introducing either holes or additional checks
which complicates the logic.

Here, we solve this longstanding issue by using IsFunctionConversion to
verify the extended function type information conversion in the correct
direction (from RHS to LHS), after first removing other differences in
the function type (argument and result type mismatch, prototype vs. no
prototype) to allow IsFunctionConversion to obtain an exact match. The
complications introduced for checking newer attributes are removed.

Fixes #41465
Fixes #85415
2025-10-09 17:30:25 +02:00
Boaz Brickner
7e3080f0c1
[clang] Mark OverloadCandidateSet::OperatorRewriteInfo methods as const (#162271)
They don't mutate the object and this makes them easier to use and
allows better const correctness when using Clang as a library.
2025-10-07 16:32:32 +02:00
Jonas Hahnfeld
a9dafc9bdc
[Sema] Compare canonical conversion function (#154158)
With lazy template loading, it is possible to find non-canonical
FunctionDecls, depending on when redecl chains are completed. This
is a problem for templated conversion operators that would allow to
call either the copy assignment or the move assignment operator.
This ambiguity is resolved by isBetterReferenceBindingKind (called
from CompareStandardConversionSequences) ranking rvalue refs over
lvalue refs.
    
Unfortunately, this fix is hard to test in isolation without the
changes in https://github.com/llvm/llvm-project/pull/133057 that
make lazy template loading more likely to complete redecl chains
at "inconvenient" times. The added reproducer passes before and
after this commit, but would have failed with the proposed changes
of the linked PR.
    
Kudos to Maksim Ivanov for providing an initial version of the
reproducer that I further simplified.
2025-10-06 10:34:49 +02:00
Corentin Jabot
e9972debc9
[Clang] Normalize constraints before checking for satisfaction (#161671)
In the standard, constraint satisfaction checking is done on the
normalized form of a constraint.

Clang instead substitutes on the non-normalized form, which causes us to
report substitution failures in template arguments or concept ids, which
is non-conforming but unavoidable without a parameter mapping

This patch normalizes before satisfaction checking. However, we preserve
concept-id nodes in the normalized form, solely for diagnostics
purposes.

This addresses https://github.com/llvm/llvm-project/issues/61811 and
related concepts conformance bugs, ideally to make the remaining
implementation of concept template parameters easier

Fixes https://github.com/llvm/llvm-project/issues/135190
Fixes https://github.com/llvm/llvm-project/issues/61811

Co-authored-by: Younan Zhang
[zyn7109@gmail.com](mailto:zyn7109@gmail.com)

---------

Co-authored-by: Younan Zhang <zyn7109@gmail.com>
2025-10-03 09:29:23 +02:00
Corentin Jabot
047f8c8ee0
Revert "[Clang] Normalize constraints before checking for satisfaction" (#161669)
Reverts llvm/llvm-project#141776

CI failures

https://lab.llvm.org/buildbot/#/builders/202/builds/3591 
https://lab.llvm.org/buildbot/#/builders/55/builds/18066
https://lab.llvm.org/buildbot/#/builders/85/builds/14103
2025-10-02 15:58:55 +02:00
Corentin Jabot
9583b399d8
[Clang] Normalize constraints before checking for satisfaction (#141776)
In the standard, constraint satisfaction checking is done on the
normalized form of a constraint.

Clang instead substitutes on the non-normalized form, which causes us to
report substitution failures in template arguments or concept ids, which
is non-conforming but unavoidable without a parameter mapping

This patch normalizes before satisfaction checking. However, we preserve
concept-id nodes in the normalized form, solely for diagnostics
purposes.

This addresses #61811 and related concepts conformance bugs, ideally to
make the remaining implementation of concept template parameters easier

Fixes #135190
Fixes  #61811

Co-authored-by: Younan Zhang <zyn7109@gmail.com>
2025-10-02 14:35:38 +02:00
Joseph Huber
134a58adff
[Clang] Permit implicit conversion from integral to boolean vectors (#158369)
Summary:
Clang supports boolean vectors as an extension to the vector model.
These are commonly used to represent mask vectors in many vector ISAs.
Currently, using these is quite difficult because all of the vector
comparison operations use integral bitmasks. C / C++ has a long history
of allowing implicit conversions to bool, and I think that we should be
able to do the same here, especially because boolean vectors often work
as wrappers around a bitfield.

This patch adds the minimal changes to enable integral to boolean
conversions for vectors. Because LLVM already handles comparison to zero
for vectors natively, minimal changes are required. We are not bound to
the OpenCL standard at all here because it explicitly forbids boolean
vectors anyway, so these are simply clang extensions.
2025-09-15 10:09:10 -05:00
camc
59d69bfc20
[clang] Detect int-to-float narrowing when the back-conversion is unspecified (#157174)
Resolves #157067 

APFloat::convertToInteger returns opInvalidOp when the conversion has
unspecified value. The int-to-float narrowing detection logic doesn't
check for this when comparing the converted-back integer with the
original integer.

PR adds a check for this, and test cases.
2025-09-07 20:59:58 +08:00
Matheus Izvekov
249167a898
[clang] NFC: reintroduce clang/include/clang/AST/Type.h (#155050)
This reintroduces `Type.h`, having earlier been renamed to `TypeBase.h`,
as a redirection to `TypeBase.h`, and redirects most users to include
the former instead.

This is a preparatory patch for being able to provide inline definitions
for `Type` methods which would otherwise cause a circular dependency
with `Decl{,CXX}.h`.

Doing these operations into their own NFC patch helps the git rename
detection logic work, preserving the history.

This patch makes clang just a little slower to build (~0.17%), just
because it makes more code indirectly include `DeclCXX.h`.
2025-08-27 13:11:34 -03:00
Matheus Izvekov
bcd1530836
[clang] NFC: rename clang/include/clang/AST/Type.h to TypeBase.h (#155049)
This is a preparatory patch, to be able to provide inline definitions
for `Type` functions which depend on `Decl{,CXX}.h`. As the latter also
depends on `Type.h`, this would not be possible without some
reorganizing.

Splitting this rename into its own patch allows git to track this as a
rename, and preserve all git history, and not force any code
reformatting.

A later NFC patch will reintroduce `Type.h` as redirection to
`TypeBase.h`, rewriting most places back to directly including `Type.h`
instead of `TypeBase.h`, leaving only a handful of places where this is
necessary.

Then yet a later patch will exploit this by making more stuff inline.
2025-08-27 13:09:48 -03:00
Matheus Izvekov
88438ba1f3
[clang] AST: fix getAs canonicalization of leaf types (#155028) 2025-08-27 06:20:14 -03:00
Matheus Izvekov
2ec71d93ad
[clang] NFC: introduce Type::getAsEnumDecl, and cast variants for all TagDecls (#155463)
And make use of those.

These changes are split from prior PR #155028, in order to decrease the
size of that PR and facilitate review.
2025-08-26 16:05:59 -03:00
Matheus Izvekov
dc8596d548
[clang] NFC: change more places to use Type::getAsTagDecl and friends (#155313)
This changes a bunch of places which use getAs<TagType>, including
derived types, just to obtain the tag definition.

This is preparation for #155028, offloading all the changes that PR used
to introduce which don't depend on any new helpers.
2025-08-25 20:18:56 -03:00
Shafik Yaghmour
c22ec9cde3
[Clang][Sema] Add nullptr check in IsFunctionConversion (#153710)
Static analysis flagged this code b/c ToFPT could be nullptr but we were
not checking it even though in the previous if statement we did. It
looks like this was a mistaken refactor from:

https://github.com/llvm/llvm-project/pull/135836

In the older code ToFPT was set using a cast which would have asserted
but no longer in the new code.
2025-08-14 18:42:59 -07:00
Jongmyeong Choi
385f83c774
[clang] Fix assertion failure with explicit(bool) in pre-C++11 modes (#152985)
Allow CCEKind::ExplicitBool in BuildConvertedConstantExpression for
pre-C++11 contexts, similar to the existing TempArgStrict exception.
This enables explicit(bool) to work as a C++20 extension in earlier
language modes without triggering assertion failures.

Fixes #152729

---------

Co-authored-by: Jongmyeong Choi <cheesechoi@gmail.com>
2025-08-13 07:03:09 -07:00
Matheus Izvekov
91cdd35008
[clang] Improve nested name specifier AST representation (#147835)
This is a major change on how we represent nested name qualifications in
the AST.

* The nested name specifier itself and how it's stored is changed. The
prefixes for types are handled within the type hierarchy, which makes
canonicalization for them super cheap, no memory allocation required.
Also translating a type into nested name specifier form becomes a no-op.
An identifier is stored as a DependentNameType. The nested name
specifier gains a lightweight handle class, to be used instead of
passing around pointers, which is similar to what is implemented for
TemplateName. There is still one free bit available, and this handle can
be used within a PointerUnion and PointerIntPair, which should keep
bit-packing aficionados happy.
* The ElaboratedType node is removed, all type nodes in which it could
previously apply to can now store the elaborated keyword and name
qualifier, tail allocating when present.
* TagTypes can now point to the exact declaration found when producing
these, as opposed to the previous situation of there only existing one
TagType per entity. This increases the amount of type sugar retained,
and can have several applications, for example in tracking module
ownership, and other tools which care about source file origins, such as
IWYU. These TagTypes are lazily allocated, in order to limit the
increase in AST size.

This patch offers a great performance benefit.

It greatly improves compilation time for
[stdexec](https://github.com/NVIDIA/stdexec). For one datapoint, for
`test_on2.cpp` in that project, which is the slowest compiling test,
this patch improves `-c` compilation time by about 7.2%, with the
`-fsyntax-only` improvement being at ~12%.

This has great results on compile-time-tracker as well:

![image](https://github.com/user-attachments/assets/700dce98-2cab-4aa8-97d1-b038c0bee831)

This patch also further enables other optimziations in the future, and
will reduce the performance impact of template specialization resugaring
when that lands.

It has some other miscelaneous drive-by fixes.

About the review: Yes the patch is huge, sorry about that. Part of the
reason is that I started by the nested name specifier part, before the
ElaboratedType part, but that had a huge performance downside, as
ElaboratedType is a big performance hog. I didn't have the steam to go
back and change the patch after the fact.

There is also a lot of internal API changes, and it made sense to remove
ElaboratedType in one go, versus removing it from one type at a time, as
that would present much more churn to the users. Also, the nested name
specifier having a different API avoids missing changes related to how
prefixes work now, which could make existing code compile but not work.

How to review: The important changes are all in
`clang/include/clang/AST` and `clang/lib/AST`, with also important
changes in `clang/lib/Sema/TreeTransform.h`.

The rest and bulk of the changes are mostly consequences of the changes
in API.

PS: TagType::getDecl is renamed to `getOriginalDecl` in this patch, just
for easier to rebasing. I plan to rename it back after this lands.

Fixes #136624
Fixes https://github.com/llvm/llvm-project/issues/43179
Fixes https://github.com/llvm/llvm-project/issues/68670
Fixes https://github.com/llvm/llvm-project/issues/92757
2025-08-09 05:06:53 -03:00
Corentin Jabot
d803c61aca
[Clang] Fix a regression introduced by #147046 (#150893)
Static functions have an implicit object argument during deduction.
2025-07-28 14:22:07 +03:00
Corentin Jabot
724cfce580
[Clang] Do not assume a perfect match is a better match than a non-template non-perfect match (#149504)
This fixes a regression introduced by the "perfect match" overload
resolution mechanism introduced in 8c5a307.

[This does regress the performance noticeably (-0.7% for a stage 2
build)](https://llvm-compile-time-tracker.com/compare.php?from=42d2ae1034b287eb60563c370dbf52c59b66db20&to=82303bbc3e003c937ded498ac9f94f49a3fc3d90&stat=instructions:u),
however, the original patch had a +4% performance impact, so we are only
losing some of the gain, and this has
the benefit of being correct and more robust.

Fixes #147374
2025-07-18 17:05:18 +02:00
Corentin Jabot
28e1e7e1b4
Revert "[Clang] Do not treat Foo -> const Foo conversion sequences as perfect" (#149272)
Reverts llvm/llvm-project#148613

Considering object argument conversion qualifications perfect leads to
situations where we prefer a non-template const qualified function over
a non-qualified template function, which is very wrong indeed.

I explored solutions to work around that, but instead, we might want to
go the GCC road and prefer the friend overload in the #147374 example,
as this seems a lot more consistent and reliable
2025-07-17 11:32:49 +02:00
Corentin Jabot
acf07dc77c
[Clang] Do not treat Foo -> const Foo conversion sequences as perfect (#148613)
For implicit object arguments.
This fixes a regression introduced by the "perfect match" overload
resolution mechanism introduced in 8c5a307.

Note that GCC allows the ambiguity between a const and non-const
candidate to be resolved. But this patch focuses on restoring the Clang
20 behavior, and to fix the cases which we did resolve incorrectly.

Fixes #147374
2025-07-15 09:18:25 +02:00
Corentin Jabot
ab0d11c815
[Clang] Fix a crash when diagnosing wrong conversion to explicit object parameter (#147996)
When an overload is invalid, we try to initialize each conversion
sequence for the purpose of diagmostics, but we failed to initialize
explicit objects, leading to a crash

Fixes #147121
2025-07-10 19:28:47 +02:00
Corentin Jabot
39ea9b71d9
[Clang] Correctly handle taking the address of an explicit object member function template (#147046)
When implementing #93430, I failed to consider some cases involving
function templates.

```
struct A {
    template <typename T>
    void a(this T self);
};
(&A::a<A>)(A{});
```

This fixes that
2025-07-10 14:05:23 +02: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
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
Kazu Hirata
8f5c338b89
[Sema] Use a range-based for loop (NFC) (#144252)
Note that LLVM Coding Standards discourages for_each.
2025-06-15 10:32:52 -07: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
Mikael Holmen
77062244ed Fix two instances of -Wparentheses warnings [NFC]
Add parentheses around the assert conditions.

Without this gcc warned like
 ../lib/Target/AMDGPU/GCNSchedStrategy.cpp:2250: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
  2250 |          NewMI != RegionBounds.second && "cannot remove at region end");
and
 ../../clang/lib/Sema/SemaOverload.cpp:11326:39: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
 11326 |          DeferredCandidatesCount == 0 &&
       |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
 11327 |              "Unexpected deferred template candidates");
       |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2025-06-12 09:43:30 +02:00
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
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
PiJoules
b194cf1e40
[clang] Function type attribute to prevent CFI instrumentation (#135836)
This introduces the attribute discussed in

https://discourse.llvm.org/t/rfc-function-type-attribute-to-prevent-cfi-instrumentation/85458.

The proposed name has been changed from `no_cfi` to
`cfi_unchecked_callee` to help differentiate from `no_sanitize("cfi")`
more easily. The proposed attribute has the following semantics:

1. Indirect calls to a function type with this attribute will not be
instrumented with CFI. That is, the indirect call will not be checked.
Note that this only changes the behavior for indirect calls on pointers
to function types having this attribute. It does not prevent all
indirect function calls for a given type from being checked.
2. All direct references to a function whose type has this attribute
will always reference the true function definition rather than an entry
in the CFI jump table.
3. When a pointer to a function with this attribute is implicitly cast
to a pointer to a function without this attribute, the compiler will
give a warning saying this attribute is discarded. This warning can be
silenced with an explicit C-style cast or C++ static_cast.
2025-06-04 11:19:26 -07:00
Younan Zhang
e04e140adb
[Clang] Reapply CWG2369 "Ordering between constraints and substitution" (#122423)
The previous approach broke code generation for the MS ABI due to an
unintended code path during constraint substitution. This time we
address the issue by inspecting the evaluation contexts and thereby
avoiding that code path.

This reapplies 96eced624 (#102857).
2025-06-02 17:10:07 +08:00
cor3ntin
13011f21d6
[Clang] Optimize some getBeginLoc implementations (#141058)
The bulk of the changes are in `CallExpr`

We cache Begin/End source locs in the trailing objects, in the space
left by making the offset to the trailing objects static.
We also set a flag to indicate that we are calling an explicit object
member function, further reducing the cost of getBeginLoc.

Fixes #140876
2025-05-29 10:25:53 +02:00
cor3ntin
a2f156b84a
[Clang] Fix deduction of explicit object member functions (#140030)
When taking the address of an overload set containing an explicit object
member, we should not take the
explicit object parameter into account.
2025-05-15 15:29:56 +02:00
PiJoules
a6385a87a2
[Sema] Refactor IsFunctionConversion (#139172)
A bunch of uses of IsFunctionConversion don't use the third argument and
just make a dummy QualType to pass. This splits IsFunctionConversion
into 2 functions, one that just takes 2 arguments and does the check,
and one that does the actual conversion using the 3rd argument. Both
functions can be const and replace current uses appropriately.
2025-05-09 10:19:52 -07:00
Younan Zhang
1b60b83ada
[Clang] Don't retain template FoundDecl for conversion function calls (#138377) 2025-05-04 19:27:08 +08:00
cor3ntin
cce6de8313
[Clang] Never consider conversion from single-element braced-init-list perfect (#138307)
We might prefer a template std::initializer list constructor.

Fix a regression introduced by #136203
https://github.com/llvm/llvm-project/pull/136203#issuecomment-2843498895

GCC had a similar issue and a similar fix
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100963
2025-05-02 20:56:02 +02:00
Vlad Serebrennikov
cf2f13a867 [clang][NFC] Convert Sema::CCEKind to scoped enum 2025-05-02 14:01:40 +03:00
Vlad Serebrennikov
6e63b68389 [clang][NFC] Convert Sema::OverloadKind to scoped enum 2025-05-02 13:44:32 +03:00