Skip to content
This repository was archived by the owner on Apr 23, 2020. It is now read-only.

Commit 3b61b92

Browse files
committed
[libclang] Fix issue with clang_tokenize and make sure it interprets CXSourceRange as half-open character range.
Patch provided by Emilio Cobos Álvarez! (https://reviews.llvm.org/D26446) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@286421 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 3b3f2f6 commit 3b61b92

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

test/Index/annotate-tokens.c

+4
Original file line numberDiff line numberDiff line change
@@ -239,3 +239,7 @@ void test() {
239239
// CHECK-RANGE2: Identifier: "reg" [68:3 - 68:6] DeclRefExpr=reg:67:7
240240
// CHECK-RANGE2: Punctuation: "." [68:6 - 68:7] MemberRefExpr=field:62:9
241241
// CHECK-RANGE2: Identifier: "field" [68:7 - 68:12] MemberRefExpr=field:62:9
242+
243+
// RUN: c-index-test -test-annotate-tokens=%s:68:15:68:16 %s | FileCheck %s -check-prefix=CHECK-RANGE3
244+
// CHECK-RANGE3: Literal: "1" [68:15 - 68:16] IntegerLiteral=
245+
// CHECK-RANGE3-NOT: Punctuation: ";"

tools/libclang/CIndex.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -6156,7 +6156,7 @@ static void getTokens(ASTUnit *CXXUnit, SourceRange Range,
61566156
}
61576157
CXTokens.push_back(CXTok);
61586158
previousWasAt = Tok.is(tok::at);
6159-
} while (Lex.getBufferLocation() <= EffectiveBufferEnd);
6159+
} while (Lex.getBufferLocation() < EffectiveBufferEnd);
61606160
}
61616161

61626162
void clang_tokenize(CXTranslationUnit TU, CXSourceRange Range,

0 commit comments

Comments
 (0)