<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Oct 5, 2015 at 6:55 AM, Benjamin Kramer via cfe-commits <span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: d0k<br>
Date: Mon Oct 5 08:55:09 2015<br>
New Revision: 249314<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=249314&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=249314&view=rev</a><br>
Log:<br>
[VFS] Move class out of method so it looks less like Java.<br>
<br>
No functionality change.<br>
<br>
Modified:<br>
cfe/trunk/lib/Basic/VirtualFileSystem.cpp<br>
<br>
Modified: cfe/trunk/lib/Basic/VirtualFileSystem.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/VirtualFileSystem.cpp?rev=249314&r1=249313&r2=249314&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/VirtualFileSystem.cpp?rev=249314&r1=249313&r2=249314&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Basic/VirtualFileSystem.cpp (original)<br>
+++ cfe/trunk/lib/Basic/VirtualFileSystem.cpp Mon Oct 5 08:55:09 2015<br>
@@ -942,6 +942,33 @@ ErrorOr<Status> VFSFromYAML::status(cons<br>
return status(Path, *Result);<br>
}<br>
<br>
+namespace {<br>
+/// Provide a file wrapper that returns the external name when asked.<br>
+class NamedFileAdaptor : public File {<br>
+ std::unique_ptr<File> InnerFile;<br>
+ std::string NewName;<br>
+<br>
+public:<br>
+ NamedFileAdaptor(std::unique_ptr<File> InnerFile, std::string NewName)<br>
+ : InnerFile(std::move(InnerFile)), NewName(std::move(NewName)) {}<br>
+<br>
+ llvm::ErrorOr<Status> status() override {<br>
+ auto InnerStatus = InnerFile->status();<br>
+ if (InnerStatus)<br>
+ return Status::copyWithNewName(*InnerStatus, NewName);<br>
+ return InnerStatus.getError();<br>
+ }<br>
+ llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>><br>
+ getBuffer(const Twine &Name, int64_t FileSize = -1,<br>
+ bool RequiresNullTerminator = true,<br>
+ bool IsVolatile = false) override {<br></blockquote><div><br></div><div>Why are default arguments being specified here? This is only called virtually, right?</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ return InnerFile->getBuffer(Name, FileSize, RequiresNullTerminator,<br>
+ IsVolatile);<br>
+ }<br>
+ std::error_code close() override { return InnerFile->close(); }<br>
+};<br>
+} // end anonymous namespace<br>
+<br>
ErrorOr<std::unique_ptr<File>> VFSFromYAML::openFileForRead(const Twine &Path) {<br>
ErrorOr<Entry *> E = lookupPath(Path);<br>
if (!E)<br>
@@ -955,34 +982,9 @@ ErrorOr<std::unique_ptr<File>> VFSFromYA<br>
if (!Result)<br>
return Result;<br>
<br>
- if (!F->useExternalName(UseExternalNames)) {<br>
- // Provide a file wrapper that returns the external name when asked.<br>
- class NamedFileAdaptor : public File {<br>
- std::unique_ptr<File> InnerFile;<br>
- std::string NewName;<br>
-<br>
- public:<br>
- NamedFileAdaptor(std::unique_ptr<File> InnerFile, std::string NewName)<br>
- : InnerFile(std::move(InnerFile)), NewName(std::move(NewName)) {}<br>
-<br>
- llvm::ErrorOr<Status> status() override {<br>
- auto InnerStatus = InnerFile->status();<br>
- if (InnerStatus)<br>
- return Status::copyWithNewName(*InnerStatus, NewName);<br>
- return InnerStatus.getError();<br>
- }<br>
- llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>><br>
- getBuffer(const Twine &Name, int64_t FileSize = -1,<br>
- bool RequiresNullTerminator = true,<br>
- bool IsVolatile = false) override {<br>
- return InnerFile->getBuffer(Name, FileSize, RequiresNullTerminator,<br>
- IsVolatile);<br>
- }<br>
- std::error_code close() override { return InnerFile->close(); }<br>
- };<br>
+ if (!F->useExternalName(UseExternalNames))<br>
return std::unique_ptr<File>(<br>
new NamedFileAdaptor(std::move(*Result), Path.str()));<br>
- }<br>
<br>
return Result;<br>
}<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div></div>