2016-05-18 00:48:49 +08:00
|
|
|
//===-- HeaderMapCoolector.h - find all symbols------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_CLANG_TOOLS_EXTRA_FIND_ALL_SYMBOLS_HEADER_MAP_COLLECTOR_H
|
|
|
|
#define LLVM_CLANG_TOOLS_EXTRA_FIND_ALL_SYMBOLS_HEADER_MAP_COLLECTOR_H
|
|
|
|
|
|
|
|
#include "llvm/ADT/StringMap.h"
|
2016-07-04 19:22:35 +08:00
|
|
|
#include "llvm/Support/Regex.h"
|
2016-05-18 00:48:49 +08:00
|
|
|
#include <string>
|
2016-07-04 19:42:37 +08:00
|
|
|
#include <vector>
|
2016-05-18 00:48:49 +08:00
|
|
|
|
|
|
|
namespace clang {
|
|
|
|
namespace find_all_symbols {
|
|
|
|
|
2016-05-24 23:10:58 +08:00
|
|
|
/// \brief HeaderMappCollector collects all remapping header files. This maps
|
2016-07-04 19:22:35 +08:00
|
|
|
/// complete header names or header name regex patterns to header names.
|
2016-05-18 00:48:49 +08:00
|
|
|
class HeaderMapCollector {
|
|
|
|
public:
|
|
|
|
typedef llvm::StringMap<std::string> HeaderMap;
|
2016-07-04 21:34:11 +08:00
|
|
|
typedef std::vector<std::pair<const char *, const char *>> RegexHeaderMap;
|
2016-05-18 00:48:49 +08:00
|
|
|
|
2016-07-04 19:22:35 +08:00
|
|
|
HeaderMapCollector() : RegexHeaderMappingTable(nullptr) {}
|
2016-05-24 23:10:58 +08:00
|
|
|
|
2016-07-04 19:22:35 +08:00
|
|
|
explicit HeaderMapCollector(const RegexHeaderMap *RegexHeaderMappingTable)
|
|
|
|
: RegexHeaderMappingTable(RegexHeaderMappingTable) {}
|
2016-05-24 23:10:58 +08:00
|
|
|
|
2016-05-18 00:48:49 +08:00
|
|
|
void addHeaderMapping(llvm::StringRef OrignalHeaderPath,
|
|
|
|
llvm::StringRef MappingHeaderPath) {
|
|
|
|
HeaderMappingTable[OrignalHeaderPath] = MappingHeaderPath;
|
|
|
|
};
|
2016-05-24 23:10:58 +08:00
|
|
|
|
2016-07-04 19:22:35 +08:00
|
|
|
/// Check if there is a mapping from \p Header or a regex pattern that matches
|
|
|
|
/// it to another header name.
|
2016-05-24 23:10:58 +08:00
|
|
|
/// \param Header A header name.
|
|
|
|
/// \return \p Header itself if there is no mapping for it; otherwise, return
|
|
|
|
/// a mapped header name.
|
|
|
|
llvm::StringRef getMappedHeader(llvm::StringRef Header) const;
|
2016-05-18 00:48:49 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
/// A string-to-string map saving the mapping relationship.
|
|
|
|
HeaderMap HeaderMappingTable;
|
2016-05-24 23:10:58 +08:00
|
|
|
|
2016-07-04 19:22:35 +08:00
|
|
|
// A map from header patterns to header names.
|
2016-05-24 23:10:58 +08:00
|
|
|
// This is a reference to a hard-coded map.
|
2016-07-04 19:22:35 +08:00
|
|
|
const RegexHeaderMap *const RegexHeaderMappingTable;
|
2016-05-18 00:48:49 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace find_all_symbols
|
|
|
|
} // namespace clang
|
|
|
|
|
|
|
|
#endif // LLVM_CLANG_TOOLS_EXTRA_FIND_ALL_SYMBOLS_HEADER_MAP_COLLECTOR_H
|