From: Nico Weber Date: Tue, 18 Sep 2018 15:06:16 +0000 (+0000) Subject: Remove dead function user_cache_directory() X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d4ed32c52673337cabc2a0e9b62513d91d24f379;p=platform%2Fupstream%2Fllvm.git Remove dead function user_cache_directory() It's been unused since it was added almost 3 years ago in https://reviews.llvm.org/D13801 Motivated by https://reviews.llvm.org/rL342002 since it removes one of the functions keeping a ref to SHGetKnownFolderPath. Differential Revision: https://reviews.llvm.org/D52184 llvm-svn: 342485 --- diff --git a/llvm/include/llvm/Support/Path.h b/llvm/include/llvm/Support/Path.h index c4cc937..76de887 100644 --- a/llvm/include/llvm/Support/Path.h +++ b/llvm/include/llvm/Support/Path.h @@ -361,22 +361,6 @@ void system_temp_directory(bool erasedOnReboot, SmallVectorImpl &result); /// @result True if a home directory is set, false otherwise. bool home_directory(SmallVectorImpl &result); -/// Get the user's cache directory. -/// -/// Expect the resulting path to be a directory shared with other -/// applications/services used by the user. Params \p Path1 to \p Path3 can be -/// used to append additional directory names to the resulting path. Recommended -/// pattern is //. -/// -/// @param Result Holds the resulting path. -/// @param Path1 Additional path to be appended to the user's cache directory -/// path. "" can be used to append nothing. -/// @param Path2 Second additional path to be appended. -/// @param Path3 Third additional path to be appended. -/// @result True if a cache directory path is set, false otherwise. -bool user_cache_directory(SmallVectorImpl &Result, const Twine &Path1, - const Twine &Path2 = "", const Twine &Path3 = ""); - /// Has root name? /// /// root_name != "" diff --git a/llvm/lib/Support/Path.cpp b/llvm/lib/Support/Path.cpp index 41f2564..7eba596 100644 --- a/llvm/lib/Support/Path.cpp +++ b/llvm/lib/Support/Path.cpp @@ -1240,17 +1240,5 @@ Expected TempFile::create(const Twine &Model, unsigned Mode) { } } -namespace path { - -bool user_cache_directory(SmallVectorImpl &Result, const Twine &Path1, - const Twine &Path2, const Twine &Path3) { - if (getUserCacheDir(Result)) { - append(Result, Path1, Path2, Path3); - return true; - } - return false; -} - -} // end namespace path } // end namsspace sys } // end namespace llvm diff --git a/llvm/lib/Support/Unix/Path.inc b/llvm/lib/Support/Unix/Path.inc index e0f0144..ec3eecb 100644 --- a/llvm/lib/Support/Unix/Path.inc +++ b/llvm/lib/Support/Unix/Path.inc @@ -970,29 +970,6 @@ static bool getDarwinConfDir(bool TempDir, SmallVectorImpl &Result) { return false; } -static bool getUserCacheDir(SmallVectorImpl &Result) { - // First try using XDG_CACHE_HOME env variable, - // as specified in XDG Base Directory Specification at - // http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html - if (const char *XdgCacheDir = std::getenv("XDG_CACHE_HOME")) { - Result.clear(); - Result.append(XdgCacheDir, XdgCacheDir + strlen(XdgCacheDir)); - return true; - } - - // Try Darwin configuration query - if (getDarwinConfDir(false, Result)) - return true; - - // Use "$HOME/.cache" if $HOME is available - if (home_directory(Result)) { - append(Result, ".cache"); - return true; - } - - return false; -} - static const char *getEnvTempDir() { // Check whether the temporary directory is specified by an environment // variable. diff --git a/llvm/lib/Support/Windows/Path.inc b/llvm/lib/Support/Windows/Path.inc index 84565dc..e719d3c 100644 --- a/llvm/lib/Support/Windows/Path.inc +++ b/llvm/lib/Support/Windows/Path.inc @@ -1270,10 +1270,6 @@ static bool getKnownFolderPath(KNOWNFOLDERID folderId, return ok; } -bool getUserCacheDir(SmallVectorImpl &Result) { - return getKnownFolderPath(FOLDERID_LocalAppData, Result); -} - bool home_directory(SmallVectorImpl &result) { return getKnownFolderPath(FOLDERID_Profile, result); } diff --git a/llvm/unittests/Support/Path.cpp b/llvm/unittests/Support/Path.cpp index 0207672..851a4af 100644 --- a/llvm/unittests/Support/Path.cpp +++ b/llvm/unittests/Support/Path.cpp @@ -347,35 +347,6 @@ TEST(Support, HomeDirectoryWithNoEnv) { } #endif -TEST(Support, UserCacheDirectory) { - SmallString<13> CacheDir; - SmallString<20> CacheDir2; - auto Status = path::user_cache_directory(CacheDir, ""); - EXPECT_TRUE(Status ^ CacheDir.empty()); - - if (Status) { - EXPECT_TRUE(path::user_cache_directory(CacheDir2, "")); // should succeed - EXPECT_EQ(CacheDir, CacheDir2); // and return same paths - - EXPECT_TRUE(path::user_cache_directory(CacheDir, "A", "B", "file.c")); - auto It = path::rbegin(CacheDir); - EXPECT_EQ("file.c", *It); - EXPECT_EQ("B", *++It); - EXPECT_EQ("A", *++It); - auto ParentDir = *++It; - - // Test Unicode: "/(pi)r^2/aleth.0" - EXPECT_TRUE(path::user_cache_directory(CacheDir2, "\xCF\x80r\xC2\xB2", - "\xE2\x84\xB5.0")); - auto It2 = path::rbegin(CacheDir2); - EXPECT_EQ("\xE2\x84\xB5.0", *It2); - EXPECT_EQ("\xCF\x80r\xC2\xB2", *++It2); - auto ParentDir2 = *++It2; - - EXPECT_EQ(ParentDir, ParentDir2); - } -} - TEST(Support, TempDirectory) { SmallString<32> TempDir; path::system_temp_directory(false, TempDir);