summaryrefslogtreecommitdiff
path: root/tools
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
commitab24b4cf70b9476b81808917c9f960c52b8980bf (patch)
treeaadb9e2bdd2de2a8c157cf0696d26f241140e6bc /tools
parent8946fe177659512b14f7292eb0f0fc8532fcce64 (diff)
downloadllvm-ab24b4cf70b9476b81808917c9f960c52b8980bf.tar.gz
llvm-ab24b4cf70b9476b81808917c9f960c52b8980bf.tar.bz2
llvm-ab24b4cf70b9476b81808917c9f960c52b8980bf.tar.xz
Fix PR1516:
When printing the uses of a function (-gen-function only), make sure to include the constants referenced by intializers of global variables. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37615 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rw-r--r--tools/llvm2cpp/CppWriter.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/tools/llvm2cpp/CppWriter.cpp b/tools/llvm2cpp/CppWriter.cpp
index 1076b59c02..a5aa7d46e3 100644
--- a/tools/llvm2cpp/CppWriter.cpp
+++ b/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);
}
}