[lld] r189025 - [lld][PECOFF] Fix use of temporary strings
Rui Ueyama
ruiu at google.com
Thu Aug 22 14:10:12 PDT 2013
LGTM. Thank you for doing this.
On Thu, Aug 22, 2013 at 8:37 AM, Shankar Easwaran
<shankare at codeaurora.org>wrote:
> Author: shankare
> Date: Thu Aug 22 10:37:09 2013
> New Revision: 189025
>
> URL: http://llvm.org/viewvc/llvm-project?rev=189025&view=rev
> Log:
> [lld][PECOFF] Fix use of temporary strings
>
> Modified:
> lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h
> lld/trunk/lib/Driver/WinLinkDriver.cpp
> lld/trunk/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp
>
> Modified: lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h
> URL:
> http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h?rev=189025&r1=189024&r2=189025&view=diff
>
> ==============================================================================
> --- lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h (original)
> +++ lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h Thu Aug 22
> 10:37:09 2013
> @@ -95,7 +95,7 @@ public:
> virtual ErrorOr<Reference::Kind> relocKindFromString(StringRef str)
> const;
> virtual ErrorOr<std::string> stringFromRelocKind(Reference::Kind kind)
> const;
>
> - StringRef allocateString(StringRef ref) {
> + StringRef allocateString(StringRef ref) const {
> char *x = _alloc.Allocate<char>(ref.size() + 1);
> memcpy(x, ref.data(), ref.size());
> x[ref.size()] = '\0';
>
> Modified: lld/trunk/lib/Driver/WinLinkDriver.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/WinLinkDriver.cpp?rev=189025&r1=189024&r2=189025&view=diff
>
> ==============================================================================
> --- lld/trunk/lib/Driver/WinLinkDriver.cpp (original)
> +++ lld/trunk/lib/Driver/WinLinkDriver.cpp Thu Aug 22 10:37:09 2013
> @@ -195,7 +195,7 @@ StringRef PECOFFFileNode::path(const Lin
> if (_path.endswith(".lib"))
> return _ctx.searchLibraryFile(_path);
> if (llvm::sys::path::extension(_path).empty())
> - return (_path.str() + ".obj");
> + return (_ctx.allocateString(_path.str() + ".obj"));
> return _path;
> }
>
>
> Modified: lld/trunk/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp?rev=189025&r1=189024&r2=189025&view=diff
>
> ==============================================================================
> --- lld/trunk/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp (original)
> +++ lld/trunk/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp Thu Aug 22
> 10:37:09 2013
> @@ -73,7 +73,7 @@ StringRef PECOFFLinkingContext::searchLi
> SmallString<128> path = dir;
> llvm::sys::path::append(path, filename);
> if (llvm::sys::fs::exists(path.str()))
> - return (*(new (_alloc) std::string(path.str())));
> + return allocateString(path.str());
> }
> return filename;
> }
> @@ -95,5 +95,4 @@ void PECOFFLinkingContext::addPasses(Pas
> pm.add(std::unique_ptr<Pass>(new pecoff::IdataPass()));
> pm.add(std::unique_ptr<Pass>(new LayoutPass()));
> }
> -
> } // end namespace lld
>
>
> _______________________________________________
> 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/20130822/af38bcb8/attachment.html>
More information about the llvm-commits
mailing list