Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 14 | pmbaty | 1 | //===- ExtractAPI/APIIgnoresList.h ---------------*- 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-exception |
||
| 6 | // |
||
| 7 | //===----------------------------------------------------------------------===// |
||
| 8 | /// |
||
| 9 | /// \file This file defines APIIgnoresList which is a type that allows querying |
||
| 10 | /// a file containing symbols to ignore when extracting API information. |
||
| 11 | /// |
||
| 12 | //===----------------------------------------------------------------------===// |
||
| 13 | |||
| 14 | #ifndef LLVM_CLANG_API_IGNORES_LIST_H |
||
| 15 | #define LLVM_CLANG_API_IGNORES_LIST_H |
||
| 16 | |||
| 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" |
||
| 22 | |||
| 23 | #include <memory> |
||
| 24 | #include <system_error> |
||
| 25 | |||
| 26 | namespace llvm { |
||
| 27 | class MemoryBuffer; |
||
| 28 | } // namespace llvm |
||
| 29 | |||
| 30 | namespace clang { |
||
| 31 | namespace extractapi { |
||
| 32 | |||
| 33 | struct IgnoresFileNotFound : public llvm::ErrorInfo<IgnoresFileNotFound> { |
||
| 34 | std::string Path; |
||
| 35 | static char ID; |
||
| 36 | |||
| 37 | explicit IgnoresFileNotFound(StringRef Path) : Path(Path) {} |
||
| 38 | |||
| 39 | virtual void log(llvm::raw_ostream &os) const override; |
||
| 40 | |||
| 41 | virtual std::error_code convertToErrorCode() const override; |
||
| 42 | }; |
||
| 43 | |||
| 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 | /// The API to use for generating from the file at \p IgnoresFilePath. |
||
| 48 | /// |
||
| 49 | /// \returns an initialized APIIgnoresList or an Error. |
||
| 50 | static llvm::Expected<APIIgnoresList> create(llvm::StringRef IgnoresFilePath, |
||
| 51 | FileManager &FM); |
||
| 52 | |||
| 53 | APIIgnoresList() = default; |
||
| 54 | |||
| 55 | /// Check if \p SymbolName is specified in the APIIgnoresList and if it should |
||
| 56 | /// therefore be ignored. |
||
| 57 | bool shouldIgnore(llvm::StringRef SymbolName) const; |
||
| 58 | |||
| 59 | private: |
||
| 60 | using SymbolNameList = llvm::SmallVector<llvm::StringRef, 32>; |
||
| 61 | |||
| 62 | APIIgnoresList(SymbolNameList SymbolsToIgnore, |
||
| 63 | std::unique_ptr<llvm::MemoryBuffer> Buffer) |
||
| 64 | : SymbolsToIgnore(std::move(SymbolsToIgnore)), Buffer(std::move(Buffer)) { |
||
| 65 | } |
||
| 66 | |||
| 67 | SymbolNameList SymbolsToIgnore; |
||
| 68 | std::unique_ptr<llvm::MemoryBuffer> Buffer; |
||
| 69 | }; |
||
| 70 | |||
| 71 | } // namespace extractapi |
||
| 72 | } // namespace clang |
||
| 73 | |||
| 74 | #endif // LLVM_CLANG_API_IGNORES_LIST_H |