13 Commits

Author SHA1 Message Date
Corentin Jabot
ca61961380 Implement CWG2631
Implement https://cplusplus.github.io/CWG/issues/2631.html.

Immediate calls in default arguments and defaults members
are not evaluated.

Instead, we evaluate them when constructing a
`CXXDefaultArgExpr`/`BuildCXXDefaultInitExpr`.

The immediate calls are executed by doing a
transform on the initializing expression.

Note that lambdas are not considering subexpressions so
we do not need to transform them.

As a result of this patch, unused default member
initializers are not considered odr-used, and
errors about members binding to local variables
in an outer scope only surface at the point
where a constructor is defined.

Reviewed By: aaron.ballman, #clang-language-wg, rupprecht

Differential Revision: https://reviews.llvm.org/D136554
2023-01-08 10:35:26 +01:00
Krasimir Georgiev
339a7687e1 Revert "Implement CWG2631"
This reverts commit f1f1b60c7ba607e9ffe3bc012161d43ef95ac773.

Temporary revert, possibly triggers a new assertion failure on
QualType::getCommonPtr.
We're working on a reproducer, to follow-up on
https://reviews.llvm.org/D136554.
2022-12-14 09:10:22 +00:00
Corentin Jabot
f1f1b60c7b Implement CWG2631
Implement https://cplusplus.github.io/CWG/issues/2631.html.

Immediate calls in default arguments and defaults members
are not evaluated.

Instead, we evaluate them when constructing a
`CXXDefaultArgExpr`/`BuildCXXDefaultInitExpr`.

The immediate calls are executed by doing a
transform on the initializing expression.

Note that lambdas are not considering subexpressions so
we do not need to transform them.

As a result of this patch, unused default member
initializers are not considered odr-used, and
errors about members binding to local variables
in an outer scope only surface at the point
where a constructor is defined.

Reviewed By: aaron.ballman, #clang-language-wg

Differential Revision: https://reviews.llvm.org/D136554
2022-12-13 09:57:05 +01:00
Arthur Eubanks
be305674bf Revert "Implement CWG2631"
This reverts commit c9a6713b4788f10b81202b70993068e475b392f7.

Causes crashes, see D136554.
2022-12-09 14:20:30 -08:00
Corentin Jabot
c9a6713b47 Implement CWG2631
Implement https://cplusplus.github.io/CWG/issues/2631.html.

Immediate calls in default arguments and defaults members
are not evaluated.

Instead, we evaluate them when constructing a
`CXXDefaultArgExpr`/`BuildCXXDefaultInitExpr`.

The immediate calls are executed by doing a
transform on the initializing expression.

Note that lambdas are not considering subexpressions so
we do not need to transform them.

As a result of this patch, unused default member
initializers are not considered odr-used, and
errors about members binding to local variables
in an outer scope only surface at the point
where a constructor is defined.

Reviewed By: aaron.ballman, #clang-language-wg

Differential Revision: https://reviews.llvm.org/D136554
2022-12-09 10:25:44 +01:00
Corentin Jabot
49c86eab62 Revert "Implement CWG2631"
This patch causes another link error,
reverting until I can investigate.

This reverts commit a96a6ed83230265f3eab09a94f0e9525d05f8a74.
2022-12-08 19:57:58 +01:00
Corentin Jabot
a96a6ed832 Implement CWG2631
Implement https://cplusplus.github.io/CWG/issues/2631.html.

Immediate calls in default arguments and defaults members
are not evaluated.

Instead, we evaluate them when constructing a
`CXXDefaultArgExpr`/`BuildCXXDefaultInitExpr`.

The immediate calls are executed by doing a
transform on the initializing expression.

Note that lambdas are not considering subexpressions so
we do not need to transform them.

As a result of this patch, unused default member
initializers are not considered odr-used, and
errors about members binding to local variables
in an outer scope only surface at the point
where a constructor is defined.

Reviewed By: aaron.ballman, #clang-language-wg

Differential Revision: https://reviews.llvm.org/D136554
2022-12-08 10:32:54 +01:00
Yaxun (Sam) Liu
a5435844f0 [HIP][OpenMP] Fix assertion in deferred diag
Fix assertion in UsedDeclVisitor where clang is trying to look up a destructor
for a forward declared class.

Fixes: https://bugs.llvm.org/show_bug.cgi?id=52250

Reviewed by: Artem Belevich, John McCall

Differential Revision: https://reviews.llvm.org/D112235
2021-10-25 11:07:40 -04:00
Geoff Levner
b9225543e8 DeferredDiagnosticsEmitter crashes
Patch VisitCXXDeleteExpr() in clang::UsedDeclVisitor to avoid it crashing
when the expression's destroyed type is null. According to the comments
in CXXDeleteExpr::getDestroyedType(), this can happen when the type to
delete is a dependent type.

Patch by Geoff Levner.

Differential Revision: https://reviews.llvm.org/D88949
2020-10-08 11:42:21 -04:00
Yaxun (Sam) Liu
b670ab7b6b recommit 1b978ddba05c [CUDA][HIP][OpenMP] Emit deferred diagnostics by a post-parsing AST travese
Differential Revision: https://reviews.llvm.org/D70172
2020-03-23 12:09:07 -04:00
Yaxun (Sam) Liu
08ab8c9af4 [NFC] Add UsedDeclVisitor
Differential Revision: https://reviews.llvm.org/D76262
2020-03-17 12:12:40 -04:00
Yaxun (Sam) Liu
36f480f22c Revert "[CUDA][HIP][OpenMP] Add lib/Sema/UsedDeclVisitor.h after D70172"
This reverts commit c7fa409bcadaf4ddba1862b2e52349e0ab03d1b4.
2020-02-18 14:45:34 -05:00
Fangrui Song
c7fa409bca [CUDA][HIP][OpenMP] Add lib/Sema/UsedDeclVisitor.h after D70172 2020-02-16 20:33:07 -08:00