Changes in directory llvm/lib/VMCore:
Module.cpp updated: 1.67 -> 1.68 --- Log message: Make the getNamedFunction and getNamedGlobal methods be const. They don't change the module in any way and we should enforce that. --- Diffs of the changes: (+8 -8) Module.cpp | 16 ++++++++-------- 1 files changed, 8 insertions(+), 8 deletions(-) Index: llvm/lib/VMCore/Module.cpp diff -u llvm/lib/VMCore/Module.cpp:1.67 llvm/lib/VMCore/Module.cpp:1.68 --- llvm/lib/VMCore/Module.cpp:1.67 Thu May 18 00:46:08 2006 +++ llvm/lib/VMCore/Module.cpp Wed May 31 11:40:28 2006 @@ -250,16 +250,16 @@ /// specified name, of arbitrary type. This method returns null if a function /// with the specified name is not found. /// -Function *Module::getNamedFunction(const std::string &Name) { +Function *Module::getNamedFunction(const std::string &Name) const { // Loop over all of the functions, looking for the function desired - Function *Found = 0; - for (iterator I = begin(), E = end(); I != E; ++I) + const Function *Found = 0; + for (const_iterator I = begin(), E = end(); I != E; ++I) if (I->getName() == Name) if (I->isExternal()) Found = I; else - return I; - return Found; // Non-external function not found... + return const_cast<Function*>(&(*I)); + return const_cast<Function*>(Found); // Non-external function not found... } //===----------------------------------------------------------------------===// @@ -287,13 +287,13 @@ /// specified name, of arbitrary type. This method returns null if a global /// with the specified name is not found. /// -GlobalVariable *Module::getNamedGlobal(const std::string &Name) { +GlobalVariable *Module::getNamedGlobal(const std::string &Name) const { // FIXME: This would be much faster with a symbol table that doesn't // discriminate based on type! - for (global_iterator I = global_begin(), E = global_end(); + for (const_global_iterator I = global_begin(), E = global_end(); I != E; ++I) if (I->getName() == Name) - return I; + return const_cast<GlobalVariable*>(&(*I)); return 0; } _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits