Do not emit an include in the indexer if we failed to resolve the file. Also add -resource-dir to tests.

This commit is contained in:
Jacob Dufault 2017-12-15 21:24:31 -08:00
parent d23de3a9fb
commit c0c3fc41a4
8 changed files with 16 additions and 22 deletions

View File

@ -518,7 +518,8 @@ CXIdxClientFile OnIndexIncludedFile(CXClientData client_data,
IndexInclude include; IndexInclude include;
include.line = line; include.line = line;
include.resolved_path = FileName(file->file); include.resolved_path = FileName(file->file);
db->includes.push_back(include); if (!include.resolved_path.empty())
db->includes.push_back(include);
return nullptr; return nullptr;
} }

View File

@ -120,7 +120,7 @@ void RunIndexTests() {
float memory_after = -1.; float memory_after = -1.;
{ {
// if (path != "tests/constructors/make_functions.cc") continue; // if (path != "tests/stl.cc") continue;
Config config; Config config;
FileConsumer::SharedState file_consumer_shared; FileConsumer::SharedState file_consumer_shared;
@ -129,7 +129,9 @@ void RunIndexTests() {
// std::cout << "[START] " << path << std::endl; // std::cout << "[START] " << path << std::endl;
PerformanceImportFile perf; PerformanceImportFile perf;
std::vector<std::unique_ptr<IndexFile>> dbs = std::vector<std::unique_ptr<IndexFile>> dbs =
Parse(&config, &file_consumer_shared, path, {"-xc++", "-std=c++11"}, Parse(&config, &file_consumer_shared, path,
{"-xc++", "-std=c++11",
"-resource-dir=" + GetDefaultResourceDirectory()},
{}, &perf, &index, false /*dump_ast*/); {}, &perf, &index, false /*dump_ast*/);
// Parse expected output from the test, parse it into JSON document. // Parse expected output from the test, parse it into JSON document.

View File

@ -81,7 +81,7 @@ OUTPUT:
"short_name": "y", "short_name": "y",
"detailed_name": "int y", "detailed_name": "int y",
"definition_spelling": "4:31-4:32", "definition_spelling": "4:31-4:32",
"definition_extent": "4:31-4:32", "definition_extent": "4:27-4:32",
"is_local": false, "is_local": false,
"is_macro": false, "is_macro": false,
"uses": ["4:31-4:32", "6:7-6:8"] "uses": ["4:31-4:32", "6:7-6:8"]

View File

@ -63,7 +63,7 @@ OUTPUT:
"id": 1, "id": 1,
"usr": "c:complex.cc@8@macro@FOO", "usr": "c:complex.cc@8@macro@FOO",
"short_name": "FOO", "short_name": "FOO",
"detailed_name": "FOO", "detailed_name": "#define FOO(aaa, bbb)\n int a();\n int a() { return aaa + bbb; }",
"definition_spelling": "1:9-1:12", "definition_spelling": "1:9-1:12",
"definition_extent": "1:9-3:32", "definition_extent": "1:9-3:32",
"is_local": false, "is_local": false,

View File

@ -56,7 +56,7 @@ OUTPUT:
"id": 1, "id": 1,
"usr": "c:foo.cc@8@macro@A", "usr": "c:foo.cc@8@macro@A",
"short_name": "A", "short_name": "A",
"detailed_name": "A", "detailed_name": "#define A 5",
"definition_spelling": "1:9-1:10", "definition_spelling": "1:9-1:10",
"definition_extent": "1:9-1:12", "definition_extent": "1:9-1:12",
"is_local": false, "is_local": false,
@ -66,7 +66,7 @@ OUTPUT:
"id": 2, "id": 2,
"usr": "c:foo.cc@21@macro@DISALLOW", "usr": "c:foo.cc@21@macro@DISALLOW",
"short_name": "DISALLOW", "short_name": "DISALLOW",
"detailed_name": "DISALLOW", "detailed_name": "#define DISALLOW(type) type(type&&) = delete;",
"definition_spelling": "2:9-2:17", "definition_spelling": "2:9-2:17",
"definition_extent": "2:9-2:46", "definition_extent": "2:9-2:46",
"is_local": false, "is_local": false,

View File

@ -14,7 +14,7 @@ OUTPUT:
"id": 0, "id": 0,
"usr": "c:include_guard.cc@21@macro@FOO", "usr": "c:include_guard.cc@21@macro@FOO",
"short_name": "FOO", "short_name": "FOO",
"detailed_name": "FOO", "detailed_name": "#define FOO",
"definition_spelling": "2:9-2:12", "definition_spelling": "2:9-2:12",
"definition_extent": "2:9-2:12", "definition_extent": "2:9-2:12",
"is_local": false, "is_local": false,

View File

@ -176,13 +176,13 @@ OUTPUT:
"resolved_path": "&signal.h" "resolved_path": "&signal.h"
}, { }, {
"line": 14, "line": 14,
"resolved_path": "&" "resolved_path": "&stdalign.h"
}, { }, {
"line": 15, "line": 15,
"resolved_path": "&stdarg.h" "resolved_path": "&stdarg.h"
}, { }, {
"line": 16, "line": 16,
"resolved_path": "&" "resolved_path": "&stdatomic.h"
}, { }, {
"line": 17, "line": 17,
"resolved_path": "&stdbool.h" "resolved_path": "&stdbool.h"
@ -200,16 +200,13 @@ OUTPUT:
"resolved_path": "&stdlib.h" "resolved_path": "&stdlib.h"
}, { }, {
"line": 22, "line": 22,
"resolved_path": "&" "resolved_path": "&stdnoreturn.h"
}, { }, {
"line": 23, "line": 23,
"resolved_path": "&string.h" "resolved_path": "&string.h"
}, { }, {
"line": 24, "line": 24,
"resolved_path": "&" "resolved_path": "&tgmath.h"
}, {
"line": 25,
"resolved_path": "&"
}, { }, {
"line": 26, "line": 26,
"resolved_path": "&time.h" "resolved_path": "&time.h"
@ -345,9 +342,6 @@ OUTPUT:
}, { }, {
"line": 72, "line": 72,
"resolved_path": "&scoped_allocator" "resolved_path": "&scoped_allocator"
}, {
"line": 73,
"resolved_path": "&"
}, { }, {
"line": 74, "line": 74,
"resolved_path": "&climits" "resolved_path": "&climits"
@ -435,9 +429,6 @@ OUTPUT:
}, { }, {
"line": 102, "line": 102,
"resolved_path": "&algorithm" "resolved_path": "&algorithm"
}, {
"line": 103,
"resolved_path": "&"
}, { }, {
"line": 104, "line": 104,
"resolved_path": "&iterator" "resolved_path": "&iterator"

View File

@ -46,7 +46,7 @@ OUTPUT:
"id": 0, "id": 0,
"usr": "c:func_called_from_macro_argument.cc@8@macro@MACRO_CALL", "usr": "c:func_called_from_macro_argument.cc@8@macro@MACRO_CALL",
"short_name": "MACRO_CALL", "short_name": "MACRO_CALL",
"detailed_name": "MACRO_CALL", "detailed_name": "#define MACRO_CALL(e) e",
"definition_spelling": "1:9-1:19", "definition_spelling": "1:9-1:19",
"definition_extent": "1:9-1:24", "definition_extent": "1:9-1:24",
"is_local": false, "is_local": false,