clang-tools 8.0.0

HeaderMapCollector.cpp
Go to the documentation of this file.
1 //===-- HeaderMapCoolector.h - find all symbols------------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #include "HeaderMapCollector.h"
11 #include "llvm/Support/Regex.h"
12
13 namespace clang {
14 namespace find_all_symbols {
15
16 HeaderMapCollector::HeaderMapCollector(
17 const RegexHeaderMap *RegexHeaderMappingTable) {
18 assert(RegexHeaderMappingTable);
19 this->RegexHeaderMappingTable.reserve(RegexHeaderMappingTable->size());
20 for (const auto &Entry : *RegexHeaderMappingTable) {
21 this->RegexHeaderMappingTable.emplace_back(llvm::Regex(Entry.first),
22 Entry.second);
23 }
24 }
25
26 llvm::StringRef
27 HeaderMapCollector::getMappedHeader(llvm::StringRef Header) const {
28 auto Iter = HeaderMappingTable.find(Header);
29 if (Iter != HeaderMappingTable.end())
30 return Iter->second;
31 // If there is no complete header name mapping for this header, check the
32 // regex header mapping.
33 for (auto &Entry : RegexHeaderMappingTable) {
34 #ifndef NDEBUG
35 std::string Dummy;
36 assert(Entry.first.isValid(Dummy) && "Regex should never be invalid!");
37 #endif
38 if (Entry.first.match(Header))
39 return Entry.second;
40 }
41 return Header;
42 }
43
44 } // namespace find_all_symbols
45 } // namespace clang
HeaderMapCollector.h
clang::find_all_symbols::HeaderMapCollector::RegexHeaderMap
std::vector< std::pair< const char *, const char * > > RegexHeaderMap
Definition: HeaderMapCollector.h:26
clang::find_all_symbols::HeaderMapCollector::getMappedHeader
llvm::StringRef getMappedHeader(llvm::StringRef Header) const
Check if there is a mapping from Header or a regex pattern that matches it to another header name...
Definition: HeaderMapCollector.cpp:27
clang::find_all_symbols::HeaderMapCollector::HeaderMapCollector
HeaderMapCollector()=default
clang
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Definition: ChangeNamespace.cpp:18
Entry
Definition: Modularize.cpp:430