Skip to content
This repository has been archived by the owner on Apr 23, 2020. It is now read-only.

Commit

Permalink
Fix a longstanding (but previously unknown) bug in the lazy
Browse files Browse the repository at this point in the history
deserialization of precompiled headers, where the deserialization of
the source location entry for a buffer (e.g., macro instantiation
scratch space) would overwrite a one-element FileID cache in the
source manager. When tickled at the wrong time, we would return the
wrong decomposed source location and eventually cause c-index-test to
crash.

Found by dumb luck. It's amazing this hasn't shown up before.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98940 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
DougGregor committed Mar 19, 2010
1 parent 0396f46 commit 5de6572
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/Basic/SourceManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ FileID SourceManager::createFileID(const ContentCache *File,
= SLocEntry::get(Offset, FileInfo::get(IncludePos, File, FileCharacter));
SLocEntryLoaded[PreallocatedID] = true;
FileID FID = FileID::get(PreallocatedID);
return LastFileIDLookup = FID;
return FID;
}

SLocEntryTable.push_back(SLocEntry::get(NextOffset,
Expand Down
6 changes: 6 additions & 0 deletions test/Index/c-index-getCursor-test.m
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ int main (int argc, const char * argv[]) {
main(someEnum, (const char **)bee);
}

#define CONCAT(X, Y) X##Y

void f() {
int CONCAT(my,_var);
}

// CHECK: [1:1 - 3:1] Invalid Cursor => NoDeclFound
// CHECK: [3:1 - 7:1] ObjCInterfaceDecl=Foo:3:12
// CHECK: [7:1 - 7:7] ObjCInstanceMethodDecl=foo:7:1
Expand Down

0 comments on commit 5de6572

Please sign in to comment.