Skip to content

Commit

Permalink
Fix -Wcast-qual warnings.
Browse files Browse the repository at this point in the history
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101779 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
Dan Gohman committed Apr 19, 2010
1 parent 5af8f42 commit dfd4bbf
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/Archive/Archive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ llvm::GetBitcodeSymbols(const unsigned char *BufPtr, unsigned Length,
// Get the module.
std::auto_ptr<MemoryBuffer> Buffer(
MemoryBuffer::getNewMemBuffer(Length, ModuleID.c_str()));
memcpy((char*)Buffer->getBufferStart(), BufPtr, Length);
memcpy(const_cast<char *>(Buffer->getBufferStart()), BufPtr, Length);

Module *M = ParseBitcodeFile(Buffer.get(), Context, ErrMsg);
if (!M)
Expand Down
9 changes: 6 additions & 3 deletions lib/Archive/ArchiveReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,8 @@ Archive::getAllModules(std::vector<Module*>& Modules,
"(" + I->getPath().str() + ")";
MemoryBuffer *Buffer =
MemoryBuffer::getNewMemBuffer(I->getSize(), FullMemberName.c_str());
memcpy((char*)Buffer->getBufferStart(), I->getData(), I->getSize());
memcpy(const_cast<char *>(Buffer->getBufferStart()),
I->getData(), I->getSize());

Module *M = ParseBitcodeFile(Buffer, Context, ErrMessage);
delete Buffer;
Expand Down Expand Up @@ -489,7 +490,8 @@ Archive::findModuleDefiningSymbol(const std::string& symbol,
mbr->getPath().str() + ")";
MemoryBuffer *Buffer =MemoryBuffer::getNewMemBuffer(mbr->getSize(),
FullMemberName.c_str());
memcpy((char*)Buffer->getBufferStart(), mbr->getData(), mbr->getSize());
memcpy(const_cast<char *>(Buffer->getBufferStart()),
mbr->getData(), mbr->getSize());

Module *m = getLazyBitcodeModule(Buffer, Context, ErrMsg);
if (!m)
Expand Down Expand Up @@ -617,7 +619,8 @@ bool Archive::isBitcodeArchive() {

MemoryBuffer *Buffer =
MemoryBuffer::getNewMemBuffer(I->getSize(), FullMemberName.c_str());
memcpy((char*)Buffer->getBufferStart(), I->getData(), I->getSize());
memcpy(const_cast<char *>(Buffer->getBufferStart()),
I->getData(), I->getSize());
Module *M = ParseBitcodeFile(Buffer, Context);
delete Buffer;
if (!M)
Expand Down
6 changes: 4 additions & 2 deletions lib/VMCore/TypeSymbolTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,15 @@ void TypeSymbolTable::refineAbstractType(const DerivedType *OldType,
// faster to remove them all in one pass.
//
for (iterator I = begin(), E = end(); I != E; ++I) {
if (I->second == (Type*)OldType) { // FIXME when Types aren't const.
// FIXME when Types aren't const.
if (I->second == const_cast<DerivedType *>(OldType)) {
#if DEBUG_ABSTYPE
dbgs() << "Removing type " << OldType->getDescription() << "\n";
#endif
OldType->removeAbstractTypeUser(this);

I->second = (Type*)NewType; // TODO FIXME when types aren't const
// TODO FIXME when types aren't const
I->second = const_cast<Type *>(NewType);
if (NewType->isAbstract()) {
#if DEBUG_ABSTYPE
dbgs() << "Added type " << NewType->getDescription() << "\n";
Expand Down

0 comments on commit dfd4bbf

Please sign in to comment.