[all-commits] [llvm/llvm-project] e6e53c: [clangd] [HeuristicResolver] Protect against infin...

Nathan Ridge via All-commits all-commits at lists.llvm.org
Sun Mar 3 21:13:07 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: e6e53ca8470d719882539359ebe3ad8b442a8cb0
      https://github.com/llvm/llvm-project/commit/e6e53ca8470d719882539359ebe3ad8b442a8cb0
  Author: Nathan Ridge <zeratul976 at hotmail.com>
  Date:   2024-03-04 (Mon, 04 Mar 2024)

  Changed paths:
    M clang-tools-extra/clangd/HeuristicResolver.cpp
    M clang-tools-extra/clangd/HeuristicResolver.h
    M clang-tools-extra/clangd/unittests/FindTargetTests.cpp

  Log Message:
  -----------
  [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



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list