1 | //===-- HeaderMapCoolector.h - find all symbols------------------*- 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 | #ifndef LLVM_CLANG_TOOLS_EXTRA_FIND_ALL_SYMBOLS_HEADER_MAP_COLLECTOR_H |
10 | #define |
11 | |
12 | #include "llvm/ADT/StringMap.h" |
13 | #include "llvm/Support/Regex.h" |
14 | #include <string> |
15 | #include <vector> |
16 | |
17 | namespace clang { |
18 | namespace find_all_symbols { |
19 | |
20 | /// HeaderMappCollector collects all remapping header files. This maps |
21 | /// complete header names or header name regex patterns to header names. |
22 | class { |
23 | public: |
24 | typedef llvm::StringMap<std::string> ; |
25 | typedef std::vector<std::pair<const char *, const char *>> ; |
26 | |
27 | () = default; |
28 | explicit (const RegexHeaderMap *); |
29 | |
30 | void (llvm::StringRef , |
31 | llvm::StringRef ) { |
32 | HeaderMappingTable[OrignalHeaderPath] = std::string(MappingHeaderPath); |
33 | }; |
34 | |
35 | /// Check if there is a mapping from \p Header or a regex pattern that matches |
36 | /// it to another header name. |
37 | /// \param Header A header name. |
38 | /// \return \p Header itself if there is no mapping for it; otherwise, return |
39 | /// a mapped header name. |
40 | llvm::StringRef (llvm::StringRef ) const; |
41 | |
42 | private: |
43 | /// A string-to-string map saving the mapping relationship. |
44 | HeaderMap ; |
45 | |
46 | // A map from header patterns to header names. |
47 | // The header names are not owned. This is only threadsafe because the regexes |
48 | // never fail. |
49 | mutable std::vector<std::pair<llvm::Regex, const char *>> |
50 | ; |
51 | }; |
52 | |
53 | } // namespace find_all_symbols |
54 | } // namespace clang |
55 | |
56 | #endif // LLVM_CLANG_TOOLS_EXTRA_FIND_ALL_SYMBOLS_HEADER_MAP_COLLECTOR_H |
57 | |