• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ clang_getCString函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中clang_getCString函数的典型用法代码示例。如果您正苦于以下问题:C++ clang_getCString函数的具体用法?C++ clang_getCString怎么用?C++ clang_getCString使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了clang_getCString函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: foundChild

enum CXChildVisitResult foundChild(CXCursor cursor, CXCursor parent, CXClientData client_data)
{
    if(clang_getCursorKind(cursor) == CXCursor_CallExpr)
    {
        printf("-%s\n", clang_getCString(clang_getCursorSpelling(cursor)));
    }

    if(clang_isDeclaration(clang_getCursorKind(cursor)) &&
       (clang_getCursorLinkage(cursor) == CXLinkage_External ||
        clang_getCursorLinkage(cursor) == CXLinkage_Internal))
    {
        CXFile file;
        const char * filename, * wantFilename;
        CXSourceLocation cloc;

        cloc = clang_getCursorLocation(cursor);
        clang_getInstantiationLocation(cloc, &file, NULL, NULL, NULL);
        filename = clang_getCString(clang_getFileName(file));
        wantFilename = (const char *)client_data;

        if(!filename || strcmp(wantFilename, filename))
            return CXChildVisit_Recurse;

        if(clang_getCursorLinkage(cursor) == CXLinkage_External)
            printf("+%s\n", clang_getCString(clang_getCursorSpelling(cursor)));
        else
            printf("?%s\n", clang_getCString(clang_getCursorSpelling(cursor)));
    }

    return CXChildVisit_Recurse;
}
开发者ID:hortont424,项目名称:guesscc,代码行数:31,代码来源:symbolScanner.c


示例2: PrintCursor

static void PrintCursor(CXCursor Cursor) {
  if (clang_isInvalid(Cursor.kind)) {
    CXString ks = clang_getCursorKindSpelling(Cursor.kind);
    printf("Invalid Cursor => %s", clang_getCString(ks));
    clang_disposeString(ks);
  }
  else {
    CXString string, ks;
    CXCursor Referenced;
    unsigned line, column;

    ks = clang_getCursorKindSpelling(Cursor.kind);
    string = clang_getCursorSpelling(Cursor);
    printf("%s=%s", clang_getCString(ks),
                    clang_getCString(string));
    clang_disposeString(ks);
    clang_disposeString(string);

    Referenced = clang_getCursorReferenced(Cursor);
    if (!clang_equalCursors(Referenced, clang_getNullCursor())) {
      CXSourceLocation Loc = clang_getCursorLocation(Referenced);
      clang_getInstantiationLocation(Loc, 0, &line, &column, 0);
      printf(":%d:%d", line, column);
    }

    if (clang_isCursorDefinition(Cursor))
      printf(" (Definition)");
  }
}
开发者ID:albertz,项目名称:clang,代码行数:29,代码来源:c-index-test.c


示例3: visit

    virtual enum CXChildVisitResult visit(CXCursor cursor, CXCursor parent) {
        CXFile file;
        unsigned int line, column, offset;
        clang_getInstantiationLocation(
                clang_getCursorLocation(cursor),
                &file, &line, &column, &offset);
        CXCursorKind kind = clang_getCursorKind(cursor);
        const char* cursorFilename = clang_getCString(clang_getFileName(file));

        if (!clang_getFileName(file).data || strcmp(cursorFilename, translationUnitFilename) != 0) {
            return CXChildVisit_Continue;
        }

        CXCursor refCursor = clang_getCursorReferenced(cursor);
        if (!clang_equalCursors(refCursor, clang_getNullCursor())) {
            CXFile refFile;
            unsigned int refLine, refColumn, refOffset;
            clang_getInstantiationLocation(
                    clang_getCursorLocation(refCursor),
                    &refFile, &refLine, &refColumn, &refOffset);

            if (clang_getFileName(refFile).data) {
                std::string referencedUsr(clang_getCString(clang_getCursorUSR(refCursor)));
                if (!referencedUsr.empty()) {
                    std::stringstream ss;
                    ss << cursorFilename
                       << ":" << line << ":" << column << ":" << kind;
                    std::string location(ss.str());
                    usrToReferences[referencedUsr].insert(location);
                }
            }
        }
        return CXChildVisit_Recurse;
    }
开发者ID:gurjeet,项目名称:clang_indexer,代码行数:34,代码来源:clic_add.cpp


示例4: visitor

enum CXChildVisitResult visitor(CXCursor cursor, CXCursor parent, CXClientData data)
{
  enum CXCursorKind cKind = clang_getCursorKind(cursor);
  CXString nameString = clang_getCursorDisplayName(cursor);
  CXString typeString = clang_getCursorKindSpelling(cKind);
  printf("Name:%s, Kind:%s\n", clang_getCString(nameString), clang_getCString(typeString));
  clang_disposeString(nameString);
  clang_disposeString(typeString);
  return CXChildVisit_Continue;
}
开发者ID:Kirill888,项目名称:LibClang,代码行数:10,代码来源:Test_ChildVisitor.c


示例5: PrintDiagnostic

void PrintDiagnostic(CXDiagnostic Diagnostic) {
  FILE *out = stderr;
  CXFile file;
  CXString Msg;
  unsigned display_opts = CXDiagnostic_DisplaySourceLocation
    | CXDiagnostic_DisplayColumn | CXDiagnostic_DisplaySourceRanges;
  unsigned i, num_fixits;

  if (clang_getDiagnosticSeverity(Diagnostic) == CXDiagnostic_Ignored)
    return;

  Msg = clang_formatDiagnostic(Diagnostic, display_opts);
  fprintf(stderr, "%s\n", clang_getCString(Msg));
  clang_disposeString(Msg);

  clang_getInstantiationLocation(clang_getDiagnosticLocation(Diagnostic),
                                 &file, 0, 0, 0);
  if (!file)
    return;

  num_fixits = clang_getDiagnosticNumFixIts(Diagnostic);
  for (i = 0; i != num_fixits; ++i) {
    CXSourceRange range;
    CXString insertion_text = clang_getDiagnosticFixIt(Diagnostic, i, &range);
    CXSourceLocation start = clang_getRangeStart(range);
    CXSourceLocation end = clang_getRangeEnd(range);
    unsigned start_line, start_column, end_line, end_column;
    CXFile start_file, end_file;
    clang_getInstantiationLocation(start, &start_file, &start_line,
                                   &start_column, 0);
    clang_getInstantiationLocation(end, &end_file, &end_line, &end_column, 0);
    if (clang_equalLocations(start, end)) {
      /* Insertion. */
      if (start_file == file)
        fprintf(out, "FIX-IT: Insert \"%s\" at %d:%d\n",
                clang_getCString(insertion_text), start_line, start_column);
    } else if (strcmp(clang_getCString(insertion_text), "") == 0) {
      /* Removal. */
      if (start_file == file && end_file == file) {
        fprintf(out, "FIX-IT: Remove ");
        PrintExtent(out, start_line, start_column, end_line, end_column);
        fprintf(out, "\n");
      }
    } else {
      /* Replacement. */
      if (start_file == end_file) {
        fprintf(out, "FIX-IT: Replace ");
        PrintExtent(out, start_line, start_column, end_line, end_column);
        fprintf(out, " with \"%s\"\n", clang_getCString(insertion_text));
      }
      break;
    }
    clang_disposeString(insertion_text);
  }
}
开发者ID:colgur,项目名称:gaius,代码行数:55,代码来源:index-api-test.c


示例6: QASTNode

QASTField::QASTField(
        QAnnotatedTokenSet *tokenSet,
        QSourceLocation* cursorLocation,
        QSourceLocation* rangeStartLocation,
        QSourceLocation* rangeEndLocation,
        QASTNode* parent)

    : QASTNode("field", tokenSet, cursorLocation, rangeStartLocation, rangeEndLocation, parent){

    // Get Identifier
    // --------------

    CXString id = clang_getCursorSpelling(tokenSet->cursor());
    setIdentifier(clang_getCString(id));

    // Get Field Type
    // ---------------

    CXType type           = clang_getCursorType(tokenSet->cursor());
    CXString typeSpelling = clang_getTypeSpelling(type);
    m_fieldType           = clang_getCString(typeSpelling);
    clang_disposeString(typeSpelling);

    // Determine field type
    // --------------------

    if ( type.kind == CXType_Unexposed || type.kind == CXType_Invalid || m_fieldType.contains("int") ){
        m_fieldType = "";

        bool doubleColonFlag = false;
        for ( QAnnotatedTokenSet::Iterator it = tokenSet->begin(); it != tokenSet->end(); ++it ){

            CXToken t              = (*it)->token().token;
            CXString tSpelling     = clang_getTokenSpelling(tokenSet->translationUnit(), t);
            const char* tCSpelling = clang_getCString(tSpelling);
            CXTokenKind tKind      = clang_getTokenKind(t);

            if ( tKind == CXToken_Identifier && std::string(clang_getCString(id)) == tCSpelling ){
                break;
            } else if ( tKind == CXToken_Punctuation && std::string("::") == tCSpelling ){
                doubleColonFlag = true;
                m_fieldType    += tCSpelling;
            } else if ( ( tKind == CXToken_Identifier || tKind == CXToken_Keyword ) &&
                        !m_fieldType.isEmpty() && !doubleColonFlag ){
                m_fieldType    += QString(" ") + tCSpelling;
            } else {
                doubleColonFlag = false;
                m_fieldType    += tCSpelling;
            }
        }
    }

    clang_disposeString(id);
}
开发者ID:dinusv,项目名称:cpp-snippet-assist,代码行数:54,代码来源:QASTField.cpp


示例7: property_list_builder

enum CXChildVisitResult property_list_builder(CXCursor cursor, CXCursor cursor_parent, CXClientData client_data) {
	ScintillaObject *current_doc_sci = (ScintillaObject *)client_data;
	enum CXCursorKind code_cursor_kind;
	CXSourceLocation code_source_location;
	
	code_source_location = clang_getCursorLocation(cursor);
	code_cursor_kind = clang_getCursorKind(cursor);
	
	if (code_cursor_kind == 1) {
		property_kind = property_helper_get_kind(current_doc_sci,code_source_location);
	} else if (code_cursor_kind == 6) {
		gchar *type = NULL;
		gchar *name = NULL;
		
		type = property_helper_get_type(current_doc_sci,code_source_location);
		name = (gchar *)clang_getCString(clang_getCursorSpelling(cursor));
		
		chunked_property_add(&property_list, type, name, sg_do_getters, sg_do_setters, sg_placement_inner, property_kind);
		
		free(type);
		free(name);
	}
	
	return CXChildVisit_Continue;
}
开发者ID:iamtakingiteasy,项目名称:geany-setters-getters-generator-plugin,代码行数:25,代码来源:setters_getters.c


示例8: print_completion_string

void print_completion_string(CXCompletionString completion_string, FILE *file) {
  int I, N;

  N = clang_getNumCompletionChunks(completion_string);
  for (I = 0; I != N; ++I) {
    CXString text;
    const char *cstr;
    enum CXCompletionChunkKind Kind
      = clang_getCompletionChunkKind(completion_string, I);

    if (Kind == CXCompletionChunk_Optional) {
      fprintf(file, "{Optional ");
      print_completion_string(
                clang_getCompletionChunkCompletionString(completion_string, I),
                              file);
      fprintf(file, "}");
      continue;
    }

    text = clang_getCompletionChunkText(completion_string, I);
    cstr = clang_getCString(text);
    fprintf(file, "{%s %s}",
            clang_getCompletionChunkKindSpelling(Kind),
            cstr ? cstr : "");
    clang_disposeString(text);
  }

}
开发者ID:albertz,项目名称:clang,代码行数:28,代码来源:c-index-test.c


示例9: getQString

QString getQString(const CXString &cxString, bool disposeCXString)
{
    QString s = QString::fromUtf8(clang_getCString(cxString));
    if (disposeCXString)
        clang_disposeString(cxString);
    return s;
}
开发者ID:FlavioFalcao,项目名称:qt-creator,代码行数:7,代码来源:utils_p.cpp


示例10: completion_doSyntaxCheck

/* Handle syntax checking request, message format:
       source_length: [#src_length#]
       <# SOURCE CODE #>
*/
void completion_doSyntaxCheck(completion_Session *session, FILE *fp)
{
    unsigned int i_diag = 0, n_diag;
    CXDiagnostic diag;
    CXString     dmsg;

    /* get a copy of fresh source file */
    completion_readSourcefile(session, fp);

    /* reparse the source to retrieve diagnostic message */
    completion_reparseTranslationUnit(session);

    /* dump all diagnostic messages to fp */
    n_diag = clang_getNumDiagnostics(session->cx_tu);
    for ( ; i_diag < n_diag; i_diag++)
    {
        diag = clang_getDiagnostic(session->cx_tu, i_diag);
        dmsg = clang_formatDiagnostic(diag, clang_defaultDiagnosticDisplayOptions());
        fprintf(stdout, "%s\n", clang_getCString(dmsg));
        clang_disposeString(dmsg);
        clang_disposeDiagnostic(diag);
    }

    fprintf(stdout, "$"); fflush(stdout);    /* end of output */
}
开发者ID:To1ne,项目名称:emacs-clang-complete-async,代码行数:29,代码来源:msg_handlers.c


示例11: clang_getTypeSpelling

std::ostream& operator<<( std::ostream& os, CXType type )
{
    auto typestr = clang_getTypeSpelling( type );
    os << "Type: " << clang_getCString( typestr ) << "\n";
    clang_disposeString( typestr );
    return os;
}
开发者ID:styxyang,项目名称:clang-faces,代码行数:7,代码来源:main.cpp


示例12: code_completion_results_cmp

static int code_completion_results_cmp(CXCompletionResult *r1,
				       CXCompletionResult *r2)
{
	int prio1 = clang_getCompletionPriority(r1->CompletionString);
	int prio2 = clang_getCompletionPriority(r2->CompletionString);
	if (prio1 != prio2)
		return prio1 - prio2;

	CXString r1t = get_result_typed_text(r1);
	CXString r2t = get_result_typed_text(r2);
	int cmp = strcmp(clang_getCString(r1t),
			 clang_getCString(r2t));
	clang_disposeString(r1t);
	clang_disposeString(r2t);
	return cmp;
}
开发者ID:gordio,项目名称:ccode,代码行数:16,代码来源:server.c


示例13: visitor_enum_cb

static enum CXChildVisitResult
visitor_enum_cb(CXCursor cursor, CXCursor parent, CXClientData client_data) {
  EnumData* data = (EnumData*)client_data;
  ErlNifEnv *env = data->env;
  ERL_NIF_TERM name;
  ERL_NIF_TERM value;
  long long cvalue;

  CXString tmp;
  char* cstr;

  switch (clang_getCursorKind(cursor)) {
    case CXCursor_EnumConstantDecl: {
      tmp = clang_getCursorSpelling(cursor);
      cstr = (char*)clang_getCString(tmp);
      cvalue = clang_getEnumConstantDeclValue(cursor);
      name = enif_make_string(env, cstr, ERL_NIF_LATIN1);
      value = enif_make_int64(env, cvalue);
      data->enum_values = enif_make_list_cell(env,
                                              enif_make_tuple2(env, name, value),
                                              data->enum_values);
    }
    default: {
      return CXChildVisit_Continue;
    }
  }
}
开发者ID:parapluu,项目名称:nifty,代码行数:27,代码来源:nifty_clangparse.c


示例14: switch

void
ast_json::record_token(
    json_t& obj, CXToken token, CXTranslationUnit translation_unit)
{
    // Record token kind
    switch (clang_getTokenKind(token)) {
      case CXToken_Punctuation:
          obj[lex_token::KIND] = "punctuation";
          break;
      case CXToken_Keyword:
          obj[lex_token::KIND] = "keyword";
          break;
      case CXToken_Identifier:
          obj[lex_token::KIND] = "identifier";
          break;
      case CXToken_Literal:
          obj[lex_token::KIND] = "literal";
          break;
      case CXToken_Comment:
          obj[lex_token::KIND] = "comment";
          break;
    }

    // Get attributes
    CXString spelling = clang_getTokenSpelling(translation_unit, token);
    CXSourceRange extent = clang_getTokenExtent(translation_unit, token);

    obj[lex_token::DATA] = std::string(clang_getCString(spelling));
    record_extent(obj, extent);

    // Reclaim memory
    clang_disposeString(spelling);
}
开发者ID:chubbymaggie,项目名称:llvm-datalog,代码行数:33,代码来源:json_utils.cpp


示例15: GetCursorSource

static const char* GetCursorSource(CXCursor Cursor) {
  CXSourceLocation Loc = clang_getCursorLocation(Cursor);
  CXString source;
  CXFile file;
  clang_getInstantiationLocation(Loc, &file, 0, 0, 0);
  source = clang_getFileName(file);
  if (!clang_getCString(source)) {
    clang_disposeString(source);
    return "<invalid loc>";
  }
  else {
    const char *b = basename(clang_getCString(source));
    clang_disposeString(source);
    return b;
  }
}
开发者ID:albertz,项目名称:clang,代码行数:16,代码来源:c-index-test.c


示例16: printString

static void printString(const char *name, CXString string)
{
    const char *cstr = clang_getCString(string);
    if (cstr && *cstr) {
        printf("%s: %s ", name, cstr);
    }
    clang_disposeString(string);
}
开发者ID:HackerFoo,项目名称:rtags,代码行数:8,代码来源:clangtest.c


示例17: clang_getCString

std::string libclang_vim::stringize_key_value(const char* key_name,
                                              const cxstring_ptr& p) {
    const auto* cstring = clang_getCString(p);
    if (!cstring || std::strcmp(cstring, "") == 0)
        return "";
    else
        return "'" + std::string{key_name} + "':'" + cstring + "',";
}
开发者ID:spider391Tang,项目名称:libclang-vim,代码行数:8,代码来源:helpers.cpp


示例18: render_string_or_null

json_t* render_string_or_null(CXString s) {
  const char* str = clang_getCString(s);
  json_t* js;
  if (str && strlen(str) > 0) js = json_string(str);
  else js = json_null();
  clang_disposeString(s);
  return js;
}
开发者ID:iamaaditya,项目名称:cshore,代码行数:8,代码来源:ffigen.c


示例19: clang_getNumDiagnostics

void ClangUtils::printDiagnosticsToLog(CXTranslationUnit& TU)
{
	//// Report diagnostics to the log file
	const unsigned diagCount = clang_getNumDiagnostics(TU);
	for(unsigned i=0; i<diagCount; i++) {
		CXDiagnostic diag     = clang_getDiagnostic(TU, i);
		CXString diagStr      = clang_formatDiagnostic(diag, clang_defaultDiagnosticDisplayOptions());
        wxString wxDiagString = wxString(clang_getCString(diagStr), wxConvUTF8);
        
		if(!wxDiagString.Contains(wxT("'dllimport' attribute"))) {
			fprintf(stdout, "Diagnostic: %s\n", clang_getCString(diagStr));
        
		}
		clang_disposeString(diagStr);
		clang_disposeDiagnostic(diag);
	}
}
开发者ID:AndrianDTR,项目名称:codelite,代码行数:17,代码来源:clang_utils.cpp


示例20: cx_string

std::string Cursor::raw_comment() const
{
	UniqueCXString cx_string(clang_Cursor_getRawCommentText(m_cx_cursor));
	if ( !cx_string ) {
		CLANGXX_THROW_LogicError("Error retrieving the raw comment text associated with this cursor.");
	}
	return clang_getCString(cx_string.get());
}
开发者ID:pegacorn,项目名称:libclang-cpp,代码行数:8,代码来源:Cursor.cpp



注:本文中的clang_getCString函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ clang_getCursorKind函数代码示例发布时间:2022-05-30
下一篇:
C++ clang_disposeString函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap