Added -g command line options to clang for generating source level debug information. This patch currently enables generation of line number debug information (stoppoints) and region begin/end debug information. The new files CGDebugInfo.h and CGDebugInfo.cpp implements the debug info manager class CGDebugInfo.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50848 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp
index d8b1fc3..b234788 100644
--- a/lib/CodeGen/CodeGenModule.cpp
+++ b/lib/CodeGen/CodeGenModule.cpp
@@ -11,6 +11,7 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "CGDebugInfo.h"
 #include "CodeGenModule.h"
 #include "CodeGenFunction.h"
 #include "clang/AST/ASTContext.h"
@@ -32,13 +33,19 @@
 
 CodeGenModule::CodeGenModule(ASTContext &C, const LangOptions &LO,
                              llvm::Module &M, const llvm::TargetData &TD,
-                             Diagnostic &diags)
+                             Diagnostic &diags, bool GenerateDebugInfo)
   : Context(C), Features(LO), TheModule(M), TheTargetData(TD), Diags(diags),
     Types(C, M, TD), MemCpyFn(0), MemSetFn(0), CFConstantStringClassRef(0) {
   //TODO: Make this selectable at runtime
   Runtime = CreateObjCRuntime(M,
       getTypes().ConvertType(getContext().IntTy),
       getTypes().ConvertType(getContext().LongTy));
+
+  // If debug info generation is enabled, create the CGDebugInfo object.
+  if (GenerateDebugInfo)
+    DebugInfo = new CGDebugInfo(this);
+  else
+    DebugInfo = NULL;
 }
 
 CodeGenModule::~CodeGenModule() {
@@ -49,7 +56,7 @@
   EmitGlobalCtors();
   EmitAnnotations();
   delete Runtime;
-  
+  delete DebugInfo;
   // Run the verifier to check that the generated code is consistent.
   assert(!verifyModule(TheModule));
 }