From 122eda1c53edf49cf2dbf912b127796d86603800 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Wed, 25 Jul 2018 10:36:30 -0700 Subject: [PATCH] Improve comment and outline --- index_tests/macros/complex.cc | 2 +- index_tests/macros/foo.cc | 2 +- index_tests/multi_file/funky_enum.h | 2 +- src/indexer.cc | 13 ++++++++++--- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/index_tests/macros/complex.cc b/index_tests/macros/complex.cc index 1b17ea8e5..a74be500b 100644 --- a/index_tests/macros/complex.cc +++ b/index_tests/macros/complex.cc @@ -25,7 +25,7 @@ FOO(make1(), make2); "storage": 0, "declarations": ["12:1-12:20|0|1|1"], "spell": "12:1-12:20|0|1|2", - "extent": "1:1-1:1|0|1|0", + "extent": "12:1-12:20|0|1|0", "bases": [], "derived": [], "vars": [], diff --git a/index_tests/macros/foo.cc b/index_tests/macros/foo.cc index c2086d470..9c034cd2f 100644 --- a/index_tests/macros/foo.cc +++ b/index_tests/macros/foo.cc @@ -21,7 +21,7 @@ int x = A; "storage": 0, "declarations": [], "spell": "5:12-5:15|15041163540773201510|2|1026", - "extent": "1:1-1:1|15041163540773201510|2|0", + "extent": "5:12-5:15|15041163540773201510|2|0", "bases": [], "derived": [], "vars": [], diff --git a/index_tests/multi_file/funky_enum.h b/index_tests/multi_file/funky_enum.h index b11cc4419..1acdf0566 100644 --- a/index_tests/multi_file/funky_enum.h +++ b/index_tests/multi_file/funky_enum.h @@ -3,4 +3,4 @@ A, B, -C \ No newline at end of file +C diff --git a/src/indexer.cc b/src/indexer.cc index f4398f6fd..1325cf6ff 100644 --- a/src/indexer.cc +++ b/src/indexer.cc @@ -338,7 +338,10 @@ class IndexDataConsumer : public index::IndexDataConsumer { p++; if (p < E && *p == ' ') p++; - pad = int(p - begin); + if (p + 1 == q) + p++; + else + pad = int(p - begin); } else { // Other lines, skip |pad| bytes int prefix = pad; @@ -614,9 +617,13 @@ class IndexDataConsumer : public index::IndexDataConsumer { auto do_def_decl = [&](auto *entity) { if (is_def) { entity->def.spell = GetUse(db, loc, SemDC, role); + SourceRange R = OrigD->getSourceRange(); entity->def.extent = - GetUse(db, FromTokenRange(SM, Lang, OrigD->getSourceRange()), LexDC, - Role::None); + GetUse(db, + R.getBegin().isFileID() + ? FromTokenRange(SM, Lang, OrigD->getSourceRange()) + : loc, + LexDC, Role::None); } else if (is_decl) { entity->declarations.push_back(GetUse(db, loc, LexDC, role)); } else {