Use const_cast<> to avoid a cast-away-const error.
---
llvm/tools/clang/tools/libclang/CXCursor.cpp | 26 +++++++++++++++++---------
1 files changed, 17 insertions(+), 9 deletions(-)
diff --git a/llvm/tools/clang/tools/libclang/CXCursor.cpp b/llvm/tools/clang/tools/libclang/CXCursor.cpp
index 9508962..67d4630 100644
--- a/llvm/tools/clang/tools/libclang/CXCursor.cpp
+++ b/llvm/tools/clang/tools/libclang/CXCursor.cpp
@@ -56,7 +56,7 @@ static CXCursorKind GetCursorKind(const Attr *A) {
CXCursor cxcursor::MakeCXCursor(const Attr *A, Decl *Parent,
CXTranslationUnit TU) {
assert(A && Parent && TU && "Invalid arguments!");
- CXCursor C = { GetCursorKind(A), 0, { Parent, (void*)A, TU } };
+ CXCursor C = { GetCursorKind(A), 0, { Parent, const_cast<Attr *>(A), TU } };
return C;
}
@@ -511,7 +511,8 @@ CXCursor cxcursor::MakeCursorObjCProtocolRef(const ObjCProtocolDecl *Proto,
CXTranslationUnit TU) {
assert(Proto && TU && "Invalid arguments!");
void *RawLoc = reinterpret_cast<void *>(Loc.getRawEncoding());
- CXCursor C = { CXCursor_ObjCProtocolRef, 0, { (void*)Proto, RawLoc, TU } };
+ CXCursor C = { CXCursor_ObjCProtocolRef, 0, {
+ const_cast<ObjCProtocolDecl *>(Proto), RawLoc, TU } };
return C;
}
@@ -531,7 +532,8 @@ CXCursor cxcursor::MakeCursorObjCClassRef(const ObjCInterfaceDecl *Class,
return MakeCXCursorInvalid(CXCursor_InvalidCode);
assert(TU && "Invalid arguments!");
void *RawLoc = reinterpret_cast<void *>(Loc.getRawEncoding());
- CXCursor C = { CXCursor_ObjCClassRef, 0, { (void*)Class, RawLoc, TU } };
+ CXCursor C = { CXCursor_ObjCClassRef, 0, {
+ const_cast<ObjCInterfaceDecl *>(Class), RawLoc, TU } };
return C;
}
@@ -547,7 +549,8 @@ CXCursor cxcursor::MakeCursorTypeRef(const TypeDecl *Type, SourceLocation Loc,
CXTranslationUnit TU) {
assert(Type && TU && "Invalid arguments!");
void *RawLoc = reinterpret_cast<void *>(Loc.getRawEncoding());
- CXCursor C = { CXCursor_TypeRef, 0, { (void*)Type, RawLoc, TU } };
+ CXCursor C = { CXCursor_TypeRef, 0, { const_cast<TypeDecl *>(Type), RawLoc,
+ TU } };
return C;
}
@@ -564,7 +567,8 @@ CXCursor cxcursor::MakeCursorTemplateRef(const TemplateDecl *Template,
CXTranslationUnit TU) {
assert(Template && TU && "Invalid arguments!");
void *RawLoc = reinterpret_cast<void *>(Loc.getRawEncoding());
- CXCursor C = { CXCursor_TemplateRef, 0, { (void*)Template, RawLoc, TU } };
+ CXCursor C = { CXCursor_TemplateRef, 0, {
+ const_cast<TemplateDecl *>(Template), RawLoc, TU } };
return C;
}
@@ -583,7 +587,8 @@ CXCursor cxcursor::MakeCursorNamespaceRef(const NamedDecl *NS,
assert(NS && (isa<NamespaceDecl>(NS) || isa<NamespaceAliasDecl>(NS)) && TU &&
"Invalid arguments!");
void *RawLoc = reinterpret_cast<void *>(Loc.getRawEncoding());
- CXCursor C = { CXCursor_NamespaceRef, 0, { (void*)NS, RawLoc, TU } };
+ CXCursor C = { CXCursor_NamespaceRef, 0, { const_cast<NamedDecl *>(NS),
+ RawLoc, TU } };
return C;
}
@@ -600,7 +605,8 @@ CXCursor cxcursor::MakeCursorVariableRef(const VarDecl *Var, SourceLocation Loc,
assert(Var && TU && "Invalid arguments!");
void *RawLoc = reinterpret_cast<void *>(Loc.getRawEncoding());
- CXCursor C = { CXCursor_VariableRef, 0, { (void*)Var, RawLoc, TU } };
+ CXCursor C = { CXCursor_VariableRef, 0, { const_cast<VarDecl *>(Var), RawLoc,
+ TU } };
return C;
}
@@ -617,7 +623,8 @@ CXCursor cxcursor::MakeCursorMemberRef(const FieldDecl *Field, SourceLocation Lo
assert(Field && TU && "Invalid arguments!");
void *RawLoc = reinterpret_cast<void *>(Loc.getRawEncoding());
- CXCursor C = { CXCursor_MemberRef, 0, { (void*)Field, RawLoc, TU } };
+ CXCursor C = { CXCursor_MemberRef, 0, { const_cast<FieldDecl *>(Field),
+ RawLoc, TU } };
return C;
}
@@ -631,7 +638,8 @@ cxcursor::getCursorMemberRef(CXCursor C) {
CXCursor cxcursor::MakeCursorCXXBaseSpecifier(const CXXBaseSpecifier *B,
CXTranslationUnit TU){
- CXCursor C = { CXCursor_CXXBaseSpecifier, 0, { (void*)B, 0, TU } };
+ CXCursor C = { CXCursor_CXXBaseSpecifier, 0, {
+ const_cast<CXXBaseSpecifier *>(B), 0, TU } };
return C;
}
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits