forked from OSchip/llvm-project
Change some functions to take const pointers.
llvm-svn: 169812
This commit is contained in:
parent
c2bd620fac
commit
6ee19d28f4
|
@ -320,8 +320,9 @@ MemoryBuffer *LTOModule::makeBuffer(const void *mem, size_t length) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// objcClassNameFromExpression - Get string that the data pointer points to.
|
/// objcClassNameFromExpression - Get string that the data pointer points to.
|
||||||
bool LTOModule::objcClassNameFromExpression(Constant *c, std::string &name) {
|
bool
|
||||||
if (ConstantExpr *ce = dyn_cast<ConstantExpr>(c)) {
|
LTOModule::objcClassNameFromExpression(const Constant *c, std::string &name) {
|
||||||
|
if (const ConstantExpr *ce = dyn_cast<ConstantExpr>(c)) {
|
||||||
Constant *op = ce->getOperand(0);
|
Constant *op = ce->getOperand(0);
|
||||||
if (GlobalVariable *gvn = dyn_cast<GlobalVariable>(op)) {
|
if (GlobalVariable *gvn = dyn_cast<GlobalVariable>(op)) {
|
||||||
Constant *cn = gvn->getInitializer();
|
Constant *cn = gvn->getInitializer();
|
||||||
|
@ -337,8 +338,8 @@ bool LTOModule::objcClassNameFromExpression(Constant *c, std::string &name) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// addObjCClass - Parse i386/ppc ObjC class data structure.
|
/// addObjCClass - Parse i386/ppc ObjC class data structure.
|
||||||
void LTOModule::addObjCClass(GlobalVariable *clgv) {
|
void LTOModule::addObjCClass(const GlobalVariable *clgv) {
|
||||||
ConstantStruct *c = dyn_cast<ConstantStruct>(clgv->getInitializer());
|
const ConstantStruct *c = dyn_cast<ConstantStruct>(clgv->getInitializer());
|
||||||
if (!c) return;
|
if (!c) return;
|
||||||
|
|
||||||
// second slot in __OBJC,__class is pointer to superclass name
|
// second slot in __OBJC,__class is pointer to superclass name
|
||||||
|
@ -374,8 +375,8 @@ void LTOModule::addObjCClass(GlobalVariable *clgv) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// addObjCCategory - Parse i386/ppc ObjC category data structure.
|
/// addObjCCategory - Parse i386/ppc ObjC category data structure.
|
||||||
void LTOModule::addObjCCategory(GlobalVariable *clgv) {
|
void LTOModule::addObjCCategory(const GlobalVariable *clgv) {
|
||||||
ConstantStruct *c = dyn_cast<ConstantStruct>(clgv->getInitializer());
|
const ConstantStruct *c = dyn_cast<ConstantStruct>(clgv->getInitializer());
|
||||||
if (!c) return;
|
if (!c) return;
|
||||||
|
|
||||||
// second slot in __OBJC,__category is pointer to target class name
|
// second slot in __OBJC,__category is pointer to target class name
|
||||||
|
@ -399,7 +400,7 @@ void LTOModule::addObjCCategory(GlobalVariable *clgv) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// addObjCClassRef - Parse i386/ppc ObjC class list data structure.
|
/// addObjCClassRef - Parse i386/ppc ObjC class list data structure.
|
||||||
void LTOModule::addObjCClassRef(GlobalVariable *clgv) {
|
void LTOModule::addObjCClassRef(const GlobalVariable *clgv) {
|
||||||
std::string targetclassName;
|
std::string targetclassName;
|
||||||
if (!objcClassNameFromExpression(clgv->getInitializer(), targetclassName))
|
if (!objcClassNameFromExpression(clgv->getInitializer(), targetclassName))
|
||||||
return;
|
return;
|
||||||
|
@ -419,7 +420,7 @@ void LTOModule::addObjCClassRef(GlobalVariable *clgv) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// addDefinedDataSymbol - Add a data symbol as defined to the list.
|
/// addDefinedDataSymbol - Add a data symbol as defined to the list.
|
||||||
void LTOModule::addDefinedDataSymbol(GlobalValue *v) {
|
void LTOModule::addDefinedDataSymbol(const GlobalValue *v) {
|
||||||
// Add to list of defined symbols.
|
// Add to list of defined symbols.
|
||||||
addDefinedSymbol(v, false);
|
addDefinedSymbol(v, false);
|
||||||
|
|
||||||
|
@ -448,34 +449,34 @@ void LTOModule::addDefinedDataSymbol(GlobalValue *v) {
|
||||||
|
|
||||||
// special case if this data blob is an ObjC class definition
|
// special case if this data blob is an ObjC class definition
|
||||||
if (v->getSection().compare(0, 15, "__OBJC,__class,") == 0) {
|
if (v->getSection().compare(0, 15, "__OBJC,__class,") == 0) {
|
||||||
if (GlobalVariable *gv = dyn_cast<GlobalVariable>(v)) {
|
if (const GlobalVariable *gv = dyn_cast<GlobalVariable>(v)) {
|
||||||
addObjCClass(gv);
|
addObjCClass(gv);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// special case if this data blob is an ObjC category definition
|
// special case if this data blob is an ObjC category definition
|
||||||
else if (v->getSection().compare(0, 18, "__OBJC,__category,") == 0) {
|
else if (v->getSection().compare(0, 18, "__OBJC,__category,") == 0) {
|
||||||
if (GlobalVariable *gv = dyn_cast<GlobalVariable>(v)) {
|
if (const GlobalVariable *gv = dyn_cast<GlobalVariable>(v)) {
|
||||||
addObjCCategory(gv);
|
addObjCCategory(gv);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// special case if this data blob is the list of referenced classes
|
// special case if this data blob is the list of referenced classes
|
||||||
else if (v->getSection().compare(0, 18, "__OBJC,__cls_refs,") == 0) {
|
else if (v->getSection().compare(0, 18, "__OBJC,__cls_refs,") == 0) {
|
||||||
if (GlobalVariable *gv = dyn_cast<GlobalVariable>(v)) {
|
if (const GlobalVariable *gv = dyn_cast<GlobalVariable>(v)) {
|
||||||
addObjCClassRef(gv);
|
addObjCClassRef(gv);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// addDefinedFunctionSymbol - Add a function symbol as defined to the list.
|
/// addDefinedFunctionSymbol - Add a function symbol as defined to the list.
|
||||||
void LTOModule::addDefinedFunctionSymbol(Function *f) {
|
void LTOModule::addDefinedFunctionSymbol(const Function *f) {
|
||||||
// add to list of defined symbols
|
// add to list of defined symbols
|
||||||
addDefinedSymbol(f, true);
|
addDefinedSymbol(f, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// addDefinedSymbol - Add a defined symbol to the list.
|
/// addDefinedSymbol - Add a defined symbol to the list.
|
||||||
void LTOModule::addDefinedSymbol(GlobalValue *def, bool isFunction) {
|
void LTOModule::addDefinedSymbol(const GlobalValue *def, bool isFunction) {
|
||||||
// ignore all llvm.* symbols
|
// ignore all llvm.* symbols
|
||||||
if (def->getName().startswith("llvm."))
|
if (def->getName().startswith("llvm."))
|
||||||
return;
|
return;
|
||||||
|
@ -492,7 +493,7 @@ void LTOModule::addDefinedSymbol(GlobalValue *def, bool isFunction) {
|
||||||
if (isFunction) {
|
if (isFunction) {
|
||||||
attr |= LTO_SYMBOL_PERMISSIONS_CODE;
|
attr |= LTO_SYMBOL_PERMISSIONS_CODE;
|
||||||
} else {
|
} else {
|
||||||
GlobalVariable *gv = dyn_cast<GlobalVariable>(def);
|
const GlobalVariable *gv = dyn_cast<GlobalVariable>(def);
|
||||||
if (gv && gv->isConstant())
|
if (gv && gv->isConstant())
|
||||||
attr |= LTO_SYMBOL_PERMISSIONS_RODATA;
|
attr |= LTO_SYMBOL_PERMISSIONS_RODATA;
|
||||||
else
|
else
|
||||||
|
@ -607,7 +608,8 @@ void LTOModule::addAsmGlobalSymbolUndef(const char *name) {
|
||||||
|
|
||||||
/// addPotentialUndefinedSymbol - Add a symbol which isn't defined just yet to a
|
/// addPotentialUndefinedSymbol - Add a symbol which isn't defined just yet to a
|
||||||
/// list to be resolved later.
|
/// list to be resolved later.
|
||||||
void LTOModule::addPotentialUndefinedSymbol(GlobalValue *decl, bool isFunc) {
|
void
|
||||||
|
LTOModule::addPotentialUndefinedSymbol(const GlobalValue *decl, bool isFunc) {
|
||||||
// ignore all llvm.* symbols
|
// ignore all llvm.* symbols
|
||||||
if (decl->getName().startswith("llvm."))
|
if (decl->getName().startswith("llvm."))
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -44,7 +44,7 @@ private:
|
||||||
const char *name;
|
const char *name;
|
||||||
uint32_t attributes;
|
uint32_t attributes;
|
||||||
bool isFunction;
|
bool isFunction;
|
||||||
llvm::GlobalValue *symbol;
|
const llvm::GlobalValue *symbol;
|
||||||
};
|
};
|
||||||
|
|
||||||
llvm::OwningPtr<llvm::Module> _module;
|
llvm::OwningPtr<llvm::Module> _module;
|
||||||
|
@ -138,16 +138,16 @@ private:
|
||||||
|
|
||||||
/// addPotentialUndefinedSymbol - Add a symbol which isn't defined just yet
|
/// addPotentialUndefinedSymbol - Add a symbol which isn't defined just yet
|
||||||
/// to a list to be resolved later.
|
/// to a list to be resolved later.
|
||||||
void addPotentialUndefinedSymbol(llvm::GlobalValue *dcl, bool isFunc);
|
void addPotentialUndefinedSymbol(const llvm::GlobalValue *dcl, bool isFunc);
|
||||||
|
|
||||||
/// addDefinedSymbol - Add a defined symbol to the list.
|
/// addDefinedSymbol - Add a defined symbol to the list.
|
||||||
void addDefinedSymbol(llvm::GlobalValue *def, bool isFunction);
|
void addDefinedSymbol(const llvm::GlobalValue *def, bool isFunction);
|
||||||
|
|
||||||
/// addDefinedFunctionSymbol - Add a function symbol as defined to the list.
|
/// addDefinedFunctionSymbol - Add a function symbol as defined to the list.
|
||||||
void addDefinedFunctionSymbol(llvm::Function *f);
|
void addDefinedFunctionSymbol(const llvm::Function *f);
|
||||||
|
|
||||||
/// addDefinedDataSymbol - Add a data symbol as defined to the list.
|
/// addDefinedDataSymbol - Add a data symbol as defined to the list.
|
||||||
void addDefinedDataSymbol(llvm::GlobalValue *v);
|
void addDefinedDataSymbol(const llvm::GlobalValue *v);
|
||||||
|
|
||||||
/// addAsmGlobalSymbols - Add global symbols from module-level ASM to the
|
/// addAsmGlobalSymbols - Add global symbols from module-level ASM to the
|
||||||
/// defined or undefined lists.
|
/// defined or undefined lists.
|
||||||
|
@ -162,17 +162,17 @@ private:
|
||||||
void addAsmGlobalSymbolUndef(const char *);
|
void addAsmGlobalSymbolUndef(const char *);
|
||||||
|
|
||||||
/// addObjCClass - Parse i386/ppc ObjC class data structure.
|
/// addObjCClass - Parse i386/ppc ObjC class data structure.
|
||||||
void addObjCClass(llvm::GlobalVariable *clgv);
|
void addObjCClass(const llvm::GlobalVariable *clgv);
|
||||||
|
|
||||||
/// addObjCCategory - Parse i386/ppc ObjC category data structure.
|
/// addObjCCategory - Parse i386/ppc ObjC category data structure.
|
||||||
void addObjCCategory(llvm::GlobalVariable *clgv);
|
void addObjCCategory(const llvm::GlobalVariable *clgv);
|
||||||
|
|
||||||
/// addObjCClassRef - Parse i386/ppc ObjC class list data structure.
|
/// addObjCClassRef - Parse i386/ppc ObjC class list data structure.
|
||||||
void addObjCClassRef(llvm::GlobalVariable *clgv);
|
void addObjCClassRef(const llvm::GlobalVariable *clgv);
|
||||||
|
|
||||||
/// objcClassNameFromExpression - Get string that the data pointer points
|
/// objcClassNameFromExpression - Get string that the data pointer points
|
||||||
/// to.
|
/// to.
|
||||||
bool objcClassNameFromExpression(llvm::Constant* c, std::string &name);
|
bool objcClassNameFromExpression(const llvm::Constant* c, std::string &name);
|
||||||
|
|
||||||
/// isTargetMatch - Returns 'true' if the memory buffer is for the specified
|
/// isTargetMatch - Returns 'true' if the memory buffer is for the specified
|
||||||
/// target triple.
|
/// target triple.
|
||||||
|
|
Loading…
Reference in New Issue