[cfe-commits] r138670 - in /cfe/trunk: include/clang/Driver/Driver.h lib/Driver/Driver.cpp
Chad Rosier
mcrosier at apple.com
Fri Aug 26 15:27:03 PDT 2011
Author: mcrosier
Date: Fri Aug 26 17:27:02 2011
New Revision: 138670
URL: http://llvm.org/viewvc/llvm-project?rev=138670&view=rev
Log:
Cleanup r138662 per Ben and David's suggestions, thanks.
Modified:
cfe/trunk/include/clang/Driver/Driver.h
cfe/trunk/lib/Driver/Driver.cpp
Modified: cfe/trunk/include/clang/Driver/Driver.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Driver.h?rev=138670&r1=138669&r2=138670&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/Driver.h (original)
+++ cfe/trunk/include/clang/Driver/Driver.h Fri Aug 26 17:27:02 2011
@@ -377,7 +377,7 @@
/// 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.
Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=138670&r1=138669&r2=138670&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Fri Aug 26 17:27:02 2011
@@ -1335,15 +1335,6 @@
}
}
-// Strip the directory and suffix from BaseInput.
-static std::string getBaseName (const char *BaseInput) {
- std::pair<StringRef, StringRef> 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 @@
// Output to a temporary file?
if ((!AtTopLevel && !C.getArgs().hasArg(options::OPT_save_temps)) ||
CCGenDiagnostics) {
+ StringRef Name = llvm::sys::path::filename(BaseInput);
+ std::pair<StringRef, StringRef> 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 @@
// 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<StringRef, StringRef> 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 @@
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).
More information about the cfe-commits
mailing list