diff options
author | Dan Gohman <gohman@apple.com> | 2010-04-19 16:39:44 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2010-04-19 16:39:44 +0000 |
commit | cb421fa690da545b58a720abe5f1c49b166dbde7 (patch) | |
tree | 83aec2feca44552c955bfcd70aabb3cfc36d9563 | |
parent | cb7464ab402d057849dda9749d62a62d86c35ab8 (diff) |
Fix -Wcast-qual warnings.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101786 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang/AST/APValue.h | 8 | ||||
-rw-r--r-- | lib/AST/APValue.cpp | 3 | ||||
-rw-r--r-- | lib/AST/ASTContext.cpp | 3 | ||||
-rw-r--r-- | lib/AST/RecordLayoutBuilder.cpp | 2 | ||||
-rw-r--r-- | lib/Checker/SVals.cpp | 3 | ||||
-rw-r--r-- | lib/CodeGen/CGObjCGNU.cpp | 3 | ||||
-rw-r--r-- | lib/CodeGen/CodeGenModule.cpp | 2 | ||||
-rw-r--r-- | lib/Frontend/ASTUnit.cpp | 6 | ||||
-rw-r--r-- | lib/Frontend/CodeGenAction.cpp | 2 | ||||
-rw-r--r-- | lib/Frontend/InitHeaderSearch.cpp | 2 | ||||
-rw-r--r-- | lib/Sema/SemaType.cpp | 3 | ||||
-rw-r--r-- | tools/driver/cc1_main.cpp | 2 |
12 files changed, 25 insertions, 14 deletions
diff --git a/include/clang/AST/APValue.h b/include/clang/AST/APValue.h index 9d4bff893f..5effa9057a 100644 --- a/include/clang/AST/APValue.h +++ b/include/clang/AST/APValue.h @@ -122,13 +122,17 @@ public: return const_cast<APValue*>(this)->getFloat(); } - APValue &getVectorElt(unsigned i) const { + APValue &getVectorElt(unsigned i) { assert(isVector() && "Invalid accessor"); return ((Vec*)(char*)Data)->Elts[i]; } + const APValue &getVectorElt(unsigned i) const { + assert(isVector() && "Invalid accessor"); + return ((const Vec*)(const char*)Data)->Elts[i]; + } unsigned getVectorLength() const { assert(isVector() && "Invalid accessor"); - return ((Vec*)(void *)Data)->NumElts; + return ((const Vec*)(const void *)Data)->NumElts; } APSInt &getComplexIntReal() { diff --git a/lib/AST/APValue.cpp b/lib/AST/APValue.cpp index 50a6e0a50d..731d5e0466 100644 --- a/lib/AST/APValue.cpp +++ b/lib/AST/APValue.cpp @@ -48,7 +48,8 @@ const APValue &APValue::operator=(const APValue &RHS) { else if (isFloat()) setFloat(RHS.getFloat()); else if (isVector()) - setVector(((Vec*)(char*)RHS.Data)->Elts, RHS.getVectorLength()); + setVector(((const Vec *)(const char *)RHS.Data)->Elts, + RHS.getVectorLength()); else if (isComplexInt()) setComplexInt(RHS.getComplexIntReal(), RHS.getComplexIntImag()); else if (isComplexFloat()) diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index 68620dc346..a3c08d56b0 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -4194,7 +4194,8 @@ void getIntersectionOfProtocols(ASTContext &Context, unsigned RHSNumProtocols = RHS->getNumProtocols(); if (RHSNumProtocols > 0) { - ObjCProtocolDecl **RHSProtocols = (ObjCProtocolDecl **)RHS->qual_begin(); + ObjCProtocolDecl **RHSProtocols = + const_cast<ObjCProtocolDecl **>(RHS->qual_begin()); for (unsigned i = 0; i < RHSNumProtocols; ++i) if (InheritedProtocolSet.count(RHSProtocols[i])) IntersectionOfProtocols.push_back(RHSProtocols[i]); diff --git a/lib/AST/RecordLayoutBuilder.cpp b/lib/AST/RecordLayoutBuilder.cpp index a674ad7970..3038d912fc 100644 --- a/lib/AST/RecordLayoutBuilder.cpp +++ b/lib/AST/RecordLayoutBuilder.cpp @@ -913,7 +913,7 @@ static void DumpCXXRecordLayout(llvm::raw_ostream &OS, const ASTRecordLayout &Info = C.getASTRecordLayout(RD); PrintOffset(OS, Offset, IndentLevel); - OS << C.getTypeDeclType((CXXRecordDecl *)RD).getAsString(); + OS << C.getTypeDeclType(const_cast<CXXRecordDecl *>(RD)).getAsString(); if (Description) OS << ' ' << Description; if (RD->isEmpty()) diff --git a/lib/Checker/SVals.cpp b/lib/Checker/SVals.cpp index 4bfa2cdafb..d756be70dc 100644 --- a/lib/Checker/SVals.cpp +++ b/lib/Checker/SVals.cpp @@ -318,7 +318,8 @@ void NonLoc::dumpToStream(llvm::raw_ostream& os) const { } case nonloc::LazyCompoundValKind: { const nonloc::LazyCompoundVal &C = *cast<nonloc::LazyCompoundVal>(this); - os << "lazyCompoundVal{" << (void*) C.getStore() << ',' << C.getRegion() + os << "lazyCompoundVal{" << const_cast<void *>(C.getStore()) + << ',' << C.getRegion() << '}'; break; } diff --git a/lib/CodeGen/CGObjCGNU.cpp b/lib/CodeGen/CGObjCGNU.cpp index fe99c6ef33..36162f7e5e 100644 --- a/lib/CodeGen/CGObjCGNU.cpp +++ b/lib/CodeGen/CGObjCGNU.cpp @@ -2057,7 +2057,8 @@ llvm::GlobalVariable *CGObjCGNU::ObjCIvarOffsetVariable( if (!IvarOffsetPointer) { uint64_t Offset; if (ObjCImplementationDecl *OID = - CGM.getContext().getObjCImplementation((ObjCInterfaceDecl*)(ID))) + CGM.getContext().getObjCImplementation( + const_cast<ObjCInterfaceDecl *>(ID))) Offset = ComputeIvarBaseOffset(CGM, OID, Ivar); else Offset = ComputeIvarBaseOffset(CGM, ID, Ivar); diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp index 035e57fd0b..9cb27cc101 100644 --- a/lib/CodeGen/CodeGenModule.cpp +++ b/lib/CodeGen/CodeGenModule.cpp @@ -718,7 +718,7 @@ void CodeGenModule::EmitGlobal(GlobalDecl GD) { void CodeGenModule::EmitGlobalDefinition(GlobalDecl GD) { const ValueDecl *D = cast<ValueDecl>(GD.getDecl()); - PrettyStackTraceDecl CrashInfo((ValueDecl *)D, D->getLocation(), + PrettyStackTraceDecl CrashInfo(const_cast<ValueDecl *>(D), D->getLocation(), Context.getSourceManager(), "Generating code for declaration"); diff --git a/lib/Frontend/ASTUnit.cpp b/lib/Frontend/ASTUnit.cpp index 427bd6a9b8..0f7dca2d6b 100644 --- a/lib/Frontend/ASTUnit.cpp +++ b/lib/Frontend/ASTUnit.cpp @@ -431,8 +431,10 @@ ASTUnit *ASTUnit::LoadFromCommandLine(const char **ArgBegin, const driver::ArgStringList &CCArgs = Cmd->getArguments(); llvm::OwningPtr<CompilerInvocation> CI(new CompilerInvocation); - CompilerInvocation::CreateFromArgs(*CI, (const char**) CCArgs.data(), - (const char**) CCArgs.data()+CCArgs.size(), + CompilerInvocation::CreateFromArgs(*CI, + const_cast<const char **>(CCArgs.data()), + const_cast<const char **>(CCArgs.data()) + + CCArgs.size(), *Diags); // Override any files that need remapping diff --git a/lib/Frontend/CodeGenAction.cpp b/lib/Frontend/CodeGenAction.cpp index fdce21170e..80b00389fb 100644 --- a/lib/Frontend/CodeGenAction.cpp +++ b/lib/Frontend/CodeGenAction.cpp @@ -302,7 +302,7 @@ bool BackendConsumer::AddEmitPasses() { BackendArgs.push_back("-time-passes"); BackendArgs.push_back(0); llvm::cl::ParseCommandLineOptions(BackendArgs.size() - 1, - (char**) &BackendArgs[0]); + const_cast<char **>(&BackendArgs[0])); std::string FeaturesStr; if (TargetOpts.CPU.size() || TargetOpts.Features.size()) { diff --git a/lib/Frontend/InitHeaderSearch.cpp b/lib/Frontend/InitHeaderSearch.cpp index b675df05ff..1a0ddf0e9b 100644 --- a/lib/Frontend/InitHeaderSearch.cpp +++ b/lib/Frontend/InitHeaderSearch.cpp @@ -355,7 +355,7 @@ static bool getVisualStudioDir(std::string &path) { else if (vs80comntools) vscomntools = vs80comntools; if (vscomntools && *vscomntools) { - char *p = (char*)strstr(vscomntools, "\\Common7\\Tools"); + char *p = const_cast<char *>(strstr(vscomntools, "\\Common7\\Tools")); if (p) *p = '\0'; path = vscomntools; diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp index dc0d39a5f4..9a3827e1ca 100644 --- a/lib/Sema/SemaType.cpp +++ b/lib/Sema/SemaType.cpp @@ -1042,7 +1042,8 @@ QualType Sema::GetTypeForDeclarator(Declarator &D, Scope *S, if (getLangOptions().ObjC1 && T->isObjCInterfaceType()) { const ObjCInterfaceType *OIT = T->getAs<ObjCInterfaceType>(); T = Context.getObjCObjectPointerType(T, - (ObjCProtocolDecl **)OIT->qual_begin(), + const_cast<ObjCProtocolDecl **>( + OIT->qual_begin()), OIT->getNumProtocols(), DeclType.Ptr.TypeQuals); break; diff --git a/tools/driver/cc1_main.cpp b/tools/driver/cc1_main.cpp index 41f2997e20..144a734b15 100644 --- a/tools/driver/cc1_main.cpp +++ b/tools/driver/cc1_main.cpp @@ -251,7 +251,7 @@ int cc1_main(const char **ArgBegin, const char **ArgEnd, for (unsigned i = 0; i != NumArgs; ++i) Args[i + 1] = Clang->getFrontendOpts().LLVMArgs[i].c_str(); Args[NumArgs + 1] = 0; - llvm::cl::ParseCommandLineOptions(NumArgs + 1, (char**) Args); + llvm::cl::ParseCommandLineOptions(NumArgs + 1, const_cast<char **>(Args)); } // Create the actual diagnostics engine. |