Jonas Devlieghere | 20767d1 | 2019-01-07 23:27:25 +0000 | [diff] [blame] | 1 | //=- tools/dsymutil/SymbolMap.h -----------------------------------*- 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 | #ifndef LLVM_TOOLS_DSYMUTIL_SYMBOLMAP_H |
| 11 | #define LLVM_TOOLS_DSYMUTIL_SYMBOLMAP_H |
| 12 | |
| 13 | #include "llvm/ADT/StringRef.h" |
| 14 | |
| 15 | #include <string> |
| 16 | #include <vector> |
| 17 | |
| 18 | namespace llvm { |
| 19 | namespace dsymutil { |
| 20 | class DebugMap; |
| 21 | |
| 22 | /// Callable class to unobfuscate strings based on a BCSymbolMap. |
| 23 | class SymbolMapTranslator { |
| 24 | public: |
| 25 | SymbolMapTranslator() : MangleNames(false) {} |
| 26 | |
| 27 | SymbolMapTranslator(std::vector<std::string> UnobfuscatedStrings, |
| 28 | bool MangleNames) |
| 29 | : UnobfuscatedStrings(std::move(UnobfuscatedStrings)), |
| 30 | MangleNames(MangleNames) {} |
| 31 | |
| 32 | StringRef operator()(StringRef Input); |
| 33 | |
| 34 | operator bool() const { return !UnobfuscatedStrings.empty(); } |
| 35 | |
| 36 | private: |
| 37 | std::vector<std::string> UnobfuscatedStrings; |
| 38 | bool MangleNames; |
| 39 | }; |
| 40 | |
| 41 | /// Class to initialize SymbolMapTranslators from a BCSymbolMap. |
| 42 | class SymbolMapLoader { |
| 43 | public: |
| 44 | SymbolMapLoader(std::string SymbolMap) : SymbolMap(std::move(SymbolMap)) {} |
| 45 | |
| 46 | SymbolMapTranslator Load(StringRef InputFile, const DebugMap &Map) const; |
| 47 | |
| 48 | private: |
| 49 | const std::string SymbolMap; |
| 50 | }; |
| 51 | } // namespace dsymutil |
| 52 | } // namespace llvm |
| 53 | |
| 54 | #endif // LLVM_TOOLS_DSYMUTIL_SYMBOLMAP_H |