aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/clang/Lex/Preprocessor.h7
-rw-r--r--lib/AST/Decl.cpp8
-rw-r--r--lib/Lex/Lexer.cpp4
-rw-r--r--lib/Lex/Preprocessor.cpp18
-rw-r--r--test/Index/TestClassDecl.m19
-rw-r--r--test/Index/TestClassForwardDecl.m11
-rw-r--r--test/Index/c-index-api-fn-scan.m217
-rw-r--r--test/Index/c-index-api-loadTU-test.m39
-rw-r--r--test/Index/c-index-getCursor-test.m69
-rw-r--r--test/Index/find-decls.c25
-rw-r--r--test/Index/find-defs.c18
-rw-r--r--tools/CIndex/CIndex.cpp181
12 files changed, 235 insertions, 381 deletions
diff --git a/include/clang/Lex/Preprocessor.h b/include/clang/Lex/Preprocessor.h
index 1e664c07a4..dedbbd868a 100644
--- a/include/clang/Lex/Preprocessor.h
+++ b/include/clang/Lex/Preprocessor.h
@@ -602,7 +602,12 @@ public:
/// the returned source location would not be meaningful (e.g., if
/// it points into a macro), this routine returns an invalid
/// source location.
- SourceLocation getLocForEndOfToken(SourceLocation Loc);
+ ///
+ /// \param Offset an offset from the end of the token, where the source
+ /// location should refer to. The default offset (0) produces a source
+ /// location pointing just past the end of the token; an offset of 1 produces
+ /// a source location pointing to the last character in the token, etc.
+ SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset = 0);
/// DumpToken - Print the token to stderr, used for debugging.
///
diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp
index e77661a9fb..794b14a1f4 100644
--- a/lib/AST/Decl.cpp
+++ b/lib/AST/Decl.cpp
@@ -629,9 +629,13 @@ VarDecl::~VarDecl() {
}
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 {
diff --git a/lib/Lex/Lexer.cpp b/lib/Lex/Lexer.cpp
index 9556bc39ec..afd1ba8851 100644
--- a/lib/Lex/Lexer.cpp
+++ b/lib/Lex/Lexer.cpp
@@ -210,6 +210,7 @@ void Lexer::Stringify(llvm::SmallVectorImpl<char> &Str) {
}
}
+static bool isWhitespace(unsigned char c);
/// MeasureTokenLength - Relex the token at the specified location and return
/// its length in bytes in the input file. If the token needs cleaning (e.g.
@@ -231,6 +232,9 @@ unsigned Lexer::MeasureTokenLength(SourceLocation Loc,
std::pair<const char *,const char *> Buffer = SM.getBufferData(LocInfo.first);
const char *StrData = Buffer.first+LocInfo.second;
+ if (isWhitespace(StrData[0]))
+ return 0;
+
// Create a lexer starting at the beginning of this token.
Lexer TheLexer(Loc, LangOpts, Buffer.first, StrData, Buffer.second);
TheLexer.SetCommentRetentionState(true);
diff --git a/lib/Lex/Preprocessor.cpp b/lib/Lex/Preprocessor.cpp
index 586202bccf..5689baaac6 100644
--- a/lib/Lex/Preprocessor.cpp
+++ b/lib/Lex/Preprocessor.cpp
@@ -429,21 +429,17 @@ SourceLocation Preprocessor::AdvanceToTokenCharacter(SourceLocation TokStart,
return TokStart.getFileLocWithOffset(PhysOffset);
}
-/// \brief Computes the source location just past the end of the
-/// token at this source location.
-///
-/// This routine can be used to produce a source location that
-/// points just past the end of the token referenced by \p Loc, and
-/// is generally used when a diagnostic needs to point just after a
-/// token where it expected something different that it received. If
-/// the returned source location would not be meaningful (e.g., if
-/// it points into a macro), this routine returns an invalid
-/// source location.
-SourceLocation Preprocessor::getLocForEndOfToken(SourceLocation Loc) {
+SourceLocation Preprocessor::getLocForEndOfToken(SourceLocation Loc,
+ unsigned Offset) {
if (Loc.isInvalid() || !Loc.isFileID())
return SourceLocation();
unsigned Len = Lexer::MeasureTokenLength(Loc, getSourceManager(), Features);
+ if (Len > Offset)
+ Len = Len - Offset;
+ else
+ return Loc;
+
return AdvanceToTokenCharacter(Loc, Len);
}
diff --git a/test/Index/TestClassDecl.m b/test/Index/TestClassDecl.m
index 900629d593..f9627123a0 100644
--- a/test/Index/TestClassDecl.m
+++ b/test/Index/TestClassDecl.m
@@ -17,22 +17,17 @@ void function(Foo * arg)
// CHECK-scan: {start_line=1 start_col=1 end_line=7 end_col=1} Invalid Cursor => NoDeclFound
// CHECK-scan: {start_line=8 start_col=1 end_line=8 end_col=7} UnexposedDecl=:8:1
-// CHECK-scan: {start_line=8 start_col=8 end_line=8 end_col=10} ObjCClassRef=Foo:10:1
+// CHECK-scan: {start_line=8 start_col=8 end_line=8 end_col=10} ObjCClassRef=Foo:10:12
// CHECK-scan: {start_line=8 start_col=11 end_line=9 end_col=1} Invalid Cursor => NoDeclFound
-// CHECK-scan: {start_line=10 start_col=1 end_line=11 end_col=4} ObjCInterfaceDecl=Foo:10:1
-// CHECK-scan: {start_line=11 start_col=5 end_line=12 end_col=1} Invalid Cursor => NoDeclFound
-// CHECK-scan: {start_line=13 start_col=1 end_line=13 end_col=4} FunctionDecl=function:13:6 (Definition)
-// CHECK-scan: {start_line=13 start_col=5 end_line=13 end_col=5} Invalid Cursor => NoDeclFound
+// CHECK-scan: {start_line=10 start_col=1 end_line=11 end_col=4} ObjCInterfaceDecl=Foo:10:12
+// CHECK-scan: {start_line=11 start_col=5 end_line=13 end_col=5} Invalid Cursor => NoDeclFound
// CHECK-scan: {start_line=13 start_col=6 end_line=13 end_col=14} FunctionDecl=function:13:6 (Definition)
-// CHECK-scan: {start_line=13 start_col=15 end_line=13 end_col=17} ObjCClassRef=Foo:10:1
-// CHECK-scan: {start_line=13 start_col=18 end_line=13 end_col=18} FunctionDecl=function:13:6 (Definition)
-// CHECK-scan: {start_line=13 start_col=19 end_line=13 end_col=19} ParmDecl=arg:13:21
-// CHECK-scan: {start_line=13 start_col=20 end_line=13 end_col=20} FunctionDecl=function:13:6 (Definition)
-// CHECK-scan: {start_line=13 start_col=21 end_line=13 end_col=23} ParmDecl=arg:13:21
+// CHECK-scan: {start_line=13 start_col=15 end_line=13 end_col=17} ObjCClassRef=Foo:10:12
+// CHECK-scan: {start_line=13 start_col=18 end_line=13 end_col=23} ParmDecl=arg:13:21 (Definition)
+// CHECK-scan: {start_line=13 start_col=24 end_line=13 end_col=25} FunctionDecl=function:13:6 (Definition)
// CHECK-scan: {start_line=14 start_col=1 end_line=16 end_col=1} UnexposedStmt=function
-// CHECK-scan: {start_line=16 start_col=2 end_line=38 end_col=1} Invalid Cursor => NoDeclFound
// CHECK-load: TestClassDecl.m:10:12: ObjCInterfaceDecl=Foo:10:12 [Extent=10:1:11:4]
// CHECK-load: TestClassDecl.m:13:6: FunctionDecl=function:13:6 (Definition) [Extent=13:6:16:1]
-// CHECK-load: TestClassDecl.m:13:21: ParmDecl=arg:13:21 (Definition) [Extent=13:21:13:23]
+// CHECK-load: TestClassDecl.m:13:21: ParmDecl=arg:13:21 (Definition) [Extent=13:15:13:23]
diff --git a/test/Index/TestClassForwardDecl.m b/test/Index/TestClassForwardDecl.m
index ffb96f4f38..c53453b0ba 100644
--- a/test/Index/TestClassForwardDecl.m
+++ b/test/Index/TestClassForwardDecl.m
@@ -15,17 +15,12 @@ void function(Foo * arg)
// CHECK-scan: {start_line=1 start_col=1 end_line=7 end_col=1} Invalid Cursor => NoDeclFound
// CHECK-scan: {start_line=8 start_col=1 end_line=8 end_col=7} UnexposedDecl=:8:1
// CHECK-scan: {start_line=8 start_col=8 end_line=8 end_col=10} ObjCClassRef=Foo:8:8
-// CHECK-scan: {start_line=8 start_col=11 end_line=9 end_col=1} Invalid Cursor => NoDeclFound
-// CHECK-scan: {start_line=10 start_col=1 end_line=10 end_col=4} FunctionDecl=function:10:6 (Definition)
-// CHECK-scan: {start_line=10 start_col=5 end_line=10 end_col=5} Invalid Cursor => NoDeclFound
+// CHECK-scan: {start_line=8 start_col=11 end_line=10 end_col=5} Invalid Cursor => NoDeclFound
// CHECK-scan: {start_line=10 start_col=6 end_line=10 end_col=14} FunctionDecl=function:10:6 (Definition)
// CHECK-scan: {start_line=10 start_col=15 end_line=10 end_col=17} ObjCClassRef=Foo:8:8
-// CHECK-scan: {start_line=10 start_col=18 end_line=10 end_col=18} FunctionDecl=function:10:6 (Definition)
-// CHECK-scan: {start_line=10 start_col=19 end_line=10 end_col=19} ParmDecl=arg:10:21
-// CHECK-scan: {start_line=10 start_col=20 end_line=10 end_col=20} FunctionDecl=function:10:6 (Definition)
-// CHECK-scan: {start_line=10 start_col=21 end_line=10 end_col=23} ParmDecl=arg:10:21
+// CHECK-scan: {start_line=10 start_col=18 end_line=10 end_col=23} ParmDecl=arg:10:21 (Definition)
+// CHECK-scan: {start_line=10 start_col=24 end_line=10 end_col=25} FunctionDecl=function:10:6 (Definition)
// CHECK-scan: {start_line=11 start_col=1 end_line=13 end_col=1} UnexposedStmt=function
-// CHECK-scan: {start_line=13 start_col=2 end_line=46 end_col=1} Invalid Cursor => NoDeclFound
diff --git a/test/Index/c-index-api-fn-scan.m b/test/Index/c-index-api-fn-scan.m
deleted file mode 100644
index ecd04fe4b4..0000000000
--- a/test/Index/c-index-api-fn-scan.m
+++ /dev/null
@@ -1,217 +0,0 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-nonfragile-abi -fblocks -emit-pch -x objective-c %s -o %t.ast
-// RUN: c-index-test -test-load-tu %t.ast scan-function | FileCheck %s
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-@interface Foo
-{
-}
-
-- foo;
-+ fooC;
-
-@end
-
-@interface Bar : Foo
-{
-}
-
-@end
-
-@interface Foo (FooCat)
-- (int) catMethodWithFloat:(float) fArg;
-- (float) floatMethod;
-@end
-
-@protocol Proto
-- pMethod;
-@end
-
-@protocol SubP <Proto>
-- spMethod;
-@end
-
-@interface Baz : Bar <SubP>
-{
- int _anIVar;
-}
-
-- (Foo *) bazMethod;
-
-@end
-
-enum {
- someEnum
-};
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-int main (int argc, const char * argv[]) {
- Baz * bee;
- id a = [bee foo];
- id <SubP> c = [Foo fooC];
- id <Proto> d;
- d = c;
- [d pMethod];
- [bee catMethodWithFloat:[bee floatMethod]];
- main(someEnum, (const char **)bee);
-}
-
-// CHECK: c-index-api-fn-scan.m:84:2: ObjCClassRef=Baz:48:1
-// CHECK: c-index-api-fn-scan.m:84:3: ObjCClassRef=Baz:48:1
-// CHECK: c-index-api-fn-scan.m:84:4: ObjCClassRef=Baz:48:1
-// CHECK: c-index-api-fn-scan.m:84:6: VarDecl=bee:84:8
-// CHECK: c-index-api-fn-scan.m:84:8: VarDecl=bee:84:8
-// CHECK: c-index-api-fn-scan.m:84:9: VarDecl=bee:84:8
-// CHECK: c-index-api-fn-scan.m:84:10: VarDecl=bee:84:8
-// CHECK: <invalid loc>:85:2: TypedefDecl=id:0:0
-// CHECK: <invalid loc>:85:3: TypedefDecl=id:0:0
-// CHECK: c-index-api-fn-scan.m:85:5: VarDecl=a:85:5
-// CHECK: c-index-api-fn-scan.m:85:6: VarDecl=a:85:5
-// CHECK: c-index-api-fn-scan.m:85:7: VarDecl=a:85:5
-// CHECK: c-index-api-fn-scan.m:85:8: VarDecl=a:85:5
-// CHECK: c-index-api-fn-scan.m:85:9: ObjCMessageExpr=foo:24:1
-// CHECK: c-index-api-fn-scan.m:85:10: DeclRefExpr=bee:84:8
-// CHECK: c-index-api-fn-scan.m:85:11: DeclRefExpr=bee:84:8
-// CHECK: c-index-api-fn-scan.m:85:12: DeclRefExpr=bee:84:8
-// CHECK: c-index-api-fn-scan.m:85:13: ObjCMessageExpr=foo:24:1
-// CHECK: c-index-api-fn-scan.m:85:14: ObjCMessageExpr=foo:24:1
-// CHECK: c-index-api-fn-scan.m:85:15: ObjCMessageExpr=foo:24:1
-// CHECK: c-index-api-fn-scan.m:85:16: ObjCMessageExpr=foo:24:1
-// CHECK: c-index-api-fn-scan.m:85:17: ObjCMessageExpr=foo:24:1
-// CHECK: <invalid loc>:86:2: TypedefDecl=id:0:0
-// CHECK: <invalid loc>:86:3: TypedefDecl=id:0:0
-// CHECK: c-index-api-fn-scan.m:86:5: VarDecl=c:86:12
-// CHECK: c-index-api-fn-scan.m:86:6: ObjCProtocolRef=SubP:44:1
-// CHECK: c-index-api-fn-scan.m:86:7: ObjCProtocolRef=SubP:44:1
-// CHECK: c-index-api-fn-scan.m:86:8: ObjCProtocolRef=SubP:44:1
-// CHECK: c-index-api-fn-scan.m:86:9: ObjCProtocolRef=SubP:44:1
-// CHECK: c-index-api-fn-scan.m:86:10: VarDecl=c:86:12
-// CHECK: c-index-api-fn-scan.m:86:12: VarDecl=c:86:12
-// CHECK: c-index-api-fn-scan.m:86:13: VarDecl=c:86:12
-// CHECK: c-index-api-fn-scan.m:86:14: VarDecl=c:86:12
-// CHECK: c-index-api-fn-scan.m:86:15: VarDecl=c:86:12
-// CHECK: c-index-api-fn-scan.m:86:16: ObjCMessageExpr=fooC:25:1
-// CHECK: c-index-api-fn-scan.m:86:17: ObjCMessageExpr=fooC:25:1
-// CHECK: c-index-api-fn-scan.m:86:18: ObjCMessageExpr=fooC:25:1
-// CHECK: c-index-api-fn-scan.m:86:19: ObjCMessageExpr=fooC:25:1
-// CHECK: c-index-api-fn-scan.m:86:20: ObjCMessageExpr=fooC:25:1
-// CHECK: c-index-api-fn-scan.m:86:21: ObjCMessageExpr=fooC:25:1
-// CHECK: c-index-api-fn-scan.m:86:22: ObjCMessageExpr=fooC:25:1
-// CHECK: c-index-api-fn-scan.m:86:23: ObjCMessageExpr=fooC:25:1
-// CHECK: c-index-api-fn-scan.m:86:24: ObjCMessageExpr=fooC:25:1
-// CHECK: c-index-api-fn-scan.m:86:25: ObjCMessageExpr=fooC:25:1
-// CHECK: <invalid loc>:87:2: TypedefDecl=id:0:0
-// CHECK: <invalid loc>:87:3: TypedefDecl=id:0:0
-// CHECK: c-index-api-fn-scan.m:87:5: VarDecl=d:87:13
-// CHECK: c-index-api-fn-scan.m:87:6: ObjCProtocolRef=Proto:40:1
-// CHECK: c-index-api-fn-scan.m:87:7: ObjCProtocolRef=Proto:40:1
-// CHECK: c-index-api-fn-scan.m:87:8: ObjCProtocolRef=Proto:40:1
-// CHECK: c-index-api-fn-scan.m:87:9: ObjCProtocolRef=Proto:40:1
-// CHECK: c-index-api-fn-scan.m:87:10: ObjCProtocolRef=Proto:40:1
-// CHECK: c-index-api-fn-scan.m:87:11: VarDecl=d:87:13
-// CHECK: c-index-api-fn-scan.m:87:13: VarDecl=d:87:13
-// CHECK: c-index-api-fn-scan.m:88:2: DeclRefExpr=d:87:13
-// CHECK: c-index-api-fn-scan.m:88:6: DeclRefExpr=c:86:12
-// CHECK: c-index-api-fn-scan.m:89:2: ObjCMessageExpr=pMethod:41:1
-// CHECK: c-index-api-fn-scan.m:89:3: DeclRefExpr=d:87:13
-// CHECK: c-index-api-fn-scan.m:89:4: ObjCMessageExpr=pMethod:41:1
-// CHECK: c-index-api-fn-scan.m:89:5: ObjCMessageExpr=pMethod:41:1
-// CHECK: c-index-api-fn-scan.m:89:6: ObjCMessageExpr=pMethod:41:1
-// CHECK: c-index-api-fn-scan.m:89:7: ObjCMessageExpr=pMethod:41:1
-// CHECK: c-index-api-fn-scan.m:89:8: ObjCMessageExpr=pMethod:41:1
-// CHECK: c-index-api-fn-scan.m:89:9: ObjCMessageExpr=pMethod:41:1
-// CHECK: c-index-api-fn-scan.m:89:10: ObjCMessageExpr=pMethod:41:1
-// CHECK: c-index-api-fn-scan.m:89:11: ObjCMessageExpr=pMethod:41:1
-// CHECK: c-index-api-fn-scan.m:89:12: ObjCMessageExpr=pMethod:41:1
-// CHECK: c-index-api-fn-scan.m:90:2: ObjCMessageExpr=catMethodWithFloat::36:1
-// CHECK: c-index-api-fn-scan.m:90:3: DeclRefExpr=bee:84:8
-// CHECK: c-index-api-fn-scan.m:90:4: DeclRefExpr=bee:84:8
-// CHECK: c-index-api-fn-scan.m:90:5: DeclRefExpr=bee:84:8
-// CHECK: c-index-api-fn-scan.m:90:6: ObjCMessageExpr=catMethodWithFloat::36:1
-// CHECK: c-index-api-fn-scan.m:90:7: ObjCMessageExpr=catMethodWithFloat::36:1
-// CHECK: c-index-api-fn-scan.m:90:8: ObjCMessageExpr=catMethodWithFloat::36:1
-// CHECK: c-index-api-fn-scan.m:90:9: ObjCMessageExpr=catMethodWithFloat::36:1
-// CHECK: c-index-api-fn-scan.m:90:10: ObjCMessageExpr=catMethodWithFloat::36:1
-// CHECK: c-index-api-fn-scan.m:90:11: ObjCMessageExpr=catMethodWithFloat::36:1
-// CHECK: c-index-api-fn-scan.m:90:12: ObjCMessageExpr=catMethodWithFloat::36:1
-// CHECK: c-index-api-fn-scan.m:90:13: ObjCMessageExpr=catMethodWithFloat::36:1
-// CHECK: c-index-api-fn-scan.m:90:14: ObjCMessageExpr=catMethodWithFloat::36:1
-// CHECK: c-index-api-fn-scan.m:90:15: ObjCMessageExpr=catMethodWithFloat::36:1
-// CHECK: c-index-api-fn-scan.m:90:16: ObjCMessageExpr=catMethodWithFloat::36:1
-// CHECK: c-index-api-fn-scan.m:90:17: ObjCMessageExpr=catMethodWithFloat::36:1
-// CHECK: c-index-api-fn-scan.m:90:18: ObjCMessageExpr=catMethodWithFloat::36:1
-// CHECK: c-index-api-fn-scan.m:90:19: ObjCMessageExpr=catMethodWithFloat::36:1
-// CHECK: c-index-api-fn-scan.m:90:20: ObjCMessageExpr=catMethodWithFloat::36:1
-// CHECK: c-index-api-fn-scan.m:90:21: ObjCMessageExpr=catMethodWithFloat::36:1
-// CHECK: c-index-api-fn-scan.m:90:22: ObjCMessageExpr=catMethodWithFloat::36:1
-// CHECK: c-index-api-fn-scan.m:90:23: ObjCMessageExpr=catMethodWithFloat::36:1
-// CHECK: c-index-api-fn-scan.m:90:24: ObjCMessageExpr=catMethodWithFloat::36:1
-// CHECK: c-index-api-fn-scan.m:90:25: ObjCMessageExpr=catMethodWithFloat::36:1
-// CHECK: c-index-api-fn-scan.m:90:26: ObjCMessageExpr=floatMethod:37:1
-// CHECK: c-index-api-fn-scan.m:90:27: DeclRefExpr=bee:84:8
-// CHECK: c-index-api-fn-scan.m:90:28: DeclRefExpr=bee:84:8
-// CHECK: c-index-api-fn-scan.m:90:29: DeclRefExpr=bee:84:8
-// CHECK: c-index-api-fn-scan.m:90:30: ObjCMessageExpr=floatMethod:37:1
-// CHECK: c-index-api-fn-scan.m:90:31: ObjCMessageExpr=floatMethod:37:1
-// CHECK: c-index-api-fn-scan.m:90:32: ObjCMessageExpr=floatMethod:37:1
-// CHECK: c-index-api-fn-scan.m:90:33: ObjCMessageExpr=floatMethod:37:1
-// CHECK: c-index-api-fn-scan.m:90:34: ObjCMessageExpr=floatMethod:37:1
-// CHECK: c-index-api-fn-scan.m:90:35: ObjCMessageExpr=floatMethod:37:1
-// CHECK: c-index-api-fn-scan.m:90:36: ObjCMessageExpr=floatMethod:37:1
-// CHECK: c-index-api-fn-scan.m:90:37: ObjCMessageExpr=floatMethod:37:1
-// CHECK: c-index-api-fn-scan.m:90:38: ObjCMessageExpr=floatMethod:37:1
-// CHECK: c-index-api-fn-scan.m:90:39: ObjCMessageExpr=floatMethod:37:1
-// CHECK: c-index-api-fn-scan.m:90:40: ObjCMessageExpr=floatMethod:37:1
-// CHECK: c-index-api-fn-scan.m:90:41: ObjCMessageExpr=floatMethod:37:1
-// CHECK: c-index-api-fn-scan.m:90:42: ObjCMessageExpr=floatMethod:37:1
-// CHECK: c-index-api-fn-scan.m:90:43: ObjCMessageExpr=catMethodWithFloat::36:1
-// CHECK: c-index-api-fn-scan.m:91:3: DeclRefExpr=main:83:5
-// CHECK: c-index-api-fn-scan.m:91:4: DeclRefExpr=main:83:5
-// CHECK: c-index-api-fn-scan.m:91:5: DeclRefExpr=main:83:5
-// CHECK: c-index-api-fn-scan.m:91:6: DeclRefExpr=main:83:5
-// CHECK: c-index-api-fn-scan.m:91:8: DeclRefExpr=someEnum:58:3
-// CHECK: c-index-api-fn-scan.m:91:9: DeclRefExpr=someEnum:58:3
-// CHECK: c-index-api-fn-scan.m:91:10: DeclRefExpr=someEnum:58:3
-// CHECK: c-index-api-fn-scan.m:91:11: DeclRefExpr=someEnum:58:3
-// CHECK: c-index-api-fn-scan.m:91:12: DeclRefExpr=someEnum:58:3
-// CHECK: c-index-api-fn-scan.m:91:13: DeclRefExpr=someEnum:58:3
-// CHECK: c-index-api-fn-scan.m:91:14: DeclRefExpr=someEnum:58:3
-// CHECK: c-index-api-fn-scan.m:91:15: DeclRefExpr=someEnum:58:3
-// CHECK: c-index-api-fn-scan.m:91:33: DeclRefExpr=bee:84:8
-// CHECK: c-index-api-fn-scan.m:91:34: DeclRefExpr=bee:84:8
-// CHECK: c-index-api-fn-scan.m:91:35: DeclRefExpr=bee:84:8
diff --git a/test/Index/c-index-api-loadTU-test.m b/test/Index/c-index-api-loadTU-test.m
index 5daadb4dd1..cf0dbff457 100644
--- a/test/Index/c-index-api-loadTU-test.m
+++ b/test/Index/c-index-api-loadTU-test.m
@@ -53,6 +53,22 @@ int main (int argc, const char * argv[]) {
main(someEnum, (const char **)bee);
}
+// CHECK: <invalid loc>:0:0: TypedefDecl=__int128_t:0:0 (Definition)
+// CHECK: <invalid loc>:0:0: TypedefDecl=__uint128_t:0:0 (Definition)
+// CHECK: <invalid loc>:0:0: TypedefDecl=SEL:0:0 (Definition)
+// CHECK: <invalid loc>:0:0: TypeRef=SEL:0:0
+// CHECK: <invalid loc>:0:0: TypedefDecl=id:0:0 (Definition)
+// CHECK: <invalid loc>:0:0: TypedefDecl=Class:0:0 (Definition)
+// CHECK: <invalid loc>:87:16: StructDecl=__va_list_tag:87:16 (Definition)
+// CHECK: <invalid loc>:87:42: FieldDecl=gp_offset:87:42 (Definition)
+// CHECK: <invalid loc>:87:63: FieldDecl=fp_offset:87:63 (Definition)
+// CHECK: <invalid loc>:87:81: FieldDecl=overflow_arg_area:87:81 (Definition)
+// CHECK: <invalid loc>:87:107: FieldDecl=reg_save_area:87:107 (Definition)
+// CHECK: <invalid loc>:87:123: TypedefDecl=__va_list_tag:87:123 (Definition)
+// CHECK: <invalid loc>:87:9: TypeRef=struct __va_list_tag:87:16
+// CHECK: <invalid loc>:87:159: TypedefDecl=__builtin_va_list:87:159 (Definition)
+// CHECK: <invalid loc>:87:145: TypeRef=__va_list_tag:87:123
+// CHECK: <invalid loc>:87:177: UnexposedExpr=
// CHECK: c-index-api-loadTU-test.m:4:12: ObjCInterfaceDecl=Foo:4:12 [Extent=4:1:11:4]
// CHECK: c-index-api-loadTU-test.m:8:1: ObjCInstanceMethodDecl=foo:8:1 [Extent=8:1:8:6]
// CHECK: c-index-api-loadTU-test.m:9:1: ObjCClassMethodDecl=fooC:9:1 [Extent=9:1:9:7]
@@ -61,6 +77,7 @@ int main (int argc, const char * argv[]) {
// CHECK: c-index-api-loadTU-test.m:19:12: ObjCCategoryDecl=FooCat:19:12 [Extent=19:1:22:4]
// CHECK: c-index-api-loadTU-test.m:19:12: ObjCClassRef=Foo:4:12 [Extent=19:12:19:14]
// CHECK: c-index-api-loadTU-test.m:20:1: ObjCInstanceMethodDecl=catMethodWithFloat::20:1 [Extent=20:1:20:40]
+// CHECK: c-index-api-loadTU-test.m:20:36: ParmDecl=fArg:20:36 (Definition) [Extent=20:29:20:39]
// CHECK: c-index-api-loadTU-test.m:21:1: ObjCInstanceMethodDecl=floatMethod:21:1 [Extent=21:1:21:22]
// CHECK: c-index-api-loadTU-test.m:24:1: ObjCProtocolDecl=Proto:24:1 (Definition) [Extent=24:1:26:4]
// CHECK: c-index-api-loadTU-test.m:25:1: ObjCInstanceMethodDecl=pMethod:25:1 [Extent=25:1:25:10]
@@ -75,25 +92,25 @@ int main (int argc, const char * argv[]) {
// CHECK: c-index-api-loadTU-test.m:41:1: EnumDecl=:41:1 (Definition) [Extent=41:1:43:1]
// CHECK: c-index-api-loadTU-test.m:42:3: EnumConstantDecl=someEnum:42:3 (Definition) [Extent=42:3:42:10]
// CHECK: c-index-api-loadTU-test.m:45:5: FunctionDecl=main:45:5 (Definition) [Extent=45:5:54:1]
-// CHECK: c-index-api-loadTU-test.m:45:15: ParmDecl=argc:45:15 (Definition) [Extent=45:15:45:18]
-// CHECK: c-index-api-loadTU-test.m:45:34: ParmDecl=argv:45:34 (Definition) [Extent=45:34:45:37]
-// CHECK: c-index-api-loadTU-test.m:45:5: UnexposedStmt=main [Extent=45:5:54:1]
-// CHECK: c-index-api-loadTU-test.m:45:5: UnexposedStmt=main [Extent=45:5:54:1]
-// CHECK: c-index-api-loadTU-test.m:46:8: VarDecl=bee:46:8 (Definition) [Extent=46:8:46:10]
+// CHECK: c-index-api-loadTU-test.m:45:15: ParmDecl=argc:45:15 (Definition) [Extent=45:11:45:18]
+// CHECK: c-index-api-loadTU-test.m:45:34: ParmDecl=argv:45:34 (Definition) [Extent=45:27:45:37]
+// CHECK: c-index-api-loadTU-test.m:45:5: UnexposedStmt=main [Extent=45:42:54:1]
+// CHECK: c-index-api-loadTU-test.m:45:5: UnexposedStmt=main [Extent=46:2:46:11]
+// CHECK: c-index-api-loadTU-test.m:46:8: VarDecl=bee:46:8 (Definition) [Extent=46:2:46:10]
// CHECK: c-index-api-loadTU-test.m:46:2: ObjCClassRef=Baz:32:12 [Extent=46:2:46:4]
-// CHECK: c-index-api-loadTU-test.m:46:8: UnexposedStmt=bee [Extent=46:8:46:10]
-// CHECK: c-index-api-loadTU-test.m:47:5: VarDecl=a:47:5 (Definition) [Extent=47:5:47:17]
+// CHECK: c-index-api-loadTU-test.m:46:8: UnexposedStmt=bee [Extent=47:2:47:18]
+// CHECK: c-index-api-loadTU-test.m:47:5: VarDecl=a:47:5 (Definition) [Extent=47:2:47:17]
// CHECK: c-index-api-loadTU-test.m:47:2: TypeRef=id:0:0 [Extent=47:2:47:3]
// CHECK: c-index-api-loadTU-test.m:47:9: ObjCMessageExpr=foo:8:1 [Extent=47:9:47:17]
// CHECK: c-index-api-loadTU-test.m:47:10: DeclRefExpr=bee:46:8 [Extent=47:10:47:12]
-// CHECK: c-index-api-loadTU-test.m:47:5: UnexposedStmt=a [Extent=47:5:47:17]
-// CHECK: c-index-api-loadTU-test.m:48:12: VarDecl=c:48:12 (Definition) [Extent=48:12:48:25]
+// CHECK: c-index-api-loadTU-test.m:47:5: UnexposedStmt=a [Extent=48:2:48:26]
+// CHECK: c-index-api-loadTU-test.m:48:12: VarDecl=c:48:12 (Definition) [Extent=48:2:48:25]
// CHECK: c-index-api-loadTU-test.m:48:2: TypeRef=id:0:0 [Extent=48:2:48:3]
// CHECK: c-index-api-loadTU-test.m:48:6: ObjCProtocolRef=SubP:28:1 [Extent=48:6:48:9]
// CHECK: c-index-api-loadTU-test.m:48:16: UnexposedExpr=fooC:9:1 [Extent=48:16:48:25]
// CHECK: c-index-api-loadTU-test.m:48:16: ObjCMessageExpr=fooC:9:1 [Extent=48:16:48:25]
-// CHECK: c-index-api-loadTU-test.m:48:12: UnexposedStmt=c [Extent=48:12:48:25]
-// CHECK: c-index-api-loadTU-test.m:49:13: VarDecl=d:49:13 (Definition) [Extent=49:13:49:13]
+// CHECK: c-index-api-loadTU-test.m:48:12: UnexposedStmt=c [Extent=49:2:49:14]
+// CHECK: c-index-api-loadTU-test.m:49:13: VarDecl=d:49:13 (Definition) [Extent=49:2:49:13]
// CHECK: c-index-api-loadTU-test.m:49:2: TypeRef=id:0:0 [Extent=49:2:49:3]
// CHECK: c-index-api-loadTU-test.m:49:6: ObjCProtocolRef=Proto:24:1 [Extent=49:6:49:10]
// CHECK: c-index-api-loadTU-test.m:50:2: UnexposedExpr= [Extent=50:2:50:6]
diff --git a/test/Index/c-index-getCursor-test.m b/test/Index/c-index-getCursor-test.m
index e0d8588bc2..8fb7ffc5ff 100644
--- a/test/Index/c-index-getCursor-test.m
+++ b/test/Index/c-index-getCursor-test.m
@@ -59,13 +59,15 @@ int main (int argc, const char * argv[]) {
// CHECK: {start_line=8 start_col=1 end_line=8 end_col=7} ObjCClassMethodDecl=fooC:8:1
// CHECK: {start_line=8 start_col=8 end_line=10 end_col=4} ObjCInterfaceDecl=Foo:3:12
// CHECK: {start_line=10 start_col=5 end_line=11 end_col=1} Invalid Cursor => NoDeclFound
-// CHECK: {start_line=12 start_col=1 end_line=16 end_col=4} ObjCInterfaceDecl=Bar:12:12
+// CHECK: {start_line=12 start_col=1 end_line=12 end_col=17} ObjCInterfaceDecl=Bar:12:12
+// CHECK: {start_line=12 start_col=18 end_line=12 end_col=20} ObjCSuperClassRef=Foo:3:12
+// CHECK: {start_line=12 start_col=21 end_line=16 end_col=4} ObjCInterfaceDecl=Bar:12:12
// CHECK: {start_line=16 start_col=5 end_line=17 end_col=1} Invalid Cursor => NoDeclFound
-// CHECK: {start_line=18 start_col=1 end_line=18 end_col=24} ObjCCategoryDecl=FooCat:18:12
+// CHECK: {start_line=18 start_col=1 end_line=18 end_col=11} ObjCCategoryDecl=FooCat:18:12
+// CHECK: {start_line=18 start_col=12 end_line=18 end_col=14} ObjCClassRef=Foo:3:12
+// CHECK: {start_line=18 start_col=15 end_line=18 end_col=24} ObjCCategoryDecl=FooCat:18:12
// CHECK: {start_line=19 start_col=1 end_line=19 end_col=28} ObjCInstanceMethodDecl=catMethodWithFloat::19:1
-// CHECK: {start_line=19 start_col=29 end_line=19 end_col=33} ParmDecl=fArg:19:36 (Definition)
-// CHECK: {start_line=19 start_col=34 end_line=19 end_col=35} ObjCInstanceMethodDecl=catMethodWithFloat::19:1
-// CHECK: {start_line=19 start_col=36 end_line=19 end_col=39} ParmDecl=fArg:19:36 (Definition)
+// CHECK: {start_line=19 start_col=29 end_line=19 end_col=39} ParmDecl=fArg:19:36 (Definition)
// CHECK: {start_line=19 start_col=40 end_line=19 end_col=40} ObjCInstanceMethodDecl=catMethodWithFloat::19:1
// CHECK: {start_line=19 start_col=41 end_line=19 end_col=41} ObjCCategoryDecl=FooCat:18:12
// CHECK: {start_line=20 start_col=1 end_line=20 end_col=22} ObjCInstanceMethodDecl=floatMethod:20:1
@@ -75,13 +77,17 @@ int main (int argc, const char * argv[]) {
// CHECK: {start_line=24 start_col=1 end_line=24 end_col=10} ObjCInstanceMethodDecl=pMethod:24:1
// CHECK: {start_line=24 start_col=11 end_line=25 end_col=4} ObjCProtocolDecl=Proto:23:1 (Definition)
// CHECK: {start_line=25 start_col=5 end_line=26 end_col=1} Invalid Cursor => NoDeclFound
-// CHECK: {start_line=27 start_col=1 end_line=27 end_col=23} ObjCProtocolDecl=SubP:27:1 (Definition)
+// CHECK: {start_line=27 start_col=1 end_line=27 end_col=16} ObjCProtocolDecl=SubP:27:1 (Definition)
+// CHECK: {start_line=27 start_col=17 end_line=27 end_col=21} ObjCProtocolRef=Proto:23:1
+// CHECK: {start_line=27 start_col=22 end_line=27 end_col=23} ObjCProtocolDecl=SubP:27:1 (Definition)
// CHECK: {start_line=28 start_col=1 end_line=28 end_col=11} ObjCInstanceMethodDecl=spMethod:28:1
// CHECK: {start_line=28 start_col=12 end_line=29 end_col=4} ObjCProtocolDecl=SubP:27:1 (Definition)
// CHECK: {start_line=29 start_col=5 end_line=30 end_col=1} Invalid Cursor => NoDeclFound
-// CHECK: {start_line=31 start_col=1 end_line=33 end_col=4} ObjCInterfaceDecl=Baz:31:12
-// CHECK: {start_line=33 start_col=5 end_line=33 end_col=7} ObjCIvarDecl=_anIVar:33:9 (Definition)
-// CHECK: {start_line=33 start_col=8 end_line=33 end_col=8} ObjCInterfaceDecl=Baz:31:12
+// CHECK: {start_line=31 start_col=1 end_line=31 end_col=17} ObjCInterfaceDecl=Baz:31:12
+// CHECK: {start_line=31 start_col=18 end_line=31 end_col=20} ObjCSuperClassRef=Bar:12:12
+// CHECK: {start_line=31 start_col=21 end_line=31 end_col=22} ObjCInterfaceDecl=Baz:31:12
+// CHECK: {start_line=31 start_col=23 end_line=31 end_col=26} ObjCProtocolRef=SubP:27:1
+// CHECK: {start_line=31 start_col=27 end_line=33 end_col=8} ObjCInterfaceDecl=Baz:31:12
// CHECK: {start_line=33 start_col=9 end_line=33 end_col=15} ObjCIvarDecl=_anIVar:33:9 (Definition)
// CHECK: {start_line=33 start_col=16 end_line=35 end_col=1} ObjCInterfaceDecl=Baz:31:12
// CHECK: {start_line=36 start_col=1 end_line=36 end_col=20} ObjCInstanceMethodDecl=bazMethod:36:1
@@ -90,53 +96,35 @@ int main (int argc, const char * argv[]) {
// CHECK: {start_line=40 start_col=1 end_line=41 end_col=2} EnumDecl=:40:1 (Definition)
// CHECK: {start_line=41 start_col=3 end_line=41 end_col=10} EnumConstantDecl=someEnum:41:3 (Definition)
// CHECK: {start_line=41 start_col=11 end_line=42 end_col=1} EnumDecl=:40:1 (Definition)
-// CHECK: {start_line=42 start_col=2 end_line=43 end_col=1} Invalid Cursor => NoDeclFound
-// CHECK: {start_line=44 start_col=1 end_line=44 end_col=3} FunctionDecl=main:44:5 (Definition)
-// CHECK: {start_line=44 start_col=4 end_line=44 end_col=4} Invalid Cursor => NoDeclFound
+// CHECK: {start_line=42 start_col=2 end_line=44 end_col=4} Invalid Cursor => NoDeclFound
// CHECK: {start_line=44 start_col=5 end_line=44 end_col=10} FunctionDecl=main:44:5 (Definition)
-// CHECK: {start_line=44 start_col=11 end_line=44 end_col=13} ParmDecl=argc:44:15 (Definition)
-// CHECK: {start_line=44 start_col=14 end_line=44 end_col=14} FunctionDecl=main:44:5 (Definition)
-// CHECK: {start_line=44 start_col=15 end_line=44 end_col=18} ParmDecl=argc:44:15 (Definition)
+// CHECK: {start_line=44 start_col=11 end_line=44 end_col=18} ParmDecl=argc:44:15 (Definition)
// CHECK: {start_line=44 start_col=19 end_line=44 end_col=26} FunctionDecl=main:44:5 (Definition)
-// CHECK: {start_line=44 start_col=27 end_line=44 end_col=30} ParmDecl=argv:44:34 (Definition)
-// CHECK: {start_line=44 start_col=31 end_line=44 end_col=31} FunctionDecl=main:44:5 (Definition)
-// CHECK: {start_line=44 start_col=32 end_line=44 end_col=32} ParmDecl=argv:44:34 (Definition)
-// CHECK: {start_line=44 start_col=33 end_line=44 end_col=33} FunctionDecl=main:44:5 (Definition)
-// CHECK: {start_line=44 start_col=34 end_line=44 end_col=39} ParmDecl=argv:44:34 (Definition)
-// CHECK: {start_line=44 start_col=40 end_line=44 end_col=41} FunctionDecl=main:44:5 (Definition)
+// CHECK: {start_line=44 start_col=27 end_line=44 end_col=37} ParmDecl=argv:44:34 (Definition)
+// CHECK: {start_line=44 start_col=38 end_line=44 end_col=41} FunctionDecl=main:44:5 (Definition)
// CHECK: {start_line=44 start_col=42 end_line=45 end_col=1} UnexposedStmt=main
// CHECK: {start_line=45 start_col=2 end_line=45 end_col=4} ObjCClassRef=Baz:31:12
-// CHECK: {start_line=45 start_col=5 end_line=45 end_col=5} UnexposedStmt=main
-// CHECK: {start_line=45 start_col=6 end_line=45 end_col=6} VarDecl=bee:45:8 (Definition)
-// CHECK: {start_line=45 start_col=7 end_line=45 end_col=7} UnexposedStmt=main
-// CHECK: {start_line=45 start_col=8 end_line=45 end_col=10} VarDecl=bee:45:8 (Definition)
+// CHECK: {start_line=45 start_col=5 end_line=45 end_col=10} VarDecl=bee:45:8 (Definition)
// CHECK: {start_line=45 start_col=11 end_line=45 end_col=11} UnexposedStmt=main
// CHECK: {start_line=45 start_col=12 end_line=46 end_col=1} UnexposedStmt=main
-// CHECK: {start_line=46 start_col=2 end_line=46 end_col=3} TypedefDecl=id:0:0 (Definition)
-// CHECK: {start_line=46 start_col=4 end_line=46 end_col=4} UnexposedStmt=main
-// CHECK: {start_line=46 start_col=5 end_line=46 end_col=8} VarDecl=a:46:5 (Definition)
+// CHECK: {start_line=46 start_col=2 end_line=46 end_col=3} TypeRef=id:0:0
+// CHECK: {start_line=46 start_col=4 end_line=46 end_col=8} VarDecl=a:46:5 (Definition)
// CHECK: {start_line=46 start_col=9 end_line=46 end_col=9} ObjCMessageExpr=foo:7:1
// CHECK: {start_line=46 start_col=10 end_line=46 end_col=12} DeclRefExpr=bee:45:8
// CHECK: {start_line=46 start_col=13 end_line=46 end_col=17} ObjCMessageExpr=foo:7:1
// CHECK: {start_line=46 start_col=18 end_line=46 end_col=18} UnexposedStmt=main
// CHECK: {start_line=46 start_col=19 end_line=47 end_col=1} UnexposedStmt=main
-// CHECK: {start_line=47 start_col=2 end_line=47 end_col=3} TypedefDecl=id:0:0 (Definition)
-// CHECK: {start_line=47 start_col=4 end_line=47 end_col=4} UnexposedStmt=main
-// CHECK: {start_line=47 start_col=5 end_line=47 end_col=5} VarDecl=c:47:12 (Definition)
+// CHECK: {start_line=47 start_col=2 end_line=47 end_col=3} TypeRef=id:0:0
+// CHECK: {start_line=47 start_col=4 end_line=47 end_col=5} VarDecl=c:47:12 (Definition)
// CHECK: {start_line=47 start_col=6 end_line=47 end_col=9} ObjCProtocolRef=SubP:27:1
-// CHECK: {start_line=47 start_col=10 end_line=47 end_col=10} VarDecl=c:47:12 (Definition)
-// CHECK: {start_line=47 start_col=11 end_line=47 end_col=11} UnexposedStmt=main
-// CHECK: {start_line=47 start_col=12 end_line=47 end_col=15} VarDecl=c:47:12 (Definition)
+// CHECK: {start_line=47 start_col=10 end_line=47 end_col=15} VarDecl=c:47:12 (Definition)
// CHECK: {start_line=47 start_col=16 end_line=47 end_col=25} ObjCMessageExpr=fooC:8:1
// CHECK: {start_line=47 start_col=26 end_line=47 end_col=26} UnexposedStmt=main
// CHECK: {start_line=47 start_col=27 end_line=48 end_col=1} UnexposedStmt=main
-// CHECK: {start_line=48 start_col=2 end_line=48 end_col=3} TypedefDecl=id:0:0 (Definition)
-// CHECK: {start_line=48 start_col=4 end_line=48 end_col=4} UnexposedStmt=main
-// CHECK: {start_line=48 start_col=5 end_line=48 end_col=5} VarDecl=d:48:13 (Definition)
+// CHECK: {start_line=48 start_col=2 end_line=48 end_col=3} TypeRef=id:0:0
+// CHECK: {start_line=48 start_col=4 end_line=48 end_col=5} VarDecl=d:48:13 (Definition)
// CHECK: {start_line=48 start_col=6 end_line=48 end_col=10} ObjCProtocolRef=Proto:23:1
-// CHECK: {start_line=48 start_col=11 end_line=48 end_col=11} VarDecl=d:48:13 (Definition)
-// CHECK: {start_line=48 start_col=12 end_line=48 end_col=12} UnexposedStmt=main
-// CHECK: {start_line=48 start_col=13 end_line=48 end_col=13} VarDecl=d:48:13 (Definition)
+// CHECK: {start_line=48 start_col=11 end_line=48 end_col=13} VarDecl=d:48:13 (Definition)
// CHECK: {start_line=48 start_col=14 end_line=48 end_col=14} UnexposedStmt=main
// CHECK: {start_line=48 start_col=15 end_line=49 end_col=1} UnexposedStmt=main
// CHECK: {start_line=49 start_col=2 end_line=49 end_col=2} DeclRefExpr=d:48:13
@@ -163,4 +151,3 @@ int main (int argc, const char * argv[]) {
// CHECK: {start_line=52 start_col=33 end_line=52 end_col=35} DeclRefExpr=bee:45:8
// CHECK: {start_line=52 start_col=36 end_line=52 end_col=36} CallExpr=main:44:5
// CHECK: {start_line=52 start_col=37 end_line=53 end_col=1} UnexposedStmt=main
-
diff --git a/test/Index/find-decls.c b/test/Index/find-decls.c
deleted file mode 100644
index f1999b2151..0000000000
--- a/test/Index/find-decls.c
+++ /dev/null
@@ -1,25 +0,0 @@
-// RUN: %clang_cc1 -fblocks -emit-pch %S/Inputs/t1.c -o %t1.ast
-// RUN: %clang_cc1 -fblocks -emit-pch %S/Inputs/t2.c -o %t2.ast
-
-// RUN: index-test %t1.ast %t2.ast -point-at %S/Inputs/t1.c:8:7 -print-decls > %t
-// RUN: cat %t | count 3
-// RUN: grep 'foo.h:4:6,' %t | count 2
-// RUN: grep 't2.c:5:6,' %t
-
-// RUN: index-test %t1.ast %t2.ast -point-at %S/Inputs/t1.c:5:47 -print-decls > %t
-// RUN: cat %t | count 1
-// RUN: grep 't1.c:5:12,' %t
-
-// RUN: index-test %t1.ast %t2.ast -point-at %S/Inputs/t1.c:6:20 -print-decls > %t
-// RUN: cat %t | count 1
-// RUN: grep 't1.c:3:19,' %t
-
-// field test
-
-// RUN: index-test %t1.ast %t2.ast -point-at %S/Inputs/t1.c:21:6 -print-decls > %t
-// RUN: cat %t | count 1
-// RUN: grep 't1.c:12:7,' %t
-
-// RUN: index-test %t1.ast %t2.ast -point-at %S/Inputs/t1.c:22:21 -print-decls > %t
-// RUN: cat %t | count 1
-// RUN: grep 't1.c:16:7,' %t
diff --git a/test/Index/find-defs.c b/test/Index/find-defs.c
deleted file mode 100644
index 51292704a1..0000000000
--- a/test/Index/find-defs.c
+++ /dev/null
@@ -1,18 +0,0 @@
-// RUN: %clang_cc1 -fblocks -emit-pch %S/Inputs/t1.c -o %t1.ast
-// RUN: %clang_cc1 -fblocks -emit-pch %S/Inputs/t2.c -o %t2.ast
-
-// RUN: index-test %t1.ast %t2.ast -point-at %S/Inputs/foo.h:1:14 -print-defs > %t
-// RUN: cat %t | count 1
-// RUN: grep 't2.c:3:5,' %t
-
-// RUN: index-test %t1.ast %t2.ast -point-at %S/Inputs/foo.h:3:9 -print-defs > %t
-// RUN: cat %t | count 1
-// RUN: grep 't1.c:3:6,' %t
-
-// RUN: index-test %t1.ast %t2.ast -point-at %S/Inputs/foo.h:4:9 -print-defs > %t
-// RUN: cat %t | count 1
-// RUN: grep 't2.c:5:6,' %t
-
-// RUN: index-test %t1.ast %t2.ast -point-at %S/Inputs/t1.c:8:7 -print-defs > %t
-// RUN: cat %t | count 1
-// RUN: grep 't2.c:5:6,' %t
diff --git a/tools/CIndex/CIndex.cpp b/tools/CIndex/CIndex.cpp
index e84d15ceae..3447553ae3 100644
--- a/tools/CIndex/CIndex.cpp
+++ b/tools/CIndex/CIndex.cpp
@@ -19,6 +19,7 @@
#include "clang/AST/StmtVisitor.h"
#include "clang/AST/TypeLocVisitor.h"
#include "clang/Lex/Lexer.h"
+#include "clang/Lex/Preprocessor.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/System/Program.h"
@@ -133,9 +134,40 @@ static CXSourceRange translateSourceRange(ASTContext &Context, SourceRange R) {
return Result;
}
+static SourceRange translateSourceRange(CXSourceRange R) {
+ return SourceRange(SourceLocation::getFromRawEncoding(R.begin_int_data),
+ SourceLocation::getFromRawEncoding(R.end_int_data));
+}
+
+/// \brief The result of comparing two source ranges.
+enum RangeComparisonResult {
+ /// \brief Either the ranges overlap or one of the ranges is invalid.
+ RangeOverlap,
+
+ /// \brief The first range ends before the second range starts.
+ RangeBefore,
+
+ /// \brief The first range starts after the second range ends.
+ RangeAfter
+};
+
+/// \brief Compare two source ranges to determine their relative position in
+/// the translation unit.
+static RangeComparisonResult RangeCompare(SourceManager &SM,
+ SourceRange R1,
+ SourceRange R2) {
+ assert(R1.isValid() && "First range is invalid?");
+ assert(R2.isValid() && "Second range is invalid?");
+ if (SM.isBeforeInTranslationUnit(R1.getEnd(), R2.getBegin()))
+ return RangeBefore;
+ if (SM.isBeforeInTranslationUnit(R2.getEnd(), R1.getBegin()))
+ return RangeAfter;
+ return RangeOverlap;
+}
+
//===----------------------------------------------------------------------===//
-// Visitors.
+// Cursor visitor.
//===----------------------------------------------------------------------===//
namespace {
@@ -145,25 +177,53 @@ class CursorVisitor : public DeclVisitor<CursorVisitor, bool>,
public TypeLocVisitor<CursorVisitor, bool>,
public StmtVisitor<CursorVisitor, bool>
{
+ /// \brief The translation unit we are traversing.
ASTUnit *TU;
+
+ /// \brief The parent cursor whose children we are traversing.
CXCursor Parent;
+
+ /// \brief The declaration that serves at the parent of any statement or
+ /// expression nodes.
Decl *StmtParent;
+
+ /// \brief The visitor function.
CXCursorVisitor Visitor;
+
+ /// \brief The opaque client data, to be passed along to the visitor.
CXClientData ClientData;
-
+
// MaxPCHLevel - the maximum PCH level of declarations that we will pass on
// to the visitor. Declarations with a PCH level greater than this value will
// be suppressed.
unsigned MaxPCHLevel;
-
+
+ /// \brief When valid, a source range to which the cursor should restrict
+ /// its search.
+ SourceRange RegionOfInterest;
+