]> git.proxmox.com Git - rustc.git/blame - src/llvm/include/llvm/IR/DebugLoc.h
Imported Upstream version 1.0.0+dfsg1
[rustc.git] / src / llvm / include / llvm / IR / DebugLoc.h
CommitLineData
1a4d82fc 1//===- DebugLoc.h - Debug Location Information ------------------*- C++ -*-===//
223e47cc
LB
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file defines a number of light weight data structures used
11// to describe and track debug location information.
1a4d82fc 12//
223e47cc
LB
13//===----------------------------------------------------------------------===//
14
1a4d82fc
JJ
15#ifndef LLVM_IR_DEBUGLOC_H
16#define LLVM_IR_DEBUGLOC_H
17
85aaf69f 18#include "llvm/IR/TrackingMDRef.h"
1a4d82fc 19#include "llvm/Support/DataTypes.h"
223e47cc
LB
20
21namespace llvm {
85aaf69f 22
223e47cc 23 class LLVMContext;
1a4d82fc 24 class raw_ostream;
85aaf69f 25 class MDNode;
1a4d82fc 26
223e47cc
LB
27 /// DebugLoc - Debug location id. This is carried by Instruction, SDNode,
28 /// and MachineInstr to compactly encode file/line/scope information for an
29 /// operation.
30 class DebugLoc {
85aaf69f 31 TrackingMDNodeRef Loc;
223e47cc 32
85aaf69f
SL
33 public:
34 DebugLoc() {}
35 DebugLoc(DebugLoc &&X) : Loc(std::move(X.Loc)) {}
36 DebugLoc(const DebugLoc &X) : Loc(X.Loc) {}
37 DebugLoc &operator=(DebugLoc &&X) {
38 Loc = std::move(X.Loc);
39 return *this;
40 }
41 DebugLoc &operator=(const DebugLoc &X) {
42 Loc = X.Loc;
43 return *this;
223e47cc
LB
44 }
45
85aaf69f
SL
46 /// \brief Check whether this has a trivial destructor.
47 bool hasTrivialDestructor() const { return Loc.hasTrivialDestructor(); }
1a4d82fc 48
223e47cc
LB
49 /// get - Get a new DebugLoc that corresponds to the specified line/col
50 /// scope/inline location.
85aaf69f
SL
51 static DebugLoc get(unsigned Line, unsigned Col, MDNode *Scope,
52 MDNode *InlinedAt = nullptr);
1a4d82fc 53
223e47cc
LB
54 /// getFromDILocation - Translate the DILocation quad into a DebugLoc.
55 static DebugLoc getFromDILocation(MDNode *N);
56
57 /// getFromDILexicalBlock - Translate the DILexicalBlock into a DebugLoc.
58 static DebugLoc getFromDILexicalBlock(MDNode *N);
59
60 /// isUnknown - Return true if this is an unknown location.
85aaf69f 61 bool isUnknown() const { return !Loc; }
1a4d82fc 62
85aaf69f
SL
63 unsigned getLine() const;
64 unsigned getCol() const;
1a4d82fc 65
223e47cc
LB
66 /// getScope - This returns the scope pointer for this DebugLoc, or null if
67 /// invalid.
85aaf69f
SL
68 MDNode *getScope() const;
69 MDNode *getScope(const LLVMContext &) const { return getScope(); }
1a4d82fc 70
223e47cc
LB
71 /// getInlinedAt - This returns the InlinedAt pointer for this DebugLoc, or
72 /// null if invalid or not present.
85aaf69f
SL
73 MDNode *getInlinedAt() const;
74 MDNode *getInlinedAt(const LLVMContext &) const { return getInlinedAt(); }
1a4d82fc 75
223e47cc 76 /// getScopeAndInlinedAt - Return both the Scope and the InlinedAt values.
85aaf69f 77 void getScopeAndInlinedAt(MDNode *&Scope, MDNode *&IA) const;
223e47cc 78 void getScopeAndInlinedAt(MDNode *&Scope, MDNode *&IA,
85aaf69f
SL
79 const LLVMContext &) const {
80 return getScopeAndInlinedAt(Scope, IA);
81 }
1a4d82fc
JJ
82
83 /// getScopeNode - Get MDNode for DebugLoc's scope, or null if invalid.
85aaf69f
SL
84 MDNode *getScopeNode() const;
85 MDNode *getScopeNode(const LLVMContext &) const { return getScopeNode(); }
1a4d82fc
JJ
86
87 // getFnDebugLoc - Walk up the scope chain of given debug loc and find line
88 // number info for the function.
85aaf69f
SL
89 DebugLoc getFnDebugLoc() const;
90 DebugLoc getFnDebugLoc(const LLVMContext &) const {
91 return getFnDebugLoc();
92 }
1a4d82fc 93
223e47cc
LB
94 /// getAsMDNode - This method converts the compressed DebugLoc node into a
95 /// DILocation compatible MDNode.
85aaf69f
SL
96 MDNode *getAsMDNode() const;
97 MDNode *getAsMDNode(LLVMContext &) const { return getAsMDNode(); }
1a4d82fc 98
85aaf69f 99 bool operator==(const DebugLoc &DL) const { return Loc == DL.Loc; }
223e47cc
LB
100 bool operator!=(const DebugLoc &DL) const { return !(*this == DL); }
101
85aaf69f
SL
102 void dump() const;
103 void dump(const LLVMContext &) const { dump(); }
1a4d82fc 104 /// \brief prints source location /path/to/file.exe:line:col @[inlined at]
85aaf69f
SL
105 void print(raw_ostream &OS) const;
106 void print(const LLVMContext &, raw_ostream &OS) const { print(OS); }
223e47cc
LB
107 };
108
223e47cc
LB
109} // end namespace llvm
110
970d7e83 111#endif /* LLVM_SUPPORT_DEBUGLOC_H */