DebugInfo: Add equality operators and default constructor to DILineInfo.
[oota-llvm.git] / include / llvm / DebugInfo / DIContext.h
1 //===-- DIContext.h ---------------------------------------------*- C++ -*-===//
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 DIContext, an abstract data structure that holds
11 // debug information data.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #ifndef LLVM_DEBUGINFO_DICONTEXT_H
16 #define LLVM_DEBUGINFO_DICONTEXT_H
17
18 #include "llvm/ADT/StringRef.h"
19 #include "llvm/Support/DataTypes.h"
20 #include <cstring>
21
22 namespace llvm {
23
24 class raw_ostream;
25
26 /// DILineInfo - a format-neutral container for source line information.
27 class DILineInfo {
28   const char *FileName;
29   uint32_t Line;
30   uint32_t Column;
31 public:
32   DILineInfo() : FileName("<invalid>"), Line(0), Column(0) {}
33   DILineInfo(const char *fileName, uint32_t line, uint32_t column)
34     : FileName(fileName), Line(line), Column(column) {}
35
36   const char *getFileName() const { return FileName; }
37   uint32_t getLine() const { return Line; }
38   uint32_t getColumn() const { return Column; }
39
40   bool operator==(const DILineInfo &RHS) const {
41     return Line == RHS.Line && Column == RHS.Column &&
42            std::strcmp(FileName, RHS.FileName) == 0;
43   }
44   bool operator!=(const DILineInfo &RHS) const {
45     return !(*this == RHS);
46   }
47 };
48
49 class DIContext {
50 public:
51   virtual ~DIContext();
52
53   /// getDWARFContext - get a context for binary DWARF data.
54   static DIContext *getDWARFContext(bool isLittleEndian,
55                                     StringRef infoSection,
56                                     StringRef abbrevSection,
57                                     StringRef aRangeSection = StringRef(),
58                                     StringRef lineSection = StringRef(),
59                                     StringRef stringSection = StringRef());
60
61   virtual void dump(raw_ostream &OS) = 0;
62
63   virtual DILineInfo getLineInfoForAddress(uint64_t address) = 0;
64 };
65
66 }
67
68 #endif