@@ -112,7 +112,7 @@ class AutolinkExtractInvocation {
112
112
// / Return 'true' if there was an error, and 'false' otherwise.
113
113
static bool
114
114
extractLinkerFlagsFromObjectFile (const llvm::object::ObjectFile *ObjectFile,
115
- std::vector<std::string > &LinkerFlags,
115
+ llvm::SetVector<StringRef > &LinkerFlags,
116
116
CompilerInstance &Instance) {
117
117
// Search for the section we hold autolink entries in
118
118
for (auto &Section : ObjectFile->sections ()) {
@@ -141,7 +141,7 @@ extractLinkerFlagsFromObjectFile(const llvm::object::ObjectFile *ObjectFile,
141
141
SectionData->split (SplitFlags, llvm::StringRef (" \0 " , 1 ), -1 ,
142
142
/* KeepEmpty=*/ false );
143
143
for (const auto &Flag : SplitFlags)
144
- LinkerFlags.push_back (Flag. str () );
144
+ LinkerFlags.insert (Flag);
145
145
}
146
146
}
147
147
return false ;
@@ -152,7 +152,7 @@ extractLinkerFlagsFromObjectFile(const llvm::object::ObjectFile *ObjectFile,
152
152
// / 'true' if there was an error, and 'false' otherwise.
153
153
static bool
154
154
extractLinkerFlagsFromObjectFile (const llvm::object::WasmObjectFile *ObjectFile,
155
- std::vector<std::string > &LinkerFlags,
155
+ llvm::SetVector<StringRef > &LinkerFlags,
156
156
CompilerInstance &Instance) {
157
157
// Search for the data segment we hold autolink entries in
158
158
for (const llvm::object::WasmSegment &Segment : ObjectFile->dataSegments ()) {
@@ -165,7 +165,7 @@ extractLinkerFlagsFromObjectFile(const llvm::object::WasmObjectFile *ObjectFile,
165
165
SegmentData.split (SplitFlags, llvm::StringRef (" \0 " , 1 ), -1 ,
166
166
/* KeepEmpty=*/ false );
167
167
for (const auto &Flag : SplitFlags)
168
- LinkerFlags.push_back (Flag. str () );
168
+ LinkerFlags.insert (Flag);
169
169
}
170
170
}
171
171
return false ;
@@ -178,7 +178,7 @@ extractLinkerFlagsFromObjectFile(const llvm::object::WasmObjectFile *ObjectFile,
178
178
static bool extractLinkerFlags (const llvm::object::Binary *Bin,
179
179
CompilerInstance &Instance,
180
180
StringRef BinaryFileName,
181
- std::vector<std::string > &LinkerFlags) {
181
+ llvm::SetVector<StringRef > &LinkerFlags) {
182
182
if (auto *ObjectFile = llvm::dyn_cast<llvm::object::ELFObjectFileBase>(Bin)) {
183
183
return extractLinkerFlagsFromObjectFile (ObjectFile, LinkerFlags, Instance);
184
184
} else if (auto *ObjectFile =
@@ -227,7 +227,7 @@ int autolink_extract_main(ArrayRef<const char *> Args, const char *Argv0,
227
227
return 1 ;
228
228
}
229
229
230
- std::vector<std::string > LinkerFlags;
230
+ llvm::SetVector<StringRef > LinkerFlags;
231
231
232
232
// Extract the linker flags from the objects.
233
233
for (const auto &BinaryFileName : Invocation.getInputFilenames ()) {
@@ -261,7 +261,7 @@ int autolink_extract_main(ArrayRef<const char *> Args, const char *Argv0,
261
261
}
262
262
263
263
for (auto &Flag : LinkerFlags) {
264
- OutOS << Flag << ' \n ' ;
264
+ OutOS << Flag. str () << ' \n ' ;
265
265
}
266
266
267
267
return 0 ;
0 commit comments