Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:43:45

0001 //===- TpiHashing.h ---------------------------------------------*- 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 #ifndef LLVM_DEBUGINFO_PDB_NATIVE_TPIHASHING_H
0010 #define LLVM_DEBUGINFO_PDB_NATIVE_TPIHASHING_H
0011 
0012 #include "llvm/DebugInfo/CodeView/TypeRecord.h"
0013 #include "llvm/Support/Error.h"
0014 
0015 namespace llvm {
0016 namespace pdb {
0017 
0018 Expected<uint32_t> hashTypeRecord(const llvm::codeview::CVType &Type);
0019 
0020 struct TagRecordHash {
0021   explicit TagRecordHash(codeview::ClassRecord CR, uint32_t Full,
0022                          uint32_t Forward)
0023       : FullRecordHash(Full), ForwardDeclHash(Forward), Class(std::move(CR)) {
0024     State = 0;
0025   }
0026 
0027   explicit TagRecordHash(codeview::EnumRecord ER, uint32_t Full,
0028                          uint32_t Forward)
0029       : FullRecordHash(Full), ForwardDeclHash(Forward), Enum(std::move(ER)) {
0030     State = 1;
0031   }
0032 
0033   explicit TagRecordHash(codeview::UnionRecord UR, uint32_t Full,
0034                          uint32_t Forward)
0035       : FullRecordHash(Full), ForwardDeclHash(Forward), Union(std::move(UR)) {
0036     State = 2;
0037   }
0038 
0039   uint32_t FullRecordHash;
0040   uint32_t ForwardDeclHash;
0041 
0042   codeview::TagRecord &getRecord() {
0043     switch (State) {
0044     case 0:
0045       return Class;
0046     case 1:
0047       return Enum;
0048     case 2:
0049       return Union;
0050     }
0051     llvm_unreachable("unreachable!");
0052   }
0053 
0054 private:
0055   union {
0056     codeview::ClassRecord Class;
0057     codeview::EnumRecord Enum;
0058     codeview::UnionRecord Union;
0059   };
0060 
0061   uint8_t State = 0;
0062 };
0063 
0064 /// Given a CVType referring to a class, structure, union, or enum, compute
0065 /// the hash of its forward decl and full decl.
0066 Expected<TagRecordHash> hashTagRecord(const codeview::CVType &Type);
0067 
0068 } // end namespace pdb
0069 } // end namespace llvm
0070 
0071 #endif // LLVM_DEBUGINFO_PDB_NATIVE_TPIHASHING_H