Skip to content

Commit 1e61b09

Browse files
committed
CXQualTypeKind => CXTypeKind
1 parent 3afc55d commit 1e61b09

File tree

2 files changed

+41
-39
lines changed

2 files changed

+41
-39
lines changed

include/clang-c/CXCppInterOp.h

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
#include "clang-c/CXErrorCode.h"
66
#include "clang-c/CXString.h"
77
#include "clang-c/ExternC.h"
8+
#include "clang-c/Index.h"
89
#include "clang-c/Platform.h"
9-
#include "llvm-c/LLJIT.h"
1010

1111
#include <stdbool.h>
1212
#include <stddef.h>
@@ -255,20 +255,11 @@ clang_interpreter_getFunctionAddressFromMangledName(CXInterpreter I,
255255
* @{
256256
*/
257257

258-
/**
259-
* Describes the kind of entity that a type refers to.
260-
*/
261-
enum CXQualTypeKind {
262-
CXQualType_Unexposed = 0,
263-
CXQualType_Invalid = 1,
264-
// reserved for future use
265-
};
266-
267258
/**
268259
* An opaque pointer representing a type.
269260
*/
270261
typedef struct {
271-
enum CXQualTypeKind kind;
262+
enum CXTypeKind kind;
272263
void* data;
273264
const void* meta;
274265
} CXQualType;

lib/Interpreter/CXCppInterOp.cpp

Lines changed: 39 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ clang_interpreter_getFunctionAddressFromMangledName(CXInterpreter I,
198198

199199
static inline CXQualType
200200
makeCXQualType(const CXInterpreterImpl* I, const clang::QualType Ty,
201-
const CXQualTypeKind K = CXQualType_Unexposed) {
201+
const CXTypeKind K = CXType_Unexposed) {
202202
assert(I && "Invalid interpreter");
203203
return CXQualType{K, Ty.getAsOpaquePtr(), static_cast<const void*>(I)};
204204
}
@@ -273,7 +273,7 @@ CXString clang_qualtype_getTypeAsString(CXQualType type) {
273273
CXQualType clang_qualtype_getCanonicalType(CXQualType type) {
274274
const clang::QualType QT = getType(type);
275275
if (QT.isNull())
276-
return makeCXQualType(getMeta(type), clang::QualType(), CXQualType_Invalid);
276+
return makeCXQualType(getMeta(type), clang::QualType(), CXType_Invalid);
277277

278278
return makeCXQualType(getMeta(type), QT.getCanonicalType());
279279
}
@@ -286,7 +286,7 @@ CXQualType clang_qualtype_getType(CXInterpreter I, const char* name) {
286286
auto& S = getInterpreter(I)->getSema();
287287
const clang::QualType QT = Cpp::GetType(std::string(name), S);
288288
if (QT.isNull())
289-
return makeCXQualType(I, QT, CXQualType_Invalid);
289+
return makeCXQualType(I, QT, CXType_Invalid);
290290

291291
return makeCXQualType(I, QT);
292292
}
@@ -347,7 +347,7 @@ void clang_scope_dump(CXScope S) { getDecl(S)->dump(); }
347347

348348
CXQualType clang_scope_getTypeFromScope(CXScope S) {
349349
if (isNull(S))
350-
return makeCXQualType(getMeta(S), clang::QualType(), CXQualType_Invalid);
350+
return makeCXQualType(getMeta(S), clang::QualType(), CXType_Invalid);
351351

352352
auto* D = getDecl(S);
353353
if (const auto* VD = llvm::dyn_cast<clang::ValueDecl>(D))
@@ -443,7 +443,7 @@ CXQualType clang_scope_getIntegerTypeFromEnumScope(CXScope S) {
443443
if (const auto* ED = llvm::dyn_cast_or_null<clang::EnumDecl>(getDecl(S)))
444444
return makeCXQualType(getMeta(S), ED->getIntegerType());
445445

446-
return makeCXQualType(getMeta(S), clang::QualType(), CXQualType_Invalid);
446+
return makeCXQualType(getMeta(S), clang::QualType(), CXType_Invalid);
447447
}
448448

449449
void clang_disposeScopeSet(CXScopeSet* set) {
@@ -453,30 +453,34 @@ void clang_disposeScopeSet(CXScopeSet* set) {
453453

454454
CXScopeSet* clang_scope_getEnumConstants(CXScope S) {
455455
const auto* ED = llvm::dyn_cast_or_null<clang::EnumDecl>(getDecl(S));
456-
if (!ED || ED->enumerators().empty())
456+
if (!ED)
457+
return nullptr;
458+
459+
auto EI = ED->enumerator_begin();
460+
auto EE = ED->enumerator_end();
461+
if (EI == EE)
457462
return nullptr;
458463

459464
auto* Set = new CXScopeSet; // NOLINT(*-owning-memory)
460-
Set->Count = std::distance(ED->enumerator_begin(), ED->enumerator_end());
465+
Set->Count = std::distance(EI, EE);
461466
Set->Scopes = new CXScope[Set->Count]; // NOLINT(*-owning-memory)
462-
for (auto En : llvm::enumerate(ED->enumerators())) {
463-
auto Idx = En.index();
464-
auto* Val = En.value();
465-
Set->Scopes[Idx] = makeCXScope(getMeta(S), Val, CXScope_EnumConstant);
467+
for (auto I = EI; I != EE; ++I) {
468+
auto Idx = std::distance(EI, I);
469+
Set->Scopes[Idx] = makeCXScope(getMeta(S), *I, CXScope_EnumConstant);
466470
}
467471

468472
return Set;
469473
}
470474

471475
CXQualType clang_scope_getEnumConstantType(CXScope S) {
472476
if (isNull(S))
473-
return makeCXQualType(getMeta(S), clang::QualType(), CXQualType_Invalid);
477+
return makeCXQualType(getMeta(S), clang::QualType(), CXType_Invalid);
474478

475479
if (const auto* ECD =
476480
llvm::dyn_cast_or_null<clang::EnumConstantDecl>(getDecl(S)))
477481
return makeCXQualType(getMeta(S), ECD->getType());
478482

479-
return makeCXQualType(getMeta(S), clang::QualType(), CXQualType_Invalid);
483+
return makeCXQualType(getMeta(S), clang::QualType(), CXType_Invalid);
480484
}
481485

482486
size_t clang_scope_getEnumConstantValue(CXScope S) {
@@ -566,17 +570,20 @@ CXString clang_scope_getQualifiedCompleteName(CXScope S) {
566570

567571
CXScopeSet* clang_scope_getUsingNamespaces(CXScope S) {
568572
const auto* DC = llvm::dyn_cast_or_null<clang::DeclContext>(getDecl(S));
569-
if (!DC || DC->using_directives().empty())
573+
if (!DC)
574+
return nullptr;
575+
576+
auto DI = DC->using_directives().begin();
577+
auto DE = DC->using_directives().end();
578+
if (DI == DE)
570579
return nullptr;
571580

572581
auto* Set = new CXScopeSet; // NOLINT(*-owning-memory)
573-
Set->Count = std::distance(DC->using_directives().begin(),
574-
DC->using_directives().end());
582+
Set->Count = std::distance(DI, DE);
575583
Set->Scopes = new CXScope[Set->Count]; // NOLINT(*-owning-memory)
576-
for (auto En : llvm::enumerate(DC->using_directives())) {
577-
auto Idx = En.index();
578-
auto* Val = En.value();
579-
Set->Scopes[Idx] = makeCXScope(getMeta(S), Val->getNominatedNamespace(),
584+
for (auto I = DI; I != DE; ++I) {
585+
auto Idx = std::distance(DI, I);
586+
Set->Scopes[Idx] = makeCXScope(getMeta(S), (*I)->getNominatedNamespace(),
580587
CXScope_Namespace);
581588
}
582589

@@ -882,7 +889,7 @@ CXQualType clang_scope_getFunctionReturnType(CXScope func) {
882889
return makeCXQualType(getMeta(func), FTD->getReturnType());
883890
}
884891

885-
return makeCXQualType(getMeta(func), clang::QualType(), CXQualType_Invalid);
892+
return makeCXQualType(getMeta(func), clang::QualType(), CXType_Invalid);
886893
}
887894

888895
size_t clang_scope_getFunctionNumArgs(CXScope func) {
@@ -917,7 +924,7 @@ CXQualType clang_scope_getFunctionArgType(CXScope func, size_t iarg) {
917924
}
918925
}
919926

920-
return makeCXQualType(getMeta(func), clang::QualType(), CXQualType_Invalid);
927+
return makeCXQualType(getMeta(func), clang::QualType(), CXType_Invalid);
921928
}
922929

923930
CXString clang_scope_getFunctionSignature(CXScope func) {
@@ -1131,13 +1138,17 @@ CXScopeSet* clang_scope_getDatamembers(CXScope S) {
11311138
if (!CXXRD)
11321139
return nullptr;
11331140

1141+
auto FI = CXXRD->field_begin();
1142+
auto FE = CXXRD->field_end();
1143+
if (FI == FE)
1144+
return nullptr;
1145+
11341146
auto* Set = new CXScopeSet; // NOLINT(*-owning-memory)
1135-
Set->Count = std::distance(CXXRD->field_begin(), CXXRD->field_end());
1147+
Set->Count = std::distance(FI, FE);
11361148
Set->Scopes = new CXScope[Set->Count]; // NOLINT(*-owning-memory)
1137-
for (auto En : llvm::enumerate(CXXRD->fields())) {
1138-
auto Idx = En.index();
1139-
auto* Val = En.value();
1140-
Set->Scopes[Idx] = makeCXScope(getMeta(S), Val, CXScope_Function);
1149+
for (auto I = FE; I != FE; ++I) {
1150+
auto Idx = std::distance(FI, I);
1151+
Set->Scopes[Idx] = makeCXScope(getMeta(S), *I, CXScope_Field);
11411152
}
11421153

11431154
return Set;
@@ -1206,7 +1217,7 @@ CXQualType clang_scope_getVariableType(CXScope var) {
12061217
if (const auto* DD = llvm::dyn_cast_or_null<clang::DeclaratorDecl>(D))
12071218
return makeCXQualType(getMeta(var), DD->getType());
12081219

1209-
return makeCXQualType(getMeta(var), clang::QualType(), CXQualType_Invalid);
1220+
return makeCXQualType(getMeta(var), clang::QualType(), CXType_Invalid);
12101221
}
12111222

12121223
namespace Cpp {

0 commit comments

Comments
 (0)