[cfe-commits] r39424 - in /cfe/cfe/trunk/Basic: SourceBuffer.cpp SourceManager.cpp
clattner at cs.uiuc.edu
clattner at cs.uiuc.edu
Wed Jul 11 09:44:13 PDT 2007
Author: clattner
Date: Wed Jul 11 11:44:12 2007
New Revision: 39424
URL: http://llvm.org/viewvc/llvm-project?rev=39424&view=rev
Log:
minor cleanups
Modified:
cfe/cfe/trunk/Basic/SourceBuffer.cpp
cfe/cfe/trunk/Basic/SourceManager.cpp
Modified: cfe/cfe/trunk/Basic/SourceBuffer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Basic/SourceBuffer.cpp?rev=39424&r1=39423&r2=39424&view=diff
==============================================================================
--- cfe/cfe/trunk/Basic/SourceBuffer.cpp (original)
+++ cfe/cfe/trunk/Basic/SourceBuffer.cpp Wed Jul 11 11:44:12 2007
@@ -163,44 +163,39 @@
// SourceBufferReadFile implementation.
//===----------------------------------------------------------------------===//
-#include <iostream>
SourceBuffer *SourceBuffer::getFile(const FileEntry *FileEnt) {
- try {
- // If the file is larger than some threshold, use 'read', otherwise use mmap.
- if (FileEnt->getSize() >= 4096*4)
- return new SourceBufferMMapFile(sys::Path(FileEnt->getName()));
+ // If the file is larger than some threshold, use 'read', otherwise use mmap.
+ if (FileEnt->getSize() >= 4096*4)
+ return new SourceBufferMMapFile(sys::Path(FileEnt->getName()));
- SourceBuffer *SB = getNewUninitMemBuffer(FileEnt->getSize(),
- FileEnt->getName());
- char *BufPtr = const_cast<char*>(SB->getBufferStart());
+ SourceBuffer *SB = getNewUninitMemBuffer(FileEnt->getSize(),
+ FileEnt->getName());
+ char *BufPtr = const_cast<char*>(SB->getBufferStart());
+
+ int FD = ::open(FileEnt->getName(), O_RDONLY);
+ if (FD == -1) {
+ delete SB;
+ return 0;
+ }
- int FD = ::open(FileEnt->getName(), O_RDONLY);
- if (FD == -1) {
+ unsigned BytesLeft = FileEnt->getSize();
+ while (BytesLeft) {
+ ssize_t NumRead = ::read(FD, BufPtr, BytesLeft);
+ if (NumRead != -1) {
+ BytesLeft -= NumRead;
+ BufPtr += NumRead;
+ } else if (errno == EINTR) {
+ // try again
+ } else {
+ // error reading.
+ close(FD);
delete SB;
return 0;
}
-
- unsigned BytesLeft = FileEnt->getSize();
- while (BytesLeft) {
- ssize_t NumRead = ::read(FD, BufPtr, BytesLeft);
- if (NumRead != -1) {
- BytesLeft -= NumRead;
- BufPtr += NumRead;
- } else if (errno == EINTR) {
- // try again
- } else {
- // error reading.
- close(FD);
- delete SB;
- return 0;
- }
- }
- close(FD);
-
- return SB;
- } catch (...) {
- return 0;
}
+ close(FD);
+
+ return SB;
}
//===----------------------------------------------------------------------===//
Modified: cfe/cfe/trunk/Basic/SourceManager.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Basic/SourceManager.cpp?rev=39424&r1=39423&r2=39424&view=diff
==============================================================================
--- cfe/cfe/trunk/Basic/SourceManager.cpp (original)
+++ cfe/cfe/trunk/Basic/SourceManager.cpp Wed Jul 11 11:44:12 2007
@@ -47,14 +47,9 @@
return &*I;
// Nope, get information.
- const SourceBuffer *File;
- try {
- File = clang::SourceBuffer::getFile(FileEnt);
- if (File == 0)
- return 0;
- } catch (...) {
+ const SourceBuffer *File = clang::SourceBuffer::getFile(FileEnt);
+ if (File == 0)
return 0;
- }
const InfoRec &Entry =
*FileInfos.insert(I, std::make_pair(FileEnt, FileInfo()));
More information about the cfe-commits
mailing list