MCPcopy Create free account
hub / github.com/chigraph/chigraph / typeFromName

Method typeFromName

libchigraph/src/LangModule.cpp:883–920  ·  view source on GitHub ↗

the lang module just has the basic llvm types.

Source from the content-addressed store, hash-verified

881
882// the lang module just has the basic llvm types.
883DataType 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
922Result LangModule::addForwardDeclarations(llvm::Module&) const { return {}; }
923

Callers 15

JSONSerializer.cppFile · 0.45
IfNodeTypeMethod · 0.45
ConstIntNodeTypeMethod · 0.45
ConstFloatNodeTypeMethod · 0.45
ConstBoolNodeTypeMethod · 0.45
StringLiteralNodeTypeMethod · 0.45
IntToFloatNodeTypeMethod · 0.45

Calls 3

to_stringMethod · 0.80
c_strMethod · 0.80
endMethod · 0.80

Tested by

no test coverage detected