#include "llvm/Instructions.h"
#include "llvm/Assembly/Writer.h"
#include <iostream>
+#include <sstream>
using namespace llvm;
// Error - Simple wrapper function to conditionally assign to E and return true.
return true;
}
+static std::string ToStr(const Type *Ty, const Module *M) {
+ std::ostringstream OS;
+ WriteTypeSymbolic(OS, Ty, M);
+ return OS.str();
+}
+
//
// Function: ResolveTypes()
//
if (SGV->isConstant() != DGV->isConstant())
return Error(Err, "Global Variable Collision on '" +
- SGV->getType()->getDescription() + " %" + SGV->getName() +
+ ToStr(SGV->getType(), Src) + " %" + SGV->getName() +
"' - Global variables differ in const'ness");
// Otherwise, just perform the link.
if (SGV->isConstant() != DGV->isConstant())
return Error(Err, "Global Variable Collision on '" +
- SGV->getType()->getDescription() + " %" + SGV->getName() +
+ ToStr(SGV->getType(), Src) + " %" + SGV->getName() +
"' - Global variables differ in const'ness");
if (!SGV->hasLinkOnceLinkage())
// Allow linking two exactly identical external global variables...
if (SGV->isConstant() != DGV->isConstant())
return Error(Err, "Global Variable Collision on '" +
- SGV->getType()->getDescription() + " %" + SGV->getName() +
+ ToStr(SGV->getType(), Src) + " %" + SGV->getName() +
"' - Global variables differ in const'ness");
if (SGV->getInitializer() != DGV->getInitializer())
return Error(Err, "Global Variable Collision on '" +
- SGV->getType()->getDescription() + " %" + SGV->getName() +
+ ToStr(SGV->getType(), Src) + " %" + SGV->getName() +
"' - External linkage globals have different initializers");
ValueMap.insert(std::make_pair(SGV, DGV));
if (SGV->hasExternalLinkage()) {
if (DGV->getInitializer() != SInit)
return Error(Err, "Global Variable Collision on '" +
- SGV->getType()->getDescription() +"':%"+SGV->getName()+
+ ToStr(SGV->getType(), Src) +"':%"+SGV->getName()+
" - Global variables have different initializers");
} else if (DGV->hasLinkOnceLinkage() || DGV->hasWeakLinkage()) {
// Nothing is required, mapped values will take the new global
} else if (SF->hasExternalLinkage()) {
// The function is defined in both modules!!
return Error(Err, "Function '" +
- SF->getFunctionType()->getDescription() + "':\"" +
+ ToStr(SF->getFunctionType(), Src) + "':\"" +
SF->getName() + "\" - Function is already defined!");
} else {
assert(0 && "Unknown linkage configuration found!");
#include "llvm/Instructions.h"
#include "llvm/Assembly/Writer.h"
#include <iostream>
+#include <sstream>
using namespace llvm;
// Error - Simple wrapper function to conditionally assign to E and return true.
return true;
}
+static std::string ToStr(const Type *Ty, const Module *M) {
+ std::ostringstream OS;
+ WriteTypeSymbolic(OS, Ty, M);
+ return OS.str();
+}
+
//
// Function: ResolveTypes()
//
if (SGV->isConstant() != DGV->isConstant())
return Error(Err, "Global Variable Collision on '" +
- SGV->getType()->getDescription() + " %" + SGV->getName() +
+ ToStr(SGV->getType(), Src) + " %" + SGV->getName() +
"' - Global variables differ in const'ness");
// Otherwise, just perform the link.
if (SGV->isConstant() != DGV->isConstant())
return Error(Err, "Global Variable Collision on '" +
- SGV->getType()->getDescription() + " %" + SGV->getName() +
+ ToStr(SGV->getType(), Src) + " %" + SGV->getName() +
"' - Global variables differ in const'ness");
if (!SGV->hasLinkOnceLinkage())
// Allow linking two exactly identical external global variables...
if (SGV->isConstant() != DGV->isConstant())
return Error(Err, "Global Variable Collision on '" +
- SGV->getType()->getDescription() + " %" + SGV->getName() +
+ ToStr(SGV->getType(), Src) + " %" + SGV->getName() +
"' - Global variables differ in const'ness");
if (SGV->getInitializer() != DGV->getInitializer())
return Error(Err, "Global Variable Collision on '" +
- SGV->getType()->getDescription() + " %" + SGV->getName() +
+ ToStr(SGV->getType(), Src) + " %" + SGV->getName() +
"' - External linkage globals have different initializers");
ValueMap.insert(std::make_pair(SGV, DGV));
if (SGV->hasExternalLinkage()) {
if (DGV->getInitializer() != SInit)
return Error(Err, "Global Variable Collision on '" +
- SGV->getType()->getDescription() +"':%"+SGV->getName()+
+ ToStr(SGV->getType(), Src) +"':%"+SGV->getName()+
" - Global variables have different initializers");
} else if (DGV->hasLinkOnceLinkage() || DGV->hasWeakLinkage()) {
// Nothing is required, mapped values will take the new global
} else if (SF->hasExternalLinkage()) {
// The function is defined in both modules!!
return Error(Err, "Function '" +
- SF->getFunctionType()->getDescription() + "':\"" +
+ ToStr(SF->getFunctionType(), Src) + "':\"" +
SF->getName() + "\" - Function is already defined!");
} else {
assert(0 && "Unknown linkage configuration found!");