[cfe-commits] r125378 - /cfe/trunk/lib/Basic/SourceManager.cpp
Douglas Gregor
dgregor at apple.com
Fri Feb 11 10:08:15 PST 2011
Author: dgregor
Date: Fri Feb 11 12:08:15 2011
New Revision: 125378
URL: http://llvm.org/viewvc/llvm-project?rev=125378&view=rev
Log:
Don't compare llvm::Optional<> objects directly; compare their
contents when it's safe. I just *love* C++ some days.
Modified:
cfe/trunk/lib/Basic/SourceManager.cpp
Modified: cfe/trunk/lib/Basic/SourceManager.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/SourceManager.cpp?rev=125378&r1=125377&r2=125378&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/SourceManager.cpp (original)
+++ cfe/trunk/lib/Basic/SourceManager.cpp Fri Feb 11 12:08:15 2011
@@ -1145,16 +1145,19 @@
if (MainSLoc.isFile()) {
const ContentCache *MainContentCache
= MainSLoc.getFile().getContentCache();
- if (MainContentCache->Entry == SourceFile)
+ if (!MainContentCache) {
+ // Can't do anything
+ } else if (MainContentCache->Entry == SourceFile) {
FirstFID = MainFileID;
- else if (MainContentCache) {
+ } else {
// Fall back: check whether we have the same base name and inode
// as the main file.
const FileEntry *MainFile = MainContentCache->Entry;
SourceFileName = llvm::sys::path::filename(SourceFile->getName());
if (*SourceFileName == llvm::sys::path::filename(MainFile->getName())) {
SourceFileInode = getActualFileInode(SourceFile);
- if (SourceFileInode == getActualFileInode(MainFile)) {
+ if (SourceFileInode &&
+ *SourceFileInode == getActualFileInode(MainFile)) {
FirstFID = MainFileID;
SourceFile = MainFile;
}
@@ -1192,11 +1195,14 @@
= SLoc.getFile().getContentCache();
const FileEntry *Entry =FileContentCache? FileContentCache->Entry : 0;
if (Entry &&
- *SourceFileName == llvm::sys::path::filename(Entry->getName()) &&
- SourceFileInode == getActualFileInode(Entry)) {
- FirstFID = FileID::get(I);
- SourceFile = Entry;
- break;
+ *SourceFileName == llvm::sys::path::filename(Entry->getName())) {
+ if (llvm::Optional<ino_t> EntryInode = getActualFileInode(Entry)) {
+ if (*SourceFileInode == *EntryInode) {
+ FirstFID = FileID::get(I);
+ SourceFile = Entry;
+ break;
+ }
+ }
}
}
}
More information about the cfe-commits
mailing list