Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
67c4161
[Clang] fix range calculation for conditionals with throw expressions
a-tarasyuk Oct 12, 2024
8366e2c
Merge branch 'main' into fix/111854
a-tarasyuk Oct 12, 2024
336810f
Merge branch 'main' into fix/111854
a-tarasyuk Oct 14, 2024
248a56a
Merge branch 'main' into fix/111854
a-tarasyuk Oct 14, 2024
3a56d10
Merge branch 'main' into fix/111854
a-tarasyuk Oct 15, 2024
c3c5b8f
Merge branch 'main' into fix/111854
a-tarasyuk Oct 18, 2024
9c2a745
change return type to nullable for handling invalid ranges in integer…
a-tarasyuk Oct 18, 2024
6e2b0aa
Merge branch 'fix/111854' of https://github.com/a-tarasyuk/llvm-proje…
a-tarasyuk Oct 18, 2024
661abfd
Merge branch 'main' of https://github.com/llvm/llvm-project into fix/…
a-tarasyuk Oct 18, 2024
cd3d083
Merge branch 'main' into fix/111854
a-tarasyuk Oct 18, 2024
eb5f2e2
Merge branch 'main' into fix/111854
a-tarasyuk Oct 19, 2024
0cb124d
Merge branch 'main' into fix/111854
a-tarasyuk Oct 19, 2024
76be3d8
Merge branch 'main' into fix/111854
a-tarasyuk Oct 19, 2024
646675b
Merge branch 'main' into fix/111854
a-tarasyuk Oct 19, 2024
f19a1a1
Merge branch 'main' into fix/111854
a-tarasyuk Oct 20, 2024
01dc877
Merge branch 'main' into fix/111854
a-tarasyuk Oct 22, 2024
ad1ed80
Merge branch 'main' into fix/111854
a-tarasyuk Oct 22, 2024
79adbbe
Merge branch 'main' into fix/111854
a-tarasyuk Oct 24, 2024
3d1ed95
Update ReleaseNotes
a-tarasyuk Oct 24, 2024
b8af5b8
Merge branch 'main' into fix/111854
a-tarasyuk Oct 24, 2024
ef19b65
Merge branch 'main' into fix/111854
a-tarasyuk Oct 24, 2024
331a5ec
Merge branch 'main' into fix/111854
a-tarasyuk Oct 24, 2024
39adc48
Merge branch 'main' into fix/111854
a-tarasyuk Oct 24, 2024
fe739b6
Merge branch 'main' into fix/111854
a-tarasyuk Oct 25, 2024
e0f056c
update comments
a-tarasyuk Oct 25, 2024
93ccc0d
Merge branch 'fix/111854' of https://github.com/a-tarasyuk/llvm-proje…
a-tarasyuk Oct 25, 2024
ddb0fcb
Merge branch 'main' of https://github.com/llvm/llvm-project into fix/…
a-tarasyuk Oct 25, 2024
93e2369
Merge branch 'main' into fix/111854
a-tarasyuk Oct 25, 2024
4b19638
Merge branch 'main' into fix/111854
a-tarasyuk Oct 25, 2024
edb0a54
Merge branch 'main' into fix/111854
a-tarasyuk Oct 25, 2024
d223061
Merge branch 'main' into fix/111854
a-tarasyuk Oct 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,7 @@ Bug Fixes to C++ Support
certain situations. (#GH47400), (#GH90896)
- Fix erroneous templated array size calculation leading to crashes in generated code. (#GH41441)
- During the lookup for a base class name, non-type names are ignored. (#GH16855)
- Fixed assertion failure in range calculations for conditional throw expressions (#GH111854)

Bug Fixes to AST Handling
^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
3 changes: 3 additions & 0 deletions clang/lib/Sema/SemaChecking.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9827,6 +9827,9 @@ static IntRange GetExprRange(ASTContext &C, const Expr *E, unsigned MaxWidth,
return IntRange(BitField->getBitWidthValue(C),
BitField->getType()->isUnsignedIntegerOrEnumerationType());

if (GetExprType(E)->isVoidType())
return IntRange{0, true};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these changes are fine as-is, but I do wonder if a cleaner model for us to aim for is to make the return value std::optional and return no valid object in this case; a void expression has no values it can take, and that's different than a value range of [0,0].

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AaronBallman thanks for the feedback. Do you mean the following changes?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@erichkeane @shafik @AaronBallman when you have a moment, could you review these changes? thanks

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AaronBallman @shafik if these changes look good to you, would you mind proceeding with the merge? thanks


return IntRange::forValueOfType(C, GetExprType(E));
}

Expand Down
7 changes: 7 additions & 0 deletions clang/test/SemaCXX/conditional-expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -429,3 +429,10 @@ void g() {
long e = a = b ? throw 0 : throw 1;
}
} // namespace PR46484

namespace GH111854 {
void f() {
(true ? throw 0 : 0) <= 0; // expected-warning {{relational comparison result unused}}
(false ? 0 : throw 0) <= 0; // expected-warning {{relational comparison result unused}}
}
}
Loading