Skip to content

Commit 1864913

Browse files
author
git apple-llvm automerger
committed
Merge commit '8f7762157417' from llvm.org/main into next
2 parents 15707fd + 8f77621 commit 1864913

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,8 @@ Non-comprehensive list of changes in this release
246246

247247
- ``__builtin_assume_dereferenceable`` now accepts non-constant size operands.
248248

249+
- Fixed a crash when the second argument to ``__builtin_assume_aligned`` was not constant (#GH161314)
250+
249251
New Compiler Flags
250252
------------------
251253
- New option ``-fno-sanitize-debug-trap-reasons`` added to disable emitting trap reasons into the debug info when compiling with trapping UBSan (e.g. ``-fsanitize-trap=undefined``).

clang/lib/Sema/SemaChecking.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5996,6 +5996,9 @@ bool Sema::BuiltinAssumeAligned(CallExpr *TheCall) {
59965996
if (Result > Sema::MaximumAlignment)
59975997
Diag(TheCall->getBeginLoc(), diag::warn_assume_aligned_too_great)
59985998
<< SecondArg->getSourceRange() << Sema::MaximumAlignment;
5999+
6000+
TheCall->setArg(1,
6001+
ConstantExpr::Create(Context, SecondArg, APValue(Result)));
59996002
}
60006003

60016004
if (NumArgs > 2) {

clang/test/SemaCXX/builtin-assume-aligned.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,9 @@ constexpr void *s1 = __builtin_assume_aligned(x, 32);
4747
constexpr void *s2 = __builtin_assume_aligned(x, 32, 5);
4848
constexpr void *s3 = __builtin_assume_aligned(x, 32, -1);
4949

50+
51+
constexpr int add(int a, int b) {
52+
return a+b;
53+
}
54+
constexpr void *c1 = __builtin_assume_aligned(p, add(1,1));
55+
constexpr void *c2 = __builtin_assume_aligned(p, add(2,1)); // expected-error {{not a power of 2}}

0 commit comments

Comments
 (0)