[cfe-commits] r78393 - in /cfe/trunk: include/clang/AST/ASTContext.h lib/AST/ASTContext.cpp lib/AST/DeclCXX.cpp lib/CodeGen/CGCXX.cpp lib/CodeGen/CodeGenTypes.cpp

Mike Stump mrs at apple.com
Fri Aug 7 11:05:12 PDT 2009


Author: mrs
Date: Fri Aug  7 13:05:12 2009
New Revision: 78393

URL: http://llvm.org/viewvc/llvm-project?rev=78393&view=rev
Log:
Fix some const_cast issues.  This is the beginning of the rabbit hole.

Modified:
    cfe/trunk/include/clang/AST/ASTContext.h
    cfe/trunk/lib/AST/ASTContext.cpp
    cfe/trunk/lib/AST/DeclCXX.cpp
    cfe/trunk/lib/CodeGen/CGCXX.cpp
    cfe/trunk/lib/CodeGen/CodeGenTypes.cpp

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=78393&r1=78392&r2=78393&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Fri Aug  7 13:05:12 2009
@@ -444,7 +444,7 @@
   
   /// getTagDeclType - Return the unique reference to the type for the
   /// specified TagDecl (struct/union/class/enum) decl.
-  QualType getTagDeclType(TagDecl *Decl);
+  QualType getTagDeclType(const TagDecl *Decl);
   
   /// getSizeType - Return the unique type for "size_t" (C99 7.17), defined
   /// in <stddef.h>. The sizeof operator requires this (C99 6.5.3.4p4).

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=78393&r1=78392&r2=78393&view=diff

==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Fri Aug  7 13:05:12 2009
@@ -2029,9 +2029,11 @@
 
 /// getTagDeclType - Return the unique reference to the type for the
 /// specified TagDecl (struct/union/class/enum) decl.
-QualType ASTContext::getTagDeclType(TagDecl *Decl) {
+QualType ASTContext::getTagDeclType(const TagDecl *Decl) {
   assert (Decl);
-  return getTypeDeclType(Decl);
+  // FIXME: What is the design on getTagDeclType when it requires casting
+  // away const?  mutable?
+  return getTypeDeclType(const_cast<TagDecl*>(Decl));
 }
 
 /// getSizeType - Return the unique type for "size_t" (C99 7.17), the result 

Modified: cfe/trunk/lib/AST/DeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclCXX.cpp?rev=78393&r1=78392&r2=78393&view=diff

==============================================================================
--- cfe/trunk/lib/AST/DeclCXX.cpp (original)
+++ cfe/trunk/lib/AST/DeclCXX.cpp Fri Aug  7 13:05:12 2009
@@ -379,9 +379,7 @@
   if (ClassTemplateDecl *TD = getParent()->getDescribedClassTemplate())
     ClassTy = TD->getInjectedClassNameType(C);
   else
-    // FIXME: What is the design on getTagDeclType when it requires casting
-    // away const?  mutable?
-    ClassTy = C.getTagDeclType(const_cast<CXXRecordDecl*>(getParent()));
+    ClassTy = C.getTagDeclType(getParent());
   ClassTy = ClassTy.getWithAdditionalQualifiers(getTypeQualifiers());
   return C.getPointerType(ClassTy);
 }
@@ -466,10 +464,9 @@
     return false;
 
   // Is it a reference to our class type?
-  QualType PointeeType 
+  QualType PointeeType
     = Context.getCanonicalType(ParamRefType->getPointeeType());
-  QualType ClassTy 
-    = Context.getTagDeclType(const_cast<CXXRecordDecl*>(getParent()));
+  QualType ClassTy = Context.getTagDeclType(getParent());
   if (PointeeType.getUnqualifiedType() != ClassTy)
     return false;
 

Modified: cfe/trunk/lib/CodeGen/CGCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCXX.cpp?rev=78393&r1=78392&r2=78393&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCXX.cpp Fri Aug  7 13:05:12 2009
@@ -506,9 +506,7 @@
   llvm::SmallString<256> OutName;
   llvm::raw_svector_ostream Out(OutName);
   QualType ClassTy;
-  // FIXME: What is the design on getTagDeclType when it requires casting
-  // away const?  mutable?
-  ClassTy = getContext().getTagDeclType(const_cast<CXXRecordDecl*>(RD));
+  ClassTy = getContext().getTagDeclType(RD);
   mangleCXXRtti(ClassTy, getContext(), Out);
   const char *Name = OutName.c_str();
   llvm::GlobalVariable::LinkageTypes linktype;
@@ -599,9 +597,7 @@
   llvm::SmallString<256> OutName;
   llvm::raw_svector_ostream Out(OutName);
   QualType ClassTy;
-  // FIXME: What is the design on getTagDeclType when it requires casting
-  // away const?  mutable?
-  ClassTy = getContext().getTagDeclType(const_cast<CXXRecordDecl*>(RD));
+  ClassTy = getContext().getTagDeclType(RD);
   mangleCXXVtable(ClassTy, getContext(), Out);
   const char *Name = OutName.c_str();
   llvm::GlobalVariable::LinkageTypes linktype;

Modified: cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenTypes.cpp?rev=78393&r1=78392&r2=78393&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenTypes.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenTypes.cpp Fri Aug  7 13:05:12 2009
@@ -121,8 +121,7 @@
 /// UpdateCompletedType - When we find the full definition for a TagDecl,
 /// replace the 'opaque' type we previously made for it if applicable.
 void CodeGenTypes::UpdateCompletedType(const TagDecl *TD) {
-  const Type *Key = 
-    Context.getTagDeclType(const_cast<TagDecl*>(TD)).getTypePtr();
+  const Type *Key = Context.getTagDeclType(TD).getTypePtr();
   llvm::DenseMap<const Type*, llvm::PATypeHolder>::iterator TDTI = 
     TagDeclTypes.find(Key);
   if (TDTI == TagDeclTypes.end()) return;
@@ -395,7 +394,7 @@
   // TagDecl's are not necessarily unique, instead use the (clang)
   // type connected to the decl.
   const Type *Key = 
-    Context.getTagDeclType(const_cast<TagDecl*>(TD)).getTypePtr();
+    Context.getTagDeclType(TD).getTypePtr();
   llvm::DenseMap<const Type*, llvm::PATypeHolder>::iterator TDTI = 
     TagDeclTypes.find(Key);
   
@@ -478,7 +477,7 @@
 const CGRecordLayout *
 CodeGenTypes::getCGRecordLayout(const TagDecl *TD) const {
   const Type *Key = 
-    Context.getTagDeclType(const_cast<TagDecl*>(TD)).getTypePtr();
+    Context.getTagDeclType(TD).getTypePtr();
   llvm::DenseMap<const Type*, CGRecordLayout *>::iterator I
     = CGRecordLayouts.find(Key);
   assert (I != CGRecordLayouts.end() 





More information about the cfe-commits mailing list