From: Chad Rosier Date: Fri, 26 Aug 2011 22:27:02 +0000 (+0000) Subject: Cleanup r138662 per Ben and David's suggestions, thanks. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f43b5e84aa982afacd87a225440ec88a9b66c1a0;p=clang Cleanup r138662 per Ben and David's suggestions, thanks. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138670 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Driver/Driver.h b/include/clang/Driver/Driver.h index 2145d724c3..bcb75b3a28 100644 --- a/include/clang/Driver/Driver.h +++ b/include/clang/Driver/Driver.h @@ -377,7 +377,7 @@ public: /// as part of compilation; the file will have the given prefix and suffix. /// /// GCC goes to extra lengths here to be a bit more robust. - std::string GetTemporaryPath(const char *Prefix, const char *Suffix) const; + std::string GetTemporaryPath(StringRef Prefix, const char *Suffix) const; /// GetHostInfo - Construct a new host info object for the given /// host triple. diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp index 66d2df16e1..534984b4b3 100644 --- a/lib/Driver/Driver.cpp +++ b/lib/Driver/Driver.cpp @@ -1335,15 +1335,6 @@ void Driver::BuildJobsForAction(Compilation &C, } } -// Strip the directory and suffix from BaseInput. -static std::string getBaseName (const char *BaseInput) { - std::pair Split = StringRef(BaseInput).rsplit('/'); - if (Split.second != "") - return Split.second.split('.').first.str(); - else - return Split.first.split('.').first.str(); -} - const char *Driver::GetNamedOutputPath(Compilation &C, const JobAction &JA, const char *BaseInput, @@ -1363,9 +1354,10 @@ const char *Driver::GetNamedOutputPath(Compilation &C, // Output to a temporary file? if ((!AtTopLevel && !C.getArgs().hasArg(options::OPT_save_temps)) || CCGenDiagnostics) { + StringRef Name = llvm::sys::path::filename(BaseInput); + std::pair Split = Name.split('.'); std::string TmpName = - GetTemporaryPath(getBaseName(BaseInput).c_str(), - types::getTypeTempSuffix(JA.getType())); + GetTemporaryPath(Split.first, types::getTypeTempSuffix(JA.getType())); return C.addTempFile(C.getArgs().MakeArgString(TmpName.c_str())); } @@ -1399,9 +1391,10 @@ const char *Driver::GetNamedOutputPath(Compilation &C, // filename, then avoid overwriting input file. if (!AtTopLevel && C.getArgs().hasArg(options::OPT_save_temps) && NamedOutput == BaseName) { + StringRef Name = llvm::sys::path::filename(BaseInput); + std::pair Split = Name.split('.'); std::string TmpName = - GetTemporaryPath(getBaseName(BaseInput).c_str(), - types::getTypeTempSuffix(JA.getType())); + GetTemporaryPath(Split.first, types::getTypeTempSuffix(JA.getType())); return C.addTempFile(C.getArgs().MakeArgString(TmpName.c_str())); } @@ -1486,7 +1479,7 @@ std::string Driver::GetProgramPath(const char *Name, const ToolChain &TC, return Name; } -std::string Driver::GetTemporaryPath(const char *Prefix, const char *Suffix) +std::string Driver::GetTemporaryPath(StringRef Prefix, const char *Suffix) const { // FIXME: This is lame; sys::Path should provide this function (in particular, // it should know how to find the temporary files dir).