Support/PathV1: Deprecate get{Basename,Dirname,Suffix}.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122157 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Michael J. Spencer 2010-12-18 22:23:07 +00:00
parent a37029cd24
commit 7385509101
7 changed files with 18 additions and 19 deletions

View File

@ -272,11 +272,13 @@ namespace sys {
/// this function to return "foo". /// this function to return "foo".
/// @returns StringRef containing the basename of the path /// @returns StringRef containing the basename of the path
/// @brief Get the base name of the path /// @brief Get the base name of the path
StringRef getBasename() const; LLVM_ATTRIBUTE_DEPRECATED(StringRef getBasename() const,
LLVMV_PATH_DEPRECATED_MSG);
/// This function strips off the suffix of the path beginning with the /// This function strips off the suffix of the path beginning with the
/// path separator ('/' on Unix, '\' on Windows) and returns the result. /// path separator ('/' on Unix, '\' on Windows) and returns the result.
StringRef getDirname() const; LLVM_ATTRIBUTE_DEPRECATED(StringRef getDirname() const,
LLVMV_PATH_DEPRECATED_MSG);
/// This function strips off the path and basename(up to and /// This function strips off the path and basename(up to and
/// including the last dot) of the file or directory name and /// including the last dot) of the file or directory name and
@ -284,7 +286,8 @@ namespace sys {
/// this function to return "bar". /// this function to return "bar".
/// @returns StringRef containing the suffix of the path /// @returns StringRef containing the suffix of the path
/// @brief Get the suffix of the path /// @brief Get the suffix of the path
StringRef getSuffix() const; LLVM_ATTRIBUTE_DEPRECATED(StringRef getSuffix() const,
LLVMV_PATH_DEPRECATED_MSG);
/// Obtain a 'C' string for the path name. /// Obtain a 'C' string for the path name.
/// @returns a 'C' string containing the path name. /// @returns a 'C' string containing the path name.

View File

@ -32,7 +32,8 @@ using namespace llvmc;
namespace llvmc { namespace llvmc {
const std::string* LanguageMap::GetLanguage(const sys::Path& File) const { const std::string* LanguageMap::GetLanguage(const sys::Path& File) const {
StringRef suf = File.getSuffix(); // Remove the '.'.
StringRef suf = sys::path::extension(File.str()).substr(1);
LanguageMap::const_iterator Lang = LanguageMap::const_iterator Lang =
this->find(suf.empty() ? "*empty*" : suf); this->find(suf.empty() ? "*empty*" : suf);
if (Lang == this->end()) { if (Lang == this->end()) {

View File

@ -43,8 +43,7 @@ namespace {
return 0; return 0;
} }
else if (SaveTemps == SaveTempsEnum::Obj && !OutputFilename.empty()) { else if (SaveTemps == SaveTempsEnum::Obj && !OutputFilename.empty()) {
tempDir = OutputFilename; tempDir = sys::path::parent_path(OutputFilename);
tempDir = tempDir.getDirname();
} }
else { else {
// SaveTemps == Cwd --> use current dir (leave tempDir empty). // SaveTemps == Cwd --> use current dir (leave tempDir empty).

View File

@ -61,7 +61,7 @@ sys::Path Tool::OutFilename(const sys::Path& In,
Out.appendSuffix(OutputSuffix); Out.appendSuffix(OutputSuffix);
} }
else { else {
Out.set(In.getBasename()); Out.set(sys::path::stem(In.str()));
Out.appendSuffix(OutputSuffix); Out.appendSuffix(OutputSuffix);
} }
} }
@ -69,7 +69,7 @@ sys::Path Tool::OutFilename(const sys::Path& In,
if (IsJoin()) if (IsJoin())
Out = MakeTempFile(TempDir, "tmp", OutputSuffix); Out = MakeTempFile(TempDir, "tmp", OutputSuffix);
else else
Out = MakeTempFile(TempDir, In.getBasename(), OutputSuffix); Out = MakeTempFile(TempDir, sys::path::stem(In.str()), OutputSuffix);
} }
return Out; return Out;
} }

View File

@ -1301,10 +1301,9 @@ Linker::LinkModules(Module *Dest, Module *Src, std::string *ErrorMsg) {
// If the source library's module id is in the dependent library list of the // If the source library's module id is in the dependent library list of the
// destination library, remove it since that module is now linked in. // destination library, remove it since that module is now linked in.
sys::Path modId; const std::string &modId = Src->getModuleIdentifier();
modId.set(Src->getModuleIdentifier()); if (!modId.empty())
if (!modId.isEmpty()) Dest->removeLibrary(sys::path::stem(modId));
Dest->removeLibrary(modId.getBasename());
return false; return false;
} }

View File

@ -526,7 +526,7 @@ int main(int argc, char **argv, char **envp) {
initializeTarget(Registry); initializeTarget(Registry);
// Initial global variable above for convenience printing of program name. // Initial global variable above for convenience printing of program name.
progname = sys::Path(argv[0]).getBasename(); progname = sys::path::stem(argv[0]);
// Parse the command line options // Parse the command line options
cl::ParseCommandLineOptions(argc, argv, "llvm linker\n"); cl::ParseCommandLineOptions(argc, argv, "llvm linker\n");
@ -538,11 +538,8 @@ int main(int argc, char **argv, char **envp) {
OutputFilename = "a.exe"; OutputFilename = "a.exe";
// If there is no suffix add an "exe" one. // If there is no suffix add an "exe" one.
sys::Path ExeFile( OutputFilename ); if (sys::path::extension(OutputFilename).empty())
if (ExeFile.getSuffix() == "") { OutputFilename.append(".exe");
ExeFile.appendSuffix("exe");
OutputFilename = ExeFile.str();
}
} }
#endif #endif

View File

@ -523,7 +523,7 @@ int main(int argc, char **argv) {
errs().indent(ToolName.size()) << ": DLL Name : " << DLLName << '\n'; errs().indent(ToolName.size()) << ": DLL Name : " << DLLName << '\n';
} }
if (NoUser32 && sys::Path(DLLName).getBasename() == "user32") { if (NoUser32 && sys::path::stem(DLLName) == "user32") {
// Program is loading user32.dll, in the applications we are testing, // Program is loading user32.dll, in the applications we are testing,
// this only happens if an assert has fired. By now the message has // this only happens if an assert has fired. By now the message has
// already been printed, so simply close the program. // already been printed, so simply close the program.