APIIgnoresList.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- ExtractAPI/APIIgnoresList.h ---------------*- C++ -*-===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. ///
  14. /// \file This file defines APIIgnoresList which is a type that allows querying
  15. /// a file containing symbols to ignore when extracting API information.
  16. ///
  17. //===----------------------------------------------------------------------===//
  18. #ifndef LLVM_CLANG_API_IGNORES_LIST_H
  19. #define LLVM_CLANG_API_IGNORES_LIST_H
  20. #include "clang/Basic/FileManager.h"
  21. #include "llvm/ADT/SmallVector.h"
  22. #include "llvm/ADT/StringRef.h"
  23. #include "llvm/Support/Error.h"
  24. #include "llvm/Support/raw_ostream.h"
  25. #include <memory>
  26. #include <system_error>
  27. namespace llvm {
  28. class MemoryBuffer;
  29. } // namespace llvm
  30. namespace clang {
  31. namespace extractapi {
  32. struct IgnoresFileNotFound : public llvm::ErrorInfo<IgnoresFileNotFound> {
  33. std::string Path;
  34. static char ID;
  35. explicit IgnoresFileNotFound(StringRef Path) : Path(Path) {}
  36. virtual void log(llvm::raw_ostream &os) const override;
  37. virtual std::error_code convertToErrorCode() const override;
  38. };
  39. /// A type that provides access to a new line separated list of symbol names to
  40. /// ignore when extracting API information.
  41. struct APIIgnoresList {
  42. /// The API to use for generating from the file at \p IgnoresFilePath.
  43. ///
  44. /// \returns an initialized APIIgnoresList or an Error.
  45. static llvm::Expected<APIIgnoresList> create(llvm::StringRef IgnoresFilePath,
  46. FileManager &FM);
  47. APIIgnoresList() = default;
  48. /// Check if \p SymbolName is specified in the APIIgnoresList and if it should
  49. /// therefore be ignored.
  50. bool shouldIgnore(llvm::StringRef SymbolName) const;
  51. private:
  52. using SymbolNameList = llvm::SmallVector<llvm::StringRef, 32>;
  53. APIIgnoresList(SymbolNameList SymbolsToIgnore,
  54. std::unique_ptr<llvm::MemoryBuffer> Buffer)
  55. : SymbolsToIgnore(std::move(SymbolsToIgnore)), Buffer(std::move(Buffer)) {
  56. }
  57. SymbolNameList SymbolsToIgnore;
  58. std::unique_ptr<llvm::MemoryBuffer> Buffer;
  59. };
  60. } // namespace extractapi
  61. } // namespace clang
  62. #endif // LLVM_CLANG_API_IGNORES_LIST_H
  63. #ifdef __GNUC__
  64. #pragma GCC diagnostic pop
  65. #endif