1 //===- Line.h ---------------------------------------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_DEBUGINFO_CODEVIEW_LINE_H
10 #define LLVM_DEBUGINFO_CODEVIEW_LINE_H
12 #include "llvm/DebugInfo/CodeView/TypeIndex.h"
13 #include "llvm/Support/Endian.h"
19 using llvm::support::ulittle32_t
;
24 AlwaysStepIntoLineNumber
= 0xfeefee,
25 NeverStepIntoLineNumber
= 0xf00f00
28 enum : int { EndLineDeltaShift
= 24 };
31 StartLineMask
= 0x00ffffff,
32 EndLineDeltaMask
= 0x7f000000,
33 StatementFlag
= 0x80000000u
36 LineInfo(uint32_t StartLine
, uint32_t EndLine
, bool IsStatement
);
37 LineInfo(uint32_t LineData
) : LineData(LineData
) {}
39 uint32_t getStartLine() const { return LineData
& StartLineMask
; }
41 uint32_t getLineDelta() const {
42 return (LineData
& EndLineDeltaMask
) >> EndLineDeltaShift
;
45 uint32_t getEndLine() const { return getStartLine() + getLineDelta(); }
47 bool isStatement() const { return (LineData
& StatementFlag
) != 0; }
49 uint32_t getRawData() const { return LineData
; }
51 bool isAlwaysStepInto() const {
52 return getStartLine() == AlwaysStepIntoLineNumber
;
55 bool isNeverStepInto() const {
56 return getStartLine() == NeverStepIntoLineNumber
;
65 static const uint32_t StartColumnMask
= 0x0000ffffu
;
66 static const uint32_t EndColumnMask
= 0xffff0000u
;
67 static const int EndColumnShift
= 16;
70 ColumnInfo(uint16_t StartColumn
, uint16_t EndColumn
) {
72 (static_cast<uint32_t>(StartColumn
) & StartColumnMask
) |
73 ((static_cast<uint32_t>(EndColumn
) << EndColumnShift
) & EndColumnMask
);
76 uint16_t getStartColumn() const {
77 return static_cast<uint16_t>(ColumnData
& StartColumnMask
);
80 uint16_t getEndColumn() const {
81 return static_cast<uint16_t>((ColumnData
& EndColumnMask
) >>
85 uint32_t getRawData() const { return ColumnData
; }
98 Line(int32_t CodeOffset
, uint32_t StartLine
, uint32_t EndLine
,
99 uint16_t StartColumn
, uint16_t EndColumn
, bool IsStatement
)
100 : CodeOffset(CodeOffset
), LineInf(StartLine
, EndLine
, IsStatement
),
101 ColumnInf(StartColumn
, EndColumn
) {}
103 Line(int32_t CodeOffset
, LineInfo LineInf
, ColumnInfo ColumnInf
)
104 : CodeOffset(CodeOffset
), LineInf(LineInf
), ColumnInf(ColumnInf
) {}
106 LineInfo
getLineInfo() const { return LineInf
; }
108 ColumnInfo
getColumnInfo() const { return ColumnInf
; }
110 int32_t getCodeOffset() const { return CodeOffset
; }
112 uint32_t getStartLine() const { return LineInf
.getStartLine(); }
114 uint32_t getLineDelta() const { return LineInf
.getLineDelta(); }
116 uint32_t getEndLine() const { return LineInf
.getEndLine(); }
118 uint16_t getStartColumn() const { return ColumnInf
.getStartColumn(); }
120 uint16_t getEndColumn() const { return ColumnInf
.getEndColumn(); }
122 bool isStatement() const { return LineInf
.isStatement(); }
124 bool isAlwaysStepInto() const { return LineInf
.isAlwaysStepInto(); }
126 bool isNeverStepInto() const { return LineInf
.isNeverStepInto(); }
129 } // namespace codeview