History log of /llvm-project/clang/lib/Sema/SemaCast.cpp (Results 1 – 25 of 236)
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
Revision tags: llvmorg-21-init
# d049db83 20-Jan-2025 Arseniy Zaostrovnykh <necto.ne@gmail.com>

[clang] Fix false warning on reinterpret_casting unknown template type (#109430)

After 1595988ee6f9732e7ea79928af8a470ad5ef7dbe
diag::warn_undefined_reinterpret_cast started raising on
non-instantia

[clang] Fix false warning on reinterpret_casting unknown template type (#109430)

After 1595988ee6f9732e7ea79928af8a470ad5ef7dbe
diag::warn_undefined_reinterpret_cast started raising on
non-instantiated template functions without sufficient knowledge whether
the reinterpret_cast is indeed UB.

show more ...


Revision tags: llvmorg-19.1.7, llvmorg-19.1.6, llvmorg-19.1.5, llvmorg-19.1.4
# 46d750be 16-Nov-2024 Kazu Hirata <kazu@google.com>

[Sema] Remove unused includes (NFC) (#116461)

Identified with misc-include-cleaner.


# b9d678d2 15-Nov-2024 Joseph Huber <huberjn@outlook.com>

[Clang] Use TargetInfo when deciding if an address space is compatible (#115777)

Summary:
Address spaces are used in several embedded and GPU targets to describe
accesses to different types of memo

[Clang] Use TargetInfo when deciding if an address space is compatible (#115777)

Summary:
Address spaces are used in several embedded and GPU targets to describe
accesses to different types of memory. Currently we use the address
space enumerations to control which address spaces are considered
supersets of eachother, however this is also a target level property as
described by the C standard's passing mentions. This patch allows the
address space checks to use the target information to decide if a
pointer conversion is legal. For AMDGPU and NVPTX, all supported address
spaces can be converted to the default address space.

More semantic checks can be added on top of this, for now I'm mainly
looking to get more standard semantics working for C/C++. Right now the
address space conversions must all be done explicitly in C/C++ unlike
the offloading languages which define their own custom address spaces
that just map to the same target specific ones anyway. The main question
is if this behavior is a function of the target or the language.

show more ...


# b63b0101 13-Nov-2024 Oleksandr T. <oleksandr.tarasiuk@outlook.com>

[Clang] enhance diagnostic message for __builtin_bit_cast size mismatch (#115940)

Fixes #115870


Revision tags: llvmorg-19.1.3, llvmorg-19.1.2, llvmorg-19.1.1
# 0dd56858 18-Sep-2024 Alejandro Álvarez Ayllón <alejandro.alvarez@sonarsource.com>

[clang][Sema] Fix assertion in `tryDiagnoseOverloadedCast` (#108021)

Fixed an assertion failure in debug mode, and potential crashes in
release mode, when
diagnosing a failed cast caused indirectl

[clang][Sema] Fix assertion in `tryDiagnoseOverloadedCast` (#108021)

Fixed an assertion failure in debug mode, and potential crashes in
release mode, when
diagnosing a failed cast caused indirectly by a failed implicit
conversion to the type of the constructor parameter.

For instance

```
template<typename>
struct StringTrait {};

template< int N >
struct StringTrait< const char[ N ] > {
typedef char CharType;
static const MissingIntT length = N - 1;
};

class String {
public:
template <typename T>
String(T& str, typename StringTrait<T>::CharType = 0);
};


class Exception {
public:
Exception(String const&);
};

void foo() {
throw Exception("some error");
}
```

`Exception(String const&)` is a matching constructor for `Exception`
from a `const char*`, via an implicit conversion to `String`. However,
the instantiation of the `String` constructor will fail because of the
missing type `MissingIntT` inside the specialization of `StringTrait`.

When trying to emit a diagnosis, `tryDiagnoseOverloadedCast` expects not
to have a matching constructor, but there is; it just could not be
instantiated.

show more ...


Revision tags: llvmorg-19.1.0, llvmorg-19.1.0-rc4
# ff04c5b2 29-Aug-2024 Dan Liew <dan@su-root.co.uk>

[NFC][Sema] Move `Sema::AssignmentAction` into its own scoped enum (#106453)

The primary motivation behind this is to allow the enum type to be
referred to earlier in the Sema.h file which is neede

[NFC][Sema] Move `Sema::AssignmentAction` into its own scoped enum (#106453)

The primary motivation behind this is to allow the enum type to be
referred to earlier in the Sema.h file which is needed for #106321.

It was requested in #106321 that a scoped enum be used (rather than
moving the enum declaration earlier in the Sema class declaration).
Unfortunately doing this creates a lot of churn as all use sites of the
enum constants had to be changed. Appologies to all downstream forks in
advanced.

Note the AA_ prefix has been dropped from the enum value names as they
are now redundant.

show more ...


Revision tags: llvmorg-19.1.0-rc3, llvmorg-19.1.0-rc2, llvmorg-19.1.0-rc1, llvmorg-20-init
# bae2c549 01-Jul-2024 Vlad Serebrennikov <serebrennikov.vladislav@gmail.com>

[clang][NFC] Move documentation of `Sema` functions into `Sema.h`

This patch moves documentation of `Sema` functions from `.cpp` files to `Sema.h` when there was no documentation in the latter, or i

[clang][NFC] Move documentation of `Sema` functions into `Sema.h`

This patch moves documentation of `Sema` functions from `.cpp` files to `Sema.h` when there was no documentation in the latter, or it can be trivially subsumed. More complicated cases when there's less trivial divergence between documentation attached to declaration and the one attached to implementation are left for a later PR that would require review.

It appears that doxygen can find the documentation for a function defined out-of-line even if it's attached to an implementation, and not declaration. But other tools, e.g. clangd, are not as powerful. So this patch significantly improves autocompletion experience for (at least) clangd-based IDEs.

show more ...


Revision tags: llvmorg-18.1.8, llvmorg-18.1.7
# 2bc098b8 03-Jun-2024 Raul Tambre <raul@tambre.ee>

[clang][Sema] Don't issue -Wcast-function-type-mismatch for enums with a matching underlying type (#87793)

Enums are passed as their underlying integral type so they're ABI compatible if the size ma

[clang][Sema] Don't issue -Wcast-function-type-mismatch for enums with a matching underlying type (#87793)

Enums are passed as their underlying integral type so they're ABI compatible if the size matches.
Useful with C APIs that pass user-controlled values to callbacks that can be made type safe by using enumerations (e.g. GStreamer).

Discovered internally in some code after 999d4f840777bf8de26d45947192aa0728edc0fb.

show more ...


# a640a2e0 22-May-2024 Vlad Serebrennikov <serebrennikov.vladislav@gmail.com>

[clang] Introduce `SemaRISCV` (#92682)

This patch moves `Sema` functions that are specific for RISC-V into the
new `SemaRISCV` class. This continues previous efforts to split `Sema`
up. Additional

[clang] Introduce `SemaRISCV` (#92682)

This patch moves `Sema` functions that are specific for RISC-V into the
new `SemaRISCV` class. This continues previous efforts to split `Sema`
up. Additional context can be found in
https://github.com/llvm/llvm-project/pull/84184.

This PR is somewhat different from previous PRs on this topic:
1. Splitting out target-specific functions wasn't previously discussed.
It felt quite natural to do, though.
2. I had to make some static function in `SemaChecking.cpp` member
functions of `Sema` in order to use them in `SemaRISCV`.
3. I dropped "RISCV" from identifiers, but decided to leave "RVV"
(RISC-V "V" vector extensions) intact. I think it's an idiomatic
abbreviation at this point, but I'm open to input from contributors in
that area.
4. I repurposed `SemaRISCVVectorLookup.cpp` for `SemaRISCV`.

I think this was a successful experiment, which both helps the goal of
splitting `Sema` up, and shows a way to approach `SemaChecking.cpp`,
which I wasn't sure how to approach before. As we move more
target-specific function out of there, we'll gradually make the checking
"framework" inside `SemaChecking.cpp` public, which is currently a whole
bunch of static functions. This would enable us to move more functions
outside of `SemaChecking.cpp`.

show more ...


Revision tags: llvmorg-18.1.6
# 31a203fa 13-May-2024 Vlad Serebrennikov <serebrennikov.vladislav@gmail.com>

[clang] Introduce `SemaObjC` (#89086)

This is continuation of efforts to split `Sema` up, following the
example of OpenMP, OpenACC, etc. Context can be found in
https://github.com/llvm/llvm-projec

[clang] Introduce `SemaObjC` (#89086)

This is continuation of efforts to split `Sema` up, following the
example of OpenMP, OpenACC, etc. Context can be found in
https://github.com/llvm/llvm-project/pull/82217 and
https://github.com/llvm/llvm-project/pull/84184.

I split formatting changes into a separate commit to help reviewing the
actual changes.

show more ...


Revision tags: llvmorg-18.1.5
# e11b17a4 17-Apr-2024 Vlad Serebrennikov <serebrennikov.vladislav@gmail.com>

[clang][NFC] Refactor `Sema::CheckedConversionKind`

Convert it to scoped enum, and move it to namespace scope to enable forward declarations.


Revision tags: llvmorg-18.1.4
# 6e934b7c 14-Apr-2024 Jie Fu <jiefu@tencent.com>

[clang] Fix -Wunused-variable in SemaCast.cpp (NFC)

llvm-project/clang/lib/Sema/SemaCast.cpp:503:23:
error: unused variable 'Res' [-Werror,-Wunused-variable]
OverloadingResult Res =

[clang] Fix -Wunused-variable in SemaCast.cpp (NFC)

llvm-project/clang/lib/Sema/SemaCast.cpp:503:23:
error: unused variable 'Res' [-Werror,-Wunused-variable]
OverloadingResult Res =
^
1 error generated.

show more ...


# ef164cee 14-Apr-2024 Sirraide <aeternalmail@gmail.com>

[Clang] [C++26] Implement P2573R2: `= delete("should have a reason");` (#86526)

This implements support for the `= delete("message")` syntax that was
only just added to C++26
([P2573R2](https://is

[Clang] [C++26] Implement P2573R2: `= delete("should have a reason");` (#86526)

This implements support for the `= delete("message")` syntax that was
only just added to C++26
([P2573R2](https://isocpp.org/files/papers/P2573R2.html#proposal-scope)).

show more ...


Revision tags: llvmorg-18.1.3, llvmorg-18.1.2, llvmorg-18.1.1, llvmorg-18.1.0, llvmorg-18.1.0-rc4, llvmorg-18.1.0-rc3, llvmorg-18.1.0-rc2, llvmorg-18.1.0-rc1, llvmorg-19-init, llvmorg-17.0.6, llvmorg-17.0.5
# ae7b20b5 31-Oct-2023 Vlad Serebrennikov <serebrennikov.vladislav@gmail.com>

[clang][NFC] Refactor `VectorType::VectorKind`

This patch moves `VectorKind` to namespace scope, and make it complete at the point its bit-field is declared. It also converts it to a scoped enum.


Revision tags: llvmorg-17.0.4
# d8a5c79e 18-Oct-2023 Botond István Horváth <horvath.botond.istvan@gmail.com>

[clang][Sema] Correct end for the `CastOperation.OpRange` (#69480)

Set the correct end for the CastOperation.OpRange in CXXFunctionalCastExpr.
Now it is the closing bracket's location instead of the

[clang][Sema] Correct end for the `CastOperation.OpRange` (#69480)

Set the correct end for the CastOperation.OpRange in CXXFunctionalCastExpr.
Now it is the closing bracket's location instead of the parameter's location.

This can lead to better highlight in the diagnostics.
Similar to https://github.com/llvm/llvm-project/pull/66853

Before:

warning: cast from 'long (*)(const int &)' to 'decltype(fun_ptr)' (aka 'long (*)(int &)') converts to incompatible function type [-Wcast-function-type-strict]
24 | return decltype(fun_ptr)( f_ptr /*comment*/);
| ^~~~~~~~~~~~~~~~~~~~~~~~

After:

warning: cast from 'long (*)(const int &)' to 'decltype(fun_ptr)' (aka 'long (*)(int &)') converts to incompatible function type [-Wcast-function-type-strict]
24 | return decltype(fun_ptr)( f_ptr /*comment*/);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Reviewed By: AaronBallman, tbaederr

GitHub PR: https://github.com/llvm/llvm-project/pull/69480

show more ...


Revision tags: llvmorg-17.0.3, llvmorg-17.0.2, llvmorg-17.0.1, llvmorg-17.0.0
# 2fbd1323 05-Sep-2023 Kristina Bessonova <kbessonova@accesssoftek.com>

[Sema] Make C++ functional-style cast warn about dropped qualifiers (-Wcast-qual)

Functional-style cast (i.e. a simple-type-specifier or typename-specifier
followed by a parenthesize single expression

[Sema] Make C++ functional-style cast warn about dropped qualifiers (-Wcast-qual)

Functional-style cast (i.e. a simple-type-specifier or typename-specifier
followed by a parenthesize single expression [expr.type.conv]) is equivalent
to the C-style cast, so that makes sense they have identical behavior
including warnings.

This also matches GCC https://godbolt.org/z/b8Ma9Thjb.

Reviewed By: rnk, aaron.ballman

Differential Revision: https://reviews.llvm.org/D159133

show more ...


Revision tags: llvmorg-17.0.0-rc4, llvmorg-17.0.0-rc3
# 0ce056a8 11-Aug-2023 Aaron Ballman <aaron@aaronballman.com>

[C23] Rename C2x -> C23; NFC

This does the rename for most internal uses of C2x, but does not rename
or reword diagnostics (those will be done in a follow-up).

I also updated standards references a

[C23] Rename C2x -> C23; NFC

This does the rename for most internal uses of C2x, but does not rename
or reword diagnostics (those will be done in a follow-up).

I also updated standards references and citations to the final wording
in the standard.

show more ...


Revision tags: llvmorg-17.0.0-rc2
# 9a370a1e 02-Aug-2023 Dmitry Chernenkov <dmitryc@google.com>

Reland "For #64088: mark vtable as used if we might emit a reference to it."

This reverts commit 3b34d69ac7a643742364be3591b324ddd14ef9aa.


Revision tags: llvmorg-17.0.0-rc1
# 3b34d69a 28-Jul-2023 Dmitry Chernenkov <dmitryc@google.com>

Revert "For #64088: mark vtable as used if we might emit a reference to it."

This reverts commit b6847edfc235829b37dd6d734ef5bbfa0a58b6fc.


# b6847edf 25-Jul-2023 Richard Smith <richard@metafoo.co.uk>

For #64088: mark vtable as used if we might emit a reference to it.


Revision tags: llvmorg-18-init
# fe0116ab 17-Jul-2023 Alan Zhao <ayzhao@google.com>

[clang] Fix a crash when casting to an array type

In C++20, if Clang fails to perform constructor overload on a
RecordType, then Clang will try to perform parentesized aggregate
initialization. If t

[clang] Fix a crash when casting to an array type

In C++20, if Clang fails to perform constructor overload on a
RecordType, then Clang will try to perform parentesized aggregate
initialization. If that fails and the initialization was attempted as
part of a cast, then we should get the diagnostics from the failed
constructor overload attempt. However, we don't attempt constructor
overloading for arrays, so previously, if we try to diagnose an
overloaded cast for a parenthesized aggregate initialization of an
array, we crash. To fix this, we now exit tryDiagnoseOverloadedCast(...)
for failed parentesized list initialization if the destination type is
an array.

Fixes #63758

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D155523

show more ...


# b0abd489 17-Jun-2023 Elliot Goodrich <elliotgoodrich@gmail.com>

[llvm] Add missing StringExtras.h includes

In preparation for removing the `#include "llvm/ADT/StringExtras.h"`
from the header to source file of `llvm/Support/Error.h`, first add in
all the missing

[llvm] Add missing StringExtras.h includes

In preparation for removing the `#include "llvm/ADT/StringExtras.h"`
from the header to source file of `llvm/Support/Error.h`, first add in
all the missing includes that were previously included transitively
through this header.

show more ...


Revision tags: llvmorg-16.0.6
# 55aeb23f 10-Jun-2023 Paulo Matos <pmatos@igalia.com>

[clang][WebAssembly] Implement support for table types and builtins

This commit implements support for WebAssembly table types and
respective builtins. Table tables are WebAssembly objects to store

[clang][WebAssembly] Implement support for table types and builtins

This commit implements support for WebAssembly table types and
respective builtins. Table tables are WebAssembly objects to store
reference types. They have a large amount of semantic restrictions
including, but not limited to, only being allowed to be declared
at the top-level as static arrays of zero-length. Not being arguments
or result of functions, not being stored ot memory, etc.

This commit introduces the __attribute__((wasm_table)) to attach to
arrays of WebAssembly reference types. And the following builtins to
manage tables:

* ref __builtin_wasm_table_get(table, idx)
* void __builtin_wasm_table_set(table, idx, ref)
* uint __builtin_wasm_table_size(table)
* uint __builtin_wasm_table_grow(table, ref, uint)
* void __builtin_wasm_table_fill(table, idx, ref, uint)
* void __builtin_wasm_table_copy(table, table, uint, uint, uint)

This commit also enables reference-types feature at bleeding-edge.

This is joint work with Alex Bradbury (@asb).

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D139010

show more ...


Revision tags: llvmorg-16.0.5
# e6217573 27-May-2023 M. Zeeshan Siddiqui <mzs@microsoft.com>

[Clang][BFloat16] Upgrade __bf16 to arithmetic type, change mangling, and extend excess precision support

Pursuant to discussions at
https://discourse.llvm.org/t/rfc-c-23-p1467r9-extended-floating-p

[Clang][BFloat16] Upgrade __bf16 to arithmetic type, change mangling, and extend excess precision support

Pursuant to discussions at
https://discourse.llvm.org/t/rfc-c-23-p1467r9-extended-floating-point-types-and-standard-names/70033/22,
this commit enhances the handling of the __bf16 type in Clang.
- Firstly, it upgrades __bf16 from a storage-only type to an arithmetic
type.
- Secondly, it changes the mangling of __bf16 to DF16b on all
architectures except ARM. This change has been made in
accordance with the finalization of the mangling for the
std::bfloat16_t type, as discussed at
https://github.com/itanium-cxx-abi/cxx-abi/pull/147.
- Finally, this commit extends the existing excess precision support to
the __bf16 type. This applies to hardware architectures that do not
natively support bfloat16 arithmetic.
Appropriate tests have been added to verify the effects of these
changes and ensure no regressions in other areas of the compiler.

Reviewed By: rjmccall, pengfei, zahiraam

Differential Revision: https://reviews.llvm.org/D150913

show more ...


Revision tags: llvmorg-16.0.4, llvmorg-16.0.3
# 42e79d97 28-Apr-2023 Craig Topper <craig.topper@sifive.com>

[RISCV] Add attribute(riscv_rvv_vector_bits(N)) based on AArch64 arm_sve_vector_bits.

This allows the user to set the size of the scalable vector so they
can be used in structs and as the type of gl

[RISCV] Add attribute(riscv_rvv_vector_bits(N)) based on AArch64 arm_sve_vector_bits.

This allows the user to set the size of the scalable vector so they
can be used in structs and as the type of global variables. This works
by representing the type as a fixed vector instead of a scalable vector
in IR. Conversions to and from scalable vectors are made where necessary
like function arguments/returns and intrinsics.

This features has been requested here
https://github.com/riscv-non-isa/rvv-intrinsic-doc/issues/176
I know arm_sve_vector_bits is used by the Eigen library so this
could be used to port Eigen to RVV.

This patch adds a new preprocessor define `__riscv_v_fixed_vlen` that
is set when -mrvv_vector_bits is passed on the command line.

The code is largely based on the AArch64 code. A lot of code was
copy/pasted and then modiied to RVV. There may be some opportunities
for sharing.

This first patch only supports the LMUL=1 types. Additional changes
will be needed to support other LMULs. I have also not supported
mask vectors.

Differential Revision: https://reviews.llvm.org/D145088

show more ...


12345678910