blob: efc924507df0b73bcee1c7fefb30bf6196081c9f [file] [log] [blame]
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001//===- Strings.h ------------------------------------------------*- C++ -*-===//
2//
Andrew Walbran16937d02019-10-22 13:54:20 +01003// 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
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLD_STRINGS_H
10#define LLD_STRINGS_H
11
12#include "llvm/ADT/ArrayRef.h"
13#include "llvm/ADT/Optional.h"
14#include "llvm/ADT/StringRef.h"
15#include "llvm/Support/GlobPattern.h"
16#include <string>
17#include <vector>
18
19namespace lld {
20// Returns a demangled C++ symbol name. If Name is not a mangled
21// name, it returns Optional::None.
22llvm::Optional<std::string> demangleItanium(llvm::StringRef Name);
23llvm::Optional<std::string> demangleMSVC(llvm::StringRef S);
24
25std::vector<uint8_t> parseHex(llvm::StringRef S);
26bool isValidCIdentifier(llvm::StringRef S);
27
Andrew Scullcdfcccc2018-10-05 20:58:37 +010028// Write the contents of the a buffer to a file
29void saveBuffer(llvm::StringRef Buffer, const llvm::Twine &Path);
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010030
31// This class represents multiple glob patterns.
32class StringMatcher {
33public:
34 StringMatcher() = default;
35 explicit StringMatcher(llvm::ArrayRef<llvm::StringRef> Pat);
36
37 bool match(llvm::StringRef S) const;
38
39private:
40 std::vector<llvm::GlobPattern> Patterns;
41};
42
Andrew Scullcdfcccc2018-10-05 20:58:37 +010043} // namespace lld
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010044
45#endif