brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.0 KiB · b07b9ed Raw
54 lines · c
1//===--- IncludeSpeller.h - Spelling strategies for headers.-------- C++-*-===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8// An extension point to let applications introduce custom spelling9// strategies for physical headers.10//===----------------------------------------------------------------------===//11 12#ifndef CLANG_INCLUDE_CLEANER_INCLUDESPELLER_H13#define CLANG_INCLUDE_CLEANER_INCLUDESPELLER_H14 15#include "clang-include-cleaner/Types.h"16#include "clang/Lex/HeaderSearch.h"17#include "llvm/Support/Registry.h"18#include <string>19 20namespace clang::include_cleaner {21 22/// IncludeSpeller provides an extension point to allow clients implement23/// custom include spelling strategies for physical headers.24class IncludeSpeller {25public:26  /// Provides the necessary information for custom spelling computations.27  struct Input {28    const Header &H;29    const HeaderSearch &HS;30    const FileEntry *Main;31  };32  virtual ~IncludeSpeller() = default;33 34  /// Takes in an `Input` struct with necessary infos about a header and35  /// returns a verbatim include spelling (with angles/quotes) or an empty36  /// string to indicate no customizations are needed.37  virtual std::string operator()(const Input &Input) const = 0;38};39 40using IncludeSpellingStrategy = llvm::Registry<IncludeSpeller>;41 42/// Generates a spelling for the header in the `Input` that can be directly43/// included in the main file. When the `Input` specifies a physical header,44/// prefers the spelling provided by custom llvm strategies, if any.45/// Otherwise, uses header search info to generate shortest spelling.46std::string spellHeader(const IncludeSpeller::Input &Input);47} // namespace clang::include_cleaner48 49namespace llvm {50extern template class Registry<clang::include_cleaner::IncludeSpeller>;51} // namespace llvm52 53#endif54