summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-03-19 06:12:06 +0000
committerDouglas Gregor <dgregor@apple.com>2010-03-19 06:12:06 +0000
commit51c2351d30ac2f2126ed0ea2d7b70bc27d7bf140 (patch)
tree57678c866b529ecf1668641f1dfcab5968f157ef /clang
parent90a7859ebcb5f1a1dc81223f1561cce4de9c47da (diff)
downloadbcm5719-llvm-51c2351d30ac2f2126ed0ea2d7b70bc27d7bf140.tar.gz
bcm5719-llvm-51c2351d30ac2f2126ed0ea2d7b70bc27d7bf140.zip
Fix a longstanding (but previously unknown) bug in the lazy
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. llvm-svn: 98940
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Basic/SourceManager.cpp2
-rw-r--r--clang/test/Index/c-index-getCursor-test.m6
2 files changed, 7 insertions, 1 deletions
diff --git a/clang/lib/Basic/SourceManager.cpp b/clang/lib/Basic/SourceManager.cpp
index 4c24d030b87..6def967c4cf 100644
--- a/clang/lib/Basic/SourceManager.cpp
+++ b/clang/lib/Basic/SourceManager.cpp
@@ -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,
diff --git a/clang/test/Index/c-index-getCursor-test.m b/clang/test/Index/c-index-getCursor-test.m
index 8341b80a673..62701dbc0c9 100644
--- a/clang/test/Index/c-index-getCursor-test.m
+++ b/clang/test/Index/c-index-getCursor-test.m
@@ -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
OpenPOWER on IntegriCloud