| 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/CVRecord.h" |
| 13 | #include "llvm/DebugInfo/CodeView/CodeView.h" |
| 14 | #include "llvm/Support/Compiler.h" |
| 15 | |
| 16 | namespace llvm { |
| 17 | namespace codeview { |
| 18 | /// Return true if this symbol opens a scope. This implies that the symbol has |
| 19 | /// "parent" and "end" fields, which contain the offset of the S_END or |
| 20 | /// S_INLINESITE_END record. |
| 21 | inline bool symbolOpensScope(SymbolKind Kind) { |
| 22 | switch (Kind) { |
| 23 | case SymbolKind::S_GPROC32: |
| 24 | case SymbolKind::S_LPROC32: |
| 25 | case SymbolKind::S_LPROC32_ID: |
| 26 | case SymbolKind::S_GPROC32_ID: |
| 27 | case SymbolKind::S_BLOCK32: |
| 28 | case SymbolKind::S_SEPCODE: |
| 29 | case SymbolKind::S_THUNK32: |
| 30 | case SymbolKind::S_INLINESITE: |
| 31 | case SymbolKind::S_INLINESITE2: |
| 32 | return true; |
| 33 | default: |
| 34 | break; |
| 35 | } |
| 36 | return false; |
| 37 | } |
| 38 | |
| 39 | /// Return true if this ssymbol ends a scope. |
| 40 | inline bool symbolEndsScope(SymbolKind Kind) { |
| 41 | switch (Kind) { |
| 42 | case SymbolKind::S_END: |
| 43 | case SymbolKind::S_PROC_ID_END: |
| 44 | case SymbolKind::S_INLINESITE_END: |
| 45 | return true; |
| 46 | default: |
| 47 | break; |
| 48 | } |
| 49 | return false; |
| 50 | } |
| 51 | |
| 52 | /// Given a symbol P for which symbolOpensScope(P) == true, return the |
| 53 | /// corresponding end offset. |
| 54 | LLVM_ABI uint32_t getScopeEndOffset(const CVSymbol &Symbol); |
| 55 | LLVM_ABI uint32_t getScopeParentOffset(const CVSymbol &Symbol); |
| 56 | |
| 57 | LLVM_ABI CVSymbolArray limitSymbolArrayToScope(const CVSymbolArray &Symbols, |
| 58 | uint32_t ScopeBegin); |
| 59 | |
| 60 | } // namespace codeview |
| 61 | } // namespace llvm |
| 62 | |
| 63 | #endif |
| 64 |