Introduce DILocation.
authorDevang Patel <dpatel@apple.com>
Tue, 1 Sep 2009 01:14:15 +0000 (01:14 +0000)
committerDevang Patel <dpatel@apple.com>
Tue, 1 Sep 2009 01:14:15 +0000 (01:14 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80648 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Analysis/DebugInfo.h
lib/Analysis/DebugInfo.cpp

index f4783c022a4af0ebe3a0ae22bb34bce9f909f1c2..7c6b421ca35c878408d7d536cf9f60155843b354 100644 (file)
@@ -471,8 +471,24 @@ namespace llvm {
     const std::string &getDirectory(std::string &D) const {
       return getContext().getDirectory(D);
     }
+  };
 
+  /// DILocation - This object holds location information. This object
+  /// is not associated with any DWARF tag.
+  class DILocation : public DIDescriptor {
+  public:
+    explicit DILocation(MDNode *L) { DbgNode = L; }
 
+    unsigned getLineNumber() const     { return getUnsignedField(0); }
+    unsigned getColumnNumber() const   { return getUnsignedField(1); }
+    DIScope  getScope() const          { return getFieldAs<DIScope>(3); }
+    DILocation getOrigLocation() const { return getFieldAs<DILocation>(4); }
+    std::string getFilename(std::string &F) const  { 
+      return getScope().getFilename(F); 
+    }
+    std::string getDirectory(std::string &D) const { 
+      return getScope().getDirectory(D); 
+    }
   };
 
   /// DIFactory - This object assists with the construction of the various
@@ -575,6 +591,10 @@ namespace llvm {
     /// with the specified parent context.
     DILexicalBlock CreateLexicalBlock(DIDescriptor Context);
 
+    /// CreateLocation - Creates a debug info location.
+    DILocation CreateLocation(unsigned LineNo, unsigned ColumnNo, 
+                             DIScope S, DILocation OrigLoc);
+
     /// InsertStopPoint - Create a new llvm.dbg.stoppoint intrinsic invocation,
     /// inserting it at the end of the specified basic block.
     void InsertStopPoint(DICompileUnit CU, unsigned LineNo, unsigned ColNo,
index 0be6fcfec52612d4705850efc1e0d1ab7056560e..d09704f303927f535e12c137b57056a24cc330bc 100644 (file)
@@ -791,6 +791,18 @@ DILexicalBlock DIFactory::CreateLexicalBlock(DIDescriptor Context) {
   return DILexicalBlock(MDNode::get(VMContext, &Elts[0], 2));
 }
 
+/// CreateLocation - Creates a debug info location.
+DILocation DIFactory::CreateLocation(unsigned LineNo, unsigned ColumnNo, 
+                                    DIScope S, DILocation OrigLoc) {
+  Value *Elts[] = {
+    ConstantInt::get(Type::getInt32Ty(VMContext), LineNo),
+    ConstantInt::get(Type::getInt32Ty(VMContext), ColumnNo),
+    S.getNode(),
+    OrigLoc.getNode(),
+  };
+  return DILocation(MDNode::get(VMContext, &Elts[0], 4));
+}
+
 
 //===----------------------------------------------------------------------===//
 // DIFactory: Routines for inserting code into a function