1 //===- ExtractAPI/APIIgnoresList.h ---------------*- C++ -*-===//
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-exception
7 //===----------------------------------------------------------------------===//
9 /// \file This file defines APIIgnoresList which is a type that allows querying
10 /// files containing symbols to ignore when extracting API information.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_CLANG_API_IGNORES_LIST_H
15 #define LLVM_CLANG_API_IGNORES_LIST_H
17 #include "clang/Basic/FileManager.h"
18 #include "llvm/ADT/SmallVector.h"
19 #include "llvm/ADT/StringRef.h"
20 #include "llvm/Support/Error.h"
21 #include "llvm/Support/raw_ostream.h"
24 #include <system_error>
31 namespace extractapi {
33 struct IgnoresFileNotFound : public llvm::ErrorInfo<IgnoresFileNotFound> {
37 explicit IgnoresFileNotFound(StringRef Path) : Path(Path) {}
39 virtual void log(llvm::raw_ostream &os) const override;
41 virtual std::error_code convertToErrorCode() const override;
44 /// A type that provides access to a new line separated list of symbol names to
45 /// ignore when extracting API information.
46 struct APIIgnoresList {
47 using FilePathList = std::vector<std::string>;
49 /// The API to use for generating from the files at \p IgnoresFilePathList.
51 /// \returns an initialized APIIgnoresList or an Error.
52 static llvm::Expected<APIIgnoresList>
53 create(const FilePathList &IgnoresFilePathList, FileManager &FM);
55 APIIgnoresList() = default;
57 /// Check if \p SymbolName is specified in the APIIgnoresList and if it should
58 /// therefore be ignored.
59 bool shouldIgnore(llvm::StringRef SymbolName) const;
62 using SymbolNameList = llvm::SmallVector<llvm::StringRef, 32>;
63 using BufferList = llvm::SmallVector<std::unique_ptr<llvm::MemoryBuffer>>;
65 APIIgnoresList(SymbolNameList SymbolsToIgnore, BufferList Buffers)
66 : SymbolsToIgnore(std::move(SymbolsToIgnore)),
67 Buffers(std::move(Buffers)) {}
69 SymbolNameList SymbolsToIgnore;
73 } // namespace extractapi
76 #endif // LLVM_CLANG_API_IGNORES_LIST_H