From: Dmitri Gribenko Date: Mon, 14 Jan 2013 00:46:27 +0000 (+0000) Subject: libclang: remove a few const_casts X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=05756dc8d11cd2054e0cb94f0302e4eb39acc68e;p=clang libclang: remove a few const_casts git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172373 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp index 33811d0fb7..7b271dcd50 100644 --- a/tools/libclang/CIndex.cpp +++ b/tools/libclang/CIndex.cpp @@ -4462,7 +4462,7 @@ CXCursor clang_getCursorDefinition(CXCursor C) { case Decl::CXXConversion: { const FunctionDecl *Def = 0; if (cast(D)->getBody(Def)) - return MakeCXCursor(const_cast(Def), TU); + return MakeCXCursor(Def, TU); return clang_getNullCursor(); } diff --git a/tools/libclang/CXCursor.cpp b/tools/libclang/CXCursor.cpp index 7134dc4189..bdd06bd334 100644 --- a/tools/libclang/CXCursor.cpp +++ b/tools/libclang/CXCursor.cpp @@ -53,7 +53,7 @@ static CXCursorKind GetCursorKind(const Attr *A) { return CXCursor_UnexposedAttr; } -CXCursor cxcursor::MakeCXCursor(const Attr *A, Decl *Parent, +CXCursor cxcursor::MakeCXCursor(const Attr *A, const Decl *Parent, CXTranslationUnit TU) { assert(A && Parent && TU && "Invalid arguments!"); CXCursor C = { GetCursorKind(A), 0, { Parent, A, TU } }; @@ -89,7 +89,7 @@ CXCursor cxcursor::MakeCXCursor(const Decl *D, CXTranslationUnit TU, return C; } -CXCursor cxcursor::MakeCXCursor(const Stmt *S, Decl *Parent, +CXCursor cxcursor::MakeCXCursor(const Stmt *S, const Decl *Parent, CXTranslationUnit TU, SourceRange RegionOfInterest) { assert(S && TU && "Invalid arguments!"); @@ -830,7 +830,7 @@ void cxcursor::getOverriddenCursors(CXCursor cursor, for (SmallVector::iterator I = OverDecls.begin(), E = OverDecls.end(); I != E; ++I) { - overridden.push_back(MakeCXCursor(const_cast(*I), TU)); + overridden.push_back(MakeCXCursor(*I, TU)); } } diff --git a/tools/libclang/CXCursor.h b/tools/libclang/CXCursor.h index 79892f4d29..880b6643d8 100644 --- a/tools/libclang/CXCursor.h +++ b/tools/libclang/CXCursor.h @@ -48,12 +48,12 @@ namespace cxcursor { CXCursor getCursor(CXTranslationUnit, SourceLocation); -CXCursor MakeCXCursor(const clang::Attr *A, clang::Decl *Parent, +CXCursor MakeCXCursor(const clang::Attr *A, const clang::Decl *Parent, CXTranslationUnit TU); CXCursor MakeCXCursor(const clang::Decl *D, CXTranslationUnit TU, SourceRange RegionOfInterest = SourceRange(), bool FirstInDeclGroup = true); -CXCursor MakeCXCursor(const clang::Stmt *S, clang::Decl *Parent, +CXCursor MakeCXCursor(const clang::Stmt *S, const clang::Decl *Parent, CXTranslationUnit TU, SourceRange RegionOfInterest = SourceRange()); CXCursor MakeCXCursorInvalid(CXCursorKind K, CXTranslationUnit TU = 0); diff --git a/tools/libclang/IndexingContext.cpp b/tools/libclang/IndexingContext.cpp index 3a73aee59f..43eeb44ef0 100644 --- a/tools/libclang/IndexingContext.cpp +++ b/tools/libclang/IndexingContext.cpp @@ -69,7 +69,7 @@ AttrListInfo::AttrListInfo(const Decl *D, IndexingContext &IdxCtx) for (AttrVec::const_iterator AttrI = D->attr_begin(), AttrE = D->attr_end(); AttrI != AttrE; ++AttrI) { const Attr *A = *AttrI; - CXCursor C = MakeCXCursor(A, const_cast(D), IdxCtx.CXTU); + CXCursor C = MakeCXCursor(A, D, IdxCtx.CXTU); CXIdxLoc Loc = IdxCtx.getIndexLoc(A->getLocation()); switch (C.kind) { default: @@ -644,8 +644,7 @@ bool IndexingContext::handleReference(const NamedDecl *D, SourceLocation Loc, if (!D) return false; - CXCursor Cursor = E ? MakeCXCursor(const_cast(E), - const_cast(cast(DC)), CXTU) + CXCursor Cursor = E ? MakeCXCursor(E, cast(DC), CXTU) : getRefCursor(D, Loc); return handleReference(D, Loc, Cursor, Parent, DC, E, Kind); }