ilya-biryukov created this revision. ilya-biryukov added a reviewer: jkorous. Herald added subscribers: llvm-commits, jfb, dexonsmith, hiraditya. Herald added a project: LLVM.
The latter is slightly more efficient and communicates the intent of the API: writeFileAtomically does not own or copy the callback, it merely calls it at some point. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D67584 Files: llvm/include/llvm/Support/FileUtilities.h llvm/lib/Support/FileUtilities.cpp Index: llvm/lib/Support/FileUtilities.cpp =================================================================== --- llvm/lib/Support/FileUtilities.cpp +++ llvm/lib/Support/FileUtilities.cpp @@ -296,7 +296,7 @@ llvm::Error llvm::writeFileAtomically( StringRef TempPathModel, StringRef FinalPath, - std::function<llvm::Error(llvm::raw_ostream &)> Writer) { + llvm::function_ref<llvm::Error(llvm::raw_ostream &)> Writer) { SmallString<128> GeneratedUniqPath; int TempFD; if (sys::fs::createUniqueFile(TempPathModel.str(), TempFD, Index: llvm/include/llvm/Support/FileUtilities.h =================================================================== --- llvm/include/llvm/Support/FileUtilities.h +++ llvm/include/llvm/Support/FileUtilities.h @@ -14,6 +14,7 @@ #ifndef LLVM_SUPPORT_FILEUTILITIES_H #define LLVM_SUPPORT_FILEUTILITIES_H +#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/Errc.h" #include "llvm/Support/ErrorHandling.h" @@ -109,7 +110,7 @@ llvm::Error writeFileAtomically(StringRef TempPathModel, StringRef FinalPath, - std::function<llvm::Error(llvm::raw_ostream &)> Writer); + llvm::function_ref<llvm::Error(llvm::raw_ostream &)> Writer); } // End llvm namespace #endif
Index: llvm/lib/Support/FileUtilities.cpp =================================================================== --- llvm/lib/Support/FileUtilities.cpp +++ llvm/lib/Support/FileUtilities.cpp @@ -296,7 +296,7 @@ llvm::Error llvm::writeFileAtomically( StringRef TempPathModel, StringRef FinalPath, - std::function<llvm::Error(llvm::raw_ostream &)> Writer) { + llvm::function_ref<llvm::Error(llvm::raw_ostream &)> Writer) { SmallString<128> GeneratedUniqPath; int TempFD; if (sys::fs::createUniqueFile(TempPathModel.str(), TempFD, Index: llvm/include/llvm/Support/FileUtilities.h =================================================================== --- llvm/include/llvm/Support/FileUtilities.h +++ llvm/include/llvm/Support/FileUtilities.h @@ -14,6 +14,7 @@ #ifndef LLVM_SUPPORT_FILEUTILITIES_H #define LLVM_SUPPORT_FILEUTILITIES_H +#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/Errc.h" #include "llvm/Support/ErrorHandling.h" @@ -109,7 +110,7 @@ llvm::Error writeFileAtomically(StringRef TempPathModel, StringRef FinalPath, - std::function<llvm::Error(llvm::raw_ostream &)> Writer); + llvm::function_ref<llvm::Error(llvm::raw_ostream &)> Writer); } // End llvm namespace #endif
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits