From: Argyrios Kyrtzidis Date: Wed, 9 Nov 2016 23:58:39 +0000 (+0000) Subject: [libclang] Fix issue with clang_tokenize and make sure it interprets CXSourceRange... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3b61b92e0fdf5093a247270ef1265c85697de3f9;p=clang [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 --- diff --git a/test/Index/annotate-tokens.c b/test/Index/annotate-tokens.c index c72e4f725f..08e7a9a02f 100644 --- a/test/Index/annotate-tokens.c +++ b/test/Index/annotate-tokens.c @@ -239,3 +239,7 @@ void test() { // CHECK-RANGE2: Identifier: "reg" [68:3 - 68:6] DeclRefExpr=reg:67:7 // CHECK-RANGE2: Punctuation: "." [68:6 - 68:7] MemberRefExpr=field:62:9 // CHECK-RANGE2: Identifier: "field" [68:7 - 68:12] MemberRefExpr=field:62:9 + +// RUN: c-index-test -test-annotate-tokens=%s:68:15:68:16 %s | FileCheck %s -check-prefix=CHECK-RANGE3 +// CHECK-RANGE3: Literal: "1" [68:15 - 68:16] IntegerLiteral= +// CHECK-RANGE3-NOT: Punctuation: ";" diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp index 17fe88b631..98a6e70fd6 100644 --- a/tools/libclang/CIndex.cpp +++ b/tools/libclang/CIndex.cpp @@ -6156,7 +6156,7 @@ static void getTokens(ASTUnit *CXXUnit, SourceRange Range, } CXTokens.push_back(CXTok); previousWasAt = Tok.is(tok::at); - } while (Lex.getBufferLocation() <= EffectiveBufferEnd); + } while (Lex.getBufferLocation() < EffectiveBufferEnd); } void clang_tokenize(CXTranslationUnit TU, CXSourceRange Range,