Teach CIndex's cursor visitor to restrict its traversal to a specific
region of interest (if provided). Implement clang_getCursor() in terms
of this traversal rather than using the Index library; the unified
cursor visitor is more complete, and will be The Way Forward.

Minor other tweaks needed to make this work:
  - Extend Preprocessor::getLocForEndOfToken() to accept an offset
  from the end, making it easy to move to the last character in the
  token (rather than just past the end of the token).
  - In Lexer::MeasureTokenLength(), the length of whitespace is zero.

llvm-svn: 94200
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index e77661a..794b14a 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -629,9 +629,13 @@
 }
 
 SourceRange VarDecl::getSourceRange() const {
+  SourceLocation Start = getTypeSpecStartLoc();
+  if (Start.isInvalid())
+    Start = getLocation();
+  
   if (getInit())
-    return SourceRange(getLocation(), getInit()->getLocEnd());
-  return SourceRange(getLocation(), getLocation());
+    return SourceRange(Start, getInit()->getLocEnd());
+  return SourceRange(Start, getLocation());
 }
 
 bool VarDecl::isOutOfLine() const {