llvm-capstone/clang-tools-extra/clangd
Nathan Ridge 0c1dcd6752 [clangd] [HeuristicResolver] Protect against infinite recursion on DependentNameTypes (#83542)
When resolving names inside templates that implement recursive
compile-time functions (e.g. waldo<N>::type is defined in terms
of waldo<N-1>::type), HeuristicResolver could get into an infinite
recursion, specifically one where resolveDependentNameType() can
be called recursively with the same DependentNameType*.

To guard against this, HeuristicResolver tracks, for each external
call into a HeuristicResolver function, the set of DependentNameTypes
that it has seen, and bails if it sees the same DependentNameType again.

To implement this, a helper class HeuristicResolverImpl is introduced
to store state that persists for the duration of an external call into
HeuristicResolver (but does not persist between such calls).

Fixes https://github.com/clangd/clangd/issues/1951

(cherry picked from commit e6e53ca8470d719882539359ebe3ad8b442a8cb0)
2024-03-16 15:26:15 -07:00
..
benchmarks [clangd] Allow to build Clangd without decision forest 2022-12-07 13:52:22 +01:00
fuzzer [clangd] Fix shared lib builds 2023-01-20 08:57:21 +01:00
index [clangd] check for synthesized symbols when tracking include locations (#75128) 2024-01-03 17:52:50 +01:00
indexer [clangd] Add --query-driver flag to clangd-indexer 2023-08-24 11:51:59 -04:00
quality [NFC][Py Reformat] Reformat python files in clang and clang-tools-extra 2023-05-23 08:29:52 +02:00
refactor [clangd] Use StringRef::{starts,ends}_with (NFC) 2023-12-13 23:26:09 -08:00
support [clangd] Use StringRef::{starts,ends}_with (NFC) 2023-12-13 23:26:09 -08:00
test [clangd] Dont require confirmation for include-cleaner batch-fixes (#76826) 2024-01-04 12:57:42 +01:00
tool [clangd] Use StringRef::{starts,ends}_with (NFC) 2023-12-13 23:26:09 -08:00
unittests [clangd] [HeuristicResolver] Protect against infinite recursion on DependentNameTypes (#83542) 2024-03-16 15:26:15 -07:00
xpc cmake: add missing dependencies on ClangDriverOptions tablegen 2023-08-04 10:27:19 -07:00
AST.cpp [clangd] Fix typo in function name in AST.cpp (#77504) 2024-01-09 18:58:38 -05:00
AST.h [clangd] Full support for #import insertions 2023-01-09 09:48:30 -05:00
ASTSignals.cpp [clangd] Full support for #import insertions 2023-01-09 09:48:30 -05:00
ASTSignals.h [clangd] Full support for #import insertions 2023-01-09 09:48:30 -05:00
ClangdLSPServer.cpp [clangd] Prefer definitions for gototype and implementation 2023-07-21 14:38:51 +02:00
ClangdLSPServer.h [clangd] Fix a build error for f4f6c229bd 2023-07-18 19:20:06 +02:00
ClangdServer.cpp [clangd] Use StringRef::{starts,ends}_with (NFC) 2023-12-13 23:26:09 -08:00
ClangdServer.h [clangd] Delete deprecated enumerateTweaks endpoint 2023-09-11 09:09:12 +02:00
CMakeLists.txt [clangd] Fix missing dependency on clang/Driver/Options.inc's tblgen target 2023-05-06 10:11:39 -07:00
CodeComplete.cpp [clangd] Use StringRef::{starts,ends}_with (NFC) 2023-12-13 23:26:09 -08:00
CodeComplete.h [clangd] Add flag to control #import include insertions 2023-01-09 09:48:29 -05:00
CodeCompletionStrings.cpp [clangd] Use StringRef::{starts,ends}_with (NFC) 2023-12-13 23:26:09 -08:00
CodeCompletionStrings.h [clangd][CodeComplete] Improve FunctionCanBeCall 2023-09-28 21:42:02 +08:00
CollectMacros.cpp [clangd] Store offsets in MacroOccurrence 2023-06-23 09:21:08 +02:00
CollectMacros.h [clangd] Store offsets in MacroOccurrence 2023-06-23 09:21:08 +02:00
CompileCommands.cpp [clangd] Use starts_with instead of startswith in CompileCommands.cpp (NFC) 2024-01-12 16:18:14 +08:00
CompileCommands.h [clangd] Expand response files before CDB interpolation (#75753) 2023-12-19 03:25:48 -05:00
Compiler.cpp [clang] NFCI: Change returned LanguageOptions pointer to reference 2023-09-05 13:23:53 -07:00
Compiler.h [clangd] Full support for #import insertions 2023-01-09 09:48:30 -05:00
Config.cpp
Config.h [clangd] Don't run slow clang-tidy checks by default 2023-10-20 11:47:29 +02:00
ConfigCompile.cpp [clangd] Use StringRef::{starts,ends}_with (NFC) 2023-12-13 23:26:09 -08:00
ConfigFragment.h [clangd] Don't run slow clang-tidy checks by default 2023-10-20 11:47:29 +02:00
ConfigProvider.cpp [clang-tools-extra] Use std::optional instead of llvm::Optional (NFC) 2023-01-02 16:17:40 -08:00
ConfigProvider.h [clangd] Clean up unused includes. NFCI 2022-02-26 12:00:16 +01:00
ConfigYAML.cpp [clangd] Don't run slow clang-tidy checks by default 2023-10-20 11:47:29 +02:00
DecisionForest.cpp [clangd] NFC. Add a newline at the end of the file 2022-12-09 12:31:50 +01:00
Diagnostics.cpp [clangd] Downgrade deprecated warnings to hints 2023-07-04 16:07:08 +02:00
Diagnostics.h [clangd] Add batch fixes for include-cleaner diagnostics 2023-04-27 12:08:59 +02:00
DraftStore.cpp [clang-tools-extra] Use std::optional instead of llvm::Optional (NFC) 2023-01-07 20:19:42 -08:00
DraftStore.h [clang-tools-extra] Use std::optional instead of llvm::Optional (NFC) 2023-01-07 20:19:42 -08:00
DumpAST.cpp [c++20] P1907R1: Support for generalized non-type template arguments of scalar type. (#78041) 2024-01-21 21:28:57 +01:00
DumpAST.h
ExpectedTypes.cpp [clang-tools-extra] Use std::optional instead of llvm::Optional (NFC) 2023-01-07 20:19:42 -08:00
ExpectedTypes.h [clang-tools-extra] Use std::optional instead of llvm::Optional (NFC) 2023-01-07 20:19:42 -08:00
Feature.cpp [NFC][TargetParser] Replace uses of llvm/Support/Host.h 2023-02-10 09:59:46 +00:00
Feature.h
FeatureModule.cpp Don't use Optional::hasValue (NFC) 2022-06-26 19:54:41 -07:00
FeatureModule.h [clang-tools-extra] Use std::optional instead of llvm::Optional (NFC) 2023-01-07 20:19:42 -08:00
Features.inc.in [clangd] Fix a typo "Features.h" => "Feature.h" in IWYU pragma. 2022-12-12 13:46:19 +01:00
FileDistance.cpp [clangd] Use StringRef::{starts,ends}_with (NFC) 2023-12-13 23:26:09 -08:00
FileDistance.h [clangd] Clean up unused includes. NFCI 2022-02-26 12:00:16 +01:00
FindSymbols.cpp [clangd] Use StringRef::{starts,ends}_with (NFC) 2023-12-13 23:26:09 -08:00
FindSymbols.h
FindTarget.cpp [c++20] P1907R1: Support for generalized non-type template arguments of scalar type. (#78041) 2024-01-21 21:28:57 +01:00
FindTarget.h [clangd] Clean up unused includes. NFCI 2022-02-26 12:00:16 +01:00
Format.cpp [clangd] Use StringRef::{starts,ends}_with (NFC) 2023-12-13 23:26:09 -08:00
Format.h [clangd] Clean up unused includes. NFCI 2022-02-26 12:00:16 +01:00
FS.cpp [clangd] Store paths as requested in PreambleStatCache 2023-05-23 14:30:58 +02:00
FS.h [clangd] Store paths as requested in PreambleStatCache 2023-05-23 14:30:58 +02:00
FuzzyMatch.cpp [llvm][ADT] Replace uses of makeMutableArrayRef with deduction guides 2023-01-16 14:49:37 -07:00
FuzzyMatch.h [clang-tools-extra] Use std::optional instead of llvm::Optional (NFC) 2023-01-02 16:17:40 -08:00
GlobalCompilationDatabase.cpp [clangd] Expand response files before CDB interpolation (#75753) 2023-12-19 03:25:48 -05:00
GlobalCompilationDatabase.h [clang-tools-extra] Remove remaining uses of llvm::Optional (NFC) 2023-01-07 20:34:53 -08:00
Headers.cpp [clangd] Use StringRef::{starts,ends}_with (NFC) 2023-12-13 23:26:09 -08:00
Headers.h [clangd] Loose include-cleaner matching for verbatim headers 2023-07-27 19:20:53 +02:00
HeaderSourceSwitch.cpp [clang-tools-extra] Use std::optional instead of llvm::Optional (NFC) 2023-01-07 20:19:42 -08:00
HeaderSourceSwitch.h [clang-tools-extra] Remove remaining uses of llvm::Optional (NFC) 2023-01-07 20:34:53 -08:00
HeuristicResolver.cpp [clangd] [HeuristicResolver] Protect against infinite recursion on DependentNameTypes (#83542) 2024-03-16 15:26:15 -07:00
HeuristicResolver.h [clangd] [HeuristicResolver] Protect against infinite recursion on DependentNameTypes (#83542) 2024-03-16 15:26:15 -07:00
Hover.cpp [clangd] Track IWYU pragmas for non-preamble includes (#75612) 2024-01-03 15:57:30 +01:00
Hover.h [clangd] Show alignment for records and fields decls (#67213) 2023-10-22 20:37:12 +04:00
IncludeCleaner.cpp [clangd] Dont require confirmation for include-cleaner batch-fixes (#76826) 2024-01-04 12:57:42 +01:00
IncludeCleaner.h [clangd] Loose include-cleaner matching for verbatim headers 2023-07-27 19:20:53 +02:00
IncludeFixer.cpp [clangd] Use StringRef::{starts,ends}_with (NFC) 2023-12-13 23:26:09 -08:00
IncludeFixer.h [clangd] Full support for #import insertions 2023-01-09 09:48:30 -05:00
InlayHints.cpp Backport '[clang] static operators should evaluate object argument (reland)' to release/18.x (#80109) 2024-02-03 10:35:40 -08:00
InlayHints.h JSON: llvm::Optional => std::optional 2022-12-16 07:56:52 +00:00
JSONTransport.cpp [clangd] Use StringRef::{starts,ends}_with (NFC) 2023-12-13 23:26:09 -08:00
LSPBinder.h
ParsedAST.cpp [clangd] Track IWYU pragmas for non-preamble includes (#75612) 2024-01-03 15:57:30 +01:00
ParsedAST.h [clangd] Track IWYU pragmas for non-preamble includes (#75612) 2024-01-03 15:57:30 +01:00
PathMapping.cpp [clangd] Use StringRef::{starts,ends}_with (NFC) 2023-12-13 23:26:09 -08:00
PathMapping.h [clang-tools-extra] Use std::optional instead of llvm::Optional (NFC) 2023-01-02 16:17:40 -08:00
Preamble.cpp [clang] NFCI: Use FileEntryRef in ASTReader::GetHeaderFileInfo() 2023-09-29 09:07:13 -07:00
Preamble.h [clang] NFCI: Use FileEntryRef in PreamblePatch 2023-09-20 16:10:18 -07:00
Protocol.cpp [clangd] Use StringRef::{starts,ends}_with (NFC) 2023-12-13 23:26:09 -08:00
Protocol.h [clangd] Fix typo in comment 2023-08-14 20:07:58 +02:00
Quality.cpp [clang][NFC] Refactor clang::Linkage (#71049) 2023-11-02 20:57:29 +04:00
Quality.h [clang-tools-extra] Use std::optional instead of llvm::Optional (NFC) 2023-01-07 20:19:42 -08:00
README.md
RIFF.cpp
RIFF.h [clangd] Clean up unused includes. NFCI 2022-02-26 12:00:16 +01:00
Selection.cpp [clangd] Handle lambda scopes inside Node::getDeclContext() (#76329) 2024-01-11 16:59:18 +08:00
Selection.h
SemanticHighlighting.cpp [Clang][NFC] Rename CXXMethodDecl::isPure -> is VirtualPure (#78463) 2024-01-18 15:30:58 +01:00
SemanticHighlighting.h [clangd] Add semantic token for labels 2023-06-07 12:28:06 +02:00
SemanticSelection.cpp [llvm][ADT] Replace uses of makeMutableArrayRef with deduction guides 2023-01-16 14:49:37 -07:00
SemanticSelection.h FoldingRanges: Handle LineFoldingsOnly clients. 2022-08-29 19:03:48 +02:00
SourceCode.cpp [clangd] Use StringRef::{starts,ends}_with (NFC) 2023-12-13 23:26:09 -08:00
SourceCode.h [clangd] Fix the range for include reference to itself. 2023-07-14 12:51:14 +00:00
SystemIncludeExtractor.cpp [clangd] Use StringRef::{starts,ends}_with (NFC) 2023-12-13 23:26:09 -08:00
TidyFastChecks.inc [clangd] Add script to maintain list of fast clang-tidy checks 2022-11-28 14:29:23 +01:00
TidyFastChecks.py [NFC][Py Reformat] Reformat python files in clang and clang-tools-extra 2023-05-23 08:29:52 +02:00
TidyProvider.cpp [clangd] Don't run slow clang-tidy checks by default 2023-10-20 11:47:29 +02:00
TidyProvider.h [clangd] Don't run slow clang-tidy checks by default 2023-10-20 11:47:29 +02:00
Transport.h [clangd] Fix some header guard names, NFC 2022-12-13 10:00:51 +01:00
TUScheduler.cpp [clang][clangd] Ensure the stack bottom before building AST 2023-09-02 18:53:06 +08:00
TUScheduler.h [clangd] Update symbol collector to use include-cleaner. 2023-07-19 13:47:02 +00:00
URI.cpp [clangd] Use StringRef::{starts,ends}_with (NFC) 2023-12-13 23:26:09 -08:00
URI.h
XRefs.cpp [Clang][NFC] Rename CXXMethodDecl::isPure -> is VirtualPure (#78463) 2024-01-18 15:30:58 +01:00
XRefs.h [clangd] Use index for go-to-type 2023-07-21 23:10:33 +02:00

clangd

clangd is a language server, and provides C++ IDE features to editors. This is not its documentation.

Communication channels

If you have any questions or feedback, you can reach community and developers through one of these channels:

Building and testing clangd

For a minimal setup on building clangd:

  • Clone the LLVM repo to $LLVM_ROOT.

  • Create a build directory, for example at $LLVM_ROOT/build.

  • Inside the build directory run: cmake $LLVM_ROOT/llvm/ -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra".

    • We suggest building in Release mode as building DEBUG binaries requires considerably more resources. You can check Building LLVM with CMake documentation for more details about cmake flags.
    • In addition to that using Ninja as a generator rather than default make is preferred. To do that consider passing -G Ninja to cmake invocation.
    • Finally, you can turn on assertions via -DLLVM_ENABLE_ASSERTS=On.
  • Afterwards you can build clangd with cmake --build $LLVM_ROOT/build --target clangd, similarly run tests by changing target to check-clangd.