[cfe-commits] r86438 - in /cfe/trunk/tools: CIndex/CIndex.cpp c-index-test/c-index-test.c
Daniel Dunbar
daniel at zuster.org
Sat Nov 7 20:11:32 PST 2009
Author: ddunbar
Date: Sat Nov 7 22:11:32 2009
New Revision: 86438
URL: http://llvm.org/viewvc/llvm-project?rev=86438&view=rev
Log:
CIndex: Add temporary hack to leak memory instead of returning invalid pointers.
Modified:
cfe/trunk/tools/CIndex/CIndex.cpp
cfe/trunk/tools/c-index-test/c-index-test.c
Modified: cfe/trunk/tools/CIndex/CIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/CIndex/CIndex.cpp?rev=86438&r1=86437&r2=86438&view=diff
==============================================================================
--- cfe/trunk/tools/CIndex/CIndex.cpp (original)
+++ cfe/trunk/tools/CIndex/CIndex.cpp Sat Nov 7 22:11:32 2009
@@ -552,7 +552,8 @@
NamedDecl *ND = static_cast<NamedDecl *>(AnonDecl);
if (ObjCMethodDecl *OMD = dyn_cast<ObjCMethodDecl>(ND)) {
- return OMD->getSelector().getAsString().c_str();
+ // FIXME: Memory leak! We need to move to a CXString or other API.
+ return ::strdup(OMD->getSelector().getAsString().c_str());
}
if (ObjCCategoryImplDecl *CIMP = dyn_cast<ObjCCategoryImplDecl>(ND))
// No, this isn't the same as the code below. getIdentifier() is non-virtual
@@ -650,7 +651,8 @@
ObjCMessageExpr *OME = dyn_cast<ObjCMessageExpr>(
static_cast<Stmt *>(C.stmt));
assert(OME && "clang_getCursorLine(): Missing message expr");
- return OME->getSelector().getAsString().c_str();
+ // FIXME: Memory leak! We need to move to a CXString or other API.
+ return ::strdup(OME->getSelector().getAsString().c_str());
}
case CXCursor_VarRef:
case CXCursor_FunctionRef:
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=86438&r1=86437&r2=86438&view=diff
==============================================================================
--- cfe/trunk/tools/c-index-test/c-index-test.c (original)
+++ cfe/trunk/tools/c-index-test/c-index-test.c Sat Nov 7 22:11:32 2009
@@ -4,6 +4,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
+#include <assert.h>
#ifdef _MSC_VER
char *basename(const char* path)
@@ -86,7 +87,7 @@
printf("// CHECK: %s:%d:%d: ", basename(clang_getCursorSource(Ref)),
curLine, curColumn);
PrintCursor(Ref);
- printf(" [Context:%s]\n", clang_getDeclSpelling(Ref.decl));
+ printf(" [Context:%s]\n", clang_getDeclSpelling(Ref.decl));
}
startBuf++;
}
More information about the cfe-commits
mailing list