[cfe-commits] r96439 - in /cfe/trunk: include/clang-c/Index.h tools/CIndex/CIndexCodeCompletion.cpp tools/c-index-test/c-index-test.c
Ted Kremenek
kremenek at apple.com
Tue Feb 16 17:42:24 PST 2010
Author: kremenek
Date: Tue Feb 16 19:42:24 2010
New Revision: 96439
URL: http://llvm.org/viewvc/llvm-project?rev=96439&view=rev
Log:
Convert clang_getCompletionChunkText() to return a CXString.
Modified:
cfe/trunk/include/clang-c/Index.h
cfe/trunk/tools/CIndex/CIndexCodeCompletion.cpp
cfe/trunk/tools/c-index-test/c-index-test.c
Modified: cfe/trunk/include/clang-c/Index.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=96439&r1=96438&r2=96439&view=diff
==============================================================================
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Tue Feb 16 19:42:24 2010
@@ -1478,7 +1478,7 @@
*
* \returns the text associated with the chunk at index \c chunk_number.
*/
-CINDEX_LINKAGE const char *
+CINDEX_LINKAGE CXString
clang_getCompletionChunkText(CXCompletionString completion_string,
unsigned chunk_number);
Modified: cfe/trunk/tools/CIndex/CIndexCodeCompletion.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/CIndex/CIndexCodeCompletion.cpp?rev=96439&r1=96438&r2=96439&view=diff
==============================================================================
--- cfe/trunk/tools/CIndex/CIndexCodeCompletion.cpp (original)
+++ cfe/trunk/tools/CIndex/CIndexCodeCompletion.cpp Tue Feb 16 19:42:24 2010
@@ -21,6 +21,7 @@
#include "llvm/System/Program.h"
using namespace clang;
+using namespace clang::cxstring;
extern "C" {
@@ -80,11 +81,11 @@
return CXCompletionChunk_Text;
}
-const char *clang_getCompletionChunkText(CXCompletionString completion_string,
- unsigned chunk_number) {
+CXString clang_getCompletionChunkText(CXCompletionString completion_string,
+ unsigned chunk_number) {
CodeCompletionString *CCStr = (CodeCompletionString *)completion_string;
if (!CCStr || chunk_number >= CCStr->size())
- return 0;
+ return createCXString(0);
switch ((*CCStr)[chunk_number].Kind) {
case CodeCompletionString::CK_TypedText:
@@ -107,17 +108,18 @@
case CodeCompletionString::CK_Equal:
case CodeCompletionString::CK_HorizontalSpace:
case CodeCompletionString::CK_VerticalSpace:
- return (*CCStr)[chunk_number].Text;
+ return createCXString((*CCStr)[chunk_number].Text, false);
case CodeCompletionString::CK_Optional:
// Note: treated as an empty text block.
- return "";
+ return createCXString("");
}
// Should be unreachable, but let's be careful.
- return 0;
+ return createCXString(0);
}
+
CXCompletionString
clang_getCompletionChunkCompletionString(CXCompletionString completion_string,
unsigned chunk_number) {
Modified: cfe/trunk/tools/c-index-test/c-index-test.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-index-test/c-index-test.c?rev=96439&r1=96438&r2=96439&view=diff
==============================================================================
--- cfe/trunk/tools/c-index-test/c-index-test.c (original)
+++ cfe/trunk/tools/c-index-test/c-index-test.c Tue Feb 16 19:42:24 2010
@@ -755,7 +755,8 @@
N = clang_getNumCompletionChunks(completion_string);
for (I = 0; I != N; ++I) {
- const char *text = 0;
+ CXString text;
+ const char *cstr;
enum CXCompletionChunkKind Kind
= clang_getCompletionChunkKind(completion_string, I);
@@ -769,10 +770,13 @@
}
text = clang_getCompletionChunkText(completion_string, I);
+ cstr = clang_getCString(text);
fprintf(file, "{%s %s}",
clang_getCompletionChunkKindSpelling(Kind),
- text? text : "");
+ cstr ? cstr : "");
+ clang_disposeString(text);
}
+
}
void print_completion_result(CXCompletionResult *completion_result,
More information about the cfe-commits
mailing list