aboutsummaryrefslogtreecommitdiff
path: root/src/zig_clang.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2019-05-10 16:03:54 -0400
committerAndrew Kelley <andrew@ziglang.org>2019-05-10 16:03:54 -0400
commita6f7a9ce2b008ff66ab32c8162d64dd77ffe952f (patch)
tree7e0f1e80cabf9e2869949035aa5ff95e06749d4c /src/zig_clang.cpp
parentd065f297ab6de5ca35636d169195ce5da6235786 (diff)
downloadzig-a6f7a9ce2b008ff66ab32c8162d64dd77ffe952f.tar.gz
zig-a6f7a9ce2b008ff66ab32c8162d64dd77ffe952f.zip
translate-c: we have our first test of self-hosted
See #1964
Diffstat (limited to 'src/zig_clang.cpp')
-rw-r--r--src/zig_clang.cpp43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/zig_clang.cpp b/src/zig_clang.cpp
index b1457fd817..25e309a63e 100644
--- a/src/zig_clang.cpp
+++ b/src/zig_clang.cpp
@@ -1236,6 +1236,25 @@ static_assert((clang::CallingConv)ZigClangCallingConv_PreserveMost == clang::CC_
static_assert((clang::CallingConv)ZigClangCallingConv_PreserveAll == clang::CC_PreserveAll, "");
static_assert((clang::CallingConv)ZigClangCallingConv_AArch64VectorCall == clang::CC_AArch64VectorCall, "");
+void ZigClang_detect_enum_StorageClass(clang::StorageClass x) {
+ switch (x) {
+ case clang::SC_None:
+ case clang::SC_Extern:
+ case clang::SC_Static:
+ case clang::SC_PrivateExtern:
+ case clang::SC_Auto:
+ case clang::SC_Register:
+ break;
+ }
+}
+
+static_assert((clang::StorageClass)ZigClangStorageClass_None == clang::SC_None, "");
+static_assert((clang::StorageClass)ZigClangStorageClass_Extern == clang::SC_Extern, "");
+static_assert((clang::StorageClass)ZigClangStorageClass_Static == clang::SC_Static, "");
+static_assert((clang::StorageClass)ZigClangStorageClass_PrivateExtern == clang::SC_PrivateExtern, "");
+static_assert((clang::StorageClass)ZigClangStorageClass_Auto == clang::SC_Auto, "");
+static_assert((clang::StorageClass)ZigClangStorageClass_Register == clang::SC_Register, "");
+
static_assert(sizeof(ZigClangSourceLocation) == sizeof(clang::SourceLocation), "");
static ZigClangSourceLocation bitcast(clang::SourceLocation src) {
@@ -1434,6 +1453,30 @@ struct ZigClangSourceLocation ZigClangFunctionDecl_getLocation(const struct ZigC
return bitcast(casted->getLocation());
}
+bool ZigClangFunctionDecl_hasBody(const struct ZigClangFunctionDecl *self) {
+ auto casted = reinterpret_cast<const clang::FunctionDecl *>(self);
+ return casted->hasBody();
+}
+
+enum ZigClangStorageClass ZigClangFunctionDecl_getStorageClass(const struct ZigClangFunctionDecl *self) {
+ auto casted = reinterpret_cast<const clang::FunctionDecl *>(self);
+ return (ZigClangStorageClass)casted->getStorageClass();
+}
+
+const struct ZigClangParmVarDecl *ZigClangFunctionDecl_getParamDecl(const struct ZigClangFunctionDecl *self,
+ unsigned i)
+{
+ auto casted = reinterpret_cast<const clang::FunctionDecl *>(self);
+ const clang::ParmVarDecl *parm_var_decl = casted->getParamDecl(i);
+ return reinterpret_cast<const ZigClangParmVarDecl *>(parm_var_decl);
+}
+
+const struct ZigClangStmt *ZigClangFunctionDecl_getBody(const struct ZigClangFunctionDecl *self) {
+ auto casted = reinterpret_cast<const clang::FunctionDecl *>(self);
+ const clang::Stmt *stmt = casted->getBody();
+ return reinterpret_cast<const ZigClangStmt *>(stmt);
+}
+
const ZigClangTypedefNameDecl *ZigClangTypedefType_getDecl(const ZigClangTypedefType *self) {
auto casted = reinterpret_cast<const clang::TypedefType *>(self);
const clang::TypedefNameDecl *name_decl = casted->getDecl();