зеркало из https://github.com/microsoft/clang-1.git
Improve the const-ness of a few methods.
No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57417 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
42220c5432
Коммит
d2595ecce5
|
@ -99,7 +99,8 @@ protected:
|
|||
: 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 @@ public:
|
|||
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 @@ public:
|
|||
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;
|
||||
|
|
|
@ -299,7 +299,10 @@ protected:
|
|||
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) {
|
||||
|
|
|
@ -344,10 +344,10 @@ DeclContext *Decl::castToDeclContext(const Decl *D) {
|
|||
// 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;
|
||||
|
|
|
@ -54,7 +54,8 @@ CXXMethodDecl::Create(ASTContext &C, CXXRecordDecl *RD,
|
|||
|
||||
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;
|
||||
|
|
Загрузка…
Ссылка в новой задаче