]> granicus.if.org Git - clang/commitdiff
Simplify code and add comments, in code that generate debug info for constant integer...
authorDevang Patel <dpatel@apple.com>
Tue, 10 Aug 2010 17:53:33 +0000 (17:53 +0000)
committerDevang Patel <dpatel@apple.com>
Tue, 10 Aug 2010 17:53:33 +0000 (17:53 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110694 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGDebugInfo.cpp
lib/CodeGen/CGDebugInfo.h
lib/CodeGen/CGExprScalar.cpp
lib/CodeGen/CodeGenFunction.cpp
lib/CodeGen/CodeGenFunction.h

index 5ec68c0ff00c180eda6403a37c5d9bb9127a5d36..a75ff104767da23af21e923b7bfe8fe8c8985948 100644 (file)
@@ -1801,7 +1801,9 @@ void CGDebugInfo::EmitGlobalVariable(llvm::GlobalVariable *Var,
                                     true/*definition*/, Var);
 }
 
-void CGDebugInfo::EmitGlobalVariable(llvm::Constant *C, const ValueDecl *VD,
+/// EmitGlobalVariable - Emit global variable's debug info.
+void CGDebugInfo::EmitGlobalVariable(const ValueDecl *VD, 
+                                     llvm::ConstantInt *Init,
                                      CGBuilderTy &Builder) {
   // Create the descriptor for the variable.
   llvm::DIFile Unit = getOrCreateFile(VD->getLocation());
@@ -1809,7 +1811,7 @@ void CGDebugInfo::EmitGlobalVariable(llvm::Constant *C, const ValueDecl *VD,
   DebugFactory.CreateGlobalVariable(Unit, Name, Name, Name, Unit,
                                     getLineNumber(VD->getLocation()),
                                     getOrCreateType(VD->getType(), Unit),
-                                    true, true, C);
+                                    true, true, Init);
 }
 
 /// getOrCreateNamesSpace - Return namespace descriptor for the given
index 4df2ab62f82f5b74711cfff6530677a1371db473..93c9aeea3ce1a0d613b9237f752b22ded53d8c5a 100644 (file)
@@ -181,8 +181,8 @@ public:
   /// EmitGlobalVariable - Emit information about an objective-c interface.
   void EmitGlobalVariable(llvm::GlobalVariable *GV, ObjCInterfaceDecl *Decl);
 
-  /// EmitGlobalVariable - Emit information about a constant.
-  void EmitGlobalVariable(llvm::Constant *C, const ValueDecl *VD
+  /// EmitGlobalVariable - Emit global variable's debug info.
+  void EmitGlobalVariable(const ValueDecl *VD, llvm::ConstantInt *Init
                           CGBuilderTy &Builder);
 
 private:
index f6f126a8a621c9c89b6a335e6cd2069c306a982a..89947df9407feaf7fff7f0bc7fd4d3be60d2b655 100644 (file)
@@ -149,8 +149,10 @@ public:
     Expr::EvalResult Result;
     if (E->Evaluate(Result, CGF.getContext()) && Result.Val.isInt()) {
       assert(!Result.HasSideEffects && "Constant declref with side-effect?!");
-      CGF.EmitDeclRefExprDbgValue(E, Result.Val);
-      return llvm::ConstantInt::get(VMContext, Result.Val.getInt());
+      llvm::ConstantInt *CI 
+        = llvm::ConstantInt::get(VMContext, Result.Val.getInt());
+      CGF.EmitDeclRefExprDbgValue(E, CI);
+      return CI;
     }
     return EmitLoadOfLValue(E);
   }
index f992aa72e2e7a4e01b6d95b7d491d8d1ed178790..f883bec4ff5b97acbddd240af0f7d2a5dff491ce 100644 (file)
@@ -1286,15 +1286,8 @@ llvm::Value *CodeGenFunction::getEHCleanupDestSlot() {
 }
 
 void CodeGenFunction::EmitDeclRefExprDbgValue(const DeclRefExpr *E, 
-                                              const APValue &AV) {
-  CGDebugInfo *Dbg = getDebugInfo();
-  if (!Dbg) return;
-
-  llvm::Constant *C = NULL;
-  if (AV.isInt())
-    C = llvm::ConstantInt::get(getLLVMContext(), AV.getInt());
-  else if (AV.isFloat())
-    C = llvm::ConstantFP::get(getLLVMContext(), AV.getFloat());
-  if (C)
-    Dbg->EmitGlobalVariable(C, E->getDecl(), Builder);
+                                              llvm::ConstantInt *Init) {
+  assert (Init && "Invalid DeclRefExpr initializer!");
+  if (CGDebugInfo *Dbg = getDebugInfo())
+    Dbg->EmitGlobalVariable(E->getDecl(), Init, Builder);
 }
index e0673d991742f2e07b1dc93566166185739a8472..325940d2452fe4981bc173462ebbf51a0138a961 100644 (file)
@@ -1373,7 +1373,7 @@ public:
   LValue EmitStmtExprLValue(const StmtExpr *E);
   LValue EmitPointerToDataMemberBinaryExpr(const BinaryOperator *E);
   LValue EmitObjCSelectorLValue(const ObjCSelectorExpr *E);
-  void   EmitDeclRefExprDbgValue(const DeclRefExpr *E, const APValue &AV);
+  void   EmitDeclRefExprDbgValue(const DeclRefExpr *E, llvm::ConstantInt *Init);
   //===--------------------------------------------------------------------===//
   //                         Scalar Expression Emission
   //===--------------------------------------------------------------------===//