diff options
| author | LemonBoy <thatlemon@gmail.com> | 2020-01-02 11:33:26 +0100 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2020-01-02 12:32:51 -0500 |
| commit | 8e89bdfe991ebf643c6f35064a2e72de18feff9b (patch) | |
| tree | 817be8192b4bea3127b6956490303ccbae1237e5 /src/zig_clang.cpp | |
| parent | 7bd80f207147167821634e16983edf9e9b115c9f (diff) | |
| download | zig-8e89bdfe991ebf643c6f35064a2e72de18feff9b.tar.gz zig-8e89bdfe991ebf643c6f35064a2e72de18feff9b.zip | |
Translate linksection attribute
Diffstat (limited to 'src/zig_clang.cpp')
| -rw-r--r-- | src/zig_clang.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/zig_clang.cpp b/src/zig_clang.cpp index ba25d365f7..cf839d16c8 100644 --- a/src/zig_clang.cpp +++ b/src/zig_clang.cpp @@ -1582,6 +1582,16 @@ const ZigClangVarDecl *ZigClangVarDecl_getCanonicalDecl(const ZigClangVarDecl *s return reinterpret_cast<const ZigClangVarDecl *>(decl); } +const char* ZigClangVarDecl_getSectionAttribute(const struct ZigClangVarDecl *self, size_t *len) { + auto casted = reinterpret_cast<const clang::VarDecl *>(self); + if (const clang::SectionAttr *SA = casted->getAttr<clang::SectionAttr>()) { + llvm::StringRef str_ref = SA->getName(); + *len = str_ref.size(); + return (const char *)str_ref.bytes_begin(); + } + return nullptr; +} + const ZigClangRecordDecl *ZigClangRecordDecl_getDefinition(const ZigClangRecordDecl *zig_record_decl) { const clang::RecordDecl *record_decl = reinterpret_cast<const clang::RecordDecl *>(zig_record_decl); const clang::RecordDecl *definition = record_decl->getDefinition(); @@ -1696,6 +1706,16 @@ bool ZigClangFunctionDecl_isInlineSpecified(const struct ZigClangFunctionDecl *s return casted->isInlineSpecified(); } +const char* ZigClangFunctionDecl_getSectionAttribute(const struct ZigClangFunctionDecl *self, size_t *len) { + auto casted = reinterpret_cast<const clang::FunctionDecl *>(self); + if (const clang::SectionAttr *SA = casted->getAttr<clang::SectionAttr>()) { + llvm::StringRef str_ref = SA->getName(); + *len = str_ref.size(); + return (const char *)str_ref.bytes_begin(); + } + return nullptr; +} + const ZigClangTypedefNameDecl *ZigClangTypedefType_getDecl(const ZigClangTypedefType *self) { auto casted = reinterpret_cast<const clang::TypedefType *>(self); const clang::TypedefNameDecl *name_decl = casted->getDecl(); |
