[PATCH] D14959: [Support] Add path::temp_directory() function.

Aaron Ballman via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 25 06:45:18 PST 2015


aaron.ballman added inline comments.

================
Comment at: include/llvm/Support/Path.h:336
@@ +335,3 @@
+/// @param Result Holds the resulting path name.
+void temp_directory(SmallVectorImpl<char> &Result, const Twine &Path1,
+                    const Twine &Path2 = "", const Twine &Path3 = "");
----------------
chfast wrote:
> aaron.ballman wrote:
> > Why is Path1 required to pass to the function?
> It was discussed around user_cache_directory(). It is not good idea to place files there directly so the API enforces appending at least one path element.
> 
> http://reviews.llvm.org/D13801?id=37977#inline-115640
That's not the case for the temp directory on Windows, but is the case for the user_cached_directory(). Temp files generally live directly in the temp directory on Windows, and folders are only used when there is a chance the file names will conflict with an existing file. However, the usual pattern when in the temp directory is to pick a temp file name, and so those conflicts do not happen. However, with the user's cache directory, those files are longer-lived, and so they tend to have specific file names that can conflict.

================
Comment at: lib/Support/Unix/Path.inc:563
@@ -562,3 +562,3 @@
 
-static bool getDarwinConfDir(bool TempDir, SmallVectorImpl<char> &Result) {
-  #if defined(_CS_DARWIN_USER_TEMP_DIR) && defined(_CS_DARWIN_USER_CACHE_DIR)
+enum class DarwinConfDir : bool { Temp, Cache };
+
----------------
chfast wrote:
> aaron.ballman wrote:
> > Is there a reason this is a bool instead of an int?
> Not any particular reason. I was replacing bool flag, so I used bool.
I'm not keen on the bool because then comparisons below are effectively if (bool == bool) instead of if (bool). I have a slight preference for unsigned here.


http://reviews.llvm.org/D14959





More information about the llvm-commits mailing list