summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm2cpp/CppWriter.cpp
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2007-06-16 20:33:24 +0000
committerReid Spencer <rspencer@reidspencer.com>2007-06-16 20:33:24 +0000
commit83c15f8a1b19e7b656cf4bb75a01c9fea8be7a6d (patch)
treee0ffca23c64bd15bd6759b5e4fb13ac51e09f241 /llvm/tools/llvm2cpp/CppWriter.cpp
parent7aa84fe7c556d2deeba33b153cd8265dab3684a7 (diff)
downloadbcm5719-llvm-83c15f8a1b19e7b656cf4bb75a01c9fea8be7a6d.tar.gz
bcm5719-llvm-83c15f8a1b19e7b656cf4bb75a01c9fea8be7a6d.zip
Fix PR1516:
When printing the uses of a function (-gen-function only), make sure to include the constants referenced by intializers of global variables. llvm-svn: 37615
Diffstat (limited to 'llvm/tools/llvm2cpp/CppWriter.cpp')
-rw-r--r--llvm/tools/llvm2cpp/CppWriter.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/llvm/tools/llvm2cpp/CppWriter.cpp b/llvm/tools/llvm2cpp/CppWriter.cpp
index 1076b59c021..a5aa7d46e3c 100644
--- a/llvm/tools/llvm2cpp/CppWriter.cpp
+++ b/llvm/tools/llvm2cpp/CppWriter.cpp
@@ -1435,9 +1435,14 @@ void CppWriter::printFunctionUses(const Function* F) {
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);
}
}
OpenPOWER on IntegriCloud