[llvm-commits] CVS: llvm/tools/llvm2cpp/CppWriter.cpp

Reid Spencer reid at x10sys.com
Sat Jun 16 13:33:47 PDT 2007



Changes in directory llvm/tools/llvm2cpp:

CppWriter.cpp updated: 1.50 -> 1.51
---
Log message:

Fix PR1516: http://llvm.org/PR1516 :
When printing the uses of a function (-gen-function only), make sure to 
include the constants referenced by intializers of global variables.


---
Diffs of the changes:  (+7 -2)

 CppWriter.cpp |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)


Index: llvm/tools/llvm2cpp/CppWriter.cpp
diff -u llvm/tools/llvm2cpp/CppWriter.cpp:1.50 llvm/tools/llvm2cpp/CppWriter.cpp:1.51
--- llvm/tools/llvm2cpp/CppWriter.cpp:1.50	Sat Jun 16 11:17:35 2007
+++ llvm/tools/llvm2cpp/CppWriter.cpp	Sat Jun 16 15:33:24 2007
@@ -1435,9 +1435,14 @@
       for (unsigned i = 0; i < I->getNumOperands(); ++i) {
         Value* operand = I->getOperand(i);
         printType(operand->getType());
-        if (GlobalValue* GV = dyn_cast<GlobalValue>(operand))
+
+        // If the operand references a GVal or Constant, make a note of it
+        if (GlobalValue* GV = dyn_cast<GlobalValue>(operand)) {
           gvs.push_back(GV);
-        else if (Constant* C = dyn_cast<Constant>(operand))
+          if (GlobalVariable *GVar = dyn_cast<GlobalVariable>(GV)) 
+            if (GVar->hasInitializer())
+              consts.push_back(GVar->getInitializer());
+        } else if (Constant* C = dyn_cast<Constant>(operand))
           consts.push_back(C);
       }
     }






More information about the llvm-commits mailing list