Remove several unhelpful checks for isValid from sys::Path.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118127 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Dan Gohman 2010-11-03 00:01:23 +00:00
parent 4c914125c4
commit aabb9b67bc

View File

@ -149,10 +149,7 @@ Path::GetTemporaryDirectory(std::string *ErrMsg) {
std::string(pathname) + ": can't create temporary directory"); std::string(pathname) + ": can't create temporary directory");
return Path(); return Path();
} }
Path result; return Path(pathname);
result.set(pathname);
assert(result.isValid() && "mkdtemp didn't create a valid pathname!");
return result;
#elif defined(HAVE_MKSTEMP) #elif defined(HAVE_MKSTEMP)
// If no mkdtemp is available, mkstemp can be used to create a temporary file // If no mkdtemp is available, mkstemp can be used to create a temporary file
// which is then removed and created as a directory. We prefer this over // which is then removed and created as a directory. We prefer this over
@ -173,10 +170,7 @@ Path::GetTemporaryDirectory(std::string *ErrMsg) {
std::string(pathname) + ": can't create temporary directory"); std::string(pathname) + ": can't create temporary directory");
return Path(); return Path();
} }
Path result; return Path(pathname);
result.set(pathname);
assert(result.isValid() && "mkstemp didn't create a valid pathname!");
return result;
#elif defined(HAVE_MKTEMP) #elif defined(HAVE_MKTEMP)
// If a system doesn't have mkdtemp(3) or mkstemp(3) but it does have // If a system doesn't have mkdtemp(3) or mkstemp(3) but it does have
// mktemp(3) then we'll assume that system (e.g. AIX) has a reasonable // mktemp(3) then we'll assume that system (e.g. AIX) has a reasonable
@ -195,10 +189,7 @@ Path::GetTemporaryDirectory(std::string *ErrMsg) {
std::string(TmpName) + ": can't create temporary directory"); std::string(TmpName) + ": can't create temporary directory");
return Path(); return Path();
} }
Path result; return Path(TmpName);
result.set(TmpName);
assert(result.isValid() && "mktemp didn't create a valid pathname!");
return result;
#else #else
// This is the worst case implementation. tempnam(3) leaks memory unless its // This is the worst case implementation. tempnam(3) leaks memory unless its
// on an SVID2 (or later) system. On BSD 4.3 it leaks. tmpnam(3) has thread // on an SVID2 (or later) system. On BSD 4.3 it leaks. tmpnam(3) has thread
@ -219,10 +210,7 @@ Path::GetTemporaryDirectory(std::string *ErrMsg) {
std::string(pathname) + ": can't create temporary directory"); std::string(pathname) + ": can't create temporary directory");
return Path(); return Path();
} }
Path result; return Path(pathname);
result.set(pathname);
assert(result.isValid() && "mkstemp didn't create a valid pathname!");
return result;
#endif #endif
} }
@ -597,10 +585,6 @@ Path::set(StringRef a_path) {
return false; return false;
std::string save(path); std::string save(path);
path = a_path; path = a_path;
if (!isValid()) {
path = save;
return false;
}
return true; return true;
} }
@ -612,10 +596,6 @@ Path::appendComponent(StringRef name) {
if (!lastIsSlash(path)) if (!lastIsSlash(path))
path += '/'; path += '/';
path += name; path += name;
if (!isValid()) {
path = save;
return false;
}
return true; return true;
} }
@ -647,8 +627,6 @@ Path::eraseSuffix() {
return true; return true;
} }
} }
if (!isValid())
path = save;
return false; return false;
} }