class FileMatchTrieNode

Declaration

class FileMatchTrieNode { /* full declaration omitted */ };

Description

A node of the \c 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.

Declared at: clang/lib/Tooling/FileMatchTrie.cpp:43

Member Variables

private std::string Path
private llvm::StringMap<FileMatchTrieNode> Children

Method Overview

  • public llvm::StringRef findEquivalent(const clang::tooling::PathComparator & Comparator, llvm::StringRef FileName, bool & IsAmbiguous, unsigned int ConsumedLength = 0) const
  • private void getAll(std::vector<StringRef> & Results, llvm::StringMap<FileMatchTrieNode>::const_iterator Except) const
  • public void insert(llvm::StringRef NewPath, unsigned int ConsumedLength = 0)

Methods

llvm::StringRef findEquivalent(
    const clang::tooling::PathComparator&
        Comparator,
    llvm::StringRef FileName,
    bool& IsAmbiguous,
    unsigned int ConsumedLength = 0) const

Description

Tries to find the node under this \c FileMatchTrieNode that best matches 'FileName'. If multiple paths fit 'FileName' equally well, \c IsAmbiguous is set to\c true and an empty string is returned. If no path fits 'FileName', an empty string is returned. \c ConsumedLength denotes the number of\c Filename's trailing characters already consumed during recursion. To find the best matching node for a given path 'p', the\c 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.

Declared at: clang/lib/Tooling/FileMatchTrie.cpp:104

Parameters

const clang::tooling::PathComparator& Comparator
llvm::StringRef FileName
bool& IsAmbiguous
unsigned int ConsumedLength = 0

void getAll(std::vector<StringRef>& Results,
            llvm::StringMap<FileMatchTrieNode>::
                const_iterator Except) const

Description

Gets all paths under this FileMatchTrieNode.

Declared at: clang/lib/Tooling/FileMatchTrie.cpp:154

Parameters

std::vector<StringRef>& Results
llvm::StringMap<FileMatchTrieNode>::const_iterator Except

void insert(llvm::StringRef NewPath,
            unsigned int ConsumedLength = 0)

Description

Inserts 'NewPath' into this trie. \c ConsumedLength denotes the number of \c 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.

Declared at: clang/lib/Tooling/FileMatchTrie.cpp:59

Parameters

llvm::StringRef NewPath
unsigned int ConsumedLength = 0