Skip to content

Commit

Permalink
Merge pull request #337 from janvennemann/TIMOB-27824
Browse files Browse the repository at this point in the history
fix(ios): handle new external vector type
  • Loading branch information
lokeshchdhry committed Apr 3, 2020
2 parents 49a67d7 + d99bf40 commit 3fa5fb9
Show file tree
Hide file tree
Showing 11 changed files with 117 additions and 41 deletions.
29 changes: 29 additions & 0 deletions iphone/hooks/generate/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,29 @@ function isPrimitive(type) {
return false;
}

/**
* Checks whether the given type is an unexpected unknown type.
*
* This can happen when a new version of Xcode/libclang adds new types that
* our metabase parser doesn't know about.
*
* @param {string} type
* @param {object} meta
*/
function isUnknown(type, meta) {
if (type.startsWith('unknown type:')) {
if (!isUnknown.warned[type]) {
console.warn(`Unexpected ${type}`, meta);
isUnknown.warned[type] = true;
}

return true;
}

return false;
}
isUnknown.warned = {};

function addImport (state, name, obj) {
if (name === 'NSObject') {
obj = obj || {};
Expand Down Expand Up @@ -493,6 +516,9 @@ function getObjCReturnType (value) {
return 'SEL';
}
}
if (isUnknown(value.type, value)) {
return value.value || 'void *';
}
if (isPrimitive(value.type)) {
return value.value || getPrimitiveValue(value.type);
}
Expand Down Expand Up @@ -561,6 +587,9 @@ function getObjCReturnResult (value, name, returns, asPointer) {
return returns + ' (' + name + ' == nil) ? (id)[NSNull null] : (id)[HyperloopPointer pointer:(__bridge void *)' + asPointer + name +' encoding:"' + value.encoding + '"];';
}
}
if (isUnknown(value.type, value)) {
return returns + ' (' + name + ' == nil) ? (id)[NSNull null] : (id)[HyperloopPointer pointer:(const void *)' + asPointer + name + ' encoding:@encode(' + value.value + ')];';
}
if (isPrimitive(value.type)) {
switch (value.encoding) {
case 'd':
Expand Down
8 changes: 4 additions & 4 deletions packages/hyperloop-ios-metabase/include/clang-c/BuildSystem.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*==-- clang-c/BuildSystem.h - Utilities for use by build systems -*- C -*-===*\
|* *|
|* The LLVM Compiler Infrastructure *|
|* *|
|* This file is distributed under the University of Illinois Open Source *|
|* License. See LICENSE.TXT for details. *|
|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *|
|* Exceptions. *|
|* See https://llvm.org/LICENSE.txt for license information. *|
|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *|
|* *|
|*===----------------------------------------------------------------------===*|
|* *|
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*===-- clang-c/CXCompilationDatabase.h - Compilation database ---*- C -*-===*\
|* *|
|* The LLVM Compiler Infrastructure *|
|* *|
|* This file is distributed under the University of Illinois Open Source *|
|* License. See LICENSE.TXT for details. *|
|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *|
|* Exceptions. *|
|* See https://llvm.org/LICENSE.txt for license information. *|
|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *|
|* *|
|*===----------------------------------------------------------------------===*|
|* *|
Expand Down
8 changes: 4 additions & 4 deletions packages/hyperloop-ios-metabase/include/clang-c/CXErrorCode.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*===-- clang-c/CXErrorCode.h - C Index Error Codes --------------*- C -*-===*\
|* *|
|* The LLVM Compiler Infrastructure *|
|* *|
|* This file is distributed under the University of Illinois Open Source *|
|* License. See LICENSE.TXT for details. *|
|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *|
|* Exceptions. *|
|* See https://llvm.org/LICENSE.txt for license information. *|
|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *|
|* *|
|*===----------------------------------------------------------------------===*|
|* *|
Expand Down
8 changes: 4 additions & 4 deletions packages/hyperloop-ios-metabase/include/clang-c/CXString.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*===-- clang-c/CXString.h - C Index strings --------------------*- C -*-===*\
|* *|
|* The LLVM Compiler Infrastructure *|
|* *|
|* This file is distributed under the University of Illinois Open Source *|
|* License. See LICENSE.TXT for details. *|
|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *|
|* Exceptions. *|
|* See https://llvm.org/LICENSE.txt for license information. *|
|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *|
|* *|
|*===----------------------------------------------------------------------===*|
|* *|
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*==-- clang-c/Documentation.h - Utilities for comment processing -*- C -*-===*\
|* *|
|* The LLVM Compiler Infrastructure *|
|* *|
|* This file is distributed under the University of Illinois Open Source *|
|* License. See LICENSE.TXT for details. *|
|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *|
|* Exceptions. *|
|* See https://llvm.org/LICENSE.txt for license information. *|
|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *|
|* *|
|*===----------------------------------------------------------------------===*|
|* *|
Expand Down
65 changes: 53 additions & 12 deletions packages/hyperloop-ios-metabase/include/clang-c/Index.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*===-- clang-c/Index.h - Indexing Public C Interface -------------*- C -*-===*\
|* *|
|* The LLVM Compiler Infrastructure *|
|* *|
|* This file is distributed under the University of Illinois Open Source *|
|* License. See LICENSE.TXT for details. *|
|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *|
|* Exceptions. *|
|* See https://llvm.org/LICENSE.txt for license information. *|
|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *|
|* *|
|*===----------------------------------------------------------------------===*|
|* *|
Expand Down Expand Up @@ -32,7 +32,7 @@
* compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
*/
#define CINDEX_VERSION_MAJOR 0
#define CINDEX_VERSION_MINOR 50
#define CINDEX_VERSION_MINOR 59

#define CINDEX_VERSION_ENCODE(major, minor) ( \
((major) * 10000) \
Expand Down Expand Up @@ -221,7 +221,12 @@ enum CXCursor_ExceptionSpecificationKind {
/**
* The exception specification has not been parsed yet.
*/
CXCursor_ExceptionSpecificationKind_Unparsed
CXCursor_ExceptionSpecificationKind_Unparsed,

/**
* The cursor has a __declspec(nothrow) exception specification.
*/
CXCursor_ExceptionSpecificationKind_NoThrow
};

/**
Expand Down Expand Up @@ -1341,7 +1346,17 @@ enum CXTranslationUnit_Flags {
/**
* Used to indicate that implicit attributes should be visited.
*/
CXTranslationUnit_VisitImplicitAttributes = 0x2000
CXTranslationUnit_VisitImplicitAttributes = 0x2000,

/**
* Used to indicate that non-errors from included files should be ignored.
*
* If set, clang_getDiagnosticSetFromTU() will not report e.g. warnings from
* included files anymore. This speeds up clang_getDiagnosticSetFromTU() for
* the case where these warnings are not of interest, as for an IDE for
* example, which typically shows only the diagnostics in the main file.
*/
CXTranslationUnit_IgnoreNonErrorsFromIncludedFiles = 0x4000
};

/**
Expand Down Expand Up @@ -2531,7 +2546,11 @@ enum CXCursorKind {
*/
CXCursor_OMPTargetTeamsDistributeSimdDirective = 279,

CXCursor_LastStmt = CXCursor_OMPTargetTeamsDistributeSimdDirective,
/** C++2a std::bit_cast expression.
*/
CXCursor_BuiltinBitCastExpr = 280,

CXCursor_LastStmt = CXCursor_BuiltinBitCastExpr,

/**
* Cursor that represents the translation unit itself.
Expand Down Expand Up @@ -2586,7 +2605,11 @@ enum CXCursorKind {
CXCursor_ObjCRuntimeVisible = 435,
CXCursor_ObjCBoxable = 436,
CXCursor_FlagEnum = 437,
CXCursor_LastAttr = CXCursor_FlagEnum,
CXCursor_ConvergentAttr = 438,
CXCursor_WarnUnusedAttr = 439,
CXCursor_WarnUnusedResultAttr = 440,
CXCursor_AlignedAttr = 441,
CXCursor_LastAttr = CXCursor_AlignedAttr,

/* Preprocessing */
CXCursor_PreprocessingDirective = 500,
Expand Down Expand Up @@ -3311,7 +3334,9 @@ enum CXTypeKind {
CXType_OCLIntelSubgroupAVCImeResultDualRefStreamout = 173,
CXType_OCLIntelSubgroupAVCImeSingleRefStreamin = 174,

CXType_OCLIntelSubgroupAVCImeDualRefStreamin = 175
CXType_OCLIntelSubgroupAVCImeDualRefStreamin = 175,

CXType_ExtVector = 176
};

/**
Expand Down Expand Up @@ -3838,7 +3863,11 @@ enum CXTypeLayoutError {
/**
* The Field name is not valid for this record.
*/
CXTypeLayoutError_InvalidFieldName = -5
CXTypeLayoutError_InvalidFieldName = -5,
/**
* The type is undeduced.
*/
CXTypeLayoutError_Undeduced = -6
};

/**
Expand Down Expand Up @@ -3910,11 +3939,23 @@ CINDEX_LINKAGE CXType clang_Type_getModifiedType(CXType T);
*/
CINDEX_LINKAGE long long clang_Cursor_getOffsetOfField(CXCursor C);

/**
* Determine whether the given cursor represents an anonymous
* tag or namespace
*/
CINDEX_LINKAGE unsigned clang_Cursor_isAnonymous(CXCursor C);

/**
* Determine whether the given cursor represents an anonymous record
* declaration.
*/
CINDEX_LINKAGE unsigned clang_Cursor_isAnonymous(CXCursor C);
CINDEX_LINKAGE unsigned clang_Cursor_isAnonymousRecordDecl(CXCursor C);

/**
* Determine whether the given cursor represents an inline namespace
* declaration.
*/
CINDEX_LINKAGE unsigned clang_Cursor_isInlineNamespace(CXCursor C);

enum CXRefQualifierKind {
/** No ref-qualifier was provided. */
Expand Down
8 changes: 4 additions & 4 deletions packages/hyperloop-ios-metabase/include/clang-c/Platform.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*===-- clang-c/Platform.h - C Index platform decls -------------*- C -*-===*\
|* *|
|* The LLVM Compiler Infrastructure *|
|* *|
|* This file is distributed under the University of Illinois Open Source *|
|* License. See LICENSE.TXT for details. *|
|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *|
|* Exceptions. *|
|* See https://llvm.org/LICENSE.txt for license information. *|
|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *|
|* *|
|*===----------------------------------------------------------------------===*|
|* *|
Expand Down
3 changes: 2 additions & 1 deletion packages/hyperloop-ios-metabase/src/function.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ namespace hyperloop {
case CXCursor_ConstAttr:
case CXCursor_PureAttr:
case CXCursor_VisibilityAttr:
case CXCursor_NSReturnsRetained: {
case CXCursor_NSReturnsRetained:
case CXCursor_WarnUnusedResultAttr: {
break;
}
default: {
Expand Down
8 changes: 4 additions & 4 deletions packages/hyperloop-ios-metabase/src/union.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ namespace hyperloop {
break;
}
default: {
std::cerr << "not handled, union: " << displayName << " kind: " << kind << std::endl;
std::map<std::string, std::string> location;
hyperloop::getSourceLocation(cursor, unionDef->getContext(), location);
std::cout << "union: " << displayName << " kind: " << kind << ", " << hyperloop::toJSON(location) << std::endl;
// std::cerr << "not handled, union: " << displayName << " kind: " << kind << std::endl;
// std::map<std::string, std::string> location;
// hyperloop::getSourceLocation(cursor, unionDef->getContext(), location);
// std::cout << "union: " << displayName << " kind: " << kind << ", " << hyperloop::toJSON(location) << std::endl;
break;
}
}
Expand Down
5 changes: 5 additions & 0 deletions packages/hyperloop-ios-metabase/src/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,11 @@ namespace hyperloop {
case CXType_MemberPointer: {
return "member_pointer";
}
case CXType_ExtVector: {
// fallback to unexposed since external vectors have no encoding yet
// @see http://llvm.org/viewvc/llvm-project?view=revision&revision=216301
return "unexposed";
}
default: {
std::stringstream ss;
ss << "unknown type: ";
Expand Down

0 comments on commit 3fa5fb9

Please sign in to comment.