the lang module just has the basic llvm types.
| 881 | |
| 882 | // the lang module just has the basic llvm types. |
| 883 | DataType LangModule::typeFromName(boost::string_view name) { |
| 884 | using namespace std::string_literals; |
| 885 | |
| 886 | llvm::Type* ty; |
| 887 | |
| 888 | auto err = llvm::SMDiagnostic(); |
| 889 | #if LLVM_VERSION_LESS_EQUAL(3, 8) |
| 890 | // just parse the type |
| 891 | auto IR = "@G = external global "s + name.to_string(); |
| 892 | |
| 893 | auto tmpModule = llvm:: |
| 894 | #if LLVM_VERSION_LESS_EQUAL(3, 5) |
| 895 | ParseAssemblyString(IR.c_str(), new llvm::Module("tmp", context().llvmContext()), err, |
| 896 | context().llvmContext()); |
| 897 | #else |
| 898 | parseAssemblyString(IR, err, context().llvmContext()); |
| 899 | #endif |
| 900 | |
| 901 | if (!tmpModule) { return nullptr; } |
| 902 | |
| 903 | ty = tmpModule->getNamedValue("G")->getType()->getContainedType(0); |
| 904 | #else |
| 905 | { |
| 906 | llvm::Module tMod("tmp", context().llvmContext()); |
| 907 | ty = llvm::parseType(name.to_string(), err, tMod, nullptr); |
| 908 | } |
| 909 | #endif |
| 910 | |
| 911 | // get debug type |
| 912 | auto iter = mDebugTypes.find(name.to_string()); |
| 913 | if (iter == mDebugTypes.end()) { return {}; } |
| 914 | |
| 915 | #if LLVM_VERSION_LESS_EQUAL(3, 5) |
| 916 | delete tmpModule; |
| 917 | #endif |
| 918 | |
| 919 | return DataType{this, name.to_string(), ty, iter->second}; |
| 920 | } |
| 921 | |
| 922 | Result LangModule::addForwardDeclarations(llvm::Module&) const { return {}; } |
| 923 |
no test coverage detected