@@ -19,15 +19,13 @@ class MCSymbolWasm : public MCSymbol {
19
19
bool IsHidden = false ;
20
20
bool IsComdat = false ;
21
21
mutable bool IsUsedInGOT = false ;
22
+ Optional<StringRef> ImportModule;
23
+ Optional<StringRef> ImportName;
24
+ Optional<StringRef> ExportName;
25
+ wasm::WasmSignature *Signature = nullptr ;
22
26
Optional<wasm::WasmGlobalType> GlobalType;
23
27
Optional<wasm::WasmEventType> EventType;
24
28
25
- // Non-owning pointers since MCSymbol must be trivially destructible.
26
- std::string *ImportModule = nullptr ;
27
- std::string *ImportName = nullptr ;
28
- std::string *ExportName = nullptr ;
29
- wasm::WasmSignature *Signature = nullptr ;
30
-
31
29
// / An expression describing how to calculate the size of a symbol. If a
32
30
// / symbol has no size this field will be NULL.
33
31
const MCExpr *SymbolSize = nullptr ;
@@ -71,32 +69,29 @@ class MCSymbolWasm : public MCSymbol {
71
69
bool isComdat () const { return IsComdat; }
72
70
void setComdat (bool isComdat) { IsComdat = isComdat; }
73
71
74
- bool hasImportModule () const { return ImportModule != nullptr ; }
72
+ bool hasImportModule () const { return ImportModule. hasValue () ; }
75
73
StringRef getImportModule () const {
76
- if (ImportModule)
77
- return StringRef (* ImportModule);
74
+ if (ImportModule. hasValue () )
75
+ return ImportModule. getValue ( );
78
76
// Use a default module name of "env" for now, for compatibility with
79
77
// existing tools.
80
78
// TODO(sbc): Find a way to specify a default value in the object format
81
79
// without picking a hardcoded value like this.
82
80
return " env" ;
83
81
}
84
- void setImportModule (std::string * Name) { ImportModule = Name; }
82
+ void setImportModule (StringRef Name) { ImportModule = Name; }
85
83
86
- bool hasImportName () const { return ImportName != nullptr ; }
84
+ bool hasImportName () const { return ImportName. hasValue () ; }
87
85
StringRef getImportName () const {
88
- if (ImportName)
89
- return StringRef (* ImportName);
86
+ if (ImportName. hasValue () )
87
+ return ImportName. getValue ( );
90
88
return getName ();
91
89
}
92
- void setImportName (std::string * Name) { ImportName = Name; }
90
+ void setImportName (StringRef Name) { ImportName = Name; }
93
91
94
- bool hasExportName () const { return ExportName != nullptr ; }
95
- StringRef getExportName () const {
96
- assert (ExportName);
97
- return StringRef (*ExportName);
98
- }
99
- void setExportName (std::string *Name) { ExportName = Name; }
92
+ bool hasExportName () const { return ExportName.hasValue (); }
93
+ StringRef getExportName () const { return ExportName.getValue (); }
94
+ void setExportName (StringRef Name) { ExportName = Name; }
100
95
101
96
void setUsedInGOT () const { IsUsedInGOT = true ; }
102
97
bool isUsedInGOT () const { return IsUsedInGOT; }
0 commit comments