clang 19.0.0git
Public Member Functions | List of all members
clang::tooling::FileMatchTrieNode Class Reference

A node of the FileMatchTrie. More...

Public Member Functions

void insert (StringRef NewPath, unsigned ConsumedLength=0)
 Inserts 'NewPath' into this trie.
 
StringRef findEquivalent (const PathComparator &Comparator, StringRef FileName, bool &IsAmbiguous, unsigned ConsumedLength=0) const
 Tries to find the node under this FileMatchTrieNode that best matches 'FileName'.
 

Detailed Description

A node of the FileMatchTrie.

Each node has storage for up to one path and a map mapping a path segment to child nodes. The trie starts with an empty root node.

Definition at line 43 of file FileMatchTrie.cpp.

Member Function Documentation

◆ findEquivalent()

StringRef clang::tooling::FileMatchTrieNode::findEquivalent ( const PathComparator Comparator,
StringRef  FileName,
bool IsAmbiguous,
unsigned  ConsumedLength = 0 
) const
inline

Tries to find the node under this FileMatchTrieNode that best matches 'FileName'.

If multiple paths fit 'FileName' equally well, IsAmbiguous is set to true and an empty string is returned. If no path fits 'FileName', an empty string is returned. ConsumedLength denotes the number of Filename's trailing characters already consumed during recursion.

To find the best matching node for a given path 'p', the findEquivalent() function is called recursively for each path segment (back to front) of 'p' until a node 'n' is reached that does not ..

  • .. have children. In this case it is checked whether the stored path is equivalent to 'p'. If yes, the best match is found. Otherwise continue with the parent node as if this node did not exist.
  • .. a child matching the next path segment. In this case, all children of 'n' are an equally good match for 'p'. All children are of 'n' are found recursively and their equivalence to 'p' is determined. If none are equivalent, continue with the parent node as if 'n' didn't exist. If one is equivalent, the best match is found. Otherwise, report and ambigiuity error.

Definition at line 104 of file FileMatchTrie.cpp.

References clang::tooling::PathComparator::equivalent(), clang::FileName, and clang::Result.

Referenced by clang::tooling::FileMatchTrie::findEquivalent().

◆ insert()

void clang::tooling::FileMatchTrieNode::insert ( StringRef  NewPath,
unsigned  ConsumedLength = 0 
)
inline

Inserts 'NewPath' into this trie.

ConsumedLength denotes the number of NewPath's trailing characters already consumed during recursion.

An insert of a path 'p'starts at the root node and does the following:

  • If the node is empty, insert 'p' into its storage and abort.
  • If the node has a path 'p2' but no children, take the last path segment 's' of 'p2', put a new child into the map at 's' an insert the rest of 'p2' there.
  • Insert a new child for the last segment of 'p' and insert the rest of 'p' there.

An insert operation is linear in the number of a path's segments.

Definition at line 59 of file FileMatchTrie.cpp.

Referenced by clang::tooling::FileMatchTrie::insert().


The documentation for this class was generated from the following file: