Skip to content
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

Replace is_incomplete_type with is_complete_type #90

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
16 changes: 8 additions & 8 deletions clang/lib/Sema/Metafunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,9 @@ static bool is_alias(APValue &Result, Sema &S, EvalFn Evaluator,
DiagFn Diagnoser, QualType ResultTy, SourceRange Range,
ArrayRef<Expr *> Args);

static bool is_incomplete_type(APValue &Result, Sema &S, EvalFn Evaluator,
DiagFn Diagnoser, QualType ResultTy,
SourceRange Range, ArrayRef<Expr *> Args);
static bool is_complete_type(APValue &Result, Sema &S, EvalFn Evaluator,
DiagFn Diagnoser, QualType ResultTy,
SourceRange Range, ArrayRef<Expr *> Args);

static bool is_template(APValue &Result, Sema &S, EvalFn Evaluator,
DiagFn Diagnoser, QualType ResultTy, SourceRange Range,
Expand Down Expand Up @@ -551,7 +551,7 @@ static constexpr Metafunction Metafunctions[] = {
{ Metafunction::MFRK_bool, 1, 1, is_variable },
{ Metafunction::MFRK_bool, 1, 1, is_type },
{ Metafunction::MFRK_bool, 1, 1, is_alias },
{ Metafunction::MFRK_bool, 1, 1, is_incomplete_type },
{ Metafunction::MFRK_bool, 1, 1, is_complete_type },
{ Metafunction::MFRK_bool, 1, 1, is_template },
{ Metafunction::MFRK_bool, 1, 1, is_function_template },
{ Metafunction::MFRK_bool, 1, 1, is_variable_template },
Expand Down Expand Up @@ -3856,9 +3856,9 @@ bool is_alias(APValue &Result, Sema &S, EvalFn Evaluator, DiagFn Diagnoser,
llvm_unreachable("unknown reflection kind");
}

bool is_incomplete_type(APValue &Result, Sema &S, EvalFn Evaluator,
DiagFn Diagnoser, QualType ResultTy, SourceRange Range,
ArrayRef<Expr *> Args) {
bool is_complete_type(APValue &Result, Sema &S, EvalFn Evaluator,
DiagFn Diagnoser, QualType ResultTy, SourceRange Range,
ArrayRef<Expr *> Args) {
assert(Args[0]->getType()->isReflectionType());
assert(ResultTy == S.Context.BoolTy);

Expand All @@ -3873,7 +3873,7 @@ bool is_incomplete_type(APValue &Result, Sema &S, EvalFn Evaluator,
if (Decl *typeDecl = findTypeDecl(RV.getReflectedType()))
(void) ensureInstantiated(S, typeDecl, Range);

result = RV.getReflectedType()->isIncompleteType();
result = !RV.getReflectedType()->isIncompleteType();
}
return SetAndSucceed(Result, makeBool(S.Context, result));
}
Expand Down
10 changes: 5 additions & 5 deletions libcxx/include/experimental/meta
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ consteval auto is_variable(info) -> bool;
consteval auto is_type(info) -> bool;
consteval auto is_type_alias(info) -> bool;
consteval auto is_namespace_alias(info) -> bool;
consteval auto is_incomplete_type(info) -> bool;
consteval auto is_complete_type(info) -> bool;
consteval auto is_template(info) -> bool;
consteval auto is_function_template(info) -> bool;
consteval auto is_variable_template(info) -> bool;
Expand Down Expand Up @@ -473,7 +473,7 @@ enum : unsigned {
__metafn_is_variable,
__metafn_is_type,
__metafn_is_alias,
__metafn_is_incomplete_type,
__metafn_is_complete_type,
__metafn_is_template,
__metafn_is_function_template,
__metafn_is_variable_template,
Expand Down Expand Up @@ -1174,9 +1174,9 @@ consteval auto is_namespace_alias(info r) -> bool {
return is_namespace(r) && __metafunction(detail::__metafn_is_alias, r);
}

// Returns true if the reflected entity is an incomplete type.
consteval auto is_incomplete_type(info r) -> bool {
return __metafunction(detail::__metafn_is_incomplete_type, r);
// Returns true if the reflected entity is a complete type.
consteval auto is_complete_type(info r) -> bool {
return __metafunction(detail::__metafn_is_complete_type, r);
}

// Returns true if the reflected entity is a template.
Expand Down
32 changes: 16 additions & 16 deletions libcxx/test/std/experimental/reflection/define-class.pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ namespace completion_with_no_fields {
struct S;
class C;
union U;
static_assert(is_incomplete_type(^^S));
static_assert(is_incomplete_type(^^C));
static_assert(is_incomplete_type(^^U));
static_assert(!is_complete_type(^^S));
static_assert(!is_complete_type(^^C));
static_assert(!is_complete_type(^^U));
static_assert(is_type(define_class(^^S, {})));
static_assert(is_type(define_class(^^C, {})));
static_assert(is_type(define_class(^^U, {})));
static_assert(!is_incomplete_type(^^S));
static_assert(!is_incomplete_type(^^C));
static_assert(!is_incomplete_type(^^U));
static_assert(is_complete_type(^^S));
static_assert(is_complete_type(^^C));
static_assert(is_complete_type(^^U));
static_assert(nonstatic_data_members_of(^^S).size() == 0);
static_assert(nonstatic_data_members_of(^^C).size() == 0);
static_assert(nonstatic_data_members_of(^^U).size() == 0);
Expand All @@ -57,14 +57,14 @@ U u;

namespace test_all_flags {
struct S;
static_assert(is_incomplete_type(^^S));
static_assert(!is_complete_type(^^S));
static_assert(is_type(define_class(^^S, {
data_member_spec(^^int, {.name="count", .alignment=16}),
data_member_spec(^^bool, {.name="flag"}),
data_member_spec(^^int, {.width=0}),
data_member_spec(^^int, {.width=5}),
})));
static_assert(!is_incomplete_type(^^S));
static_assert(is_complete_type(^^S));
// unnamed bitfields are not nonstatic data members.
static_assert(nonstatic_data_members_of(^^S).size() == 3);
static_assert(alignment_of(^^S::count) == 16);
Expand Down Expand Up @@ -92,12 +92,12 @@ static_assert(sizeof(WithEmpty) == sizeof(int));
// ================
namespace class_completion {
class C;
static_assert(is_incomplete_type(^^C));
static_assert(!is_complete_type(^^C));
static_assert(is_type(define_class(^^C, {
data_member_spec(^^int, {.name="count"}),
data_member_spec(^^bool, {.name="flag"}),
})));
static_assert(!is_incomplete_type(^^C));
static_assert(is_complete_type(^^C));
static_assert(nonstatic_data_members_of(^^C).size() == 2);
static_assert(
(members_of(^^C) |
Expand All @@ -113,12 +113,12 @@ C c;

namespace union_completion {
union U;
static_assert(is_incomplete_type(^^U));
static_assert(!is_complete_type(^^U));
static_assert(is_type(define_class(^^U, {
data_member_spec(^^int, {.name="count"}),
data_member_spec(^^bool, {.name="flag"}),
})));
static_assert(!is_incomplete_type(^^U));
static_assert(is_complete_type(^^U));
static_assert(size_of(^^U) == size_of(^^U::count));
static_assert(nonstatic_data_members_of(^^U).size() == 2);
static_assert(
Expand All @@ -140,7 +140,7 @@ template <> struct S<2> {};

consteval int nextIncompleteIdx() {
for (int Idx = 0;; ++Idx)
if (is_incomplete_type(substitute(^^S, {std::meta::reflect_value(Idx)})))
if (!is_complete_type(substitute(^^S, {std::meta::reflect_value(Idx)})))
return Idx;
}
static_assert(is_type(define_class(^^S<nextIncompleteIdx()>, {
Expand All @@ -156,7 +156,7 @@ static_assert(type_of(^^S<1>::mem) == ^^int);
static_assert(nonstatic_data_members_of(^^S<2>).size() == 0);
static_assert(nonstatic_data_members_of(^^S<3>).size() == 1);
static_assert(type_of(^^S<3>::mem) == ^^bool);
static_assert(is_incomplete_type(^^S<4>));
static_assert(!is_complete_type(^^S<4>));
} // namespace template_specialization_completion

// ============================
Expand All @@ -170,11 +170,11 @@ consteval bool completeDefn() {
}

struct S;
static_assert(is_incomplete_type(^^S));
static_assert(!is_complete_type(^^S));
static_assert(completeDefn<S,
data_member_spec(^^bool, {.name="flag"}),
data_member_spec(^^int, {.name="count"})>());
static_assert(!is_incomplete_type(^^S));
static_assert(is_complete_type(^^S));
static_assert(nonstatic_data_members_of(^^S).size() == 2);

S s;
Expand Down
Loading
Loading