Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:36:54

0001 //===- ExtractAPI/APIIgnoresList.h ---------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 ///
0009 /// \file This file defines APIIgnoresList which is a type that allows querying
0010 /// files containing symbols to ignore when extracting API information.
0011 ///
0012 //===----------------------------------------------------------------------===//
0013 
0014 #ifndef LLVM_CLANG_API_IGNORES_LIST_H
0015 #define LLVM_CLANG_API_IGNORES_LIST_H
0016 
0017 #include "clang/Basic/FileManager.h"
0018 #include "llvm/ADT/SmallVector.h"
0019 #include "llvm/ADT/StringRef.h"
0020 #include "llvm/Support/Error.h"
0021 #include "llvm/Support/raw_ostream.h"
0022 
0023 #include <memory>
0024 #include <system_error>
0025 
0026 namespace llvm {
0027 class MemoryBuffer;
0028 } // namespace llvm
0029 
0030 namespace clang {
0031 namespace extractapi {
0032 
0033 struct IgnoresFileNotFound : public llvm::ErrorInfo<IgnoresFileNotFound> {
0034   std::string Path;
0035   static char ID;
0036 
0037   explicit IgnoresFileNotFound(StringRef Path) : Path(Path) {}
0038 
0039   virtual void log(llvm::raw_ostream &os) const override;
0040 
0041   virtual std::error_code convertToErrorCode() const override;
0042 };
0043 
0044 /// A type that provides access to a new line separated list of symbol names to
0045 /// ignore when extracting API information.
0046 struct APIIgnoresList {
0047   using FilePathList = std::vector<std::string>;
0048 
0049   /// The API to use for generating from the files at \p IgnoresFilePathList.
0050   ///
0051   /// \returns an initialized APIIgnoresList or an Error.
0052   static llvm::Expected<APIIgnoresList>
0053   create(const FilePathList &IgnoresFilePathList, FileManager &FM);
0054 
0055   APIIgnoresList() = default;
0056 
0057   /// Check if \p SymbolName is specified in the APIIgnoresList and if it should
0058   /// therefore be ignored.
0059   bool shouldIgnore(llvm::StringRef SymbolName) const;
0060 
0061 private:
0062   using SymbolNameList = llvm::SmallVector<llvm::StringRef, 32>;
0063   using BufferList = llvm::SmallVector<std::unique_ptr<llvm::MemoryBuffer>>;
0064 
0065   APIIgnoresList(SymbolNameList SymbolsToIgnore, BufferList Buffers)
0066       : SymbolsToIgnore(std::move(SymbolsToIgnore)),
0067         Buffers(std::move(Buffers)) {}
0068 
0069   SymbolNameList SymbolsToIgnore;
0070   BufferList Buffers;
0071 };
0072 
0073 } // namespace extractapi
0074 } // namespace clang
0075 
0076 #endif // LLVM_CLANG_API_IGNORES_LIST_H