[llvm] r232622 - Remove many superfluous SmallString::str() calls.
Yaron Keren
yaron.keren at gmail.com
Wed Mar 18 04:45:05 PDT 2015
Sorry! already fixed in r232623/4.
2015-03-18 13:26 GMT+02:00 Renato Golin <renato.golin at linaro.org>:
> Hi, this breaks compilation of our buildbot:
>
> http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-full/builds/4283
>
> lib/Sema/SemaStmt.cpp:909:53: error: operands to ?: have different
> types 'llvm::SmallString<16u>' and 'llvm::StringRef'
> (PrevString.empty() ? CaseValStr : PrevString);
>
> cheers,
> --renato
>
> On 18 March 2015 at 10:17, Yaron Keren <yaron.keren at gmail.com> wrote:
> > Author: yrnkrn
> > Date: Wed Mar 18 05:17:07 2015
> > New Revision: 232622
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=232622&view=rev
> > Log:
> > 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.
> >
> >
> > Modified:
> > llvm/trunk/include/llvm/Support/FileUtilities.h
> > llvm/trunk/lib/MC/MCAsmStreamer.cpp
> > llvm/trunk/lib/MC/MCAssembler.cpp
> > llvm/trunk/lib/MC/MCDwarf.cpp
> > llvm/trunk/lib/Support/APInt.cpp
> > llvm/trunk/lib/Support/LockFileManager.cpp
> > llvm/trunk/lib/Support/Triple.cpp
> > llvm/trunk/lib/Support/Windows/Path.inc
> > llvm/trunk/utils/TableGen/FixedLenDecoderEmitter.cpp
> >
> > Modified: llvm/trunk/include/llvm/Support/FileUtilities.h
> > URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/FileUtilities.h?rev=232622&r1=232621&r2=232622&view=diff
> >
> ==============================================================================
> > --- llvm/trunk/include/llvm/Support/FileUtilities.h (original)
> > +++ llvm/trunk/include/llvm/Support/FileUtilities.h Wed Mar 18 05:17:07
> 2015
> > @@ -51,7 +51,7 @@ namespace llvm {
> > ~FileRemover() {
> > if (DeleteIt) {
> > // Ignore problems deleting the file.
> > - sys::fs::remove(Filename.str());
> > + sys::fs::remove(Filename);
> > }
> > }
> >
> > @@ -61,7 +61,7 @@ namespace llvm {
> > void setFile(const Twine& filename, bool deleteIt = true) {
> > if (DeleteIt) {
> > // Ignore problems deleting the file.
> > - sys::fs::remove(Filename.str());
> > + sys::fs::remove(Filename);
> > }
> >
> > Filename.clear();
> >
> > Modified: llvm/trunk/lib/MC/MCAsmStreamer.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmStreamer.cpp?rev=232622&r1=232621&r2=232622&view=diff
> >
> ==============================================================================
> > --- llvm/trunk/lib/MC/MCAsmStreamer.cpp (original)
> > +++ llvm/trunk/lib/MC/MCAsmStreamer.cpp Wed Mar 18 05:17:07 2015
> > @@ -267,7 +267,7 @@ void MCAsmStreamer::EmitCommentsAndEOL()
> > }
> >
> > CommentStream.flush();
> > - StringRef Comments = CommentToEmit.str();
> > + StringRef Comments = CommentToEmit;
> >
> > assert(Comments.back() == '\n' &&
> > "Comment array not newline terminated");
> >
> > Modified: llvm/trunk/lib/MC/MCAssembler.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAssembler.cpp?rev=232622&r1=232621&r2=232622&view=diff
> >
> ==============================================================================
> > --- llvm/trunk/lib/MC/MCAssembler.cpp (original)
> > +++ llvm/trunk/lib/MC/MCAssembler.cpp Wed Mar 18 05:17:07 2015
> > @@ -789,7 +789,7 @@ static void writeFragment(const MCAssemb
> >
> > case MCFragment::FT_LEB: {
> > const MCLEBFragment &LF = cast<MCLEBFragment>(F);
> > - OW->WriteBytes(LF.getContents().str());
> > + OW->WriteBytes(LF.getContents());
> > break;
> > }
> >
> > @@ -805,12 +805,12 @@ static void writeFragment(const MCAssemb
> >
> > case MCFragment::FT_Dwarf: {
> > const MCDwarfLineAddrFragment &OF =
> cast<MCDwarfLineAddrFragment>(F);
> > - OW->WriteBytes(OF.getContents().str());
> > + OW->WriteBytes(OF.getContents());
> > break;
> > }
> > case MCFragment::FT_DwarfFrame: {
> > const MCDwarfCallFrameFragment &CF =
> cast<MCDwarfCallFrameFragment>(F);
> > - OW->WriteBytes(CF.getContents().str());
> > + OW->WriteBytes(CF.getContents());
> > break;
> > }
> > }
> >
> > Modified: llvm/trunk/lib/MC/MCDwarf.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCDwarf.cpp?rev=232622&r1=232621&r2=232622&view=diff
> >
> ==============================================================================
> > --- llvm/trunk/lib/MC/MCDwarf.cpp (original)
> > +++ llvm/trunk/lib/MC/MCDwarf.cpp Wed Mar 18 05:17:07 2015
> > @@ -1293,7 +1293,7 @@ const MCSymbol &FrameEmitterImpl::EmitCI
> > Augmentation += "R";
> > if (IsSignalFrame)
> > Augmentation += "S";
> > - streamer.EmitBytes(Augmentation.str());
> > + streamer.EmitBytes(Augmentation);
> > }
> > streamer.EmitIntValue(0, 1);
> >
> >
> > Modified: llvm/trunk/lib/Support/APInt.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/APInt.cpp?rev=232622&r1=232621&r2=232622&view=diff
> >
> ==============================================================================
> > --- llvm/trunk/lib/Support/APInt.cpp (original)
> > +++ llvm/trunk/lib/Support/APInt.cpp Wed Mar 18 05:17:07 2015
> > @@ -2297,7 +2297,7 @@ void APInt::dump() const {
> > void APInt::print(raw_ostream &OS, bool isSigned) const {
> > SmallString<40> S;
> > this->toString(S, 10, isSigned, /* formatAsCLiteral = */false);
> > - OS << S.str();
> > + OS << S;
> > }
> >
> > // This implements a variety of operations on a representation of
> >
> > Modified: llvm/trunk/lib/Support/LockFileManager.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/LockFileManager.cpp?rev=232622&r1=232621&r2=232622&view=diff
> >
> ==============================================================================
> > --- llvm/trunk/lib/Support/LockFileManager.cpp (original)
> > +++ llvm/trunk/lib/Support/LockFileManager.cpp Wed Mar 18 05:17:07 2015
> > @@ -91,7 +91,7 @@ LockFileManager::LockFileManager(StringR
> > UniqueLockFileName += "-%%%%%%%%";
> > int UniqueLockFileID;
> > if (std::error_code EC = sys::fs::createUniqueFile(
> > - UniqueLockFileName.str(), UniqueLockFileID,
> UniqueLockFileName)) {
> > + UniqueLockFileName, UniqueLockFileID, UniqueLockFileName)) {
> > Error = EC;
> > return;
> > }
> > @@ -116,7 +116,7 @@ LockFileManager::LockFileManager(StringR
> > // We failed to write out PID, so make up an excuse, remove the
> > // unique lock file, and fail.
> > Error = make_error_code(errc::no_space_on_device);
> > - sys::fs::remove(UniqueLockFileName.c_str());
> > + sys::fs::remove(UniqueLockFileName);
> > return;
> > }
> > }
> > @@ -124,7 +124,7 @@ LockFileManager::LockFileManager(StringR
> > while (1) {
> > // Create a link from the lock file name. If this succeeds, we're
> done.
> > std::error_code EC =
> > - sys::fs::create_link(UniqueLockFileName.str(),
> LockFileName.str());
> > + sys::fs::create_link(UniqueLockFileName, LockFileName);
> > if (!EC)
> > return;
> >
> > @@ -137,11 +137,11 @@ LockFileManager::LockFileManager(StringR
> > // from the lock file.
> > if ((Owner = readLockFile(LockFileName))) {
> > // Wipe out our unique lock file (it's useless now)
> > - sys::fs::remove(UniqueLockFileName.str());
> > + sys::fs::remove(UniqueLockFileName);
> > return;
> > }
> >
> > - if (!sys::fs::exists(LockFileName.str())) {
> > + if (!sys::fs::exists(LockFileName)) {
> > // The previous owner released the lock file before we could read
> it.
> > // Try to get ownership again.
> > continue;
> > @@ -149,7 +149,7 @@ LockFileManager::LockFileManager(StringR
> >
> > // There is a lock file that nobody owns; try to clean it up and get
> > // ownership.
> > - if ((EC = sys::fs::remove(LockFileName.str()))) {
> > + if ((EC = sys::fs::remove(LockFileName))) {
> > Error = EC;
> > return;
> > }
> > @@ -171,8 +171,8 @@ LockFileManager::~LockFileManager() {
> > return;
> >
> > // Since we own the lock, remove the lock file and our own unique
> lock file.
> > - sys::fs::remove(LockFileName.str());
> > - sys::fs::remove(UniqueLockFileName.str());
> > + sys::fs::remove(LockFileName);
> > + sys::fs::remove(UniqueLockFileName);
> > }
> >
> > LockFileManager::WaitForUnlockResult LockFileManager::waitForUnlock() {
> > @@ -203,7 +203,7 @@ LockFileManager::WaitForUnlockResult Loc
> > if (sys::fs::access(LockFileName.c_str(),
> sys::fs::AccessMode::Exist) ==
> > errc::no_such_file_or_directory) {
> > // If the original file wasn't created, somone thought the lock
> was dead.
> > - if (!sys::fs::exists(FileName.str()))
> > + if (!sys::fs::exists(FileName))
> > return Res_OwnerDied;
> > return Res_Success;
> > }
> > @@ -236,5 +236,5 @@ LockFileManager::WaitForUnlockResult Loc
> > }
> >
> > std::error_code LockFileManager::unsafeRemoveLockFile() {
> > - return sys::fs::remove(LockFileName.str());
> > + return sys::fs::remove(LockFileName);
> > }
> >
> > Modified: llvm/trunk/lib/Support/Triple.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Triple.cpp?rev=232622&r1=232621&r2=232622&view=diff
> >
> ==============================================================================
> > --- llvm/trunk/lib/Support/Triple.cpp (original)
> > +++ llvm/trunk/lib/Support/Triple.cpp Wed Mar 18 05:17:07 2015
> > @@ -850,7 +850,7 @@ void Triple::setArchName(StringRef Str)
> > Triple += getVendorName();
> > Triple += "-";
> > Triple += getOSAndEnvironmentName();
> > - setTriple(Triple.str());
> > + setTriple(Triple);
> > }
> >
> > void Triple::setVendorName(StringRef Str) {
> >
> > Modified: llvm/trunk/lib/Support/Windows/Path.inc
> > URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Windows/Path.inc?rev=232622&r1=232621&r2=232622&view=diff
> >
> ==============================================================================
> > --- llvm/trunk/lib/Support/Windows/Path.inc (original)
> > +++ llvm/trunk/lib/Support/Windows/Path.inc Wed Mar 18 05:17:07 2015
> > @@ -599,8 +599,8 @@ std::error_code detail::directory_iterat
> >
> > it.IterationHandle = intptr_t(FindHandle.take());
> > SmallString<128> directory_entry_path(path);
> > - path::append(directory_entry_path, directory_entry_name_utf8.str());
> > - it.CurrentEntry = directory_entry(directory_entry_path.str());
> > + path::append(directory_entry_path, directory_entry_name_utf8);
> > + it.CurrentEntry = directory_entry(directory_entry_path);
> >
> > return std::error_code();
> > }
> >
> > Modified: llvm/trunk/utils/TableGen/FixedLenDecoderEmitter.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/FixedLenDecoderEmitter.cpp?rev=232622&r1=232621&r2=232622&view=diff
> >
> ==============================================================================
> > --- llvm/trunk/utils/TableGen/FixedLenDecoderEmitter.cpp (original)
> > +++ llvm/trunk/utils/TableGen/FixedLenDecoderEmitter.cpp Wed Mar 18
> 05:17:07 2015
> > @@ -1091,7 +1091,7 @@ unsigned FilterChooser::getDecoderIndex(
> > // overkill for now, though.
> >
> > // Make sure the predicate is in the table.
> > - Decoders.insert(Decoder.str());
> > + Decoders.insert(StringRef(Decoder));
> > // Now figure out the index for when we write out the table.
> > DecoderSet::const_iterator P = std::find(Decoders.begin(),
> > Decoders.end(),
> >
> >
> > _______________________________________________
> > llvm-commits mailing list
> > llvm-commits at cs.uiuc.edu
> > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150318/8929a778/attachment.html>
More information about the llvm-commits
mailing list