diff options
| author | Reid Spencer <rspencer@reidspencer.com> | 2006-05-31 16:40:28 +0000 |
|---|---|---|
| committer | Reid Spencer <rspencer@reidspencer.com> | 2006-05-31 16:40:28 +0000 |
| commit | 9fef163d19ce6b2b75acffc8a00a8501768c8d8c (patch) | |
| tree | 5f986b12a0ef7cd97563c4a50816ece84be1e475 /llvm/lib | |
| parent | 735e3f76a87d237c7f871f13b658a22bb876d333 (diff) | |
| download | bcm5719-llvm-9fef163d19ce6b2b75acffc8a00a8501768c8d8c.tar.gz bcm5719-llvm-9fef163d19ce6b2b75acffc8a00a8501768c8d8c.zip | |
Make the getNamedFunction and getNamedGlobal methods be const. They don't
change the module in any way and we should enforce that.
llvm-svn: 28588
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/VMCore/Module.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/llvm/lib/VMCore/Module.cpp b/llvm/lib/VMCore/Module.cpp index da7d410423f..7dcd44ca2e5 100644 --- a/llvm/lib/VMCore/Module.cpp +++ b/llvm/lib/VMCore/Module.cpp @@ -250,16 +250,16 @@ Function *Module::getMainFunction() { /// 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 @@ GlobalVariable *Module::getGlobalVariable(const std::string &Name, /// 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; } |

