pax_global_header00006660000000000000000000000064136477660030014526gustar00rootroot0000000000000052 comment=4ed0dfe0751ac8fd3e415ecf1981313f83153b13 ccls-0.20190823.6/000077500000000000000000000000001364776600300132265ustar00rootroot00000000000000ccls-0.20190823.6/.appveyor.yml000066400000000000000000000012021364776600300156670ustar00rootroot00000000000000version: "{build}" os: Visual Studio 2017 platform: - x64 build: parallel: true # enable MSBuild parallel builds verbosity: minimal install: - if not exist llvm.tar.xz appveyor DownloadFile "https://ziglang.org/deps/llvm+clang-7.0.0-win64-msvc-release.tar.xz" -FileName llvm.tar.xz - 7z e -txz llvm.tar.xz - 7z x llvm.tar - git submodule update --init --recursive build_script: - cmake -G"Visual Studio 15 2017 Win64" -H. -Bbuild -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=C:\projects\ccls\llvm+clang-7.0.0-win64-msvc-release - cmake --build build --target ccls --config Release artifacts: - path: build\Release ccls-0.20190823.6/.clang-format000066400000000000000000000000231364776600300155740ustar00rootroot00000000000000BasedOnStyle: LLVM ccls-0.20190823.6/.github/000077500000000000000000000000001364776600300145665ustar00rootroot00000000000000ccls-0.20190823.6/.github/ISSUE_TEMPLATE000066400000000000000000000023671364776600300167040ustar00rootroot00000000000000Here are some things you should try before filing a bug report: + For client issues related to [emacs-ccls](https://github.com/MaskRay/emacs-ccls) or [vscode-ccls](https://github.com/MaskRay/vscode-ccls), report in their own repository. + For build problems, check https://github.com/MaskRay/ccls/wiki/Build + Check https://github.com/MaskRay/ccls/wiki/Debugging + Check [the FAQ](https://github.com/MaskRay/ccls/wiki/FAQ) to see if your issue is mentioned. If none of those help, remove this section and fill out the four sections in the template below. --- ### Observed behavior Describe what happened. Any aids you can include (that you think could be relevant) are a tremendous help. * `compile_commands.json` or `.ccls` ([wiki/Project-Setup](https://github.com/MaskRay/ccls/wiki/Project-Setup)) * Reduce to A minimal set of `.c` `.cc` `.h` `.hh` files that can still demonstrate the issue. * Consider a screencast gif. ### Expected behavior Describe what you expected to happen. ### Steps to reproduce 1. Select these example steps, 2. Delete them, 3. And replace them with precise steps to reproduce your issue. ### System information * ccls version (`git describe --tags --long`): * clang version: * OS: * Editor: * Language client (and version): ccls-0.20190823.6/.gitignore000066400000000000000000000000701364776600300152130ustar00rootroot00000000000000.* build debug release /compile_commands.json !.github/ ccls-0.20190823.6/.gitmodules000066400000000000000000000001561364776600300154050ustar00rootroot00000000000000[submodule "third_party/rapidjson"] path = third_party/rapidjson url = https://github.com/Tencent/rapidjson ccls-0.20190823.6/CMakeLists.txt000066400000000000000000000151761364776600300160000ustar00rootroot00000000000000cmake_minimum_required(VERSION 3.8) project(ccls LANGUAGES CXX) option(USE_SYSTEM_RAPIDJSON "Use system RapidJSON instead of the git submodule if exists" ON) # Sources for the executable are specified at end of CMakeLists.txt add_executable(ccls "") ### Default build type set(DEFAULT_CMAKE_BUILD_TYPE Release) # CMAKE_BUILD_TYPE is not available if a multi-configuration generator is used # (eg Visual Studio generators) if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) message(STATUS "Setting build type to '${DEFAULT_CMAKE_BUILD_TYPE}' as none \ was specified.") set(CMAKE_BUILD_TYPE ${DEFAULT_CMAKE_BUILD_TYPE} CACHE STRING "Choose the type of build." FORCE) # Set the possible values of build type for cmake-gui set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS Debug Release MinSizeRel RelWithDebInfo) endif() ### Compile options # Enable C++17 (Required) set_property(TARGET ccls PROPERTY CXX_STANDARD 17) set_property(TARGET ccls PROPERTY CXX_STANDARD_REQUIRED ON) set_property(TARGET ccls PROPERTY CXX_EXTENSIONS OFF) # CMake sets MSVC for both MSVC and Clang(Windows) if(MSVC) # Common MSVC/Clang(Windows) options target_compile_options(ccls PRIVATE /nologo /EHsc /D_CRT_SECURE_NO_WARNINGS # don't try to use MSVC std replacements /W3 # roughly -Wall /wd4996 # ignore deprecated declaration /wd4267 # ignores warning C4267 # (conversion from 'size_t' to 'type'), # roughly -Wno-sign-compare /wd4800 /wd4068 # Disable unknown pragma warning /std:c++17 $<$:/FS> ) # relink system libs target_link_libraries(ccls PRIVATE Mincore.lib) else() # Common GCC/Clang(Linux) options target_compile_options(ccls PRIVATE -Wall -Wno-sign-compare ) if(${CMAKE_CXX_COMPILER_ID} STREQUAL GNU) target_compile_options(ccls PRIVATE -Wno-return-type -Wno-unused-result) endif() if(${CMAKE_CXX_COMPILER_ID} STREQUAL Clang) target_compile_options(ccls PRIVATE $<$:-fno-limit-debug-info>) endif() endif() ### Libraries find_package(Clang REQUIRED) target_link_libraries(ccls PRIVATE clangIndex clangFormat clangTooling clangToolingInclusions clangToolingCore clangFrontend clangParse clangSerialization clangSema clangAST clangLex clangDriver clangBasic ) if(LLVM_LINK_LLVM_DYLIB) target_link_libraries(ccls PRIVATE LLVM) else() # In llvm 7, clangDriver headers reference LLVMOption target_link_libraries(ccls PRIVATE LLVMOption LLVMSupport) endif() if(NOT LLVM_ENABLE_RTTI) # releases.llvm.org libraries are compiled with -fno-rtti # The mismatch between lib{clang,LLVM}* and ccls can make libstdc++ std::make_shared return nullptr # _Sp_counted_ptr_inplace::_M_get_deleter if(MSVC) target_compile_options(ccls PRIVATE /GR-) else() target_compile_options(ccls PRIVATE -fno-rtti) endif() endif() # Enable threading support set(THREADS_PREFER_PTHREAD_FLAG ON) find_package(Threads REQUIRED) target_link_libraries(ccls PRIVATE Threads::Threads) if(${CMAKE_SYSTEM_NAME} STREQUAL FreeBSD) find_package(Backtrace REQUIRED) target_link_libraries(ccls PRIVATE ${Backtrace_LIBRARIES}) # src/platform_posix.cc uses libthr target_link_libraries(ccls PRIVATE thr) endif() ### Definitions # Find Clang resource directory with Clang executable. if(NOT CLANG_RESOURCE_DIR) find_program(CLANG_EXECUTABLE clang) if(NOT CLANG_EXECUTABLE) message(FATAL_ERROR "clang executable not found.") endif() execute_process( COMMAND ${CLANG_EXECUTABLE} -print-resource-dir RESULT_VARIABLE CLANG_FIND_RESOURCE_DIR_RESULT OUTPUT_VARIABLE CLANG_RESOURCE_DIR ERROR_VARIABLE CLANG_FIND_RESOURCE_DIR_ERROR OUTPUT_STRIP_TRAILING_WHITESPACE ) if(CLANG_FIND_RESOURCE_DIR_RESULT) message(FATAL_ERROR "Error retrieving Clang resource directory with Clang \ executable. Output:\n ${CLANG_FIND_RESOURCE_DIR_ERROR}") endif() endif() set_property(SOURCE src/utils.cc APPEND PROPERTY COMPILE_DEFINITIONS CLANG_RESOURCE_DIRECTORY=R"\(${CLANG_RESOURCE_DIR}\)") ### Includes if(USE_SYSTEM_RAPIDJSON) find_package(RapidJSON QUIET) endif() if(NOT RapidJSON_FOUND) set(RapidJSON_INCLUDE_DIRS third_party/rapidjson/include) endif() target_include_directories(ccls PRIVATE src) foreach(include_dir third_party ${LLVM_INCLUDE_DIRS} ${CLANG_INCLUDE_DIRS} ${RapidJSON_INCLUDE_DIRS}) get_filename_component(include_dir_realpath ${include_dir} REALPATH) # Don't add as SYSTEM if they are in CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES. # It would reorder the system search paths and cause issues with libstdc++'s # use of #include_next. See https://github.com/MaskRay/ccls/pull/417 if(NOT "${include_dir_realpath}" IN_LIST CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES) target_include_directories(ccls SYSTEM PRIVATE ${include_dir}) endif() endforeach() ### Install install(TARGETS ccls RUNTIME DESTINATION bin) ### Sources target_sources(ccls PRIVATE third_party/siphash.cc) target_sources(ccls PRIVATE src/clang_tu.cc src/config.cc src/filesystem.cc src/fuzzy_match.cc src/main.cc src/include_complete.cc src/indexer.cc src/log.cc src/lsp.cc src/message_handler.cc src/pipeline.cc src/platform_posix.cc src/platform_win.cc src/position.cc src/project.cc src/query.cc src/sema_manager.cc src/serializer.cc src/test.cc src/utils.cc src/working_files.cc ) target_sources(ccls PRIVATE src/messages/ccls_call.cc src/messages/ccls_info.cc src/messages/ccls_inheritance.cc src/messages/ccls_member.cc src/messages/ccls_navigate.cc src/messages/ccls_reload.cc src/messages/ccls_vars.cc src/messages/initialize.cc src/messages/textDocument_code.cc src/messages/textDocument_completion.cc src/messages/textDocument_definition.cc src/messages/textDocument_did.cc src/messages/textDocument_foldingRange.cc src/messages/textDocument_formatting.cc src/messages/textDocument_document.cc src/messages/textDocument_hover.cc src/messages/textDocument_references.cc src/messages/textDocument_rename.cc src/messages/textDocument_signatureHelp.cc src/messages/workspace.cc ) ### Obtain CCLS version information from Git ### This only happens when cmake is re-run! if(NOT CCLS_VERSION) execute_process(COMMAND git describe --tag --long HEAD OUTPUT_VARIABLE CCLS_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}") if(NOT CCLS_VERSION) set(CCLS_VERSION "") endif() endif() set_property(SOURCE src/main.cc APPEND PROPERTY COMPILE_DEFINITIONS CCLS_VERSION=\"${CCLS_VERSION}\") ccls-0.20190823.6/LICENSE000066400000000000000000000261351364776600300142420ustar00rootroot00000000000000 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ccls-0.20190823.6/README.md000066400000000000000000000036511364776600300145120ustar00rootroot00000000000000# ccls [![Telegram](https://img.shields.io/badge/telegram-@cclsp-blue.svg)](https://telegram.me/cclsp) [![Gitter](https://img.shields.io/badge/gitter-ccls--project-blue.svg?logo=gitter-white)](https://gitter.im/ccls-project/ccls) ccls, which originates from [cquery](https://github.com/cquery-project/cquery), is a C/C++/Objective-C language server. * code completion (with both signature help and snippets) * [definition](src/messages/textDocument_definition.cc)/[references](src/messages/textDocument_references.cc), and other cross references * cross reference extensions: `$ccls/call` `$ccls/inheritance` `$ccls/member` `$ccls/vars` ... * formatting * hierarchies: [call (caller/callee) hierarchy](src/messages/ccls_call.cc), [inheritance (base/derived) hierarchy](src/messages/ccls_inheritance.cc), [member hierarchy](src/messages/ccls_member.cc) * [symbol rename](src/messages/textDocument_rename.cc) * [document symbols](src/messages/textDocument_document.cc) and approximate search of [workspace symbol](src/messages/workspace.cc) * [hover information](src/messages/textDocument_hover.cc) * diagnostics and code actions (clang FixIts) * semantic highlighting and preprocessor skipped regions * semantic navigation: `$ccls/navigate` It has a global view of the code base and support a lot of cross reference features, see [wiki/FAQ](../../wiki/FAQ). It starts indexing the whole project (including subprojects if exist) parallelly when you open the first file, while the main thread can serve requests before the indexing is complete. Saving files will incrementally update the index. # >>> [Getting started](../../wiki/Home) (CLICK HERE) <<< * [Build](../../wiki/Build) * [FAQ](../../wiki/FAQ) ccls can index itself (~180MiB RSS when idle, noted on 2018-09-01), FreeBSD, glibc, Linux, LLVM (~1800MiB RSS), musl (~60MiB RSS), ... with decent memory footprint. See [wiki/Project-Setup](../../wiki/Project-Setup) for examples. ccls-0.20190823.6/ci/000077500000000000000000000000001364776600300136215ustar00rootroot00000000000000ccls-0.20190823.6/ci/before_deploy.sh000077500000000000000000000027671364776600300170120ustar00rootroot00000000000000#!/usr/bin/env bash root=$(cd "$(dirname "$0")/.."; pwd) version=$(TZ=UTC date +v%Y%m%d) cd "$root/build/release" case $(uname -s) in Darwin) libclang=(lib/clang+llvm-*/lib/libclang.dylib) strip_option="-x" name=ccls-$version-x86_64-apple-darwin ;; FreeBSD) libclang=(lib/clang+llvm-*/lib/libclang.so.?) strip_option="-s" name=ccls-$version-x86_64-unknown-freebsd10 ;; Linux) libclang=(lib/clang+llvm-*/lib/libclang.so.?) strip_option="-s" name=ccls-$version-x86_64-unknown-linux-gnu ;; *) echo Unsupported >&2 exit 1 ;; esac pkg=$(mktemp -d) mkdir "$pkg/$name" rsync -rtLR bin "./${libclang[-1]}" ./lib/clang+llvm-*/lib/clang/*/include "$pkg/$name" cd "$pkg" strip "$strip_option" "$name/bin/ccls" "$name/${libclang[-1]}" case $(uname -s) in Darwin) # https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man1/tar.1.html # macOS's bsdtar is lack of flags to set uid/gid. # First, we generate a list of file in mtree format. tar -cf filelist --format=mtree --options="!all,time,mode,type" "$name" # Then add a line "/set uid=0 gid=0" after the first line "#mtree". awk '/#mtree/{print;print "/set uid=0 gid=0";next}1' filelist > newflielist # Finally, use the list to generate the tarball. tar -zcf "$root/build/$name.tar.gz" @newflielist ;; Linux) tar -Jcf "$root/build/$name.tar.xz" --owner 0 --group 0 $name ;; *) tar -Jcf "$root/build/$name.tar.xz" --uid 0 --gid 0 $name ;; esac rm -r "$pkg" ccls-0.20190823.6/index_tests/000077500000000000000000000000001364776600300155575ustar00rootroot00000000000000ccls-0.20190823.6/index_tests/_empty_test.cc000066400000000000000000000000211364776600300204130ustar00rootroot00000000000000/* OUTPUT: {} */ ccls-0.20190823.6/index_tests/class_forward_declaration.cc000066400000000000000000000011731364776600300232660ustar00rootroot00000000000000class Foo; class Foo; class Foo {}; class Foo; /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [], "usr2type": [{ "usr": 15041163540773201510, "detailed_name": "class Foo", "qual_name_offset": 6, "short_name": "Foo", "spell": "3:7-3:10|3:1-3:13|2|-1", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 5, "parent_kind": 0, "declarations": ["1:7-1:10|1:1-1:10|1|-1", "2:7-2:10|2:1-2:10|1|-1", "4:7-4:10|4:1-4:10|1|-1"], "derived": [], "instances": [], "uses": [] }], "usr2var": [] } */ ccls-0.20190823.6/index_tests/constructors/000077500000000000000000000000001364776600300203275ustar00rootroot00000000000000ccls-0.20190823.6/index_tests/constructors/constructor.cc000066400000000000000000000044471364776600300232340ustar00rootroot00000000000000class Foo { public: Foo() {} }; void foo() { Foo f; Foo* f2 = new Foo(); } /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [{ "usr": 3385168158331140247, "detailed_name": "Foo::Foo()", "qual_name_offset": 0, "short_name": "Foo", "spell": "3:3-3:6|3:3-3:11|1026|-1", "bases": [], "vars": [], "callees": [], "kind": 9, "parent_kind": 5, "storage": 0, "declarations": [], "derived": [], "uses": ["7:7-7:8|16676|-1", "8:17-8:20|16676|-1"] }, { "usr": 4259594751088586730, "detailed_name": "void foo()", "qual_name_offset": 5, "short_name": "foo", "spell": "6:6-6:9|6:1-9:2|2|-1", "bases": [], "vars": [10983126130596230582, 17165811951126099095], "callees": ["7:7-7:8|3385168158331140247|3|16676", "7:7-7:8|3385168158331140247|3|16676", "8:17-8:20|3385168158331140247|3|16676", "8:17-8:20|3385168158331140247|3|16676"], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": [], "derived": [], "uses": [] }], "usr2type": [{ "usr": 15041163540773201510, "detailed_name": "class Foo {}", "qual_name_offset": 6, "short_name": "Foo", "spell": "1:7-1:10|1:1-4:2|2|-1", "bases": [], "funcs": [3385168158331140247], "types": [], "vars": [], "alias_of": 0, "kind": 5, "parent_kind": 0, "declarations": [], "derived": [], "instances": [10983126130596230582, 17165811951126099095], "uses": ["3:3-3:6|4|-1", "7:3-7:6|4|-1", "8:3-8:6|4|-1", "8:17-8:20|4|-1"] }], "usr2var": [{ "usr": 10983126130596230582, "detailed_name": "Foo f", "qual_name_offset": 4, "short_name": "f", "spell": "7:7-7:8|7:3-7:8|2|-1", "type": 15041163540773201510, "kind": 13, "parent_kind": 12, "storage": 0, "declarations": [], "uses": [] }, { "usr": 17165811951126099095, "detailed_name": "Foo *f2", "qual_name_offset": 5, "short_name": "f2", "hover": "Foo *f2 = new Foo()", "spell": "8:8-8:10|8:3-8:22|2|-1", "type": 15041163540773201510, "kind": 13, "parent_kind": 12, "storage": 0, "declarations": [], "uses": [] }] } */ ccls-0.20190823.6/index_tests/constructors/destructor.cc000066400000000000000000000047661364776600300230510ustar00rootroot00000000000000class Foo { public: Foo() {} ~Foo() {}; }; void foo() { Foo f; } // TODO: Support destructors (notice how the dtor has no usages listed). // - check if variable is a pointer. if so, do *not* insert dtor // - check if variable is normal type. if so, insert dtor // - scan for statements that look like dtors in function def handler // - figure out some way to support w/ unique_ptrs? /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [{ "usr": 3385168158331140247, "detailed_name": "Foo::Foo()", "qual_name_offset": 0, "short_name": "Foo", "spell": "3:3-3:6|3:3-3:11|1026|-1", "bases": [], "vars": [], "callees": [], "kind": 9, "parent_kind": 5, "storage": 0, "declarations": [], "derived": [], "uses": ["8:7-8:8|16676|-1"] }, { "usr": 4259594751088586730, "detailed_name": "void foo()", "qual_name_offset": 5, "short_name": "foo", "spell": "7:6-7:9|7:1-9:2|2|-1", "bases": [], "vars": [1893354193220338759], "callees": ["8:7-8:8|3385168158331140247|3|16676", "8:7-8:8|3385168158331140247|3|16676"], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": [], "derived": [], "uses": [] }, { "usr": 7440261702884428359, "detailed_name": "Foo::~Foo() noexcept", "qual_name_offset": 0, "short_name": "~Foo", "spell": "4:3-4:7|4:3-4:12|1026|-1", "bases": [], "vars": [], "callees": [], "kind": 6, "parent_kind": 5, "storage": 0, "declarations": [], "derived": [], "uses": [] }], "usr2type": [{ "usr": 15041163540773201510, "detailed_name": "class Foo {}", "qual_name_offset": 6, "short_name": "Foo", "spell": "1:7-1:10|1:1-5:2|2|-1", "bases": [], "funcs": [3385168158331140247, 7440261702884428359], "types": [], "vars": [], "alias_of": 0, "kind": 5, "parent_kind": 0, "declarations": [], "derived": [], "instances": [1893354193220338759], "uses": ["3:3-3:6|4|-1", "4:4-4:7|4|-1", "8:3-8:6|4|-1"] }], "usr2var": [{ "usr": 1893354193220338759, "detailed_name": "Foo f", "qual_name_offset": 4, "short_name": "f", "spell": "8:7-8:8|8:3-8:8|2|-1", "type": 15041163540773201510, "kind": 13, "parent_kind": 12, "storage": 0, "declarations": [], "uses": [] }] } */ ccls-0.20190823.6/index_tests/constructors/implicit_constructor.cc000066400000000000000000000044601364776600300251210ustar00rootroot00000000000000struct Type { Type() {} }; void Make() { Type foo0; auto foo1 = Type(); } /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [{ "usr": 3957104924306079513, "detailed_name": "void Make()", "qual_name_offset": 5, "short_name": "Make", "spell": "5:6-5:10|5:1-8:2|2|-1", "bases": [], "vars": [449111627548814328, 17097499197730163115], "callees": ["6:8-6:12|10530961286677896857|3|16676", "6:8-6:12|10530961286677896857|3|16676", "7:15-7:19|10530961286677896857|3|16676", "7:15-7:19|10530961286677896857|3|16676"], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": [], "derived": [], "uses": [] }, { "usr": 10530961286677896857, "detailed_name": "Type::Type()", "qual_name_offset": 0, "short_name": "Type", "spell": "2:3-2:7|2:3-2:12|1026|-1", "bases": [], "vars": [], "callees": [], "kind": 9, "parent_kind": 23, "storage": 0, "declarations": [], "derived": [], "uses": ["6:8-6:12|16676|-1", "7:15-7:19|16676|-1"] }], "usr2type": [{ "usr": 13487927231218873822, "detailed_name": "struct Type {}", "qual_name_offset": 7, "short_name": "Type", "spell": "1:8-1:12|1:1-3:2|2|-1", "bases": [], "funcs": [10530961286677896857], "types": [], "vars": [], "alias_of": 0, "kind": 23, "parent_kind": 0, "declarations": [], "derived": [], "instances": [449111627548814328, 17097499197730163115], "uses": ["2:3-2:7|4|-1", "6:3-6:7|4|-1", "7:15-7:19|4|-1"] }], "usr2var": [{ "usr": 449111627548814328, "detailed_name": "Type foo0", "qual_name_offset": 5, "short_name": "foo0", "spell": "6:8-6:12|6:3-6:12|2|-1", "type": 13487927231218873822, "kind": 13, "parent_kind": 12, "storage": 0, "declarations": [], "uses": [] }, { "usr": 17097499197730163115, "detailed_name": "Type foo1", "qual_name_offset": 5, "short_name": "foo1", "hover": "Type foo1 = Type()", "spell": "7:8-7:12|7:3-7:21|2|-1", "type": 13487927231218873822, "kind": 13, "parent_kind": 12, "storage": 0, "declarations": [], "uses": [] }] } */ ccls-0.20190823.6/index_tests/constructors/invalid_reference.cc000066400000000000000000000020221364776600300242760ustar00rootroot00000000000000struct Foo {}; template Foo::Foo() {} /* EXTRA_FLAGS: -fms-compatibility -fdelayed-template-parsing OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [{ "usr": 17319723337446061757, "detailed_name": "Foo::Foo::Foo()", "qual_name_offset": 0, "short_name": "Foo", "spell": "4:6-4:9|4:1-4:11|1026|-1", "bases": [], "vars": [], "callees": [], "kind": 9, "parent_kind": 23, "storage": 0, "declarations": [], "derived": [], "uses": [] }], "usr2type": [{ "usr": 15041163540773201510, "detailed_name": "struct Foo {}", "qual_name_offset": 7, "short_name": "Foo", "spell": "1:8-1:11|1:1-1:14|2|-1", "bases": [], "funcs": [17319723337446061757], "types": [], "vars": [], "alias_of": 0, "kind": 23, "parent_kind": 0, "declarations": [], "derived": [], "instances": [], "uses": ["4:1-4:4|4|-1", "4:6-4:9|4|-1"] }], "usr2var": [] } */ ccls-0.20190823.6/index_tests/constructors/make_functions.cc000066400000000000000000000215131364776600300236450ustar00rootroot00000000000000#include "make_functions.h" template T* MakeUnique(Args&&... args) { return nullptr; } template T* maKE_NoRefs(Args... args) { return nullptr; } void caller22() { MakeUnique(); MakeUnique(1); MakeUnique(1, new Bar(), nullptr); maKE_NoRefs(1, new Bar(), nullptr); } // TODO: Eliminate the extra entries in the "types" array here. They come from // the template function definitions. // Foobar is defined in a separate file to ensure that we can attribute // MakeUnique calls across translation units. /* OUTPUT: make_functions.h { "includes": [], "skipped_ranges": [], "usr2func": [{ "usr": 3765833212244435302, "detailed_name": "Foobar::Foobar(int &&, Bar *, bool *)", "qual_name_offset": 0, "short_name": "Foobar", "spell": "7:3-7:9|7:3-7:32|1026|-1", "bases": [], "vars": [], "callees": [], "kind": 9, "parent_kind": 5, "storage": 0, "declarations": [], "derived": [], "uses": [] }, { "usr": 13028995015627606181, "detailed_name": "Foobar::Foobar(int)", "qual_name_offset": 0, "short_name": "Foobar", "spell": "6:3-6:9|6:3-6:17|1026|-1", "bases": [], "vars": [], "callees": [], "kind": 9, "parent_kind": 5, "storage": 0, "declarations": [], "derived": [], "uses": [] }, { "usr": 13131778807733950299, "detailed_name": "Foobar::Foobar()", "qual_name_offset": 0, "short_name": "Foobar", "spell": "5:3-5:9|5:3-5:14|1026|-1", "bases": [], "vars": [], "callees": [], "kind": 9, "parent_kind": 5, "storage": 0, "declarations": [], "derived": [], "uses": [] }, { "usr": 17321436359755983845, "detailed_name": "Foobar::Foobar(int, Bar *, bool *)", "qual_name_offset": 0, "short_name": "Foobar", "spell": "8:3-8:9|8:3-8:30|1026|-1", "bases": [], "vars": [], "callees": [], "kind": 9, "parent_kind": 5, "storage": 0, "declarations": [], "derived": [], "uses": [] }], "usr2type": [{ "usr": 12993848456528750350, "detailed_name": "struct Bar {}", "qual_name_offset": 7, "short_name": "Bar", "spell": "1:8-1:11|1:1-1:14|2|-1", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 23, "parent_kind": 0, "declarations": [], "derived": [], "instances": [], "uses": ["7:17-7:20|4|-1", "8:15-8:18|4|-1"] }, { "usr": 14935975554338052500, "detailed_name": "class Foobar {}", "qual_name_offset": 6, "short_name": "Foobar", "spell": "3:7-3:13|3:1-9:2|2|-1", "bases": [], "funcs": [13131778807733950299, 13028995015627606181, 3765833212244435302, 17321436359755983845], "types": [], "vars": [], "alias_of": 0, "kind": 5, "parent_kind": 0, "declarations": [], "derived": [], "instances": [], "uses": ["5:3-5:9|4|-1", "6:3-6:9|4|-1", "7:3-7:9|4|-1", "8:3-8:9|4|-1"] }], "usr2var": [] } OUTPUT: make_functions.cc { "includes": [{ "line": 0, "resolved_path": "&make_functions.h" }], "skipped_ranges": [], "usr2func": [{ "usr": 768523651983844320, "detailed_name": "", "qual_name_offset": 0, "short_name": "", "bases": [], "vars": [2555873744476712860, 2555873744476712860, 2555873744476712860], "callees": [], "kind": 0, "parent_kind": 0, "storage": 0, "declarations": [], "derived": [], "uses": [] }, { "usr": 2532818908869373467, "detailed_name": "T *maKE_NoRefs(Args ...args)", "qual_name_offset": 3, "short_name": "maKE_NoRefs", "spell": "9:4-9:15|9:1-11:2|2|-1", "bases": [], "vars": [3908732770590594660], "callees": [], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": [], "derived": [], "uses": ["17:3-17:14|16420|-1"] }, { "usr": 2816883305867289955, "detailed_name": "void caller22()", "qual_name_offset": 5, "short_name": "caller22", "spell": "13:6-13:14|13:1-18:2|2|-1", "bases": [], "vars": [], "callees": ["14:3-14:13|15793662558620604611|3|16420", "15:3-15:13|15793662558620604611|3|16420", "16:3-16:13|15793662558620604611|3|16420", "17:3-17:14|2532818908869373467|3|16420"], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": [], "derived": [], "uses": [] }, { "usr": 11138976705878544996, "detailed_name": "", "qual_name_offset": 0, "short_name": "", "bases": [], "vars": [16395392342608151399], "callees": [], "kind": 0, "parent_kind": 0, "storage": 0, "declarations": [], "derived": [], "uses": [] }, { "usr": 11363675606380070883, "detailed_name": "", "qual_name_offset": 0, "short_name": "", "bases": [], "vars": [180270746871803062, 180270746871803062, 180270746871803062], "callees": [], "kind": 0, "parent_kind": 0, "storage": 0, "declarations": [], "derived": [], "uses": [] }, { "usr": 15793662558620604611, "detailed_name": "T *MakeUnique(Args &&...args)", "qual_name_offset": 3, "short_name": "MakeUnique", "spell": "4:4-4:14|4:1-6:2|2|-1", "bases": [], "vars": [8463700030555379526], "callees": [], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": [], "derived": [], "uses": ["14:3-14:13|16420|-1", "15:3-15:13|16420|-1", "16:3-16:13|16420|-1"] }], "usr2type": [{ "usr": 53, "detailed_name": "", "qual_name_offset": 0, "short_name": "", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 0, "parent_kind": 0, "declarations": [], "derived": [], "instances": [180270746871803062], "uses": [] }, { "usr": 87, "detailed_name": "", "qual_name_offset": 0, "short_name": "", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 0, "parent_kind": 0, "declarations": [], "derived": [], "instances": [180270746871803062], "uses": [] }, { "usr": 12993848456528750350, "detailed_name": "struct Bar {}", "qual_name_offset": 7, "short_name": "Bar", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 23, "parent_kind": 0, "declarations": [], "derived": [], "instances": [], "uses": ["16:29-16:32|4|-1", "17:30-17:33|4|-1"] }, { "usr": 14935975554338052500, "detailed_name": "class Foobar {}", "qual_name_offset": 6, "short_name": "Foobar", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 5, "parent_kind": 0, "declarations": [], "derived": [], "instances": [], "uses": ["14:14-14:20|4|-1", "15:14-15:20|4|-1", "16:14-16:20|4|-1", "17:15-17:21|4|-1"] }], "usr2var": [{ "usr": 180270746871803062, "detailed_name": "int args", "qual_name_offset": 4, "short_name": "args", "spell": "9:24-9:28|9:16-9:28|1026|-1", "type": 87, "kind": 253, "parent_kind": 12, "storage": 0, "declarations": [], "uses": [] }, { "usr": 2555873744476712860, "detailed_name": "int &&args", "qual_name_offset": 6, "short_name": "args", "spell": "4:25-4:29|4:15-4:29|1026|-1", "type": 0, "kind": 253, "parent_kind": 12, "storage": 0, "declarations": [], "uses": [] }, { "usr": 3908732770590594660, "detailed_name": "Args ...args", "qual_name_offset": 8, "short_name": "args", "spell": "9:24-9:28|9:16-9:28|1026|-1", "type": 0, "kind": 253, "parent_kind": 12, "storage": 0, "declarations": [], "uses": [] }, { "usr": 8463700030555379526, "detailed_name": "Args &&...args", "qual_name_offset": 10, "short_name": "args", "spell": "4:25-4:29|4:15-4:29|1026|-1", "type": 0, "kind": 253, "parent_kind": 12, "storage": 0, "declarations": [], "uses": [] }, { "usr": 16395392342608151399, "detailed_name": "int &&args", "qual_name_offset": 6, "short_name": "args", "spell": "4:25-4:29|4:15-4:29|1026|-1", "type": 0, "kind": 253, "parent_kind": 12, "storage": 0, "declarations": [], "uses": [] }] } */ ccls-0.20190823.6/index_tests/constructors/make_functions.h000066400000000000000000000002111364776600300234770ustar00rootroot00000000000000struct Bar {}; class Foobar { public: Foobar() {} Foobar(int) {} Foobar(int&&, Bar*, bool*) {} Foobar(int, Bar*, bool*) {} }; ccls-0.20190823.6/index_tests/declaration_vs_definition/000077500000000000000000000000001364776600300227645ustar00rootroot00000000000000ccls-0.20190823.6/index_tests/declaration_vs_definition/class.cc000066400000000000000000000013361364776600300244030ustar00rootroot00000000000000class Foo; class Foo; class Foo {}; class Foo; /* // NOTE: Separate decl/definition are not supported for classes. See source // for comments. OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [], "usr2type": [{ "usr": 15041163540773201510, "detailed_name": "class Foo", "qual_name_offset": 6, "short_name": "Foo", "spell": "3:7-3:10|3:1-3:13|2|-1", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 5, "parent_kind": 0, "declarations": ["1:7-1:10|1:1-1:10|1|-1", "2:7-2:10|2:1-2:10|1|-1", "4:7-4:10|4:1-4:10|1|-1"], "derived": [], "instances": [], "uses": [] }], "usr2var": [] } */ ccls-0.20190823.6/index_tests/declaration_vs_definition/class_member.cc000066400000000000000000000023471364776600300257350ustar00rootroot00000000000000class Foo { int foo; }; /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [], "usr2type": [{ "usr": 53, "detailed_name": "", "qual_name_offset": 0, "short_name": "", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 0, "parent_kind": 0, "declarations": [], "derived": [], "instances": [9736582033442720743], "uses": [] }, { "usr": 15041163540773201510, "detailed_name": "class Foo {}", "qual_name_offset": 6, "short_name": "Foo", "spell": "1:7-1:10|1:1-3:2|2|-1", "bases": [], "funcs": [], "types": [], "vars": [{ "L": 9736582033442720743, "R": 0 }], "alias_of": 0, "kind": 5, "parent_kind": 0, "declarations": [], "derived": [], "instances": [], "uses": [] }], "usr2var": [{ "usr": 9736582033442720743, "detailed_name": "int Foo::foo", "qual_name_offset": 4, "short_name": "foo", "spell": "2:7-2:10|2:3-2:10|1026|-1", "type": 53, "kind": 8, "parent_kind": 5, "storage": 0, "declarations": [], "uses": [] }] } */ ccls-0.20190823.6/index_tests/declaration_vs_definition/class_member_static.cc000066400000000000000000000024061364776600300273000ustar00rootroot00000000000000class Foo { static int foo; }; int Foo::foo; /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [], "usr2type": [{ "usr": 53, "detailed_name": "", "qual_name_offset": 0, "short_name": "", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 0, "parent_kind": 0, "declarations": [], "derived": [], "instances": [8942920329766232482, 8942920329766232482], "uses": [] }, { "usr": 15041163540773201510, "detailed_name": "class Foo {}", "qual_name_offset": 6, "short_name": "Foo", "spell": "1:7-1:10|1:1-3:2|2|-1", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 5, "parent_kind": 0, "declarations": [], "derived": [], "instances": [], "uses": ["5:5-5:8|4|-1"] }], "usr2var": [{ "usr": 8942920329766232482, "detailed_name": "static int Foo::foo", "qual_name_offset": 11, "short_name": "foo", "spell": "5:10-5:13|5:1-5:13|1026|-1", "type": 53, "kind": 13, "parent_kind": 5, "storage": 2, "declarations": ["2:14-2:17|2:3-2:17|1025|-1"], "uses": [] }] } */ ccls-0.20190823.6/index_tests/declaration_vs_definition/func.cc000066400000000000000000000012401364776600300242230ustar00rootroot00000000000000void foo(); void foo(); void foo() {} void foo(); /* // Note: we always use the latest seen ("most local") definition/declaration. OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [{ "usr": 4259594751088586730, "detailed_name": "void foo()", "qual_name_offset": 5, "short_name": "foo", "spell": "3:6-3:9|3:1-3:14|2|-1", "bases": [], "vars": [], "callees": [], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": ["1:6-1:9|1:1-1:11|1|-1", "2:6-2:9|2:1-2:11|1|-1", "4:6-4:9|4:1-4:11|1|-1"], "derived": [], "uses": [] }], "usr2type": [], "usr2var": [] } */ ccls-0.20190823.6/index_tests/declaration_vs_definition/func_associated_function_params.cc000066400000000000000000000032151364776600300316760ustar00rootroot00000000000000int foo(int, int); int foo(int aa, int bb); int foo(int aaa, int bbb); int foo(int a, int b) { return 0; } /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [{ "usr": 2747674671862363334, "detailed_name": "int foo(int, int)", "qual_name_offset": 4, "short_name": "foo", "spell": "5:5-5:8|5:1-5:36|2|-1", "bases": [], "vars": [14555488990109936920, 10963664335057337329], "callees": [], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": ["1:5-1:8|1:1-1:18|1|-1", "2:5-2:8|2:1-3:16|1|-1", "4:5-4:8|4:1-4:26|1|-1"], "derived": [], "uses": [] }], "usr2type": [{ "usr": 53, "detailed_name": "", "qual_name_offset": 0, "short_name": "", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 0, "parent_kind": 0, "declarations": [], "derived": [], "instances": [14555488990109936920, 10963664335057337329], "uses": [] }], "usr2var": [{ "usr": 10963664335057337329, "detailed_name": "int b", "qual_name_offset": 4, "short_name": "b", "spell": "5:20-5:21|5:16-5:21|1026|-1", "type": 53, "kind": 253, "parent_kind": 12, "storage": 0, "declarations": [], "uses": [] }, { "usr": 14555488990109936920, "detailed_name": "int a", "qual_name_offset": 4, "short_name": "a", "spell": "5:13-5:14|5:9-5:14|1026|-1", "type": 53, "kind": 253, "parent_kind": 12, "storage": 0, "declarations": [], "uses": [] }] } */ ccls-0.20190823.6/index_tests/declaration_vs_definition/method.cc000066400000000000000000000034471364776600300245630ustar00rootroot00000000000000class Foo { void declonly(); virtual void purevirtual() = 0; void def(); }; void Foo::def() {} /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [{ "usr": 4012226004228259562, "detailed_name": "void Foo::declonly()", "qual_name_offset": 5, "short_name": "declonly", "bases": [], "vars": [], "callees": [], "kind": 6, "parent_kind": 0, "storage": 0, "declarations": ["2:8-2:16|2:3-2:18|1025|-1"], "derived": [], "uses": [] }, { "usr": 10939323144126021546, "detailed_name": "virtual void Foo::purevirtual() = 0", "qual_name_offset": 13, "short_name": "purevirtual", "bases": [], "vars": [], "callees": [], "kind": 6, "parent_kind": 0, "storage": 0, "declarations": ["3:16-3:27|3:3-3:33|1089|-1"], "derived": [], "uses": [] }, { "usr": 15416083548883122431, "detailed_name": "void Foo::def()", "qual_name_offset": 5, "short_name": "def", "spell": "7:11-7:14|7:1-7:19|1026|-1", "bases": [], "vars": [], "callees": [], "kind": 6, "parent_kind": 5, "storage": 0, "declarations": ["4:8-4:11|4:3-4:13|1025|-1"], "derived": [], "uses": [] }], "usr2type": [{ "usr": 15041163540773201510, "detailed_name": "class Foo {}", "qual_name_offset": 6, "short_name": "Foo", "spell": "1:7-1:10|1:1-5:2|2|-1", "bases": [], "funcs": [4012226004228259562, 10939323144126021546, 15416083548883122431], "types": [], "vars": [], "alias_of": 0, "kind": 5, "parent_kind": 0, "declarations": [], "derived": [], "instances": [], "uses": ["7:6-7:9|4|-1"] }], "usr2var": [] } */ ccls-0.20190823.6/index_tests/enums/000077500000000000000000000000001364776600300167065ustar00rootroot00000000000000ccls-0.20190823.6/index_tests/enums/enum_class_decl.cc000066400000000000000000000034431364776600300223410ustar00rootroot00000000000000typedef unsigned char uint8_t; enum class Foo : uint8_t { A, B = 20 }; /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [], "usr2type": [{ "usr": 2010430204259339553, "detailed_name": "typedef unsigned char uint8_t", "qual_name_offset": 22, "short_name": "uint8_t", "spell": "1:23-1:30|1:1-1:30|2|-1", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 252, "parent_kind": 0, "declarations": [], "derived": [], "instances": [], "uses": [] }, { "usr": 16985894625255407295, "detailed_name": "enum class Foo : uint8_t {}", "qual_name_offset": 11, "short_name": "Foo", "spell": "2:12-2:15|2:1-5:2|2|-1", "bases": [], "funcs": [], "types": [], "vars": [{ "L": 439339022761937396, "R": -1 }, { "L": 15962370213938840720, "R": -1 }], "alias_of": 0, "kind": 10, "parent_kind": 0, "declarations": [], "derived": [], "instances": [], "uses": [] }], "usr2var": [{ "usr": 439339022761937396, "detailed_name": "Foo::A", "qual_name_offset": 0, "short_name": "A", "hover": "Foo::A = 0", "spell": "3:3-3:4|3:3-3:4|1026|-1", "type": 16985894625255407295, "kind": 22, "parent_kind": 10, "storage": 0, "declarations": [], "uses": [] }, { "usr": 15962370213938840720, "detailed_name": "Foo::B = 20", "qual_name_offset": 0, "short_name": "B", "spell": "4:3-4:4|4:3-4:9|1026|-1", "type": 16985894625255407295, "kind": 22, "parent_kind": 10, "storage": 0, "declarations": [], "uses": [] }] } */ ccls-0.20190823.6/index_tests/enums/enum_decl.cc000066400000000000000000000022401364776600300211460ustar00rootroot00000000000000enum Foo { A, B = 20 }; /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [], "usr2type": [{ "usr": 16985894625255407295, "detailed_name": "enum Foo {}", "qual_name_offset": 5, "short_name": "Foo", "spell": "1:6-1:9|1:1-4:2|2|-1", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 10, "parent_kind": 0, "declarations": [], "derived": [], "instances": [], "uses": [] }], "usr2var": [{ "usr": 439339022761937396, "detailed_name": "A", "qual_name_offset": 0, "short_name": "A", "hover": "A = 0", "spell": "2:3-2:4|2:3-2:4|1026|-1", "type": 16985894625255407295, "kind": 22, "parent_kind": 0, "storage": 0, "declarations": [], "uses": [] }, { "usr": 15962370213938840720, "detailed_name": "B = 20", "qual_name_offset": 0, "short_name": "B", "spell": "3:3-3:4|3:3-3:9|1026|-1", "type": 16985894625255407295, "kind": 22, "parent_kind": 0, "storage": 0, "declarations": [], "uses": [] }] } */ ccls-0.20190823.6/index_tests/enums/enum_inherit.cc000066400000000000000000000055261364776600300217130ustar00rootroot00000000000000enum Foo : int { A, B = 20 }; typedef int int32_t; enum class E : int32_t { E0, E20 = 20 }; /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [], "usr2type": [{ "usr": 2986879766914123941, "detailed_name": "enum class E : int32_t {}", "qual_name_offset": 11, "short_name": "E", "spell": "8:12-8:13|8:1-11:2|2|-1", "bases": [], "funcs": [], "types": [], "vars": [{ "L": 16614320383091394267, "R": -1 }, { "L": 16847439761518576294, "R": -1 }], "alias_of": 0, "kind": 10, "parent_kind": 0, "declarations": [], "derived": [], "instances": [], "uses": [] }, { "usr": 14939241684006947339, "detailed_name": "typedef int int32_t", "qual_name_offset": 12, "short_name": "int32_t", "spell": "6:13-6:20|6:1-6:20|2|-1", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 252, "parent_kind": 0, "declarations": [], "derived": [], "instances": [], "uses": [] }, { "usr": 16985894625255407295, "detailed_name": "enum Foo : int {}", "qual_name_offset": 5, "short_name": "Foo", "spell": "1:6-1:9|1:1-4:2|2|-1", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 10, "parent_kind": 0, "declarations": [], "derived": [], "instances": [], "uses": [] }], "usr2var": [{ "usr": 439339022761937396, "detailed_name": "A", "qual_name_offset": 0, "short_name": "A", "hover": "A = 0", "spell": "2:3-2:4|2:3-2:4|1026|-1", "type": 16985894625255407295, "kind": 22, "parent_kind": 0, "storage": 0, "declarations": [], "uses": [] }, { "usr": 15962370213938840720, "detailed_name": "B = 20", "qual_name_offset": 0, "short_name": "B", "spell": "3:3-3:4|3:3-3:9|1026|-1", "type": 16985894625255407295, "kind": 22, "parent_kind": 0, "storage": 0, "declarations": [], "uses": [] }, { "usr": 16614320383091394267, "detailed_name": "E::E0", "qual_name_offset": 0, "short_name": "E0", "hover": "E::E0 = 0", "spell": "9:3-9:5|9:3-9:5|1026|-1", "type": 2986879766914123941, "kind": 22, "parent_kind": 10, "storage": 0, "declarations": [], "uses": [] }, { "usr": 16847439761518576294, "detailed_name": "E::E20 = 20", "qual_name_offset": 0, "short_name": "E20", "spell": "10:3-10:6|10:3-10:11|1026|-1", "type": 2986879766914123941, "kind": 22, "parent_kind": 10, "storage": 0, "declarations": [], "uses": [] }] } */ ccls-0.20190823.6/index_tests/enums/enum_usage.cc000066400000000000000000000033661364776600300213550ustar00rootroot00000000000000enum class Foo { A, B = 20 }; Foo x = Foo::A; /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [], "usr2type": [{ "usr": 16985894625255407295, "detailed_name": "enum class Foo : int {}", "qual_name_offset": 11, "short_name": "Foo", "spell": "1:12-1:15|1:1-4:2|2|-1", "bases": [], "funcs": [], "types": [], "vars": [{ "L": 439339022761937396, "R": -1 }, { "L": 15962370213938840720, "R": -1 }], "alias_of": 0, "kind": 10, "parent_kind": 0, "declarations": [], "derived": [], "instances": [10677751717622394455], "uses": ["6:1-6:4|4|-1", "6:9-6:12|4|-1"] }], "usr2var": [{ "usr": 439339022761937396, "detailed_name": "Foo::A", "qual_name_offset": 0, "short_name": "A", "hover": "Foo::A = 0", "spell": "2:3-2:4|2:3-2:4|1026|-1", "type": 16985894625255407295, "kind": 22, "parent_kind": 10, "storage": 0, "declarations": [], "uses": ["6:14-6:15|4|-1"] }, { "usr": 10677751717622394455, "detailed_name": "Foo x", "qual_name_offset": 4, "short_name": "x", "hover": "Foo x = Foo::A", "spell": "6:5-6:6|6:1-6:15|2|-1", "type": 16985894625255407295, "kind": 13, "parent_kind": 0, "storage": 0, "declarations": [], "uses": [] }, { "usr": 15962370213938840720, "detailed_name": "Foo::B = 20", "qual_name_offset": 0, "short_name": "B", "spell": "3:3-3:4|3:3-3:9|1026|-1", "type": 16985894625255407295, "kind": 22, "parent_kind": 10, "storage": 0, "declarations": [], "uses": [] }] } */ ccls-0.20190823.6/index_tests/foobar.cc000066400000000000000000000050671364776600300173460ustar00rootroot00000000000000enum A {}; enum B {}; template struct Foo { struct Inner {}; }; Foo::Inner a; Foo b; /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [], "usr2type": [{ "usr": 6697181287623958829, "detailed_name": "enum A {}", "qual_name_offset": 5, "short_name": "A", "spell": "1:6-1:7|1:1-1:10|2|-1", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 10, "parent_kind": 0, "declarations": [], "derived": [], "instances": [], "uses": ["9:5-9:6|4|-1"] }, { "usr": 10528472276654770367, "detailed_name": "struct Foo {}", "qual_name_offset": 7, "short_name": "Foo", "spell": "5:8-5:11|5:1-7:2|2|-1", "bases": [], "funcs": [], "types": [13938528237873543349], "vars": [], "alias_of": 0, "kind": 23, "parent_kind": 0, "declarations": [], "derived": [], "instances": [12028309045033782423], "uses": ["9:1-9:4|4|-1", "10:1-10:4|4|-1"] }, { "usr": 13892793056005362145, "detailed_name": "enum B {}", "qual_name_offset": 5, "short_name": "B", "spell": "2:6-2:7|2:1-2:10|2|-1", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 10, "parent_kind": 0, "declarations": [], "derived": [], "instances": [], "uses": ["10:5-10:6|4|-1"] }, { "usr": 13938528237873543349, "detailed_name": "struct Foo::Inner {}", "qual_name_offset": 7, "short_name": "Inner", "spell": "6:10-6:15|6:3-6:18|1026|-1", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 23, "parent_kind": 23, "declarations": [], "derived": [], "instances": [16721564935990383768], "uses": ["9:9-9:14|4|-1"] }], "usr2var": [{ "usr": 12028309045033782423, "detailed_name": "Foo b", "qual_name_offset": 7, "short_name": "b", "spell": "10:8-10:9|10:1-10:9|2|-1", "type": 10528472276654770367, "kind": 13, "parent_kind": 0, "storage": 0, "declarations": [], "uses": [] }, { "usr": 16721564935990383768, "detailed_name": "Foo::Inner a", "qual_name_offset": 14, "short_name": "a", "spell": "9:15-9:16|9:1-9:16|2|-1", "type": 13938528237873543349, "kind": 13, "parent_kind": 0, "storage": 0, "declarations": [], "uses": [] }] } */ ccls-0.20190823.6/index_tests/function_declaration.cc000066400000000000000000000007521364776600300222640ustar00rootroot00000000000000void foo(int a, int b); /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [{ "usr": 2747674671862363334, "detailed_name": "void foo(int a, int b)", "qual_name_offset": 5, "short_name": "foo", "bases": [], "vars": [], "callees": [], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": ["1:6-1:9|1:1-1:23|1|-1"], "derived": [], "uses": [] }], "usr2type": [], "usr2var": [] } */ ccls-0.20190823.6/index_tests/function_declaration_definition.cc000066400000000000000000000010111364776600300244610ustar00rootroot00000000000000void foo(); void foo() {} /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [{ "usr": 4259594751088586730, "detailed_name": "void foo()", "qual_name_offset": 5, "short_name": "foo", "spell": "3:6-3:9|3:1-3:14|2|-1", "bases": [], "vars": [], "callees": [], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": ["1:6-1:9|1:1-1:11|1|-1"], "derived": [], "uses": [] }], "usr2type": [], "usr2var": [] } */ ccls-0.20190823.6/index_tests/function_definition.cc000066400000000000000000000007451364776600300221310ustar00rootroot00000000000000void foo() {} /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [{ "usr": 4259594751088586730, "detailed_name": "void foo()", "qual_name_offset": 5, "short_name": "foo", "spell": "1:6-1:9|1:1-1:14|2|-1", "bases": [], "vars": [], "callees": [], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": [], "derived": [], "uses": [] }], "usr2type": [], "usr2var": [] } */ ccls-0.20190823.6/index_tests/inheritance/000077500000000000000000000000001364776600300200505ustar00rootroot00000000000000ccls-0.20190823.6/index_tests/inheritance/class_inherit.cc000066400000000000000000000020411364776600300232030ustar00rootroot00000000000000class Parent {}; class Derived : public Parent {}; /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [], "usr2type": [{ "usr": 3866412049634585509, "detailed_name": "class Parent {}", "qual_name_offset": 6, "short_name": "Parent", "spell": "1:7-1:13|1:1-1:16|2|-1", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 5, "parent_kind": 0, "declarations": [], "derived": [10963370434658308541], "instances": [], "uses": ["2:24-2:30|2052|-1"] }, { "usr": 10963370434658308541, "detailed_name": "class Derived : public Parent {}", "qual_name_offset": 6, "short_name": "Derived", "spell": "2:7-2:14|2:1-2:33|2|-1", "bases": [3866412049634585509], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 5, "parent_kind": 0, "declarations": [], "derived": [], "instances": [], "uses": [] }], "usr2var": [] } */ ccls-0.20190823.6/index_tests/inheritance/class_inherit_templated_parent.cc000066400000000000000000000055741364776600300266310ustar00rootroot00000000000000template class Base1 {}; template class Base2 {}; template class Derived1 : Base1 {}; template class Derived2 : Base2 {}; class Derived : Base1<3>, Base2, Derived1<4>, Derived2 {}; /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [], "usr2type": [{ "usr": 5863733211528032190, "detailed_name": "class Derived1 : Base1 {}", "qual_name_offset": 6, "short_name": "Derived1", "spell": "8:7-8:15|8:1-8:29|2|-1", "bases": [11930058224338108382], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 5, "parent_kind": 0, "declarations": [], "derived": [10963370434658308541], "instances": [], "uses": ["13:43-13:51|2052|-1"] }, { "usr": 10651399730831737929, "detailed_name": "class Derived2 : Base2 {}", "qual_name_offset": 6, "short_name": "Derived2", "spell": "11:7-11:15|11:1-11:29|2|-1", "bases": [11118288764693061434], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 5, "parent_kind": 0, "declarations": [], "derived": [10963370434658308541], "instances": [], "uses": ["13:56-13:64|2052|-1"] }, { "usr": 10963370434658308541, "detailed_name": "class Derived : Base1<3>, Base2, Derived1<4>, Derived2 {}", "qual_name_offset": 6, "short_name": "Derived", "spell": "13:7-13:14|13:1-13:76|2|-1", "bases": [11930058224338108382, 11118288764693061434, 5863733211528032190, 10651399730831737929], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 5, "parent_kind": 0, "declarations": [], "derived": [], "instances": [], "uses": ["13:33-13:40|2052|-1", "13:65-13:72|2052|-1"] }, { "usr": 11118288764693061434, "detailed_name": "class Base2 {}", "qual_name_offset": 6, "short_name": "Base2", "spell": "5:7-5:12|5:1-5:15|2|-1", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 5, "parent_kind": 0, "declarations": [], "derived": [10651399730831737929, 10963370434658308541], "instances": [], "uses": ["11:18-11:23|2052|-1", "13:27-13:32|2052|-1"] }, { "usr": 11930058224338108382, "detailed_name": "class Base1 {}", "qual_name_offset": 6, "short_name": "Base1", "spell": "2:7-2:12|2:1-2:15|2|-1", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 5, "parent_kind": 0, "declarations": [], "derived": [5863733211528032190, 10963370434658308541], "instances": [], "uses": ["8:18-8:23|2052|-1", "13:17-13:22|2052|-1"] }], "usr2var": [] } */ ccls-0.20190823.6/index_tests/inheritance/class_multiple_inherit.cc000066400000000000000000000042071364776600300251240ustar00rootroot00000000000000class Root {}; class MiddleA : public Root {}; class MiddleB : public Root {}; class Derived : public MiddleA, public MiddleB {}; /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [], "usr2type": [{ "usr": 3897841498936210886, "detailed_name": "class Root {}", "qual_name_offset": 6, "short_name": "Root", "spell": "1:7-1:11|1:1-1:14|2|-1", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 5, "parent_kind": 0, "declarations": [], "derived": [11863524815063131483, 14022569716337624303], "instances": [], "uses": ["2:24-2:28|2052|-1", "3:24-3:28|2052|-1"] }, { "usr": 10963370434658308541, "detailed_name": "class Derived : public MiddleA, public MiddleB {}", "qual_name_offset": 6, "short_name": "Derived", "spell": "4:7-4:14|4:1-4:50|2|-1", "bases": [11863524815063131483, 14022569716337624303], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 5, "parent_kind": 0, "declarations": [], "derived": [], "instances": [], "uses": [] }, { "usr": 11863524815063131483, "detailed_name": "class MiddleA : public Root {}", "qual_name_offset": 6, "short_name": "MiddleA", "spell": "2:7-2:14|2:1-2:31|2|-1", "bases": [3897841498936210886], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 5, "parent_kind": 0, "declarations": [], "derived": [10963370434658308541], "instances": [], "uses": ["4:24-4:31|2052|-1"] }, { "usr": 14022569716337624303, "detailed_name": "class MiddleB : public Root {}", "qual_name_offset": 6, "short_name": "MiddleB", "spell": "3:7-3:14|3:1-3:31|2|-1", "bases": [3897841498936210886], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 5, "parent_kind": 0, "declarations": [], "derived": [10963370434658308541], "instances": [], "uses": ["4:40-4:47|2052|-1"] }], "usr2var": [] } */ ccls-0.20190823.6/index_tests/inheritance/function_override.cc000066400000000000000000000035561364776600300241140ustar00rootroot00000000000000class Root { virtual void foo(); }; class Derived : public Root { void foo() override {} }; /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [{ "usr": 6666242542855173890, "detailed_name": "void Derived::foo()", "qual_name_offset": 5, "short_name": "foo", "spell": "5:8-5:11|5:3-5:25|5186|-1", "bases": [9948027785633571339], "vars": [], "callees": [], "kind": 6, "parent_kind": 5, "storage": 0, "declarations": [], "derived": [], "uses": [] }, { "usr": 9948027785633571339, "detailed_name": "virtual void Root::foo()", "qual_name_offset": 13, "short_name": "foo", "bases": [], "vars": [], "callees": [], "kind": 6, "parent_kind": 0, "storage": 0, "declarations": ["2:16-2:19|2:3-2:21|1089|-1"], "derived": [6666242542855173890], "uses": [] }], "usr2type": [{ "usr": 3897841498936210886, "detailed_name": "class Root {}", "qual_name_offset": 6, "short_name": "Root", "spell": "1:7-1:11|1:1-3:2|2|-1", "bases": [], "funcs": [9948027785633571339], "types": [], "vars": [], "alias_of": 0, "kind": 5, "parent_kind": 0, "declarations": [], "derived": [10963370434658308541], "instances": [], "uses": ["4:24-4:28|2052|-1"] }, { "usr": 10963370434658308541, "detailed_name": "class Derived : public Root {}", "qual_name_offset": 6, "short_name": "Derived", "spell": "4:7-4:14|4:1-6:2|2|-1", "bases": [3897841498936210886], "funcs": [6666242542855173890], "types": [], "vars": [], "alias_of": 0, "kind": 5, "parent_kind": 0, "declarations": [], "derived": [], "instances": [], "uses": [] }], "usr2var": [] } */ ccls-0.20190823.6/index_tests/inheritance/interface_pure_virtual.cc000066400000000000000000000016541364776600300251260ustar00rootroot00000000000000class IFoo { virtual void foo() = 0; }; /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [{ "usr": 3277829753446788562, "detailed_name": "virtual void IFoo::foo() = 0", "qual_name_offset": 13, "short_name": "foo", "bases": [], "vars": [], "callees": [], "kind": 6, "parent_kind": 0, "storage": 0, "declarations": ["2:16-2:19|2:3-2:25|1089|-1"], "derived": [], "uses": [] }], "usr2type": [{ "usr": 9949214233977131946, "detailed_name": "class IFoo {}", "qual_name_offset": 6, "short_name": "IFoo", "spell": "1:7-1:11|1:1-3:2|2|-1", "bases": [], "funcs": [3277829753446788562], "types": [], "vars": [], "alias_of": 0, "kind": 5, "parent_kind": 0, "declarations": [], "derived": [], "instances": [], "uses": [] }], "usr2var": [] } */ ccls-0.20190823.6/index_tests/inheritance/multiple_base_functions.cc000066400000000000000000000055201364776600300252760ustar00rootroot00000000000000struct Base0 { virtual ~Base0() { } }; struct Base1 { virtual ~Base1() { } }; struct Derived : Base0, Base1 { ~Derived() override { } }; /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [{ "usr": 8401779086123965305, "detailed_name": "virtual Base1::~Base1() noexcept", "qual_name_offset": 8, "short_name": "~Base1", "spell": "5:11-5:17|5:3-5:23|1090|-1", "bases": [], "vars": [], "callees": [], "kind": 6, "parent_kind": 23, "storage": 0, "declarations": [], "derived": [], "uses": [] }, { "usr": 13164726294460837993, "detailed_name": "Derived::~Derived() noexcept", "qual_name_offset": 0, "short_name": "~Derived", "spell": "8:3-8:11|8:3-8:26|5186|-1", "bases": [], "vars": [], "callees": [], "kind": 6, "parent_kind": 23, "storage": 0, "declarations": [], "derived": [], "uses": [] }, { "usr": 16347272523198263017, "detailed_name": "virtual Base0::~Base0() noexcept", "qual_name_offset": 8, "short_name": "~Base0", "spell": "2:11-2:17|2:3-2:23|1090|-1", "bases": [], "vars": [], "callees": [], "kind": 6, "parent_kind": 23, "storage": 0, "declarations": [], "derived": [], "uses": [] }], "usr2type": [{ "usr": 10963370434658308541, "detailed_name": "struct Derived : Base0, Base1 {}", "qual_name_offset": 7, "short_name": "Derived", "spell": "7:8-7:15|7:1-9:2|2|-1", "bases": [11628904180681204356, 15826803741381445676], "funcs": [13164726294460837993], "types": [], "vars": [], "alias_of": 0, "kind": 23, "parent_kind": 0, "declarations": [], "derived": [], "instances": [], "uses": ["8:4-8:11|4|-1"] }, { "usr": 11628904180681204356, "detailed_name": "struct Base0 {}", "qual_name_offset": 7, "short_name": "Base0", "spell": "1:8-1:13|1:1-3:2|2|-1", "bases": [], "funcs": [16347272523198263017], "types": [], "vars": [], "alias_of": 0, "kind": 23, "parent_kind": 0, "declarations": [], "derived": [10963370434658308541], "instances": [], "uses": ["2:12-2:17|4|-1", "7:18-7:23|2052|-1"] }, { "usr": 15826803741381445676, "detailed_name": "struct Base1 {}", "qual_name_offset": 7, "short_name": "Base1", "spell": "4:8-4:13|4:1-6:2|2|-1", "bases": [], "funcs": [8401779086123965305], "types": [], "vars": [], "alias_of": 0, "kind": 23, "parent_kind": 0, "declarations": [], "derived": [10963370434658308541], "instances": [], "uses": ["5:12-5:17|4|-1", "7:25-7:30|2052|-1"] }], "usr2var": [] } */ccls-0.20190823.6/index_tests/lambdas/000077500000000000000000000000001364776600300171625ustar00rootroot00000000000000ccls-0.20190823.6/index_tests/lambdas/lambda.cc000066400000000000000000000056661364776600300207260ustar00rootroot00000000000000void foo() { int x; auto dosomething = [&x](int y) { ++x; ++y; }; dosomething(1); dosomething(1); dosomething(1); } /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [{ "usr": 4259594751088586730, "detailed_name": "void foo()", "qual_name_offset": 5, "short_name": "foo", "spell": "1:6-1:9|1:1-12:2|2|-1", "bases": [], "vars": [12666114896600231317, 2981279427664991319], "callees": ["9:14-9:15|17926497908620168464|3|16420", "10:14-10:15|17926497908620168464|3|16420", "11:14-11:15|17926497908620168464|3|16420"], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": [], "derived": [], "uses": [] }, { "usr": 17926497908620168464, "detailed_name": "inline void foo()::(anon class)::operator()(int y) const", "qual_name_offset": 12, "short_name": "operator()", "bases": [], "vars": [], "callees": [], "kind": 6, "parent_kind": 0, "storage": 0, "declarations": [], "derived": [], "uses": ["9:14-9:15|16420|-1", "10:14-10:15|16420|-1", "11:14-11:15|16420|-1"] }], "usr2type": [{ "usr": 53, "detailed_name": "", "qual_name_offset": 0, "short_name": "", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 0, "parent_kind": 0, "declarations": [], "derived": [], "instances": [12666114896600231317], "uses": [] }, { "usr": 14635009347499519042, "detailed_name": "", "qual_name_offset": 0, "short_name": "", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 0, "parent_kind": 0, "declarations": [], "derived": [], "instances": [2981279427664991319], "uses": [] }], "usr2var": [{ "usr": 2981279427664991319, "detailed_name": "(lambda) dosomething", "qual_name_offset": 9, "short_name": "dosomething", "hover": "(lambda) dosomething", "spell": "4:8-4:19|4:3-7:4|2|-1", "type": 14635009347499519042, "kind": 13, "parent_kind": 12, "storage": 0, "declarations": [], "uses": ["9:3-9:14|4|-1", "10:3-10:14|4|-1", "11:3-11:14|4|-1"] }, { "usr": 12666114896600231317, "detailed_name": "int x", "qual_name_offset": 4, "short_name": "x", "spell": "2:7-2:8|2:3-2:8|2|-1", "type": 53, "kind": 13, "parent_kind": 12, "storage": 0, "declarations": [], "uses": ["4:24-4:25|4|-1", "5:7-5:8|28|-1"] }, { "usr": 12879188959314906706, "detailed_name": "int y", "qual_name_offset": 4, "short_name": "y", "spell": "4:31-4:32|4:27-4:32|2|-1", "type": 0, "kind": 253, "parent_kind": 6, "storage": 0, "declarations": [], "uses": ["6:7-6:8|28|-1"] }] } */ ccls-0.20190823.6/index_tests/macros/000077500000000000000000000000001364776600300170435ustar00rootroot00000000000000ccls-0.20190823.6/index_tests/macros/complex.cc000066400000000000000000000043051364776600300210230ustar00rootroot00000000000000#define FOO(aaa, bbb) \ int a();\ int a() { return aaa + bbb; } int make1() { return 3; } const int make2 = 5; FOO(make1(), make2); /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [{ "usr": 9720930732776154610, "detailed_name": "int a()", "qual_name_offset": 4, "short_name": "a", "spell": "12:1-12:20|12:1-12:4|2|-1", "bases": [], "vars": [], "callees": ["12:5-12:10|14400399977994209582|3|16420"], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": ["12:1-12:20|12:1-12:4|1|-1"], "derived": [], "uses": ["2:7-2:8|64|0", "3:7-3:8|64|0"] }, { "usr": 14400399977994209582, "detailed_name": "int make1()", "qual_name_offset": 4, "short_name": "make1", "spell": "6:5-6:10|6:1-8:2|2|-1", "bases": [], "vars": [], "callees": [], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": [], "derived": [], "uses": ["12:5-12:10|16420|-1", "12:5-12:10|64|0"] }], "usr2type": [{ "usr": 53, "detailed_name": "", "qual_name_offset": 0, "short_name": "", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 0, "parent_kind": 0, "declarations": [], "derived": [], "instances": [2878407290385495202], "uses": [] }], "usr2var": [{ "usr": 2878407290385495202, "detailed_name": "const int make2", "qual_name_offset": 10, "short_name": "make2", "hover": "const int make2 = 5", "spell": "9:11-9:16|9:1-9:20|2|-1", "type": 53, "kind": 13, "parent_kind": 0, "storage": 0, "declarations": [], "uses": ["12:14-12:19|12|-1", "12:14-12:19|64|0"] }, { "usr": 14219599523415845943, "detailed_name": "FOO", "qual_name_offset": 0, "short_name": "FOO", "hover": "#define FOO(aaa, bbb) \\\n int a();\\\n int a() { return aaa + bbb; }", "spell": "1:9-1:12|1:9-3:32|2|-1", "type": 0, "kind": 255, "parent_kind": 1, "storage": 0, "declarations": [], "uses": ["12:1-12:4|64|-1"] }] } */ccls-0.20190823.6/index_tests/macros/foo.cc000066400000000000000000000046301364776600300201400ustar00rootroot00000000000000#define A 5 #define DISALLOW(type) type(type&&) = delete; struct Foo { DISALLOW(Foo); }; int x = A; /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [{ "usr": 13788753348312146871, "detailed_name": "Foo::Foo(Foo &&) = delete", "qual_name_offset": 0, "short_name": "Foo", "spell": "5:12-5:15|5:3-5:11|1026|-1", "bases": [], "vars": [], "callees": [], "kind": 9, "parent_kind": 23, "storage": 0, "declarations": [], "derived": [], "uses": ["5:12-5:15|64|0"] }], "usr2type": [{ "usr": 53, "detailed_name": "", "qual_name_offset": 0, "short_name": "", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 0, "parent_kind": 0, "declarations": [], "derived": [], "instances": [10677751717622394455], "uses": [] }, { "usr": 15041163540773201510, "detailed_name": "struct Foo {}", "qual_name_offset": 7, "short_name": "Foo", "spell": "4:8-4:11|4:1-6:2|2|-1", "bases": [], "funcs": [13788753348312146871], "types": [], "vars": [], "alias_of": 0, "kind": 23, "parent_kind": 0, "declarations": [], "derived": [], "instances": [], "uses": ["5:12-5:15|4|-1", "5:12-5:15|64|0"] }], "usr2var": [{ "usr": 1569772797058982873, "detailed_name": "A", "qual_name_offset": 0, "short_name": "A", "hover": "#define A 5", "spell": "1:9-1:10|1:9-1:12|2|-1", "type": 0, "kind": 255, "parent_kind": 1, "storage": 0, "declarations": [], "uses": ["8:9-8:10|64|-1"] }, { "usr": 4904139678698066671, "detailed_name": "DISALLOW", "qual_name_offset": 0, "short_name": "DISALLOW", "hover": "#define DISALLOW(type) type(type&&) = delete;", "spell": "2:9-2:17|2:9-2:46|2|-1", "type": 0, "kind": 255, "parent_kind": 1, "storage": 0, "declarations": [], "uses": ["5:3-5:11|64|-1"] }, { "usr": 10677751717622394455, "detailed_name": "int x", "qual_name_offset": 4, "short_name": "x", "hover": "int x = A", "spell": "8:5-8:6|8:1-8:10|2|-1", "type": 53, "kind": 13, "parent_kind": 0, "storage": 0, "declarations": [], "uses": [] }] } */ ccls-0.20190823.6/index_tests/method_declaration.cc000066400000000000000000000021741364776600300217170ustar00rootroot00000000000000class Foo { void foo(); }; /* // NOTE: Lack of declaring_type in functions and funcs in Foo is okay, because // those are processed when we find the definition for Foo::foo. Pure // virtuals are treated specially and get added to the type immediately. OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [{ "usr": 17922201480358737771, "detailed_name": "void Foo::foo()", "qual_name_offset": 5, "short_name": "foo", "bases": [], "vars": [], "callees": [], "kind": 6, "parent_kind": 0, "storage": 0, "declarations": ["2:8-2:11|2:3-2:13|1025|-1"], "derived": [], "uses": [] }], "usr2type": [{ "usr": 15041163540773201510, "detailed_name": "class Foo {}", "qual_name_offset": 6, "short_name": "Foo", "spell": "1:7-1:10|1:1-3:2|2|-1", "bases": [], "funcs": [17922201480358737771], "types": [], "vars": [], "alias_of": 0, "kind": 5, "parent_kind": 0, "declarations": [], "derived": [], "instances": [], "uses": [] }], "usr2var": [] } */ ccls-0.20190823.6/index_tests/method_definition.cc000066400000000000000000000017601364776600300215620ustar00rootroot00000000000000class Foo { void foo() const; }; void Foo::foo() const {} /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [{ "usr": 6446764306530590711, "detailed_name": "void Foo::foo() const", "qual_name_offset": 5, "short_name": "foo", "spell": "5:11-5:14|5:1-5:25|1026|-1", "bases": [], "vars": [], "callees": [], "kind": 6, "parent_kind": 5, "storage": 0, "declarations": ["2:8-2:11|2:3-2:19|1025|-1"], "derived": [], "uses": [] }], "usr2type": [{ "usr": 15041163540773201510, "detailed_name": "class Foo {}", "qual_name_offset": 6, "short_name": "Foo", "spell": "1:7-1:10|1:1-3:2|2|-1", "bases": [], "funcs": [6446764306530590711], "types": [], "vars": [], "alias_of": 0, "kind": 5, "parent_kind": 0, "declarations": [], "derived": [], "instances": [], "uses": ["5:6-5:9|4|-1"] }], "usr2var": [] } */ ccls-0.20190823.6/index_tests/method_inline_declaration.cc000066400000000000000000000016441364776600300232560ustar00rootroot00000000000000class Foo { void foo() {} }; /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [{ "usr": 17922201480358737771, "detailed_name": "void Foo::foo()", "qual_name_offset": 5, "short_name": "foo", "spell": "2:8-2:11|2:3-2:16|1026|-1", "bases": [], "vars": [], "callees": [], "kind": 6, "parent_kind": 5, "storage": 0, "declarations": [], "derived": [], "uses": [] }], "usr2type": [{ "usr": 15041163540773201510, "detailed_name": "class Foo {}", "qual_name_offset": 6, "short_name": "Foo", "spell": "1:7-1:10|1:1-3:2|2|-1", "bases": [], "funcs": [17922201480358737771], "types": [], "vars": [], "alias_of": 0, "kind": 5, "parent_kind": 0, "declarations": [], "derived": [], "instances": [], "uses": [] }], "usr2var": [] } */ ccls-0.20190823.6/index_tests/multi_file/000077500000000000000000000000001364776600300177105ustar00rootroot00000000000000ccls-0.20190823.6/index_tests/multi_file/funky_enum.cc000066400000000000000000000041761364776600300224070ustar00rootroot00000000000000enum Foo { #include "funky_enum.h" }; /* // TODO: In the future try to have better support for types defined across // multiple files. OUTPUT: funky_enum.h { "includes": [], "skipped_ranges": [], "usr2func": [], "usr2type": [], "usr2var": [{ "usr": 439339022761937396, "detailed_name": "A", "qual_name_offset": 0, "short_name": "A", "hover": "A = 0", "comments": "This file cannot be built directory. It is included in an enum definition of\nanother file.", "spell": "4:1-4:2|4:1-4:2|1026|-1", "type": 16985894625255407295, "kind": 22, "parent_kind": 0, "storage": 0, "declarations": [], "uses": [] }, { "usr": 8524995777615948802, "detailed_name": "C", "qual_name_offset": 0, "short_name": "C", "hover": "C = 2", "comments": "This file cannot be built directory. It is included in an enum definition of\nanother file.", "spell": "6:1-6:2|6:1-6:2|1026|-1", "type": 16985894625255407295, "kind": 22, "parent_kind": 0, "storage": 0, "declarations": [], "uses": [] }, { "usr": 15962370213938840720, "detailed_name": "B", "qual_name_offset": 0, "short_name": "B", "hover": "B = 1", "comments": "This file cannot be built directory. It is included in an enum definition of\nanother file.", "spell": "5:1-5:2|5:1-5:2|1026|-1", "type": 16985894625255407295, "kind": 22, "parent_kind": 0, "storage": 0, "declarations": [], "uses": [] }] } OUTPUT: funky_enum.cc { "includes": [{ "line": 1, "resolved_path": "&funky_enum.h" }], "skipped_ranges": [], "usr2func": [], "usr2type": [{ "usr": 16985894625255407295, "detailed_name": "enum Foo {}", "qual_name_offset": 5, "short_name": "Foo", "spell": "1:6-1:9|1:1-3:2|2|-1", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 10, "parent_kind": 0, "declarations": [], "derived": [], "instances": [], "uses": [] }], "usr2var": [] } */ccls-0.20190823.6/index_tests/multi_file/funky_enum.h000066400000000000000000000001521364776600300222370ustar00rootroot00000000000000// This file cannot be built directory. It is included in an enum definition of // another file. A, B, C ccls-0.20190823.6/index_tests/multi_file/header.h000066400000000000000000000003401364776600300213060ustar00rootroot00000000000000#pragma once struct Base {}; struct SameFileDerived : Base {}; using Foo0 = SameFileDerived; template void Foo1() {} template struct Foo2 {}; enum Foo3 { A, B, C }; int Foo4; static int Foo5;ccls-0.20190823.6/index_tests/multi_file/impl.cc000066400000000000000000000127721364776600300211710ustar00rootroot00000000000000#include "header.h" void Impl() { Foo1(); } /* OUTPUT: header.h { "includes": [], "skipped_ranges": [], "usr2func": [{ "usr": 11650481237659640387, "detailed_name": "void Foo1()", "qual_name_offset": 5, "short_name": "Foo1", "spell": "10:6-10:10|10:1-10:15|2|-1", "bases": [], "vars": [], "callees": [], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": [], "derived": [], "uses": [] }], "usr2type": [{ "usr": 53, "detailed_name": "", "qual_name_offset": 0, "short_name": "", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 0, "parent_kind": 0, "declarations": [], "derived": [], "instances": [2638219001294786365, 8395885290297540138], "uses": [] }, { "usr": 529393482671181129, "detailed_name": "struct Foo2 {}", "qual_name_offset": 7, "short_name": "Foo2", "spell": "13:8-13:12|13:1-13:15|2|-1", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 23, "parent_kind": 0, "declarations": [], "derived": [], "instances": [], "uses": [] }, { "usr": 619345544228965342, "detailed_name": "using Foo0 = SameFileDerived", "qual_name_offset": 6, "short_name": "Foo0", "spell": "7:7-7:11|7:1-7:29|2|-1", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 16750616846959666305, "kind": 252, "parent_kind": 0, "declarations": [], "derived": [], "instances": [], "uses": [] }, { "usr": 4481210672785600703, "detailed_name": "enum Foo3 {}", "qual_name_offset": 5, "short_name": "Foo3", "spell": "15:6-15:10|15:1-15:22|2|-1", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 10, "parent_kind": 0, "declarations": [], "derived": [], "instances": [], "uses": [] }, { "usr": 8420119006782424779, "detailed_name": "struct Base {}", "qual_name_offset": 7, "short_name": "Base", "spell": "3:8-3:12|3:1-3:15|2|-1", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 23, "parent_kind": 0, "declarations": [], "derived": [16750616846959666305], "instances": [], "uses": ["5:26-5:30|2052|-1"] }, { "usr": 16750616846959666305, "detailed_name": "struct SameFileDerived : Base {}", "qual_name_offset": 7, "short_name": "SameFileDerived", "spell": "5:8-5:23|5:1-5:33|2|-1", "bases": [8420119006782424779], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 23, "parent_kind": 0, "declarations": [], "derived": [], "instances": [], "uses": ["7:14-7:29|4|-1"] }], "usr2var": [{ "usr": 2638219001294786365, "detailed_name": "int Foo4", "qual_name_offset": 4, "short_name": "Foo4", "spell": "17:5-17:9|17:1-17:9|2|-1", "type": 53, "kind": 13, "parent_kind": 0, "storage": 0, "declarations": [], "uses": [] }, { "usr": 6141718166919284735, "detailed_name": "A", "qual_name_offset": 0, "short_name": "A", "hover": "A = 0", "spell": "15:13-15:14|15:13-15:14|1026|-1", "type": 4481210672785600703, "kind": 22, "parent_kind": 0, "storage": 0, "declarations": [], "uses": [] }, { "usr": 7285646116511901840, "detailed_name": "C", "qual_name_offset": 0, "short_name": "C", "hover": "C = 2", "spell": "15:19-15:20|15:19-15:20|1026|-1", "type": 4481210672785600703, "kind": 22, "parent_kind": 0, "storage": 0, "declarations": [], "uses": [] }, { "usr": 8395885290297540138, "detailed_name": "static int Foo5", "qual_name_offset": 11, "short_name": "Foo5", "spell": "18:12-18:16|18:1-18:16|2|-1", "type": 53, "kind": 13, "parent_kind": 0, "storage": 2, "declarations": [], "uses": [] }, { "usr": 17716334512218775320, "detailed_name": "B", "qual_name_offset": 0, "short_name": "B", "hover": "B = 1", "spell": "15:16-15:17|15:16-15:17|1026|-1", "type": 4481210672785600703, "kind": 22, "parent_kind": 0, "storage": 0, "declarations": [], "uses": [] }] } OUTPUT: impl.cc { "includes": [{ "line": 0, "resolved_path": "&header.h" }], "skipped_ranges": [], "usr2func": [{ "usr": 5817708529036841195, "detailed_name": "void Impl()", "qual_name_offset": 5, "short_name": "Impl", "spell": "3:6-3:10|3:1-5:2|2|-1", "bases": [], "vars": [], "callees": ["4:3-4:7|11650481237659640387|3|16420"], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": [], "derived": [], "uses": [] }, { "usr": 11650481237659640387, "detailed_name": "void Foo1()", "qual_name_offset": 5, "short_name": "Foo1", "bases": [], "vars": [], "callees": [], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": [], "derived": [], "uses": ["4:3-4:7|16420|-1"] }], "usr2type": [], "usr2var": [] } */ ccls-0.20190823.6/index_tests/multi_file/simple_header.h000066400000000000000000000000341364776600300226570ustar00rootroot00000000000000#pragma once void header();ccls-0.20190823.6/index_tests/multi_file/simple_impl.cc000066400000000000000000000026701364776600300225360ustar00rootroot00000000000000#include "simple_header.h" void impl() { header(); } /* OUTPUT: simple_header.h { "includes": [], "skipped_ranges": [], "usr2func": [{ "usr": 16236105532929924676, "detailed_name": "void header()", "qual_name_offset": 5, "short_name": "header", "bases": [], "vars": [], "callees": [], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": ["3:6-3:12|3:1-3:14|1|-1"], "derived": [], "uses": [] }], "usr2type": [], "usr2var": [] } OUTPUT: simple_impl.cc { "includes": [{ "line": 0, "resolved_path": "&simple_header.h" }], "skipped_ranges": [], "usr2func": [{ "usr": 3373269392705484958, "detailed_name": "void impl()", "qual_name_offset": 5, "short_name": "impl", "spell": "3:6-3:10|3:1-5:2|2|-1", "bases": [], "vars": [], "callees": ["4:3-4:9|16236105532929924676|3|16420"], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": [], "derived": [], "uses": [] }, { "usr": 16236105532929924676, "detailed_name": "void header()", "qual_name_offset": 5, "short_name": "header", "bases": [], "vars": [], "callees": [], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": [], "derived": [], "uses": ["4:3-4:9|16420|-1"] }], "usr2type": [], "usr2var": [] } */ ccls-0.20190823.6/index_tests/multi_file/static.cc000066400000000000000000000037071364776600300215150ustar00rootroot00000000000000#include "static.h" void Buffer::CreateSharedBuffer() {} /* OUTPUT: static.h { "includes": [], "skipped_ranges": [], "usr2func": [{ "usr": 14576076421851654759, "detailed_name": "static void Buffer::CreateSharedBuffer()", "qual_name_offset": 12, "short_name": "CreateSharedBuffer", "bases": [], "vars": [], "callees": [], "kind": 254, "parent_kind": 0, "storage": 0, "declarations": ["4:15-4:33|4:3-4:35|1025|-1"], "derived": [], "uses": [] }], "usr2type": [{ "usr": 9411323049603567600, "detailed_name": "struct Buffer {}", "qual_name_offset": 7, "short_name": "Buffer", "spell": "3:8-3:14|3:1-5:2|2|-1", "bases": [], "funcs": [14576076421851654759], "types": [], "vars": [], "alias_of": 0, "kind": 23, "parent_kind": 0, "declarations": [], "derived": [], "instances": [], "uses": [] }], "usr2var": [] } OUTPUT: static.cc { "includes": [{ "line": 0, "resolved_path": "&static.h" }], "skipped_ranges": [], "usr2func": [{ "usr": 14576076421851654759, "detailed_name": "static void Buffer::CreateSharedBuffer()", "qual_name_offset": 12, "short_name": "CreateSharedBuffer", "spell": "3:14-3:32|3:1-3:37|1026|-1", "bases": [], "vars": [], "callees": [], "kind": 254, "parent_kind": 23, "storage": 0, "declarations": [], "derived": [], "uses": [] }], "usr2type": [{ "usr": 9411323049603567600, "detailed_name": "struct Buffer {}", "qual_name_offset": 7, "short_name": "Buffer", "bases": [], "funcs": [14576076421851654759], "types": [], "vars": [], "alias_of": 0, "kind": 23, "parent_kind": 0, "declarations": [], "derived": [], "instances": [], "uses": ["3:6-3:12|4|-1"] }], "usr2var": [] } */ccls-0.20190823.6/index_tests/multi_file/static.h000066400000000000000000000001051364776600300213440ustar00rootroot00000000000000#pragma once struct Buffer { static void CreateSharedBuffer(); }; ccls-0.20190823.6/index_tests/namespaces/000077500000000000000000000000001364776600300176765ustar00rootroot00000000000000ccls-0.20190823.6/index_tests/namespaces/anonymous_function.cc000066400000000000000000000007531364776600300241470ustar00rootroot00000000000000namespace { void foo(); } /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [{ "usr": 5010253035933134245, "detailed_name": "void (anon ns)::foo()", "qual_name_offset": 5, "short_name": "foo", "bases": [], "vars": [], "callees": [], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": ["2:6-2:9|2:1-2:11|1|-1"], "derived": [], "uses": [] }], "usr2type": [], "usr2var": [] } */ ccls-0.20190823.6/index_tests/namespaces/function_declaration.cc000066400000000000000000000016461364776600300244060ustar00rootroot00000000000000namespace hello { void foo(int a, int b); } /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [{ "usr": 18343102288837190527, "detailed_name": "void hello::foo(int a, int b)", "qual_name_offset": 5, "short_name": "foo", "bases": [], "vars": [], "callees": [], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": ["2:6-2:9|2:1-2:23|1025|-1"], "derived": [], "uses": [] }], "usr2type": [{ "usr": 2029211996748007610, "detailed_name": "namespace hello {}", "qual_name_offset": 10, "short_name": "hello", "bases": [], "funcs": [18343102288837190527], "types": [], "vars": [], "alias_of": 0, "kind": 3, "parent_kind": 0, "declarations": ["1:11-1:16|1:1-3:2|1|-1"], "derived": [], "instances": [], "uses": [] }], "usr2var": [] } */ ccls-0.20190823.6/index_tests/namespaces/function_definition.cc000066400000000000000000000016351364776600300242470ustar00rootroot00000000000000namespace hello { void foo() {} } /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [{ "usr": 243328841292951622, "detailed_name": "void hello::foo()", "qual_name_offset": 5, "short_name": "foo", "spell": "2:6-2:9|2:1-2:14|1026|-1", "bases": [], "vars": [], "callees": [], "kind": 12, "parent_kind": 3, "storage": 0, "declarations": [], "derived": [], "uses": [] }], "usr2type": [{ "usr": 2029211996748007610, "detailed_name": "namespace hello {}", "qual_name_offset": 10, "short_name": "hello", "bases": [], "funcs": [243328841292951622], "types": [], "vars": [], "alias_of": 0, "kind": 3, "parent_kind": 0, "declarations": ["1:11-1:16|1:1-3:2|1|-1"], "derived": [], "instances": [], "uses": [] }], "usr2var": [] } */ ccls-0.20190823.6/index_tests/namespaces/method_declaration.cc000066400000000000000000000025231364776600300240340ustar00rootroot00000000000000namespace hello { class Foo { void foo(); }; } /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [{ "usr": 10487325150128053272, "detailed_name": "void hello::Foo::foo()", "qual_name_offset": 5, "short_name": "foo", "bases": [], "vars": [], "callees": [], "kind": 6, "parent_kind": 0, "storage": 0, "declarations": ["3:8-3:11|3:3-3:13|1025|-1"], "derived": [], "uses": [] }], "usr2type": [{ "usr": 2029211996748007610, "detailed_name": "namespace hello {}", "qual_name_offset": 10, "short_name": "hello", "bases": [], "funcs": [], "types": [4508214972876735896], "vars": [], "alias_of": 0, "kind": 3, "parent_kind": 0, "declarations": ["1:11-1:16|1:1-5:2|1|-1"], "derived": [], "instances": [], "uses": [] }, { "usr": 4508214972876735896, "detailed_name": "class hello::Foo {}", "qual_name_offset": 6, "short_name": "Foo", "spell": "2:7-2:10|2:1-4:2|1026|-1", "bases": [], "funcs": [10487325150128053272], "types": [], "vars": [], "alias_of": 0, "kind": 5, "parent_kind": 3, "declarations": [], "derived": [], "instances": [], "uses": [] }], "usr2var": [] } */ ccls-0.20190823.6/index_tests/namespaces/method_definition.cc000066400000000000000000000026421364776600300237010ustar00rootroot00000000000000namespace hello { class Foo { void foo(); }; void Foo::foo() {} } /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [{ "usr": 10487325150128053272, "detailed_name": "void hello::Foo::foo()", "qual_name_offset": 5, "short_name": "foo", "spell": "6:11-6:14|6:1-6:19|1026|-1", "bases": [], "vars": [], "callees": [], "kind": 6, "parent_kind": 5, "storage": 0, "declarations": ["3:8-3:11|3:3-3:13|1025|-1"], "derived": [], "uses": [] }], "usr2type": [{ "usr": 2029211996748007610, "detailed_name": "namespace hello {}", "qual_name_offset": 10, "short_name": "hello", "bases": [], "funcs": [], "types": [4508214972876735896], "vars": [], "alias_of": 0, "kind": 3, "parent_kind": 0, "declarations": ["1:11-1:16|1:1-7:2|1|-1"], "derived": [], "instances": [], "uses": [] }, { "usr": 4508214972876735896, "detailed_name": "class hello::Foo {}", "qual_name_offset": 6, "short_name": "Foo", "spell": "2:7-2:10|2:1-4:2|1026|-1", "bases": [], "funcs": [10487325150128053272], "types": [], "vars": [], "alias_of": 0, "kind": 5, "parent_kind": 3, "declarations": [], "derived": [], "instances": [], "uses": ["6:6-6:9|4|-1"] }], "usr2var": [] } */ ccls-0.20190823.6/index_tests/namespaces/method_inline_declaration.cc000066400000000000000000000025461364776600300253770ustar00rootroot00000000000000namespace hello { class Foo { void foo() {} }; } /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [{ "usr": 10487325150128053272, "detailed_name": "void hello::Foo::foo()", "qual_name_offset": 5, "short_name": "foo", "spell": "3:8-3:11|3:3-3:16|1026|-1", "bases": [], "vars": [], "callees": [], "kind": 6, "parent_kind": 5, "storage": 0, "declarations": [], "derived": [], "uses": [] }], "usr2type": [{ "usr": 2029211996748007610, "detailed_name": "namespace hello {}", "qual_name_offset": 10, "short_name": "hello", "bases": [], "funcs": [], "types": [4508214972876735896], "vars": [], "alias_of": 0, "kind": 3, "parent_kind": 0, "declarations": ["1:11-1:16|1:1-5:2|1|-1"], "derived": [], "instances": [], "uses": [] }, { "usr": 4508214972876735896, "detailed_name": "class hello::Foo {}", "qual_name_offset": 6, "short_name": "Foo", "spell": "2:7-2:10|2:1-4:2|1026|-1", "bases": [], "funcs": [10487325150128053272], "types": [], "vars": [], "alias_of": 0, "kind": 5, "parent_kind": 3, "declarations": [], "derived": [], "instances": [], "uses": [] }], "usr2var": [] } */ ccls-0.20190823.6/index_tests/namespaces/namespace_alias.cc000066400000000000000000000100341364776600300233100ustar00rootroot00000000000000namespace foo { namespace bar { namespace baz { int qux = 42; } } } namespace fbz = foo::bar::baz; void func() { int a = foo::bar::baz::qux; int b = fbz::qux; } /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [{ "usr": 10818727483146447186, "detailed_name": "void func()", "qual_name_offset": 5, "short_name": "func", "spell": "11:6-11:10|11:1-14:2|2|-1", "bases": [], "vars": [6030927277961448585, 7657277353101371136], "callees": [], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": [], "derived": [], "uses": [] }], "usr2type": [{ "usr": 53, "detailed_name": "", "qual_name_offset": 0, "short_name": "", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 0, "parent_kind": 0, "declarations": [], "derived": [], "instances": [15042442838933090518, 6030927277961448585, 7657277353101371136], "uses": [] }, { "usr": 926793467007732869, "detailed_name": "namespace foo {}", "qual_name_offset": 10, "short_name": "foo", "bases": [], "funcs": [], "types": [17805385787823406700], "vars": [], "alias_of": 0, "kind": 3, "parent_kind": 0, "declarations": ["1:11-1:14|1:1-7:2|1|-1"], "derived": [17805385787823406700], "instances": [], "uses": ["9:17-9:20|4|-1", "12:11-12:14|4|-1"] }, { "usr": 11879713791858506216, "detailed_name": "namespace fbz = foo::bar::baz", "qual_name_offset": 10, "short_name": "fbz", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 14450849931009540802, "kind": 252, "parent_kind": 0, "declarations": ["9:11-9:14|9:1-9:30|1|-1"], "derived": [], "instances": [], "uses": ["13:11-13:14|4|-1"] }, { "usr": 14450849931009540802, "detailed_name": "namespace foo::bar::baz {}", "qual_name_offset": 10, "short_name": "baz", "bases": [17805385787823406700], "funcs": [], "types": [], "vars": [{ "L": 15042442838933090518, "R": -1 }], "alias_of": 0, "kind": 3, "parent_kind": 0, "declarations": ["3:20-3:23|3:10-5:11|1025|-1"], "derived": [], "instances": [], "uses": ["9:27-9:30|4|-1", "12:21-12:24|4|-1"] }, { "usr": 17805385787823406700, "detailed_name": "namespace foo::bar {}", "qual_name_offset": 10, "short_name": "bar", "bases": [926793467007732869], "funcs": [], "types": [14450849931009540802], "vars": [], "alias_of": 0, "kind": 3, "parent_kind": 0, "declarations": ["2:15-2:18|2:5-6:6|1025|-1"], "derived": [14450849931009540802], "instances": [], "uses": ["9:22-9:25|4|-1", "12:16-12:19|4|-1"] }], "usr2var": [{ "usr": 6030927277961448585, "detailed_name": "int a", "qual_name_offset": 4, "short_name": "a", "hover": "int a = foo::bar::baz::qux", "spell": "12:7-12:8|12:3-12:29|2|-1", "type": 53, "kind": 13, "parent_kind": 12, "storage": 0, "declarations": [], "uses": [] }, { "usr": 7657277353101371136, "detailed_name": "int b", "qual_name_offset": 4, "short_name": "b", "hover": "int b = fbz::qux", "spell": "13:7-13:8|13:3-13:19|2|-1", "type": 53, "kind": 13, "parent_kind": 12, "storage": 0, "declarations": [], "uses": [] }, { "usr": 15042442838933090518, "detailed_name": "int foo::bar::baz::qux", "qual_name_offset": 4, "short_name": "qux", "hover": "int foo::bar::baz::qux = 42", "spell": "4:18-4:21|4:14-4:26|1026|-1", "type": 53, "kind": 13, "parent_kind": 3, "storage": 0, "declarations": [], "uses": ["12:26-12:29|12|-1", "13:16-13:19|12|-1"] }] } */ ccls-0.20190823.6/index_tests/namespaces/namespace_reference.cc000066400000000000000000000051461364776600300241650ustar00rootroot00000000000000namespace ns { int Foo; void Accept(int a) {} } void Runner() { ns::Accept(ns::Foo); using namespace ns; Accept(Foo); } /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [{ "usr": 631910859630953711, "detailed_name": "void Runner()", "qual_name_offset": 5, "short_name": "Runner", "spell": "6:6-6:12|6:1-10:2|2|-1", "bases": [], "vars": [], "callees": ["7:7-7:13|17328473273923617489|3|16420", "9:3-9:9|17328473273923617489|3|16420"], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": [], "derived": [], "uses": [] }, { "usr": 17328473273923617489, "detailed_name": "void ns::Accept(int a)", "qual_name_offset": 5, "short_name": "Accept", "spell": "3:8-3:14|3:3-3:24|1026|-1", "bases": [], "vars": [3649375698083002347], "callees": [], "kind": 12, "parent_kind": 3, "storage": 0, "declarations": [], "derived": [], "uses": ["7:7-7:13|16420|-1", "9:3-9:9|16420|-1"] }], "usr2type": [{ "usr": 53, "detailed_name": "", "qual_name_offset": 0, "short_name": "", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 0, "parent_kind": 0, "declarations": [], "derived": [], "instances": [12898699035586282159, 3649375698083002347], "uses": [] }, { "usr": 11072669167287398027, "detailed_name": "namespace ns {}", "qual_name_offset": 10, "short_name": "ns", "bases": [], "funcs": [17328473273923617489], "types": [], "vars": [{ "L": 12898699035586282159, "R": -1 }], "alias_of": 0, "kind": 3, "parent_kind": 0, "declarations": ["1:11-1:13|1:1-4:2|1|-1"], "derived": [], "instances": [], "uses": ["7:3-7:5|4|-1", "7:14-7:16|4|-1", "8:19-8:21|4|-1"] }], "usr2var": [{ "usr": 3649375698083002347, "detailed_name": "int a", "qual_name_offset": 4, "short_name": "a", "spell": "3:19-3:20|3:15-3:20|1026|-1", "type": 53, "kind": 253, "parent_kind": 12, "storage": 0, "declarations": [], "uses": [] }, { "usr": 12898699035586282159, "detailed_name": "int ns::Foo", "qual_name_offset": 4, "short_name": "Foo", "spell": "2:7-2:10|2:3-2:10|1026|-1", "type": 53, "kind": 13, "parent_kind": 3, "storage": 0, "declarations": [], "uses": ["7:18-7:21|12|-1", "9:10-9:13|12|-1"] }] } */ ccls-0.20190823.6/index_tests/objective-c/000077500000000000000000000000001364776600300177515ustar00rootroot00000000000000ccls-0.20190823.6/index_tests/objective-c/class.m000066400000000000000000000104741364776600300212420ustar00rootroot00000000000000@interface AClass + (void)test; - (void)anInstanceMethod; @property (nonatomic) int aProp; @end @implementation AClass + (void)test {} - (void)anInstanceMethod {} @end int main(void) { AClass *instance = [AClass init]; [instance anInstanceMethod]; instance.aProp = 12; } /* OUTPUT: { "includes": [], "skipped_by_preprocessor": [], "types": [{ "id": 0, "usr": 11832280568361305387, "detailed_name": "AClass", "short_name": "AClass", "kind": 7, "spell": "7:17-7:23|-1|1|2", "extent": "7:1-10:2|-1|1|0", "parents": [], "derived": [], "types": [], "funcs": [], "vars": [], "instances": [2], "uses": ["14:3-14:9|-1|1|4", "14:23-14:29|-1|1|4"] }, { "id": 1, "usr": 17, "detailed_name": "", "short_name": "", "kind": 0, "parents": [], "derived": [], "types": [], "funcs": [], "vars": [], "instances": [0, 1], "uses": [] }], "funcs": [{ "id": 0, "usr": 12775970426728664910, "detailed_name": "AClass::test", "short_name": "test", "kind": 17, "storage": 0, "declarations": [{ "spelling": "2:11-2:15", "extent": "2:3-2:16", "content": "+ (void)test;", "param_spellings": [] }], "spell": "8:9-8:13|-1|1|2", "extent": "8:1-8:16|-1|1|0", "base": [], "derived": [], "locals": [], "uses": [], "callees": [] }, { "id": 1, "usr": 4096877434426330804, "detailed_name": "AClass::anInstanceMethod", "short_name": "anInstanceMethod", "kind": 16, "storage": 0, "declarations": [{ "spelling": "3:11-3:27", "extent": "3:3-3:28", "content": "- (void)anInstanceMethod;", "param_spellings": [] }], "spell": "9:9-9:25|-1|1|2", "extent": "9:1-9:28|-1|1|0", "base": [], "derived": [], "locals": [], "uses": ["15:13-15:29|4|3|64"], "callees": [] }, { "id": 2, "usr": 12774569141855220778, "detailed_name": "AClass::aProp", "short_name": "aProp", "kind": 16, "storage": 0, "declarations": [{ "spelling": "0:0-0:0", "extent": "4:29-4:34", "content": "aProp", "param_spellings": [] }], "extent": "4:29-4:34|-1|1|0", "base": [], "derived": [], "locals": [], "uses": [], "callees": [] }, { "id": 3, "usr": 17992064398538597892, "detailed_name": "AClass::setAProp:", "short_name": "setAProp:", "kind": 16, "storage": 0, "declarations": [{ "spelling": "0:0-0:0", "extent": "4:29-4:34", "content": "aProp", "param_spellings": ["4:29-4:34"] }], "extent": "4:29-4:34|-1|1|0", "base": [], "derived": [], "locals": [], "uses": ["0:0-0:0|4|3|64"], "callees": [] }, { "id": 4, "usr": 7033269674615638282, "detailed_name": "int main()", "short_name": "main", "kind": 12, "storage": 1, "declarations": [], "spell": "12:5-12:9|-1|1|2", "extent": "12:1-17:2|-1|1|0", "base": [], "derived": [], "locals": [], "uses": [], "callees": ["15:13-15:29|1|3|64", "0:0-0:0|3|3|64"] }], "vars": [{ "id": 0, "usr": 14842397373703114213, "detailed_name": "int AClass::aProp", "short_name": "aProp", "declarations": ["4:29-4:34|-1|1|1"], "type": 1, "uses": ["16:12-16:17|4|3|4"], "kind": 19, "storage": 0 }, { "id": 1, "usr": 17112602610366149042, "detailed_name": "int AClass::_aProp", "short_name": "_aProp", "declarations": [], "spell": "4:29-4:34|-1|1|2", "extent": "4:29-4:34|-1|1|0", "type": 1, "uses": [], "kind": 14, "storage": 0 }, { "id": 2, "usr": 6849095699869081177, "detailed_name": "AClass *instance", "short_name": "instance", "hover": "AClass *instance = [AClass init]", "declarations": [], "spell": "14:11-14:19|4|3|2", "extent": "14:3-14:35|4|3|2", "type": 0, "uses": ["15:4-15:12|4|3|4", "16:3-16:11|4|3|4"], "kind": 13, "storage": 1 }] } */ ccls-0.20190823.6/index_tests/operators/000077500000000000000000000000001364776600300175755ustar00rootroot00000000000000ccls-0.20190823.6/index_tests/operators/operator.cc000066400000000000000000000043241364776600300217420ustar00rootroot00000000000000class Foo { void operator()(int) { } void operator()(bool); int operator()(int a, int b); }; Foo &operator += (const Foo&, const int&); /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [{ "usr": 3545323327609582678, "detailed_name": "void Foo::operator()(bool)", "qual_name_offset": 5, "short_name": "operator()", "bases": [], "vars": [], "callees": [], "kind": 6, "parent_kind": 0, "storage": 0, "declarations": ["3:8-3:16|3:3-3:24|1025|-1"], "derived": [], "uses": [] }, { "usr": 3986818119971932909, "detailed_name": "int Foo::operator()(int a, int b)", "qual_name_offset": 4, "short_name": "operator()", "bases": [], "vars": [], "callees": [], "kind": 6, "parent_kind": 0, "storage": 0, "declarations": ["4:7-4:15|4:3-4:31|1025|-1"], "derived": [], "uses": [] }, { "usr": 7874436189163837815, "detailed_name": "void Foo::operator()(int)", "qual_name_offset": 5, "short_name": "operator()", "spell": "2:8-2:18|2:3-2:27|1026|-1", "bases": [], "vars": [], "callees": [], "kind": 6, "parent_kind": 5, "storage": 0, "declarations": [], "derived": [], "uses": [] }, { "usr": 8288368475529136092, "detailed_name": "Foo &operator+=(const Foo &, const int &)", "qual_name_offset": 5, "short_name": "operator+=", "bases": [], "vars": [], "callees": [], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": ["7:6-7:14|7:1-7:42|1|-1"], "derived": [], "uses": [] }], "usr2type": [{ "usr": 15041163540773201510, "detailed_name": "class Foo {}", "qual_name_offset": 6, "short_name": "Foo", "spell": "1:7-1:10|1:1-5:2|2|-1", "bases": [], "funcs": [7874436189163837815, 3545323327609582678, 3986818119971932909], "types": [], "vars": [], "alias_of": 0, "kind": 5, "parent_kind": 0, "declarations": [], "derived": [], "instances": [], "uses": ["7:1-7:4|4|-1", "7:25-7:28|4|-1"] }], "usr2var": [] } */ ccls-0.20190823.6/index_tests/outline/000077500000000000000000000000001364776600300172365ustar00rootroot00000000000000ccls-0.20190823.6/index_tests/outline/static_function_in_type.cc000066400000000000000000000077701364776600300245030ustar00rootroot00000000000000#include "static_function_in_type.h" namespace ns { // static void Foo::Register(Manager* m) { } } /* OUTPUT: static_function_in_type.h { "includes": [], "skipped_ranges": [], "usr2func": [{ "usr": 17019747379608639279, "detailed_name": "static void ns::Foo::Register(ns::Manager *)", "qual_name_offset": 12, "short_name": "Register", "bases": [], "vars": [], "callees": [], "kind": 254, "parent_kind": 0, "storage": 0, "declarations": ["6:15-6:23|6:3-6:33|1025|-1"], "derived": [], "uses": [] }], "usr2type": [{ "usr": 1972401196751872203, "detailed_name": "class ns::Manager", "qual_name_offset": 6, "short_name": "Manager", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 5, "parent_kind": 0, "declarations": ["3:7-3:14|3:1-3:14|1025|-1"], "derived": [], "instances": [], "uses": ["6:24-6:31|4|-1"] }, { "usr": 11072669167287398027, "detailed_name": "namespace ns {}", "qual_name_offset": 10, "short_name": "ns", "bases": [], "funcs": [], "types": [1972401196751872203, 17262466801709381811], "vars": [], "alias_of": 0, "kind": 3, "parent_kind": 0, "declarations": ["1:11-1:13|1:1-9:2|1|-1"], "derived": [], "instances": [], "uses": [] }, { "usr": 17262466801709381811, "detailed_name": "struct ns::Foo {}", "qual_name_offset": 7, "short_name": "Foo", "spell": "5:8-5:11|5:1-7:2|1026|-1", "bases": [], "funcs": [17019747379608639279], "types": [], "vars": [], "alias_of": 0, "kind": 23, "parent_kind": 3, "declarations": [], "derived": [], "instances": [], "uses": [] }], "usr2var": [] } OUTPUT: static_function_in_type.cc { "includes": [{ "line": 0, "resolved_path": "&static_function_in_type.h" }], "skipped_ranges": [], "usr2func": [{ "usr": 17019747379608639279, "detailed_name": "static void ns::Foo::Register(ns::Manager *)", "qual_name_offset": 12, "short_name": "Register", "spell": "5:11-5:19|5:1-6:2|1026|-1", "comments": "static", "bases": [], "vars": [13569879755236306838], "callees": [], "kind": 254, "parent_kind": 23, "storage": 0, "declarations": [], "derived": [], "uses": [] }], "usr2type": [{ "usr": 1972401196751872203, "detailed_name": "class ns::Manager", "qual_name_offset": 6, "short_name": "Manager", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 5, "parent_kind": 0, "declarations": [], "derived": [], "instances": [13569879755236306838], "uses": ["5:20-5:27|4|-1"] }, { "usr": 11072669167287398027, "detailed_name": "namespace ns {}", "qual_name_offset": 10, "short_name": "ns", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 3, "parent_kind": 0, "declarations": ["3:11-3:13|3:1-7:2|1|-1"], "derived": [], "instances": [], "uses": [] }, { "usr": 17262466801709381811, "detailed_name": "struct ns::Foo {}", "qual_name_offset": 7, "short_name": "Foo", "bases": [], "funcs": [17019747379608639279], "types": [], "vars": [], "alias_of": 0, "kind": 23, "parent_kind": 0, "declarations": [], "derived": [], "instances": [], "uses": ["5:6-5:9|4|-1"] }], "usr2var": [{ "usr": 13569879755236306838, "detailed_name": "ns::Manager *m", "qual_name_offset": 13, "short_name": "m", "spell": "5:29-5:30|5:20-5:30|1026|-1", "type": 1972401196751872203, "kind": 253, "parent_kind": 254, "storage": 0, "declarations": [], "uses": [] }] } */ccls-0.20190823.6/index_tests/outline/static_function_in_type.h000066400000000000000000000001451364776600300243320ustar00rootroot00000000000000namespace ns { class Manager; struct Foo { static void Register(Manager*); }; } // namespace nsccls-0.20190823.6/index_tests/preprocessor/000077500000000000000000000000001364776600300203055ustar00rootroot00000000000000ccls-0.20190823.6/index_tests/preprocessor/include_guard.cc000066400000000000000000000007231364776600300234230ustar00rootroot00000000000000#ifndef FOO #define FOO #endif /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [], "usr2type": [], "usr2var": [{ "usr": 14219599523415845943, "detailed_name": "FOO", "qual_name_offset": 0, "short_name": "FOO", "hover": "#define FOO", "spell": "2:9-2:12|2:9-2:12|2|-1", "type": 0, "kind": 255, "parent_kind": 1, "storage": 0, "declarations": [], "uses": [] }] } */ ccls-0.20190823.6/index_tests/preprocessor/skipped.cc000066400000000000000000000003511364776600300222520ustar00rootroot00000000000000 #ifdef FOOBAR void hello(); #endif #if false #endif #if defined(OS_FOO) #endif /* OUTPUT: { "includes": [], "skipped_ranges": ["2:1-5:1", "6:1-11:1", "12:1-15:1"], "usr2func": [], "usr2type": [], "usr2var": [] } */ ccls-0.20190823.6/index_tests/templates/000077500000000000000000000000001364776600300175555ustar00rootroot00000000000000ccls-0.20190823.6/index_tests/templates/func_specialized_template_param.cc000066400000000000000000000027741364776600300264600ustar00rootroot00000000000000template class Template {}; struct Foo { void Bar(Template&); }; void Foo::Bar(Template&) {} /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [{ "usr": 8412238651648388423, "detailed_name": "void Foo::Bar(Template &)", "qual_name_offset": 5, "short_name": "Bar", "spell": "8:11-8:14|8:1-8:36|1026|-1", "bases": [], "vars": [], "callees": [], "kind": 6, "parent_kind": 23, "storage": 0, "declarations": ["5:8-5:11|5:3-5:30|1025|-1"], "derived": [], "uses": [] }], "usr2type": [{ "usr": 15041163540773201510, "detailed_name": "struct Foo {}", "qual_name_offset": 7, "short_name": "Foo", "spell": "4:8-4:11|4:1-6:2|2|-1", "bases": [], "funcs": [8412238651648388423], "types": [], "vars": [], "alias_of": 0, "kind": 23, "parent_kind": 0, "declarations": [], "derived": [], "instances": [], "uses": ["8:6-8:9|4|-1"] }, { "usr": 17107291254533526269, "detailed_name": "class Template {}", "qual_name_offset": 6, "short_name": "Template", "spell": "2:7-2:15|2:1-2:18|2|-1", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 5, "parent_kind": 0, "declarations": [], "derived": [], "instances": [], "uses": ["5:12-5:20|4|-1", "8:15-8:23|4|-1"] }], "usr2var": [] } */ ccls-0.20190823.6/index_tests/templates/implicit_variable_instantiation.cc000066400000000000000000000067751364776600300265260ustar00rootroot00000000000000namespace ns { enum VarType {}; template struct Holder { static constexpr VarType static_var = (VarType)0x0; }; template const typename VarType Holder<_>::static_var; int Foo = Holder::static_var; int Foo2 = Holder::static_var; } /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [], "usr2type": [{ "usr": 53, "detailed_name": "", "qual_name_offset": 0, "short_name": "", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 0, "parent_kind": 0, "declarations": [], "derived": [], "instances": [12898699035586282159, 9008550860229740818], "uses": [] }, { "usr": 1532099849728741556, "detailed_name": "enum ns::VarType {}", "qual_name_offset": 5, "short_name": "VarType", "spell": "2:8-2:15|2:3-2:18|1026|-1", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 10, "parent_kind": 3, "declarations": [], "derived": [], "instances": [4731849186641714451, 4731849186641714451], "uses": ["6:22-6:29|4|-1", "6:44-6:51|4|-1", "10:18-10:25|4|-1"] }, { "usr": 11072669167287398027, "detailed_name": "namespace ns {}", "qual_name_offset": 10, "short_name": "ns", "bases": [], "funcs": [], "types": [1532099849728741556, 12688716854043726585], "vars": [{ "L": 12898699035586282159, "R": -1 }, { "L": 9008550860229740818, "R": -1 }], "alias_of": 0, "kind": 3, "parent_kind": 0, "declarations": ["1:11-1:13|1:1-15:2|1|-1"], "derived": [], "instances": [], "uses": [] }, { "usr": 12688716854043726585, "detailed_name": "struct ns::Holder {}", "qual_name_offset": 7, "short_name": "Holder", "spell": "5:10-5:16|5:3-7:4|1026|-1", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 23, "parent_kind": 3, "declarations": [], "derived": [], "instances": [], "uses": ["10:26-10:32|4|-1", "13:13-13:19|4|-1", "14:14-14:20|4|-1"] }], "usr2var": [{ "usr": 4731849186641714451, "detailed_name": "static constexpr ns::VarType ns::Holder::static_var", "qual_name_offset": 29, "short_name": "static_var", "hover": "static constexpr ns::VarType ns::Holder::static_var = (VarType)0x0", "spell": "10:37-10:47|9:3-10:47|1026|-1", "type": 1532099849728741556, "kind": 13, "parent_kind": 23, "storage": 2, "declarations": ["6:30-6:40|6:5-6:55|1025|-1"], "uses": ["13:26-13:36|12|-1", "14:27-14:37|12|-1"] }, { "usr": 9008550860229740818, "detailed_name": "int ns::Foo2", "qual_name_offset": 4, "short_name": "Foo2", "hover": "int ns::Foo2 = Holder::static_var", "spell": "14:7-14:11|14:3-14:37|1026|-1", "type": 53, "kind": 13, "parent_kind": 3, "storage": 0, "declarations": [], "uses": [] }, { "usr": 12898699035586282159, "detailed_name": "int ns::Foo", "qual_name_offset": 4, "short_name": "Foo", "hover": "int ns::Foo = Holder::static_var", "spell": "13:7-13:10|13:3-13:36|1026|-1", "type": 53, "kind": 13, "parent_kind": 3, "storage": 0, "declarations": [], "uses": [] }] } */ ccls-0.20190823.6/index_tests/templates/member_ref_in_template.cc000066400000000000000000000046241364776600300245560ustar00rootroot00000000000000template struct C { T x; void bar(); }; template void foo() { C d; d.x; // spelling range is empty, use cursor extent for range d.bar(); // spelling range is empty, use cursor extent for range auto e = new C; e->x; // `x` seems not exposed by libclang e->bar(); // `bar` seems not exposed by libclang } /* EXTRA_FLAGS: -fms-extensions -fms-compatibility -fdelayed-template-parsing OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [{ "usr": 6875364467121018690, "detailed_name": "void foo()", "qual_name_offset": 5, "short_name": "foo", "spell": "8:6-8:9|8:1-8:11|2|-1", "bases": [], "vars": [], "callees": [], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": [], "derived": [], "uses": [] }, { "usr": 8905286151237717330, "detailed_name": "void C::bar()", "qual_name_offset": 5, "short_name": "bar", "bases": [], "vars": [], "callees": [], "kind": 6, "parent_kind": 0, "storage": 0, "declarations": ["4:8-4:11|4:3-4:13|1025|-1"], "derived": [], "uses": [] }], "usr2type": [{ "usr": 8402783583255987702, "detailed_name": "struct C {}", "qual_name_offset": 7, "short_name": "C", "spell": "2:8-2:9|2:1-5:2|2|-1", "bases": [], "funcs": [8905286151237717330], "types": [], "vars": [{ "L": 5866801090710377175, "R": -1 }], "alias_of": 0, "kind": 23, "parent_kind": 0, "declarations": [], "derived": [], "instances": [], "uses": [] }, { "usr": 14750650276757822712, "detailed_name": "T", "qual_name_offset": 0, "short_name": "T", "spell": "1:17-1:18|1:11-1:18|2|-1", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 26, "parent_kind": 5, "declarations": [], "derived": [], "instances": [5866801090710377175], "uses": [] }], "usr2var": [{ "usr": 5866801090710377175, "detailed_name": "T C::x", "qual_name_offset": 2, "short_name": "x", "spell": "3:5-3:6|3:3-3:6|1026|-1", "type": 14750650276757822712, "kind": 8, "parent_kind": 23, "storage": 0, "declarations": [], "uses": [] }] } */ namespace_template_class_template_func_usage_folded_into_one.cc000066400000000000000000000054161364776600300343300ustar00rootroot00000000000000ccls-0.20190823.6/index_tests/templatesnamespace ns { template struct Foo { template static int foo() { return 3; } }; int a = Foo::foo(); int b = Foo::foo(); } /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [{ "usr": 8221803074608342407, "detailed_name": "static int ns::Foo::foo()", "qual_name_offset": 11, "short_name": "foo", "spell": "5:16-5:19|5:5-7:6|1026|-1", "bases": [], "vars": [], "callees": [], "kind": 254, "parent_kind": 23, "storage": 0, "declarations": [], "derived": [], "uses": ["10:21-10:24|36|-1", "11:22-11:25|36|-1"] }], "usr2type": [{ "usr": 53, "detailed_name": "", "qual_name_offset": 0, "short_name": "", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 0, "parent_kind": 0, "declarations": [], "derived": [], "instances": [15768138241775955040, 3182917058194750998], "uses": [] }, { "usr": 11072669167287398027, "detailed_name": "namespace ns {}", "qual_name_offset": 10, "short_name": "ns", "bases": [], "funcs": [], "types": [14042997404480181958], "vars": [{ "L": 15768138241775955040, "R": -1 }, { "L": 3182917058194750998, "R": -1 }], "alias_of": 0, "kind": 3, "parent_kind": 0, "declarations": ["1:11-1:13|1:1-12:2|1|-1"], "derived": [], "instances": [], "uses": [] }, { "usr": 14042997404480181958, "detailed_name": "struct ns::Foo {}", "qual_name_offset": 7, "short_name": "Foo", "spell": "3:10-3:13|3:3-8:4|1026|-1", "bases": [], "funcs": [8221803074608342407], "types": [], "vars": [], "alias_of": 0, "kind": 23, "parent_kind": 3, "declarations": [], "derived": [], "instances": [], "uses": ["10:11-10:14|4|-1", "11:11-11:14|4|-1"] }], "usr2var": [{ "usr": 3182917058194750998, "detailed_name": "int ns::b", "qual_name_offset": 4, "short_name": "b", "hover": "int ns::b = Foo::foo()", "spell": "11:7-11:8|11:3-11:35|1026|-1", "type": 53, "kind": 13, "parent_kind": 3, "storage": 0, "declarations": [], "uses": [] }, { "usr": 15768138241775955040, "detailed_name": "int ns::a", "qual_name_offset": 4, "short_name": "a", "hover": "int ns::a = Foo::foo()", "spell": "10:7-10:8|10:3-10:33|1026|-1", "type": 53, "kind": 13, "parent_kind": 3, "storage": 0, "declarations": [], "uses": [] }] } */ ccls-0.20190823.6/index_tests/templates/namespace_template_type_usage_folded_into_one.cc000066400000000000000000000035171364776600300313550ustar00rootroot00000000000000namespace ns { template class Foo {}; Foo a; Foo b; } /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [], "usr2type": [{ "usr": 11072669167287398027, "detailed_name": "namespace ns {}", "qual_name_offset": 10, "short_name": "ns", "bases": [], "funcs": [], "types": [14042997404480181958], "vars": [{ "L": 15768138241775955040, "R": -1 }, { "L": 3182917058194750998, "R": -1 }], "alias_of": 0, "kind": 3, "parent_kind": 0, "declarations": ["1:11-1:13|1:1-7:2|1|-1"], "derived": [], "instances": [], "uses": [] }, { "usr": 14042997404480181958, "detailed_name": "class ns::Foo {}", "qual_name_offset": 6, "short_name": "Foo", "spell": "3:9-3:12|3:3-3:15|1026|-1", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 5, "parent_kind": 3, "declarations": [], "derived": [], "instances": [15768138241775955040, 3182917058194750998], "uses": ["5:3-5:6|4|-1", "6:3-6:6|4|-1"] }], "usr2var": [{ "usr": 3182917058194750998, "detailed_name": "Foo ns::b", "qual_name_offset": 10, "short_name": "b", "spell": "6:13-6:14|6:3-6:14|1026|-1", "type": 14042997404480181958, "kind": 13, "parent_kind": 3, "storage": 0, "declarations": [], "uses": [] }, { "usr": 15768138241775955040, "detailed_name": "Foo ns::a", "qual_name_offset": 9, "short_name": "a", "spell": "5:12-5:13|5:3-5:13|1026|-1", "type": 14042997404480181958, "kind": 13, "parent_kind": 3, "storage": 0, "declarations": [], "uses": [] }] } */ ccls-0.20190823.6/index_tests/templates/specialization.cc000066400000000000000000000251251364776600300231070ustar00rootroot00000000000000template class function; template class function {}; function f; template class allocator; template > class vector { void clear(); }; template class vector {}; struct Z1 {}; template class vector; struct Z2 {}; template<> class vector { void clear(); }; vector vc; vector vip; vector vz1; vector vz2; enum Enum { Enum0, Enum1 }; template void foo(T Value) {} static const int kOnst = 7; template <> void foo(float Value); /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [{ "usr": 3861597222587452538, "detailed_name": "template<> void foo(float Value)", "qual_name_offset": 16, "short_name": "foo", "bases": [], "vars": [], "callees": [], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": ["43:6-43:9|42:1-43:50|1|-1"], "derived": [], "uses": [] }, { "usr": 6113470698424012876, "detailed_name": "void vector >::clear()", "qual_name_offset": 5, "short_name": "clear", "bases": [], "vars": [], "callees": [], "kind": 6, "parent_kind": 0, "storage": 0, "declarations": ["27:8-27:13|27:3-27:15|1025|-1"], "derived": [], "uses": [] }, { "usr": 17498190318698490707, "detailed_name": "void foo(T Value)", "qual_name_offset": 5, "short_name": "foo", "spell": "39:6-39:9|39:1-39:21|2|-1", "bases": [], "vars": [17826688417349629938], "callees": [], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": [], "derived": [], "uses": [] }, { "usr": 18107614608385228556, "detailed_name": "void vector::clear()", "qual_name_offset": 5, "short_name": "clear", "bases": [], "vars": [], "callees": [], "kind": 6, "parent_kind": 0, "storage": 0, "declarations": ["13:8-13:13|13:3-13:15|1025|-1"], "derived": [], "uses": [] }], "usr2type": [{ "usr": 53, "detailed_name": "", "qual_name_offset": 0, "short_name": "", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 0, "parent_kind": 0, "declarations": [], "derived": [], "instances": [13914496963221806870], "uses": [] }, { "usr": 218068462278884837, "detailed_name": "template class function {}", "qual_name_offset": 46, "short_name": "function", "spell": "5:7-5:15|4:1-5:30|2|-1", "bases": [15019211479263750068], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 5, "parent_kind": 0, "declarations": [], "derived": [], "instances": [2933643612409209903], "uses": ["7:1-7:9|4|-1"] }, { "usr": 1663022413889915338, "detailed_name": "template<> class vector> {}", "qual_name_offset": 17, "short_name": "vector", "spell": "26:7-26:13|25:1-28:2|2|-1", "bases": [7440942986741176606], "funcs": [6113470698424012876], "types": [], "vars": [], "alias_of": 0, "kind": 5, "parent_kind": 0, "declarations": [], "derived": [], "instances": [15931696253641284761], "uses": ["26:7-26:13|4|-1", "33:1-33:7|4|-1"] }, { "usr": 5760043510674081814, "detailed_name": "struct Z1 {}", "qual_name_offset": 7, "short_name": "Z1", "spell": "19:8-19:10|19:1-19:13|2|-1", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 23, "parent_kind": 0, "declarations": [], "derived": [], "instances": [], "uses": ["21:23-21:25|4|-1", "32:8-32:10|4|-1"] }, { "usr": 7440942986741176606, "detailed_name": "class vector {}", "qual_name_offset": 6, "short_name": "vector", "spell": "12:7-12:13|12:1-14:2|2|-1", "bases": [], "funcs": [18107614608385228556], "types": [], "vars": [], "alias_of": 0, "kind": 5, "parent_kind": 0, "declarations": [], "derived": [16155717907537731864, 1663022413889915338], "instances": [5792869548777559988], "uses": ["17:7-17:13|4|-1", "21:16-21:22|4|-1", "30:1-30:7|4|-1", "32:1-32:7|4|-1"] }, { "usr": 9201299975592934124, "detailed_name": "enum Enum {}", "qual_name_offset": 5, "short_name": "Enum", "spell": "35:6-35:10|35:1-37:2|2|-1", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 10, "parent_kind": 0, "declarations": [], "derived": [], "instances": [], "uses": [] }, { "usr": 10124869160135436852, "detailed_name": "struct Z2 {}", "qual_name_offset": 7, "short_name": "Z2", "spell": "23:8-23:10|23:1-23:13|2|-1", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 23, "parent_kind": 0, "declarations": [], "derived": [], "instances": [], "uses": ["26:14-26:16|4|-1", "33:8-33:10|4|-1"] }, { "usr": 14111105212951082474, "detailed_name": "T", "qual_name_offset": 0, "short_name": "T", "spell": "38:20-38:21|38:11-38:21|2|-1", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 26, "parent_kind": 5, "declarations": [], "derived": [], "instances": [17826688417349629938], "uses": [] }, { "usr": 15019211479263750068, "detailed_name": "class function", "qual_name_offset": 6, "short_name": "function", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 5, "parent_kind": 0, "declarations": ["2:7-2:15|2:1-2:15|1|-1"], "derived": [218068462278884837], "instances": [], "uses": ["5:7-5:15|4|-1"] }, { "usr": 15440970074034693939, "detailed_name": "", "qual_name_offset": 0, "short_name": "", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 0, "parent_kind": 0, "declarations": [], "derived": [], "instances": [3566687051827176322], "uses": [] }, { "usr": 15695704394170757108, "detailed_name": "class allocator", "qual_name_offset": 6, "short_name": "allocator", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 5, "parent_kind": 0, "declarations": ["9:28-9:37|9:22-9:37|1|-1"], "derived": [], "instances": [], "uses": ["11:39-11:48|4|-1"] }, { "usr": 16155717907537731864, "detailed_name": "template class vector> {}", "qual_name_offset": 28, "short_name": "vector", "spell": "17:7-17:13|16:1-17:20|2|-1", "bases": [7440942986741176606], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 5, "parent_kind": 0, "declarations": [], "derived": [], "instances": [86949563628772958], "uses": ["31:1-31:7|4|-1"] }], "usr2var": [{ "usr": 86949563628772958, "detailed_name": "vector vip", "qual_name_offset": 14, "short_name": "vip", "spell": "31:14-31:17|31:1-31:17|2|-1", "type": 16155717907537731864, "kind": 13, "parent_kind": 0, "storage": 0, "declarations": [], "uses": [] }, { "usr": 2933643612409209903, "detailed_name": "function f", "qual_name_offset": 21, "short_name": "f", "spell": "7:21-7:22|7:1-7:22|2|-1", "type": 218068462278884837, "kind": 13, "parent_kind": 0, "storage": 0, "declarations": [], "uses": [] }, { "usr": 3566687051827176322, "detailed_name": "vector vz1", "qual_name_offset": 11, "short_name": "vz1", "spell": "32:12-32:15|32:1-32:15|2|-1", "type": 15440970074034693939, "kind": 13, "parent_kind": 0, "storage": 0, "declarations": [], "uses": [] }, { "usr": 4917621020431490070, "detailed_name": "Enum1", "qual_name_offset": 0, "short_name": "Enum1", "hover": "Enum1 = 1", "spell": "36:10-36:15|36:10-36:15|1026|-1", "type": 9201299975592934124, "kind": 22, "parent_kind": 0, "storage": 0, "declarations": [], "uses": [] }, { "usr": 5792869548777559988, "detailed_name": "vector vc", "qual_name_offset": 13, "short_name": "vc", "spell": "30:14-30:16|30:1-30:16|2|-1", "type": 7440942986741176606, "kind": 13, "parent_kind": 0, "storage": 0, "declarations": [], "uses": [] }, { "usr": 13914496963221806870, "detailed_name": "static const int kOnst", "qual_name_offset": 17, "short_name": "kOnst", "hover": "static const int kOnst = 7", "spell": "41:18-41:23|41:1-41:27|2|-1", "type": 53, "kind": 13, "parent_kind": 0, "storage": 2, "declarations": [], "uses": ["43:27-43:32|12|-1"] }, { "usr": 15477793821005285152, "detailed_name": "Enum0", "qual_name_offset": 0, "short_name": "Enum0", "hover": "Enum0 = 0", "spell": "36:3-36:8|36:3-36:8|1026|-1", "type": 9201299975592934124, "kind": 22, "parent_kind": 0, "storage": 0, "declarations": [], "uses": ["43:20-43:25|4|-1"] }, { "usr": 15931696253641284761, "detailed_name": "vector vz2", "qual_name_offset": 11, "short_name": "vz2", "spell": "33:12-33:15|33:1-33:15|2|-1", "type": 1663022413889915338, "kind": 13, "parent_kind": 0, "storage": 0, "declarations": [], "uses": [] }, { "usr": 17826688417349629938, "detailed_name": "T Value", "qual_name_offset": 2, "short_name": "Value", "spell": "39:12-39:17|39:10-39:17|1026|-1", "type": 14111105212951082474, "kind": 253, "parent_kind": 12, "storage": 0, "declarations": [], "uses": [] }] } */ ccls-0.20190823.6/index_tests/templates/specialized_func_definition.cc000066400000000000000000000037521364776600300256120ustar00rootroot00000000000000template class Template { void Foo(); }; template void Template::Foo() {} template<> void Template::Foo() {} /* // TODO: usage information on Template is bad. // TODO: Foo() should have multiple definitions. EXTRA_FLAGS: -fms-compatibility -fdelayed-template-parsing OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [{ "usr": 6995843774014807426, "detailed_name": "void Template::Foo()", "qual_name_offset": 5, "short_name": "Foo", "spell": "10:22-10:25|9:1-10:30|1026|-1", "bases": [], "vars": [], "callees": [], "kind": 6, "parent_kind": 5, "storage": 0, "declarations": [], "derived": [], "uses": [] }, { "usr": 11994188353303124840, "detailed_name": "void Template::Foo()", "qual_name_offset": 5, "short_name": "Foo", "spell": "7:19-7:22|6:1-7:24|1026|-1", "bases": [], "vars": [], "callees": [], "kind": 6, "parent_kind": 5, "storage": 0, "declarations": ["3:8-3:11|3:3-3:13|1025|-1"], "derived": [], "uses": [] }], "usr2type": [{ "usr": 17107291254533526269, "detailed_name": "class Template {}", "qual_name_offset": 6, "short_name": "Template", "spell": "2:7-2:15|2:1-4:2|2|-1", "bases": [], "funcs": [11994188353303124840], "types": [], "vars": [], "alias_of": 0, "kind": 5, "parent_kind": 0, "declarations": [], "derived": [], "instances": [], "uses": ["7:6-7:14|4|-1", "10:6-10:14|4|-1"] }, { "usr": 17649312483543982122, "detailed_name": "", "qual_name_offset": 0, "short_name": "", "bases": [], "funcs": [6995843774014807426], "types": [], "vars": [], "alias_of": 0, "kind": 0, "parent_kind": 0, "declarations": [], "derived": [], "instances": [], "uses": [] }], "usr2var": [] } */ ccls-0.20190823.6/index_tests/templates/template_class_func_usage_folded_into_one.cc000066400000000000000000000041441364776600300304750ustar00rootroot00000000000000template struct Foo { static int foo() { return 3; } }; int a = Foo::foo(); int b = Foo::foo(); /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [{ "usr": 8340731781048851399, "detailed_name": "static int Foo::foo()", "qual_name_offset": 11, "short_name": "foo", "spell": "3:14-3:17|3:3-5:4|1026|-1", "bases": [], "vars": [], "callees": [], "kind": 254, "parent_kind": 23, "storage": 0, "declarations": [], "derived": [], "uses": ["8:19-8:22|36|-1", "9:20-9:23|36|-1"] }], "usr2type": [{ "usr": 53, "detailed_name": "", "qual_name_offset": 0, "short_name": "", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 0, "parent_kind": 0, "declarations": [], "derived": [], "instances": [16721564935990383768, 12028309045033782423], "uses": [] }, { "usr": 10528472276654770367, "detailed_name": "struct Foo {}", "qual_name_offset": 7, "short_name": "Foo", "spell": "2:8-2:11|2:1-6:2|2|-1", "bases": [], "funcs": [8340731781048851399], "types": [], "vars": [], "alias_of": 0, "kind": 23, "parent_kind": 0, "declarations": [], "derived": [], "instances": [], "uses": ["8:9-8:12|4|-1", "9:9-9:12|4|-1"] }], "usr2var": [{ "usr": 12028309045033782423, "detailed_name": "int b", "qual_name_offset": 4, "short_name": "b", "hover": "int b = Foo::foo()", "spell": "9:5-9:6|9:1-9:25|2|-1", "type": 53, "kind": 13, "parent_kind": 0, "storage": 0, "declarations": [], "uses": [] }, { "usr": 16721564935990383768, "detailed_name": "int a", "qual_name_offset": 4, "short_name": "a", "hover": "int a = Foo::foo()", "spell": "8:5-8:6|8:1-8:24|2|-1", "type": 53, "kind": 13, "parent_kind": 0, "storage": 0, "declarations": [], "uses": [] }] } */ ccls-0.20190823.6/index_tests/templates/template_class_template_func_usage_folded_into_one.cc000066400000000000000000000042411364776600300323660ustar00rootroot00000000000000template struct Foo { template static int foo() { return 3; } }; int a = Foo::foo(); int b = Foo::foo(); /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [{ "usr": 9034026360701857235, "detailed_name": "static int Foo::foo()", "qual_name_offset": 11, "short_name": "foo", "spell": "4:14-4:17|4:3-6:4|1026|-1", "bases": [], "vars": [], "callees": [], "kind": 254, "parent_kind": 23, "storage": 0, "declarations": [], "derived": [], "uses": ["9:19-9:22|36|-1", "10:20-10:23|36|-1"] }], "usr2type": [{ "usr": 53, "detailed_name": "", "qual_name_offset": 0, "short_name": "", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 0, "parent_kind": 0, "declarations": [], "derived": [], "instances": [16721564935990383768, 12028309045033782423], "uses": [] }, { "usr": 10528472276654770367, "detailed_name": "struct Foo {}", "qual_name_offset": 7, "short_name": "Foo", "spell": "2:8-2:11|2:1-7:2|2|-1", "bases": [], "funcs": [9034026360701857235], "types": [], "vars": [], "alias_of": 0, "kind": 23, "parent_kind": 0, "declarations": [], "derived": [], "instances": [], "uses": ["9:9-9:12|4|-1", "10:9-10:12|4|-1"] }], "usr2var": [{ "usr": 12028309045033782423, "detailed_name": "int b", "qual_name_offset": 4, "short_name": "b", "hover": "int b = Foo::foo()", "spell": "10:5-10:6|10:1-10:33|2|-1", "type": 53, "kind": 13, "parent_kind": 0, "storage": 0, "declarations": [], "uses": [] }, { "usr": 16721564935990383768, "detailed_name": "int a", "qual_name_offset": 4, "short_name": "a", "hover": "int a = Foo::foo()", "spell": "9:5-9:6|9:1-9:31|2|-1", "type": 53, "kind": 13, "parent_kind": 0, "storage": 0, "declarations": [], "uses": [] }] } */ ccls-0.20190823.6/index_tests/templates/template_class_type_usage_folded_into_one.cc000066400000000000000000000056251364776600300305300ustar00rootroot00000000000000enum A {}; enum B {}; template struct Foo { struct Inner {}; }; Foo::Inner a; Foo::Inner b; #if false EnumDecl A EnumDecl B ClassTemplate Foo TemplateTypeParameter T StructDecl Inner VarDecl a TemplateRef Foo TypeRef enum A TypeRef struct Foo::Inner CallExpr Inner VarDecl b TemplateRef Foo TypeRef enum B TypeRef struct Foo::Inner CallExpr Inner #endif /* OUTPUT: { "includes": [], "skipped_ranges": ["12:1-29:1"], "usr2func": [], "usr2type": [{ "usr": 6697181287623958829, "detailed_name": "enum A {}", "qual_name_offset": 5, "short_name": "A", "spell": "1:6-1:7|1:1-1:10|2|-1", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 10, "parent_kind": 0, "declarations": [], "derived": [], "instances": [], "uses": ["9:5-9:6|4|-1"] }, { "usr": 10528472276654770367, "detailed_name": "struct Foo {}", "qual_name_offset": 7, "short_name": "Foo", "spell": "5:8-5:11|5:1-7:2|2|-1", "bases": [], "funcs": [], "types": [13938528237873543349], "vars": [], "alias_of": 0, "kind": 23, "parent_kind": 0, "declarations": [], "derived": [], "instances": [], "uses": ["9:1-9:4|4|-1", "10:1-10:4|4|-1"] }, { "usr": 13892793056005362145, "detailed_name": "enum B {}", "qual_name_offset": 5, "short_name": "B", "spell": "2:6-2:7|2:1-2:10|2|-1", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 10, "parent_kind": 0, "declarations": [], "derived": [], "instances": [], "uses": ["10:5-10:6|4|-1"] }, { "usr": 13938528237873543349, "detailed_name": "struct Foo::Inner {}", "qual_name_offset": 7, "short_name": "Inner", "spell": "6:10-6:15|6:3-6:18|1026|-1", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 23, "parent_kind": 23, "declarations": [], "derived": [], "instances": [16721564935990383768, 12028309045033782423], "uses": ["9:9-9:14|4|-1", "10:9-10:14|4|-1"] }], "usr2var": [{ "usr": 12028309045033782423, "detailed_name": "Foo::Inner b", "qual_name_offset": 14, "short_name": "b", "spell": "10:15-10:16|10:1-10:16|2|-1", "type": 13938528237873543349, "kind": 13, "parent_kind": 0, "storage": 0, "declarations": [], "uses": [] }, { "usr": 16721564935990383768, "detailed_name": "Foo::Inner a", "qual_name_offset": 14, "short_name": "a", "spell": "9:15-9:16|9:1-9:16|2|-1", "type": 13938528237873543349, "kind": 13, "parent_kind": 0, "storage": 0, "declarations": [], "uses": [] }] } */ ccls-0.20190823.6/index_tests/templates/template_class_var_usage_folded_into_one.cc000066400000000000000000000041111364776600300303240ustar00rootroot00000000000000template struct Foo { static constexpr int var = 3; }; int a = Foo::var; int b = Foo::var; /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [], "usr2type": [{ "usr": 53, "detailed_name": "", "qual_name_offset": 0, "short_name": "", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 0, "parent_kind": 0, "declarations": [], "derived": [], "instances": [13545144895171991916, 16721564935990383768, 12028309045033782423], "uses": [] }, { "usr": 10528472276654770367, "detailed_name": "struct Foo {}", "qual_name_offset": 7, "short_name": "Foo", "spell": "2:8-2:11|2:1-4:2|2|-1", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 23, "parent_kind": 0, "declarations": [], "derived": [], "instances": [], "uses": ["6:9-6:12|4|-1", "7:9-7:12|4|-1"] }], "usr2var": [{ "usr": 12028309045033782423, "detailed_name": "int b", "qual_name_offset": 4, "short_name": "b", "hover": "int b = Foo::var", "spell": "7:5-7:6|7:1-7:23|2|-1", "type": 53, "kind": 13, "parent_kind": 0, "storage": 0, "declarations": [], "uses": [] }, { "usr": 13545144895171991916, "detailed_name": "static constexpr int Foo::var", "qual_name_offset": 21, "short_name": "var", "hover": "static constexpr int Foo::var = 3", "type": 53, "kind": 13, "parent_kind": 23, "storage": 2, "declarations": ["3:24-3:27|3:3-3:31|1025|-1"], "uses": ["6:19-6:22|12|-1", "7:20-7:23|12|-1"] }, { "usr": 16721564935990383768, "detailed_name": "int a", "qual_name_offset": 4, "short_name": "a", "hover": "int a = Foo::var", "spell": "6:5-6:6|6:1-6:22|2|-1", "type": 53, "kind": 13, "parent_kind": 0, "storage": 0, "declarations": [], "uses": [] }] } */ ccls-0.20190823.6/index_tests/templates/template_func_usage_folded_into_one.cc000066400000000000000000000033301364776600300273040ustar00rootroot00000000000000template static int foo() { return 3; } int a = foo(); int b = foo(); // TODO: put template foo inside a namespace // TODO: put template foo inside a template class inside a namespace /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [{ "usr": 326583651986177228, "detailed_name": "static int foo()", "qual_name_offset": 11, "short_name": "foo", "spell": "2:12-2:15|2:1-4:2|2|-1", "bases": [], "vars": [], "callees": [], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": [], "derived": [], "uses": ["6:9-6:12|36|-1", "7:9-7:12|36|-1"] }], "usr2type": [{ "usr": 53, "detailed_name": "", "qual_name_offset": 0, "short_name": "", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 0, "parent_kind": 0, "declarations": [], "derived": [], "instances": [16721564935990383768, 12028309045033782423], "uses": [] }], "usr2var": [{ "usr": 12028309045033782423, "detailed_name": "int b", "qual_name_offset": 4, "short_name": "b", "hover": "int b = foo()", "spell": "7:5-7:6|7:1-7:20|2|-1", "type": 53, "kind": 13, "parent_kind": 0, "storage": 0, "declarations": [], "uses": [] }, { "usr": 16721564935990383768, "detailed_name": "int a", "qual_name_offset": 4, "short_name": "a", "hover": "int a = foo()", "spell": "6:5-6:6|6:1-6:19|2|-1", "type": 53, "kind": 13, "parent_kind": 0, "storage": 0, "declarations": [], "uses": [] }] } */ ccls-0.20190823.6/index_tests/templates/template_type_usage_folded_into_one.cc000066400000000000000000000024041364776600300273330ustar00rootroot00000000000000template class Foo {}; Foo a; Foo b; /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [], "usr2type": [{ "usr": 10528472276654770367, "detailed_name": "class Foo {}", "qual_name_offset": 6, "short_name": "Foo", "spell": "2:7-2:10|2:1-2:13|2|-1", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 5, "parent_kind": 0, "declarations": [], "derived": [], "instances": [16721564935990383768, 12028309045033782423], "uses": ["4:1-4:4|4|-1", "5:1-5:4|4|-1"] }], "usr2var": [{ "usr": 12028309045033782423, "detailed_name": "Foo b", "qual_name_offset": 10, "short_name": "b", "spell": "5:11-5:12|5:1-5:12|2|-1", "type": 10528472276654770367, "kind": 13, "parent_kind": 0, "storage": 0, "declarations": [], "uses": [] }, { "usr": 16721564935990383768, "detailed_name": "Foo a", "qual_name_offset": 9, "short_name": "a", "spell": "4:10-4:11|4:1-4:11|2|-1", "type": 10528472276654770367, "kind": 13, "parent_kind": 0, "storage": 0, "declarations": [], "uses": [] }] } */ ccls-0.20190823.6/index_tests/templates/template_var_usage_folded_into_one.cc000066400000000000000000000056161364776600300271520ustar00rootroot00000000000000enum A {}; enum B {}; template T var = T(); A a = var; B b = var; // NOTE: libclang before 4.0 doesn't expose template usage on |var|. #if false EnumDecl A EnumDecl B UnexposedDecl var VarDecl a UnexposedExpr var UnexposedExpr var DeclRefExpr var TypeRef enum A UnexposedDecl var VarDecl b UnexposedExpr var UnexposedExpr var DeclRefExpr var TypeRef enum B UnexposedDecl var #endif /* EXTRA_FLAGS: -std=c++14 OUTPUT: { "includes": [], "skipped_ranges": ["12:1-29:1"], "usr2func": [], "usr2type": [{ "usr": 6697181287623958829, "detailed_name": "enum A {}", "qual_name_offset": 5, "short_name": "A", "spell": "1:6-1:7|1:1-1:10|2|-1", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 10, "parent_kind": 0, "declarations": [], "derived": [], "instances": [16721564935990383768], "uses": ["7:1-7:2|4|-1", "7:11-7:12|4|-1"] }, { "usr": 11919899838872947844, "detailed_name": "T", "qual_name_offset": 0, "short_name": "T", "spell": "4:19-4:20|4:10-4:20|2|-1", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 26, "parent_kind": 5, "declarations": [], "derived": [], "instances": [8096973118640070624], "uses": [] }, { "usr": 13892793056005362145, "detailed_name": "enum B {}", "qual_name_offset": 5, "short_name": "B", "spell": "2:6-2:7|2:1-2:10|2|-1", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 10, "parent_kind": 0, "declarations": [], "derived": [], "instances": [12028309045033782423], "uses": ["8:1-8:2|4|-1", "8:11-8:12|4|-1"] }], "usr2var": [{ "usr": 8096973118640070624, "detailed_name": "T var", "qual_name_offset": 2, "short_name": "var", "hover": "T var = T()", "spell": "5:3-5:6|5:1-5:12|2|-1", "type": 11919899838872947844, "kind": 13, "parent_kind": 0, "storage": 0, "declarations": [], "uses": ["7:7-7:10|12|-1", "8:7-8:10|12|-1"] }, { "usr": 12028309045033782423, "detailed_name": "B b", "qual_name_offset": 2, "short_name": "b", "hover": "B b = var", "spell": "8:3-8:4|8:1-8:13|2|-1", "type": 13892793056005362145, "kind": 13, "parent_kind": 0, "storage": 0, "declarations": [], "uses": [] }, { "usr": 16721564935990383768, "detailed_name": "A a", "qual_name_offset": 2, "short_name": "a", "hover": "A a = var", "spell": "7:3-7:4|7:1-7:13|2|-1", "type": 6697181287623958829, "kind": 13, "parent_kind": 0, "storage": 0, "declarations": [], "uses": [] }] } */ ccls-0.20190823.6/index_tests/types/000077500000000000000000000000001364776600300167235ustar00rootroot00000000000000ccls-0.20190823.6/index_tests/types/anonymous_struct.cc000066400000000000000000000061171364776600300226730ustar00rootroot00000000000000union vector3 { struct { float x, y, z; }; float v[3]; }; /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [], "usr2type": [{ "usr": 82, "detailed_name": "", "qual_name_offset": 0, "short_name": "", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 0, "parent_kind": 0, "declarations": [], "derived": [], "instances": [3348817847649945564, 4821094820988543895, 15292551660437765731], "uses": [] }, { "usr": 1428566502523368801, "detailed_name": "anon struct", "qual_name_offset": 0, "short_name": "anon struct", "spell": "2:3-2:9|2:3-2:28|1026|-1", "bases": [], "funcs": [], "types": [], "vars": [{ "L": 3348817847649945564, "R": 0 }, { "L": 4821094820988543895, "R": 32 }, { "L": 15292551660437765731, "R": 64 }], "alias_of": 0, "kind": 23, "parent_kind": 5, "declarations": [], "derived": [], "instances": [], "uses": [] }, { "usr": 17937907487590875128, "detailed_name": "union vector3 {}", "qual_name_offset": 6, "short_name": "vector3", "spell": "1:7-1:14|1:1-4:2|2|-1", "bases": [], "funcs": [], "types": [1428566502523368801], "vars": [{ "L": 1963212417280098348, "R": 0 }, { "L": 3348817847649945564, "R": 0 }, { "L": 4821094820988543895, "R": 32 }, { "L": 15292551660437765731, "R": 64 }], "alias_of": 0, "kind": 5, "parent_kind": 0, "declarations": [], "derived": [], "instances": [], "uses": [] }], "usr2var": [{ "usr": 1963212417280098348, "detailed_name": "float vector3::v[3]", "qual_name_offset": 6, "short_name": "v", "spell": "3:9-3:10|3:3-3:13|1026|-1", "type": 0, "kind": 8, "parent_kind": 5, "storage": 0, "declarations": [], "uses": [] }, { "usr": 3348817847649945564, "detailed_name": "float vector3::(anon struct)::x", "qual_name_offset": 6, "short_name": "x", "spell": "2:18-2:19|2:12-2:19|1026|-1", "type": 82, "kind": 8, "parent_kind": 23, "storage": 0, "declarations": [], "uses": [] }, { "usr": 4821094820988543895, "detailed_name": "float vector3::(anon struct)::y", "qual_name_offset": 6, "short_name": "y", "spell": "2:21-2:22|2:12-2:22|1026|-1", "type": 82, "kind": 8, "parent_kind": 23, "storage": 0, "declarations": [], "uses": [] }, { "usr": 15292551660437765731, "detailed_name": "float vector3::(anon struct)::z", "qual_name_offset": 6, "short_name": "z", "spell": "2:24-2:25|2:12-2:25|1026|-1", "type": 82, "kind": 8, "parent_kind": 23, "storage": 0, "declarations": [], "uses": [] }] } */ ccls-0.20190823.6/index_tests/types/typedefs.cc000066400000000000000000000017471364776600300210660ustar00rootroot00000000000000typedef int (func)(const int *a, const int *b); static func g; /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [{ "usr": 8105378401105136463, "detailed_name": "static int g(const int *, const int *)", "qual_name_offset": 11, "short_name": "g", "bases": [], "vars": [], "callees": [], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": ["2:13-2:14|2:1-2:14|1|-1"], "derived": [], "uses": [] }], "usr2type": [{ "usr": 10383876566159302459, "detailed_name": "typedef int (func)(const int *, const int *)", "qual_name_offset": 12, "short_name": "func", "spell": "1:14-1:18|1:1-1:47|2|-1", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 252, "parent_kind": 0, "declarations": [], "derived": [], "instances": [], "uses": ["2:8-2:12|4|-1"] }], "usr2var": [] } */ccls-0.20190823.6/index_tests/unions/000077500000000000000000000000001364776600300170725ustar00rootroot00000000000000ccls-0.20190823.6/index_tests/unions/union_decl.cc000066400000000000000000000036621364776600300215270ustar00rootroot00000000000000union Foo { int a; bool b; }; /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [], "usr2type": [{ "usr": 37, "detailed_name": "", "qual_name_offset": 0, "short_name": "", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 0, "parent_kind": 0, "declarations": [], "derived": [], "instances": [8804696910588009104], "uses": [] }, { "usr": 53, "detailed_name": "", "qual_name_offset": 0, "short_name": "", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 0, "parent_kind": 0, "declarations": [], "derived": [], "instances": [9529311430721959843], "uses": [] }, { "usr": 8501689086387244262, "detailed_name": "union Foo {}", "qual_name_offset": 6, "short_name": "Foo", "spell": "1:7-1:10|1:1-4:2|2|-1", "bases": [], "funcs": [], "types": [], "vars": [{ "L": 9529311430721959843, "R": 0 }, { "L": 8804696910588009104, "R": 0 }], "alias_of": 0, "kind": 5, "parent_kind": 0, "declarations": [], "derived": [], "instances": [], "uses": [] }], "usr2var": [{ "usr": 8804696910588009104, "detailed_name": "bool Foo::b", "qual_name_offset": 5, "short_name": "b", "spell": "3:8-3:9|3:3-3:9|1026|-1", "type": 37, "kind": 8, "parent_kind": 5, "storage": 0, "declarations": [], "uses": [] }, { "usr": 9529311430721959843, "detailed_name": "int Foo::a", "qual_name_offset": 4, "short_name": "a", "spell": "2:7-2:8|2:3-2:8|1026|-1", "type": 53, "kind": 8, "parent_kind": 5, "storage": 0, "declarations": [], "uses": [] }] } */ ccls-0.20190823.6/index_tests/unions/union_usage.cc000066400000000000000000000054251364776600300217230ustar00rootroot00000000000000union Foo { int a : 5; bool b : 3; }; Foo f; void act(Foo*) { f.a = 3; } /* // TODO: instantiations on Foo should include parameter? OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [{ "usr": 13982179977217945200, "detailed_name": "void act(Foo *)", "qual_name_offset": 5, "short_name": "act", "spell": "8:6-8:9|8:1-10:2|2|-1", "bases": [], "vars": [], "callees": [], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": [], "derived": [], "uses": [] }], "usr2type": [{ "usr": 37, "detailed_name": "", "qual_name_offset": 0, "short_name": "", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 0, "parent_kind": 0, "declarations": [], "derived": [], "instances": [8804696910588009104], "uses": [] }, { "usr": 53, "detailed_name": "", "qual_name_offset": 0, "short_name": "", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 0, "parent_kind": 0, "declarations": [], "derived": [], "instances": [9529311430721959843], "uses": [] }, { "usr": 8501689086387244262, "detailed_name": "union Foo {}", "qual_name_offset": 6, "short_name": "Foo", "spell": "1:7-1:10|1:1-4:2|2|-1", "bases": [], "funcs": [], "types": [], "vars": [{ "L": 9529311430721959843, "R": 0 }, { "L": 8804696910588009104, "R": 0 }], "alias_of": 0, "kind": 5, "parent_kind": 0, "declarations": [], "derived": [], "instances": [2933643612409209903], "uses": ["6:1-6:4|4|-1", "8:10-8:13|4|-1"] }], "usr2var": [{ "usr": 2933643612409209903, "detailed_name": "Foo f", "qual_name_offset": 4, "short_name": "f", "spell": "6:5-6:6|6:1-6:6|2|-1", "type": 8501689086387244262, "kind": 13, "parent_kind": 0, "storage": 0, "declarations": [], "uses": ["9:3-9:4|4|-1"] }, { "usr": 8804696910588009104, "detailed_name": "bool Foo::b : 3", "qual_name_offset": 5, "short_name": "b", "spell": "3:8-3:9|3:3-3:13|1026|-1", "type": 37, "kind": 8, "parent_kind": 5, "storage": 0, "declarations": [], "uses": [] }, { "usr": 9529311430721959843, "detailed_name": "int Foo::a : 5", "qual_name_offset": 4, "short_name": "a", "spell": "2:7-2:8|2:3-2:12|1026|-1", "type": 53, "kind": 8, "parent_kind": 5, "storage": 0, "declarations": [], "uses": ["9:5-9:6|20|-1"] }] } */ ccls-0.20190823.6/index_tests/usage/000077500000000000000000000000001364776600300166635ustar00rootroot00000000000000ccls-0.20190823.6/index_tests/usage/func_called_from_constructor.cc000066400000000000000000000026611364776600300251260ustar00rootroot00000000000000void called() {} struct Foo { Foo(); }; Foo::Foo() { called(); } /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [{ "usr": 468307235068920063, "detailed_name": "void called()", "qual_name_offset": 5, "short_name": "called", "spell": "1:6-1:12|1:1-1:17|2|-1", "bases": [], "vars": [], "callees": [], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": [], "derived": [], "uses": ["8:3-8:9|16420|-1"] }, { "usr": 3385168158331140247, "detailed_name": "Foo::Foo()", "qual_name_offset": 0, "short_name": "Foo", "spell": "7:6-7:9|7:1-9:2|1026|-1", "bases": [], "vars": [], "callees": ["8:3-8:9|468307235068920063|3|16420"], "kind": 9, "parent_kind": 23, "storage": 0, "declarations": ["4:3-4:6|4:3-4:8|1025|-1"], "derived": [], "uses": [] }], "usr2type": [{ "usr": 15041163540773201510, "detailed_name": "struct Foo {}", "qual_name_offset": 7, "short_name": "Foo", "spell": "3:8-3:11|3:1-5:2|2|-1", "bases": [], "funcs": [3385168158331140247], "types": [], "vars": [], "alias_of": 0, "kind": 23, "parent_kind": 0, "declarations": [], "derived": [], "instances": [], "uses": ["4:3-4:6|4|-1", "7:1-7:4|4|-1", "7:6-7:9|4|-1"] }], "usr2var": [] } */ ccls-0.20190823.6/index_tests/usage/func_called_from_macro_argument.cc000066400000000000000000000025551364776600300255460ustar00rootroot00000000000000#define MACRO_CALL(e) e bool called(bool a, bool b); void caller() { MACRO_CALL(called(true, true)); } /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [{ "usr": 3787803219955606747, "detailed_name": "bool called(bool a, bool b)", "qual_name_offset": 5, "short_name": "called", "bases": [], "vars": [], "callees": [], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": ["3:6-3:12|3:1-3:28|1|-1"], "derived": [], "uses": ["6:14-6:20|16420|-1", "6:14-6:20|64|0"] }, { "usr": 11404881820527069090, "detailed_name": "void caller()", "qual_name_offset": 5, "short_name": "caller", "spell": "5:6-5:12|5:1-7:2|2|-1", "bases": [], "vars": [], "callees": ["6:14-6:20|3787803219955606747|3|16420"], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": [], "derived": [], "uses": [] }], "usr2type": [], "usr2var": [{ "usr": 16326993795872073150, "detailed_name": "MACRO_CALL", "qual_name_offset": 0, "short_name": "MACRO_CALL", "hover": "#define MACRO_CALL(e) e", "spell": "1:9-1:19|1:9-1:24|2|-1", "type": 0, "kind": 255, "parent_kind": 1, "storage": 0, "declarations": [], "uses": ["6:3-6:13|64|-1"] }] } */ccls-0.20190823.6/index_tests/usage/func_called_from_template.cc000066400000000000000000000034651364776600300243570ustar00rootroot00000000000000void called(); template void caller() { called(); } void foo() { caller(); } /* // NOTE: without caller() instantation caller() is never visited so // called() is never referenced. OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [{ "usr": 468307235068920063, "detailed_name": "void called()", "qual_name_offset": 5, "short_name": "called", "bases": [], "vars": [], "callees": [], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": ["1:6-1:12|1:1-1:14|1|-1"], "derived": [], "uses": ["5:3-5:9|16420|-1"] }, { "usr": 2459767597003442547, "detailed_name": "", "qual_name_offset": 0, "short_name": "", "bases": [], "vars": [], "callees": ["5:3-5:9|468307235068920063|3|16420"], "kind": 0, "parent_kind": 0, "storage": 0, "declarations": [], "derived": [], "uses": [] }, { "usr": 4259594751088586730, "detailed_name": "void foo()", "qual_name_offset": 5, "short_name": "foo", "spell": "8:6-8:9|8:1-10:2|2|-1", "bases": [], "vars": [], "callees": ["9:3-9:9|10177235824697315808|3|16420"], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": [], "derived": [], "uses": [] }, { "usr": 10177235824697315808, "detailed_name": "void caller()", "qual_name_offset": 5, "short_name": "caller", "spell": "4:6-4:12|4:1-6:2|2|-1", "bases": [], "vars": [], "callees": ["5:3-5:9|468307235068920063|3|16420"], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": [], "derived": [], "uses": ["9:3-9:9|16420|-1"] }], "usr2type": [], "usr2var": [] } */ccls-0.20190823.6/index_tests/usage/func_called_implicit_ctor.cc000066400000000000000000000035531364776600300243600ustar00rootroot00000000000000struct Wrapper { Wrapper(int i); }; int called() { return 1; } Wrapper caller() { return called(); } /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [{ "usr": 468307235068920063, "detailed_name": "int called()", "qual_name_offset": 4, "short_name": "called", "spell": "5:5-5:11|5:1-5:27|2|-1", "bases": [], "vars": [], "callees": [], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": [], "derived": [], "uses": ["8:10-8:16|16420|-1"] }, { "usr": 10544127002917214589, "detailed_name": "Wrapper::Wrapper(int i)", "qual_name_offset": 0, "short_name": "Wrapper", "bases": [], "vars": [], "callees": [], "kind": 9, "parent_kind": 0, "storage": 0, "declarations": ["2:3-2:10|2:3-2:17|1025|-1"], "derived": [], "uses": ["8:10-8:16|16676|-1"] }, { "usr": 11404881820527069090, "detailed_name": "Wrapper caller()", "qual_name_offset": 8, "short_name": "caller", "spell": "7:9-7:15|7:1-9:2|2|-1", "bases": [], "vars": [], "callees": ["8:10-8:16|10544127002917214589|3|16676", "8:10-8:16|468307235068920063|3|16420"], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": [], "derived": [], "uses": [] }], "usr2type": [{ "usr": 13611487872560323389, "detailed_name": "struct Wrapper {}", "qual_name_offset": 7, "short_name": "Wrapper", "spell": "1:8-1:15|1:1-3:2|2|-1", "bases": [], "funcs": [10544127002917214589], "types": [], "vars": [], "alias_of": 0, "kind": 23, "parent_kind": 0, "declarations": [], "derived": [], "instances": [], "uses": ["2:3-2:10|4|-1", "7:1-7:8|4|-1"] }], "usr2var": [] } */ ccls-0.20190823.6/index_tests/usage/func_usage_addr_func.cc000066400000000000000000000035401364776600300233200ustar00rootroot00000000000000void consume(void (*)()) {} void used() {} void user() { void (*x)() = &used; consume(&used); } /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [{ "usr": 5264867802674151787, "detailed_name": "void used()", "qual_name_offset": 5, "short_name": "used", "spell": "3:6-3:10|3:1-3:15|2|-1", "bases": [], "vars": [], "callees": [], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": [], "derived": [], "uses": ["6:18-6:22|132|-1", "7:12-7:16|132|-1"] }, { "usr": 9376923949268137283, "detailed_name": "void user()", "qual_name_offset": 5, "short_name": "user", "spell": "5:6-5:10|5:1-8:2|2|-1", "bases": [], "vars": [16088407831770615719], "callees": ["6:18-6:22|5264867802674151787|3|132", "6:18-6:22|5264867802674151787|3|132", "7:3-7:10|12924914488846929470|3|16420", "7:12-7:16|5264867802674151787|3|132"], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": [], "derived": [], "uses": [] }, { "usr": 12924914488846929470, "detailed_name": "void consume(void (*)())", "qual_name_offset": 5, "short_name": "consume", "spell": "1:6-1:13|1:1-1:28|2|-1", "bases": [], "vars": [], "callees": [], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": [], "derived": [], "uses": ["7:3-7:10|16420|-1"] }], "usr2type": [], "usr2var": [{ "usr": 16088407831770615719, "detailed_name": "void (*x)()", "qual_name_offset": 7, "short_name": "x", "hover": "void (*x)() = &used", "spell": "6:10-6:11|6:3-6:22|2|-1", "type": 0, "kind": 13, "parent_kind": 12, "storage": 0, "declarations": [], "uses": [] }] } */ ccls-0.20190823.6/index_tests/usage/func_usage_addr_method.cc000066400000000000000000000034151364776600300236460ustar00rootroot00000000000000struct Foo { void Used(); }; void user() { auto x = &Foo::Used; } /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [{ "usr": 9376923949268137283, "detailed_name": "void user()", "qual_name_offset": 5, "short_name": "user", "spell": "5:6-5:10|5:1-7:2|2|-1", "bases": [], "vars": [4636142131003982569], "callees": ["6:18-6:22|18417145003926999463|3|132", "6:18-6:22|18417145003926999463|3|132"], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": [], "derived": [], "uses": [] }, { "usr": 18417145003926999463, "detailed_name": "void Foo::Used()", "qual_name_offset": 5, "short_name": "Used", "bases": [], "vars": [], "callees": [], "kind": 6, "parent_kind": 0, "storage": 0, "declarations": ["2:8-2:12|2:3-2:14|1025|-1"], "derived": [], "uses": ["6:18-6:22|132|-1"] }], "usr2type": [{ "usr": 15041163540773201510, "detailed_name": "struct Foo {}", "qual_name_offset": 7, "short_name": "Foo", "spell": "1:8-1:11|1:1-3:2|2|-1", "bases": [], "funcs": [18417145003926999463], "types": [], "vars": [], "alias_of": 0, "kind": 23, "parent_kind": 0, "declarations": [], "derived": [], "instances": [], "uses": ["6:13-6:16|4|-1"] }], "usr2var": [{ "usr": 4636142131003982569, "detailed_name": "void (Foo::*)() x", "qual_name_offset": 16, "short_name": "x", "hover": "void (Foo::*)() x = &Foo::Used", "spell": "6:8-6:9|6:3-6:22|2|-1", "type": 0, "kind": 13, "parent_kind": 12, "storage": 0, "declarations": [], "uses": [] }] } */ ccls-0.20190823.6/index_tests/usage/func_usage_call_func.cc000066400000000000000000000016611364776600300233230ustar00rootroot00000000000000void called() {} void caller() { called(); } /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [{ "usr": 468307235068920063, "detailed_name": "void called()", "qual_name_offset": 5, "short_name": "called", "spell": "1:6-1:12|1:1-1:17|2|-1", "bases": [], "vars": [], "callees": [], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": [], "derived": [], "uses": ["3:3-3:9|16420|-1"] }, { "usr": 11404881820527069090, "detailed_name": "void caller()", "qual_name_offset": 5, "short_name": "caller", "spell": "2:6-2:12|2:1-4:2|2|-1", "bases": [], "vars": [], "callees": ["3:3-3:9|468307235068920063|3|16420"], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": [], "derived": [], "uses": [] }], "usr2type": [], "usr2var": [] } */ ccls-0.20190823.6/index_tests/usage/func_usage_call_method.cc000066400000000000000000000034141364776600300236460ustar00rootroot00000000000000struct Foo { void Used(); }; void user() { Foo* f = nullptr; f->Used(); } /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [{ "usr": 9376923949268137283, "detailed_name": "void user()", "qual_name_offset": 5, "short_name": "user", "spell": "5:6-5:10|5:1-8:2|2|-1", "bases": [], "vars": [14045150712868309451], "callees": ["7:6-7:10|18417145003926999463|3|16420"], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": [], "derived": [], "uses": [] }, { "usr": 18417145003926999463, "detailed_name": "void Foo::Used()", "qual_name_offset": 5, "short_name": "Used", "bases": [], "vars": [], "callees": [], "kind": 6, "parent_kind": 0, "storage": 0, "declarations": ["2:8-2:12|2:3-2:14|1025|-1"], "derived": [], "uses": ["7:6-7:10|16420|-1"] }], "usr2type": [{ "usr": 15041163540773201510, "detailed_name": "struct Foo {}", "qual_name_offset": 7, "short_name": "Foo", "spell": "1:8-1:11|1:1-3:2|2|-1", "bases": [], "funcs": [18417145003926999463], "types": [], "vars": [], "alias_of": 0, "kind": 23, "parent_kind": 0, "declarations": [], "derived": [], "instances": [14045150712868309451], "uses": ["6:3-6:6|4|-1"] }], "usr2var": [{ "usr": 14045150712868309451, "detailed_name": "Foo *f", "qual_name_offset": 5, "short_name": "f", "hover": "Foo *f = nullptr", "spell": "6:8-6:9|6:3-6:19|2|-1", "type": 15041163540773201510, "kind": 13, "parent_kind": 12, "storage": 0, "declarations": [], "uses": ["7:3-7:4|12|-1"] }] } */ ccls-0.20190823.6/index_tests/usage/func_usage_class_inline_var_def.cc000066400000000000000000000032751364776600300255310ustar00rootroot00000000000000static int helper() { return 5; } class Foo { int x = helper(); }; /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [{ "usr": 9630503130605430498, "detailed_name": "static int helper()", "qual_name_offset": 11, "short_name": "helper", "spell": "1:12-1:18|1:1-3:2|2|-1", "bases": [], "vars": [], "callees": [], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": [], "derived": [], "uses": ["6:11-6:17|36|-1"] }], "usr2type": [{ "usr": 53, "detailed_name": "", "qual_name_offset": 0, "short_name": "", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 0, "parent_kind": 0, "declarations": [], "derived": [], "instances": [4220150017963593039], "uses": [] }, { "usr": 15041163540773201510, "detailed_name": "class Foo {}", "qual_name_offset": 6, "short_name": "Foo", "spell": "5:7-5:10|5:1-7:2|2|-1", "bases": [], "funcs": [], "types": [], "vars": [{ "L": 4220150017963593039, "R": 0 }], "alias_of": 0, "kind": 5, "parent_kind": 0, "declarations": [], "derived": [], "instances": [], "uses": [] }], "usr2var": [{ "usr": 4220150017963593039, "detailed_name": "int Foo::x", "qual_name_offset": 4, "short_name": "x", "hover": "int Foo::x = helper()", "spell": "6:7-6:8|6:3-6:19|1026|-1", "type": 53, "kind": 8, "parent_kind": 5, "storage": 0, "declarations": [], "uses": [] }] } */ ccls-0.20190823.6/index_tests/usage/func_usage_forward_decl_func.cc000066400000000000000000000016171364776600300250440ustar00rootroot00000000000000void foo(); void usage() { foo(); } /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [{ "usr": 4259594751088586730, "detailed_name": "void foo()", "qual_name_offset": 5, "short_name": "foo", "bases": [], "vars": [], "callees": [], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": ["1:6-1:9|1:1-1:11|1|-1"], "derived": [], "uses": ["4:3-4:6|16420|-1"] }, { "usr": 6767773193109753523, "detailed_name": "void usage()", "qual_name_offset": 5, "short_name": "usage", "spell": "3:6-3:11|3:1-5:2|2|-1", "bases": [], "vars": [], "callees": ["4:3-4:6|4259594751088586730|3|16420"], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": [], "derived": [], "uses": [] }], "usr2type": [], "usr2var": [] } */ ccls-0.20190823.6/index_tests/usage/func_usage_forward_decl_method.cc000066400000000000000000000034101364776600300253620ustar00rootroot00000000000000struct Foo { void foo(); }; void usage() { Foo* f = nullptr; f->foo(); } /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [{ "usr": 6767773193109753523, "detailed_name": "void usage()", "qual_name_offset": 5, "short_name": "usage", "spell": "5:6-5:11|5:1-8:2|2|-1", "bases": [], "vars": [16229832321010999607], "callees": ["7:6-7:9|17922201480358737771|3|16420"], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": [], "derived": [], "uses": [] }, { "usr": 17922201480358737771, "detailed_name": "void Foo::foo()", "qual_name_offset": 5, "short_name": "foo", "bases": [], "vars": [], "callees": [], "kind": 6, "parent_kind": 0, "storage": 0, "declarations": ["2:8-2:11|2:3-2:13|1025|-1"], "derived": [], "uses": ["7:6-7:9|16420|-1"] }], "usr2type": [{ "usr": 15041163540773201510, "detailed_name": "struct Foo {}", "qual_name_offset": 7, "short_name": "Foo", "spell": "1:8-1:11|1:1-3:2|2|-1", "bases": [], "funcs": [17922201480358737771], "types": [], "vars": [], "alias_of": 0, "kind": 23, "parent_kind": 0, "declarations": [], "derived": [], "instances": [16229832321010999607], "uses": ["6:3-6:6|4|-1"] }], "usr2var": [{ "usr": 16229832321010999607, "detailed_name": "Foo *f", "qual_name_offset": 5, "short_name": "f", "hover": "Foo *f = nullptr", "spell": "6:8-6:9|6:3-6:19|2|-1", "type": 15041163540773201510, "kind": 13, "parent_kind": 12, "storage": 0, "declarations": [], "uses": ["7:3-7:4|12|-1"] }] } */ ccls-0.20190823.6/index_tests/usage/func_usage_template_func.cc000066400000000000000000000017741364776600300242300ustar00rootroot00000000000000template void accept(T); void foo() { accept(1); accept(true); } /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [{ "usr": 4259594751088586730, "detailed_name": "void foo()", "qual_name_offset": 5, "short_name": "foo", "spell": "4:6-4:9|4:1-7:2|2|-1", "bases": [], "vars": [], "callees": ["5:3-5:9|10585861037135727329|3|16420", "6:3-6:9|10585861037135727329|3|16420"], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": [], "derived": [], "uses": [] }, { "usr": 10585861037135727329, "detailed_name": "void accept(T)", "qual_name_offset": 5, "short_name": "accept", "bases": [], "vars": [], "callees": [], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": ["2:6-2:12|2:1-2:15|1|-1"], "derived": [], "uses": ["5:3-5:9|16420|-1", "6:3-6:9|16420|-1"] }], "usr2type": [], "usr2var": [] } */ ccls-0.20190823.6/index_tests/usage/type_usage_as_template_parameter.cc000066400000000000000000000052221364776600300257560ustar00rootroot00000000000000template class unique_ptr {}; struct S {}; static unique_ptr f0; static unique_ptr f1; unique_ptr* return_type() { unique_ptr* local; return nullptr; } /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [{ "usr": 16359708726068806331, "detailed_name": "unique_ptr *return_type()", "qual_name_offset": 15, "short_name": "return_type", "spell": "9:16-9:27|9:1-12:2|2|-1", "bases": [], "vars": [3364438781074774169], "callees": [], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": [], "derived": [], "uses": [] }], "usr2type": [{ "usr": 3286534761799572592, "detailed_name": "class unique_ptr {}", "qual_name_offset": 6, "short_name": "unique_ptr", "spell": "2:7-2:17|2:1-2:20|2|-1", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 5, "parent_kind": 0, "declarations": [], "derived": [], "instances": [12857919739649552168, 18075066956054788088, 3364438781074774169], "uses": ["6:8-6:18|4|-1", "7:8-7:18|4|-1", "9:1-9:11|4|-1", "10:3-10:13|4|-1"] }, { "usr": 4750332761459066907, "detailed_name": "struct S {}", "qual_name_offset": 7, "short_name": "S", "spell": "4:8-4:9|4:1-4:12|2|-1", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 23, "parent_kind": 0, "declarations": [], "derived": [], "instances": [], "uses": ["7:19-7:20|4|-1", "9:12-9:13|4|-1", "10:14-10:15|4|-1"] }], "usr2var": [{ "usr": 3364438781074774169, "detailed_name": "unique_ptr *local", "qual_name_offset": 15, "short_name": "local", "spell": "10:18-10:23|10:3-10:23|2|-1", "type": 3286534761799572592, "kind": 13, "parent_kind": 12, "storage": 0, "declarations": [], "uses": [] }, { "usr": 12857919739649552168, "detailed_name": "static unique_ptr f0", "qual_name_offset": 24, "short_name": "f0", "spell": "6:25-6:27|6:1-6:27|2|-1", "type": 3286534761799572592, "kind": 13, "parent_kind": 0, "storage": 2, "declarations": [], "uses": [] }, { "usr": 18075066956054788088, "detailed_name": "static unique_ptr f1", "qual_name_offset": 21, "short_name": "f1", "spell": "7:22-7:24|7:1-7:24|2|-1", "type": 3286534761799572592, "kind": 13, "parent_kind": 0, "storage": 2, "declarations": [], "uses": [] }] } */ ccls-0.20190823.6/index_tests/usage/type_usage_as_template_parameter_complex.cc000066400000000000000000000137131364776600300275110ustar00rootroot00000000000000template class unique_ptr; struct S1; struct S2; #if false VarDecl f TemplateRef unique_ptr TemplateRef unique_ptr TypeRef struct S1 TypeRef struct S2 TypeRef struct S2 #endif extern unique_ptr, S2> f; #if false FunctionDecl as_return_type TemplateRef unique_ptr TemplateRef unique_ptr TypeRef struct S1 TypeRef struct S2 TypeRef struct S2 ParmDecl TemplateRef unique_ptr TypeRef struct S1 TypeRef struct S2 CompoundStmt ReturnStmt UnexposedExpr CXXNullPtrLiteralExpr #endif unique_ptr, S2>* as_return_type(unique_ptr*) { return nullptr; } #if false FunctionDecl no_return_type ParmDecl CompoundStmt #endif void no_return_type(int) {} #if false FunctionDecl empty CompoundStmt DeclStmt VarDecl local TemplateRef unique_ptr TemplateRef unique_ptr TypeRef struct S1 TypeRef struct S2 TypeRef struct S2 #endif void empty() { unique_ptr, S2>* local; } #if false ClassDecl Foo CXXMethod foo TemplateRef unique_ptr TypeRef struct S1 TypeRef struct S2 #endif class Foo { unique_ptr* foo(); }; #if false CXXMethod foo TemplateRef unique_ptr TypeRef struct S1 TypeRef struct S2 TypeRef class Foo CompoundStmt ReturnStmt UnexposedExpr CXXNullPtrLiteralExpr #endif unique_ptr* Foo::foo() { return nullptr; } /* OUTPUT: { "includes": [], "skipped_ranges": ["7:1-15:1", "17:1-33:1", "35:1-40:1", "42:1-53:1", "57:1-64:1", "68:1-79:1"], "usr2func": [{ "usr": 1246637699196435450, "detailed_name": "unique_ptr, S2> *as_return_type(unique_ptr *)", "qual_name_offset": 36, "short_name": "as_return_type", "spell": "33:37-33:51|33:1-33:92|2|-1", "bases": [], "vars": [], "callees": [], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": [], "derived": [], "uses": [] }, { "usr": 13067214284561914253, "detailed_name": "void no_return_type(int)", "qual_name_offset": 5, "short_name": "no_return_type", "spell": "40:6-40:20|40:1-40:28|2|-1", "bases": [], "vars": [], "callees": [], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": [], "derived": [], "uses": [] }, { "usr": 17922201480358737771, "detailed_name": "unique_ptr *Foo::foo()", "qual_name_offset": 20, "short_name": "foo", "spell": "79:26-79:29|79:1-79:51|1026|-1", "bases": [], "vars": [], "callees": [], "kind": 6, "parent_kind": 5, "storage": 0, "declarations": ["65:23-65:26|65:3-65:28|1025|-1"], "derived": [], "uses": [] }, { "usr": 18320186404467436976, "detailed_name": "void empty()", "qual_name_offset": 5, "short_name": "empty", "spell": "53:6-53:11|53:1-55:2|2|-1", "bases": [], "vars": [500112618220246], "callees": [], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": [], "derived": [], "uses": [] }], "usr2type": [{ "usr": 4310164820010458371, "detailed_name": "struct S1", "qual_name_offset": 7, "short_name": "S1", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 23, "parent_kind": 0, "declarations": ["4:8-4:10|4:1-4:10|1|-1"], "derived": [], "instances": [], "uses": ["15:30-15:32|4|-1", "33:23-33:25|4|-1", "33:63-33:65|4|-1", "54:25-54:27|4|-1", "65:14-65:16|4|-1", "79:12-79:14|4|-1"] }, { "usr": 12728490517004312484, "detailed_name": "struct S2", "qual_name_offset": 7, "short_name": "S2", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 23, "parent_kind": 0, "declarations": ["5:8-5:10|5:1-5:10|1|-1"], "derived": [], "instances": [], "uses": ["15:34-15:36|4|-1", "15:39-15:41|4|-1", "33:27-33:29|4|-1", "33:32-33:34|4|-1", "33:67-33:69|4|-1", "54:29-54:31|4|-1", "54:34-54:36|4|-1", "65:18-65:20|4|-1", "79:16-79:18|4|-1"] }, { "usr": 14209198335088845323, "detailed_name": "class unique_ptr", "qual_name_offset": 6, "short_name": "unique_ptr", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 5, "parent_kind": 0, "declarations": ["2:7-2:17|2:1-2:17|1|-1"], "derived": [], "instances": [2933643612409209903, 500112618220246], "uses": ["15:8-15:18|4|-1", "15:19-15:29|4|-1", "33:1-33:11|4|-1", "33:12-33:22|4|-1", "33:52-33:62|4|-1", "54:3-54:13|4|-1", "54:14-54:24|4|-1", "65:3-65:13|4|-1", "79:1-79:11|4|-1"] }, { "usr": 15041163540773201510, "detailed_name": "class Foo {}", "qual_name_offset": 6, "short_name": "Foo", "spell": "64:7-64:10|64:1-66:2|2|-1", "bases": [], "funcs": [17922201480358737771], "types": [], "vars": [], "alias_of": 0, "kind": 5, "parent_kind": 0, "declarations": [], "derived": [], "instances": [], "uses": ["79:21-79:24|4|-1"] }], "usr2var": [{ "usr": 500112618220246, "detailed_name": "unique_ptr, S2> *local", "qual_name_offset": 36, "short_name": "local", "spell": "54:39-54:44|54:3-54:44|2|-1", "type": 14209198335088845323, "kind": 13, "parent_kind": 12, "storage": 0, "declarations": [], "uses": [] }, { "usr": 2933643612409209903, "detailed_name": "extern unique_ptr, S2> f", "qual_name_offset": 42, "short_name": "f", "type": 14209198335088845323, "kind": 13, "parent_kind": 0, "storage": 1, "declarations": ["15:43-15:44|15:1-15:44|1|-1"], "uses": [] }] } */ ccls-0.20190823.6/index_tests/usage/type_usage_as_template_parameter_simple.cc000066400000000000000000000025301364776600300273260ustar00rootroot00000000000000template class unique_ptr {}; struct S; static unique_ptr foo; /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [], "usr2type": [{ "usr": 3286534761799572592, "detailed_name": "class unique_ptr {}", "qual_name_offset": 6, "short_name": "unique_ptr", "spell": "2:7-2:17|2:1-2:20|2|-1", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 5, "parent_kind": 0, "declarations": [], "derived": [], "instances": [3398408600781120939], "uses": ["6:8-6:18|4|-1"] }, { "usr": 4750332761459066907, "detailed_name": "struct S", "qual_name_offset": 7, "short_name": "S", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 23, "parent_kind": 0, "declarations": ["4:8-4:9|4:1-4:9|1|-1"], "derived": [], "instances": [], "uses": ["6:19-6:20|4|-1"] }], "usr2var": [{ "usr": 3398408600781120939, "detailed_name": "static unique_ptr foo", "qual_name_offset": 21, "short_name": "foo", "spell": "6:22-6:25|6:1-6:25|2|-1", "type": 3286534761799572592, "kind": 13, "parent_kind": 0, "storage": 2, "declarations": [], "uses": [] }] } */ ccls-0.20190823.6/index_tests/usage/type_usage_declare_extern.cc000066400000000000000000000015421364776600300244050ustar00rootroot00000000000000struct T {}; extern T t; /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [], "usr2type": [{ "usr": 5673439900521455039, "detailed_name": "struct T {}", "qual_name_offset": 7, "short_name": "T", "spell": "1:8-1:9|1:1-1:12|2|-1", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 23, "parent_kind": 0, "declarations": [], "derived": [], "instances": [1346710425945444872], "uses": ["3:8-3:9|4|-1"] }], "usr2var": [{ "usr": 1346710425945444872, "detailed_name": "extern T t", "qual_name_offset": 9, "short_name": "t", "type": 5673439900521455039, "kind": 13, "parent_kind": 0, "storage": 1, "declarations": ["3:10-3:11|3:1-3:11|1|-1"], "uses": [] }] } */ ccls-0.20190823.6/index_tests/usage/type_usage_declare_field.cc000066400000000000000000000044131364776600300241630ustar00rootroot00000000000000struct ForwardType; struct ImplementedType {}; struct Foo { ForwardType* a; ImplementedType b; }; /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [], "usr2type": [{ "usr": 8508299082070213750, "detailed_name": "struct ImplementedType {}", "qual_name_offset": 7, "short_name": "ImplementedType", "spell": "2:8-2:23|2:1-2:26|2|-1", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 23, "parent_kind": 0, "declarations": [], "derived": [], "instances": [14727441168849658842], "uses": ["6:3-6:18|4|-1"] }, { "usr": 13749354388332789217, "detailed_name": "struct ForwardType", "qual_name_offset": 7, "short_name": "ForwardType", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 23, "parent_kind": 0, "declarations": ["1:8-1:19|1:1-1:19|1|-1"], "derived": [], "instances": [14314859014962085433], "uses": ["5:3-5:14|4|-1"] }, { "usr": 15041163540773201510, "detailed_name": "struct Foo {}", "qual_name_offset": 7, "short_name": "Foo", "spell": "4:8-4:11|4:1-7:2|2|-1", "bases": [], "funcs": [], "types": [], "vars": [{ "L": 14314859014962085433, "R": 0 }, { "L": 14727441168849658842, "R": 64 }], "alias_of": 0, "kind": 23, "parent_kind": 0, "declarations": [], "derived": [], "instances": [], "uses": [] }], "usr2var": [{ "usr": 14314859014962085433, "detailed_name": "ForwardType *Foo::a", "qual_name_offset": 13, "short_name": "a", "spell": "5:16-5:17|5:3-5:17|1026|-1", "type": 13749354388332789217, "kind": 8, "parent_kind": 23, "storage": 0, "declarations": [], "uses": [] }, { "usr": 14727441168849658842, "detailed_name": "ImplementedType Foo::b", "qual_name_offset": 16, "short_name": "b", "spell": "6:19-6:20|6:3-6:20|1026|-1", "type": 8508299082070213750, "kind": 8, "parent_kind": 23, "storage": 0, "declarations": [], "uses": [] }] } */ ccls-0.20190823.6/index_tests/usage/type_usage_declare_local.cc000066400000000000000000000041561364776600300241760ustar00rootroot00000000000000struct ForwardType; struct ImplementedType {}; void Foo() { ForwardType* a; ImplementedType b; } /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [{ "usr": 4654328188330986029, "detailed_name": "void Foo()", "qual_name_offset": 5, "short_name": "Foo", "spell": "4:6-4:9|4:1-7:2|2|-1", "bases": [], "vars": [16374832544037266261, 2580122838476012357], "callees": [], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": [], "derived": [], "uses": [] }], "usr2type": [{ "usr": 8508299082070213750, "detailed_name": "struct ImplementedType {}", "qual_name_offset": 7, "short_name": "ImplementedType", "spell": "2:8-2:23|2:1-2:26|2|-1", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 23, "parent_kind": 0, "declarations": [], "derived": [], "instances": [2580122838476012357], "uses": ["6:3-6:18|4|-1"] }, { "usr": 13749354388332789217, "detailed_name": "struct ForwardType", "qual_name_offset": 7, "short_name": "ForwardType", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 23, "parent_kind": 0, "declarations": ["1:8-1:19|1:1-1:19|1|-1"], "derived": [], "instances": [16374832544037266261], "uses": ["5:3-5:14|4|-1"] }], "usr2var": [{ "usr": 2580122838476012357, "detailed_name": "ImplementedType b", "qual_name_offset": 16, "short_name": "b", "spell": "6:19-6:20|6:3-6:20|2|-1", "type": 8508299082070213750, "kind": 13, "parent_kind": 12, "storage": 0, "declarations": [], "uses": [] }, { "usr": 16374832544037266261, "detailed_name": "ForwardType *a", "qual_name_offset": 13, "short_name": "a", "spell": "5:16-5:17|5:3-5:17|2|-1", "type": 13749354388332789217, "kind": 13, "parent_kind": 12, "storage": 0, "declarations": [], "uses": [] }] } */ ccls-0.20190823.6/index_tests/usage/type_usage_declare_param.cc000066400000000000000000000042301364776600300241750ustar00rootroot00000000000000struct ForwardType; struct ImplementedType {}; void foo(ForwardType* f, ImplementedType a) {} /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [{ "usr": 1699390678058422036, "detailed_name": "void foo(ForwardType *f, ImplementedType a)", "qual_name_offset": 5, "short_name": "foo", "spell": "4:6-4:9|4:1-4:47|2|-1", "bases": [], "vars": [13058491096576226774, 11055777568039014776], "callees": [], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": [], "derived": [], "uses": [] }], "usr2type": [{ "usr": 8508299082070213750, "detailed_name": "struct ImplementedType {}", "qual_name_offset": 7, "short_name": "ImplementedType", "spell": "2:8-2:23|2:1-2:26|2|-1", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 23, "parent_kind": 0, "declarations": [], "derived": [], "instances": [11055777568039014776], "uses": ["4:26-4:41|4|-1"] }, { "usr": 13749354388332789217, "detailed_name": "struct ForwardType", "qual_name_offset": 7, "short_name": "ForwardType", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 23, "parent_kind": 0, "declarations": ["1:8-1:19|1:1-1:19|1|-1"], "derived": [], "instances": [13058491096576226774], "uses": ["4:10-4:21|4|-1"] }], "usr2var": [{ "usr": 11055777568039014776, "detailed_name": "ImplementedType a", "qual_name_offset": 16, "short_name": "a", "spell": "4:42-4:43|4:26-4:43|1026|-1", "type": 8508299082070213750, "kind": 253, "parent_kind": 12, "storage": 0, "declarations": [], "uses": [] }, { "usr": 13058491096576226774, "detailed_name": "ForwardType *f", "qual_name_offset": 13, "short_name": "f", "spell": "4:23-4:24|4:10-4:24|1026|-1", "type": 13749354388332789217, "kind": 253, "parent_kind": 12, "storage": 0, "declarations": [], "uses": [] }] } */ ccls-0.20190823.6/index_tests/usage/type_usage_declare_param_prototype.cc000066400000000000000000000031341364776600300263240ustar00rootroot00000000000000struct Foo; void foo(Foo* f, Foo*); void foo(Foo* f, Foo*) {} /* // TODO: No interesting usage on prototype. But maybe that's ok! // TODO: We should have the same variable declared for both prototype and // declaration. So it should have a usage marker on both. Then we could // rename parameters! OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [{ "usr": 8908726657907936744, "detailed_name": "void foo(Foo *f, Foo *)", "qual_name_offset": 5, "short_name": "foo", "spell": "4:6-4:9|4:1-4:26|2|-1", "bases": [], "vars": [13823260660189154978], "callees": [], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": ["3:6-3:9|3:1-3:23|1|-1"], "derived": [], "uses": [] }], "usr2type": [{ "usr": 15041163540773201510, "detailed_name": "struct Foo", "qual_name_offset": 7, "short_name": "Foo", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 23, "parent_kind": 0, "declarations": ["1:8-1:11|1:1-1:11|1|-1"], "derived": [], "instances": [13823260660189154978], "uses": ["3:10-3:13|4|-1", "3:18-3:21|4|-1", "4:10-4:13|4|-1", "4:18-4:21|4|-1"] }], "usr2var": [{ "usr": 13823260660189154978, "detailed_name": "Foo *f", "qual_name_offset": 5, "short_name": "f", "spell": "4:15-4:16|4:10-4:16|1026|-1", "type": 15041163540773201510, "kind": 253, "parent_kind": 12, "storage": 0, "declarations": [], "uses": [] }] } */ ccls-0.20190823.6/index_tests/usage/type_usage_declare_param_unnamed.cc000066400000000000000000000016621364776600300257120ustar00rootroot00000000000000struct ForwardType; void foo(ForwardType*) {} /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [{ "usr": 15327735280790448926, "detailed_name": "void foo(ForwardType *)", "qual_name_offset": 5, "short_name": "foo", "spell": "2:6-2:9|2:1-2:26|2|-1", "bases": [], "vars": [], "callees": [], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": [], "derived": [], "uses": [] }], "usr2type": [{ "usr": 13749354388332789217, "detailed_name": "struct ForwardType", "qual_name_offset": 7, "short_name": "ForwardType", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 23, "parent_kind": 0, "declarations": ["1:8-1:19|1:1-1:19|1|-1"], "derived": [], "instances": [], "uses": ["2:10-2:21|4|-1"] }], "usr2var": [] } */ ccls-0.20190823.6/index_tests/usage/type_usage_declare_qualifiers.cc000066400000000000000000000064531364776600300252520ustar00rootroot00000000000000struct Type {}; void foo(Type& a0, const Type& a1) { Type a2; Type* a3; const Type* a4; const Type* const a5 = nullptr; } /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [{ "usr": 16858540520096802573, "detailed_name": "void foo(Type &a0, const Type &a1)", "qual_name_offset": 5, "short_name": "foo", "spell": "3:6-3:9|3:1-8:2|2|-1", "bases": [], "vars": [7997456978847868736, 17228576662112939520, 15429032129697337561, 6081981442495435784, 5004072032239834773, 14939253431683105646], "callees": [], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": [], "derived": [], "uses": [] }], "usr2type": [{ "usr": 13487927231218873822, "detailed_name": "struct Type {}", "qual_name_offset": 7, "short_name": "Type", "spell": "1:8-1:12|1:1-1:15|2|-1", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 23, "parent_kind": 0, "declarations": [], "derived": [], "instances": [7997456978847868736, 17228576662112939520, 15429032129697337561, 6081981442495435784, 5004072032239834773, 14939253431683105646], "uses": ["3:10-3:14|4|-1", "3:26-3:30|4|-1", "4:3-4:7|4|-1", "5:3-5:7|4|-1", "6:9-6:13|4|-1", "7:9-7:13|4|-1"] }], "usr2var": [{ "usr": 5004072032239834773, "detailed_name": "const Type *a4", "qual_name_offset": 12, "short_name": "a4", "spell": "6:15-6:17|6:3-6:17|2|-1", "type": 13487927231218873822, "kind": 13, "parent_kind": 12, "storage": 0, "declarations": [], "uses": [] }, { "usr": 6081981442495435784, "detailed_name": "Type *a3", "qual_name_offset": 6, "short_name": "a3", "spell": "5:9-5:11|5:3-5:11|2|-1", "type": 13487927231218873822, "kind": 13, "parent_kind": 12, "storage": 0, "declarations": [], "uses": [] }, { "usr": 7997456978847868736, "detailed_name": "Type &a0", "qual_name_offset": 6, "short_name": "a0", "spell": "3:16-3:18|3:10-3:18|1026|-1", "type": 13487927231218873822, "kind": 253, "parent_kind": 12, "storage": 0, "declarations": [], "uses": [] }, { "usr": 14939253431683105646, "detailed_name": "const Type *const a5", "qual_name_offset": 18, "short_name": "a5", "hover": "const Type *const a5 = nullptr", "spell": "7:21-7:23|7:3-7:33|2|-1", "type": 13487927231218873822, "kind": 13, "parent_kind": 12, "storage": 0, "declarations": [], "uses": [] }, { "usr": 15429032129697337561, "detailed_name": "Type a2", "qual_name_offset": 5, "short_name": "a2", "spell": "4:8-4:10|4:3-4:10|2|-1", "type": 13487927231218873822, "kind": 13, "parent_kind": 12, "storage": 0, "declarations": [], "uses": [] }, { "usr": 17228576662112939520, "detailed_name": "const Type &a1", "qual_name_offset": 12, "short_name": "a1", "spell": "3:32-3:34|3:20-3:34|1026|-1", "type": 13487927231218873822, "kind": 253, "parent_kind": 12, "storage": 0, "declarations": [], "uses": [] }] } */ ccls-0.20190823.6/index_tests/usage/type_usage_declare_static.cc000066400000000000000000000016061364776600300243700ustar00rootroot00000000000000struct Type {}; static Type t; /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [], "usr2type": [{ "usr": 13487927231218873822, "detailed_name": "struct Type {}", "qual_name_offset": 7, "short_name": "Type", "spell": "1:8-1:12|1:1-1:15|2|-1", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 23, "parent_kind": 0, "declarations": [], "derived": [], "instances": [6601831367240627080], "uses": ["2:8-2:12|4|-1"] }], "usr2var": [{ "usr": 6601831367240627080, "detailed_name": "static Type t", "qual_name_offset": 12, "short_name": "t", "spell": "2:13-2:14|2:1-2:14|2|-1", "type": 13487927231218873822, "kind": 13, "parent_kind": 0, "storage": 2, "declarations": [], "uses": [] }] } */ ccls-0.20190823.6/index_tests/usage/type_usage_on_return_type.cc000066400000000000000000000064771364776600300245110ustar00rootroot00000000000000struct Type; Type* foo(); Type* foo(); Type* foo() { return nullptr; } class Foo { Type* Get(int); void Empty(); }; Type* Foo::Get(int) { return nullptr; } void Foo::Empty() {} extern const Type& external(); static Type* bar(); static Type* bar() { return nullptr; } /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [{ "usr": 4240751906910175539, "detailed_name": "void Foo::Empty()", "qual_name_offset": 5, "short_name": "Empty", "spell": "13:11-13:16|13:1-13:21|1026|-1", "bases": [], "vars": [], "callees": [], "kind": 6, "parent_kind": 5, "storage": 0, "declarations": ["9:8-9:13|9:3-9:15|1025|-1"], "derived": [], "uses": [] }, { "usr": 4259594751088586730, "detailed_name": "Type *foo()", "qual_name_offset": 6, "short_name": "foo", "spell": "5:7-5:10|5:1-5:32|2|-1", "bases": [], "vars": [], "callees": [], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": ["3:7-3:10|3:1-3:12|1|-1", "4:7-4:10|4:1-4:12|1|-1"], "derived": [], "uses": [] }, { "usr": 7746867874366499515, "detailed_name": "extern const Type &external()", "qual_name_offset": 19, "short_name": "external", "bases": [], "vars": [], "callees": [], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": ["15:20-15:28|15:1-15:30|1|-1"], "derived": [], "uses": [] }, { "usr": 13402221340333431092, "detailed_name": "Type *Foo::Get(int)", "qual_name_offset": 6, "short_name": "Get", "spell": "12:12-12:15|12:1-12:40|1026|-1", "bases": [], "vars": [], "callees": [], "kind": 6, "parent_kind": 5, "storage": 0, "declarations": ["8:9-8:12|8:3-8:17|1025|-1"], "derived": [], "uses": [] }, { "usr": 18408440185620243373, "detailed_name": "static Type *bar()", "qual_name_offset": 13, "short_name": "bar", "spell": "18:14-18:17|18:1-18:39|2|-1", "bases": [], "vars": [], "callees": [], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": ["17:14-17:17|17:1-17:19|1|-1"], "derived": [], "uses": [] }], "usr2type": [{ "usr": 13487927231218873822, "detailed_name": "struct Type", "qual_name_offset": 7, "short_name": "Type", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 23, "parent_kind": 0, "declarations": ["1:8-1:12|1:1-1:12|1|-1"], "derived": [], "instances": [], "uses": ["3:1-3:5|4|-1", "4:1-4:5|4|-1", "5:1-5:5|4|-1", "8:3-8:7|4|-1", "12:1-12:5|4|-1", "15:14-15:18|4|-1", "17:8-17:12|4|-1", "18:8-18:12|4|-1"] }, { "usr": 15041163540773201510, "detailed_name": "class Foo {}", "qual_name_offset": 6, "short_name": "Foo", "spell": "7:7-7:10|7:1-10:2|2|-1", "bases": [], "funcs": [13402221340333431092, 4240751906910175539], "types": [], "vars": [], "alias_of": 0, "kind": 5, "parent_kind": 0, "declarations": [], "derived": [], "instances": [], "uses": ["12:7-12:10|4|-1", "13:6-13:9|4|-1"] }], "usr2var": [] } */ ccls-0.20190823.6/index_tests/usage/type_usage_typedef_and_using.cc000066400000000000000000000076341364776600300251200ustar00rootroot00000000000000struct Foo; using Foo1 = Foo*; typedef Foo Foo2; using Foo3 = Foo1; using Foo4 = int; void accept(Foo*) {} void accept1(Foo1*) {} void accept2(Foo2*) {} void accept3(Foo3*) {} /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [{ "usr": 558620830317390922, "detailed_name": "void accept1(Foo1 *)", "qual_name_offset": 5, "short_name": "accept1", "spell": "8:6-8:13|8:1-8:23|2|-1", "bases": [], "vars": [], "callees": [], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": [], "derived": [], "uses": [] }, { "usr": 9119341505144503905, "detailed_name": "void accept(Foo *)", "qual_name_offset": 5, "short_name": "accept", "spell": "7:6-7:12|7:1-7:21|2|-1", "bases": [], "vars": [], "callees": [], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": [], "derived": [], "uses": [] }, { "usr": 10523262907746124479, "detailed_name": "void accept2(Foo2 *)", "qual_name_offset": 5, "short_name": "accept2", "spell": "9:6-9:13|9:1-9:23|2|-1", "bases": [], "vars": [], "callees": [], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": [], "derived": [], "uses": [] }, { "usr": 14986366321326974406, "detailed_name": "void accept3(Foo3 *)", "qual_name_offset": 5, "short_name": "accept3", "spell": "10:6-10:13|10:1-10:23|2|-1", "bases": [], "vars": [], "callees": [], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": [], "derived": [], "uses": [] }], "usr2type": [{ "usr": 1544499294580512394, "detailed_name": "using Foo1 = Foo *", "qual_name_offset": 6, "short_name": "Foo1", "spell": "2:7-2:11|2:1-2:18|2|-1", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 15041163540773201510, "kind": 252, "parent_kind": 0, "declarations": [], "derived": [], "instances": [], "uses": ["4:14-4:18|4|-1", "8:14-8:18|4|-1"] }, { "usr": 2638219001294786365, "detailed_name": "using Foo4 = int", "qual_name_offset": 6, "short_name": "Foo4", "spell": "5:7-5:11|5:1-5:17|2|-1", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 252, "parent_kind": 0, "declarations": [], "derived": [], "instances": [], "uses": [] }, { "usr": 15041163540773201510, "detailed_name": "struct Foo", "qual_name_offset": 7, "short_name": "Foo", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 23, "parent_kind": 0, "declarations": ["1:8-1:11|1:1-1:11|1|-1"], "derived": [], "instances": [], "uses": ["2:14-2:17|4|-1", "3:9-3:12|4|-1", "7:13-7:16|4|-1"] }, { "usr": 15466821155413653804, "detailed_name": "typedef Foo Foo2", "qual_name_offset": 12, "short_name": "Foo2", "spell": "3:13-3:17|3:1-3:17|2|-1", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 15041163540773201510, "kind": 252, "parent_kind": 0, "declarations": [], "derived": [], "instances": [], "uses": ["9:14-9:18|4|-1"] }, { "usr": 17897026942631673064, "detailed_name": "using Foo3 = Foo1", "qual_name_offset": 6, "short_name": "Foo3", "spell": "4:7-4:11|4:1-4:18|2|-1", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 1544499294580512394, "kind": 252, "parent_kind": 0, "declarations": [], "derived": [], "instances": [], "uses": ["10:14-10:18|4|-1"] }], "usr2var": [] } */ ccls-0.20190823.6/index_tests/usage/type_usage_typedef_and_using_template.cc000066400000000000000000000027321364776600300270050ustar00rootroot00000000000000template struct Foo; using Foo1 = Foo; typedef Foo Foo2; /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [], "usr2type": [{ "usr": 1544499294580512394, "detailed_name": "using Foo1 = Foo", "qual_name_offset": 6, "short_name": "Foo1", "spell": "4:7-4:11|4:1-4:22|2|-1", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 10528472276654770367, "kind": 252, "parent_kind": 0, "declarations": [], "derived": [], "instances": [], "uses": ["5:13-5:17|4|-1"] }, { "usr": 10528472276654770367, "detailed_name": "struct Foo", "qual_name_offset": 7, "short_name": "Foo", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 5, "parent_kind": 0, "declarations": ["2:8-2:11|2:1-2:11|1|-1"], "derived": [], "instances": [], "uses": ["4:14-4:17|4|-1", "5:9-5:12|4|-1"] }, { "usr": 15933698173231330933, "detailed_name": "typedef Foo Foo2", "qual_name_offset": 18, "short_name": "Foo2", "spell": "5:19-5:23|5:1-5:23|2|-1", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 10528472276654770367, "kind": 252, "parent_kind": 0, "declarations": [], "derived": [], "instances": [], "uses": [] }], "usr2var": [] } */ ccls-0.20190823.6/index_tests/usage/type_usage_various.cc000066400000000000000000000033731364776600300231150ustar00rootroot00000000000000class Foo { Foo* make(); }; Foo* Foo::make() { Foo f; return nullptr; } extern Foo foo; /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [{ "usr": 9488177941273031343, "detailed_name": "Foo *Foo::make()", "qual_name_offset": 5, "short_name": "make", "spell": "5:11-5:15|5:1-8:2|1026|-1", "bases": [], "vars": [16380484338511689669], "callees": [], "kind": 6, "parent_kind": 5, "storage": 0, "declarations": ["2:8-2:12|2:3-2:14|1025|-1"], "derived": [], "uses": [] }], "usr2type": [{ "usr": 15041163540773201510, "detailed_name": "class Foo {}", "qual_name_offset": 6, "short_name": "Foo", "spell": "1:7-1:10|1:1-3:2|2|-1", "bases": [], "funcs": [9488177941273031343], "types": [], "vars": [], "alias_of": 0, "kind": 5, "parent_kind": 0, "declarations": [], "derived": [], "instances": [16380484338511689669, 14455976355866885943], "uses": ["2:3-2:6|4|-1", "5:1-5:4|4|-1", "5:6-5:9|4|-1", "6:3-6:6|4|-1", "10:8-10:11|4|-1"] }], "usr2var": [{ "usr": 14455976355866885943, "detailed_name": "extern Foo foo", "qual_name_offset": 11, "short_name": "foo", "type": 15041163540773201510, "kind": 13, "parent_kind": 0, "storage": 1, "declarations": ["10:12-10:15|10:1-10:15|1|-1"], "uses": [] }, { "usr": 16380484338511689669, "detailed_name": "Foo f", "qual_name_offset": 4, "short_name": "f", "spell": "6:7-6:8|6:3-6:8|2|-1", "type": 15041163540773201510, "kind": 13, "parent_kind": 6, "storage": 0, "declarations": [], "uses": [] }] } */ ccls-0.20190823.6/index_tests/usage/usage_inside_of_call.cc000066400000000000000000000066751364776600300233260ustar00rootroot00000000000000void called(int a); int gen(); struct Foo { static int static_var; int field_var; }; int Foo::static_var = 0; void foo() { int a = 5; called(a + gen() + Foo().field_var + Foo::static_var); } /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [{ "usr": 4259594751088586730, "detailed_name": "void foo()", "qual_name_offset": 5, "short_name": "foo", "spell": "12:6-12:9|12:1-15:2|2|-1", "bases": [], "vars": [8039186520399841081], "callees": ["14:3-14:9|18319417758892371313|3|16420", "14:14-14:17|11404602816585117695|3|16420"], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": [], "derived": [], "uses": [] }, { "usr": 11404602816585117695, "detailed_name": "int gen()", "qual_name_offset": 4, "short_name": "gen", "bases": [], "vars": [], "callees": [], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": ["3:5-3:8|3:1-3:10|1|-1"], "derived": [], "uses": ["14:14-14:17|16420|-1"] }, { "usr": 18319417758892371313, "detailed_name": "void called(int a)", "qual_name_offset": 5, "short_name": "called", "bases": [], "vars": [], "callees": [], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": ["1:6-1:12|1:1-1:19|1|-1"], "derived": [], "uses": ["14:3-14:9|16420|-1"] }], "usr2type": [{ "usr": 53, "detailed_name": "", "qual_name_offset": 0, "short_name": "", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 0, "parent_kind": 0, "declarations": [], "derived": [], "instances": [11489549839875479478, 9648311402855509901, 11489549839875479478, 8039186520399841081], "uses": [] }, { "usr": 15041163540773201510, "detailed_name": "struct Foo {}", "qual_name_offset": 7, "short_name": "Foo", "spell": "5:8-5:11|5:1-8:2|2|-1", "bases": [], "funcs": [], "types": [], "vars": [{ "L": 9648311402855509901, "R": 0 }], "alias_of": 0, "kind": 23, "parent_kind": 0, "declarations": [], "derived": [], "instances": [], "uses": ["10:5-10:8|4|-1", "14:22-14:25|4|-1", "14:40-14:43|4|-1"] }], "usr2var": [{ "usr": 8039186520399841081, "detailed_name": "int a", "qual_name_offset": 4, "short_name": "a", "hover": "int a = 5", "spell": "13:7-13:8|13:3-13:12|2|-1", "type": 53, "kind": 13, "parent_kind": 12, "storage": 0, "declarations": [], "uses": ["14:10-14:11|12|-1"] }, { "usr": 9648311402855509901, "detailed_name": "int Foo::field_var", "qual_name_offset": 4, "short_name": "field_var", "spell": "7:7-7:16|7:3-7:16|1026|-1", "type": 53, "kind": 8, "parent_kind": 23, "storage": 0, "declarations": [], "uses": ["14:28-14:37|12|-1"] }, { "usr": 11489549839875479478, "detailed_name": "static int Foo::static_var", "qual_name_offset": 11, "short_name": "static_var", "spell": "10:10-10:20|10:1-10:24|1026|-1", "type": 53, "kind": 13, "parent_kind": 23, "storage": 2, "declarations": ["6:14-6:24|6:3-6:24|1025|-1"], "uses": ["14:45-14:55|12|-1"] }] } */ ccls-0.20190823.6/index_tests/usage/usage_inside_of_call_simple.cc000066400000000000000000000026561364776600300246720ustar00rootroot00000000000000void called(int a); int gen() { return 1; } void foo() { called(gen() * gen()); } /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [{ "usr": 4259594751088586730, "detailed_name": "void foo()", "qual_name_offset": 5, "short_name": "foo", "spell": "5:6-5:9|5:1-7:2|2|-1", "bases": [], "vars": [], "callees": ["6:3-6:9|18319417758892371313|3|16420", "6:10-6:13|11404602816585117695|3|16420", "6:18-6:21|11404602816585117695|3|16420"], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": [], "derived": [], "uses": [] }, { "usr": 11404602816585117695, "detailed_name": "int gen()", "qual_name_offset": 4, "short_name": "gen", "spell": "3:5-3:8|3:1-3:24|2|-1", "bases": [], "vars": [], "callees": [], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": [], "derived": [], "uses": ["6:10-6:13|16420|-1", "6:18-6:21|16420|-1"] }, { "usr": 18319417758892371313, "detailed_name": "void called(int a)", "qual_name_offset": 5, "short_name": "called", "bases": [], "vars": [], "callees": [], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": ["1:6-1:12|1:1-1:19|1|-1"], "derived": [], "uses": ["6:3-6:9|16420|-1"] }], "usr2type": [], "usr2var": [] } */ ccls-0.20190823.6/index_tests/usage/var_usage_call_function.cc000066400000000000000000000026461364776600300240560ustar00rootroot00000000000000void called() {} void caller() { auto x = &called; x(); called(); } /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [{ "usr": 468307235068920063, "detailed_name": "void called()", "qual_name_offset": 5, "short_name": "called", "spell": "1:6-1:12|1:1-1:17|2|-1", "bases": [], "vars": [], "callees": [], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": [], "derived": [], "uses": ["4:13-4:19|132|-1", "7:3-7:9|16420|-1"] }, { "usr": 11404881820527069090, "detailed_name": "void caller()", "qual_name_offset": 5, "short_name": "caller", "spell": "3:6-3:12|3:1-8:2|2|-1", "bases": [], "vars": [9121974011454213596], "callees": ["4:13-4:19|468307235068920063|3|132", "4:13-4:19|468307235068920063|3|132", "7:3-7:9|468307235068920063|3|16420"], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": [], "derived": [], "uses": [] }], "usr2type": [], "usr2var": [{ "usr": 9121974011454213596, "detailed_name": "void (*)() x", "qual_name_offset": 11, "short_name": "x", "hover": "void (*)() x = &called", "spell": "4:8-4:9|4:3-4:19|2|-1", "type": 0, "kind": 13, "parent_kind": 12, "storage": 0, "declarations": [], "uses": ["5:3-5:4|16428|-1"] }] } */ ccls-0.20190823.6/index_tests/usage/var_usage_class_member.cc000066400000000000000000000072161364776600300236700ustar00rootroot00000000000000class Foo { public: int x; int y; }; void accept(int); void accept(int*); void foo() { Foo f; f.x = 3; f.x += 5; accept(f.x); accept(f.x + 20); accept(&f.x); accept(f.y); } /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [{ "usr": 4259594751088586730, "detailed_name": "void foo()", "qual_name_offset": 5, "short_name": "foo", "spell": "10:6-10:9|10:1-18:2|2|-1", "bases": [], "vars": [14669930844300034456], "callees": ["14:3-14:9|17175780305784503374|3|16420", "15:3-15:9|17175780305784503374|3|16420", "16:3-16:9|12086644540399881766|3|16420", "17:3-17:9|17175780305784503374|3|16420"], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": [], "derived": [], "uses": [] }, { "usr": 12086644540399881766, "detailed_name": "void accept(int *)", "qual_name_offset": 5, "short_name": "accept", "bases": [], "vars": [], "callees": [], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": ["8:6-8:12|8:1-8:18|1|-1"], "derived": [], "uses": ["16:3-16:9|16420|-1"] }, { "usr": 17175780305784503374, "detailed_name": "void accept(int)", "qual_name_offset": 5, "short_name": "accept", "bases": [], "vars": [], "callees": [], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": ["7:6-7:12|7:1-7:17|1|-1"], "derived": [], "uses": ["14:3-14:9|16420|-1", "15:3-15:9|16420|-1", "17:3-17:9|16420|-1"] }], "usr2type": [{ "usr": 53, "detailed_name": "", "qual_name_offset": 0, "short_name": "", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 0, "parent_kind": 0, "declarations": [], "derived": [], "instances": [4220150017963593039, 3873837747174060388], "uses": [] }, { "usr": 15041163540773201510, "detailed_name": "class Foo {}", "qual_name_offset": 6, "short_name": "Foo", "spell": "1:7-1:10|1:1-5:2|2|-1", "bases": [], "funcs": [], "types": [], "vars": [{ "L": 4220150017963593039, "R": 0 }, { "L": 3873837747174060388, "R": 32 }], "alias_of": 0, "kind": 5, "parent_kind": 0, "declarations": [], "derived": [], "instances": [14669930844300034456], "uses": ["11:3-11:6|4|-1"] }], "usr2var": [{ "usr": 3873837747174060388, "detailed_name": "int Foo::y", "qual_name_offset": 4, "short_name": "y", "spell": "4:7-4:8|4:3-4:8|1026|-1", "type": 53, "kind": 8, "parent_kind": 5, "storage": 0, "declarations": [], "uses": ["17:12-17:13|12|-1"] }, { "usr": 4220150017963593039, "detailed_name": "int Foo::x", "qual_name_offset": 4, "short_name": "x", "spell": "3:7-3:8|3:3-3:8|1026|-1", "type": 53, "kind": 8, "parent_kind": 5, "storage": 0, "declarations": [], "uses": ["12:5-12:6|20|-1", "13:5-13:6|4|-1", "14:12-14:13|12|-1", "15:12-15:13|12|-1", "16:13-16:14|132|-1"] }, { "usr": 14669930844300034456, "detailed_name": "Foo f", "qual_name_offset": 4, "short_name": "f", "spell": "11:7-11:8|11:3-11:8|2|-1", "type": 15041163540773201510, "kind": 13, "parent_kind": 12, "storage": 0, "declarations": [], "uses": ["12:3-12:4|4|-1", "13:3-13:4|4|-1", "14:10-14:11|4|-1", "15:10-15:11|4|-1", "16:11-16:12|4|-1", "17:10-17:11|4|-1"] }] } */ ccls-0.20190823.6/index_tests/usage/var_usage_class_member_static.cc000066400000000000000000000037721364776600300252420ustar00rootroot00000000000000struct Foo { static int x; }; void accept(int); void foo() { accept(Foo::x); } /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [{ "usr": 4259594751088586730, "detailed_name": "void foo()", "qual_name_offset": 5, "short_name": "foo", "spell": "7:6-7:9|7:1-9:2|2|-1", "bases": [], "vars": [], "callees": ["8:3-8:9|17175780305784503374|3|16420"], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": [], "derived": [], "uses": [] }, { "usr": 17175780305784503374, "detailed_name": "void accept(int)", "qual_name_offset": 5, "short_name": "accept", "bases": [], "vars": [], "callees": [], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": ["5:6-5:12|5:1-5:17|1|-1"], "derived": [], "uses": ["8:3-8:9|16420|-1"] }], "usr2type": [{ "usr": 53, "detailed_name": "", "qual_name_offset": 0, "short_name": "", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 0, "parent_kind": 0, "declarations": [], "derived": [], "instances": [8599782646965457351], "uses": [] }, { "usr": 15041163540773201510, "detailed_name": "struct Foo {}", "qual_name_offset": 7, "short_name": "Foo", "spell": "1:8-1:11|1:1-3:2|2|-1", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 23, "parent_kind": 0, "declarations": [], "derived": [], "instances": [], "uses": ["8:10-8:13|4|-1"] }], "usr2var": [{ "usr": 8599782646965457351, "detailed_name": "static int Foo::x", "qual_name_offset": 11, "short_name": "x", "type": 53, "kind": 13, "parent_kind": 23, "storage": 2, "declarations": ["2:14-2:15|2:3-2:15|1025|-1"], "uses": ["8:15-8:16|12|-1"] }] } */ ccls-0.20190823.6/index_tests/usage/var_usage_cstyle_cast.cc000066400000000000000000000047741364776600300235570ustar00rootroot00000000000000enum VarType {}; struct Holder { static constexpr VarType static_var = (VarType)0x0; }; const VarType Holder::static_var; /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [], "usr2type": [{ "usr": 5792006888140599735, "detailed_name": "enum VarType {}", "qual_name_offset": 5, "short_name": "VarType", "spell": "1:6-1:13|1:1-1:16|2|-1", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 10, "parent_kind": 0, "declarations": [], "derived": [], "instances": [7057400933868440116, 7057400933868440116], "uses": ["4:20-4:27|4|-1", "4:42-4:49|4|-1", "7:7-7:14|4|-1"] }, { "usr": 10028537921178202800, "detailed_name": "struct Holder {}", "qual_name_offset": 7, "short_name": "Holder", "spell": "3:8-3:14|3:1-5:2|2|-1", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 23, "parent_kind": 0, "declarations": [], "derived": [], "instances": [], "uses": ["7:15-7:21|4|-1"] }], "usr2var": [{ "usr": 7057400933868440116, "detailed_name": "static constexpr VarType Holder::static_var", "qual_name_offset": 25, "short_name": "static_var", "hover": "static constexpr VarType Holder::static_var = (VarType)0x0", "spell": "7:23-7:33|7:1-7:33|1026|-1", "type": 5792006888140599735, "kind": 13, "parent_kind": 23, "storage": 2, "declarations": ["4:28-4:38|4:3-4:53|1025|-1"], "uses": [] }] } */ //#include //#include //#include //#include //#include //#include //#include //#include //#include //#include //#include //#include //#include //#include //#include //#include //#include //#include //#include //#include //#include //#include //#include //#include //#include //#include //#include //#include //#include //#include //#include //#include //#include //#include //#include //#include //#include //#include //#include //#include //#include //#include //#include ccls-0.20190823.6/index_tests/usage/var_usage_extern.cc000066400000000000000000000022031364776600300225300ustar00rootroot00000000000000extern int a; void foo() { a = 5; } /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [{ "usr": 4259594751088586730, "detailed_name": "void foo()", "qual_name_offset": 5, "short_name": "foo", "spell": "3:6-3:9|3:1-5:2|2|-1", "bases": [], "vars": [], "callees": [], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": [], "derived": [], "uses": [] }], "usr2type": [{ "usr": 53, "detailed_name": "", "qual_name_offset": 0, "short_name": "", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 0, "parent_kind": 0, "declarations": [], "derived": [], "instances": [16721564935990383768], "uses": [] }], "usr2var": [{ "usr": 16721564935990383768, "detailed_name": "extern int a", "qual_name_offset": 11, "short_name": "a", "type": 53, "kind": 13, "parent_kind": 0, "storage": 1, "declarations": ["1:12-1:13|1:1-1:13|1|-1"], "uses": ["4:3-4:4|20|-1"] }] } */ ccls-0.20190823.6/index_tests/usage/var_usage_func_parameter.cc000066400000000000000000000022431364776600300242220ustar00rootroot00000000000000void foo(int a) { a += 10; } /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [{ "usr": 11998306017310352355, "detailed_name": "void foo(int a)", "qual_name_offset": 5, "short_name": "foo", "spell": "1:6-1:9|1:1-3:2|2|-1", "bases": [], "vars": [10063793875496522529], "callees": [], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": [], "derived": [], "uses": [] }], "usr2type": [{ "usr": 53, "detailed_name": "", "qual_name_offset": 0, "short_name": "", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 0, "parent_kind": 0, "declarations": [], "derived": [], "instances": [10063793875496522529], "uses": [] }], "usr2var": [{ "usr": 10063793875496522529, "detailed_name": "int a", "qual_name_offset": 4, "short_name": "a", "spell": "1:14-1:15|1:10-1:15|1026|-1", "type": 53, "kind": 253, "parent_kind": 12, "storage": 0, "declarations": [], "uses": ["2:3-2:4|4|-1"] }] } */ ccls-0.20190823.6/index_tests/usage/var_usage_local.cc000066400000000000000000000022301364776600300223150ustar00rootroot00000000000000void foo() { int x; x = 3; } /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [{ "usr": 4259594751088586730, "detailed_name": "void foo()", "qual_name_offset": 5, "short_name": "foo", "spell": "1:6-1:9|1:1-4:2|2|-1", "bases": [], "vars": [14014650769929566957], "callees": [], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": [], "derived": [], "uses": [] }], "usr2type": [{ "usr": 53, "detailed_name": "", "qual_name_offset": 0, "short_name": "", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 0, "parent_kind": 0, "declarations": [], "derived": [], "instances": [14014650769929566957], "uses": [] }], "usr2var": [{ "usr": 14014650769929566957, "detailed_name": "int x", "qual_name_offset": 4, "short_name": "x", "spell": "2:7-2:8|2:3-2:8|2|-1", "type": 53, "kind": 13, "parent_kind": 12, "storage": 0, "declarations": [], "uses": ["3:3-3:4|20|-1"] }] } */ ccls-0.20190823.6/index_tests/usage/var_usage_shadowed_local.cc000066400000000000000000000030621364776600300241770ustar00rootroot00000000000000void foo() { int a; a = 1; { int a; a = 2; } a = 3; } /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [{ "usr": 4259594751088586730, "detailed_name": "void foo()", "qual_name_offset": 5, "short_name": "foo", "spell": "1:6-1:9|1:1-9:2|2|-1", "bases": [], "vars": [13311055950748663970, 14036425367303419504], "callees": [], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": [], "derived": [], "uses": [] }], "usr2type": [{ "usr": 53, "detailed_name": "", "qual_name_offset": 0, "short_name": "", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 0, "parent_kind": 0, "declarations": [], "derived": [], "instances": [13311055950748663970, 14036425367303419504], "uses": [] }], "usr2var": [{ "usr": 13311055950748663970, "detailed_name": "int a", "qual_name_offset": 4, "short_name": "a", "spell": "2:7-2:8|2:3-2:8|2|-1", "type": 53, "kind": 13, "parent_kind": 12, "storage": 0, "declarations": [], "uses": ["3:3-3:4|20|-1", "8:3-8:4|20|-1"] }, { "usr": 14036425367303419504, "detailed_name": "int a", "qual_name_offset": 4, "short_name": "a", "spell": "5:9-5:10|5:5-5:10|2|-1", "type": 53, "kind": 13, "parent_kind": 12, "storage": 0, "declarations": [], "uses": ["6:5-6:6|20|-1"] }] } */ ccls-0.20190823.6/index_tests/usage/var_usage_shadowed_parameter.cc000066400000000000000000000030721364776600300250660ustar00rootroot00000000000000void foo(int a) { a = 1; { int a; a = 2; } a = 3; } /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [{ "usr": 11998306017310352355, "detailed_name": "void foo(int a)", "qual_name_offset": 5, "short_name": "foo", "spell": "1:6-1:9|1:1-8:2|2|-1", "bases": [], "vars": [11608231465452906059, 6997229590862003559], "callees": [], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": [], "derived": [], "uses": [] }], "usr2type": [{ "usr": 53, "detailed_name": "", "qual_name_offset": 0, "short_name": "", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 0, "parent_kind": 0, "declarations": [], "derived": [], "instances": [11608231465452906059, 6997229590862003559], "uses": [] }], "usr2var": [{ "usr": 6997229590862003559, "detailed_name": "int a", "qual_name_offset": 4, "short_name": "a", "spell": "4:9-4:10|4:5-4:10|2|-1", "type": 53, "kind": 13, "parent_kind": 12, "storage": 0, "declarations": [], "uses": ["5:5-5:6|20|-1"] }, { "usr": 11608231465452906059, "detailed_name": "int a", "qual_name_offset": 4, "short_name": "a", "spell": "1:14-1:15|1:10-1:15|1026|-1", "type": 53, "kind": 253, "parent_kind": 12, "storage": 0, "declarations": [], "uses": ["2:3-2:4|20|-1", "7:3-7:4|20|-1"] }] } */ ccls-0.20190823.6/index_tests/usage/var_usage_static.cc000066400000000000000000000022251364776600300225160ustar00rootroot00000000000000static int a; void foo() { a = 3; } /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [{ "usr": 4259594751088586730, "detailed_name": "void foo()", "qual_name_offset": 5, "short_name": "foo", "spell": "3:6-3:9|3:1-5:2|2|-1", "bases": [], "vars": [], "callees": [], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": [], "derived": [], "uses": [] }], "usr2type": [{ "usr": 53, "detailed_name": "", "qual_name_offset": 0, "short_name": "", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 0, "parent_kind": 0, "declarations": [], "derived": [], "instances": [11823161916242867318], "uses": [] }], "usr2var": [{ "usr": 11823161916242867318, "detailed_name": "static int a", "qual_name_offset": 11, "short_name": "a", "spell": "1:12-1:13|1:1-1:13|2|-1", "type": 53, "kind": 13, "parent_kind": 0, "storage": 2, "declarations": [], "uses": ["4:3-4:4|20|-1"] }] } */ ccls-0.20190823.6/index_tests/vars/000077500000000000000000000000001364776600300165325ustar00rootroot00000000000000ccls-0.20190823.6/index_tests/vars/class_member.cc000066400000000000000000000017121364776600300214760ustar00rootroot00000000000000class Foo { Foo* member; }; /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [], "usr2type": [{ "usr": 15041163540773201510, "detailed_name": "class Foo {}", "qual_name_offset": 6, "short_name": "Foo", "spell": "1:7-1:10|1:1-3:2|2|-1", "bases": [], "funcs": [], "types": [], "vars": [{ "L": 13799811842374292251, "R": 0 }], "alias_of": 0, "kind": 5, "parent_kind": 0, "declarations": [], "derived": [], "instances": [13799811842374292251], "uses": ["2:3-2:6|4|-1"] }], "usr2var": [{ "usr": 13799811842374292251, "detailed_name": "Foo *Foo::member", "qual_name_offset": 5, "short_name": "member", "spell": "2:8-2:14|2:3-2:14|1026|-1", "type": 15041163540773201510, "kind": 8, "parent_kind": 5, "storage": 0, "declarations": [], "uses": [] }] } */ ccls-0.20190823.6/index_tests/vars/class_static_member.cc000066400000000000000000000020101364776600300230350ustar00rootroot00000000000000class Foo { static Foo* member; }; Foo* Foo::member = nullptr; /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [], "usr2type": [{ "usr": 15041163540773201510, "detailed_name": "class Foo {}", "qual_name_offset": 6, "short_name": "Foo", "spell": "1:7-1:10|1:1-3:2|2|-1", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 5, "parent_kind": 0, "declarations": [], "derived": [], "instances": [5844987037615239736, 5844987037615239736], "uses": ["2:10-2:13|4|-1", "4:1-4:4|4|-1", "4:6-4:9|4|-1"] }], "usr2var": [{ "usr": 5844987037615239736, "detailed_name": "static Foo *Foo::member", "qual_name_offset": 12, "short_name": "member", "spell": "4:11-4:17|4:1-4:27|1026|-1", "type": 15041163540773201510, "kind": 13, "parent_kind": 5, "storage": 2, "declarations": ["2:15-2:21|2:3-2:21|1025|-1"], "uses": [] }] } */ ccls-0.20190823.6/index_tests/vars/class_static_member_decl_only.cc000066400000000000000000000022571364776600300251020ustar00rootroot00000000000000class Foo { static int member; }; /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [], "usr2type": [{ "usr": 53, "detailed_name": "", "qual_name_offset": 0, "short_name": "", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 0, "parent_kind": 0, "declarations": [], "derived": [], "instances": [5844987037615239736], "uses": [] }, { "usr": 15041163540773201510, "detailed_name": "class Foo {}", "qual_name_offset": 6, "short_name": "Foo", "spell": "1:7-1:10|1:1-3:2|2|-1", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 5, "parent_kind": 0, "declarations": [], "derived": [], "instances": [], "uses": [] }], "usr2var": [{ "usr": 5844987037615239736, "detailed_name": "static int Foo::member", "qual_name_offset": 11, "short_name": "member", "type": 53, "kind": 13, "parent_kind": 5, "storage": 2, "declarations": ["2:14-2:20|2:3-2:20|1025|-1"], "uses": [] }] } */ ccls-0.20190823.6/index_tests/vars/deduce_auto_type.cc000066400000000000000000000033341364776600300223660ustar00rootroot00000000000000class Foo {}; void f() { auto x = new Foo(); auto* y = new Foo(); } /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [{ "usr": 880549676430489861, "detailed_name": "void f()", "qual_name_offset": 5, "short_name": "f", "spell": "2:6-2:7|2:1-5:2|2|-1", "bases": [], "vars": [10601729374837386290, 18422884837902130475], "callees": [], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": [], "derived": [], "uses": [] }], "usr2type": [{ "usr": 15041163540773201510, "detailed_name": "class Foo {}", "qual_name_offset": 6, "short_name": "Foo", "spell": "1:7-1:10|1:1-1:13|2|-1", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 5, "parent_kind": 0, "declarations": [], "derived": [], "instances": [10601729374837386290, 18422884837902130475], "uses": ["3:16-3:19|4|-1", "4:17-4:20|4|-1"] }], "usr2var": [{ "usr": 10601729374837386290, "detailed_name": "Foo *x", "qual_name_offset": 5, "short_name": "x", "hover": "Foo *x = new Foo()", "spell": "3:8-3:9|3:3-3:21|2|-1", "type": 15041163540773201510, "kind": 13, "parent_kind": 12, "storage": 0, "declarations": [], "uses": [] }, { "usr": 18422884837902130475, "detailed_name": "Foo *y", "qual_name_offset": 5, "short_name": "y", "hover": "Foo *y = new Foo()", "spell": "4:9-4:10|4:3-4:22|2|-1", "type": 15041163540773201510, "kind": 13, "parent_kind": 12, "storage": 0, "declarations": [], "uses": [] }] } */ ccls-0.20190823.6/index_tests/vars/function_local.cc000066400000000000000000000023501364776600300220400ustar00rootroot00000000000000struct Foo; void foo() { Foo* a; } /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [{ "usr": 4259594751088586730, "detailed_name": "void foo()", "qual_name_offset": 5, "short_name": "foo", "spell": "3:6-3:9|3:1-5:2|2|-1", "bases": [], "vars": [13198746475679542317], "callees": [], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": [], "derived": [], "uses": [] }], "usr2type": [{ "usr": 15041163540773201510, "detailed_name": "struct Foo", "qual_name_offset": 7, "short_name": "Foo", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 23, "parent_kind": 0, "declarations": ["1:8-1:11|1:1-1:11|1|-1"], "derived": [], "instances": [13198746475679542317], "uses": ["4:3-4:6|4|-1"] }], "usr2var": [{ "usr": 13198746475679542317, "detailed_name": "Foo *a", "qual_name_offset": 5, "short_name": "a", "spell": "4:8-4:9|4:3-4:9|2|-1", "type": 15041163540773201510, "kind": 13, "parent_kind": 12, "storage": 0, "declarations": [], "uses": [] }] } */ ccls-0.20190823.6/index_tests/vars/function_param.cc000066400000000000000000000032041364776600300220450ustar00rootroot00000000000000struct Foo; void foo(Foo* p0, Foo* p1) {} /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [{ "usr": 8908726657907936744, "detailed_name": "void foo(Foo *p0, Foo *p1)", "qual_name_offset": 5, "short_name": "foo", "spell": "3:6-3:9|3:1-3:30|2|-1", "bases": [], "vars": [8730439006497971620, 2525014371090380500], "callees": [], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": [], "derived": [], "uses": [] }], "usr2type": [{ "usr": 15041163540773201510, "detailed_name": "struct Foo", "qual_name_offset": 7, "short_name": "Foo", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 23, "parent_kind": 0, "declarations": ["1:8-1:11|1:1-1:11|1|-1"], "derived": [], "instances": [8730439006497971620, 2525014371090380500], "uses": ["3:10-3:13|4|-1", "3:19-3:22|4|-1"] }], "usr2var": [{ "usr": 2525014371090380500, "detailed_name": "Foo *p1", "qual_name_offset": 5, "short_name": "p1", "spell": "3:24-3:26|3:19-3:26|1026|-1", "type": 15041163540773201510, "kind": 253, "parent_kind": 12, "storage": 0, "declarations": [], "uses": [] }, { "usr": 8730439006497971620, "detailed_name": "Foo *p0", "qual_name_offset": 5, "short_name": "p0", "spell": "3:15-3:17|3:10-3:17|1026|-1", "type": 15041163540773201510, "kind": 253, "parent_kind": 12, "storage": 0, "declarations": [], "uses": [] }] } */ ccls-0.20190823.6/index_tests/vars/function_param_unnamed.cc000066400000000000000000000007641364776600300235640ustar00rootroot00000000000000void foo(int, int) {} /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [{ "usr": 2747674671862363334, "detailed_name": "void foo(int, int)", "qual_name_offset": 5, "short_name": "foo", "spell": "1:6-1:9|1:1-1:22|2|-1", "bases": [], "vars": [], "callees": [], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": [], "derived": [], "uses": [] }], "usr2type": [], "usr2var": [] } */ ccls-0.20190823.6/index_tests/vars/function_shadow_local.cc000066400000000000000000000030541364776600300234070ustar00rootroot00000000000000void foo() { int a; a = 1; { int a; a = 2; } a = 3; } /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [{ "usr": 4259594751088586730, "detailed_name": "void foo()", "qual_name_offset": 5, "short_name": "foo", "spell": "1:6-1:9|1:1-9:2|2|-1", "bases": [], "vars": [1894874819807168345, 4508045017817092115], "callees": [], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": [], "derived": [], "uses": [] }], "usr2type": [{ "usr": 53, "detailed_name": "", "qual_name_offset": 0, "short_name": "", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 0, "parent_kind": 0, "declarations": [], "derived": [], "instances": [1894874819807168345, 4508045017817092115], "uses": [] }], "usr2var": [{ "usr": 1894874819807168345, "detailed_name": "int a", "qual_name_offset": 4, "short_name": "a", "spell": "2:7-2:8|2:3-2:8|2|-1", "type": 53, "kind": 13, "parent_kind": 12, "storage": 0, "declarations": [], "uses": ["3:3-3:4|20|-1", "8:3-8:4|20|-1"] }, { "usr": 4508045017817092115, "detailed_name": "int a", "qual_name_offset": 4, "short_name": "a", "spell": "5:9-5:10|5:5-5:10|2|-1", "type": 53, "kind": 13, "parent_kind": 12, "storage": 0, "declarations": [], "uses": ["6:5-6:6|20|-1"] }] } */ ccls-0.20190823.6/index_tests/vars/function_shadow_param.cc000066400000000000000000000030071364776600300234130ustar00rootroot00000000000000void foo(int p) { { int p = 0; } } /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [{ "usr": 11998306017310352355, "detailed_name": "void foo(int p)", "qual_name_offset": 5, "short_name": "foo", "spell": "1:6-1:9|1:1-3:2|2|-1", "bases": [], "vars": [5875271969926422921, 11404600766177939811], "callees": [], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": [], "derived": [], "uses": [] }], "usr2type": [{ "usr": 53, "detailed_name": "", "qual_name_offset": 0, "short_name": "", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 0, "parent_kind": 0, "declarations": [], "derived": [], "instances": [5875271969926422921, 11404600766177939811], "uses": [] }], "usr2var": [{ "usr": 5875271969926422921, "detailed_name": "int p", "qual_name_offset": 4, "short_name": "p", "spell": "1:14-1:15|1:10-1:15|1026|-1", "type": 53, "kind": 253, "parent_kind": 12, "storage": 0, "declarations": [], "uses": [] }, { "usr": 11404600766177939811, "detailed_name": "int p", "qual_name_offset": 4, "short_name": "p", "hover": "int p = 0", "spell": "2:9-2:10|2:5-2:14|2|-1", "type": 53, "kind": 13, "parent_kind": 12, "storage": 0, "declarations": [], "uses": [] }] } */ ccls-0.20190823.6/index_tests/vars/global_variable.cc000066400000000000000000000015001364776600300221420ustar00rootroot00000000000000static int global = 0; /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [], "usr2type": [{ "usr": 53, "detailed_name": "", "qual_name_offset": 0, "short_name": "", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 0, "parent_kind": 0, "declarations": [], "derived": [], "instances": [6834525061342585382], "uses": [] }], "usr2var": [{ "usr": 6834525061342585382, "detailed_name": "static int global", "qual_name_offset": 11, "short_name": "global", "hover": "static int global = 0", "spell": "1:12-1:18|1:1-1:22|2|-1", "type": 53, "kind": 13, "parent_kind": 0, "storage": 2, "declarations": [], "uses": [] }] } */ ccls-0.20190823.6/index_tests/vars/global_variable_decl_only.cc000066400000000000000000000014031364776600300241740ustar00rootroot00000000000000extern int global; /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [], "usr2type": [{ "usr": 53, "detailed_name": "", "qual_name_offset": 0, "short_name": "", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 0, "parent_kind": 0, "declarations": [], "derived": [], "instances": [9937941849651546906], "uses": [] }], "usr2var": [{ "usr": 9937941849651546906, "detailed_name": "extern int global", "qual_name_offset": 11, "short_name": "global", "type": 53, "kind": 13, "parent_kind": 0, "storage": 1, "declarations": ["1:12-1:18|1:1-1:18|1|-1"], "uses": [] }] } */ ccls-0.20190823.6/index_tests/vars/type_instance_on_using_type.cc000066400000000000000000000033311364776600300246500ustar00rootroot00000000000000struct S {}; using F = S; void Foo() { F a; } // TODO: Should we also add a usage to |S|? /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [{ "usr": 4654328188330986029, "detailed_name": "void Foo()", "qual_name_offset": 5, "short_name": "Foo", "spell": "3:6-3:9|3:1-5:2|2|-1", "bases": [], "vars": [6975456769752895964], "callees": [], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": [], "derived": [], "uses": [] }], "usr2type": [{ "usr": 4750332761459066907, "detailed_name": "struct S {}", "qual_name_offset": 7, "short_name": "S", "spell": "1:8-1:9|1:1-1:12|2|-1", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 23, "parent_kind": 0, "declarations": [], "derived": [], "instances": [], "uses": ["2:11-2:12|4|-1"] }, { "usr": 7434820806199665424, "detailed_name": "using F = S", "qual_name_offset": 6, "short_name": "F", "spell": "2:7-2:8|2:1-2:12|2|-1", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 4750332761459066907, "kind": 252, "parent_kind": 0, "declarations": [], "derived": [], "instances": [6975456769752895964], "uses": ["4:3-4:4|4|-1"] }], "usr2var": [{ "usr": 6975456769752895964, "detailed_name": "F a", "qual_name_offset": 2, "short_name": "a", "spell": "4:5-4:6|4:3-4:6|2|-1", "type": 7434820806199665424, "kind": 13, "parent_kind": 12, "storage": 0, "declarations": [], "uses": [] }] } */ ccls-0.20190823.6/src/000077500000000000000000000000001364776600300140155ustar00rootroot00000000000000ccls-0.20190823.6/src/clang_tu.cc000066400000000000000000000174431364776600300161310ustar00rootroot00000000000000// Copyright 2017-2018 ccls Authors // SPDX-License-Identifier: Apache-2.0 #include "clang_tu.hh" #include "config.hh" #include "platform.hh" #include #include #include #include using namespace clang; namespace ccls { std::string pathFromFileEntry(const FileEntry &file) { StringRef name = file.tryGetRealPathName(); if (name.empty()) name = file.getName(); std::string ret = normalizePath(name); // Resolve symlinks outside of workspace folders, e.g. /usr/include/c++/7.3.0 return normalizeFolder(ret) ? ret : realPath(ret); } static Pos decomposed2LineAndCol(const SourceManager &sm, std::pair i) { int l = (int)sm.getLineNumber(i.first, i.second) - 1, c = (int)sm.getColumnNumber(i.first, i.second) - 1; bool invalid = false; StringRef buf = sm.getBufferData(i.first, &invalid); if (!invalid) { StringRef p = buf.substr(i.second - c, c); c = 0; for (size_t i = 0; i < p.size();) if (c++, (uint8_t)p[i++] >= 128) while (i < p.size() && (uint8_t)p[i] >= 128 && (uint8_t)p[i] < 192) i++; } return {(uint16_t)std::min(l, UINT16_MAX), (int16_t)std::min(c, INT16_MAX)}; } Range fromCharSourceRange(const SourceManager &sm, const LangOptions &lang, CharSourceRange csr, FileID *fid) { SourceLocation bloc = csr.getBegin(), eloc = csr.getEnd(); std::pair binfo = sm.getDecomposedLoc(bloc), einfo = sm.getDecomposedLoc(eloc); if (csr.isTokenRange()) einfo.second += Lexer::MeasureTokenLength(eloc, sm, lang); if (fid) *fid = binfo.first; return {decomposed2LineAndCol(sm, binfo), decomposed2LineAndCol(sm, einfo)}; } Range fromTokenRange(const SourceManager &sm, const LangOptions &lang, SourceRange sr, FileID *fid) { return fromCharSourceRange(sm, lang, CharSourceRange::getTokenRange(sr), fid); } Range fromTokenRangeDefaulted(const SourceManager &sm, const LangOptions &lang, SourceRange sr, FileID fid, Range range) { auto decomposed = sm.getDecomposedLoc(sm.getExpansionLoc(sr.getBegin())); if (decomposed.first == fid) range.start = decomposed2LineAndCol(sm, decomposed); SourceLocation sl = sm.getExpansionLoc(sr.getEnd()); decomposed = sm.getDecomposedLoc(sl); if (decomposed.first == fid) { decomposed.second += Lexer::MeasureTokenLength(sl, sm, lang); range.end = decomposed2LineAndCol(sm, decomposed); } return range; } std::unique_ptr buildCompilerInvocation(const std::string &main, std::vector args, IntrusiveRefCntPtr vfs) { std::string save = "-resource-dir=" + g_config->clang.resourceDir; args.push_back(save.c_str()); IntrusiveRefCntPtr diags( CompilerInstance::createDiagnostics(new DiagnosticOptions, new IgnoringDiagConsumer, true)); std::unique_ptr ci = createInvocationFromCommandLine(args, diags, vfs); if (ci) { ci->getDiagnosticOpts().IgnoreWarnings = true; ci->getFrontendOpts().DisableFree = false; // Enable IndexFrontendAction::shouldSkipFunctionBody. ci->getFrontendOpts().SkipFunctionBodies = true; ci->getLangOpts()->SpellChecking = false; auto &isec = ci->getFrontendOpts().Inputs; if (isec.size()) isec[0] = FrontendInputFile(main, isec[0].getKind(), isec[0].isSystem()); } return ci; } // clang::BuiltinType::getName without PrintingPolicy const char *clangBuiltinTypeName(int kind) { switch (BuiltinType::Kind(kind)) { case BuiltinType::Void: return "void"; case BuiltinType::Bool: return "bool"; case BuiltinType::Char_S: case BuiltinType::Char_U: return "char"; case BuiltinType::SChar: return "signed char"; case BuiltinType::Short: return "short"; case BuiltinType::Int: return "int"; case BuiltinType::Long: return "long"; case BuiltinType::LongLong: return "long long"; case BuiltinType::Int128: return "__int128"; case BuiltinType::UChar: return "unsigned char"; case BuiltinType::UShort: return "unsigned short"; case BuiltinType::UInt: return "unsigned int"; case BuiltinType::ULong: return "unsigned long"; case BuiltinType::ULongLong: return "unsigned long long"; case BuiltinType::UInt128: return "unsigned __int128"; case BuiltinType::Half: return "__fp16"; case BuiltinType::Float: return "float"; case BuiltinType::Double: return "double"; case BuiltinType::LongDouble: return "long double"; case BuiltinType::ShortAccum: return "short _Accum"; case BuiltinType::Accum: return "_Accum"; case BuiltinType::LongAccum: return "long _Accum"; case BuiltinType::UShortAccum: return "unsigned short _Accum"; case BuiltinType::UAccum: return "unsigned _Accum"; case BuiltinType::ULongAccum: return "unsigned long _Accum"; case BuiltinType::BuiltinType::ShortFract: return "short _Fract"; case BuiltinType::BuiltinType::Fract: return "_Fract"; case BuiltinType::BuiltinType::LongFract: return "long _Fract"; case BuiltinType::BuiltinType::UShortFract: return "unsigned short _Fract"; case BuiltinType::BuiltinType::UFract: return "unsigned _Fract"; case BuiltinType::BuiltinType::ULongFract: return "unsigned long _Fract"; case BuiltinType::BuiltinType::SatShortAccum: return "_Sat short _Accum"; case BuiltinType::BuiltinType::SatAccum: return "_Sat _Accum"; case BuiltinType::BuiltinType::SatLongAccum: return "_Sat long _Accum"; case BuiltinType::BuiltinType::SatUShortAccum: return "_Sat unsigned short _Accum"; case BuiltinType::BuiltinType::SatUAccum: return "_Sat unsigned _Accum"; case BuiltinType::BuiltinType::SatULongAccum: return "_Sat unsigned long _Accum"; case BuiltinType::BuiltinType::SatShortFract: return "_Sat short _Fract"; case BuiltinType::BuiltinType::SatFract: return "_Sat _Fract"; case BuiltinType::BuiltinType::SatLongFract: return "_Sat long _Fract"; case BuiltinType::BuiltinType::SatUShortFract: return "_Sat unsigned short _Fract"; case BuiltinType::BuiltinType::SatUFract: return "_Sat unsigned _Fract"; case BuiltinType::BuiltinType::SatULongFract: return "_Sat unsigned long _Fract"; case BuiltinType::Float16: return "_Float16"; case BuiltinType::Float128: return "__float128"; case BuiltinType::WChar_S: case BuiltinType::WChar_U: return "wchar_t"; case BuiltinType::Char8: return "char8_t"; case BuiltinType::Char16: return "char16_t"; case BuiltinType::Char32: return "char32_t"; case BuiltinType::NullPtr: return "nullptr_t"; case BuiltinType::Overload: return ""; case BuiltinType::BoundMember: return ""; case BuiltinType::PseudoObject: return ""; case BuiltinType::Dependent: return ""; case BuiltinType::UnknownAny: return ""; case BuiltinType::ARCUnbridgedCast: return ""; case BuiltinType::BuiltinFn: return ""; case BuiltinType::ObjCId: return "id"; case BuiltinType::ObjCClass: return "Class"; case BuiltinType::ObjCSel: return "SEL"; case BuiltinType::OCLSampler: return "sampler_t"; case BuiltinType::OCLEvent: return "event_t"; case BuiltinType::OCLClkEvent: return "clk_event_t"; case BuiltinType::OCLQueue: return "queue_t"; case BuiltinType::OCLReserveID: return "reserve_id_t"; case BuiltinType::OMPArraySection: return ""; default: return ""; } } } // namespace ccls ccls-0.20190823.6/src/clang_tu.hh000066400000000000000000000025511364776600300161350ustar00rootroot00000000000000// Copyright 2017-2018 ccls Authors // SPDX-License-Identifier: Apache-2.0 #pragma once #include "position.hh" #include #include #include #include #if LLVM_VERSION_MAJOR < 8 // D52783 Lift VFS from clang to llvm namespace llvm { namespace vfs = clang::vfs; } #endif namespace ccls { std::string pathFromFileEntry(const clang::FileEntry &file); Range fromCharSourceRange(const clang::SourceManager &sm, const clang::LangOptions &lang, clang::CharSourceRange csr, clang::FileID *fid = nullptr); Range fromTokenRange(const clang::SourceManager &sm, const clang::LangOptions &lang, clang::SourceRange sr, clang::FileID *fid = nullptr); Range fromTokenRangeDefaulted(const clang::SourceManager &sm, const clang::LangOptions &lang, clang::SourceRange sr, clang::FileID fid, Range range); std::unique_ptr buildCompilerInvocation(const std::string &main, std::vector args, llvm::IntrusiveRefCntPtr VFS); const char *clangBuiltinTypeName(int); } // namespace ccls ccls-0.20190823.6/src/config.cc000066400000000000000000000007401364776600300155720ustar00rootroot00000000000000// Copyright 2017-2018 ccls Authors // SPDX-License-Identifier: Apache-2.0 #include "config.hh" namespace ccls { Config *g_config; void doPathMapping(std::string &arg) { for (const std::string &mapping : g_config->clang.pathMappings) { auto sep = mapping.find('>'); if (sep != std::string::npos) { auto p = arg.find(mapping.substr(0, sep)); if (p != std::string::npos) arg.replace(p, sep, mapping.substr(sep + 1)); } } } } // namespace ccls ccls-0.20190823.6/src/config.hh000066400000000000000000000330651364776600300156120ustar00rootroot00000000000000// Copyright 2017-2018 ccls Authors // SPDX-License-Identifier: Apache-2.0 #pragma once #include "serializer.hh" #include namespace ccls { /* The language client plugin needs to send initialization options in the `initialize` request to the ccls language server. If necessary, the command line option --init can be used to override initialization options specified by the client. For example, in shell syntax: '--init={"index": {"comments": 2, "whitelist": ["."]}}' */ struct Config { // **Not available for configuration** std::string fallbackFolder; std::vector> workspaceFolders; // If specified, this option overrides compile_commands.json and this // external command will be executed with an option |projectRoot|. // The initialization options will be provided as stdin. // The stdout of the command should be the JSON compilation database. std::string compilationDatabaseCommand; // Directory containing compile_commands.json. std::string compilationDatabaseDirectory; struct Cache { // Cache directory for indexed files, either absolute or relative to the // project root. // // If empty, retainInMemory will be set to 1 and cache will be stored in // memory. std::string directory = ".ccls-cache"; // Cache serialization format. // // "json" generates $directory/.../xxx.json files which can be pretty // printed with jq. // // "binary" uses a compact binary serialization format. // It is not schema-aware and you need to re-index whenever an internal // struct member has changed. SerializeFormat format = SerializeFormat::Binary; // If false, store cache files as $directory/@a@b/c.cc.blob // // If true, $directory/a/b/c.cc.blob. If cache.directory is absolute, make // sure different projects use different cache.directory as they would have // conflicting cache files for system headers. bool hierarchicalPath = false; // After this number of loads, keep a copy of file index in memory (which // increases memory usage). During incremental updates, the index subtracted // will come from the in-memory copy, instead of the on-disk file. // // The initial load or a save action is counted as one load. // 0: never retain; 1: retain after initial load; 2: retain after 2 loads // (initial load+first save) int retainInMemory = 2; } cache; struct ServerCap { struct DocumentOnTypeFormattingOptions { std::string firstTriggerCharacter = "}"; std::vector moreTriggerCharacter; } documentOnTypeFormattingProvider; // Set to false if you don't want folding ranges. bool foldingRangeProvider = true; struct Workspace { struct WorkspaceFolders { // Set to false if you don't want workspace folders. bool supported = true; bool changeNotifications = true; } workspaceFolders; } workspace; } capabilities; struct Clang { // Arguments matching any of these glob patterns will be excluded, e.g. // ["-fopenmp", "-m*", "-Wall"]. std::vector excludeArgs; // Additional arguments to pass to clang. std::vector extraArgs; // Translate absolute paths in compile_commands.json entries, .ccls options // and cache files. This allows to reuse cache files built otherwhere if the // source paths are different. // // This is a list of colon-separated strings, e.g. ["/container:/host"] // // An entry of "clang -I /container/include /container/a.cc" will be // translated to "clang -I /host/include /host/a.cc". This is simple string // replacement, so "clang /prefix/container/a.cc" will become "clang // /prefix/host/a.cc". std::vector pathMappings; // Value to use for clang -resource-dir if not specified. // // This option defaults to clang -print-resource-dir and should not be // specified unless you are using an esoteric configuration. std::string resourceDir; } clang; struct ClientCapability { // TextDocumentClientCapabilities.publishDiagnostics.relatedInformation bool diagnosticsRelatedInformation = true; // TextDocumentClientCapabilities.documentSymbol.hierarchicalDocumentSymbolSupport bool hierarchicalDocumentSymbolSupport = true; // TextDocumentClientCapabilities.definition.linkSupport bool linkSupport = true; // TextDocumentClientCapabilities.completion.completionItem.snippetSupport bool snippetSupport = true; } client; struct CodeLens { // Enables code lens on parameter and function variables. bool localVariables = true; } codeLens; struct Completion { // 0: case-insensitive // 1: case-folded, i.e. insensitive if no input character is uppercase. // 2: case-sensitive int caseSensitivity = 2; // Some completion UI, such as Emacs' completion-at-point and company-lsp, // display completion item label and detail side by side. // This does not look right, when you see things like: // "foo" "int foo()" // "bar" "void bar(int i = 0)" // When this option is enabled, the completion item label is very detailed, // it shows the full signature of the candidate. // The detail just contains the completion item parent context. bool detailedLabel = true; // On large projects, completion can take a long time. By default if ccls // receives multiple completion requests while completion is still running // it will only service the newest request. If this is set to false then all // completion requests will be serviced. bool dropOldRequests = true; // Functions with default arguments, generate one more item per default // argument. That is, you get something like: // "int foo()" "Foo" // "void bar()" "Foo" // "void bar(int i = 0)" "Foo" // Be wary, this is quickly quite verbose, // items can end up truncated by the UIs. bool duplicateOptional = true; // If true, filter and sort completion response. ccls filters and sorts // completions to try to be nicer to clients that can't handle big numbers // of completion candidates. This behaviour can be disabled by specifying // false for the option. This option is the most useful for LSP clients // that implement their own filtering and sorting logic. bool filterAndSort = true; // Maxmum number of results. int maxNum = 100; struct Include { // Regex patterns to match include completion candidates against. They // receive the absolute file path. // // For example, to hide all files in a /CACHE/ folder, use ".*/CACHE/.*" std::vector blacklist; // Maximum path length to show in completion results. Paths longer than // this will be elided with ".." put at the front. Set to 0 or a negative // number to disable eliding. int maxPathSize = 30; // Whitelist that file paths will be tested against. If a file path does // not end in one of these values, it will not be considered for // auto-completion. An example value is { ".h", ".hpp" } // // This is significantly faster than using a regex. std::vector suffixWhitelist = {".h", ".hpp", ".hh", ".inc"}; std::vector whitelist; } include; } completion; struct Diagnostics { // Like index.{whitelist,blacklist}, don't publish diagnostics to // blacklisted files. std::vector blacklist; // Time to wait before computing diagnostics for textDocument/didChange. // -1: disable diagnostics on change // 0: immediately // positive (e.g. 500): wait for 500 milliseconds. didChange requests in // this period of time will only cause one computation. int onChange = 1000; // Time to wait before computing diagnostics for textDocument/didOpen. int onOpen = 0; // Time to wait before computing diagnostics for textDocument/didSave. int onSave = 0; bool spellChecking = true; std::vector whitelist; } diagnostics; // Semantic highlighting struct Highlight { // Disable semantic highlighting for files larger than the size. int64_t largeFileSize = 2 * 1024 * 1024; // true: LSP line/character; false: position bool lsRanges = false; // Like index.{whitelist,blacklist}, don't publish semantic highlighting to // blacklisted files. std::vector blacklist; std::vector whitelist; } highlight; struct Index { // If a translation unit's absolute path matches any EMCAScript regex in the // whitelist, or does not match any regex in the blacklist, it will be // indexed. To only index files in the whitelist, add ".*" to the blacklist. // `std::regex_search(path, regex, std::regex_constants::match_any)` // // Example: `ash/.*\.cc` std::vector blacklist; // 0: none, 1: Doxygen, 2: all comments // Plugin support for clients: // - https://github.com/emacs-lsp/lsp-ui // - https://github.com/autozimu/LanguageClient-neovim/issues/224 int comments = 2; // If false, names of no linkage are not indexed in the background. They are // indexed after the files are opened. bool initialNoLinkage = false; // Use the two options to exclude files that should not be indexed in the // background. std::vector initialBlacklist; std::vector initialWhitelist; // If a variable initializer/macro replacement-list has fewer than this many // lines, include the initializer in detailed_name. int maxInitializerLines = 5; // If not 0, a file will be indexed in each tranlation unit that includes // it. int multiVersion = 0; // If multiVersion != 0, files that match blacklist but not whitelist will // still only be indexed for one version. std::vector multiVersionBlacklist; std::vector multiVersionWhitelist; struct Name { // Suppress inline and unnamed namespaces in identifier names. bool suppressUnwrittenScope = false; } name; // Allow indexing on textDocument/didChange. // May be too slow for big projects, so it is off by default. bool onChange = false; // If true, index parameters in declarations. bool parametersInDeclarations = true; // Number of indexer threads. If 0, 80% of cores are used. int threads = 0; // Whether to reparse a file if write times of its dependencies have // changed. The file will always be reparsed if its own write time changes. // 0: no, 1: only during initial load of project, 2: yes int trackDependency = 2; std::vector whitelist; } index; struct Request { // If the document of a request has not been indexed, wait up to this many // milleseconds before reporting error. int64_t timeout = 5000; } request; struct Session { int maxNum = 10; } session; struct WorkspaceSymbol { int caseSensitivity = 1; // Maximum workspace search results. int maxNum = 1000; // If true, workspace search results will be dynamically rescored/reordered // as the search progresses. Some clients do their own ordering and assume // that the results stay sorted in the same order as the search progresses. bool sort = true; } workspaceSymbol; struct Xref { // Maximum number of definition/reference/... results. int maxNum = 2000; } xref; }; REFLECT_STRUCT(Config::Cache, directory, format, hierarchicalPath, retainInMemory); REFLECT_STRUCT(Config::ServerCap::DocumentOnTypeFormattingOptions, firstTriggerCharacter, moreTriggerCharacter); REFLECT_STRUCT(Config::ServerCap::Workspace::WorkspaceFolders, supported, changeNotifications); REFLECT_STRUCT(Config::ServerCap::Workspace, workspaceFolders); REFLECT_STRUCT(Config::ServerCap, documentOnTypeFormattingProvider, foldingRangeProvider, workspace); REFLECT_STRUCT(Config::Clang, excludeArgs, extraArgs, pathMappings, resourceDir); REFLECT_STRUCT(Config::ClientCapability, diagnosticsRelatedInformation, hierarchicalDocumentSymbolSupport, linkSupport, snippetSupport); REFLECT_STRUCT(Config::CodeLens, localVariables); REFLECT_STRUCT(Config::Completion::Include, blacklist, maxPathSize, suffixWhitelist, whitelist); REFLECT_STRUCT(Config::Completion, caseSensitivity, detailedLabel, dropOldRequests, duplicateOptional, filterAndSort, include, maxNum); REFLECT_STRUCT(Config::Diagnostics, blacklist, onChange, onOpen, onSave, spellChecking, whitelist) REFLECT_STRUCT(Config::Highlight, largeFileSize, lsRanges, blacklist, whitelist) REFLECT_STRUCT(Config::Index::Name, suppressUnwrittenScope); REFLECT_STRUCT(Config::Index, blacklist, comments, initialNoLinkage, initialBlacklist, initialWhitelist, maxInitializerLines, multiVersion, multiVersionBlacklist, multiVersionWhitelist, name, onChange, parametersInDeclarations, threads, trackDependency, whitelist); REFLECT_STRUCT(Config::Request, timeout); REFLECT_STRUCT(Config::Session, maxNum); REFLECT_STRUCT(Config::WorkspaceSymbol, caseSensitivity, maxNum, sort); REFLECT_STRUCT(Config::Xref, maxNum); REFLECT_STRUCT(Config, compilationDatabaseCommand, compilationDatabaseDirectory, cache, capabilities, clang, client, codeLens, completion, diagnostics, highlight, index, request, session, workspaceSymbol, xref); extern Config *g_config; void doPathMapping(std::string &arg); } // namespace ccls ccls-0.20190823.6/src/filesystem.cc000066400000000000000000000036611364776600300165160ustar00rootroot00000000000000// Copyright 2017-2018 ccls Authors // SPDX-License-Identifier: Apache-2.0 #include "filesystem.hh" using namespace llvm; #include "utils.hh" #include #include void getFilesInFolder(std::string folder, bool recursive, bool dir_prefix, const std::function &handler) { ccls::ensureEndsInSlash(folder); sys::fs::file_status status; if (sys::fs::status(folder, status, true)) return; sys::fs::UniqueID id; std::vector curr{folder}; std::vector> succ; std::set seen{status.getUniqueID()}; while (curr.size() || succ.size()) { if (curr.empty()) { for (auto &it : succ) if (!seen.count(it.second.getUniqueID())) curr.push_back(std::move(it.first)); succ.clear(); } else { std::error_code ec; std::string folder1 = curr.back(); curr.pop_back(); for (sys::fs::directory_iterator i(folder1, ec, false), e; i != e && !ec; i.increment(ec)) { std::string path = i->path(); std::string filename(sys::path::filename(path)); if ((filename[0] == '.' && filename != ".ccls") || sys::fs::status(path, status, false)) continue; if (sys::fs::is_symlink_file(status)) { if (sys::fs::status(path, status, true)) continue; if (sys::fs::is_directory(status)) { if (recursive) succ.emplace_back(path, status); continue; } } if (sys::fs::is_regular_file(status)) { if (!dir_prefix) path = path.substr(folder.size()); handler(sys::path::convert_to_slash(path)); } else if (recursive && sys::fs::is_directory(status) && !seen.count(id = status.getUniqueID())) { curr.push_back(path); seen.insert(id); } } } } } ccls-0.20190823.6/src/filesystem.hh000066400000000000000000000006011364776600300165170ustar00rootroot00000000000000// Copyright 2017-2018 ccls Authors // SPDX-License-Identifier: Apache-2.0 #pragma once #include #include #include #include void getFilesInFolder(std::string folder, bool recursive, bool add_folder_to_path, const std::function &handler); ccls-0.20190823.6/src/fuzzy_match.cc000066400000000000000000000126551364776600300167000ustar00rootroot00000000000000// Copyright 2017-2018 ccls Authors // SPDX-License-Identifier: Apache-2.0 #include "fuzzy_match.hh" #include #include #include #include namespace ccls { namespace { enum CharClass { Other, Lower, Upper }; enum CharRole { None, Tail, Head }; CharClass getCharClass(int c) { if (islower(c)) return Lower; if (isupper(c)) return Upper; return Other; } void calculateRoles(std::string_view s, int roles[], int *class_set) { if (s.empty()) { *class_set = 0; return; } CharClass pre = Other, cur = getCharClass(s[0]), suc; *class_set = 1 << cur; auto fn = [&]() { if (cur == Other) return None; // U(U)L is Head while U(U)U is Tail return pre == Other || (cur == Upper && (pre == Lower || suc == Lower)) ? Head : Tail; }; for (size_t i = 0; i < s.size() - 1; i++) { suc = getCharClass(s[i + 1]); *class_set |= 1 << suc; roles[i] = fn(); pre = cur; cur = suc; } roles[s.size() - 1] = fn(); } } // namespace int FuzzyMatcher::missScore(int j, bool last) { int s = -3; if (last) s -= 10; if (text_role[j] == Head) s -= 10; return s; } int FuzzyMatcher::matchScore(int i, int j, bool last) { int s = 0; // Case matching. if (pat[i] == text[j]) { s++; // pat contains uppercase letters or prefix matching. if ((pat_set & 1 << Upper) || i == j) s++; } if (pat_role[i] == Head) { if (text_role[j] == Head) s += 30; else if (text_role[j] == Tail) s -= 10; } // Matching a tail while previous char wasn't matched. if (text_role[j] == Tail && i && !last) s -= 30; // First char of pat matches a tail. if (i == 0 && text_role[j] == Tail) s -= 40; return s; } FuzzyMatcher::FuzzyMatcher(std::string_view pattern, int sensitivity) { calculateRoles(pattern, pat_role, &pat_set); if (sensitivity == 1) sensitivity = pat_set & 1 << Upper ? 2 : 0; case_sensitivity = sensitivity; size_t n = 0; for (size_t i = 0; i < pattern.size(); i++) if (pattern[i] != ' ') { pat += pattern[i]; low_pat[n] = (char)::tolower(pattern[i]); pat_role[n] = pat_role[i]; n++; } } int FuzzyMatcher::match(std::string_view text, bool strict) { if (pat.empty() != text.empty()) return kMinScore; int n = int(text.size()); if (n > kMaxText) return kMinScore + 1; this->text = text; for (int i = 0; i < n; i++) low_text[i] = (char)::tolower(text[i]); calculateRoles(text, text_role, &text_set); if (strict && n && !!pat_role[0] != !!text_role[0]) return kMinScore; dp[0][0][0] = dp[0][0][1] = 0; for (int j = 0; j < n; j++) { dp[0][j + 1][0] = dp[0][j][0] + missScore(j, false); dp[0][j + 1][1] = kMinScore * 2; } for (int i = 0; i < int(pat.size()); i++) { int(*pre)[2] = dp[i & 1]; int(*cur)[2] = dp[(i + 1) & 1]; cur[i][0] = cur[i][1] = kMinScore; for (int j = i; j < n; j++) { cur[j + 1][0] = std::max(cur[j][0] + missScore(j, false), cur[j][1] + missScore(j, true)); // For the first char of pattern, apply extra restriction to filter bad // candidates (e.g. |int| in |PRINT|) cur[j + 1][1] = (case_sensitivity ? pat[i] == text[j] : low_pat[i] == low_text[j] && (i || text_role[j] != Tail || pat[i] == text[j])) ? std::max(pre[j][0] + matchScore(i, j, false), pre[j][1] + matchScore(i, j, true)) : kMinScore * 2; } } // Enumerate the end position of the match in str. Each removed trailing // character has a penulty. int ret = kMinScore; for (int j = pat.size(); j <= n; j++) ret = std::max(ret, dp[pat.size() & 1][j][1] - 2 * (n - j)); return ret; } } // namespace ccls #if 0 TEST_SUITE("fuzzy_match") { bool Ranks(std::string_view pat, std::vector texts) { FuzzyMatcher fuzzy(pat, 0); std::vector scores; for (auto text : texts) scores.push_back(fuzzy.Match(text)); bool ret = true; for (size_t i = 0; i < texts.size() - 1; i++) if (scores[i] < scores[i + 1]) { ret = false; break; } if (!ret) { for (size_t i = 0; i < texts.size(); i++) printf("%s %d ", texts[i], scores[i]); puts(""); } return ret; } TEST_CASE("test") { FuzzyMatcher fuzzy("", 0); CHECK(fuzzy.Match("") == 0); CHECK(fuzzy.Match("aaa") < 0); // case CHECK(Ranks("monad", {"monad", "Monad", "mONAD"})); // initials CHECK(Ranks("ab", {"ab", "aoo_boo", "acb"})); CHECK(Ranks("CC", {"CamelCase", "camelCase", "camelcase"})); CHECK(Ranks("cC", {"camelCase", "CamelCase", "camelcase"})); CHECK(Ranks("c c", {"camelCase", "camel case", "CamelCase", "camelcase", "camel ace"})); CHECK(Ranks("Da.Te", {"Data.Text", "Data.Text.Lazy", "Data.Aeson.Encoding.text"})); CHECK(Ranks("foo bar.h", {"foo/bar.h", "foobar.h"})); // prefix CHECK(Ranks("is", {"isIEEE", "inSuf"})); // shorter CHECK(Ranks("ma", {"map", "many", "maximum"})); CHECK(Ranks("print", {"printf", "sprintf"})); // score(PRINT) = kMinScore CHECK(Ranks("ast", {"ast", "AST", "INT_FAST16_MAX"})); // score(PRINT) > kMinScore CHECK(Ranks("Int", {"int", "INT", "PRINT"})); } } #endif ccls-0.20190823.6/src/fuzzy_match.hh000066400000000000000000000015261364776600300167050ustar00rootroot00000000000000// Copyright 2017-2018 ccls Authors // SPDX-License-Identifier: Apache-2.0 #pragma once #include #include #include namespace ccls { class FuzzyMatcher { public: constexpr static int kMaxPat = 100; constexpr static int kMaxText = 200; // Negative but far from INT_MIN so that intermediate results are hard to // overflow. constexpr static int kMinScore = INT_MIN / 4; FuzzyMatcher(std::string_view pattern, int case_sensitivity); int match(std::string_view text, bool strict); private: int case_sensitivity; std::string pat; std::string_view text; int pat_set, text_set; char low_pat[kMaxPat], low_text[kMaxText]; int pat_role[kMaxPat], text_role[kMaxText]; int dp[2][kMaxText + 1][2]; int matchScore(int i, int j, bool last); int missScore(int j, bool last); }; } // namespace ccls ccls-0.20190823.6/src/hierarchy.hh000066400000000000000000000013651364776600300163210ustar00rootroot00000000000000// Copyright 2017-2018 ccls Authors // SPDX-License-Identifier: Apache-2.0 #pragma once #include "lsp.hh" #include #include namespace ccls { template std::vector flattenHierarchy(const std::optional &root) { if (!root) return {}; std::vector ret; std::queue q; for (auto &entry : root->children) q.push(&entry); while (q.size()) { auto *entry = q.front(); q.pop(); if (entry->location.uri.raw_uri.size()) ret.push_back({entry->location}); for (auto &entry1 : entry->children) q.push(&entry1); } std::sort(ret.begin(), ret.end()); ret.erase(std::unique(ret.begin(), ret.end()), ret.end()); return ret; } } // namespace ccls ccls-0.20190823.6/src/include_complete.cc000066400000000000000000000134251364776600300176440ustar00rootroot00000000000000// Copyright 2017-2018 ccls Authors // SPDX-License-Identifier: Apache-2.0 #include "include_complete.hh" #include "filesystem.hh" #include "platform.hh" #include "project.hh" #include #include #include #include using namespace llvm; #include namespace ccls { namespace { struct CompletionCandidate { std::string absolute_path; CompletionItem completion_item; }; std::string elideLongPath(const std::string &path) { if (g_config->completion.include.maxPathSize <= 0 || (int)path.size() <= g_config->completion.include.maxPathSize) return path; size_t start = path.size() - g_config->completion.include.maxPathSize; return ".." + path.substr(start + 2); } size_t trimCommonPathPrefix(const std::string &result, const std::string &trimmer) { #ifdef _WIN32 std::string s = result, t = trimmer; std::transform(s.begin(), s.end(), s.begin(), ::tolower); std::transform(t.begin(), t.end(), t.begin(), ::tolower); if (s.compare(0, t.size(), t) == 0) return t.size(); #else if (result.compare(0, trimmer.size(), trimmer) == 0) return trimmer.size(); #endif return 0; } int trimPath(Project *project, std::string &path) { size_t pos = 0; int kind = 0; for (auto &[root, folder] : project->root2folder) for (auto &[search, search_dir_kind] : folder.search_dir2kind) if (int t = trimCommonPathPrefix(path, search); t > pos) pos = t, kind = search_dir_kind; path = path.substr(pos); return kind; } CompletionItem buildCompletionItem(const std::string &path, int kind) { CompletionItem item; item.label = elideLongPath(path); item.detail = path; // the include path, used in de-duplicating item.textEdit.newText = path; item.insertTextFormat = InsertTextFormat::PlainText; item.kind = CompletionItemKind::File; item.quote_kind_ = kind; item.priority_ = 0; return item; } } // namespace IncludeComplete::IncludeComplete(Project *project) : is_scanning(false), project_(project) {} IncludeComplete::~IncludeComplete() { // Spin until the scanning has completed. while (is_scanning.load()) std::this_thread::sleep_for(std::chrono::milliseconds(100)); } void IncludeComplete::rescan() { if (is_scanning || LLVM_VERSION_MAJOR >= 8) return; completion_items.clear(); absolute_path_to_completion_item.clear(); inserted_paths.clear(); if (!match_ && (g_config->completion.include.whitelist.size() || g_config->completion.include.blacklist.size())) match_ = std::make_unique(g_config->completion.include.whitelist, g_config->completion.include.blacklist); is_scanning = true; std::thread([this]() { set_thread_name("include"); for (auto &[root, folder] : project_->root2folder) { for (auto &search_kind : folder.search_dir2kind) { const std::string &search = search_kind.first; int kind = search_kind.second; assert(search.back() == '/'); if (match_ && !match_->matches(search)) return; bool include_cpp = search.find("include/c++") != std::string::npos; std::vector results; getFilesInFolder( search, true /*recursive*/, false /*add_folder_to_path*/, [&](const std::string &path) { bool ok = include_cpp; for (StringRef suffix : g_config->completion.include.suffixWhitelist) if (StringRef(path).endswith(suffix)) ok = true; if (!ok) return; if (match_ && !match_->matches(search + path)) return; CompletionCandidate candidate; candidate.absolute_path = search + path; candidate.completion_item = buildCompletionItem(path, kind); results.push_back(candidate); }); std::lock_guard lock(completion_items_mutex); for (CompletionCandidate &result : results) insertCompletionItem(result.absolute_path, std::move(result.completion_item)); } } is_scanning = false; }).detach(); } void IncludeComplete::insertCompletionItem(const std::string &absolute_path, CompletionItem &&item) { if (inserted_paths.try_emplace(item.detail, inserted_paths.size()).second) { completion_items.push_back(item); // insert if not found or with shorter include path auto it = absolute_path_to_completion_item.find(absolute_path); if (it == absolute_path_to_completion_item.end() || completion_items[it->second].detail.length() > item.detail.length()) { absolute_path_to_completion_item[absolute_path] = completion_items.size() - 1; } } } void IncludeComplete::addFile(const std::string &path) { bool ok = false; for (StringRef suffix : g_config->completion.include.suffixWhitelist) if (StringRef(path).endswith(suffix)) ok = true; if (!ok) return; if (match_ && !match_->matches(path)) return; std::string trimmed_path = path; int kind = trimPath(project_, trimmed_path); CompletionItem item = buildCompletionItem(trimmed_path, kind); std::unique_lock lock(completion_items_mutex, std::defer_lock); if (is_scanning) lock.lock(); insertCompletionItem(path, std::move(item)); } std::optional IncludeComplete::findCompletionItemForAbsolutePath( const std::string &absolute_path) { std::lock_guard lock(completion_items_mutex); auto it = absolute_path_to_completion_item.find(absolute_path); if (it == absolute_path_to_completion_item.end()) return std::nullopt; return completion_items[it->second]; } } // namespace ccls ccls-0.20190823.6/src/include_complete.hh000066400000000000000000000025741364776600300176610ustar00rootroot00000000000000// Copyright 2017-2018 ccls Authors // SPDX-License-Identifier: Apache-2.0 #pragma once #include "message_handler.hh" #include #include namespace ccls { struct GroupMatch; struct Project; struct IncludeComplete { IncludeComplete(Project *project); ~IncludeComplete(); // Starts scanning directories. Clears existing cache. void rescan(); // Ensures the one-off file is inside |completion_items|. void addFile(const std::string &absolute_path); std::optional findCompletionItemForAbsolutePath(const std::string &absolute_path); // Insert item to |completion_items|. // Update |absolute_path_to_completion_item| and |inserted_paths|. void insertCompletionItem(const std::string &absolute_path, ccls::CompletionItem &&item); // Guards |completion_items| when |is_scanning| is true. std::mutex completion_items_mutex; std::atomic is_scanning; std::vector completion_items; // Absolute file path to the completion item in |completion_items|. // Keep the one with shortest include path. std::unordered_map absolute_path_to_completion_item; // Only one completion item per include path. std::unordered_map inserted_paths; // Cached references Project *project_; std::unique_ptr match_; }; } // namespace ccls ccls-0.20190823.6/src/indexer.cc000066400000000000000000001406641364776600300157750ustar00rootroot00000000000000// Copyright 2017-2018 ccls Authors // SPDX-License-Identifier: Apache-2.0 #include "indexer.hh" #include "clang_tu.hh" #include "log.hh" #include "pipeline.hh" #include "platform.hh" #include "sema_manager.hh" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace clang; namespace ccls { namespace { GroupMatch *multiVersionMatcher; struct File { std::string path; int64_t mtime; std::string content; std::unique_ptr db; }; struct IndexParam { std::unordered_map uid2file; std::unordered_map uid2multi; struct DeclInfo { Usr usr; std::string short_name; std::string qualified; }; std::unordered_map decl2Info; VFS &vfs; ASTContext *ctx; bool no_linkage; IndexParam(VFS &vfs, bool no_linkage) : vfs(vfs), no_linkage(no_linkage) {} void seenFile(FileID fid) { // If this is the first time we have seen the file (ignoring if we are // generating an index for it): auto [it, inserted] = uid2file.try_emplace(fid); if (inserted) { const FileEntry *fe = ctx->getSourceManager().getFileEntryForID(fid); if (!fe) return; std::string path = pathFromFileEntry(*fe); it->second.path = path; it->second.mtime = fe->getModificationTime(); if (!it->second.mtime) if (auto tim = lastWriteTime(path)) it->second.mtime = *tim; if (std::optional content = readContent(path)) it->second.content = *content; if (!vfs.stamp(path, it->second.mtime, no_linkage ? 3 : 1)) return; it->second.db = std::make_unique(path, it->second.content, no_linkage); } } IndexFile *consumeFile(FileID fid) { seenFile(fid); return uid2file[fid].db.get(); } bool useMultiVersion(FileID fid) { auto it = uid2multi.try_emplace(fid); if (it.second) if (const FileEntry *fe = ctx->getSourceManager().getFileEntryForID(fid)) it.first->second = multiVersionMatcher->matches(pathFromFileEntry(*fe)); return it.first->second; } }; StringRef getSourceInRange(const SourceManager &sm, const LangOptions &langOpts, SourceRange sr) { SourceLocation bloc = sr.getBegin(), eLoc = sr.getEnd(); std::pair bInfo = sm.getDecomposedLoc(bloc), eInfo = sm.getDecomposedLoc(eLoc); bool invalid = false; StringRef buf = sm.getBufferData(bInfo.first, &invalid); if (invalid) return ""; return buf.substr(bInfo.second, eInfo.second + Lexer::MeasureTokenLength(eLoc, sm, langOpts) - bInfo.second); } Kind getKind(const Decl *d, SymbolKind &kind) { switch (d->getKind()) { case Decl::LinkageSpec: return Kind::Invalid; case Decl::Namespace: case Decl::NamespaceAlias: kind = SymbolKind::Namespace; return Kind::Type; case Decl::ObjCCategory: case Decl::ObjCCategoryImpl: case Decl::ObjCImplementation: case Decl::ObjCInterface: case Decl::ObjCProtocol: kind = SymbolKind::Interface; return Kind::Type; case Decl::ObjCMethod: kind = SymbolKind::Method; return Kind::Func; case Decl::ObjCProperty: kind = SymbolKind::Property; return Kind::Type; case Decl::ClassTemplate: kind = SymbolKind::Class; return Kind::Type; case Decl::FunctionTemplate: kind = SymbolKind::Function; return Kind::Func; case Decl::TypeAliasTemplate: kind = SymbolKind::TypeAlias; return Kind::Type; case Decl::VarTemplate: kind = SymbolKind::Variable; return Kind::Var; case Decl::TemplateTemplateParm: kind = SymbolKind::TypeParameter; return Kind::Type; case Decl::Enum: kind = SymbolKind::Enum; return Kind::Type; case Decl::CXXRecord: case Decl::Record: kind = SymbolKind::Class; // spec has no Union, use Class if (auto *rd = dyn_cast(d)) if (rd->getTagKind() == TTK_Struct) kind = SymbolKind::Struct; return Kind::Type; case Decl::ClassTemplateSpecialization: case Decl::ClassTemplatePartialSpecialization: kind = SymbolKind::Class; return Kind::Type; case Decl::TemplateTypeParm: kind = SymbolKind::TypeParameter; return Kind::Type; case Decl::TypeAlias: case Decl::Typedef: case Decl::UnresolvedUsingTypename: kind = SymbolKind::TypeAlias; return Kind::Type; case Decl::Using: kind = SymbolKind::Null; // ignored return Kind::Invalid; case Decl::Binding: kind = SymbolKind::Variable; return Kind::Var; case Decl::Field: case Decl::ObjCIvar: kind = SymbolKind::Field; return Kind::Var; case Decl::Function: kind = SymbolKind::Function; return Kind::Func; case Decl::CXXMethod: { const auto *md = cast(d); kind = md->isStatic() ? SymbolKind::StaticMethod : SymbolKind::Method; return Kind::Func; } case Decl::CXXConstructor: kind = SymbolKind::Constructor; return Kind::Func; case Decl::CXXConversion: case Decl::CXXDestructor: kind = SymbolKind::Method; return Kind::Func; case Decl::NonTypeTemplateParm: // ccls extension kind = SymbolKind::Parameter; return Kind::Var; case Decl::Var: case Decl::Decomposition: kind = SymbolKind::Variable; return Kind::Var; case Decl::ImplicitParam: case Decl::ParmVar: // ccls extension kind = SymbolKind::Parameter; return Kind::Var; case Decl::VarTemplateSpecialization: case Decl::VarTemplatePartialSpecialization: kind = SymbolKind::Variable; return Kind::Var; case Decl::EnumConstant: kind = SymbolKind::EnumMember; return Kind::Var; case Decl::UnresolvedUsingValue: kind = SymbolKind::Variable; return Kind::Var; case Decl::TranslationUnit: return Kind::Invalid; default: return Kind::Invalid; } } LanguageId getDeclLanguage(const Decl *d) { switch (d->getKind()) { default: return LanguageId::C; case Decl::ImplicitParam: case Decl::ObjCAtDefsField: case Decl::ObjCCategory: case Decl::ObjCCategoryImpl: case Decl::ObjCCompatibleAlias: case Decl::ObjCImplementation: case Decl::ObjCInterface: case Decl::ObjCIvar: case Decl::ObjCMethod: case Decl::ObjCProperty: case Decl::ObjCPropertyImpl: case Decl::ObjCProtocol: case Decl::ObjCTypeParam: return LanguageId::ObjC; case Decl::CXXConstructor: case Decl::CXXConversion: case Decl::CXXDestructor: case Decl::CXXMethod: case Decl::CXXRecord: case Decl::ClassTemplate: case Decl::ClassTemplatePartialSpecialization: case Decl::ClassTemplateSpecialization: case Decl::Friend: case Decl::FriendTemplate: case Decl::FunctionTemplate: case Decl::LinkageSpec: case Decl::Namespace: case Decl::NamespaceAlias: case Decl::NonTypeTemplateParm: case Decl::StaticAssert: case Decl::TemplateTemplateParm: case Decl::TemplateTypeParm: case Decl::UnresolvedUsingTypename: case Decl::UnresolvedUsingValue: case Decl::Using: case Decl::UsingDirective: case Decl::UsingShadow: return LanguageId::Cpp; } } // clang/lib/AST/DeclPrinter.cpp QualType getBaseType(QualType t, bool deduce_auto) { QualType baseType = t; while (!baseType.isNull() && !baseType->isSpecifierType()) { if (const PointerType *pTy = baseType->getAs()) baseType = pTy->getPointeeType(); else if (const BlockPointerType *bPy = baseType->getAs()) baseType = bPy->getPointeeType(); else if (const ArrayType *aTy = dyn_cast(baseType)) baseType = aTy->getElementType(); else if (const VectorType *vTy = baseType->getAs()) baseType = vTy->getElementType(); else if (const ReferenceType *rTy = baseType->getAs()) baseType = rTy->getPointeeType(); else if (const ParenType *pTy = baseType->getAs()) baseType = pTy->desugar(); else if (deduce_auto) { if (const AutoType *aTy = baseType->getAs()) baseType = aTy->getDeducedType(); else break; } else break; } return baseType; } const Decl *getTypeDecl(QualType t, bool *specialization = nullptr) { Decl *d = nullptr; t = getBaseType(t.getUnqualifiedType(), true); const Type *tp = t.getTypePtrOrNull(); if (!tp) return nullptr; try_again: switch (tp->getTypeClass()) { case Type::Typedef: d = cast(tp)->getDecl(); break; case Type::ObjCObject: d = cast(tp)->getInterface(); break; case Type::ObjCInterface: d = cast(tp)->getDecl(); break; case Type::Record: case Type::Enum: d = cast(tp)->getDecl(); break; case Type::TemplateTypeParm: d = cast(tp)->getDecl(); break; case Type::TemplateSpecialization: if (specialization) *specialization = true; if (const RecordType *record = tp->getAs()) d = record->getDecl(); else d = cast(tp) ->getTemplateName() .getAsTemplateDecl(); break; case Type::Auto: case Type::DeducedTemplateSpecialization: tp = cast(tp)->getDeducedType().getTypePtrOrNull(); if (tp) goto try_again; break; case Type::InjectedClassName: d = cast(tp)->getDecl(); break; // FIXME: Template type parameters! case Type::Elaborated: tp = cast(tp)->getNamedType().getTypePtrOrNull(); goto try_again; default: break; } return d; } const Decl *getAdjustedDecl(const Decl *d) { while (d) { if (auto *r = dyn_cast(d)) { if (auto *s = dyn_cast(r)) { if (!s->getTypeAsWritten()) { llvm::PointerUnion result = s->getSpecializedTemplateOrPartial(); if (result.is()) d = result.get(); else d = result.get(); continue; } } else if (auto *d1 = r->getInstantiatedFromMemberClass()) { d = d1; continue; } } else if (auto *ed = dyn_cast(d)) { if (auto *d1 = ed->getInstantiatedFromMemberEnum()) { d = d1; continue; } } break; } return d; } bool validateRecord(const RecordDecl *rd) { for (const auto *i : rd->fields()) { QualType fqt = i->getType(); if (fqt->isIncompleteType() || fqt->isDependentType()) return false; if (const RecordType *childType = i->getType()->getAs()) if (const RecordDecl *child = childType->getDecl()) if (!validateRecord(child)) return false; } return true; } class IndexDataConsumer : public index::IndexDataConsumer { public: ASTContext *ctx; IndexParam ¶m; std::string getComment(const Decl *d) { SourceManager &sm = ctx->getSourceManager(); const RawComment *rc = ctx->getRawCommentForAnyRedecl(d); if (!rc) return ""; StringRef raw = rc->getRawText(ctx->getSourceManager()); SourceRange sr = rc->getSourceRange(); std::pair bInfo = sm.getDecomposedLoc(sr.getBegin()); unsigned start_column = sm.getLineNumber(bInfo.first, bInfo.second); std::string ret; int pad = -1; for (const char *p = raw.data(), *e = raw.end(); p < e;) { // The first line starts with a comment marker, but the rest needs // un-indenting. unsigned skip = start_column - 1; for (; skip > 0 && p < e && (*p == ' ' || *p == '\t'); p++) skip--; const char *q = p; while (q < e && *q != '\n') q++; if (q < e) q++; // A minimalist approach to skip Doxygen comment markers. // See https://www.stack.nl/~dimitri/doxygen/manual/docblocks.html if (pad < 0) { // First line, detect the length of comment marker and put into |pad| const char *begin = p; while (p < e && (*p == '/' || *p == '*' || *p == '-' || *p == '=')) p++; if (p < e && (*p == '<' || *p == '!')) p++; if (p < e && *p == ' ') p++; if (p + 1 == q) p++; else pad = int(p - begin); } else { // Other lines, skip |pad| bytes int prefix = pad; while (prefix > 0 && p < e && (*p == ' ' || *p == '/' || *p == '*' || *p == '<' || *p == '!')) prefix--, p++; } ret.insert(ret.end(), p, q); p = q; } while (ret.size() && isspace(ret.back())) ret.pop_back(); if (StringRef(ret).endswith("*/") || StringRef(ret).endswith("\n/")) ret.resize(ret.size() - 2); while (ret.size() && isspace(ret.back())) ret.pop_back(); return ret; } Usr getUsr(const Decl *d, IndexParam::DeclInfo **info = nullptr) const { d = d->getCanonicalDecl(); auto [it, inserted] = param.decl2Info.try_emplace(d); if (inserted) { SmallString<256> usr; index::generateUSRForDecl(d, usr); auto &info = it->second; info.usr = hashUsr(usr); if (auto *nd = dyn_cast(d)) { info.short_name = nd->getNameAsString(); llvm::raw_string_ostream os(info.qualified); nd->printQualifiedName(os, getDefaultPolicy()); simplifyAnonymous(info.qualified); } } if (info) *info = &it->second; return it->second.usr; } PrintingPolicy getDefaultPolicy() const { PrintingPolicy pp(ctx->getLangOpts()); pp.AnonymousTagLocations = false; pp.TerseOutput = true; pp.PolishForDeclaration = true; pp.ConstantsAsWritten = true; pp.SuppressTagKeyword = true; pp.SuppressUnwrittenScope = g_config->index.name.suppressUnwrittenScope; pp.SuppressInitializers = true; pp.FullyQualifiedName = false; return pp; } static void simplifyAnonymous(std::string &name) { for (std::string::size_type i = 0;;) { if ((i = name.find("(anonymous ", i)) == std::string::npos) break; i++; if (name.size() - i > 19 && name.compare(i + 10, 9, "namespace") == 0) name.replace(i, 19, "anon ns"); else name.replace(i, 9, "anon"); } } template void setName(const Decl *d, std::string_view short_name, std::string_view qualified, Def &def) { SmallString<256> str; llvm::raw_svector_ostream os(str); d->print(os, getDefaultPolicy()); std::string name(str.data(), str.size()); simplifyAnonymous(name); // Remove \n in DeclPrinter.cpp "{\n" + if(!TerseOutput)something + "}" for (std::string::size_type i = 0;;) { if ((i = name.find("{\n}", i)) == std::string::npos) break; name.replace(i, 3, "{}"); } auto i = name.find(short_name); if (short_name.size()) while (i != std::string::npos && ((i && isIdentifierBody(name[i - 1])) || isIdentifierBody(name[i + short_name.size()]))) i = name.find(short_name, i + short_name.size()); if (i == std::string::npos) { // e.g. operator type-parameter-1 i = 0; def.short_name_offset = 0; } else if (short_name.empty() || (i >= 2 && name[i - 2] == ':')) { // Don't replace name with qualified name in ns::name Cls::*name def.short_name_offset = i; } else { name.replace(i, short_name.size(), qualified); def.short_name_offset = i + qualified.size() - short_name.size(); } def.short_name_size = short_name.size(); for (int paren = 0; i; i--) { // Skip parentheses in "(anon struct)::name" if (name[i - 1] == ')') paren++; else if (name[i - 1] == '(') paren--; else if (!(paren > 0 || isIdentifierBody(name[i - 1]) || name[i - 1] == ':')) break; } def.qual_name_offset = i; def.detailed_name = intern(name); } void setVarName(const Decl *d, std::string_view short_name, std::string_view qualified, IndexVar::Def &def) { QualType t; const Expr *init = nullptr; bool deduced = false; if (auto *vd = dyn_cast(d)) { t = vd->getType(); init = vd->getAnyInitializer(); def.storage = vd->getStorageClass(); } else if (auto *fd = dyn_cast(d)) { t = fd->getType(); init = fd->getInClassInitializer(); } else if (auto *bd = dyn_cast(d)) { t = bd->getType(); deduced = true; } if (!t.isNull()) { if (t->getContainedDeducedType()) { deduced = true; } else if (auto *dt = dyn_cast(t)) { // decltype(y) x; while (dt && !dt->getUnderlyingType().isNull()) { t = dt->getUnderlyingType(); dt = dyn_cast(t); } deduced = true; } } if (!t.isNull() && deduced) { SmallString<256> str; llvm::raw_svector_ostream os(str); PrintingPolicy pp = getDefaultPolicy(); t.print(os, pp); if (str.size() && (str.back() != ' ' && str.back() != '*' && str.back() != '&')) str += ' '; def.qual_name_offset = str.size(); def.short_name_offset = str.size() + qualified.size() - short_name.size(); def.short_name_size = short_name.size(); str += StringRef(qualified.data(), qualified.size()); def.detailed_name = intern(str); } else { setName(d, short_name, qualified, def); } if (init) { SourceManager &sm = ctx->getSourceManager(); const LangOptions &lang = ctx->getLangOpts(); SourceRange sr = sm.getExpansionRange(init->getSourceRange()).getAsRange(); SourceLocation l = d->getLocation(); if (l.isMacroID() || !sm.isBeforeInTranslationUnit(l, sr.getBegin())) return; StringRef buf = getSourceInRange(sm, lang, sr); Twine init = buf.count('\n') <= g_config->index.maxInitializerLines - 1 ? buf.size() && buf[0] == ':' ? Twine(" ", buf) : Twine(" = ", buf) : Twine(); Twine t = def.detailed_name + init; def.hover = def.storage == SC_Static && strncmp(def.detailed_name, "static ", 7) ? intern(("static " + t).str()) : intern(t.str()); } } static int getFileLID(IndexFile *db, SourceManager &sm, FileID fid) { auto [it, inserted] = db->uid2lid_and_path.try_emplace(fid); if (inserted) { const FileEntry *fe = sm.getFileEntryForID(fid); if (!fe) { it->second.first = -1; return -1; } it->second.first = db->uid2lid_and_path.size() - 1; it->second.second = pathFromFileEntry(*fe); } return it->second.first; } void addMacroUse(IndexFile *db, SourceManager &sm, Usr usr, Kind kind, SourceLocation sl) const { FileID fid = sm.getFileID(sl); int lid = getFileLID(db, sm, fid); if (lid < 0) return; Range spell = fromTokenRange(sm, ctx->getLangOpts(), SourceRange(sl, sl)); Use use{{spell, Role::Dynamic}, lid}; switch (kind) { case Kind::Func: db->toFunc(usr).uses.push_back(use); break; case Kind::Type: db->toType(usr).uses.push_back(use); break; case Kind::Var: db->toVar(usr).uses.push_back(use); break; default: llvm_unreachable(""); } } void collectRecordMembers(IndexType &type, const RecordDecl *rd) { SmallVector, 2> stack{{rd, 0}}; llvm::DenseSet seen; seen.insert(rd); while (stack.size()) { int offset; std::tie(rd, offset) = stack.back(); stack.pop_back(); if (!rd->isCompleteDefinition() || rd->isDependentType() || rd->isInvalidDecl() || !validateRecord(rd)) offset = -1; for (FieldDecl *fd : rd->fields()) { int offset1 = offset < 0 ? -1 : offset + ctx->getFieldOffset(fd); if (fd->getIdentifier()) type.def.vars.emplace_back(getUsr(fd), offset1); else if (const auto *rt1 = fd->getType()->getAs()) { if (const RecordDecl *rd1 = rt1->getDecl()) if (seen.insert(rd1).second) stack.push_back({rd1, offset1}); } } } } public: IndexDataConsumer(IndexParam ¶m) : param(param) {} void initialize(ASTContext &ctx) override { this->ctx = param.ctx = &ctx; } #if LLVM_VERSION_MAJOR < 10 // llvmorg-10-init-12036-g3b9715cb219 # define handleDeclOccurrence handleDeclOccurence #endif bool handleDeclOccurrence(const Decl *d, index::SymbolRoleSet roles, ArrayRef relations, SourceLocation src_loc, ASTNodeInfo ast_node) override { if (!param.no_linkage) { if (auto *nd = dyn_cast(d); nd && nd->hasLinkage()) ; else return true; } SourceManager &sm = ctx->getSourceManager(); const LangOptions &lang = ctx->getLangOpts(); FileID fid; SourceLocation spell = sm.getSpellingLoc(src_loc); Range loc; auto r = sm.isMacroArgExpansion(src_loc) ? CharSourceRange::getTokenRange(spell) : sm.getExpansionRange(src_loc); loc = fromCharSourceRange(sm, lang, r); fid = sm.getFileID(r.getBegin()); if (fid.isInvalid()) return true; int lid = -1; IndexFile *db; if (g_config->index.multiVersion && param.useMultiVersion(fid)) { db = param.consumeFile(sm.getMainFileID()); if (!db) return true; param.seenFile(fid); if (!sm.isWrittenInMainFile(r.getBegin())) lid = getFileLID(db, sm, fid); } else { db = param.consumeFile(fid); if (!db) return true; } // spell, extent, comments use OrigD while most others use adjusted |D|. const Decl *origD = ast_node.OrigD; const DeclContext *sem_dc = origD->getDeclContext()->getRedeclContext(); const DeclContext *lex_dc = ast_node.ContainerDC->getRedeclContext(); { const NamespaceDecl *nd; while ((nd = dyn_cast(cast(sem_dc))) && nd->isAnonymousNamespace()) sem_dc = nd->getDeclContext()->getRedeclContext(); while ((nd = dyn_cast(cast(lex_dc))) && nd->isAnonymousNamespace()) lex_dc = nd->getDeclContext()->getRedeclContext(); } Role role = static_cast(roles); db->language = LanguageId((int)db->language | (int)getDeclLanguage(d)); bool is_decl = roles & uint32_t(index::SymbolRole::Declaration); bool is_def = roles & uint32_t(index::SymbolRole::Definition); if (is_decl && d->getKind() == Decl::Binding) is_def = true; IndexFunc *func = nullptr; IndexType *type = nullptr; IndexVar *var = nullptr; SymbolKind ls_kind = SymbolKind::Unknown; Kind kind = getKind(d, ls_kind); if (is_def) switch (d->getKind()) { case Decl::CXXConversion: // *operator* int => *operator int* case Decl::CXXDestructor: // *~*A => *~A* case Decl::CXXMethod: // *operator*= => *operator=* case Decl::Function: // operator delete if (src_loc.isFileID()) { SourceRange sr = cast(origD)->getNameInfo().getSourceRange(); if (sr.getEnd().isFileID()) loc = fromTokenRange(sm, lang, sr); } break; default: break; } else { // e.g. typedef Foo gg; => Foo has an unadjusted `D` const Decl *d1 = getAdjustedDecl(d); if (d1 && d1 != d) d = d1; } IndexParam::DeclInfo *info; Usr usr = getUsr(d, &info); auto do_def_decl = [&](auto *entity) { Use use{{loc, role}, lid}; if (is_def) { SourceRange sr = origD->getSourceRange(); entity->def.spell = {use, fromTokenRangeDefaulted(sm, lang, sr, fid, loc)}; entity->def.parent_kind = SymbolKind::File; getKind(cast(sem_dc), entity->def.parent_kind); } else if (is_decl) { SourceRange sr = origD->getSourceRange(); entity->declarations.push_back( {use, fromTokenRangeDefaulted(sm, lang, sr, fid, loc)}); } else { entity->uses.push_back(use); return; } if (entity->def.comments[0] == '\0' && g_config->index.comments) entity->def.comments = intern(getComment(origD)); }; switch (kind) { case Kind::Invalid: if (ls_kind == SymbolKind::Unknown) LOG_S(INFO) << "Unhandled " << int(d->getKind()) << " " << info->qualified << " in " << db->path << ":" << (loc.start.line + 1) << ":" << (loc.start.column + 1); return true; case Kind::File: return true; case Kind::Func: func = &db->toFunc(usr); func->def.kind = ls_kind; // Mark as Role::Implicit to span one more column to the left/right. if (!is_def && !is_decl && (d->getKind() == Decl::CXXConstructor || d->getKind() == Decl::CXXConversion)) role = Role(role | Role::Implicit); do_def_decl(func); if (spell != src_loc) addMacroUse(db, sm, usr, Kind::Func, spell); if (func->def.detailed_name[0] == '\0') setName(d, info->short_name, info->qualified, func->def); if (is_def || is_decl) { const Decl *dc = cast(sem_dc); if (getKind(dc, ls_kind) == Kind::Type) db->toType(getUsr(dc)).def.funcs.push_back(usr); } else { const Decl *dc = cast(lex_dc); if (getKind(dc, ls_kind) == Kind::Func) db->toFunc(getUsr(dc)) .def.callees.push_back({loc, usr, Kind::Func, role}); } break; case Kind::Type: type = &db->toType(usr); type->def.kind = ls_kind; do_def_decl(type); if (spell != src_loc) addMacroUse(db, sm, usr, Kind::Type, spell); if ((is_def || type->def.detailed_name[0] == '\0') && info->short_name.size()) { if (d->getKind() == Decl::TemplateTypeParm) type->def.detailed_name = intern(info->short_name); else // OrigD may be detailed, e.g. "struct D : B {}" setName(origD, info->short_name, info->qualified, type->def); } if (is_def || is_decl) { const Decl *dc = cast(sem_dc); if (getKind(dc, ls_kind) == Kind::Type) db->toType(getUsr(dc)).def.types.push_back(usr); } break; case Kind::Var: var = &db->toVar(usr); var->def.kind = ls_kind; do_def_decl(var); if (spell != src_loc) addMacroUse(db, sm, usr, Kind::Var, spell); if (var->def.detailed_name[0] == '\0') setVarName(d, info->short_name, info->qualified, var->def); QualType t; if (auto *vd = dyn_cast(d)) t = vd->getType(); if (is_def || is_decl) { const Decl *dc = cast(sem_dc); Kind kind = getKind(dc, var->def.parent_kind); if (kind == Kind::Func) db->toFunc(getUsr(dc)).def.vars.push_back(usr); else if (kind == Kind::Type && !isa(sem_dc)) db->toType(getUsr(dc)).def.vars.emplace_back(usr, -1); if (!t.isNull()) { if (auto *bt = t->getAs()) { Usr usr1 = static_cast(bt->getKind()); var->def.type = usr1; if (!isa(d)) db->toType(usr1).instances.push_back(usr); } else if (const Decl *d1 = getAdjustedDecl(getTypeDecl(t))) { #if LLVM_VERSION_MAJOR < 9 if (isa(d1)) { // e.g. TemplateTypeParmDecl is not handled by // handleDeclOccurence. SourceRange sr1 = d1->getSourceRange(); if (sm.getFileID(sr1.getBegin()) == fid) { IndexParam::DeclInfo *info1; Usr usr1 = getUsr(d1, &info1); IndexType &type1 = db->toType(usr1); SourceLocation sl1 = d1->getLocation(); type1.def.spell = { Use{{fromTokenRange(sm, lang, {sl1, sl1}), Role::Definition}, lid}, fromTokenRange(sm, lang, sr1)}; type1.def.detailed_name = intern(info1->short_name); type1.def.short_name_size = int16_t(info1->short_name.size()); type1.def.kind = SymbolKind::TypeParameter; type1.def.parent_kind = SymbolKind::Class; var->def.type = usr1; type1.instances.push_back(usr); break; } } #endif IndexParam::DeclInfo *info1; Usr usr1 = getUsr(d1, &info1); var->def.type = usr1; if (!isa(d)) db->toType(usr1).instances.push_back(usr); } } } else if (!var->def.spell && var->declarations.empty()) { // e.g. lambda parameter SourceLocation l = d->getLocation(); if (sm.getFileID(l) == fid) { var->def.spell = { Use{{fromTokenRange(sm, lang, {l, l}), Role::Definition}, lid}, fromTokenRange(sm, lang, d->getSourceRange())}; var->def.parent_kind = SymbolKind::Method; } } break; } switch (d->getKind()) { case Decl::Namespace: if (d->isFirstDecl()) { auto *nd = cast(d); auto *nd1 = cast(nd->getParent()); if (isa(nd1)) { Usr usr1 = getUsr(nd1); type->def.bases.push_back(usr1); db->toType(usr1).derived.push_back(usr); } } break; case Decl::NamespaceAlias: { auto *nad = cast(d); if (const NamespaceDecl *nd = nad->getNamespace()) { Usr usr1 = getUsr(nd); type->def.alias_of = usr1; (void)db->toType(usr1); } break; } case Decl::CXXRecord: if (is_def) { auto *rd = dyn_cast(d); if (rd && rd->hasDefinition()) for (const CXXBaseSpecifier &base : rd->bases()) if (const Decl *baseD = getAdjustedDecl(getTypeDecl(base.getType()))) { Usr usr1 = getUsr(baseD); type->def.bases.push_back(usr1); db->toType(usr1).derived.push_back(usr); } } [[fallthrough]]; case Decl::Record: if (auto *rd = dyn_cast(d)) { if (type->def.detailed_name[0] == '\0' && info->short_name.empty()) { StringRef tag; switch (rd->getTagKind()) { case TTK_Struct: tag = "struct"; break; case TTK_Interface: tag = "__interface"; break; case TTK_Union: tag = "union"; break; case TTK_Class: tag = "class"; break; case TTK_Enum: tag = "enum"; break; } if (TypedefNameDecl *td = rd->getTypedefNameForAnonDecl()) { StringRef name = td->getName(); std::string detailed = ("anon " + tag + " " + name).str(); type->def.detailed_name = intern(detailed); type->def.short_name_size = detailed.size(); } else { std::string name = ("anon " + tag).str(); type->def.detailed_name = intern(name); type->def.short_name_size = name.size(); } } if (is_def) if (auto *ord = dyn_cast(origD)) collectRecordMembers(*type, ord); } break; case Decl::ClassTemplateSpecialization: case Decl::ClassTemplatePartialSpecialization: type->def.kind = SymbolKind::Class; if (is_def) { if (auto *ord = dyn_cast(origD)) collectRecordMembers(*type, ord); if (auto *rd = dyn_cast(d)) { Decl *d1 = nullptr; if (auto *sd = dyn_cast(rd)) d1 = sd->getSpecializedTemplate(); else if (auto *sd = dyn_cast(rd)) { llvm::PointerUnion result = sd->getSpecializedTemplateOrPartial(); if (result.is()) d1 = result.get(); else d1 = result.get(); } else d1 = rd->getInstantiatedFromMemberClass(); if (d1) { Usr usr1 = getUsr(d1); type->def.bases.push_back(usr1); db->toType(usr1).derived.push_back(usr); } } } break; case Decl::TypeAlias: case Decl::Typedef: case Decl::UnresolvedUsingTypename: if (auto *td = dyn_cast(d)) { bool specialization = false; QualType t = td->getUnderlyingType(); if (const Decl *d1 = getAdjustedDecl(getTypeDecl(t, &specialization))) { Usr usr1 = getUsr(d1); IndexType &type1 = db->toType(usr1); type->def.alias_of = usr1; // Not visited template struct B {typedef A t;}; if (specialization) { const TypeSourceInfo *tsi = td->getTypeSourceInfo(); SourceLocation l1 = tsi->getTypeLoc().getBeginLoc(); if (sm.getFileID(l1) == fid) type1.uses.push_back( {{fromTokenRange(sm, lang, {l1, l1}), Role::Reference}, lid}); } } } break; case Decl::CXXMethod: if (is_def || is_decl) { if (auto *nd = dyn_cast(d)) { SmallVector overDecls; ctx->getOverriddenMethods(nd, overDecls); for (const auto *nd1 : overDecls) { Usr usr1 = getUsr(nd1); func->def.bases.push_back(usr1); db->toFunc(usr1).derived.push_back(usr); } } } break; case Decl::EnumConstant: if (is_def && strchr(var->def.detailed_name, '=') == nullptr) { auto *ecd = cast(d); const auto &val = ecd->getInitVal(); std::string init = " = " + (val.isSigned() ? std::to_string(val.getSExtValue()) : std::to_string(val.getZExtValue())); var->def.hover = intern(var->def.detailed_name + init); } break; default: break; } return true; } }; class IndexPPCallbacks : public PPCallbacks { SourceManager &sm; IndexParam ¶m; std::pair getMacro(const Token &tok) const { StringRef name = tok.getIdentifierInfo()->getName(); SmallString<256> usr("@macro@"); usr += name; return {name, hashUsr(usr)}; } public: IndexPPCallbacks(SourceManager &sm, IndexParam ¶m) : sm(sm), param(param) {} void FileChanged(SourceLocation sl, FileChangeReason reason, SrcMgr::CharacteristicKind, FileID) override { if (reason == FileChangeReason::EnterFile) (void)param.consumeFile(sm.getFileID(sl)); } void InclusionDirective(SourceLocation hashLoc, const Token &tok, StringRef included, bool isAngled, CharSourceRange filenameRange, const FileEntry *file, StringRef searchPath, StringRef relativePath, const Module *imported, SrcMgr::CharacteristicKind fileType) override { if (!file) return; auto spell = fromCharSourceRange(sm, param.ctx->getLangOpts(), filenameRange, nullptr); FileID fid = sm.getFileID(filenameRange.getBegin()); if (IndexFile *db = param.consumeFile(fid)) { std::string path = pathFromFileEntry(*file); if (path.size()) db->includes.push_back({spell.start.line, intern(path)}); } } void MacroDefined(const Token &tok, const MacroDirective *md) override { const LangOptions &lang = param.ctx->getLangOpts(); SourceLocation sl = md->getLocation(); FileID fid = sm.getFileID(sl); if (IndexFile *db = param.consumeFile(fid)) { auto [name, usr] = getMacro(tok); IndexVar &var = db->toVar(usr); Range range = fromTokenRange(sm, lang, {sl, sl}, nullptr); var.def.kind = SymbolKind::Macro; var.def.parent_kind = SymbolKind::File; if (var.def.spell) var.declarations.push_back(*var.def.spell); const MacroInfo *mi = md->getMacroInfo(); SourceRange sr(mi->getDefinitionLoc(), mi->getDefinitionEndLoc()); Range extent = fromTokenRange(sm, param.ctx->getLangOpts(), sr); var.def.spell = {Use{{range, Role::Definition}}, extent}; if (var.def.detailed_name[0] == '\0') { var.def.detailed_name = intern(name); var.def.short_name_size = name.size(); StringRef buf = getSourceInRange(sm, lang, sr); var.def.hover = intern(buf.count('\n') <= g_config->index.maxInitializerLines - 1 ? Twine("#define ", getSourceInRange(sm, lang, sr)).str() : Twine("#define ", name).str()); } } } void MacroExpands(const Token &tok, const MacroDefinition &, SourceRange sr, const MacroArgs *) override { SourceLocation sl = sm.getSpellingLoc(sr.getBegin()); FileID fid = sm.getFileID(sl); if (IndexFile *db = param.consumeFile(fid)) { IndexVar &var = db->toVar(getMacro(tok).second); var.uses.push_back( {{fromTokenRange(sm, param.ctx->getLangOpts(), {sl, sl}, nullptr), Role::Dynamic}}); } } void MacroUndefined(const Token &tok, const MacroDefinition &md, const MacroDirective *ud) override { if (ud) { SourceLocation sl = ud->getLocation(); MacroExpands(tok, md, {sl, sl}, nullptr); } } void SourceRangeSkipped(SourceRange sr, SourceLocation) override { Range range = fromCharSourceRange(sm, param.ctx->getLangOpts(), CharSourceRange::getCharRange(sr)); FileID fid = sm.getFileID(sr.getBegin()); if (fid.isValid()) if (IndexFile *db = param.consumeFile(fid)) db->skipped_ranges.push_back(range); } }; class IndexFrontendAction : public ASTFrontendAction { std::shared_ptr dataConsumer; const index::IndexingOptions &indexOpts; IndexParam ¶m; public: IndexFrontendAction(std::shared_ptr dataConsumer, const index::IndexingOptions &indexOpts, IndexParam ¶m) : dataConsumer(std::move(dataConsumer)), indexOpts(indexOpts), param(param) {} std::unique_ptr CreateASTConsumer(CompilerInstance &ci, StringRef inFile) override { class SkipProcessed : public ASTConsumer { IndexParam ¶m; const ASTContext *ctx = nullptr; public: SkipProcessed(IndexParam ¶m) : param(param) {} void Initialize(ASTContext &ctx) override { this->ctx = &ctx; } bool shouldSkipFunctionBody(Decl *d) override { const SourceManager &sm = ctx->getSourceManager(); FileID fid = sm.getFileID(sm.getExpansionLoc(d->getLocation())); return !(g_config->index.multiVersion && param.useMultiVersion(fid)) && !param.consumeFile(fid); } }; std::shared_ptr pp = ci.getPreprocessorPtr(); pp->addPPCallbacks( std::make_unique(pp->getSourceManager(), param)); std::vector> consumers; consumers.push_back(std::make_unique(param)); #if LLVM_VERSION_MAJOR >= 10 // rC370337 consumers.push_back(index::createIndexingASTConsumer( dataConsumer, indexOpts, std::move(pp))); #endif return std::make_unique(std::move(consumers)); } }; } // namespace const int IndexFile::kMajorVersion = 21; const int IndexFile::kMinorVersion = 0; IndexFile::IndexFile(const std::string &path, const std::string &contents, bool no_linkage) : path(path), no_linkage(no_linkage), file_contents(contents) {} IndexFunc &IndexFile::toFunc(Usr usr) { auto [it, inserted] = usr2func.try_emplace(usr); if (inserted) it->second.usr = usr; return it->second; } IndexType &IndexFile::toType(Usr usr) { auto [it, inserted] = usr2type.try_emplace(usr); if (inserted) it->second.usr = usr; return it->second; } IndexVar &IndexFile::toVar(Usr usr) { auto [it, inserted] = usr2var.try_emplace(usr); if (inserted) it->second.usr = usr; return it->second; } std::string IndexFile::toString() { return ccls::serialize(SerializeFormat::Json, *this); } template void uniquify(std::vector &a) { std::unordered_set seen; size_t n = 0; for (size_t i = 0; i < a.size(); i++) if (seen.insert(a[i]).second) a[n++] = a[i]; a.resize(n); } namespace idx { void init() { multiVersionMatcher = new GroupMatch(g_config->index.multiVersionWhitelist, g_config->index.multiVersionBlacklist); } std::vector> index(SemaManager *manager, WorkingFiles *wfiles, VFS *vfs, const std::string &opt_wdir, const std::string &main, const std::vector &args, const std::vector> &remapped, bool no_linkage, bool &ok) { ok = true; auto pch = std::make_shared(); llvm::IntrusiveRefCntPtr fs = llvm::vfs::getRealFileSystem(); std::shared_ptr ci = buildCompilerInvocation(main, args, fs); // e.g. .s if (!ci) return {}; ok = false; // -fparse-all-comments enables documentation in the indexer and in // code completion. ci->getLangOpts()->CommentOpts.ParseAllComments = g_config->index.comments > 1; ci->getLangOpts()->RetainCommentsFromSystemHeaders = true; std::string buf = wfiles->getContent(main); std::vector> bufs; if (buf.size()) for (auto &[filename, content] : remapped) { bufs.push_back(llvm::MemoryBuffer::getMemBuffer(content)); ci->getPreprocessorOpts().addRemappedFile(filename, bufs.back().get()); } DiagnosticConsumer dc; auto clang = std::make_unique(pch); clang->setInvocation(std::move(ci)); clang->createDiagnostics(&dc, false); clang->getDiagnostics().setIgnoreAllWarnings(true); clang->setTarget(TargetInfo::CreateTargetInfo( clang->getDiagnostics(), clang->getInvocation().TargetOpts)); if (!clang->hasTarget()) return {}; clang->getPreprocessorOpts().RetainRemappedFileBuffers = true; #if LLVM_VERSION_MAJOR >= 9 // rC357037 clang->createFileManager(fs); #else clang->setVirtualFileSystem(fs); clang->createFileManager(); #endif clang->setSourceManager(new SourceManager(clang->getDiagnostics(), clang->getFileManager(), true)); IndexParam param(*vfs, no_linkage); index::IndexingOptions indexOpts; indexOpts.SystemSymbolFilter = index::IndexingOptions::SystemSymbolFilterKind::All; if (no_linkage) { indexOpts.IndexFunctionLocals = true; indexOpts.IndexImplicitInstantiation = true; #if LLVM_VERSION_MAJOR >= 9 indexOpts.IndexParametersInDeclarations = g_config->index.parametersInDeclarations; indexOpts.IndexTemplateParameters = true; #endif } #if LLVM_VERSION_MAJOR >= 10 // rC370337 auto action = std::make_unique( std::make_shared(param), indexOpts, param); #else auto dataConsumer = std::make_shared(param); auto action = createIndexingAction( dataConsumer, indexOpts, std::make_unique(dataConsumer, indexOpts, param)); #endif std::string reason; { llvm::CrashRecoveryContext crc; auto parse = [&]() { if (!action->BeginSourceFile(*clang, clang->getFrontendOpts().Inputs[0])) return; #if LLVM_VERSION_MAJOR >= 9 // rL364464 if (llvm::Error e = action->Execute()) { reason = llvm::toString(std::move(e)); return; } #else if (!action->Execute()) return; #endif action->EndSourceFile(); ok = true; }; if (!crc.RunSafely(parse)) { LOG_S(ERROR) << "clang crashed for " << main; return {}; } } if (!ok) { LOG_S(ERROR) << "failed to index " << main << (reason.empty() ? "" : ": " + reason); return {}; } std::vector> result; for (auto &it : param.uid2file) { if (!it.second.db) continue; std::unique_ptr &entry = it.second.db; entry->import_file = main; entry->args = args; for (auto &[_, it] : entry->uid2lid_and_path) if (it.first >= 0) entry->lid2path.emplace_back(it.first, std::move(it.second)); entry->uid2lid_and_path.clear(); for (auto &it : entry->usr2func) { // e.g. declaration + out-of-line definition uniquify(it.second.derived); uniquify(it.second.uses); } for (auto &it : entry->usr2type) { uniquify(it.second.derived); uniquify(it.second.uses); // e.g. declaration + out-of-line definition uniquify(it.second.def.bases); uniquify(it.second.def.funcs); } for (auto &it : entry->usr2var) uniquify(it.second.uses); // Update dependencies for the file. for (auto &[_, file] : param.uid2file) { const std::string &path = file.path; if (path.empty()) continue; if (path == entry->path) entry->mtime = file.mtime; else if (path != entry->import_file) entry->dependencies[llvm::CachedHashStringRef(intern(path))] = file.mtime; } result.push_back(std::move(entry)); } return result; } } // namespace idx void reflect(JsonReader &vis, SymbolRef &v) { std::string t = vis.getString(); char *s = const_cast(t.c_str()); v.range = Range::fromString(s); s = strchr(s, '|'); v.usr = strtoull(s + 1, &s, 10); v.kind = static_cast(strtol(s + 1, &s, 10)); v.role = static_cast(strtol(s + 1, &s, 10)); } void reflect(JsonReader &vis, Use &v) { std::string t = vis.getString(); char *s = const_cast(t.c_str()); v.range = Range::fromString(s); s = strchr(s, '|'); v.role = static_cast(strtol(s + 1, &s, 10)); v.file_id = static_cast(strtol(s + 1, &s, 10)); } void reflect(JsonReader &vis, DeclRef &v) { std::string t = vis.getString(); char *s = const_cast(t.c_str()); v.range = Range::fromString(s); s = strchr(s, '|') + 1; v.extent = Range::fromString(s); s = strchr(s, '|'); v.role = static_cast(strtol(s + 1, &s, 10)); v.file_id = static_cast(strtol(s + 1, &s, 10)); } void reflect(JsonWriter &vis, SymbolRef &v) { char buf[99]; snprintf(buf, sizeof buf, "%s|%" PRIu64 "|%d|%d", v.range.toString().c_str(), v.usr, int(v.kind), int(v.role)); std::string s(buf); reflect(vis, s); } void reflect(JsonWriter &vis, Use &v) { char buf[99]; snprintf(buf, sizeof buf, "%s|%d|%d", v.range.toString().c_str(), int(v.role), v.file_id); std::string s(buf); reflect(vis, s); } void reflect(JsonWriter &vis, DeclRef &v) { char buf[99]; snprintf(buf, sizeof buf, "%s|%s|%d|%d", v.range.toString().c_str(), v.extent.toString().c_str(), int(v.role), v.file_id); std::string s(buf); reflect(vis, s); } void reflect(BinaryReader &vis, SymbolRef &v) { reflect(vis, v.range); reflect(vis, v.usr); reflect(vis, v.kind); reflect(vis, v.role); } void reflect(BinaryReader &vis, Use &v) { reflect(vis, v.range); reflect(vis, v.role); reflect(vis, v.file_id); } void reflect(BinaryReader &vis, DeclRef &v) { reflect(vis, static_cast(v)); reflect(vis, v.extent); } void reflect(BinaryWriter &vis, SymbolRef &v) { reflect(vis, v.range); reflect(vis, v.usr); reflect(vis, v.kind); reflect(vis, v.role); } void reflect(BinaryWriter &vis, Use &v) { reflect(vis, v.range); reflect(vis, v.role); reflect(vis, v.file_id); } void reflect(BinaryWriter &vis, DeclRef &v) { reflect(vis, static_cast(v)); reflect(vis, v.extent); } } // namespace ccls ccls-0.20190823.6/src/indexer.hh000066400000000000000000000244751364776600300160100ustar00rootroot00000000000000// Copyright 2017-2018 ccls Authors // SPDX-License-Identifier: Apache-2.0 #pragma once #include "lsp.hh" #include "position.hh" #include "serializer.hh" #include "utils.hh" #include #include #include #include #include #include #include #include namespace std { template <> struct hash { std::size_t operator()(clang::FileID fid) const { return fid.getHashValue(); } }; } // namespace std namespace ccls { using Usr = uint64_t; // The order matters. In findSymbolsAtLocation, we want Var/Func ordered in // front of others. enum class Kind : uint8_t { Invalid, File, Type, Func, Var }; REFLECT_UNDERLYING_B(Kind); enum class Role : uint16_t { None = 0, Declaration = 1 << 0, Definition = 1 << 1, Reference = 1 << 2, Read = 1 << 3, Write = 1 << 4, Call = 1 << 5, Dynamic = 1 << 6, Address = 1 << 7, Implicit = 1 << 8, All = (1 << 9) - 1, }; REFLECT_UNDERLYING_B(Role); inline uint16_t operator&(Role lhs, Role rhs) { return uint16_t(lhs) & uint16_t(rhs); } inline Role operator|(Role lhs, Role rhs) { return Role(uint16_t(lhs) | uint16_t(rhs)); } struct SymbolIdx { Usr usr; Kind kind; bool operator==(const SymbolIdx &o) const { return usr == o.usr && kind == o.kind; } bool operator<(const SymbolIdx &o) const { return usr != o.usr ? usr < o.usr : kind < o.kind; } }; // |id,kind| refer to the referenced entity. struct SymbolRef { Range range; Usr usr; Kind kind; Role role; operator SymbolIdx() const { return {usr, kind}; } std::tuple toTuple() const { return std::make_tuple(range, usr, kind, role); } bool operator==(const SymbolRef &o) const { return toTuple() == o.toTuple(); } bool valid() const { return range.valid(); } }; struct ExtentRef : SymbolRef { Range extent; std::tuple toTuple() const { return std::make_tuple(range, usr, kind, role, extent); } bool operator==(const ExtentRef &o) const { return toTuple() == o.toTuple(); } }; struct Ref { Range range; Role role; bool valid() const { return range.valid(); } std::tuple toTuple() const { return std::make_tuple(range, role); } bool operator==(const Ref &o) const { return toTuple() == o.toTuple(); } bool operator<(const Ref &o) const { return toTuple() < o.toTuple(); } }; // Represents an occurrence of a variable/type, |usr,kind| refer to the lexical // parent. struct Use : Ref { // |file| is used in Query* but not in Index* int file_id = -1; bool operator==(const Use &o) const { // lexical container info is ignored. return range == o.range && file_id == o.file_id; } }; struct DeclRef : Use { Range extent; }; void reflect(JsonReader &visitor, SymbolRef &value); void reflect(JsonReader &visitor, Use &value); void reflect(JsonReader &visitor, DeclRef &value); void reflect(JsonWriter &visitor, SymbolRef &value); void reflect(JsonWriter &visitor, Use &value); void reflect(JsonWriter &visitor, DeclRef &value); void reflect(BinaryReader &visitor, SymbolRef &value); void reflect(BinaryReader &visitor, Use &value); void reflect(BinaryReader &visitor, DeclRef &value); void reflect(BinaryWriter &visitor, SymbolRef &value); void reflect(BinaryWriter &visitor, Use &value); void reflect(BinaryWriter &visitor, DeclRef &value); template using VectorAdapter = std::vector>; template struct NameMixin { std::string_view name(bool qualified) const { auto self = static_cast(this); return qualified ? std::string_view(self->detailed_name + self->qual_name_offset, self->short_name_offset - self->qual_name_offset + self->short_name_size) : std::string_view(self->detailed_name + self->short_name_offset, self->short_name_size); } }; template