[cfe-commits] r98940 - in /cfe/trunk: lib/Basic/SourceManager.cpp test/Index/c-index-getCursor-test.m

Douglas Gregor dgregor at apple.com
Thu Mar 18 23:12:06 PDT 2010


Author: dgregor
Date: Fri Mar 19 01:12:06 2010
New Revision: 98940

URL: http://llvm.org/viewvc/llvm-project?rev=98940&view=rev
Log:
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.

Modified:
    cfe/trunk/lib/Basic/SourceManager.cpp
    cfe/trunk/test/Index/c-index-getCursor-test.m

Modified: cfe/trunk/lib/Basic/SourceManager.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/SourceManager.cpp?rev=98940&r1=98939&r2=98940&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/SourceManager.cpp (original)
+++ cfe/trunk/lib/Basic/SourceManager.cpp Fri Mar 19 01:12:06 2010
@@ -411,7 +411,7 @@
       = 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,

Modified: cfe/trunk/test/Index/c-index-getCursor-test.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/c-index-getCursor-test.m?rev=98940&r1=98939&r2=98940&view=diff
==============================================================================
--- cfe/trunk/test/Index/c-index-getCursor-test.m (original)
+++ cfe/trunk/test/Index/c-index-getCursor-test.m Fri Mar 19 01:12:06 2010
@@ -52,6 +52,12 @@
   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





More information about the cfe-commits mailing list