|
|
|||
File indexing completed on 2026-05-10 08:44:25
0001 //===-- RemarkStringTable.h - Serializing string table ----------*- C++/-*-===// 0002 // 0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 0004 // See https://llvm.org/LICENSE.txt for license information. 0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 0006 // 0007 //===----------------------------------------------------------------------===// 0008 // 0009 // This class is used to deduplicate and serialize a string table used for 0010 // generating remarks. 0011 // 0012 // For parsing a string table, use ParsedStringTable in RemarkParser.h 0013 // 0014 //===----------------------------------------------------------------------===// 0015 0016 #ifndef LLVM_REMARKS_REMARKSTRINGTABLE_H 0017 #define LLVM_REMARKS_REMARKSTRINGTABLE_H 0018 0019 #include "llvm/ADT/StringMap.h" 0020 #include "llvm/Support/Allocator.h" 0021 #include <vector> 0022 0023 namespace llvm { 0024 0025 class raw_ostream; 0026 class StringRef; 0027 0028 namespace remarks { 0029 0030 struct ParsedStringTable; 0031 struct Remark; 0032 0033 /// The string table used for serializing remarks. 0034 /// This table can be for example serialized in a section to be consumed after 0035 /// the compilation. 0036 struct StringTable { 0037 /// The string table containing all the unique strings used in the output. 0038 /// It maps a string to an unique ID. 0039 StringMap<unsigned, BumpPtrAllocator> StrTab; 0040 /// Total size of the string table when serialized. 0041 size_t SerializedSize = 0; 0042 0043 StringTable() = default; 0044 0045 /// Disable copy. 0046 StringTable(const StringTable &) = delete; 0047 StringTable &operator=(const StringTable &) = delete; 0048 /// Should be movable. 0049 StringTable(StringTable &&) = default; 0050 StringTable &operator=(StringTable &&) = default; 0051 0052 /// Construct a string table from a ParsedStringTable. 0053 StringTable(const ParsedStringTable &Other); 0054 0055 /// Add a string to the table. It returns an unique ID of the string. 0056 std::pair<unsigned, StringRef> add(StringRef Str); 0057 /// Modify \p R to use strings from this string table. If the string table 0058 /// does not contain the strings, it adds them. 0059 void internalize(Remark &R); 0060 /// Serialize the string table to a stream. It is serialized as a little 0061 /// endian uint64 (the size of the table in bytes) followed by a sequence of 0062 /// NULL-terminated strings, where the N-th string is the string with the ID N 0063 /// in the StrTab map. 0064 void serialize(raw_ostream &OS) const; 0065 /// Serialize the string table to a vector. This allows users to do the actual 0066 /// writing to file/memory/other. 0067 /// The string with the ID == N should be the N-th element in the vector. 0068 std::vector<StringRef> serialize() const; 0069 }; 0070 0071 } // end namespace remarks 0072 } // end namespace llvm 0073 0074 #endif // LLVM_REMARKS_REMARKSTRINGTABLE_H
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|