1//===- SymbolRecordHelpers.h ------------------------------------*- C++ -*-===// 2// 3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4// See https://llvm.org/LICENSE.txt for license information. 5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6// 7//===----------------------------------------------------------------------===// 8 9#ifndef LLVM_DEBUGINFO_CODEVIEW_SYMBOLRECORDHELPERS_H 10#define LLVM_DEBUGINFO_CODEVIEW_SYMBOLRECORDHELPERS_H 11 12#include "llvm/DebugInfo/CodeView/SymbolRecord.h" 13 14namespace llvm { 15namespace codeview { 16/// Return true if this symbol opens a scope. This implies that the symbol has 17/// "parent" and "end" fields, which contain the offset of the S_END or 18/// S_INLINESITE_END record. 19inline bool symbolOpensScope(SymbolKind Kind) { 20 switch (Kind) { 21 case SymbolKind::S_GPROC32: 22 case SymbolKind::S_LPROC32: 23 case SymbolKind::S_LPROC32_ID: 24 case SymbolKind::S_GPROC32_ID: 25 case SymbolKind::S_BLOCK32: 26 case SymbolKind::S_SEPCODE: 27 case SymbolKind::S_THUNK32: 28 case SymbolKind::S_INLINESITE: 29 case SymbolKind::S_INLINESITE2: 30 return true; 31 default: 32 break; 33 } 34 return false; 35} 36 37/// Return true if this ssymbol ends a scope. 38inline bool symbolEndsScope(SymbolKind Kind) { 39 switch (Kind) { 40 case SymbolKind::S_END: 41 case SymbolKind::S_PROC_ID_END: 42 case SymbolKind::S_INLINESITE_END: 43 return true; 44 default: 45 break; 46 } 47 return false; 48} 49 50/// Given a symbol P for which symbolOpensScope(P) == true, return the 51/// corresponding end offset. 52uint32_t getScopeEndOffset(const CVSymbol &Symbol); 53uint32_t getScopeParentOffset(const CVSymbol &Symbol); 54 55CVSymbolArray limitSymbolArrayToScope(const CVSymbolArray &Symbols, 56 uint32_t ScopeBegin); 57 58} // namespace codeview 59} // namespace llvm 60 61#endif 62