]> granicus.if.org Git - clang/commitdiff
[libclang] Fix issue with clang_tokenize and make sure it interprets CXSourceRange...
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Wed, 9 Nov 2016 23:58:39 +0000 (23:58 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Wed, 9 Nov 2016 23:58:39 +0000 (23:58 +0000)
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

test/Index/annotate-tokens.c
tools/libclang/CIndex.cpp

index c72e4f725fcce9b614f4b7b493eb1b756f8e1e3d..08e7a9a02f8f2471faf6b0fa26a74ad9f7a2a0ea 100644 (file)
@@ -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: ";"
index 17fe88b631b67274fe97d9ce92ca3d2a621f48a5..98a6e70fd6c09b8abdff6c213f274c14d96c6c2a 100644 (file)
@@ -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,