Skip to content

Commit

Permalink
LEWG updates and some consteval-only type fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
katzdm committed Oct 18, 2024
1 parent ce4b3cd commit bf9669e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
3 changes: 2 additions & 1 deletion clang/include/clang/AST/Type.h
Original file line number Diff line number Diff line change
Expand Up @@ -6913,7 +6913,8 @@ class TypeWithKeyword : public Type {
protected:
TypeWithKeyword(ElaboratedTypeKeyword Keyword, TypeClass tc,
QualType Canonical, TypeDependence Dependence)
: Type(tc, Canonical, Dependence, /*ConstevalOnly=*/false) {
: Type(tc, Canonical, Dependence,
!Canonical.isNull() ? Canonical->isConstevalOnly() : false) {
TypeWithKeywordBits.Keyword = llvm::to_underlying(Keyword);
}

Expand Down
5 changes: 3 additions & 2 deletions clang/lib/AST/Type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4178,7 +4178,7 @@ TagType::TagType(TypeClass TC, const TagDecl *D, QualType can)
: Type(TC, can,
D->isDependentType() ? TypeDependence::DependentInstantiation
: TypeDependence::None,
/*ConstevalOnly=*/false),
isa<RecordDecl>(D) && cast<RecordDecl>(D)->isConstevalOnly()),
decl(const_cast<TagDecl *>(D)) {}

static TagDecl *getInterestingTagDecl(TagDecl *decl) {
Expand Down Expand Up @@ -4408,7 +4408,8 @@ TemplateSpecializationType::TemplateSpecializationType(
? TypeDependence::DependentInstantiation
: toSemanticDependence(Canon->getDependence())) |
(toTypeDependence(T.getDependence()) &
TypeDependence::UnexpandedPack), /*ConstevalOnly=*/false),
TypeDependence::UnexpandedPack),
!Canon.isNull() ? Canon->isConstevalOnly() : false),
Template(T) {
TemplateSpecializationTypeBits.NumArgs = Args.size();
TemplateSpecializationTypeBits.TypeAlias = !AliasedType.isNull();
Expand Down
18 changes: 11 additions & 7 deletions libcxx/include/experimental/meta
Original file line number Diff line number Diff line change
Expand Up @@ -797,15 +797,16 @@ consteval auto u8display_string_of(info r) -> u8string_view;
enum class operators {
op_new = 1, op_delete, op_array_new, op_array_delete, op_co_await,
op_parentheses, op_square_brackets, op_arrow, op_arrow_star, op_tilde,
op_exclaim, op_plus, op_minus, op_star, op_slash, op_percent, op_caret,
op_exclamation, op_plus, op_minus, op_star, op_slash, op_percent, op_caret,
op_ampersand, op_pipe, op_equals, op_plus_equals, op_minus_equals,
op_star_equals, op_slash_equals, op_percent_equals, op_caret_equals,
op_ampersand_equals, op_pipe_equals, op_equals_equals, op_exclaim_equals,
op_less, op_greater, op_less_equals, op_greater_equals, op_three_way_compare,
op_ampersand_equals, op_pipe_equals, op_equals_equals, op_exclamation_equals,
op_less, op_greater, op_less_equals, op_greater_equals, op_spaceship,
op_ampersand_ampersand, op_pipe_pipe, op_less_less, op_greater_greater,
op_less_less_equals, op_greater_greater_equals, op_plus_plus, op_minus_minus,
op_comma,
};
using enum operators;

// Returns the operator overloaded by the represented operator function or
// operator function template.
Expand All @@ -819,7 +820,7 @@ consteval auto has_identifier(info r) -> bool {
}

// Returns the string representation of the operator.
consteval auto operator_symbol_of(operators op) -> string_view {
consteval auto symbol_of(operators op) -> string_view {
static constexpr string_view op_names[45] = {
{}, "new", "delete", "new[]", "delete[]", "coawait", "()", "[]", "->",
"->*", "~", "!", "+", "-", "*", "/", "%", "^", "&", "|", "=", "+=", "-=",
Expand All @@ -829,7 +830,7 @@ consteval auto operator_symbol_of(operators op) -> string_view {
return op_names[int(op)];
}

consteval auto u8operator_symbol_of(operators op) -> u8string_view {
consteval auto u8symbol_of(operators op) -> u8string_view {
static constexpr u8string_view op_names[45] = {
{}, u8"new", u8"delete", u8"new[]", u8"delete[]", u8"coawait", u8"()",
u8"[]", u8"->", u8"->*", u8"~", u8"!", u8"+", u8"-", u8"*", u8"/", u8"%",
Expand Down Expand Up @@ -1508,6 +1509,9 @@ struct data_member_options_t {

template <typename T> requires constructible_from<string, T>
consteval name_type(T &&in) : impl(in_place_type<string>, in) {}

private:
info unused = ^^::;
};

optional<name_type> name = nullopt;
Expand Down Expand Up @@ -2342,9 +2346,9 @@ struct pretty_printer {

static consteval auto operator_symbol_helper(operators Op) {
if constexpr (IsUtf8)
return u8operator_symbol_of(Op);
return u8symbol_of(Op);
else
return operator_symbol_of(Op);
return symbol_of(Op);
}

template <info R>
Expand Down

0 comments on commit bf9669e

Please sign in to comment.