[cfe-commits] r57417 - in /cfe/trunk: include/clang/AST/Decl.h include/clang/AST/DeclBase.h lib/AST/DeclBase.cpp lib/AST/DeclCXX.cpp
Argiris Kirtzidis
akyrtzi at gmail.com
Sun Oct 12 11:40:02 PDT 2008
Author: akirtzidis
Date: Sun Oct 12 13:40:01 2008
New Revision: 57417
URL: http://llvm.org/viewvc/llvm-project?rev=57417&view=rev
Log:
Improve the const-ness of a few methods.
No functionality change.
Modified:
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/include/clang/AST/DeclBase.h
cfe/trunk/lib/AST/DeclBase.cpp
cfe/trunk/lib/AST/DeclCXX.cpp
Modified: cfe/trunk/include/clang/AST/Decl.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=57417&r1=57416&r2=57417&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Sun Oct 12 13:40:01 2008
@@ -99,7 +99,8 @@
: NamedDecl(DK, L, Id), NextDeclarator(PrevDecl), Next(0), DeclCtx(DC) {}
public:
- DeclContext *getDeclContext() const { return DeclCtx; }
+ const DeclContext *getDeclContext() const { return DeclCtx; }
+ DeclContext *getDeclContext() { return DeclCtx; }
ScopedDecl *getNext() const { return Next; }
void setNext(ScopedDecl *N) { Next = N; }
@@ -311,7 +312,7 @@
bool isBlockVarDecl() const {
if (getKind() != Decl::Var)
return false;
- if (DeclContext *DC = getDeclContext())
+ if (const DeclContext *DC = getDeclContext())
return DC->isFunctionOrMethod();
return false;
}
@@ -1036,7 +1037,8 @@
Args.clear();
Args.insert(Args.begin(), args, args+numargs);
}
- DeclContext *getParentContext() const { return ParentContext; }
+ const DeclContext *getParentContext() const { return ParentContext; }
+ DeclContext *getParentContext() { return ParentContext; }
/// arg_iterator - Iterate over the ParmVarDecl's for this block.
typedef llvm::SmallVector<ParmVarDecl*, 8>::const_iterator param_iterator;
Modified: cfe/trunk/include/clang/AST/DeclBase.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclBase.h?rev=57417&r1=57416&r2=57417&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclBase.h (original)
+++ cfe/trunk/include/clang/AST/DeclBase.h Sun Oct 12 13:40:01 2008
@@ -299,7 +299,10 @@
public:
/// getParent - Returns the containing DeclContext if this is a ScopedDecl,
/// else returns NULL.
- DeclContext *getParent() const;
+ DeclContext *getParent();
+ const DeclContext *getParent() const {
+ return const_cast<DeclContext*>(this)->getParent();
+ }
bool isFunctionOrMethod() const {
switch (DeclKind) {
Modified: cfe/trunk/lib/AST/DeclBase.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclBase.cpp?rev=57417&r1=57416&r2=57417&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclBase.cpp (original)
+++ cfe/trunk/lib/AST/DeclBase.cpp Sun Oct 12 13:40:01 2008
@@ -344,10 +344,10 @@
// DeclContext Implementation
//===----------------------------------------------------------------------===//
-DeclContext *DeclContext::getParent() const {
- if (const ScopedDecl *SD = dyn_cast<ScopedDecl>(this))
+DeclContext *DeclContext::getParent() {
+ if (ScopedDecl *SD = dyn_cast<ScopedDecl>(this))
return SD->getDeclContext();
- else if (const BlockDecl *BD = dyn_cast<BlockDecl>(this))
+ else if (BlockDecl *BD = dyn_cast<BlockDecl>(this))
return BD->getParentContext();
else
return NULL;
Modified: cfe/trunk/lib/AST/DeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclCXX.cpp?rev=57417&r1=57416&r2=57417&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclCXX.cpp (original)
+++ cfe/trunk/lib/AST/DeclCXX.cpp Sun Oct 12 13:40:01 2008
@@ -54,7 +54,8 @@
QualType CXXMethodDecl::getThisType(ASTContext &C) const {
assert(isInstance() && "No 'this' for static methods!");
- QualType ClassTy = C.getTagDeclType(cast<CXXRecordDecl>(getParent()));
+ QualType ClassTy = C.getTagDeclType(const_cast<CXXRecordDecl*>(
+ cast<CXXRecordDecl>(getParent())));
QualType ThisTy = C.getPointerType(ClassTy);
ThisTy.addConst();
return ThisTy;
More information about the cfe-commits
mailing list