- StringMapEntry<bool> *NameEntry = &UsedNames.GetOrCreateValue(Name);
- if (NameEntry->getValue()) {
- assert(isTemporary && "Cannot rename non-temporary symbols");
- SmallString<128> NewName = Name;
- do {
+MCSymbol *MCContext::createSymbolImpl(const StringMapEntry<bool> *Name,
+ bool IsTemporary) {
+ if (MOFI) {
+ switch (MOFI->getObjectFileType()) {
+ case MCObjectFileInfo::IsCOFF:
+ return new (Name, *this) MCSymbolCOFF(Name, IsTemporary);
+ case MCObjectFileInfo::IsELF:
+ return new (Name, *this) MCSymbolELF(Name, IsTemporary);
+ case MCObjectFileInfo::IsMachO:
+ return new (Name, *this) MCSymbolMachO(Name, IsTemporary);
+ }
+ }
+ return new (Name, *this) MCSymbol(MCSymbol::SymbolKindUnset, Name,
+ IsTemporary);
+}
+
+MCSymbol *MCContext::createSymbol(StringRef Name, bool AlwaysAddSuffix,
+ bool CanBeUnnamed) {
+ if (CanBeUnnamed && !UseNamesOnTempLabels)
+ return createSymbolImpl(nullptr, true);
+
+ // Determine whether this is an user writter assembler temporary or normal
+ // label, if used.
+ bool IsTemporary = CanBeUnnamed;
+ if (AllowTemporaryLabels && !IsTemporary)
+ IsTemporary = Name.startswith(MAI->getPrivateGlobalPrefix());
+
+ SmallString<128> NewName = Name;
+ bool AddSuffix = AlwaysAddSuffix;
+ unsigned &NextUniqueID = NextID[Name];
+ for (;;) {
+ if (AddSuffix) {