Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 1 | //===- Strings.h ------------------------------------------------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Linker |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #ifndef LLD_STRINGS_H |
| 11 | #define LLD_STRINGS_H |
| 12 | |
| 13 | #include "llvm/ADT/ArrayRef.h" |
| 14 | #include "llvm/ADT/Optional.h" |
| 15 | #include "llvm/ADT/StringRef.h" |
| 16 | #include "llvm/Support/GlobPattern.h" |
| 17 | #include <string> |
| 18 | #include <vector> |
| 19 | |
| 20 | namespace lld { |
| 21 | // Returns a demangled C++ symbol name. If Name is not a mangled |
| 22 | // name, it returns Optional::None. |
| 23 | llvm::Optional<std::string> demangleItanium(llvm::StringRef Name); |
| 24 | llvm::Optional<std::string> demangleMSVC(llvm::StringRef S); |
| 25 | |
| 26 | std::vector<uint8_t> parseHex(llvm::StringRef S); |
| 27 | bool isValidCIdentifier(llvm::StringRef S); |
| 28 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame^] | 29 | // Write the contents of the a buffer to a file |
| 30 | void saveBuffer(llvm::StringRef Buffer, const llvm::Twine &Path); |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 31 | |
| 32 | // This class represents multiple glob patterns. |
| 33 | class StringMatcher { |
| 34 | public: |
| 35 | StringMatcher() = default; |
| 36 | explicit StringMatcher(llvm::ArrayRef<llvm::StringRef> Pat); |
| 37 | |
| 38 | bool match(llvm::StringRef S) const; |
| 39 | |
| 40 | private: |
| 41 | std::vector<llvm::GlobPattern> Patterns; |
| 42 | }; |
| 43 | |
| 44 | inline llvm::ArrayRef<uint8_t> toArrayRef(llvm::StringRef S) { |
| 45 | return {reinterpret_cast<const uint8_t *>(S.data()), S.size()}; |
| 46 | } |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame^] | 47 | } // namespace lld |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 48 | |
| 49 | #endif |