History log of /llvm-project/clang/lib/Sema/SemaChecking.cpp (Results 1 – 25 of 1882)
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1ac3665e 29-Jan-2025 Fraser Cormack <fraser@codeplay.com>

[clang] Restrict the use of scalar types in vector builtins (#119423)

This commit restricts the use of scalar types in vector math builtins,
particularly the `__builtin_elementwise_*` builtins.

[clang] Restrict the use of scalar types in vector builtins (#119423)

This commit restricts the use of scalar types in vector math builtins,
particularly the `__builtin_elementwise_*` builtins.

Previously, small scalar integer types would be promoted to `int`, as
per the usual conversions. This would silently do the wrong thing for
certain operations, such as `add_sat`, `popcount`, `bitreverse`, and
others. Similarly, since unsigned integer types were promoted to `int`,
something like `add_sat(unsigned char, unsigned char)` would perform a
*signed* operation.

With this patch, promotable scalar integer types are not promoted to
int, and are kept intact. If any of the types differ in the binary and
ternary builtins, an error is issued. Similarly an error is issued if
builtins are supplied integer types of different signs. Mixing enums of
different types in binary/ternary builtins now consistently raises an
error in all language modes.

This brings the behaviour surrounding scalar types more in line with
that of vector types. No change is made to vector types, which are both
not promoted and whose element types must match.

Fixes #84047.

RFC:
https://discourse.llvm.org/t/rfc-change-behaviour-of-elementwise-builtins-on-scalar-integer-types/83725

show more ...


Revision tags: llvmorg-21-init
# c4ef805b 22-Jan-2025 Oliver Stannard <oliver.stannard@arm.com>

[Clang] Re-write codegen for atomic_test_and_set and atomic_clear (#121943)

Re-write the sema and codegen for the atomic_test_and_set and
atomic_clear builtin functions to go via AtomicExpr, like t

[Clang] Re-write codegen for atomic_test_and_set and atomic_clear (#121943)

Re-write the sema and codegen for the atomic_test_and_set and
atomic_clear builtin functions to go via AtomicExpr, like the other
atomic builtins do. This simplifies the code, because AtomicExpr already
handles things like generating code for to dynamically select the memory
ordering, which was duplicated for these builtins. This also fixes a few
crash bugs, one when passing an integer to the pointer argument, and one
when using an array.

This also adds diagnostics for the memory orderings which are not valid
for atomic_clear according to
https://gcc.gnu.org/onlinedocs/gcc/_005f_005fatomic-Builtins.html, which
were missing before.

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

This is a re-land of #120449, modified to allow any non-const pointer
type for the first argument.

show more ...


# e5992b68 20-Jan-2025 Amr Hesham <amr96@programmer.net>

[Clang] Fix warning for non std functions with name `infinity` (#123417)

Fix reporting diagnostic for non std functions that has the name
`infinity`

Fixes: #123231


Revision tags: llvmorg-19.1.7
# cfe26358 11-Jan-2025 Timm Baeder <tbaeder@redhat.com>

Reapply "[clang] Avoid re-evaluating field bitwidth" (#122289)


# 59bdea24 08-Jan-2025 Timm Bäder <tbaeder@redhat.com>

Revert "[clang] Avoid re-evaluating field bitwidth (#117732)"

This reverts commit 81fc3add1e627c23b7270fe2739cdacc09063e54.

This breaks some LLDB tests, e.g.
SymbolFile/DWARF/x86/no_unique_address-

Revert "[clang] Avoid re-evaluating field bitwidth (#117732)"

This reverts commit 81fc3add1e627c23b7270fe2739cdacc09063e54.

This breaks some LLDB tests, e.g.
SymbolFile/DWARF/x86/no_unique_address-with-bitfields.cpp:

lldb: ../llvm-project/clang/lib/AST/Decl.cpp:4604: unsigned int clang::FieldDecl::getBitWidthValue() const: Assertion `isa<ConstantExpr>(getBitWidth())' failed.

show more ...


# 81fc3add 08-Jan-2025 Timm Baeder <tbaeder@redhat.com>

[clang] Avoid re-evaluating field bitwidth (#117732)

Save the bitwidth value as a `ConstantExpr` with the value set. Remove
the `ASTContext` parameter from `getBitWidthValue()`, so the latter
simply

[clang] Avoid re-evaluating field bitwidth (#117732)

Save the bitwidth value as a `ConstantExpr` with the value set. Remove
the `ASTContext` parameter from `getBitWidthValue()`, so the latter
simply returns the value from the `ConstantExpr` instead of
constant-evaluating the bitwidth expression every time it is called.

show more ...


# 21edac25 06-Jan-2025 Farzon Lotfi <farzonlotfi@microsoft.com>

[SPIRV] Add Target Builtins using Distance ext as an example (#121598)

- Update pr labeler so new SPIRV files get properly labeled.
- Add distance target builtin to BuiltinsSPIRV.td.
- Update Targ

[SPIRV] Add Target Builtins using Distance ext as an example (#121598)

- Update pr labeler so new SPIRV files get properly labeled.
- Add distance target builtin to BuiltinsSPIRV.td.
- Update TargetBuiltins.h to account for spirv builtins.
- Update clang basic CMakeLists.txt to build spirv builtin tablegen.
- Hook up sema for SPIRV in Sema.h|cpp, SemaSPIRV.h|cpp, and
SemaChecking.cpp.
- Hookup sprv target builtins to SPIR.h|SPIR.cpp target.
- Update GBuiltin.cpp to emit spirv intrinsics when we get the expected
spirv target builtin.

Consensus was reach in this RFC to add both target builtins and pattern
matching:
https://discourse.llvm.org/t/rfc-add-targetbuiltins-for-spirv-to-support-hlsl/83329.

pattern matching will come in a separate pr this one just sets up the
groundwork to do target builtins for spirv.

partially resolves
[#99107](https://github.com/llvm/llvm-project/issues/99107)

show more ...


# 99dddef3 23-Dec-2024 Dmitry Chestnykh <dm.chestnykh@gmail.com>

[Clang][Sema] Process warnings conditionally (#120591)

There are a few functions that emit warnings related to positional
arguments in format strings. These functions use `getLocationOfByte()`
whi

[Clang][Sema] Process warnings conditionally (#120591)

There are a few functions that emit warnings related to positional
arguments in format strings. These functions use `getLocationOfByte()`
which has O(n) complexity and may lead to silent hang of compilation in
some cases. But such warnings is not widely used and actually don't emit
if user didn't pass the appropriate `-W...` flag, so if the flag is not
passed dont make the call to `EmitFormatDiagnostic` for such diags.

Fix #120462

show more ...


# 93743ee5 20-Dec-2024 Mikhail Goncharov <goncharov.mikhail@gmail.com>

Revert "[Clang] Re-write codegen for atomic_test_and_set and atomic_clear (#120449)"

This reverts commit 9fc2fadbfcb34df5f72bdaed28a7874bf584eed7.

See https://github.com/llvm/llvm-project/pull/1204

Revert "[Clang] Re-write codegen for atomic_test_and_set and atomic_clear (#120449)"

This reverts commit 9fc2fadbfcb34df5f72bdaed28a7874bf584eed7.

See https://github.com/llvm/llvm-project/pull/120449#issuecomment-2556089016

show more ...


# cc7d0841 20-Dec-2024 Brad Smith <brad@comstyle.com>

[clang][Sema] Enable the kprintf format attribute (#100669)


# ecdc5289 19-Dec-2024 Oliver Stannard <oliver.stannard@arm.com>

[Clang] Fix crash in __builtin_assume_aligned (#114217)

The CodeGen for __builtin_assume_aligned assumes that the first argument
is a pointer, so crashes if the int-conversion error is downgraded o

[Clang] Fix crash in __builtin_assume_aligned (#114217)

The CodeGen for __builtin_assume_aligned assumes that the first argument
is a pointer, so crashes if the int-conversion error is downgraded or
disabled. Emit a non-downgradable error if the argument is not a
pointer, like we currently do for __builtin_launder.

Fixes #110914.

show more ...


# 9fc2fadb 19-Dec-2024 Oliver Stannard <oliver.stannard@arm.com>

[Clang] Re-write codegen for atomic_test_and_set and atomic_clear (#120449)

Re-write the sema and codegen for the atomic_test_and_set and
atomic_clear builtin functions to go via AtomicExpr, like t

[Clang] Re-write codegen for atomic_test_and_set and atomic_clear (#120449)

Re-write the sema and codegen for the atomic_test_and_set and
atomic_clear builtin functions to go via AtomicExpr, like the other
atomic builtins do. This simplifies the code, because AtomicExpr already
handles things like generating code for to dynamically select the memory
ordering, which was duplicated for these builtins. This also fixes a few
crash bugs, one when passing an integer to the pointer argument, and one
when using an array.

This also adds diagnostics for the memory orderings which are not valid
for atomic_clear according to
https://gcc.gnu.org/onlinedocs/gcc/_005f_005fatomic-Builtins.html, which
were missing before.

Fixes #111293.

show more ...


Revision tags: llvmorg-19.1.6, llvmorg-19.1.5
# 6e720df1 28-Nov-2024 Haojian Wu <hokein.wu@gmail.com>

[clang] Improve the lifetime_capture_by diagnostic on the constructor. (#117792)

With this change, the lifetime_capture_by code path will not handle the
constructor decl to avoid bogus diagnostics

[clang] Improve the lifetime_capture_by diagnostic on the constructor. (#117792)

With this change, the lifetime_capture_by code path will not handle the
constructor decl to avoid bogus diagnostics (see the testcase).

Instead, we reuse the lifetimebound code as the
lifetime_capture_by(this) has the same semantic as lifetimebound in
constructor. The downside is that the lifetimebound diagnostic is reused
for the capture case (I think it is not a big issue).


Fixes #117680

show more ...


# b185b851 27-Nov-2024 Bill Wendling <morbo@google.com>

[Clang] Improve Sema diagnostic performance for __builtin_counted_by_ref (#116719)

Implement the sema checks with a placeholder. We then check for that
placeholder in all of the places we care to e

[Clang] Improve Sema diagnostic performance for __builtin_counted_by_ref (#116719)

Implement the sema checks with a placeholder. We then check for that
placeholder in all of the places we care to emit a diagnostic.

Fixes: #115520

show more ...


# ef206446 22-Nov-2024 Youngsuk Kim <joseph942010@gmail.com>

[clang] Warn const integer-overflow of member in temporary struct bound to rvalue reference (#117225)

Fixes #46755

---------

Co-authored-by: Sirraide <aeternalmail@gmail.com>


# c22bb6f5 20-Nov-2024 Utkarsh Saxena <usx@google.com>

[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)

This PR uses the existing lifetime analysis for the `capture_by`
attribute.

The analysis is behind `-Wdangling-capture` warn

[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)

This PR uses the existing lifetime analysis for the `capture_by`
attribute.

The analysis is behind `-Wdangling-capture` warning and is disabled by
default for now. Once it is found to be stable, it will be default
enabled.

Planned followup:
- add implicit inference of this attribute on STL container methods like
`std::vector::push_back`.
- (consider) warning if capturing `X` cannot capture anything. It should
be a reference, pointer or a view type.
- refactoring temporary visitors and other related handlers.
- start discussing `__global` vs `global` in the annotation in a
separate PR.

---------

Co-authored-by: Boaz Brickner <brickner@google.com>

show more ...


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

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

Identified with misc-include-cleaner.


# 7475156d 07-Nov-2024 Bill Wendling <morbo@google.com>

[Clang] Add __builtin_counted_by_ref builtin (#114495)

The __builtin_counted_by_ref builtin is used on a flexible array
pointer and returns a pointer to the "counted_by" attribute's COUNT
argument

[Clang] Add __builtin_counted_by_ref builtin (#114495)

The __builtin_counted_by_ref builtin is used on a flexible array
pointer and returns a pointer to the "counted_by" attribute's COUNT
argument, which is a field in the same non-anonymous struct as the
flexible array member. This is useful for automatically setting the
count field without needing the programmer's intervention. Otherwise
it's possible to get this anti-pattern:

ptr = alloc(<ty>, ..., COUNT);
ptr->FAM[9] = 42; /* <<< Sanitizer will complain */
ptr->count = COUNT;

To prevent this anti-pattern, the user can create an allocator that
automatically performs the assignment:

#define alloc(TY, FAM, COUNT) ({ \
TY __p = alloc(get_size(TY, COUNT)); \
if (__builtin_counted_by_ref(__p->FAM)) \
*__builtin_counted_by_ref(__p->FAM) = COUNT; \
__p; \
})

The builtin's behavior is heavily dependent upon the "counted_by"
attribute existing. It's main utility is during allocation to avoid
the above anti-pattern. If the flexible array member doesn't have that
attribute, the builtin becomes a no-op. Therefore, if the flexible
array member has a "count" field not referenced by "counted_by", it
must be set explicitly after the allocation as this builtin will
return a "nullptr" and the assignment will most likely be elided.

---------

Co-authored-by: Bill Wendling <isanbard@gmail.com>
Co-authored-by: Aaron Ballman <aaron@aaronballman.com>

show more ...


# 7ceb19e5 04-Nov-2024 Qiu Chaofan <qcf@ecnelises.com>

[PowerPC] Support set_flt_rounds builtin (#73750)


# dc56a86b 30-Oct-2024 serge-sans-paille <sguelton@mozilla.com>

[clang] Fix 71315698c9 in presence of incomplete types (#114095)

Incomplete types are not considered trivially copyable by clang but we
don't want to warn about invalid argument for memcpy / memset

[clang] Fix 71315698c9 in presence of incomplete types (#114095)

Incomplete types are not considered trivially copyable by clang but we
don't want to warn about invalid argument for memcpy / memset in that
case because we cannot prove they are not Trivially Copyable.

show more ...


Revision tags: llvmorg-19.1.3
# 05b6c2e4 29-Oct-2024 Oleksandr T. <oleksandr.tarasiuk@outlook.com>

[Clang] fix range calculation for conditionals with throw expressions (#112081)

Fixes #111854

---

The issue arises when `GetExprRange` encounters a `ConditionalOperator`
with a `CXXThrowExpr`

[Clang] fix range calculation for conditionals with throw expressions (#112081)

Fixes #111854

---

The issue arises when `GetExprRange` encounters a `ConditionalOperator`
with a `CXXThrowExpr`

```md
ConditionalOperator 0x1108658e0 'int'
|-CXXBoolLiteralExpr 0x110865878 '_Bool' true
|-CXXThrowExpr 0x1108658a8 'void'
| `-IntegerLiteral 0x110865888 'int' 0
`-IntegerLiteral 0x1108658c0 'int' 0
```


https://github.com/llvm/llvm-project/blob/ed3d05178274890fb804f43ae1bcdfd33b5fd8f0/clang/lib/Sema/SemaChecking.cpp#L9628-L9631

The current behavior causes the `GetExprRange` to proceed with the throw
expression (`CO->getTrueExpr()`/`void` type)

show more ...


# 71315698 28-Oct-2024 serge-sans-paille <sguelton@mozilla.com>

[clang] Warn about memset/memcpy to NonTriviallyCopyable types (#111434)

This implements a warning that's similar to what GCC does in that
context: both memcpy and memset require their first and se

[clang] Warn about memset/memcpy to NonTriviallyCopyable types (#111434)

This implements a warning that's similar to what GCC does in that
context: both memcpy and memset require their first and second operand
to be trivially copyable, let's warn if that's not the case.

show more ...


# 4dd55c56 24-Oct-2024 Jay Foad <jay.foad@amd.com>

[clang] Use {} instead of std::nullopt to initialize empty ArrayRef (#109399)

Follow up to #109133.


Revision tags: llvmorg-19.1.2
# 9440420f 01-Oct-2024 Francis Visoiu Mistrih <890283+francisvm@users.noreply.github.com>

[Clang] Add __builtin_(elementwise|reduce)_(max|min)imum (#110198)

We have the LLVM intrinsics, and we're missing the clang builtins to be
used directly in code that needs to make the distinction i

[Clang] Add __builtin_(elementwise|reduce)_(max|min)imum (#110198)

We have the LLVM intrinsics, and we're missing the clang builtins to be
used directly in code that needs to make the distinction in NaN
semantics.

show more ...


# b70d3278 01-Oct-2024 Tex Riddell <texr@microsoft.com>

[HLSL][clang] Add elementwise builtin for atan2 (p3) (#110187)

This change is part of this proposal:
https://discourse.llvm.org/t/rfc-all-the-math-intrinsics/78294

- Add HLSL frontend for atan2

[HLSL][clang] Add elementwise builtin for atan2 (p3) (#110187)

This change is part of this proposal:
https://discourse.llvm.org/t/rfc-all-the-math-intrinsics/78294

- Add HLSL frontend for atan2
- Add clang Builtin, map to new llvm.atan2
- SemaChecking restrict to floating point and 2 args
- SemaHLSL restrict to float or half.
- Add to clang ReleaseNotes.rst and LanguageExtensions.rst
- Add half-float-only-errors2.hlsl for 2 arg intrinsics, and update half-float-only-errors.hlsl with scalar case for consistency
- Remove fmod-errors.hlsl and pow-errors.hlsl now covered in half-float-only-errors2.hlsl

Part 3 for Implement the atan2 HLSL Function #70096.

show more ...


12345678910>>...76