: 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; }
bool isBlockVarDecl() const {
if (getKind() != Decl::Var)
return false;
- if (DeclContext *DC = getDeclContext())
+ if (const DeclContext *DC = getDeclContext())
return DC->isFunctionOrMethod();
return false;
}
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;
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) {
// 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;
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;