Skip to content

[clang] Preserve UDL nodes in RemoveNestedImmediateInvocation #66641

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,8 @@ Bug Fixes in This Version
(`#67722 <https://github.com/llvm/llvm-project/issues/67722>`_).
- Fixes a crash when instantiating a lambda with requires clause.
(`#64462 <https://github.com/llvm/llvm-project/issues/64462>`_)
- Fixes a regression where the ``UserDefinedLiteral`` was not properly preserved
while evaluating consteval functions. (`#63898 <https://github.com/llvm/llvm-project/issues/63898>`_).

Bug Fixes to Compiler Builtins
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
5 changes: 4 additions & 1 deletion clang/lib/Sema/SemaExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18468,7 +18468,10 @@ static void RemoveNestedImmediateInvocation(
DRSet.erase(cast<DeclRefExpr>(E->getCallee()->IgnoreImplicit()));
return Base::TransformCXXOperatorCallExpr(E);
}
/// Base::TransformInitializer skip ConstantExpr so we need to visit them
/// Base::TransformUserDefinedLiteral doesn't preserve the
/// UserDefinedLiteral node.
ExprResult TransformUserDefinedLiteral(UserDefinedLiteral *E) { return E; }
/// Base::TransformInitializer skips ConstantExpr so we need to visit them
/// here.
ExprResult TransformInitializer(Expr *Init, bool NotCopyInit) {
if (!Init)
Expand Down
17 changes: 17 additions & 0 deletions clang/test/AST/ast-dump-udl-consteval.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// RUN: %clang_cc1 -xc++ -std=c++23 -ast-dump %s | FileCheck %s

int inline consteval operator""_u32(unsigned long long val) {
return val;
}

void udl() {
(void)(0_u32 + 1_u32);
}

// CHECK: `-BinaryOperator {{.+}} <col:10, col:18> 'int' '+'
// CHECK-NEXT: |-ConstantExpr {{.+}} <col:10> 'int'
// CHECK-NEXT: | |-value: Int 0
// CHECK-NEXT: | `-UserDefinedLiteral {{.+}} <col:10> 'int'
// CHECK: `-ConstantExpr {{.+}} <col:18> 'int'
// CHECK-NEXT: |-value: Int 1
// CHECK-NEXT: `-UserDefinedLiteral {{.+}} <col:18> 'int'