llvm.org GIT mirror llvm / 703b185
Remove many superfluous SmallString::str() calls. Now that SmallString is a first-class citizen, most SmallString::str() calls are not required. This patch removes a whole bunch of them, yet there are lots more. There are two use cases where str() is really needed: 1) To use one of StringRef member functions which is not available in SmallString. 2) To convert to std::string, as StringRef implicitly converts while SmallString do not. We may wish to change this, but it may introduce ambiguity. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232622 91177308-0d34-0410-b5e6-96231b3b80d8 Yaron Keren 5 years ago
9 changed file(s) with 26 addition(s) and 26 deletion(s). Raw diff Collapse all Expand all
5050 ~FileRemover() {
5151 if (DeleteIt) {
5252 // Ignore problems deleting the file.
53 sys::fs::remove(Filename.str());
53 sys::fs::remove(Filename);
5454 }
5555 }
5656
6060 void setFile(const Twine& filename, bool deleteIt = true) {
6161 if (DeleteIt) {
6262 // Ignore problems deleting the file.
63 sys::fs::remove(Filename.str());
63 sys::fs::remove(Filename);
6464 }
6565
6666 Filename.clear();
266266 }
267267
268268 CommentStream.flush();
269 StringRef Comments = CommentToEmit.str();
269 StringRef Comments = CommentToEmit;
270270
271271 assert(Comments.back() == '\n' &&
272272 "Comment array not newline terminated");
788788
789789 case MCFragment::FT_LEB: {
790790 const MCLEBFragment &LF = cast(F);
791 OW->WriteBytes(LF.getContents().str());
791 OW->WriteBytes(LF.getContents());
792792 break;
793793 }
794794
804804
805805 case MCFragment::FT_Dwarf: {
806806 const MCDwarfLineAddrFragment &OF = cast(F);
807 OW->WriteBytes(OF.getContents().str());
807 OW->WriteBytes(OF.getContents());
808808 break;
809809 }
810810 case MCFragment::FT_DwarfFrame: {
811811 const MCDwarfCallFrameFragment &CF = cast(F);
812 OW->WriteBytes(CF.getContents().str());
812 OW->WriteBytes(CF.getContents());
813813 break;
814814 }
815815 }
12921292 Augmentation += "R";
12931293 if (IsSignalFrame)
12941294 Augmentation += "S";
1295 streamer.EmitBytes(Augmentation.str());
1295 streamer.EmitBytes(Augmentation);
12961296 }
12971297 streamer.EmitIntValue(0, 1);
12981298
22962296 void APInt::print(raw_ostream &OS, bool isSigned) const {
22972297 SmallString<40> S;
22982298 this->toString(S, 10, isSigned, /* formatAsCLiteral = */false);
2299 OS << S.str();
2299 OS << S;
23002300 }
23012301
23022302 // This implements a variety of operations on a representation of
9090 UniqueLockFileName += "-%%%%%%%%";
9191 int UniqueLockFileID;
9292 if (std::error_code EC = sys::fs::createUniqueFile(
93 UniqueLockFileName.str(), UniqueLockFileID, UniqueLockFileName)) {
93 UniqueLockFileName, UniqueLockFileID, UniqueLockFileName)) {
9494 Error = EC;
9595 return;
9696 }
115115 // We failed to write out PID, so make up an excuse, remove the
116116 // unique lock file, and fail.
117117 Error = make_error_code(errc::no_space_on_device);
118 sys::fs::remove(UniqueLockFileName.c_str());
118 sys::fs::remove(UniqueLockFileName);
119119 return;
120120 }
121121 }
123123 while (1) {
124124 // Create a link from the lock file name. If this succeeds, we're done.
125125 std::error_code EC =
126 sys::fs::create_link(UniqueLockFileName.str(), LockFileName.str());
126 sys::fs::create_link(UniqueLockFileName, LockFileName);
127127 if (!EC)
128128 return;
129129
136136 // from the lock file.
137137 if ((Owner = readLockFile(LockFileName))) {
138138 // Wipe out our unique lock file (it's useless now)
139 sys::fs::remove(UniqueLockFileName.str());
140 return;
141 }
142
143 if (!sys::fs::exists(LockFileName.str())) {
139 sys::fs::remove(UniqueLockFileName);
140 return;
141 }
142
143 if (!sys::fs::exists(LockFileName)) {
144144 // The previous owner released the lock file before we could read it.
145145 // Try to get ownership again.
146146 continue;
148148
149149 // There is a lock file that nobody owns; try to clean it up and get
150150 // ownership.
151 if ((EC = sys::fs::remove(LockFileName.str()))) {
151 if ((EC = sys::fs::remove(LockFileName))) {
152152 Error = EC;
153153 return;
154154 }
170170 return;
171171
172172 // Since we own the lock, remove the lock file and our own unique lock file.
173 sys::fs::remove(LockFileName.str());
174 sys::fs::remove(UniqueLockFileName.str());
173 sys::fs::remove(LockFileName);
174 sys::fs::remove(UniqueLockFileName);
175175 }
176176
177177 LockFileManager::WaitForUnlockResult LockFileManager::waitForUnlock() {
202202 if (sys::fs::access(LockFileName.c_str(), sys::fs::AccessMode::Exist) ==
203203 errc::no_such_file_or_directory) {
204204 // If the original file wasn't created, somone thought the lock was dead.
205 if (!sys::fs::exists(FileName.str()))
205 if (!sys::fs::exists(FileName))
206206 return Res_OwnerDied;
207207 return Res_Success;
208208 }
235235 }
236236
237237 std::error_code LockFileManager::unsafeRemoveLockFile() {
238 return sys::fs::remove(LockFileName.str());
239 }
238 return sys::fs::remove(LockFileName);
239 }
849849 Triple += getVendorName();
850850 Triple += "-";
851851 Triple += getOSAndEnvironmentName();
852 setTriple(Triple.str());
852 setTriple(Triple);
853853 }
854854
855855 void Triple::setVendorName(StringRef Str) {
598598
599599 it.IterationHandle = intptr_t(FindHandle.take());
600600 SmallString<128> directory_entry_path(path);
601 path::append(directory_entry_path, directory_entry_name_utf8.str());
602 it.CurrentEntry = directory_entry(directory_entry_path.str());
601 path::append(directory_entry_path, directory_entry_name_utf8);
602 it.CurrentEntry = directory_entry(directory_entry_path);
603603
604604 return std::error_code();
605605 }
10901090 // overkill for now, though.
10911091
10921092 // Make sure the predicate is in the table.
1093 Decoders.insert(Decoder.str());
1093 Decoders.insert(StringRef(Decoder));
10941094 // Now figure out the index for when we write out the table.
10951095 DecoderSet::const_iterator P = std::find(Decoders.begin(),
10961096 Decoders.end(),