Associate a value with its name from the given index in the provided record.
| 1850 | |
| 1851 | /// Associate a value with its name from the given index in the provided record. |
| 1852 | Expected<Value *> BitcodeReader::recordValue(SmallVectorImpl<uint64_t> &Record, |
| 1853 | unsigned NameIndex, Triple &TT) { |
| 1854 | SmallString<128> ValueName; |
| 1855 | if (convertToString(Record, NameIndex, ValueName)) |
| 1856 | return error("Invalid record"); |
| 1857 | unsigned ValueID = Record[0]; |
| 1858 | if (ValueID >= ValueList.size() || !ValueList[ValueID]) |
| 1859 | return error("Invalid record"); |
| 1860 | Value *V = ValueList[ValueID]; |
| 1861 | |
| 1862 | StringRef NameStr(ValueName.data(), ValueName.size()); |
| 1863 | if (NameStr.find_first_of(0) != StringRef::npos) |
| 1864 | return error("Invalid value name"); |
| 1865 | V->setName(NameStr); |
| 1866 | auto *GO = dyn_cast<GlobalObject>(V); |
| 1867 | if (GO) { |
| 1868 | if (GO->getComdat() == reinterpret_cast<Comdat *>(1)) { |
| 1869 | if (TT.supportsCOMDAT()) |
| 1870 | GO->setComdat(TheModule->getOrInsertComdat(V->getName())); |
| 1871 | else |
| 1872 | GO->setComdat(nullptr); |
| 1873 | } |
| 1874 | } |
| 1875 | return V; |
| 1876 | } |
| 1877 | |
| 1878 | /// Helper to note and return the current location, and jump to the given |
| 1879 | /// offset. |
nothing calls this directly
no test coverage detected