From ce33cc86d44e11e0295bfcbdfab107cd63b864a2 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Sat, 31 Mar 2018 09:25:58 -0700 Subject: [PATCH] . --- index_tests/constructors/constructor.cc | 4 +- index_tests/constructors/destructor.cc | 2 +- .../constructors/implicit_constructor.cc | 4 +- index_tests/constructors/make_functions.cc | 12 +- .../func_associated_function_params.cc | 4 +- .../class_inherit_templated_parent.cc | 4 +- index_tests/lambdas/lambda.cc | 10 +- index_tests/macros/foo.cc | 2 +- index_tests/namespaces/namespace_alias.cc | 4 +- index_tests/namespaces/namespace_reference.cc | 2 +- .../outline/static_function_in_type.cc | 2 +- index_tests/preprocessor/include_guard.cc | 2 +- .../implicit_variable_instantiation.cc | 2 +- index_tests/templates/specialization.cc | 10 +- .../template_var_usage_folded_into_one.cc | 2 +- index_tests/usage/func_usage_addr_func.cc | 2 +- index_tests/usage/func_usage_addr_method.cc | 2 +- index_tests/usage/func_usage_call_method.cc | 2 +- .../usage/func_usage_forward_decl_method.cc | 2 +- .../usage/type_usage_as_template_parameter.cc | 2 +- ...ype_usage_as_template_parameter_complex.cc | 2 +- index_tests/usage/type_usage_declare_local.cc | 4 +- index_tests/usage/type_usage_declare_param.cc | 4 +- .../type_usage_declare_param_prototype.cc | 2 +- .../usage/type_usage_declare_qualifiers.cc | 12 +- index_tests/usage/type_usage_various.cc | 2 +- index_tests/usage/usage_inside_of_call.cc | 2 +- index_tests/usage/var_usage_call_function.cc | 2 +- index_tests/usage/var_usage_class_member.cc | 2 +- index_tests/usage/var_usage_local.cc | 2 +- index_tests/usage/var_usage_shadowed_local.cc | 4 +- .../usage/var_usage_shadowed_parameter.cc | 2 +- index_tests/vars/deduce_auto_type.cc | 4 +- index_tests/vars/function_local.cc | 2 +- index_tests/vars/function_param.cc | 4 +- index_tests/vars/function_shadow_local.cc | 4 +- index_tests/vars/function_shadow_param.cc | 2 +- .../vars/type_instance_on_using_type.cc | 2 +- src/clang_indexer.cc | 25 +- src/indexer.h | 4 +- src/message_handler.cc | 4 - src/message_handler.h | 2 - src/messages/text_document_did_open.cc | 2 - src/messages/text_document_did_save.cc | 2 - src/project.cc | 734 +----------------- src/test.cc | 3 +- src/type_printer.cc | 10 +- src/utils.cc | 34 - 48 files changed, 96 insertions(+), 858 deletions(-) diff --git a/index_tests/constructors/constructor.cc b/index_tests/constructors/constructor.cc index 82c7469f..e779b786 100644 --- a/index_tests/constructors/constructor.cc +++ b/index_tests/constructors/constructor.cc @@ -64,7 +64,7 @@ OUTPUT: }], "vars": [{ "id": 0, - "usr": 18410644574635149442, + "usr": 10983126130596230582, "detailed_name": "Foo f", "short_name": "f", "declarations": [], @@ -76,7 +76,7 @@ OUTPUT: "storage": 1 }, { "id": 1, - "usr": 11468802633764653592, + "usr": 17165811951126099095, "detailed_name": "Foo *f2", "short_name": "f2", "hover": "Foo *f2 = new Foo()", diff --git a/index_tests/constructors/destructor.cc b/index_tests/constructors/destructor.cc index acfa71a3..12482769 100644 --- a/index_tests/constructors/destructor.cc +++ b/index_tests/constructors/destructor.cc @@ -85,7 +85,7 @@ OUTPUT: }], "vars": [{ "id": 0, - "usr": 9954632887635271906, + "usr": 1893354193220338759, "detailed_name": "Foo f", "short_name": "f", "declarations": [], diff --git a/index_tests/constructors/implicit_constructor.cc b/index_tests/constructors/implicit_constructor.cc index fd696780..30589861 100644 --- a/index_tests/constructors/implicit_constructor.cc +++ b/index_tests/constructors/implicit_constructor.cc @@ -63,7 +63,7 @@ OUTPUT: }], "vars": [{ "id": 0, - "usr": 17348451315735351657, + "usr": 449111627548814328, "detailed_name": "Type foo0", "short_name": "foo0", "declarations": [], @@ -75,7 +75,7 @@ OUTPUT: "storage": 1 }, { "id": 1, - "usr": 3757978174345638825, + "usr": 17097499197730163115, "detailed_name": "Type foo1", "short_name": "foo1", "declarations": [], diff --git a/index_tests/constructors/make_functions.cc b/index_tests/constructors/make_functions.cc index f044001a..ab2d2cd5 100644 --- a/index_tests/constructors/make_functions.cc +++ b/index_tests/constructors/make_functions.cc @@ -137,7 +137,7 @@ OUTPUT: make_functions.cc "skipped_by_preprocessor": [], "types": [{ "id": 0, - "usr": 7902098450755788854, + "usr": 9281343527065946499, "detailed_name": "T", "short_name": "T", "kind": 26, @@ -153,7 +153,7 @@ OUTPUT: make_functions.cc "uses": ["4:1-4:2|-1|1|4"] }, { "id": 1, - "usr": 12533159752419999454, + "usr": 10771590811355716928, "detailed_name": "Args", "short_name": "Args", "kind": 26, @@ -169,7 +169,7 @@ OUTPUT: make_functions.cc "uses": ["4:15-4:19|-1|1|4"] }, { "id": 2, - "usr": 18441628706991062891, + "usr": 11897454629873246477, "detailed_name": "T", "short_name": "T", "kind": 26, @@ -185,7 +185,7 @@ OUTPUT: make_functions.cc "uses": ["9:1-9:2|-1|1|4"] }, { "id": 3, - "usr": 9441341235704820385, + "usr": 3337128087216004141, "detailed_name": "Args", "short_name": "Args", "kind": 26, @@ -328,7 +328,7 @@ OUTPUT: make_functions.cc }], "vars": [{ "id": 0, - "usr": 15288691366352169805, + "usr": 8463700030555379526, "detailed_name": "Args &&... args", "short_name": "args", "declarations": [], @@ -339,7 +339,7 @@ OUTPUT: make_functions.cc "storage": 1 }, { "id": 1, - "usr": 12338908251430965107, + "usr": 3908732770590594660, "detailed_name": "Args... args", "short_name": "args", "declarations": [], diff --git a/index_tests/declaration_vs_definition/func_associated_function_params.cc b/index_tests/declaration_vs_definition/func_associated_function_params.cc index f917921e..e3aba26f 100644 --- a/index_tests/declaration_vs_definition/func_associated_function_params.cc +++ b/index_tests/declaration_vs_definition/func_associated_function_params.cc @@ -51,7 +51,7 @@ OUTPUT: }], "vars": [{ "id": 0, - "usr": 10480417713467708012, + "usr": 14555488990109936920, "detailed_name": "int a", "short_name": "a", "declarations": [], @@ -63,7 +63,7 @@ OUTPUT: "storage": 1 }, { "id": 1, - "usr": 18099600680625658464, + "usr": 10963664335057337329, "detailed_name": "int b", "short_name": "b", "declarations": [], diff --git a/index_tests/inheritance/class_inherit_templated_parent.cc b/index_tests/inheritance/class_inherit_templated_parent.cc index 1b1bda9d..bc12cca6 100644 --- a/index_tests/inheritance/class_inherit_templated_parent.cc +++ b/index_tests/inheritance/class_inherit_templated_parent.cc @@ -97,7 +97,7 @@ OUTPUT: "uses": ["13:56-13:64|-1|1|4"] }, { "id": 5, - "usr": 780719166805015998, + "usr": 7916588271848318236, "detailed_name": "T", "short_name": "T", "kind": 26, @@ -131,7 +131,7 @@ OUTPUT: "funcs": [], "vars": [{ "id": 0, - "usr": 3880651725784125791, + "usr": 12990052348105569112, "detailed_name": "unsigned int T", "short_name": "T", "declarations": [], diff --git a/index_tests/lambdas/lambda.cc b/index_tests/lambdas/lambda.cc index 2bc4d60f..e670cc62 100644 --- a/index_tests/lambdas/lambda.cc +++ b/index_tests/lambdas/lambda.cc @@ -32,7 +32,7 @@ OUTPUT: "uses": [] }, { "id": 1, - "usr": 1287417953265234030, + "usr": 14635009347499519042, "detailed_name": "", "short_name": "", "kind": 0, @@ -62,7 +62,7 @@ OUTPUT: "callees": ["9:14-9:15|1|3|32", "10:14-10:15|1|3|32", "11:14-11:15|1|3|32"] }, { "id": 1, - "usr": 1328781044864682611, + "usr": 17926497908620168464, "detailed_name": "", "short_name": "", "kind": 0, @@ -76,7 +76,7 @@ OUTPUT: }], "vars": [{ "id": 0, - "usr": 17270098654620601683, + "usr": 12666114896600231317, "detailed_name": "int x", "short_name": "x", "declarations": [], @@ -88,7 +88,7 @@ OUTPUT: "storage": 1 }, { "id": 1, - "usr": 16806544259835773270, + "usr": 2981279427664991319, "detailed_name": "lambda dosomething", "short_name": "dosomething", "declarations": [], @@ -100,7 +100,7 @@ OUTPUT: "storage": 1 }, { "id": 2, - "usr": 2034725908368218782, + "usr": 12879188959314906706, "detailed_name": "int y", "short_name": "y", "declarations": [], diff --git a/index_tests/macros/foo.cc b/index_tests/macros/foo.cc index 6dbe1466..88803443 100644 --- a/index_tests/macros/foo.cc +++ b/index_tests/macros/foo.cc @@ -87,7 +87,7 @@ OUTPUT: "storage": 0 }, { "id": 2, - "usr": 14946041066794678724, + "usr": 2056319845419860263, "detailed_name": "DISALLOW", "short_name": "DISALLOW", "hover": "#define DISALLOW(type) type(type&&) = delete;", diff --git a/index_tests/namespaces/namespace_alias.cc b/index_tests/namespaces/namespace_alias.cc index 9a92b808..8fa50438 100644 --- a/index_tests/namespaces/namespace_alias.cc +++ b/index_tests/namespaces/namespace_alias.cc @@ -142,7 +142,7 @@ OUTPUT: "storage": 1 }, { "id": 1, - "usr": 107714981785063096, + "usr": 6030927277961448585, "detailed_name": "int a", "short_name": "a", "hover": "int a = foo::bar::baz::qux", @@ -155,7 +155,7 @@ OUTPUT: "storage": 1 }, { "id": 2, - "usr": 1200087780658383286, + "usr": 7657277353101371136, "detailed_name": "int b", "short_name": "b", "hover": "int b = fbz::qux", diff --git a/index_tests/namespaces/namespace_reference.cc b/index_tests/namespaces/namespace_reference.cc index 235ebaee..a8383d89 100644 --- a/index_tests/namespaces/namespace_reference.cc +++ b/index_tests/namespaces/namespace_reference.cc @@ -105,7 +105,7 @@ OUTPUT: "storage": 1 }, { "id": 1, - "usr": 7976909968919750794, + "usr": 3649375698083002347, "detailed_name": "int a", "short_name": "a", "declarations": [], diff --git a/index_tests/outline/static_function_in_type.cc b/index_tests/outline/static_function_in_type.cc index 2bcf1f76..682ca165 100644 --- a/index_tests/outline/static_function_in_type.cc +++ b/index_tests/outline/static_function_in_type.cc @@ -177,7 +177,7 @@ OUTPUT: static_function_in_type.cc }], "vars": [{ "id": 0, - "usr": 9285345059965948351, + "usr": 13569879755236306838, "detailed_name": "ns::Manager *m", "short_name": "m", "declarations": [], diff --git a/index_tests/preprocessor/include_guard.cc b/index_tests/preprocessor/include_guard.cc index 4ae27e17..764e434c 100644 --- a/index_tests/preprocessor/include_guard.cc +++ b/index_tests/preprocessor/include_guard.cc @@ -12,7 +12,7 @@ OUTPUT: "funcs": [], "vars": [{ "id": 0, - "usr": 13076155634261037336, + "usr": 11674328179498211370, "detailed_name": "FOO", "short_name": "FOO", "hover": "#define FOO", diff --git a/index_tests/templates/implicit_variable_instantiation.cc b/index_tests/templates/implicit_variable_instantiation.cc index 3301266f..b4ef6130 100644 --- a/index_tests/templates/implicit_variable_instantiation.cc +++ b/index_tests/templates/implicit_variable_instantiation.cc @@ -83,7 +83,7 @@ OUTPUT: "uses": ["10:26-10:32|-1|1|4", "13:13-13:19|-1|1|4", "14:14-14:20|-1|1|4"] }, { "id": 4, - "usr": 14511917000226829276, + "usr": 2205716167465743256, "detailed_name": "", "short_name": "", "kind": 0, diff --git a/index_tests/templates/specialization.cc b/index_tests/templates/specialization.cc index 5a545a48..2b75f557 100644 --- a/index_tests/templates/specialization.cc +++ b/index_tests/templates/specialization.cc @@ -81,7 +81,7 @@ OUTPUT: "uses": ["7:1-7:9|-1|1|4"] }, { "id": 2, - "usr": 10862637711685426953, + "usr": 9673599782548740467, "detailed_name": "T", "short_name": "T", "kind": 26, @@ -97,7 +97,7 @@ OUTPUT: "uses": ["5:16-5:17|-1|1|4"] }, { "id": 3, - "usr": 756188769017350739, + "usr": 7143192229126273961, "detailed_name": "Args", "short_name": "Args", "kind": 26, @@ -159,7 +159,7 @@ OUTPUT: "uses": ["31:1-31:7|-1|1|4"] }, { "id": 7, - "usr": 3421332160420436276, + "usr": 8880262253425334092, "detailed_name": "T", "short_name": "T", "kind": 26, @@ -239,7 +239,7 @@ OUTPUT: "uses": [] }, { "id": 12, - "usr": 2461355892344618654, + "usr": 14111105212951082474, "detailed_name": "T", "short_name": "T", "kind": 26, @@ -409,7 +409,7 @@ OUTPUT: "storage": 0 }, { "id": 7, - "usr": 10307767688451422448, + "usr": 17826688417349629938, "detailed_name": "T Value", "short_name": "Value", "declarations": [], diff --git a/index_tests/templates/template_var_usage_folded_into_one.cc b/index_tests/templates/template_var_usage_folded_into_one.cc index 8c8fed78..5d7464e9 100644 --- a/index_tests/templates/template_var_usage_folded_into_one.cc +++ b/index_tests/templates/template_var_usage_folded_into_one.cc @@ -69,7 +69,7 @@ OUTPUT: "uses": ["8:1-8:2|-1|1|4", "8:11-8:12|-1|1|4"] }, { "id": 2, - "usr": 8864163146308556810, + "usr": 11919899838872947844, "detailed_name": "", "short_name": "", "kind": 0, diff --git a/index_tests/usage/func_usage_addr_func.cc b/index_tests/usage/func_usage_addr_func.cc index 6e5d8f31..2f69d39c 100644 --- a/index_tests/usage/func_usage_addr_func.cc +++ b/index_tests/usage/func_usage_addr_func.cc @@ -61,7 +61,7 @@ OUTPUT: }], "vars": [{ "id": 0, - "usr": 13681544683892648258, + "usr": 16088407831770615719, "detailed_name": "void (*)() x", "short_name": "x", "declarations": [], diff --git a/index_tests/usage/func_usage_addr_method.cc b/index_tests/usage/func_usage_addr_method.cc index faeec595..b2d9fb46 100644 --- a/index_tests/usage/func_usage_addr_method.cc +++ b/index_tests/usage/func_usage_addr_method.cc @@ -64,7 +64,7 @@ OUTPUT: }], "vars": [{ "id": 0, - "usr": 8436636043513449412, + "usr": 4636142131003982569, "detailed_name": "void (Foo::*)() x", "short_name": "x", "declarations": [], diff --git a/index_tests/usage/func_usage_call_method.cc b/index_tests/usage/func_usage_call_method.cc index 088a737a..01ef98f9 100644 --- a/index_tests/usage/func_usage_call_method.cc +++ b/index_tests/usage/func_usage_call_method.cc @@ -64,7 +64,7 @@ OUTPUT: }], "vars": [{ "id": 0, - "usr": 3014406561587537195, + "usr": 14045150712868309451, "detailed_name": "Foo *f", "short_name": "f", "hover": "Foo *f = nullptr", diff --git a/index_tests/usage/func_usage_forward_decl_method.cc b/index_tests/usage/func_usage_forward_decl_method.cc index b34f9875..c9c988c1 100644 --- a/index_tests/usage/func_usage_forward_decl_method.cc +++ b/index_tests/usage/func_usage_forward_decl_method.cc @@ -63,7 +63,7 @@ OUTPUT: }], "vars": [{ "id": 0, - "usr": 12410753116854389823, + "usr": 16229832321010999607, "detailed_name": "Foo *f", "short_name": "f", "hover": "Foo *f = nullptr", diff --git a/index_tests/usage/type_usage_as_template_parameter.cc b/index_tests/usage/type_usage_as_template_parameter.cc index 5752413b..57b128e7 100644 --- a/index_tests/usage/type_usage_as_template_parameter.cc +++ b/index_tests/usage/type_usage_as_template_parameter.cc @@ -90,7 +90,7 @@ OUTPUT: "storage": 3 }, { "id": 2, - "usr": 2462000803278878465, + "usr": 3364438781074774169, "detailed_name": "unique_ptr *local", "short_name": "local", "declarations": [], diff --git a/index_tests/usage/type_usage_as_template_parameter_complex.cc b/index_tests/usage/type_usage_as_template_parameter_complex.cc index 50e7690d..d200b025 100644 --- a/index_tests/usage/type_usage_as_template_parameter_complex.cc +++ b/index_tests/usage/type_usage_as_template_parameter_complex.cc @@ -219,7 +219,7 @@ OUTPUT: "storage": 2 }, { "id": 1, - "usr": 11547294959889394856, + "usr": 500112618220246, "detailed_name": "unique_ptr, S2> *local", "short_name": "local", "declarations": [], diff --git a/index_tests/usage/type_usage_declare_local.cc b/index_tests/usage/type_usage_declare_local.cc index 0503fbc6..73315594 100644 --- a/index_tests/usage/type_usage_declare_local.cc +++ b/index_tests/usage/type_usage_declare_local.cc @@ -60,7 +60,7 @@ OUTPUT: }], "vars": [{ "id": 0, - "usr": 11033478034711123650, + "usr": 16374832544037266261, "detailed_name": "ForwardType *a", "short_name": "a", "declarations": [], @@ -72,7 +72,7 @@ OUTPUT: "storage": 1 }, { "id": 1, - "usr": 8949902309768550158, + "usr": 2580122838476012357, "detailed_name": "ImplementedType b", "short_name": "b", "declarations": [], diff --git a/index_tests/usage/type_usage_declare_param.cc b/index_tests/usage/type_usage_declare_param.cc index 24fd0927..b6155f87 100644 --- a/index_tests/usage/type_usage_declare_param.cc +++ b/index_tests/usage/type_usage_declare_param.cc @@ -57,7 +57,7 @@ OUTPUT: }], "vars": [{ "id": 0, - "usr": 2584795197111552890, + "usr": 13058491096576226774, "detailed_name": "ForwardType *f", "short_name": "f", "declarations": [], @@ -69,7 +69,7 @@ OUTPUT: "storage": 1 }, { "id": 1, - "usr": 5136230284979460117, + "usr": 11055777568039014776, "detailed_name": "ImplementedType a", "short_name": "a", "declarations": [], diff --git a/index_tests/usage/type_usage_declare_param_prototype.cc b/index_tests/usage/type_usage_declare_param_prototype.cc index 711054df..2cbc4522 100644 --- a/index_tests/usage/type_usage_declare_param_prototype.cc +++ b/index_tests/usage/type_usage_declare_param_prototype.cc @@ -49,7 +49,7 @@ OUTPUT: }], "vars": [{ "id": 0, - "usr": 2161866804398917919, + "usr": 13823260660189154978, "detailed_name": "Foo *f", "short_name": "f", "declarations": [], diff --git a/index_tests/usage/type_usage_declare_qualifiers.cc b/index_tests/usage/type_usage_declare_qualifiers.cc index 5c31c5e1..0219d89f 100644 --- a/index_tests/usage/type_usage_declare_qualifiers.cc +++ b/index_tests/usage/type_usage_declare_qualifiers.cc @@ -46,7 +46,7 @@ OUTPUT: }], "vars": [{ "id": 0, - "usr": 16414210592877294238, + "usr": 7997456978847868736, "detailed_name": "Type &a0", "short_name": "a0", "declarations": [], @@ -58,7 +58,7 @@ OUTPUT: "storage": 1 }, { "id": 1, - "usr": 11558141642862804306, + "usr": 17228576662112939520, "detailed_name": "const Type &a1", "short_name": "a1", "declarations": [], @@ -70,7 +70,7 @@ OUTPUT: "storage": 1 }, { "id": 2, - "usr": 1536316608590232194, + "usr": 15429032129697337561, "detailed_name": "Type a2", "short_name": "a2", "declarations": [], @@ -82,7 +82,7 @@ OUTPUT: "storage": 1 }, { "id": 3, - "usr": 316760354845869406, + "usr": 6081981442495435784, "detailed_name": "Type *a3", "short_name": "a3", "declarations": [], @@ -94,7 +94,7 @@ OUTPUT: "storage": 1 }, { "id": 4, - "usr": 12321730890779907974, + "usr": 5004072032239834773, "detailed_name": "const Type *a4", "short_name": "a4", "declarations": [], @@ -106,7 +106,7 @@ OUTPUT: "storage": 1 }, { "id": 5, - "usr": 4771437488905761633, + "usr": 14939253431683105646, "detailed_name": "const Type *const a5", "short_name": "a5", "hover": "const Type *const a5 = nullptr", diff --git a/index_tests/usage/type_usage_various.cc b/index_tests/usage/type_usage_various.cc index ba72ffad..e38d14d6 100644 --- a/index_tests/usage/type_usage_various.cc +++ b/index_tests/usage/type_usage_various.cc @@ -53,7 +53,7 @@ OUTPUT: }], "vars": [{ "id": 0, - "usr": 14873619387499024780, + "usr": 16380484338511689669, "detailed_name": "Foo f", "short_name": "f", "declarations": [], diff --git a/index_tests/usage/usage_inside_of_call.cc b/index_tests/usage/usage_inside_of_call.cc index 2bec1cb6..556bacc4 100644 --- a/index_tests/usage/usage_inside_of_call.cc +++ b/index_tests/usage/usage_inside_of_call.cc @@ -125,7 +125,7 @@ OUTPUT: "storage": 0 }, { "id": 2, - "usr": 13284113377394221067, + "usr": 8039186520399841081, "detailed_name": "int a", "short_name": "a", "hover": "int a = 5", diff --git a/index_tests/usage/var_usage_call_function.cc b/index_tests/usage/var_usage_call_function.cc index e5cbf423..de98e5fc 100644 --- a/index_tests/usage/var_usage_call_function.cc +++ b/index_tests/usage/var_usage_call_function.cc @@ -46,7 +46,7 @@ OUTPUT: }], "vars": [{ "id": 0, - "usr": 3510529098767253033, + "usr": 9121974011454213596, "detailed_name": "void (*)() x", "short_name": "x", "declarations": [], diff --git a/index_tests/usage/var_usage_class_member.cc b/index_tests/usage/var_usage_class_member.cc index 37a09761..21bbdfd9 100644 --- a/index_tests/usage/var_usage_class_member.cc +++ b/index_tests/usage/var_usage_class_member.cc @@ -127,7 +127,7 @@ OUTPUT: "storage": 0 }, { "id": 2, - "usr": 16303259148898744165, + "usr": 14669930844300034456, "detailed_name": "Foo f", "short_name": "f", "declarations": [], diff --git a/index_tests/usage/var_usage_local.cc b/index_tests/usage/var_usage_local.cc index f9c0124e..09fd489c 100644 --- a/index_tests/usage/var_usage_local.cc +++ b/index_tests/usage/var_usage_local.cc @@ -40,7 +40,7 @@ OUTPUT: }], "vars": [{ "id": 0, - "usr": 8534460107894911680, + "usr": 14014650769929566957, "detailed_name": "int x", "short_name": "x", "declarations": [], diff --git a/index_tests/usage/var_usage_shadowed_local.cc b/index_tests/usage/var_usage_shadowed_local.cc index db857206..f1767412 100644 --- a/index_tests/usage/var_usage_shadowed_local.cc +++ b/index_tests/usage/var_usage_shadowed_local.cc @@ -45,7 +45,7 @@ OUTPUT: }], "vars": [{ "id": 0, - "usr": 17941402366659878910, + "usr": 13311055950748663970, "detailed_name": "int a", "short_name": "a", "declarations": [], @@ -57,7 +57,7 @@ OUTPUT: "storage": 1 }, { "id": 1, - "usr": 11094102496276744608, + "usr": 14036425367303419504, "detailed_name": "int a", "short_name": "a", "declarations": [], diff --git a/index_tests/usage/var_usage_shadowed_parameter.cc b/index_tests/usage/var_usage_shadowed_parameter.cc index e5c784ac..591f7b1d 100644 --- a/index_tests/usage/var_usage_shadowed_parameter.cc +++ b/index_tests/usage/var_usage_shadowed_parameter.cc @@ -57,7 +57,7 @@ OUTPUT: "storage": 1 }, { "id": 1, - "usr": 8011559936501990179, + "usr": 6997229590862003559, "detailed_name": "int a", "short_name": "a", "declarations": [], diff --git a/index_tests/vars/deduce_auto_type.cc b/index_tests/vars/deduce_auto_type.cc index 42f6d581..8bd1166f 100644 --- a/index_tests/vars/deduce_auto_type.cc +++ b/index_tests/vars/deduce_auto_type.cc @@ -44,7 +44,7 @@ OUTPUT: }], "vars": [{ "id": 0, - "usr": 9275666070987716270, + "usr": 10601729374837386290, "detailed_name": "Foo *x", "short_name": "x", "declarations": [], @@ -56,7 +56,7 @@ OUTPUT: "storage": 1 }, { "id": 1, - "usr": 16202433437488621027, + "usr": 18422884837902130475, "detailed_name": "Foo *y", "short_name": "y", "declarations": [], diff --git a/index_tests/vars/function_local.cc b/index_tests/vars/function_local.cc index 6f0adec7..4c3951ca 100644 --- a/index_tests/vars/function_local.cc +++ b/index_tests/vars/function_local.cc @@ -42,7 +42,7 @@ OUTPUT: }], "vars": [{ "id": 0, - "usr": 10782632605670042066, + "usr": 13198746475679542317, "detailed_name": "Foo *a", "short_name": "a", "declarations": [], diff --git a/index_tests/vars/function_param.cc b/index_tests/vars/function_param.cc index cc61eff7..0108c73b 100644 --- a/index_tests/vars/function_param.cc +++ b/index_tests/vars/function_param.cc @@ -40,7 +40,7 @@ OUTPUT: }], "vars": [{ "id": 0, - "usr": 4580260577538694711, + "usr": 8730439006497971620, "detailed_name": "Foo *p0", "short_name": "p0", "declarations": [], @@ -52,7 +52,7 @@ OUTPUT: "storage": 1 }, { "id": 1, - "usr": 12071725611268840435, + "usr": 2525014371090380500, "detailed_name": "Foo *p1", "short_name": "p1", "declarations": [], diff --git a/index_tests/vars/function_shadow_local.cc b/index_tests/vars/function_shadow_local.cc index 0c4fa4a1..1d16f481 100644 --- a/index_tests/vars/function_shadow_local.cc +++ b/index_tests/vars/function_shadow_local.cc @@ -45,7 +45,7 @@ OUTPUT: }], "vars": [{ "id": 0, - "usr": 3440226937504376525, + "usr": 1894874819807168345, "detailed_name": "int a", "short_name": "a", "declarations": [], @@ -57,7 +57,7 @@ OUTPUT: "storage": 1 }, { "id": 1, - "usr": 14700715011944976607, + "usr": 4508045017817092115, "detailed_name": "int a", "short_name": "a", "declarations": [], diff --git a/index_tests/vars/function_shadow_param.cc b/index_tests/vars/function_shadow_param.cc index 5f8a9988..ee7b225e 100644 --- a/index_tests/vars/function_shadow_param.cc +++ b/index_tests/vars/function_shadow_param.cc @@ -51,7 +51,7 @@ OUTPUT: "storage": 1 }, { "id": 1, - "usr": 2147918703972955240, + "usr": 11404600766177939811, "detailed_name": "int p", "short_name": "p", "hover": "int p = 0", diff --git a/index_tests/vars/type_instance_on_using_type.cc b/index_tests/vars/type_instance_on_using_type.cc index 7d01422b..1101a983 100644 --- a/index_tests/vars/type_instance_on_using_type.cc +++ b/index_tests/vars/type_instance_on_using_type.cc @@ -64,7 +64,7 @@ OUTPUT: }], "vars": [{ "id": 0, - "usr": 7730100248624586522, + "usr": 6975456769752895964, "detailed_name": "F a", "short_name": "a", "declarations": [], diff --git a/src/clang_indexer.cc b/src/clang_indexer.cc index 4ff2c86d..2032056b 100644 --- a/src/clang_indexer.cc +++ b/src/clang_indexer.cc @@ -525,11 +525,8 @@ void SetTypeName(IndexType* type, // Investigate why clang_getCursorPrettyPrinted gives `struct A {}` `namespace // ns {}` which are not qualified. // type->def.detailed_name = param->PrettyPrintCursor(cursor.cx_cursor); - type->def.detailed_name = + std::tie(type->def.detailed_name, type->def.short_name_offset) = param->ns.QualifiedName(container ? container : &parent, name); - auto idx = type->def.detailed_name.rfind(name); - assert(idx != std::string::npos); - type->def.short_name_offset = idx; type->def.short_name_size = strlen(name); } @@ -599,7 +596,7 @@ void SetVarDetail(IndexVar* var, ? param->PrettyPrintCursor(cursor.cx_cursor) : #endif - param->ns.QualifiedName(semanticContainer, short_name); + param->ns.QualifiedName(semanticContainer, short_name).first; if (cursor.get_kind() == CXCursor_EnumConstantDecl && semanticContainer) { CXType enum_type = clang_getCanonicalType( @@ -782,12 +779,6 @@ void Uniquify(std::vector& uses) { uses.resize(n); } -// FIXME Reference: set id in call sites and remove this -// void AddUse(std::vector& values, Range value) { -// values.push_back( -// Use(value, Id(), SymbolKind::File, Role::Reference, {})); -//} - void AddUse(IndexFile* db, std::vector& uses, Range range, @@ -1422,10 +1413,11 @@ ClangCursor::VisitResult TemplateVisitor(ClangCursor cursor, } // namespace -std::string NamespaceHelper::QualifiedName(const CXIdxContainerInfo* container, - std::string_view unqualified_name) { +std::pair NamespaceHelper::QualifiedName( + const CXIdxContainerInfo* container, + std::string_view unqualified_name) { if (!container) - return std::string(unqualified_name); + return {std::string(unqualified_name), 0}; // Anonymous namespaces are not processed by indexDeclaration. We trace // nested namespaces bottom-up through clang_getCursorSemanticParent until // one that we know its qualified name. Then do another trace top-down and @@ -1455,8 +1447,9 @@ std::string NamespaceHelper::QualifiedName(const CXIdxContainerInfo* container, qualifier += "::"; container_cursor_to_qualified_name[namespaces[i]] = qualifier; } - // C++17 string::append - return qualifier + std::string(unqualified_name); + int pos = qualifier.size(); + qualifier.append(unqualified_name); + return {qualifier, pos}; } void OnIndexDeclaration(CXClientData client_data, const CXIdxDeclInfo* decl) { diff --git a/src/indexer.h b/src/indexer.h index 24db98c4..e52ddb3d 100644 --- a/src/indexer.h +++ b/src/indexer.h @@ -509,8 +509,8 @@ struct NamespaceHelper { std::unordered_map container_cursor_to_qualified_name; - std::string QualifiedName(const CXIdxContainerInfo* container, - std::string_view unqualified_name); + std::pair QualifiedName(const CXIdxContainerInfo* container, + std::string_view unqualified_name); }; // |import_file| is the cc file which is what gets passed to clang. diff --git a/src/message_handler.cc b/src/message_handler.cc index dbf6d091..0d3a2082 100644 --- a/src/message_handler.cc +++ b/src/message_handler.cc @@ -349,7 +349,3 @@ void EmitSemanticHighlighting(QueryDatabase* db, out.params.symbols.push_back(entry.second); QueueManager::WriteStdout(kMethodType_CclsPublishSemanticHighlighting, out); } - -bool ShouldIgnoreFileForIndexing(const std::string& path) { - return StartsWith(path, "git:"); -} diff --git a/src/message_handler.h b/src/message_handler.h index 8fe0c6c4..ea6c67e3 100644 --- a/src/message_handler.h +++ b/src/message_handler.h @@ -153,5 +153,3 @@ void EmitSemanticHighlighting(QueryDatabase* db, SemanticHighlightSymbolCache* semantic_cache, WorkingFile* working_file, QueryFile* file); - -bool ShouldIgnoreFileForIndexing(const std::string& path); diff --git a/src/messages/text_document_did_open.cc b/src/messages/text_document_did_open.cc index 9b3ee9fb..7c10ebf8 100644 --- a/src/messages/text_document_did_open.cc +++ b/src/messages/text_document_did_open.cc @@ -40,8 +40,6 @@ struct Handler_TextDocumentDidOpen const auto& params = request->params; Timer time; std::string path = params.textDocument.uri.GetPath(); - if (ShouldIgnoreFileForIndexing(path)) - return; std::shared_ptr cache_manager = ICacheManager::Make(config); WorkingFile* working_file = working_files->OnOpen(params.textDocument); diff --git a/src/messages/text_document_did_save.cc b/src/messages/text_document_did_save.cc index 751d4238..57a3310b 100644 --- a/src/messages/text_document_did_save.cc +++ b/src/messages/text_document_did_save.cc @@ -32,8 +32,6 @@ struct Handler_TextDocumentDidSave void Run(In_TextDocumentDidSave* request) override { std::string path = request->params.textDocument.uri.GetPath(); - if (ShouldIgnoreFileForIndexing(path)) - return; // Send out an index request, and copy the current buffer state so we // can update the cached index contents when the index is done. diff --git a/src/project.cc b/src/project.cc index ff8c75ff..198d60f9 100644 --- a/src/project.cc +++ b/src/project.cc @@ -69,7 +69,6 @@ struct ProjectConfig { std::unordered_set angle_dirs; std::vector extra_flags; std::string project_dir; - std::string resource_dir; ProjectMode mode = ProjectMode::CompileCommandsJson; }; @@ -273,7 +272,7 @@ Project::Entry GetCompilationEntryFromCompileCommandEntry( // Add -resource-dir so clang can correctly resolve system includes like // if (!AnyStartsWith(result.args, "-resource-dir")) - result.args.push_back("-resource-dir=" + config->resource_dir); + result.args.push_back("-resource-dir=" + init_opts->resourceDirectory); // There could be a clang version mismatch between what the project uses and // what ccls uses. Make sure we do not emit warnings for mismatched options. @@ -476,39 +475,16 @@ std::vector LoadCompilationEntriesFromDirectory( // Computes a score based on how well |a| and |b| match. This is used for // argument guessing. -int ComputeGuessScore(const std::string& a, const std::string& b) { - const int kMatchPrefixWeight = 100; - const int kMismatchDirectoryWeight = 100; - const int kMatchPostfixWeight = 1; - - int score = 0; - size_t i = 0; - - // Increase score based on matching prefix. - for (i = 0; i < a.size() && i < b.size(); ++i) { - if (a[i] != b[i]) - break; - score += kMatchPrefixWeight; - } - - // Reduce score based on mismatched directory distance. - for (size_t j = i; j < a.size(); ++j) { - if (a[j] == '/') - score -= kMismatchDirectoryWeight; - } - for (size_t j = i; j < b.size(); ++j) { - if (b[j] == '/') - score -= kMismatchDirectoryWeight; - } - - // Increase score based on common ending. Don't increase as much as matching - // prefix or directory distance. - for (size_t offset = 1; offset <= a.size() && offset <= b.size(); ++offset) { - if (a[a.size() - offset] != b[b.size() - offset]) - break; - score += kMatchPostfixWeight; - } - +int ComputeGuessScore(std::string_view a, std::string_view b) { + // Increase score based on common prefix and suffix. Prefixes are prioritized. + if (a.size() < b.size()) + std::swap(a, b); + size_t i = std::mismatch(a.begin(), a.end(), b.begin()).first - a.begin(); + size_t j = std::mismatch(a.rbegin(), a.rend(), b.rbegin()).first - a.rbegin(); + int score = 10 * i + j; + if (i + j < b.size()) + score -= 100 * (std::count(a.begin() + i, a.end() - j, '/') + + std::count(b.begin() + i, b.end() - j, '/')); return score; } @@ -519,7 +495,6 @@ void Project::Load(Config* config, const std::string& root_directory) { ProjectConfig project; project.extra_flags = config->extraClangArguments; project.project_dir = root_directory; - project.resource_dir = config->resourceDirectory; entries = LoadCompilationEntriesFromDirectory( config, &project, config->compilationDatabaseDirectory); @@ -647,7 +622,7 @@ TEST_SUITE("Project") { Config config; ProjectConfig project; project.project_dir = "/w/c/s/"; - project.resource_dir = "/w/resource_dir/"; + config.resourceDirectory = "/w/resource_dir/"; CompileCommandsEntry entry; entry.directory = directory; @@ -691,19 +666,6 @@ TEST_SUITE("Project") { {"clang.exe", "-working-directory=/dir/", "-resource-dir=/w/resource_dir/", "-Wno-unknown-warning-option", "-fparse-all-comments"}); - - CheckFlags( - /* raw */ {"goma", "clang"}, - /* expected */ - {"clang", "-working-directory=/dir/", "-resource-dir=/w/resource_dir/", - "-Wno-unknown-warning-option", "-fparse-all-comments"}); - - CheckFlags( - /* raw */ {"goma", "clang", "--foo"}, - /* expected */ - {"clang", "-working-directory=/dir/", "--foo", - "-resource-dir=/w/resource_dir/", "-Wno-unknown-warning-option", - "-fparse-all-comments"}); } TEST_CASE("Windows path normalization") { @@ -756,678 +718,6 @@ TEST_SUITE("Project") { "-fparse-all-comments"}); } - // Checks flag parsing for a random chromium file in comparison to what - // YouCompleteMe fetches. - TEST_CASE("ycm") { - CheckFlags( - "/w/c/s/out/Release", "../../ash/login/lock_screen_sanity_unittest.cc", - - /* raw */ - { - "/work/goma/gomacc", - "../../third_party/llvm-build/Release+Asserts/bin/clang++", - "-MMD", - "-MF", - "obj/ash/ash_unittests/lock_screen_sanity_unittest.o.d", - "-DV8_DEPRECATION_WARNINGS", - "-DDCHECK_ALWAYS_ON=1", - "-DUSE_UDEV", - "-DUSE_AURA=1", - "-DUSE_NSS_CERTS=1", - "-DUSE_OZONE=1", - "-DFULL_SAFE_BROWSING", - "-DSAFE_BROWSING_CSD", - "-DSAFE_BROWSING_DB_LOCAL", - "-DCHROMIUM_BUILD", - "-DFIELDTRIAL_TESTING_ENABLED", - "-D_FILE_OFFSET_BITS=64", - "-D_LARGEFILE_SOURCE", - "-D_LARGEFILE64_SOURCE", - "-DCR_CLANG_REVISION=\"313786-1\"", - "-D__STDC_CONSTANT_MACROS", - "-D__STDC_FORMAT_MACROS", - "-DCOMPONENT_BUILD", - "-DOS_CHROMEOS", - "-DNDEBUG", - "-DNVALGRIND", - "-DDYNAMIC_ANNOTATIONS_ENABLED=0", - "-DGL_GLEXT_PROTOTYPES", - "-DUSE_GLX", - "-DUSE_EGL", - "-DANGLE_ENABLE_RELEASE_ASSERTS", - "-DTOOLKIT_VIEWS=1", - "-DGTEST_API_=", - "-DGTEST_HAS_POSIX_RE=0", - "-DGTEST_LANG_CXX11=1", - "-DUNIT_TEST", - "-DUSING_V8_SHARED", - "-DU_USING_ICU_NAMESPACE=0", - "-DU_ENABLE_DYLOAD=0", - "-DICU_UTIL_DATA_IMPL=ICU_UTIL_DATA_FILE", - "-DUCHAR_TYPE=uint16_t", - "-DGOOGLE_PROTOBUF_NO_RTTI", - "-DGOOGLE_PROTOBUF_NO_STATIC_INITIALIZER", - "-DHAVE_PTHREAD", - "-DPROTOBUF_USE_DLLS", - "-DBORINGSSL_SHARED_LIBRARY", - "-DSK_IGNORE_LINEONLY_AA_CONVEX_PATH_OPTS", - "-DSK_HAS_PNG_LIBRARY", - "-DSK_HAS_WEBP_LIBRARY", - "-DSK_HAS_JPEG_LIBRARY", - "-DSKIA_DLL", - "-DGR_GL_IGNORE_ES3_MSAA=0", - "-DSK_SUPPORT_GPU=1", - "-DMESA_EGL_NO_X11_HEADERS", - "-I../..", - "-Igen", - "-I../../third_party/libwebp/src", - "-I../../third_party/khronos", - "-I../../gpu", - "-I../../third_party/googletest/src/googletest/include", - "-I../../third_party/WebKit", - "-Igen/third_party/WebKit", - "-I../../v8/include", - "-Igen/v8/include", - "-I../../third_party/icu/source/common", - "-I../../third_party/icu/source/i18n", - "-I../../third_party/protobuf/src", - "-Igen/protoc_out", - "-I../../third_party/protobuf/src", - "-I../../third_party/boringssl/src/include", - "-I../../build/linux/debian_jessie_amd64-sysroot/usr/include/nss", - "-I../../build/linux/debian_jessie_amd64-sysroot/usr/include/nspr", - "-I../../skia/config", - "-I../../skia/ext", - "-I../../third_party/skia/include/c", - "-I../../third_party/skia/include/config", - "-I../../third_party/skia/include/core", - "-I../../third_party/skia/include/effects", - "-I../../third_party/skia/include/encode", - "-I../../third_party/skia/include/gpu", - "-I../../third_party/skia/include/images", - "-I../../third_party/skia/include/lazy", - "-I../../third_party/skia/include/pathops", - "-I../../third_party/skia/include/pdf", - "-I../../third_party/skia/include/pipe", - "-I../../third_party/skia/include/ports", - "-I../../third_party/skia/include/utils", - "-I../../third_party/skia/third_party/vulkan", - "-I../../third_party/skia/include/codec", - "-I../../third_party/skia/src/gpu", - "-I../../third_party/skia/src/sksl", - "-I../../third_party/ced/src", - "-I../../third_party/mesa/src/include", - "-I../../third_party/libwebm/source", - "-Igen", - "-I../../build/linux/debian_jessie_amd64-sysroot/usr/include/" - "dbus-1.0", - "-I../../build/linux/debian_jessie_amd64-sysroot/usr/lib/" - "x86_64-linux-gnu/dbus-1.0/include", - "-I../../third_party/googletest/custom", - "-I../../third_party/googletest/src/googlemock/include", - "-fno-strict-aliasing", - "-Wno-builtin-macro-redefined", - "-D__DATE__=", - "-D__TIME__=", - "-D__TIMESTAMP__=", - "-funwind-tables", - "-fPIC", - "-pipe", - "-B../../third_party/binutils/Linux_x64/Release/bin", - "-pthread", - "-fcolor-diagnostics", - "-no-canonical-prefixes", - "-m64", - "-march=x86-64", - "-Wall", - "-Werror", - "-Wextra", - "-Wno-missing-field-initializers", - "-Wno-unused-parameter", - "-Wno-c++11-narrowing", - "-Wno-covered-switch-default", - "-Wno-unneeded-internal-declaration", - "-Wno-inconsistent-missing-override", - "-Wno-undefined-var-template", - "-Wno-nonportable-include-path", - "-Wno-address-of-packed-member", - "-Wno-unused-lambda-capture", - "-Wno-user-defined-warnings", - "-Wno-enum-compare-switch", - "-Wno-tautological-unsigned-zero-compare", - "-Wno-null-pointer-arithmetic", - "-Wno-tautological-unsigned-enum-zero-compare", - "-O2", - "-fno-ident", - "-fdata-sections", - "-ffunction-sections", - "-fno-omit-frame-pointer", - "-g0", - "-fvisibility=hidden", - "-Xclang", - "-load", - "-Xclang", - "../../third_party/llvm-build/Release+Asserts/lib/" - "libFindBadConstructs.so", - "-Xclang", - "-add-plugin", - "-Xclang", - "find-bad-constructs", - "-Xclang", - "-plugin-arg-find-bad-constructs", - "-Xclang", - "check-auto-raw-pointer", - "-Xclang", - "-plugin-arg-find-bad-constructs", - "-Xclang", - "check-ipc", - "-Wheader-hygiene", - "-Wstring-conversion", - "-Wtautological-overlap-compare", - "-Wno-header-guard", - "-std=gnu++14", - "-fno-rtti", - "-nostdinc++", - "-isystem../../buildtools/third_party/libc++/trunk/include", - "-isystem../../buildtools/third_party/libc++abi/trunk/include", - "--sysroot=../../build/linux/debian_jessie_amd64-sysroot", - "-fno-exceptions", - "-fvisibility-inlines-hidden", - "-c", - "../../ash/login/ui/lock_screen_sanity_unittest.cc", - "-o", - "obj/ash/ash_unittests/lock_screen_sanity_unittest.o", - }, - - /* expected */ - {"../../third_party/llvm-build/Release+Asserts/bin/clang++", - "-working-directory=/w/c/s/out/Release", - "-DV8_DEPRECATION_WARNINGS", - "-DDCHECK_ALWAYS_ON=1", - "-DUSE_UDEV", - "-DUSE_AURA=1", - "-DUSE_NSS_CERTS=1", - "-DUSE_OZONE=1", - "-DFULL_SAFE_BROWSING", - "-DSAFE_BROWSING_CSD", - "-DSAFE_BROWSING_DB_LOCAL", - "-DCHROMIUM_BUILD", - "-DFIELDTRIAL_TESTING_ENABLED", - "-D_FILE_OFFSET_BITS=64", - "-D_LARGEFILE_SOURCE", - "-D_LARGEFILE64_SOURCE", - "-DCR_CLANG_REVISION=\"313786-1\"", - "-D__STDC_CONSTANT_MACROS", - "-D__STDC_FORMAT_MACROS", - "-DCOMPONENT_BUILD", - "-DOS_CHROMEOS", - "-DNDEBUG", - "-DNVALGRIND", - "-DDYNAMIC_ANNOTATIONS_ENABLED=0", - "-DGL_GLEXT_PROTOTYPES", - "-DUSE_GLX", - "-DUSE_EGL", - "-DANGLE_ENABLE_RELEASE_ASSERTS", - "-DTOOLKIT_VIEWS=1", - "-DGTEST_API_=", - "-DGTEST_HAS_POSIX_RE=0", - "-DGTEST_LANG_CXX11=1", - "-DUNIT_TEST", - "-DUSING_V8_SHARED", - "-DU_USING_ICU_NAMESPACE=0", - "-DU_ENABLE_DYLOAD=0", - "-DICU_UTIL_DATA_IMPL=ICU_UTIL_DATA_FILE", - "-DUCHAR_TYPE=uint16_t", - "-DGOOGLE_PROTOBUF_NO_RTTI", - "-DGOOGLE_PROTOBUF_NO_STATIC_INITIALIZER", - "-DHAVE_PTHREAD", - "-DPROTOBUF_USE_DLLS", - "-DBORINGSSL_SHARED_LIBRARY", - "-DSK_IGNORE_LINEONLY_AA_CONVEX_PATH_OPTS", - "-DSK_HAS_PNG_LIBRARY", - "-DSK_HAS_WEBP_LIBRARY", - "-DSK_HAS_JPEG_LIBRARY", - "-DSKIA_DLL", - "-DGR_GL_IGNORE_ES3_MSAA=0", - "-DSK_SUPPORT_GPU=1", - "-DMESA_EGL_NO_X11_HEADERS", - "-I../..", - "-Igen", - "-I../../third_party/libwebp/src", - "-I../../third_party/khronos", - "-I../../gpu", - "-I../../third_party/googletest/src/googletest/" - "include", - "-I../../third_party/WebKit", - "-Igen/third_party/WebKit", - "-I../../v8/include", - "-Igen/v8/include", - "-I../../third_party/icu/source/common", - "-I../../third_party/icu/source/i18n", - "-I../../third_party/protobuf/src", - "-Igen/protoc_out", - "-I../../third_party/protobuf/src", - "-I../../third_party/boringssl/src/include", - "-I../../build/linux/debian_jessie_amd64-sysroot/" - "usr/include/nss", - "-I../../build/linux/debian_jessie_amd64-sysroot/" - "usr/include/nspr", - "-I../../skia/config", - "-I../../skia/ext", - "-I../../third_party/skia/include/c", - "-I../../third_party/skia/include/config", - "-I../../third_party/skia/include/core", - "-I../../third_party/skia/include/effects", - "-I../../third_party/skia/include/encode", - "-I../../third_party/skia/include/gpu", - "-I../../third_party/skia/include/images", - "-I../../third_party/skia/include/lazy", - "-I../../third_party/skia/include/pathops", - "-I../../third_party/skia/include/pdf", - "-I../../third_party/skia/include/pipe", - "-I../../third_party/skia/include/ports", - "-I../../third_party/skia/include/utils", - "-I../../third_party/skia/third_party/vulkan", - "-I../../third_party/skia/include/codec", - "-I../../third_party/skia/src/gpu", - "-I../../third_party/skia/src/sksl", - "-I../../third_party/ced/src", - "-I../../third_party/mesa/src/include", - "-I../../third_party/libwebm/source", - "-Igen", - "-I../../build/linux/debian_jessie_amd64-sysroot/" - "usr/include/dbus-1.0", - "-I../../build/linux/debian_jessie_amd64-sysroot/" - "usr/lib/x86_64-linux-gnu/dbus-1.0/include", - "-I../../third_party/googletest/custom", - "-I../../third_party/googletest/src/googlemock/" - "include", - "-fno-strict-aliasing", - "-Wno-builtin-macro-redefined", - "-D__DATE__=", - "-D__TIME__=", - "-D__TIMESTAMP__=", - "-funwind-tables", - "-fPIC", - "-pipe", - "-B../../third_party/binutils/Linux_x64/Release/bin", - "-pthread", - "-fcolor-diagnostics", - "-no-canonical-prefixes", - "-m64", - "-march=x86-64", - "-Wall", - "-Werror", - "-Wextra", - "-Wno-missing-field-initializers", - "-Wno-unused-parameter", - "-Wno-c++11-narrowing", - "-Wno-covered-switch-default", - "-Wno-unneeded-internal-declaration", - "-Wno-inconsistent-missing-override", - "-Wno-undefined-var-template", - "-Wno-nonportable-include-path", - "-Wno-address-of-packed-member", - "-Wno-unused-lambda-capture", - "-Wno-user-defined-warnings", - "-Wno-enum-compare-switch", - "-Wno-tautological-unsigned-zero-compare", - "-Wno-null-pointer-arithmetic", - "-Wno-tautological-unsigned-enum-zero-compare", - "-O2", - "-fno-ident", - "-fdata-sections", - "-ffunction-sections", - "-fno-omit-frame-pointer", - "-g0", - "-fvisibility=hidden", - "-Wheader-hygiene", - "-Wstring-conversion", - "-Wtautological-overlap-compare", - "-Wno-header-guard", - "-std=gnu++14", - "-fno-rtti", - "-nostdinc++", - "-isystem../../buildtools/third_party/libc++/" - "trunk/" - "include", - "-isystem../../buildtools/third_party/libc++abi/" - "trunk/" - "include", - "--sysroot=&/w/c/s/out/Release/../../build/linux/" - "debian_jessie_amd64-sysroot", - "-fno-exceptions", - "-fvisibility-inlines-hidden", - "&/w/c/s/out/Release/../../ash/login/ui/" - "lock_screen_sanity_unittest.cc", - "-resource-dir=/w/resource_dir/", - "-Wno-unknown-warning-option", - "-fparse-all-comments"}); - } - - // Checks flag parsing for an example chromium file. - TEST_CASE("chromium") { - CheckFlags( - "/w/c/s/out/Release", "../../apps/app_lifetime_monitor.cc", - /* raw */ - {"/work/goma/gomacc", - "../../third_party/llvm-build/Release+Asserts/bin/clang++", - "-MMD", - "-MF", - "obj/apps/apps/app_lifetime_monitor.o.d", - "-DV8_DEPRECATION_WARNINGS", - "-DDCHECK_ALWAYS_ON=1", - "-DUSE_UDEV", - "-DUSE_ASH=1", - "-DUSE_AURA=1", - "-DUSE_NSS_CERTS=1", - "-DUSE_OZONE=1", - "-DDISABLE_NACL", - "-DFULL_SAFE_BROWSING", - "-DSAFE_BROWSING_CSD", - "-DSAFE_BROWSING_DB_LOCAL", - "-DCHROMIUM_BUILD", - "-DFIELDTRIAL_TESTING_ENABLED", - "-DCR_CLANG_REVISION=\"310694-1\"", - "-D_FILE_OFFSET_BITS=64", - "-D_LARGEFILE_SOURCE", - "-D_LARGEFILE64_SOURCE", - "-D__STDC_CONSTANT_MACROS", - "-D__STDC_FORMAT_MACROS", - "-DCOMPONENT_BUILD", - "-DOS_CHROMEOS", - "-DNDEBUG", - "-DNVALGRIND", - "-DDYNAMIC_ANNOTATIONS_ENABLED=0", - "-DGL_GLEXT_PROTOTYPES", - "-DUSE_GLX", - "-DUSE_EGL", - "-DANGLE_ENABLE_RELEASE_ASSERTS", - "-DTOOLKIT_VIEWS=1", - "-DV8_USE_EXTERNAL_STARTUP_DATA", - "-DU_USING_ICU_NAMESPACE=0", - "-DU_ENABLE_DYLOAD=0", - "-DICU_UTIL_DATA_IMPL=ICU_UTIL_DATA_FILE", - "-DUCHAR_TYPE=uint16_t", - "-DGOOGLE_PROTOBUF_NO_RTTI", - "-DGOOGLE_PROTOBUF_NO_STATIC_INITIALIZER", - "-DHAVE_PTHREAD", - "-DPROTOBUF_USE_DLLS", - "-DSK_IGNORE_LINEONLY_AA_CONVEX_PATH_OPTS", - "-DSK_HAS_PNG_LIBRARY", - "-DSK_HAS_WEBP_LIBRARY", - "-DSK_HAS_JPEG_LIBRARY", - "-DSKIA_DLL", - "-DGR_GL_IGNORE_ES3_MSAA=0", - "-DSK_SUPPORT_GPU=1", - "-DMESA_EGL_NO_X11_HEADERS", - "-DBORINGSSL_SHARED_LIBRARY", - "-DUSING_V8_SHARED", - "-I../..", - "-Igen", - "-I../../third_party/libwebp/src", - "-I../../third_party/khronos", - "-I../../gpu", - "-I../../third_party/ced/src", - "-I../../third_party/icu/source/common", - "-I../../third_party/icu/source/i18n", - "-I../../third_party/protobuf/src", - "-I../../skia/config", - "-I../../skia/ext", - "-I../../third_party/skia/include/c", - "-I../../third_party/skia/include/config", - "-I../../third_party/skia/include/core", - "-I../../third_party/skia/include/effects", - "-I../../third_party/skia/include/encode", - "-I../../third_party/skia/include/gpu", - "-I../../third_party/skia/include/images", - "-I../../third_party/skia/include/lazy", - "-I../../third_party/skia/include/pathops", - "-I../../third_party/skia/include/pdf", - "-I../../third_party/skia/include/pipe", - "-I../../third_party/skia/include/ports", - "-I../../third_party/skia/include/utils", - "-I../../third_party/skia/third_party/vulkan", - "-I../../third_party/skia/src/gpu", - "-I../../third_party/skia/src/sksl", - "-I../../third_party/mesa/src/include", - "-I../../third_party/libwebm/source", - "-I../../third_party/protobuf/src", - "-Igen/protoc_out", - "-I../../third_party/boringssl/src/include", - "-I../../build/linux/debian_jessie_amd64-sysroot/usr/include/nss", - "-I../../build/linux/debian_jessie_amd64-sysroot/usr/include/nspr", - "-Igen", - "-I../../third_party/WebKit", - "-Igen/third_party/WebKit", - "-I../../v8/include", - "-Igen/v8/include", - "-Igen", - "-I../../third_party/flatbuffers/src/include", - "-Igen", - "-fno-strict-aliasing", - "-Wno-builtin-macro-redefined", - "-D__DATE__=", - "-D__TIME__=", - "-D__TIMESTAMP__=", - "-funwind-tables", - "-fPIC", - "-pipe", - "-B../../third_party/binutils/Linux_x64/Release/bin", - "-pthread", - "-fcolor-diagnostics", - "-m64", - "-march=x86-64", - "-Wall", - "-Werror", - "-Wextra", - "-Wno-missing-field-initializers", - "-Wno-unused-parameter", - "-Wno-c++11-narrowing", - "-Wno-covered-switch-default", - "-Wno-unneeded-internal-declaration", - "-Wno-inconsistent-missing-override", - "-Wno-undefined-var-template", - "-Wno-nonportable-include-path", - "-Wno-address-of-packed-member", - "-Wno-unused-lambda-capture", - "-Wno-user-defined-warnings", - "-Wno-enum-compare-switch", - "-O2", - "-fno-ident", - "-fdata-sections", - "-ffunction-sections", - "-fno-omit-frame-pointer", - "-g0", - "-fvisibility=hidden", - "-Xclang", - "-load", - "-Xclang", - "../../third_party/llvm-build/Release+Asserts/lib/" - "libFindBadConstructs.so", - "-Xclang", - "-add-plugin", - "-Xclang", - "find-bad-constructs", - "-Xclang", - "-plugin-arg-find-bad-constructs", - "-Xclang", - "check-auto-raw-pointer", - "-Xclang", - "-plugin-arg-find-bad-constructs", - "-Xclang", - "check-ipc", - "-Wheader-hygiene", - "-Wstring-conversion", - "-Wtautological-overlap-compare", - "-Wexit-time-destructors", - "-Wno-header-guard", - "-Wno-exit-time-destructors", - "-std=gnu++14", - "-fno-rtti", - "-nostdinc++", - "-isystem../../buildtools/third_party/libc++/trunk/include", - "-isystem../../buildtools/third_party/libc++abi/trunk/include", - "--sysroot=../../build/linux/debian_jessie_amd64-sysroot", - "-fno-exceptions", - "-fvisibility-inlines-hidden", - "../../apps/app_lifetime_monitor.cc"}, - - /* expected */ - {"../../third_party/llvm-build/Release+Asserts/bin/clang++", - "-working-directory=/w/c/s/out/Release", - "-DV8_DEPRECATION_WARNINGS", - "-DDCHECK_ALWAYS_ON=1", - "-DUSE_UDEV", - "-DUSE_ASH=1", - "-DUSE_AURA=1", - "-DUSE_NSS_CERTS=1", - "-DUSE_OZONE=1", - "-DDISABLE_NACL", - "-DFULL_SAFE_BROWSING", - "-DSAFE_BROWSING_CSD", - "-DSAFE_BROWSING_DB_LOCAL", - "-DCHROMIUM_BUILD", - "-DFIELDTRIAL_TESTING_ENABLED", - "-DCR_CLANG_REVISION=\"310694-1\"", - "-D_FILE_OFFSET_BITS=64", - "-D_LARGEFILE_SOURCE", - "-D_LARGEFILE64_SOURCE", - "-D__STDC_CONSTANT_MACROS", - "-D__STDC_FORMAT_MACROS", - "-DCOMPONENT_BUILD", - "-DOS_CHROMEOS", - "-DNDEBUG", - "-DNVALGRIND", - "-DDYNAMIC_ANNOTATIONS_ENABLED=0", - "-DGL_GLEXT_PROTOTYPES", - "-DUSE_GLX", - "-DUSE_EGL", - "-DANGLE_ENABLE_RELEASE_ASSERTS", - "-DTOOLKIT_VIEWS=1", - "-DV8_USE_EXTERNAL_STARTUP_DATA", - "-DU_USING_ICU_NAMESPACE=0", - "-DU_ENABLE_DYLOAD=0", - "-DICU_UTIL_DATA_IMPL=ICU_UTIL_DATA_FILE", - "-DUCHAR_TYPE=uint16_t", - "-DGOOGLE_PROTOBUF_NO_RTTI", - "-DGOOGLE_PROTOBUF_NO_STATIC_INITIALIZER", - "-DHAVE_PTHREAD", - "-DPROTOBUF_USE_DLLS", - "-DSK_IGNORE_LINEONLY_AA_CONVEX_PATH_OPTS", - "-DSK_HAS_PNG_LIBRARY", - "-DSK_HAS_WEBP_LIBRARY", - "-DSK_HAS_JPEG_LIBRARY", - "-DSKIA_DLL", - "-DGR_GL_IGNORE_ES3_MSAA=0", - "-DSK_SUPPORT_GPU=1", - "-DMESA_EGL_NO_X11_HEADERS", - "-DBORINGSSL_SHARED_LIBRARY", - "-DUSING_V8_SHARED", - "-I../..", - "-Igen", - "-I../../third_party/libwebp/src", - "-I../../third_party/khronos", - "-I../../gpu", - "-I../../third_party/ced/src", - "-I../../third_party/icu/source/common", - "-I../../third_party/icu/source/i18n", - "-I../../third_party/protobuf/src", - "-I../../skia/config", - "-I../../skia/ext", - "-I../../third_party/skia/include/c", - "-I../../third_party/skia/include/config", - "-I../../third_party/skia/include/core", - "-I../../third_party/skia/include/effects", - "-I../../third_party/skia/include/encode", - "-I../../third_party/skia/include/gpu", - "-I../../third_party/skia/include/images", - "-I../../third_party/skia/include/lazy", - "-I../../third_party/skia/include/pathops", - "-I../../third_party/skia/include/pdf", - "-I../../third_party/skia/include/pipe", - "-I../../third_party/skia/include/ports", - "-I../../third_party/skia/include/utils", - "-I../../third_party/skia/third_party/vulkan", - "-I../../third_party/skia/src/gpu", - "-I../../third_party/skia/src/sksl", - "-I../../third_party/mesa/src/include", - "-I../../third_party/libwebm/source", - "-I../../third_party/protobuf/src", - "-Igen/protoc_out", - "-I../../third_party/boringssl/src/include", - "-I../../build/linux/debian_jessie_amd64-sysroot/" - "usr/include/nss", - "-I../../build/linux/debian_jessie_amd64-sysroot/" - "usr/include/nspr", - "-Igen", - "-I../../third_party/WebKit", - "-Igen/third_party/WebKit", - "-I../../v8/include", - "-Igen/v8/include", - "-Igen", - "-I../../third_party/flatbuffers/src/include", - "-Igen", - "-fno-strict-aliasing", - "-Wno-builtin-macro-redefined", - "-D__DATE__=", - "-D__TIME__=", - "-D__TIMESTAMP__=", - "-funwind-tables", - "-fPIC", - "-pipe", - "-B../../third_party/binutils/Linux_x64/Release/bin", - "-pthread", - "-fcolor-diagnostics", - "-m64", - "-march=x86-64", - "-Wall", - "-Werror", - "-Wextra", - "-Wno-missing-field-initializers", - "-Wno-unused-parameter", - "-Wno-c++11-narrowing", - "-Wno-covered-switch-default", - "-Wno-unneeded-internal-declaration", - "-Wno-inconsistent-missing-override", - "-Wno-undefined-var-template", - "-Wno-nonportable-include-path", - "-Wno-address-of-packed-member", - "-Wno-unused-lambda-capture", - "-Wno-user-defined-warnings", - "-Wno-enum-compare-switch", - "-O2", - "-fno-ident", - "-fdata-sections", - "-ffunction-sections", - "-fno-omit-frame-pointer", - "-g0", - "-fvisibility=hidden", - "-Wheader-hygiene", - "-Wstring-conversion", - "-Wtautological-overlap-compare", - "-Wexit-time-destructors", - "-Wno-header-guard", - "-Wno-exit-time-destructors", - "-std=gnu++14", - "-fno-rtti", - "-nostdinc++", - "-isystem../../buildtools/third_party/libc++/" - "trunk/" - "include", - "-isystem../../buildtools/third_party/libc++abi/" - "trunk/" - "include", - "--sysroot=&/w/c/s/out/Release/../../build/linux/" - "debian_jessie_amd64-sysroot", - "-fno-exceptions", - "-fvisibility-inlines-hidden", - "&/w/c/s/out/Release/../../apps/app_lifetime_monitor.cc", - "-resource-dir=/w/resource_dir/", - "-Wno-unknown-warning-option", - "-fparse-all-comments"}); - } - TEST_CASE("Directory extraction") { Config init_opts; ProjectConfig config; diff --git a/src/test.cc b/src/test.cc index 22524ab7..4c8bde2a 100644 --- a/src/test.cc +++ b/src/test.cc @@ -37,8 +37,7 @@ std::string ToString(const rapidjson::Document& document) { buffer.Clear(); document.Accept(writer); - std::string output = buffer.GetString(); - return UpdateToRnNewlines(output); + return buffer.GetString(); } void ParseTestExpectation( diff --git a/src/type_printer.cc b/src/type_printer.cc index c5aac634..4557dada 100644 --- a/src/type_printer.cc +++ b/src/type_printer.cc @@ -1,6 +1,6 @@ #include "type_printer.h" -#include -#include "loguru.hpp" + +#include namespace { @@ -38,7 +38,7 @@ std::string GetFunctionSignature(IndexFile* db, NamespaceHelper* ns, const CXIdxDeclInfo* decl) { int num_args = clang_Cursor_getNumArguments(decl->cursor); - std::string function_name = + std::pair function_name = ns->QualifiedName(decl->semanticContainer, decl->entityInfo->name); std::vector> args; @@ -76,7 +76,7 @@ std::string GetFunctionSignature(IndexFile* db, // Second pass: insert argument names before each comma and closing paren. int i = function_name_offset; std::string type_desc_with_names(type_desc.begin(), type_desc.begin() + i); - type_desc_with_names.append(function_name); + type_desc_with_names.append(function_name.first); for (auto& arg : args) { if (arg.first < 0) { LOG_S(ERROR) @@ -99,7 +99,7 @@ std::string GetFunctionSignature(IndexFile* db, } else { // type_desc is either a typedef, or some complicated type we cannot handle. // Append the function_name in this case. - ConcatTypeAndName(type_desc, function_name); + ConcatTypeAndName(type_desc, function_name.first); } return type_desc; diff --git a/src/utils.cc b/src/utils.cc index f20e3c02..614e1c67 100644 --- a/src/utils.cc +++ b/src/utils.cc @@ -430,40 +430,6 @@ std::string GetDefaultResourceDirectory() { return NormalizePath(result); } -std::string UpdateToRnNewlines(std::string output) { - size_t idx = 0; - while (true) { - idx = output.find('\n', idx); - - // No more matches. - if (idx == std::string::npos) - break; - - // Skip an existing "\r\n" match. - if (idx > 0 && output[idx - 1] == '\r') { - ++idx; - continue; - } - - // Replace "\n" with "\r|n". - output.replace(output.begin() + idx, output.begin() + idx + 1, "\r\n"); - } - - return output; -}; - -TEST_SUITE("Update \\n to \\r\\n") { - TEST_CASE("all") { - REQUIRE(UpdateToRnNewlines("\n") == "\r\n"); - REQUIRE(UpdateToRnNewlines("\n\n") == "\r\n\r\n"); - REQUIRE(UpdateToRnNewlines("\r\n\n") == "\r\n\r\n"); - REQUIRE(UpdateToRnNewlines("\n\r\n") == "\r\n\r\n"); - REQUIRE(UpdateToRnNewlines("\r\n\r\n") == "\r\n\r\n"); - REQUIRE(UpdateToRnNewlines("f1\nfo2\nfoo3") == "f1\r\nfo2\r\nfoo3"); - REQUIRE(UpdateToRnNewlines("f1\r\nfo2\r\nfoo3") == "f1\r\nfo2\r\nfoo3"); - } -} - TEST_SUITE("StripFileType") { TEST_CASE("all") { REQUIRE(StripFileType("") == "");