//===- StringMatcher.cpp - Generate a matcher for input strings -----------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // This file implements the StringMatcher class. // //===----------------------------------------------------------------------===// #include "llvm/TableGen/StringMatcher.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/raw_ostream.h" #include <cassert> #include <map> #include <string> #include <utility> #include <vector> usingnamespacellvm; /// FindFirstNonCommonLetter - Find the first character in the keys of the /// string pairs that is not shared across the whole set of strings. All /// strings are assumed to have the same length. static unsigned FindFirstNonCommonLetter(const std::vector<const StringMatcher::StringPair*> &Matches) { … } /// EmitStringMatcherForChar - Given a set of strings that are known to be the /// same length and whose characters leading up to CharNo are the same, emit /// code to verify that CharNo and later are the same. /// /// \return - True if control can leave the emitted code fragment. bool StringMatcher::EmitStringMatcherForChar( const std::vector<const StringPair *> &Matches, unsigned CharNo, unsigned IndentCount, bool IgnoreDuplicates) const { … } /// Emit - Top level entry point. /// void StringMatcher::Emit(unsigned Indent, bool IgnoreDuplicates) const { … }