[cfe-commits] r103143 - in /cfe/trunk: lib/Basic/SourceManager.cpp test/Index/annotate-tokens-include.c test/Index/annotate-tokens-include.h

Ted Kremenek kremenek at apple.com
Wed May 5 17:22:25 PDT 2010


Author: kremenek
Date: Wed May  5 19:22:25 2010
New Revision: 103143

URL: http://llvm.org/viewvc/llvm-project?rev=103143&view=rev
Log:
Workaround a really serious caching bug in SourceManager::isBeforeInTranslationUnit() where the
method will sometimes return different results for the same input SourceLocations.  I haven't
unraveled this method completely yet, so this truly is a workaround until a better fix comes
along.

Added:
    cfe/trunk/test/Index/annotate-tokens-include.c
    cfe/trunk/test/Index/annotate-tokens-include.h
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=103143&r1=103142&r2=103143&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/SourceManager.cpp (original)
+++ cfe/trunk/lib/Basic/SourceManager.cpp Wed May  5 19:22:25 2010
@@ -1170,15 +1170,20 @@
   if (LOffs.first == ROffs.first)
     return LOffs.second < ROffs.second;
 
+#if 0
   // If we are comparing a source location with multiple locations in the same
   // file, we get a big win by caching the result.
 
+  // FIXME: This caching is wrong, but I don't know enough about this code
+  // to immediately fix it.  There are cases where passing the same input
+  // values to this method causes it to return different results.
   if (LastLFIDForBeforeTUCheck == LOffs.first &&
       LastRFIDForBeforeTUCheck == ROffs.first)
     return LastResForBeforeTUCheck;
 
   LastLFIDForBeforeTUCheck = LOffs.first;
   LastRFIDForBeforeTUCheck = ROffs.first;
+#endif
 
   // "Traverse" the include/instantiation stacks of both locations and try to
   // find a common "ancestor".

Added: cfe/trunk/test/Index/annotate-tokens-include.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/annotate-tokens-include.c?rev=103143&view=auto
==============================================================================
--- cfe/trunk/test/Index/annotate-tokens-include.c (added)
+++ cfe/trunk/test/Index/annotate-tokens-include.c Wed May  5 19:22:25 2010
@@ -0,0 +1,6 @@
+#include "annotate-tokens-include.h"
+
+// RUN: c-index-test -test-annotate-tokens=%s:1:1:2:1 %s | FileCheck %s
+// CHECK: Identifier: "include" [1:2 - 1:9] preprocessing directive=
+// CHECK: Literal: ""annotate-tokens-include.h"" [1:10 - 1:37] preprocessing directive=
+

Added: cfe/trunk/test/Index/annotate-tokens-include.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/annotate-tokens-include.h?rev=103143&view=auto
==============================================================================
--- cfe/trunk/test/Index/annotate-tokens-include.h (added)
+++ cfe/trunk/test/Index/annotate-tokens-include.h Wed May  5 19:22:25 2010
@@ -0,0 +1 @@
+int foo();





More information about the cfe-commits mailing list