| author | |
| committer | |
| log | 46e1c34fcfe0973735c75a0c210db314030798f0 |
| tree | 85d3b12619d3621ba7924537cf2f96b5ecfb4715 |
| parent | 9bbd71c9ab3915b8bd8619a319a0eb6de2e2d152 |
| signature |
See #19646 files changed, 102 insertions(+), 27 deletions(-)
src-self-hosted/clang.zig+18-5| ... | ... | @@ -806,13 +806,13 @@ pub const enum_ZigClangAPValueKind = extern enum { |
| 806 | 806 | ZigClangAPValueAddrLabelDiff, |
| 807 | 807 | }; |
| 808 | 808 | pub extern fn ZigClangSourceManager_getSpellingLoc(arg0: ?*const struct_ZigClangSourceManager, Loc: struct_ZigClangSourceLocation) struct_ZigClangSourceLocation; |
| 809 | pub extern fn ZigClangSourceManager_getFilename(arg0: ?*const struct_ZigClangSourceManager, SpellingLoc: struct_ZigClangSourceLocation) [*c]const u8; | |
| 809 | pub extern fn ZigClangSourceManager_getFilename(self: *const struct_ZigClangSourceManager, SpellingLoc: struct_ZigClangSourceLocation) ?[*]const u8; | |
| 810 | 810 | pub extern fn ZigClangSourceManager_getSpellingLineNumber(arg0: ?*const struct_ZigClangSourceManager, Loc: struct_ZigClangSourceLocation) c_uint; |
| 811 | 811 | pub extern fn ZigClangSourceManager_getSpellingColumnNumber(arg0: ?*const struct_ZigClangSourceManager, Loc: struct_ZigClangSourceLocation) c_uint; |
| 812 | 812 | pub extern fn ZigClangSourceManager_getCharacterData(arg0: ?*const struct_ZigClangSourceManager, SL: struct_ZigClangSourceLocation) [*c]const u8; |
| 813 | 813 | pub extern fn ZigClangASTContext_getPointerType(arg0: ?*const struct_ZigClangASTContext, T: struct_ZigClangQualType) struct_ZigClangQualType; |
| 814 | 814 | pub extern fn ZigClangASTUnit_getASTContext(arg0: ?*struct_ZigClangASTUnit) ?*struct_ZigClangASTContext; |
| 815 | pub extern fn ZigClangASTUnit_getSourceManager(arg0: ?*struct_ZigClangASTUnit) ?*struct_ZigClangSourceManager; | |
| 815 | pub extern fn ZigClangASTUnit_getSourceManager(self: *struct_ZigClangASTUnit) *struct_ZigClangSourceManager; | |
| 816 | 816 | pub extern fn ZigClangASTUnit_visitLocalTopLevelDecls(self: *struct_ZigClangASTUnit, context: ?*c_void, Fn: ?extern fn (?*c_void, *const struct_ZigClangDecl) bool) bool; |
| 817 | 817 | pub extern fn ZigClangRecordType_getDecl(record_ty: ?*const struct_ZigClangRecordType) ?*const struct_ZigClangRecordDecl; |
| 818 | 818 | pub extern fn ZigClangEnumType_getDecl(record_ty: ?*const struct_ZigClangEnumType) ?*const struct_ZigClangEnumDecl; |
| ... | ... | @@ -824,6 +824,7 @@ pub extern fn ZigClangEnumDecl_getDefinition(arg0: ?*const struct_ZigClangEnumDe |
| 824 | 824 | pub extern fn ZigClangRecordDecl_getLocation(arg0: ?*const struct_ZigClangRecordDecl) struct_ZigClangSourceLocation; |
| 825 | 825 | pub extern fn ZigClangEnumDecl_getLocation(arg0: ?*const struct_ZigClangEnumDecl) struct_ZigClangSourceLocation; |
| 826 | 826 | pub extern fn ZigClangTypedefNameDecl_getLocation(arg0: ?*const struct_ZigClangTypedefNameDecl) struct_ZigClangSourceLocation; |
| 827 | pub extern fn ZigClangDecl_getLocation(self: *const ZigClangDecl) ZigClangSourceLocation; | |
| 827 | 828 | pub extern fn ZigClangRecordDecl_isUnion(record_decl: ?*const struct_ZigClangRecordDecl) bool; |
| 828 | 829 | pub extern fn ZigClangRecordDecl_isStruct(record_decl: ?*const struct_ZigClangRecordDecl) bool; |
| 829 | 830 | pub extern fn ZigClangRecordDecl_isAnonymousStructOrUnion(record_decl: ?*const struct_ZigClangRecordDecl) bool; |
| ... | ... | @@ -833,7 +834,7 @@ pub extern fn ZigClangSourceLocation_eq(a: struct_ZigClangSourceLocation, b: str |
| 833 | 834 | pub extern fn ZigClangTypedefType_getDecl(arg0: ?*const struct_ZigClangTypedefType) ?*const struct_ZigClangTypedefNameDecl; |
| 834 | 835 | pub extern fn ZigClangTypedefNameDecl_getUnderlyingType(arg0: ?*const struct_ZigClangTypedefNameDecl) struct_ZigClangQualType; |
| 835 | 836 | pub extern fn ZigClangQualType_getCanonicalType(arg0: struct_ZigClangQualType) struct_ZigClangQualType; |
| 836 | pub extern fn ZigClangQualType_getTypePtr(arg0: struct_ZigClangQualType) ?*const struct_ZigClangType; | |
| 837 | pub extern fn ZigClangQualType_getTypePtr(self: struct_ZigClangQualType) *const struct_ZigClangType; | |
| 837 | 838 | pub extern fn ZigClangQualType_addConst(arg0: [*c]struct_ZigClangQualType) void; |
| 838 | 839 | pub extern fn ZigClangQualType_eq(arg0: struct_ZigClangQualType, arg1: struct_ZigClangQualType) bool; |
| 839 | 840 | pub extern fn ZigClangQualType_isConstQualified(arg0: struct_ZigClangQualType) bool; |
| ... | ... | @@ -841,7 +842,7 @@ pub extern fn ZigClangQualType_isVolatileQualified(arg0: struct_ZigClangQualType |
| 841 | 842 | pub extern fn ZigClangQualType_isRestrictQualified(arg0: struct_ZigClangQualType) bool; |
| 842 | 843 | pub extern fn ZigClangType_getTypeClass(self: ?*const struct_ZigClangType) enum_ZigClangTypeClass; |
| 843 | 844 | pub extern fn ZigClangType_isVoidType(self: ?*const struct_ZigClangType) bool; |
| 844 | pub extern fn ZigClangType_getTypeClassName(self: ?*const struct_ZigClangType) [*c]const u8; | |
| 845 | pub extern fn ZigClangType_getTypeClassName(self: *const struct_ZigClangType) [*]const u8; | |
| 845 | 846 | pub extern fn ZigClangStmt_getBeginLoc(self: ?*const struct_ZigClangStmt) struct_ZigClangSourceLocation; |
| 846 | 847 | pub extern fn ZigClangStmt_getStmtClass(self: ?*const struct_ZigClangStmt) enum_ZigClangStmtClass; |
| 847 | 848 | pub extern fn ZigClangStmt_classof_Expr(self: ?*const struct_ZigClangStmt) bool; |
| ... | ... | @@ -863,6 +864,10 @@ pub extern fn ZigClangAPSInt_getRawData(self: ?*const struct_ZigClangAPSInt) [*c |
| 863 | 864 | pub extern fn ZigClangAPSInt_getNumWords(self: ?*const struct_ZigClangAPSInt) c_uint; |
| 864 | 865 | pub extern fn ZigClangAPValueLValueBase_dyn_cast_Expr(self: struct_ZigClangAPValueLValueBase) ?*const struct_ZigClangExpr; |
| 865 | 866 | pub extern fn ZigClangASTUnit_delete(arg0: ?*struct_ZigClangASTUnit) void; |
| 867 | ||
| 868 | pub extern fn ZigClangFunctionDecl_getType(self: *const struct_ZigClangFunctionDecl) struct_ZigClangQualType; | |
| 869 | pub extern fn ZigClangFunctionDecl_getLocation(self: *const struct_ZigClangFunctionDecl) struct_ZigClangSourceLocation; | |
| 870 | ||
| 866 | 871 | pub const ZigClangSourceLocation = struct_ZigClangSourceLocation; |
| 867 | 872 | pub const ZigClangQualType = struct_ZigClangQualType; |
| 868 | 873 | pub const ZigClangAPValueLValueBase = struct_ZigClangAPValueLValueBase; |
| ... | ... | @@ -944,6 +949,10 @@ pub const ZigClangStmtClass = enum_ZigClangStmtClass; |
| 944 | 949 | pub const ZigClangCK = enum_ZigClangCK; |
| 945 | 950 | pub const ZigClangAPValueKind = enum_ZigClangAPValueKind; |
| 946 | 951 | |
| 952 | pub const struct_ZigClangSourceLocation = extern struct { | |
| 953 | ID: c_uint, | |
| 954 | }; | |
| 955 | ||
| 947 | 956 | pub const Stage2ErrorMsg = extern struct { |
| 948 | 957 | filename_ptr: ?[*]const u8, |
| 949 | 958 | filename_len: usize, |
| ... | ... | @@ -968,8 +977,8 @@ pub extern fn ZigClangLoadFromCommandLine( |
| 968 | 977 | resources_path: [*c]const u8, |
| 969 | 978 | ) ?*ZigClangASTUnit; |
| 970 | 979 | |
| 971 | ||
| 972 | 980 | pub extern fn ZigClangDecl_getKind(decl: *const ZigClangDecl) ZigClangDeclKind; |
| 981 | pub extern fn ZigClangDecl_getDeclKindName(decl: *const struct_ZigClangDecl) [*]const u8; | |
| 973 | 982 | |
| 974 | 983 | pub const ZigClangDeclKind = extern enum { |
| 975 | 984 | AccessSpec, |
| ... | ... | @@ -1047,3 +1056,7 @@ pub const ZigClangDeclKind = extern enum { |
| 1047 | 1056 | StaticAssert, |
| 1048 | 1057 | TranslationUnit, |
| 1049 | 1058 | }; |
| 1059 | ||
| 1060 | pub const struct_ZigClangQualType = extern struct { | |
| 1061 | ptr: ?*c_void, | |
| 1062 | }; |
src-self-hosted/stage1.zig+2-1| ... | ... | @@ -90,7 +90,8 @@ export fn stage2_translate_c( |
| 90 | 90 | .import => translate_c.Mode.import, |
| 91 | 91 | .translate => translate_c.Mode.translate, |
| 92 | 92 | }, &errors, resources_path) catch |err| switch (err) { |
| 93 | error.SemanticAnalyzeFail => { | |
| 93 | // TODO after https://github.com/ziglang/zig/issues/769 we can remove error.UnsupportedType | |
| 94 | error.SemanticAnalyzeFail, error.UnsupportedType => { | |
| 94 | 95 | out_errors_ptr.* = errors.ptr; |
| 95 | 96 | out_errors_len.* = errors.len; |
| 96 | 97 | return Error.CCompileErrors; |
src-self-hosted/translate_c.zig+54-8| ... | ... | @@ -13,12 +13,16 @@ pub const Mode = enum { |
| 13 | 13 | |
| 14 | 14 | pub const ClangErrMsg = Stage2ErrorMsg; |
| 15 | 15 | |
| 16 | pub const Error = error{OutOfMemory}; | |
| 16 | pub const Error = error{ | |
| 17 | OutOfMemory, | |
| 18 | UnsupportedType, | |
| 19 | }; | |
| 17 | 20 | |
| 18 | 21 | const Context = struct { |
| 19 | 22 | tree: *ast.Tree, |
| 20 | 23 | source_buffer: *std.Buffer, |
| 21 | 24 | err: Error, |
| 25 | source_manager: *ZigClangSourceManager, | |
| 22 | 26 | |
| 23 | 27 | fn a(c: *Context) *std.mem.Allocator { |
| 24 | 28 | return &c.tree.arena_allocator.allocator; |
| ... | ... | @@ -28,6 +32,17 @@ const Context = struct { |
| 28 | 32 | fn str(c: *Context, s: [*]const u8) ![]u8 { |
| 29 | 33 | return std.mem.dupe(c.a(), u8, std.mem.toSliceConst(u8, s)); |
| 30 | 34 | } |
| 35 | ||
| 36 | /// Convert a clang source location to a file:line:column string | |
| 37 | fn locStr(c: *Context, loc: ZigClangSourceLocation) ![]u8 { | |
| 38 | const spelling_loc = ZigClangSourceManager_getSpellingLoc(c.source_manager, loc); | |
| 39 | const filename_c = ZigClangSourceManager_getFilename(c.source_manager, spelling_loc); | |
| 40 | const filename = if (filename_c) |s| try c.str(s) else ([]const u8)("(no file)"); | |
| 41 | ||
| 42 | const line = ZigClangSourceManager_getSpellingLineNumber(c.source_manager, spelling_loc); | |
| 43 | const column = ZigClangSourceManager_getSpellingColumnNumber(c.source_manager, spelling_loc); | |
| 44 | return std.fmt.allocPrint(c.a(), "{}:{}:{}", filename, line, column); | |
| 45 | } | |
| 31 | 46 | }; |
| 32 | 47 | |
| 33 | 48 | pub fn translate( |
| ... | ... | @@ -78,6 +93,7 @@ pub fn translate( |
| 78 | 93 | var context = Context{ |
| 79 | 94 | .tree = tree, |
| 80 | 95 | .source_buffer = &source_buffer, |
| 96 | .source_manager = ZigClangASTUnit_getSourceManager(ast_unit), | |
| 81 | 97 | .err = undefined, |
| 82 | 98 | }; |
| 83 | 99 | |
| ... | ... | @@ -105,27 +121,57 @@ fn declVisitor(c: *Context, decl: *const ZigClangDecl) Error!void { |
| 105 | 121 | return visitFnDecl(c, @ptrCast(*const ZigClangFunctionDecl, decl)); |
| 106 | 122 | }, |
| 107 | 123 | .Typedef => { |
| 108 | try appendToken(c, .LineComment, "// TODO translate typedef"); | |
| 124 | try emitWarning(c, ZigClangDecl_getLocation(decl), "TODO implement translate-c for typedefs"); | |
| 109 | 125 | }, |
| 110 | 126 | .Enum => { |
| 111 | try appendToken(c, .LineComment, "// TODO translate enum"); | |
| 127 | try emitWarning(c, ZigClangDecl_getLocation(decl), "TODO implement translate-c for enums"); | |
| 112 | 128 | }, |
| 113 | 129 | .Record => { |
| 114 | try appendToken(c, .LineComment, "// TODO translate struct"); | |
| 130 | try emitWarning(c, ZigClangDecl_getLocation(decl), "TODO implement translate-c for structs"); | |
| 115 | 131 | }, |
| 116 | 132 | .Var => { |
| 117 | try appendToken(c, .LineComment, "// TODO translate variable"); | |
| 133 | try emitWarning(c, ZigClangDecl_getLocation(decl), "TODO implement translate-c for variables"); | |
| 118 | 134 | }, |
| 119 | 135 | else => { |
| 120 | // TODO emit_warning(c, bitcast(decl->getLocation()), "ignoring %s decl", decl->getDeclKindName()); | |
| 121 | try appendToken(c, .LineComment, "// TODO translate unknown decl"); | |
| 136 | const decl_name = try c.str(ZigClangDecl_getDeclKindName(decl)); | |
| 137 | try emitWarning(c, ZigClangDecl_getLocation(decl), "ignoring {} declaration", decl_name); | |
| 122 | 138 | }, |
| 123 | 139 | } |
| 124 | 140 | } |
| 125 | 141 | |
| 126 | 142 | fn visitFnDecl(c: *Context, fn_decl: *const ZigClangFunctionDecl) Error!void { |
| 127 | 143 | const fn_name = c.str(ZigClangDecl_getName_bytes_begin(@ptrCast(*const ZigClangDecl, fn_decl))); |
| 128 | try appendToken(c, .LineComment, "// TODO translate function '{}'", fn_name); | |
| 144 | ||
| 145 | // TODO The C++ code has this: | |
| 146 | //if (get_global(c, fn_name)) { | |
| 147 | // // we already saw this function | |
| 148 | // return; | |
| 149 | //} | |
| 150 | ||
| 151 | const fn_decl_loc = ZigClangFunctionDecl_getLocation(fn_decl); | |
| 152 | const proto_node = transQualType(c, ZigClangFunctionDecl_getType(fn_decl), fn_decl_loc) catch |e| switch (e) { | |
| 153 | error.UnsupportedType => { | |
| 154 | try emitWarning(c, fn_decl_loc, "unable to resolve prototype of function '{}'", fn_name); | |
| 155 | return; | |
| 156 | }, | |
| 157 | else => return e, | |
| 158 | }; | |
| 159 | ||
| 160 | try emitWarning(c, fn_decl_loc, "TODO implement translate-c for function decls"); | |
| 161 | } | |
| 162 | ||
| 163 | fn transQualType(c: *Context, qt: ZigClangQualType, source_loc: ZigClangSourceLocation) !*ast.Node { | |
| 164 | return transType(c, ZigClangQualType_getTypePtr(qt), source_loc); | |
| 165 | } | |
| 166 | ||
| 167 | fn transType(c: *Context, ty: *const ZigClangType, source_loc: ZigClangSourceLocation) !*ast.Node { | |
| 168 | const type_name = c.str(ZigClangType_getTypeClassName(ty)); | |
| 169 | try emitWarning(c, source_loc, "unsupported type: '{}'", type_name); | |
| 170 | return error.UnsupportedType; | |
| 171 | } | |
| 172 | ||
| 173 | fn emitWarning(c: *Context, loc: ZigClangSourceLocation, comptime format: []const u8, args: ...) !void { | |
| 174 | try appendToken(c, .LineComment, "// {}: warning: " ++ format, c.locStr(loc), args); | |
| 129 | 175 | } |
| 130 | 176 | |
| 131 | 177 | fn appendToken(c: *Context, token_id: Token.Id, comptime format: []const u8, args: ...) !void { |
src/translate_c.cpp+15-13| ... | ... | @@ -4009,7 +4009,7 @@ static TransScope *trans_stmt(Context *c, TransScope *scope, const ZigClangStmt |
| 4009 | 4009 | return child_scope; |
| 4010 | 4010 | } |
| 4011 | 4011 | |
| 4012 | static void visit_fn_decl(Context *c, const clang::FunctionDecl *fn_decl) { | |
| 4012 | static void visit_fn_decl(Context *c, const ZigClangFunctionDecl *fn_decl) { | |
| 4013 | 4013 | Buf *fn_name = buf_create_from_str(ZigClangDecl_getName_bytes_begin((const ZigClangDecl *)fn_decl)); |
| 4014 | 4014 | |
| 4015 | 4015 | if (get_global(c, fn_name)) { |
| ... | ... | @@ -4017,26 +4017,28 @@ static void visit_fn_decl(Context *c, const clang::FunctionDecl *fn_decl) { |
| 4017 | 4017 | return; |
| 4018 | 4018 | } |
| 4019 | 4019 | |
| 4020 | AstNode *proto_node = trans_qual_type(c, bitcast(fn_decl->getType()), bitcast(fn_decl->getLocation())); | |
| 4020 | AstNode *proto_node = trans_qual_type(c, ZigClangFunctionDecl_getType(fn_decl), | |
| 4021 | ZigClangFunctionDecl_getLocation(fn_decl)); | |
| 4021 | 4022 | if (proto_node == nullptr) { |
| 4022 | emit_warning(c, bitcast(fn_decl->getLocation()), "unable to resolve prototype of function '%s'", buf_ptr(fn_name)); | |
| 4023 | emit_warning(c, ZigClangFunctionDecl_getLocation(fn_decl), | |
| 4024 | "unable to resolve prototype of function '%s'", buf_ptr(fn_name)); | |
| 4023 | 4025 | return; |
| 4024 | 4026 | } |
| 4025 | 4027 | |
| 4026 | 4028 | proto_node->data.fn_proto.name = fn_name; |
| 4027 | proto_node->data.fn_proto.is_extern = !fn_decl->hasBody(); | |
| 4029 | proto_node->data.fn_proto.is_extern = !((const clang::FunctionDecl*)fn_decl)->hasBody(); | |
| 4028 | 4030 | |
| 4029 | clang::StorageClass sc = fn_decl->getStorageClass(); | |
| 4031 | clang::StorageClass sc = ((const clang::FunctionDecl*)fn_decl)->getStorageClass(); | |
| 4030 | 4032 | if (sc == clang::SC_None) { |
| 4031 | 4033 | proto_node->data.fn_proto.visib_mod = c->visib_mod; |
| 4032 | proto_node->data.fn_proto.is_export = fn_decl->hasBody() ? c->want_export : false; | |
| 4034 | proto_node->data.fn_proto.is_export = ((const clang::FunctionDecl*)fn_decl)->hasBody() ? c->want_export : false; | |
| 4033 | 4035 | } else if (sc == clang::SC_Extern || sc == clang::SC_Static) { |
| 4034 | 4036 | proto_node->data.fn_proto.visib_mod = c->visib_mod; |
| 4035 | 4037 | } else if (sc == clang::SC_PrivateExtern) { |
| 4036 | emit_warning(c, bitcast(fn_decl->getLocation()), "unsupported storage class: private extern"); | |
| 4038 | emit_warning(c, ZigClangFunctionDecl_getLocation(fn_decl), "unsupported storage class: private extern"); | |
| 4037 | 4039 | return; |
| 4038 | 4040 | } else { |
| 4039 | emit_warning(c, bitcast(fn_decl->getLocation()), "unsupported storage class: unknown"); | |
| 4041 | emit_warning(c, ZigClangFunctionDecl_getLocation(fn_decl), "unsupported storage class: unknown"); | |
| 4040 | 4042 | return; |
| 4041 | 4043 | } |
| 4042 | 4044 | |
| ... | ... | @@ -4044,7 +4046,7 @@ static void visit_fn_decl(Context *c, const clang::FunctionDecl *fn_decl) { |
| 4044 | 4046 | |
| 4045 | 4047 | for (size_t i = 0; i < proto_node->data.fn_proto.params.length; i += 1) { |
| 4046 | 4048 | AstNode *param_node = proto_node->data.fn_proto.params.at(i); |
| 4047 | const clang::ParmVarDecl *param = fn_decl->getParamDecl(i); | |
| 4049 | const clang::ParmVarDecl *param = ((const clang::FunctionDecl*)fn_decl)->getParamDecl(i); | |
| 4048 | 4050 | const char *name = ZigClangDecl_getName_bytes_begin((const ZigClangDecl *)param); |
| 4049 | 4051 | |
| 4050 | 4052 | Buf *proto_param_name; |
| ... | ... | @@ -4063,7 +4065,7 @@ static void visit_fn_decl(Context *c, const clang::FunctionDecl *fn_decl) { |
| 4063 | 4065 | param_node->data.param_decl.name = scope_var->zig_name; |
| 4064 | 4066 | } |
| 4065 | 4067 | |
| 4066 | if (!fn_decl->hasBody()) { | |
| 4068 | if (!((const clang::FunctionDecl*)fn_decl)->hasBody()) { | |
| 4067 | 4069 | // just a prototype |
| 4068 | 4070 | add_top_level_decl(c, proto_node->data.fn_proto.name, proto_node); |
| 4069 | 4071 | return; |
| ... | ... | @@ -4071,11 +4073,11 @@ static void visit_fn_decl(Context *c, const clang::FunctionDecl *fn_decl) { |
| 4071 | 4073 | |
| 4072 | 4074 | // actual function definition with body |
| 4073 | 4075 | c->ptr_params.clear(); |
| 4074 | const ZigClangStmt *body = bitcast(fn_decl->getBody()); | |
| 4076 | const ZigClangStmt *body = bitcast(((const clang::FunctionDecl*)fn_decl)->getBody()); | |
| 4075 | 4077 | AstNode *actual_body_node; |
| 4076 | 4078 | TransScope *result_scope = trans_stmt(c, scope, body, &actual_body_node); |
| 4077 | 4079 | if (result_scope == nullptr) { |
| 4078 | emit_warning(c, bitcast(fn_decl->getLocation()), "unable to translate function"); | |
| 4080 | emit_warning(c, ZigClangFunctionDecl_getLocation(fn_decl), "unable to translate function"); | |
| 4079 | 4081 | return; |
| 4080 | 4082 | } |
| 4081 | 4083 | assert(actual_body_node != nullptr); |
| ... | ... | @@ -4558,7 +4560,7 @@ static bool decl_visitor(void *context, const ZigClangDecl *decl) { |
| 4558 | 4560 | |
| 4559 | 4561 | switch (ZigClangDecl_getKind(decl)) { |
| 4560 | 4562 | case ZigClangDeclFunction: |
| 4561 | visit_fn_decl(c, reinterpret_cast<const clang::FunctionDecl*>(decl)); | |
| 4563 | visit_fn_decl(c, reinterpret_cast<const ZigClangFunctionDecl*>(decl)); | |
| 4562 | 4564 | break; |
| 4563 | 4565 | case ZigClangDeclTypedef: |
| 4564 | 4566 | resolve_typedef_decl(c, reinterpret_cast<const ZigClangTypedefNameDecl *>(decl)); |
src/zig_clang.cpp+10| ... | ... | @@ -1142,6 +1142,16 @@ ZigClangQualType ZigClangEnumDecl_getIntegerType(const ZigClangEnumDecl *self) { |
| 1142 | 1142 | return bitcast(reinterpret_cast<const clang::EnumDecl *>(self)->getIntegerType()); |
| 1143 | 1143 | } |
| 1144 | 1144 | |
| 1145 | struct ZigClangQualType ZigClangFunctionDecl_getType(const struct ZigClangFunctionDecl *self) { | |
| 1146 | auto casted = reinterpret_cast<const clang::FunctionDecl *>(self); | |
| 1147 | return bitcast(casted->getType()); | |
| 1148 | } | |
| 1149 | ||
| 1150 | struct ZigClangSourceLocation ZigClangFunctionDecl_getLocation(const struct ZigClangFunctionDecl *self) { | |
| 1151 | auto casted = reinterpret_cast<const clang::FunctionDecl *>(self); | |
| 1152 | return bitcast(casted->getLocation()); | |
| 1153 | } | |
| 1154 | ||
| 1145 | 1155 | const ZigClangTypedefNameDecl *ZigClangTypedefType_getDecl(const ZigClangTypedefType *self) { |
| 1146 | 1156 | auto casted = reinterpret_cast<const clang::TypedefType *>(self); |
| 1147 | 1157 | const clang::TypedefNameDecl *name_decl = casted->getDecl(); |
src/zig_clang.h+3| ... | ... | @@ -599,6 +599,9 @@ ZIG_EXTERN_C struct ZigClangSourceLocation ZigClangEnumDecl_getLocation(const st |
| 599 | 599 | ZIG_EXTERN_C struct ZigClangSourceLocation ZigClangTypedefNameDecl_getLocation(const struct ZigClangTypedefNameDecl *); |
| 600 | 600 | ZIG_EXTERN_C struct ZigClangSourceLocation ZigClangDecl_getLocation(const struct ZigClangDecl *); |
| 601 | 601 | |
| 602 | ZIG_EXTERN_C struct ZigClangQualType ZigClangFunctionDecl_getType(const struct ZigClangFunctionDecl *); | |
| 603 | ZIG_EXTERN_C struct ZigClangSourceLocation ZigClangFunctionDecl_getLocation(const struct ZigClangFunctionDecl *); | |
| 604 | ||
| 602 | 605 | ZIG_EXTERN_C bool ZigClangRecordDecl_isUnion(const struct ZigClangRecordDecl *record_decl); |
| 603 | 606 | ZIG_EXTERN_C bool ZigClangRecordDecl_isStruct(const struct ZigClangRecordDecl *record_decl); |
| 604 | 607 | ZIG_EXTERN_C bool ZigClangRecordDecl_isAnonymousStructOrUnion(const struct ZigClangRecordDecl *record_decl); |