- Fixed broken Win32 build

- Removed warning about clobbered parameter in Bytecode/Reader


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30026 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Anton Korobeynikov
2006-09-01 20:35:17 +00:00
parent b5aaee0027
commit 7d51544903
8 changed files with 43 additions and 28 deletions

View File

@@ -2409,7 +2409,7 @@ void BytecodeReader::ParseModule() {
/// This function completely parses a bytecode buffer given by the \p Buf /// This function completely parses a bytecode buffer given by the \p Buf
/// and \p Length parameters. /// and \p Length parameters.
bool BytecodeReader::ParseBytecode(BufPtr Buf, unsigned Length, bool BytecodeReader::ParseBytecode(volatile BufPtr Buf, unsigned Length,
const std::string &ModuleID, const std::string &ModuleID,
std::string* ErrMsg) { std::string* ErrMsg) {

View File

@@ -140,7 +140,7 @@ public:
/// @returns true if an error occurred /// @returns true if an error occurred
/// @brief Main interface to parsing a bytecode buffer. /// @brief Main interface to parsing a bytecode buffer.
bool ParseBytecode( bool ParseBytecode(
const unsigned char *Buf, ///< Beginning of the bytecode buffer volatile BufPtr Buf, ///< Beginning of the bytecode buffer
unsigned Length, ///< Length of the bytecode buffer unsigned Length, ///< Length of the bytecode buffer
const std::string &ModuleID, ///< An identifier for the module constructed. const std::string &ModuleID, ///< An identifier for the module constructed.
std::string* ErrMsg = 0 ///< Optional place for error message std::string* ErrMsg = 0 ///< Optional place for error message

View File

@@ -55,6 +55,8 @@ bool MappedFile::initialize(std::string* ErrMsg) {
return MakeErrMsg(ErrMsg, return MakeErrMsg(ErrMsg,
std::string("Can't get size of file: ") + path_.toString()); std::string("Can't get size of file: ") + path_.toString());
} }
return false;
} }
void MappedFile::terminate() { void MappedFile::terminate() {

View File

@@ -315,12 +315,12 @@ bool Path::makeReadableOnDisk(std::string* ErrMsg) {
return false; return false;
} }
void Path::makeWriteableOnDisk(std::string* ErrMsg) { bool Path::makeWriteableOnDisk(std::string* ErrMsg) {
DWORD attr = GetFileAttributes(path.c_str()); DWORD attr = GetFileAttributes(path.c_str());
// If it doesn't exist, we're done. // If it doesn't exist, we're done.
if (attr == INVALID_FILE_ATTRIBUTES) if (attr == INVALID_FILE_ATTRIBUTES)
return; return false;
if (attr & FILE_ATTRIBUTE_READONLY) { if (attr & FILE_ATTRIBUTE_READONLY) {
if (!SetFileAttributes(path.c_str(), attr & ~FILE_ATTRIBUTE_READONLY)) { if (!SetFileAttributes(path.c_str(), attr & ~FILE_ATTRIBUTE_READONLY)) {
@@ -338,7 +338,11 @@ bool Path::makeExecutableOnDisk(std::string* ErrMsg) {
bool bool
Path::getDirectoryContents(std::set<Path>& result, std::string* ErrMsg) const { Path::getDirectoryContents(std::set<Path>& result, std::string* ErrMsg) const {
if (!isDirectory()) { FileStatus Status;
if (getFileStatus(Status, ErrMsg))
return true;
if (!Status.isDir) {
MakeErrMsg(ErrMsg, path + ": not a directory"); MakeErrMsg(ErrMsg, path + ": not a directory");
return true; return true;
} }
@@ -512,7 +516,7 @@ Path::createDirectoryOnDisk(bool create_parents, std::string* ErrMsg) {
// Drop trailing slash. // Drop trailing slash.
pathname[len-1] = 0; pathname[len-1] = 0;
if (!CreateDirectory(pathname, NULL)) { if (!CreateDirectory(pathname, NULL)) {
return MakeErrMsg(, std::string(pathname) + ": Can't create directory: "); return MakeErrMsg(ErrMsg, std::string(pathname) + ": Can't create directory: ");
} }
} }
return false; return false;
@@ -652,9 +656,11 @@ Path::renamePathOnDisk(const Path& newName, std::string* ErrMsg) {
} }
bool bool
Path::setStatusInfoOnDisk(const FileStatus &si, std::string *ErrStr) const { Path::setStatusInfoOnDisk(const FileStatus &si, std::string *ErrMsg) const {
// FIXME: should work on directories also. // FIXME: should work on directories also.
if (!isFile()) return true; if (!si.isFile) {
return true;
}
HANDLE h = CreateFile(path.c_str(), HANDLE h = CreateFile(path.c_str(),
FILE_READ_ATTRIBUTES | FILE_WRITE_ATTRIBUTES, FILE_READ_ATTRIBUTES | FILE_WRITE_ATTRIBUTES,
@@ -671,7 +677,7 @@ Path::setStatusInfoOnDisk(const FileStatus &si, std::string *ErrStr) const {
DWORD err = GetLastError(); DWORD err = GetLastError();
CloseHandle(h); CloseHandle(h);
SetLastError(err); SetLastError(err);
return MakeErrMsg(ErrStr, path + ": GetFileInformationByHandle: "); return MakeErrMsg(ErrMsg, path + ": GetFileInformationByHandle: ");
} }
FILETIME ft; FILETIME ft;
@@ -681,7 +687,7 @@ Path::setStatusInfoOnDisk(const FileStatus &si, std::string *ErrStr) const {
CloseHandle(h); CloseHandle(h);
if (!ret) { if (!ret) {
SetLastError(err); SetLastError(err);
return MakeErrMsg(path + ": SetFileTime: "); return MakeErrMsg(ErrMsg, path + ": SetFileTime: ");
} }
// Best we can do with Unix permission bits is to interpret the owner // Best we can do with Unix permission bits is to interpret the owner
@@ -690,13 +696,13 @@ Path::setStatusInfoOnDisk(const FileStatus &si, std::string *ErrStr) const {
if (bhfi.dwFileAttributes & FILE_ATTRIBUTE_READONLY) { if (bhfi.dwFileAttributes & FILE_ATTRIBUTE_READONLY) {
if (!SetFileAttributes(path.c_str(), if (!SetFileAttributes(path.c_str(),
bhfi.dwFileAttributes & ~FILE_ATTRIBUTE_READONLY)) bhfi.dwFileAttributes & ~FILE_ATTRIBUTE_READONLY))
return MakeErrMsg(ErrStr, path + ": SetFileAttributes: "); return MakeErrMsg(ErrMsg, path + ": SetFileAttributes: ");
} }
} else { } else {
if (!(bhfi.dwFileAttributes & FILE_ATTRIBUTE_READONLY)) { if (!(bhfi.dwFileAttributes & FILE_ATTRIBUTE_READONLY)) {
if (!SetFileAttributes(path.c_str(), if (!SetFileAttributes(path.c_str(),
bhfi.dwFileAttributes | FILE_ATTRIBUTE_READONLY)) bhfi.dwFileAttributes | FILE_ATTRIBUTE_READONLY))
return MakeErrMsg(ErrStr, path + ": SetFileAttributes: "); return MakeErrMsg(ErrMsg, path + ": SetFileAttributes: ");
} }
} }
@@ -739,13 +745,13 @@ Path::makeUnique(bool reuse_current, std::string* ErrMsg) {
bool bool
Path::createTemporaryFileOnDisk(bool reuse_current, std::string* ErrMsg) { Path::createTemporaryFileOnDisk(bool reuse_current, std::string* ErrMsg) {
// Make this into a unique file name // Make this into a unique file name
makeUnique(reuse_current); makeUnique(reuse_current, ErrMsg);
// Now go and create it // Now go and create it
HANDLE h = CreateFile(path.c_str(), GENERIC_WRITE, 0, NULL, CREATE_NEW, HANDLE h = CreateFile(path.c_str(), GENERIC_WRITE, 0, NULL, CREATE_NEW,
FILE_ATTRIBUTE_NORMAL, NULL); FILE_ATTRIBUTE_NORMAL, NULL);
if (h == INVALID_HANDLE_VALUE) if (h == INVALID_HANDLE_VALUE)
return MakeErrMsg(ErrMsg, path.toString() + ": can't create file"); return MakeErrMsg(ErrMsg, path + ": can't create file");
CloseHandle(h); CloseHandle(h);
return false; return false;

View File

@@ -158,14 +158,14 @@ Program::ExecuteAndWait(const Path& path,
MakeErrMsg(ErrMsg, "can't redirect stdin"); MakeErrMsg(ErrMsg, "can't redirect stdin");
return -1; return -1;
} }
si.hStdOutput = RedirectIO(redirects[1], 1); si.hStdOutput = RedirectIO(redirects[1], 1, ErrMsg);
if (si.hStdOutput == INVALID_HANDLE_VALUE) { if (si.hStdOutput == INVALID_HANDLE_VALUE) {
CloseHandle(si.hStdInput); CloseHandle(si.hStdInput);
MakeErrMsg(ErrMsg, "can't redirect stdout"); MakeErrMsg(ErrMsg, "can't redirect stdout");
return -1; return -1;
} }
if (redirects[1] && redirects[2] && *(redirects[1]) != *(redirects[2])) { if (redirects[1] && redirects[2] && *(redirects[1]) != *(redirects[2])) {
si.hStdError = RedirectIO(redirects[2], 2); si.hStdError = RedirectIO(redirects[2], 2, ErrMsg);
if (si.hStdError == INVALID_HANDLE_VALUE) { if (si.hStdError == INVALID_HANDLE_VALUE) {
CloseHandle(si.hStdInput); CloseHandle(si.hStdInput);
CloseHandle(si.hStdOutput); CloseHandle(si.hStdOutput);

View File

@@ -30,11 +30,7 @@ inline bool MakeErrMsg(std::string* ErrMsg, const std::string& prefix) {
char *buffer = NULL; char *buffer = NULL;
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM, FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM,
NULL, GetLastError(), 0, (LPSTR)&buffer, 1, NULL); NULL, GetLastError(), 0, (LPSTR)&buffer, 1, NULL);
ErrMsg = prefix + buffer; *ErrMsg = prefix + buffer;
LocalFree(buffer); LocalFree(buffer);
return true; return true;
} }
inline void MakeErrnoMsg(std::string* ErrMsg, const std::string & prefix) {
MakeErrorMsg(prefix + ": " + strerror(errno));
}

View File

@@ -137,12 +137,17 @@ static void EmitShellScript(char **argv) {
// Windows doesn't support #!/bin/sh style shell scripts in .exe files. To // Windows doesn't support #!/bin/sh style shell scripts in .exe files. To
// support windows systems, we copy the llvm-stub.exe executable from the // support windows systems, we copy the llvm-stub.exe executable from the
// build tree to the destination file. // build tree to the destination file.
std::string llvmstub = FindExecutable("llvm-stub.exe", argv[0]).toString(); std::string ErrMsg;
if (llvmstub.empty()) { sys::Path llvmstub = FindExecutable("llvm-stub.exe", argv[0]);
if (llvmstub.isEmpty()) {
std::cerr << "Could not find llvm-stub.exe executable!\n"; std::cerr << "Could not find llvm-stub.exe executable!\n";
exit(1); exit(1);
} }
sys::CopyFile(sys::Path(OutputFilename), sys::Path(llvmstub)); if (0 != sys::CopyFile(sys::Path(OutputFilename), llvmstub, &ErrMsg)) {
std::cerr << argv[0] << ": " << ErrMsg << "\n";
exit(1);
}
return; return;
#endif #endif

View File

@@ -345,12 +345,18 @@ static void EmitShellScript(char **argv) {
// Windows doesn't support #!/bin/sh style shell scripts in .exe files. To // Windows doesn't support #!/bin/sh style shell scripts in .exe files. To
// support windows systems, we copy the llvm-stub.exe executable from the // support windows systems, we copy the llvm-stub.exe executable from the
// build tree to the destination file. // build tree to the destination file.
std::string ErrMsg;
sys::Path llvmstub = FindExecutable("llvm-stub.exe", argv[0]); sys::Path llvmstub = FindExecutable("llvm-stub.exe", argv[0]);
if (llvmstub.isEmpty()) { if (llvmstub.isEmpty()) {
std::cerr << "Could not find llvm-stub.exe executable!\n"; std::cerr << "Could not find llvm-stub.exe executable!\n";
exit(1); exit(1);
} }
sys::CopyFile(sys::Path(OutputFilename), llvmstub);
if (0 != sys::CopyFile(sys::Path(OutputFilename), llvmstub, &ErrMsg)) {
std::cerr << argv[0] << ": " << ErrMsg << "\n";
exit(1);
}
return; return;
#endif #endif