bool IsHidden = false;
bool IsComdat = false;
mutable bool IsUsedInGOT = false;
+ Optional<StringRef> ImportModule;
+ Optional<StringRef> ImportName;
+ Optional<StringRef> ExportName;
+ wasm::WasmSignature *Signature = nullptr;
Optional<wasm::WasmGlobalType> GlobalType;
Optional<wasm::WasmEventType> EventType;
- // Non-owning pointers since MCSymbol must be trivially destructible.
- std::string *ImportModule = nullptr;
- std::string *ImportName = nullptr;
- std::string *ExportName = nullptr;
- wasm::WasmSignature *Signature = nullptr;
-
/// An expression describing how to calculate the size of a symbol. If a
/// symbol has no size this field will be NULL.
const MCExpr *SymbolSize = nullptr;
bool isComdat() const { return IsComdat; }
void setComdat(bool isComdat) { IsComdat = isComdat; }
- bool hasImportModule() const { return ImportModule != nullptr; }
+ bool hasImportModule() const { return ImportModule.hasValue(); }
StringRef getImportModule() const {
- if (ImportModule)
- return StringRef(*ImportModule);
+ if (ImportModule.hasValue())
+ return ImportModule.getValue();
// Use a default module name of "env" for now, for compatibility with
// existing tools.
// TODO(sbc): Find a way to specify a default value in the object format
// without picking a hardcoded value like this.
return "env";
}
- void setImportModule(std::string *Name) { ImportModule = Name; }
+ void setImportModule(StringRef Name) { ImportModule = Name; }
- bool hasImportName() const { return ImportName != nullptr; }
+ bool hasImportName() const { return ImportName.hasValue(); }
StringRef getImportName() const {
- if (ImportName)
- return StringRef(*ImportName);
+ if (ImportName.hasValue())
+ return ImportName.getValue();
return getName();
}
- void setImportName(std::string *Name) { ImportName = Name; }
+ void setImportName(StringRef Name) { ImportName = Name; }
- bool hasExportName() const { return ExportName != nullptr; }
- StringRef getExportName() const {
- assert(ExportName);
- return StringRef(*ExportName);
- }
- void setExportName(std::string *Name) { ExportName = Name; }
+ bool hasExportName() const { return ExportName.hasValue(); }
+ StringRef getExportName() const { return ExportName.getValue(); }
+ void setExportName(StringRef Name) { ExportName = Name; }
void setUsedInGOT() const { IsUsedInGOT = true; }
bool isUsedInGOT() const { return IsUsedInGOT; }