summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2010-05-06 00:22:25 +0000
committerTed Kremenek <kremenek@apple.com>2010-05-06 00:22:25 +0000
commit5b0773e20149485862fbe1520b08940c30f4cb6e (patch)
treeff7354a9b52e774d2ced96b019e596eb0841e704
parentf3983652eb26d2f38cd3b1375f9b94d12e31787a (diff)
downloadbcm5719-llvm-5b0773e20149485862fbe1520b08940c30f4cb6e.tar.gz
bcm5719-llvm-5b0773e20149485862fbe1520b08940c30f4cb6e.zip
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. llvm-svn: 103143
-rw-r--r--clang/lib/Basic/SourceManager.cpp5
-rw-r--r--clang/test/Index/annotate-tokens-include.c6
-rw-r--r--clang/test/Index/annotate-tokens-include.h1
3 files changed, 12 insertions, 0 deletions
diff --git a/clang/lib/Basic/SourceManager.cpp b/clang/lib/Basic/SourceManager.cpp
index 3ecab1d8c16..3fb52a100b9 100644
--- a/clang/lib/Basic/SourceManager.cpp
+++ b/clang/lib/Basic/SourceManager.cpp
@@ -1170,15 +1170,20 @@ bool SourceManager::isBeforeInTranslationUnit(SourceLocation LHS,
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".
diff --git a/clang/test/Index/annotate-tokens-include.c b/clang/test/Index/annotate-tokens-include.c
new file mode 100644
index 00000000000..3c3c43b746d
--- /dev/null
+++ b/clang/test/Index/annotate-tokens-include.c
@@ -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=
+
diff --git a/clang/test/Index/annotate-tokens-include.h b/clang/test/Index/annotate-tokens-include.h
new file mode 100644
index 00000000000..5d5f8f0c9e7
--- /dev/null
+++ b/clang/test/Index/annotate-tokens-include.h
@@ -0,0 +1 @@
+int foo();
OpenPOWER on IntegriCloud