summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2016-11-09 23:58:39 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2016-11-09 23:58:39 +0000
commitc7c6a07548172399844e85f0dfb5476525fd07ff (patch)
treecafb0d0521d416d92f068d6e90db71a531340ceb /clang
parent32ab3a817d4d8ae20e868e8966ceef1511a88d03 (diff)
downloadbcm5719-llvm-c7c6a07548172399844e85f0dfb5476525fd07ff.tar.gz
bcm5719-llvm-c7c6a07548172399844e85f0dfb5476525fd07ff.zip
[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) llvm-svn: 286421
Diffstat (limited to 'clang')
-rw-r--r--clang/test/Index/annotate-tokens.c4
-rw-r--r--clang/tools/libclang/CIndex.cpp2
2 files changed, 5 insertions, 1 deletions
diff --git a/clang/test/Index/annotate-tokens.c b/clang/test/Index/annotate-tokens.c
index c72e4f725fc..08e7a9a02f8 100644
--- a/clang/test/Index/annotate-tokens.c
+++ b/clang/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/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp
index 17fe88b631b..98a6e70fd6c 100644
--- a/clang/tools/libclang/CIndex.cpp
+++ b/clang/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,
OpenPOWER on IntegriCloud