llvm.org GIT mirror llvm / 95695c8
[Option] Store arg strings in a set backed by a BumpPtrAllocator No functionality change. This is preparing to move response file parsing into lib/Option so it can be shared between clang and lld. This change isn't just a micro-optimization. Clang's driver uses a std::set<std::string> to unique arguments while parsing response files, so this matches that. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186319 91177308-0d34-0410-b5e6-96231b3b80d8 Reid Kleckner 7 years ago
2 changed file(s) with 14 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
1111
1212 #include "llvm/ADT/SmallVector.h"
1313 #include "llvm/ADT/StringRef.h"
14 #include "llvm/ADT/StringSet.h"
1415 #include "llvm/Option/OptSpecifier.h"
1516 #include "llvm/Option/Option.h"
16 #include
17 #include "llvm/Support/Allocator.h"
1718 #include
1819 #include
1920
297298 /// This is mutable since we treat the ArgList as being the list
298299 /// of Args, and allow routines to add new strings (to have a
299300 /// convenient place to store the memory) via MakeIndex.
300 mutable std::list> SynthesizedStrings;
301 mutable StringSet> SynthesizedStrings;
301302
302303 /// The number of original input argument strings.
303304 unsigned NumInputArgStrings;
322322 unsigned InputArgList::MakeIndex(StringRef String0) const {
323323 unsigned Index = ArgStrings.size();
324324
325 // If necessary, make a copy so we can null terminate it.
326 std::string NullTerminated;
327 if (String0.back() != '\0') {
328 NullTerminated.append(String0.data(), String0.size());
329 NullTerminated.push_back('\0');
330 String0 = StringRef(&NullTerminated[0], NullTerminated.size());
331 }
332
325333 // Tuck away so we have a reliable const char *.
326 SynthesizedStrings.push_back(String0);
327 ArgStrings.push_back(SynthesizedStrings.back().c_str());
334 String0 = SynthesizedStrings.GetOrCreateValue(String0).getKey();
335 assert(String0.back() == '\0');
336 ArgStrings.push_back(String0.data());
328337
329338 return Index;
330339 }