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

Paweł Bylica via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 25 05:55:12 PST 2015


chfast 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 = "");
----------------
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

================
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 };
+
----------------
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.

================
Comment at: lib/Support/Unix/Path.inc:646
@@ +645,3 @@
+  const char *RequestedDir = getDefaultTempDir();
+  Result.append(RequestedDir, RequestedDir + strlen(RequestedDir));
+}
----------------
aaron.ballman wrote:
> Do you have to call Result.clear() here in the event getDarwinConfDir() fails but modifies Result?
getDarwinConfDir() either clears or does not modify Result in case of failure.

================
Comment at: lib/Support/Windows/Path.inc:824
@@ +823,3 @@
+
+  temp_directory(Result, "");
+}
----------------
aaron.ballman wrote:
> Do you need to clear Result if user_cache_directory() fails?
No. user_cache_directory() will either clear or not modify Result in case of failure.


http://reviews.llvm.org/D14959





More information about the llvm-commits mailing list