Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Mar 28, 2020. It is now read-only.
/swift-clangPublic archive

Commit89e5753

Browse files
authored
Merge pull request#352 from kastiglione/indexstore-flag_enum2
Mark indexstore enum flag types with flag_enum attribute
2 parents9ebee0a +f17afab commit89e5753

File tree

4 files changed

+40
-20
lines changed

4 files changed

+40
-20
lines changed

‎include/clang/Index/IndexDataStoreSymbolUtils.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ indexstore_symbol_subkind_t getIndexStoreSubKind(SymbolSubKind K);
4242
indexstore_symbol_language_tgetIndexStoreLang(SymbolLanguage L);
4343

4444
/// Map a SymbolPropertySet to its indexstore representation.
45-
uint64_tgetIndexStoreProperties(SymbolPropertySet Props);
45+
indexstore_symbol_property_tgetIndexStoreProperties(SymbolPropertySet Props);
4646

4747
/// Map a SymbolRoleSet to its indexstore representation.
48-
uint64_tgetIndexStoreRoles(SymbolRoleSet Roles);
48+
indexstore_symbol_role_tgetIndexStoreRoles(SymbolRoleSet Roles);
4949

5050
}// end namespace index
5151
}// end namespace clang

‎include/indexstore/indexstore.h‎

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,26 @@
8484
# defineINDEXSTORE_NOESCAPE
8585
#endif
8686

87+
#if__has_attribute(flag_enum)
88+
# defineINDEXSTORE_FLAG_ENUM_ATTR __attribute__((flag_enum))
89+
#else
90+
# defineINDEXSTORE_FLAG_ENUM_ATTR
91+
#endif
92+
93+
#if__has_attribute(enum_extensibility)
94+
# defineINDEXSTORE_OPEN_ENUM_ATTR __attribute__((enum_extensibility(open)))
95+
#else
96+
# defineINDEXSTORE_OPEN_ENUM_ATTR
97+
#endif
98+
99+
#defineINDEXSTORE_OPTIONS_ATTRS INDEXSTORE_OPEN_ENUM_ATTR INDEXSTORE_FLAG_ENUM_ATTR
100+
101+
#if__has_extension(cxx_strong_enums)||__has_feature(objc_fixed_enum)
102+
# defineINDEXSTORE_OPTIONS(_type,_name) enum INDEXSTORE_OPTIONS_ATTRS _name : _type _name; enum INDEXSTORE_OPTIONS_ATTRS _name : _type
103+
#else
104+
# defineINDEXSTORE_OPTIONS(_type,_name) _type _name; enum INDEXSTORE_OPTIONS_ATTRS
105+
#endif
106+
87107
INDEXSTORE_BEGIN_DECLS
88108

89109
typedefvoid*indexstore_error_t;
@@ -266,7 +286,7 @@ typedef enum {
266286
INDEXSTORE_SYMBOL_SUBKIND_SWIFTACCESSORMODIFY=1015,
267287
}indexstore_symbol_subkind_t;
268288

269-
typedefenum {
289+
typedefINDEXSTORE_OPTIONS(uint64_t,indexstore_symbol_property_t) {
270290
INDEXSTORE_SYMBOL_PROPERTY_GENERIC=1 <<0,
271291
INDEXSTORE_SYMBOL_PROPERTY_TEMPLATE_PARTIAL_SPECIALIZATION=1 <<1,
272292
INDEXSTORE_SYMBOL_PROPERTY_TEMPLATE_SPECIALIZATION=1 <<2,
@@ -276,7 +296,7 @@ typedef enum {
276296
INDEXSTORE_SYMBOL_PROPERTY_GKINSPECTABLE=1 <<6,
277297
INDEXSTORE_SYMBOL_PROPERTY_LOCAL=1 <<7,
278298
INDEXSTORE_SYMBOL_PROPERTY_PROTOCOL_INTERFACE=1 <<8,
279-
}indexstore_symbol_property_t;
299+
};
280300

281301
typedefenum {
282302
INDEXSTORE_SYMBOL_LANG_C=0,
@@ -286,7 +306,7 @@ typedef enum {
286306
INDEXSTORE_SYMBOL_LANG_SWIFT=100,
287307
}indexstore_symbol_language_t;
288308

289-
typedefenum {
309+
typedefINDEXSTORE_OPTIONS(uint64_t,indexstore_symbol_role_t) {
290310
INDEXSTORE_SYMBOL_ROLE_DECLARATION=1 <<0,
291311
INDEXSTORE_SYMBOL_ROLE_DEFINITION=1 <<1,
292312
INDEXSTORE_SYMBOL_ROLE_REFERENCE=1 <<2,
@@ -310,7 +330,7 @@ typedef enum {
310330
INDEXSTORE_SYMBOL_ROLE_REL_CONTAINEDBY=1 <<16,
311331
INDEXSTORE_SYMBOL_ROLE_REL_IBTYPEOF=1 <<17,
312332
INDEXSTORE_SYMBOL_ROLE_REL_SPECIALIZATIONOF=1 <<18,
313-
}indexstore_symbol_role_t;
333+
};
314334

315335
INDEXSTORE_PUBLICindexstore_symbol_language_t
316336
indexstore_symbol_get_language(indexstore_symbol_t);
@@ -321,13 +341,13 @@ indexstore_symbol_get_kind(indexstore_symbol_t);
321341
INDEXSTORE_PUBLICindexstore_symbol_subkind_t
322342
indexstore_symbol_get_subkind(indexstore_symbol_t);
323343

324-
INDEXSTORE_PUBLICuint64_t
344+
INDEXSTORE_PUBLICindexstore_symbol_property_t
325345
indexstore_symbol_get_properties(indexstore_symbol_t);
326346

327-
INDEXSTORE_PUBLICuint64_t
347+
INDEXSTORE_PUBLICindexstore_symbol_role_t
328348
indexstore_symbol_get_roles(indexstore_symbol_t);
329349

330-
INDEXSTORE_PUBLICuint64_t
350+
INDEXSTORE_PUBLICindexstore_symbol_role_t
331351
indexstore_symbol_get_related_roles(indexstore_symbol_t);
332352

333353
INDEXSTORE_PUBLICindexstore_string_ref_t
@@ -341,7 +361,7 @@ indexstore_symbol_get_codegen_name(indexstore_symbol_t);
341361

342362
typedefvoid*indexstore_symbol_relation_t;
343363

344-
INDEXSTORE_PUBLICuint64_t
364+
INDEXSTORE_PUBLICindexstore_symbol_role_t
345365
indexstore_symbol_relation_get_roles(indexstore_symbol_relation_t);
346366

347367
INDEXSTORE_PUBLICindexstore_symbol_t
@@ -363,7 +383,7 @@ indexstore_occurrence_relations_apply_f(indexstore_occurrence_t,
363383
void*context,
364384
INDEXSTORE_NOESCAPEbool(*applier)(void*context,indexstore_symbol_relation_tsymbol_rel));
365385

366-
INDEXSTORE_PUBLICuint64_t
386+
INDEXSTORE_PUBLICindexstore_symbol_role_t
367387
indexstore_occurrence_get_roles(indexstore_occurrence_t);
368388

369389
INDEXSTORE_PUBLICvoid

‎lib/Index/IndexDataStoreUtils.cpp‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ indexstore_symbol_language_t index::getIndexStoreLang(SymbolLanguage L) {
412412
}
413413

414414
/// Map a SymbolPropertySet to its indexstore representation.
415-
uint64_tindex::getIndexStoreProperties(SymbolPropertySet Props) {
415+
indexstore_symbol_property_tindex::getIndexStoreProperties(SymbolPropertySet Props) {
416416
uint64_t storeProp =0;
417417
applyForEachSymbolProperty(Props, [&](SymbolProperty prop) {
418418
switch (prop) {
@@ -445,11 +445,11 @@ uint64_t index::getIndexStoreProperties(SymbolPropertySet Props) {
445445
break;
446446
}
447447
});
448-
return storeProp;
448+
returnstatic_cast<indexstore_symbol_property_t>(storeProp);
449449
}
450450

451451
/// Map a SymbolRoleSet to its indexstore representation.
452-
uint64_tindex::getIndexStoreRoles(SymbolRoleSet Roles) {
452+
indexstore_symbol_role_tindex::getIndexStoreRoles(SymbolRoleSet Roles) {
453453
uint64_t storeRoles =0;
454454
applyForEachSymbolRole(Roles, [&](SymbolRole role) {
455455
switch (role) {
@@ -518,5 +518,5 @@ uint64_t index::getIndexStoreRoles(SymbolRoleSet Roles) {
518518
break;
519519
}
520520
});
521-
return storeRoles;
521+
returnstatic_cast<indexstore_symbol_role_t>(storeRoles);
522522
}

‎tools/IndexStore/IndexStore.cpp‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -321,17 +321,17 @@ indexstore_symbol_get_language(indexstore_symbol_t sym) {
321321
returngetIndexStoreLang(static_cast<IndexRecordDecl *>(sym)->SymInfo.Lang);
322322
}
323323

324-
uint64_t
324+
indexstore_symbol_property_t
325325
indexstore_symbol_get_properties(indexstore_symbol_t sym) {
326326
returngetIndexStoreProperties(static_cast<IndexRecordDecl *>(sym)->SymInfo.Properties);
327327
}
328328

329-
uint64_t
329+
indexstore_symbol_role_t
330330
indexstore_symbol_get_roles(indexstore_symbol_t sym) {
331331
returngetIndexStoreRoles(static_cast<IndexRecordDecl *>(sym)->Roles);
332332
}
333333

334-
uint64_t
334+
indexstore_symbol_role_t
335335
indexstore_symbol_get_related_roles(indexstore_symbol_t sym) {
336336
returngetIndexStoreRoles(static_cast<IndexRecordDecl *>(sym)->RelatedRoles);
337337
}
@@ -354,7 +354,7 @@ indexstore_symbol_get_codegen_name(indexstore_symbol_t sym) {
354354
returntoIndexStoreString(D->CodeGenName);
355355
}
356356

357-
uint64_t
357+
indexstore_symbol_role_t
358358
indexstore_symbol_relation_get_roles(indexstore_symbol_relation_t sym_rel) {
359359
returngetIndexStoreRoles(static_cast<IndexRecordRelation *>(sym_rel)->Roles);
360360
}
@@ -394,7 +394,7 @@ indexstore_occurrence_relations_apply_f(indexstore_occurrence_t occur,
394394
returntrue;
395395
}
396396

397-
uint64_t
397+
indexstore_symbol_role_t
398398
indexstore_occurrence_get_roles(indexstore_occurrence_t occur) {
399399
returngetIndexStoreRoles(static_cast<IndexRecordOccurrence*>(occur)->Roles);
400400
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp