]> granicus.if.org Git - clang/commitdiff
Fix -Wcast-qual warnings.
authorDan Gohman <gohman@apple.com>
Mon, 19 Apr 2010 16:39:44 +0000 (16:39 +0000)
committerDan Gohman <gohman@apple.com>
Mon, 19 Apr 2010 16:39:44 +0000 (16:39 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101786 91177308-0d34-0410-b5e6-96231b3b80d8

12 files changed:
include/clang/AST/APValue.h
lib/AST/APValue.cpp
lib/AST/ASTContext.cpp
lib/AST/RecordLayoutBuilder.cpp
lib/Checker/SVals.cpp
lib/CodeGen/CGObjCGNU.cpp
lib/CodeGen/CodeGenModule.cpp
lib/Frontend/ASTUnit.cpp
lib/Frontend/CodeGenAction.cpp
lib/Frontend/InitHeaderSearch.cpp
lib/Sema/SemaType.cpp
tools/driver/cc1_main.cpp

index 9d4bff893f02f96be5f90be179a6d78c9f88db80..5effa9057a4e13ee7a61e15deade5de21c3d29d0 100644 (file)
@@ -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() {
index 50a6e0a50d8bf6a9de57f6c2dd3c639f0a68dfa1..731d5e046681c759e3b665edd9b81d1ea27581b3 100644 (file)
@@ -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())
index 68620dc346bdceb11c570b5b1cd316baeb7c5c3a..a3c08d56b0452a16d3d62402caa13cdb25674094 100644 (file)
@@ -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]);
index a674ad797091c211f679d8434d95f1eb2024a2b8..3038d912fc32cbce2f9a9b974e1532467a4686a2 100644 (file)
@@ -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())
index 4bfa2cdafb460ec20911973741de463ec04f808a..d756be70dc25e1037f15f315a0e296788f8d9ad1 100644 (file)
@@ -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;
     }
index fe99c6ef3358307949eb86f45d9d4cbdffd518b6..36162f7e5e520ede1b90741b01a38f6e2f473668 100644 (file)
@@ -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);
index 035e57fd0b29be1cc2b10f23ac366104c5468b6d..9cb27cc1010b85b4eb001eceba983b929e40e3e2 100644 (file)
@@ -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");
   
index 427bd6a9b8035188f5c011cda6c37a83649ca7b5..0f7dca2d6b5ccd0ec3368fa5a57c6fb8ecbf11b6 100644 (file)
@@ -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
index fdce21170e315bff17fa3d19de320d3cd76e3b35..80b00389fb4057babec9dd92b07011b26f5edccb 100644 (file)
@@ -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()) {
index b675df05ff1286f038f08a20d9e6ab28fdd0ace5..1a0ddf0e9bff09a642e4db04d439612bcb4ecb42 100644 (file)
@@ -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;
index dc0d39a5f4c9922684d649336f68976eb356e519..9a3827e1cab581e7f8dbee1096242267b2dabd6f 100644 (file)
@@ -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;
index 41f2997e20075da3e267adda2688f740e301fb00..144a734b151d12faa3f1296e25f77c304bff8dc4 100644 (file)
@@ -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.