From: Chris Lattner Date: Sun, 6 Apr 2008 04:11:27 +0000 (+0000) Subject: fix a number of const qualification bugs. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e0def7589a8afa8a6acef13476bb3f882c104b91;p=clang fix a number of const qualification bugs. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49257 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/DeclObjC.h b/include/clang/AST/DeclObjC.h index d225093456..9930f1cc3b 100644 --- a/include/clang/AST/DeclObjC.h +++ b/include/clang/AST/DeclObjC.h @@ -125,7 +125,10 @@ public: NamedDecl *getMethodContext() const { return MethodContext; } - ObjCInterfaceDecl *const getClassInterface() const; + const ObjCInterfaceDecl *getClassInterface() const; + ObjCInterfaceDecl *getClassInterface() { + return (ObjCInterfaceDecl*)((ObjCMethodDecl*)this)->getClassInterface(); + } Selector getSelector() const { return SelName; } unsigned getSynthesizedMethodSize() const; @@ -161,10 +164,12 @@ public: ImplementationControl getImplementationControl() const { return ImplementationControl(DeclImplementation); } - Stmt *const getBody() const { return Body; } + Stmt *getBody() { return Body; } + const Stmt *getBody() const { return Body; } void setBody(Stmt *B) { Body = B; } - ParmVarDecl *const getSelfDecl() const { return SelfDecl; } + const ParmVarDecl *getSelfDecl() const { return SelfDecl; } + ParmVarDecl *getSelfDecl() { return SelfDecl; } void setSelfDecl(ParmVarDecl *PVD) { SelfDecl = PVD; } // Implement isa/cast/dyncast/etc. @@ -655,7 +660,8 @@ public: static ObjCCategoryDecl *Create(ASTContext &C, SourceLocation L, IdentifierInfo *Id); - ObjCInterfaceDecl *getClassInterface() const { return ClassInterface; } + ObjCInterfaceDecl *getClassInterface() { return ClassInterface; } + const ObjCInterfaceDecl *getClassInterface() const { return ClassInterface; } void setClassInterface(ObjCInterfaceDecl *IDecl) { ClassInterface = IDecl; } void setReferencedProtocolList(ObjCProtocolDecl **List, unsigned NumRPs); @@ -746,7 +752,8 @@ public: SourceLocation L, IdentifierInfo *Id, ObjCInterfaceDecl *classInterface); - ObjCInterfaceDecl *getClassInterface() const { return ClassInterface; } + const ObjCInterfaceDecl *getClassInterface() const { return ClassInterface; } + ObjCInterfaceDecl *getClassInterface() { return ClassInterface; } unsigned getNumInstanceMethods() const { return InstanceMethods.size(); } unsigned getNumClassMethods() const { return ClassMethods.size(); } @@ -844,8 +851,10 @@ public: SourceLocation getLocEnd() const { return EndLoc; } void setLocEnd(SourceLocation LE) { EndLoc = LE; }; - ObjCInterfaceDecl *getClassInterface() const { return ClassInterface; } - ObjCInterfaceDecl *getSuperClass() const { return SuperClass; } + const ObjCInterfaceDecl *getClassInterface() const { return ClassInterface; } + ObjCInterfaceDecl *getClassInterface() { return ClassInterface; } + const ObjCInterfaceDecl *getSuperClass() const { return SuperClass; } + ObjCInterfaceDecl *getSuperClass() { return SuperClass; } void setSuperClass(ObjCInterfaceDecl * superCls) { SuperClass = superCls; } diff --git a/include/clang/AST/Expr.h b/include/clang/AST/Expr.h index 7d1e7929b6..b88d5bdac3 100644 --- a/include/clang/AST/Expr.h +++ b/include/clang/AST/Expr.h @@ -1458,10 +1458,11 @@ public: ObjCIvarDecl *getDecl() { return D; } const ObjCIvarDecl *getDecl() const { return D; } virtual SourceRange getSourceRange() const { return SourceRange(Loc); } - Expr *const getBase() const { return Base; } + const Expr *getBase() const { return Base; } + Expr *getBase() { return Base; } void setBase(Expr * base) { Base = base; } - const bool isArrow() const { return IsArrow; } - const bool isFreeIvar() const { return IsFreeIvar; } + bool isArrow() const { return IsArrow; } + bool isFreeIvar() const { return IsFreeIvar; } SourceLocation getLocation() const { return Loc; } diff --git a/include/clang/AST/Stmt.h b/include/clang/AST/Stmt.h index 78d2ffeab3..8a882dfd99 100644 --- a/include/clang/AST/Stmt.h +++ b/include/clang/AST/Stmt.h @@ -1041,7 +1041,8 @@ public: AtThrowLoc = atThrowLoc; } - Expr *const getThrowExpr() const { return reinterpret_cast(Throw); } + const Expr *getThrowExpr() const { return reinterpret_cast(Throw); } + Expr *getThrowExpr() { return reinterpret_cast(Throw); } virtual SourceRange getSourceRange() const { if (Throw) diff --git a/include/clang/Analysis/Support/ExprDeclBitVector.h b/include/clang/Analysis/Support/ExprDeclBitVector.h index e54bacae7b..5796fb39a7 100644 --- a/include/clang/Analysis/Support/ExprDeclBitVector.h +++ b/include/clang/Analysis/Support/ExprDeclBitVector.h @@ -102,7 +102,7 @@ struct DeclBitVector_Types { return DeclBV[i]; } - const bool getBit(unsigned i) const { + bool getBit(unsigned i) const { return DeclBV[i]; } diff --git a/lib/AST/DeclObjC.cpp b/lib/AST/DeclObjC.cpp index a01c3042d3..5671dbe9b9 100644 --- a/lib/AST/DeclObjC.cpp +++ b/lib/AST/DeclObjC.cpp @@ -418,7 +418,7 @@ unsigned ObjCMethodDecl::getSynthesizedMethodSize() const { return length; } -ObjCInterfaceDecl *const ObjCMethodDecl::getClassInterface() const { +const ObjCInterfaceDecl *ObjCMethodDecl::getClassInterface() const { if (ObjCInterfaceDecl *ID = dyn_cast(MethodContext)) return ID; if (ObjCCategoryDecl *CD = dyn_cast(MethodContext))