diff options
author | Aaron Ballman <aaron@aaronballman.com> | 2023-06-05 11:03:14 -0400 |
---|---|---|
committer | Aaron Ballman <aaron@aaronballman.com> | 2023-06-05 11:09:58 -0400 |
commit | 12728e144994efe84715f4e5dbb8c3104e9f0b5a (patch) | |
tree | c5ca684a78cb019078c3720503f24e608ceb462c /clang/lib/Sema/SemaPseudoObject.cpp | |
parent | c9998ec145972714d581e19fd1c9cb276b836387 (diff) | |
download | llvm-12728e144994efe84715f4e5dbb8c3104e9f0b5a.zip llvm-12728e144994efe84715f4e5dbb8c3104e9f0b5a.tar.gz llvm-12728e144994efe84715f4e5dbb8c3104e9f0b5a.tar.bz2 |
[C] Support _Generic expressions with a type operand
_Generic accepts an expression operand whose type is matched against a
list of associations. The expression operand is unevaluated, but the
type matched is the type after lvalue conversion. This conversion loses
type information, which makes it more difficult to match against
qualified or incomplete types.
This extension allows _Generic to accept a type operand instead of an
expression operand. The type operand form does not undergo any
conversions and is matched directly against the association list.
This extension is also supported in C++ as we already supported
_Generic selection expressions there.
The RFC for this extension can be found at:
https://discourse.llvm.org/t/rfc-generic-selection-expression-with-a-type-operand/70388
Differential Revision: https://reviews.llvm.org/D149904
Diffstat (limited to 'clang/lib/Sema/SemaPseudoObject.cpp')
-rw-r--r-- | clang/lib/Sema/SemaPseudoObject.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaPseudoObject.cpp b/clang/lib/Sema/SemaPseudoObject.cpp index abbdc12..408f710 100644 --- a/clang/lib/Sema/SemaPseudoObject.cpp +++ b/clang/lib/Sema/SemaPseudoObject.cpp @@ -152,8 +152,13 @@ namespace { assocTypes.push_back(assoc.getTypeSourceInfo()); } + if (gse->isExprPredicate()) + return GenericSelectionExpr::Create( + S.Context, gse->getGenericLoc(), gse->getControllingExpr(), + assocTypes, assocExprs, gse->getDefaultLoc(), gse->getRParenLoc(), + gse->containsUnexpandedParameterPack(), resultIndex); return GenericSelectionExpr::Create( - S.Context, gse->getGenericLoc(), gse->getControllingExpr(), + S.Context, gse->getGenericLoc(), gse->getControllingType(), assocTypes, assocExprs, gse->getDefaultLoc(), gse->getRParenLoc(), gse->containsUnexpandedParameterPack(), resultIndex); } |