From: Dmitri Gribenko Date: Fri, 11 Jan 2013 23:08:18 +0000 (+0000) Subject: libclang: constness for CXString X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=689d747a498e7ead320af1fc84ed08050acbd527;p=clang libclang: constness for CXString git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172270 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang-c/CXString.h b/include/clang-c/CXString.h index 74c31660ef..34cab5e7bd 100644 --- a/include/clang-c/CXString.h +++ b/include/clang-c/CXString.h @@ -36,7 +36,7 @@ extern "C" { * with the string data, call \c clang_disposeString() to free the string. */ typedef struct { - void *data; + const void *data; unsigned private_flags; } CXString; diff --git a/tools/libclang/CXString.cpp b/tools/libclang/CXString.cpp index c4ab3f4f1b..1c49e2c2d8 100644 --- a/tools/libclang/CXString.cpp +++ b/tools/libclang/CXString.cpp @@ -35,7 +35,7 @@ CXString cxstring::createCXString(const char *String, bool DupString){ Str.data = strdup(String); Str.private_flags = (unsigned) CXS_Malloc; } else { - Str.data = (void*)String; + Str.data = String; Str.private_flags = (unsigned) CXS_Unmanaged; } return Str; @@ -50,7 +50,7 @@ CXString cxstring::createCXString(StringRef String, bool DupString) { Result.data = Spelling; Result.private_flags = (unsigned) CXS_Malloc; } else { - Result.data = (void*) String.data(); + Result.data = String.data(); Result.private_flags = (unsigned) CXS_Unmanaged; } return Result; @@ -123,7 +123,7 @@ void clang_disposeString(CXString string) { break; case CXS_Malloc: if (string.data) - free((void*)string.data); + free(const_cast(string.data)); break; case CXS_StringBuf: disposeCXStringBuf((CXStringBuf *) string.data);