CXCompletionString clang_getCursorCompletionString(CXCursor cursor) { enum CXCursorKind kind = clang_getCursorKind(cursor); if (clang_isDeclaration(kind)) { const Decl *decl = getCursorDecl(cursor); if (const NamedDecl *namedDecl = dyn_cast_or_null<NamedDecl>(decl)) { ASTUnit *unit = getCursorASTUnit(cursor); CodeCompletionResult Result(namedDecl, CCP_Declaration); CodeCompletionString *String = Result.CreateCodeCompletionString(unit->getASTContext(), unit->getPreprocessor(), unit->getCodeCompletionTUInfo().getAllocator(), unit->getCodeCompletionTUInfo(), true); return String; } } else if (kind == CXCursor_MacroDefinition) { const MacroDefinition *definition = getCursorMacroDefinition(cursor); const IdentifierInfo *MacroInfo = definition->getName(); ASTUnit *unit = getCursorASTUnit(cursor); CodeCompletionResult Result(MacroInfo); CodeCompletionString *String = Result.CreateCodeCompletionString(unit->getASTContext(), unit->getPreprocessor(), unit->getCodeCompletionTUInfo().getAllocator(), unit->getCodeCompletionTUInfo(), false); return String; } return NULL; }