Move libclangmm/Utility.h into clang_utils.h

This commit is contained in:
Jacob Dufault 2017-11-04 15:29:03 -07:00
parent 172f9e2e80
commit 7d549f3fdf
13 changed files with 367 additions and 382 deletions

View File

@ -1,7 +1,6 @@
#include "clang_complete.h"
#include "clang_utils.h"
#include "libclangmm/Utility.h"
#include "platform.h"
#include "timer.h"
@ -184,7 +183,7 @@ void BuildDetailString(CXCompletionString completion_string,
case CXCompletionChunk_Placeholder: {
std::string text =
clang::ToString(clang_getCompletionChunkText(completion_string, i));
ToString(clang_getCompletionChunkText(completion_string, i));
parameters->push_back(text);
detail += text;
insert += "${" + std::to_string(parameters->size()) + ":" + text + "}";
@ -198,7 +197,7 @@ void BuildDetailString(CXCompletionString completion_string,
case CXCompletionChunk_TypedText: {
std::string text =
clang::ToString(clang_getCompletionChunkText(completion_string, i));
ToString(clang_getCompletionChunkText(completion_string, i));
label = text;
detail += text;
insert += text;
@ -207,21 +206,20 @@ void BuildDetailString(CXCompletionString completion_string,
case CXCompletionChunk_Text: {
std::string text =
clang::ToString(clang_getCompletionChunkText(completion_string, i));
ToString(clang_getCompletionChunkText(completion_string, i));
detail += text;
insert += text;
break;
}
case CXCompletionChunk_Informative: {
detail +=
clang::ToString(clang_getCompletionChunkText(completion_string, i));
detail += ToString(clang_getCompletionChunkText(completion_string, i));
break;
}
case CXCompletionChunk_ResultType: {
CXString text = clang_getCompletionChunkText(completion_string, i);
std::string new_detail = clang::ToString(text) + detail + " ";
std::string new_detail = ToString(text) + detail + " ";
detail = new_detail;
break;
}
@ -441,7 +439,7 @@ void CompletionQueryMain(ClangCompleteManager* completion_manager) {
ls_completion_item.insertText,
&ls_completion_item.parameters_);
ls_completion_item.insertText += "$0";
ls_completion_item.documentation = clang::ToString(
ls_completion_item.documentation = ToString(
clang_getCompletionBriefComment(result.CompletionString));
ls_completion_item.sortText =
(const char)uint64_t(GetCompletionPriority(

View File

@ -1,6 +1,5 @@
#include "clang_utils.h"
#include "libclangmm/Utility.h"
#include "platform.h"
namespace {
@ -46,12 +45,11 @@ optional<lsDiagnostic> BuildAndDisposeDiagnostic(CXDiagnostic diagnostic,
ls_diagnostic.range =
lsRange(lsPosition(line - 1, column), lsPosition(line - 1, column));
ls_diagnostic.message =
clang::ToString(clang_getDiagnosticSpelling(diagnostic));
ls_diagnostic.message = ToString(clang_getDiagnosticSpelling(diagnostic));
// Append the flag that enables this diagnostic, ie, [-Wswitch]
std::string enabling_flag =
clang::ToString(clang_getDiagnosticOption(diagnostic, nullptr));
ToString(clang_getDiagnosticOption(diagnostic, nullptr));
if (!enabling_flag.empty())
ls_diagnostic.message += " [" + enabling_flag + "]";
@ -78,7 +76,7 @@ optional<lsDiagnostic> BuildAndDisposeDiagnostic(CXDiagnostic diagnostic,
CXString text = clang_getDiagnosticFixIt(diagnostic, i, &replacement_range);
lsTextEdit edit;
edit.newText = clang::ToString(text);
edit.newText = ToString(text);
edit.range = GetLsRangeForFixIt(replacement_range);
ls_diagnostic.fixits_.push_back(edit);
}
@ -90,6 +88,338 @@ optional<lsDiagnostic> BuildAndDisposeDiagnostic(CXDiagnostic diagnostic,
std::string FileName(CXFile file) {
CXString cx_name = clang_getFileName(file);
std::string name = clang::ToString(cx_name);
std::string name = ToString(cx_name);
return NormalizePath(name);
}
std::string ToString(CXString cx_string) {
std::string string;
if (cx_string.data != nullptr) {
string = clang_getCString(cx_string);
clang_disposeString(cx_string);
}
return string;
}
std::string ToString(CXCursorKind kind) {
switch (kind) {
case CXCursor_UnexposedDecl:
return "UnexposedDecl";
case CXCursor_StructDecl:
return "StructDecl";
case CXCursor_UnionDecl:
return "UnionDecl";
case CXCursor_ClassDecl:
return "ClassDecl";
case CXCursor_EnumDecl:
return "EnumDecl";
case CXCursor_FieldDecl:
return "FieldDecl";
case CXCursor_EnumConstantDecl:
return "EnumConstantDecl";
case CXCursor_FunctionDecl:
return "FunctionDecl";
case CXCursor_VarDecl:
return "VarDecl";
case CXCursor_ParmDecl:
return "ParmDecl";
case CXCursor_ObjCInterfaceDecl:
return "ObjCInterfaceDecl";
case CXCursor_ObjCCategoryDecl:
return "ObjCCategoryDecl";
case CXCursor_ObjCProtocolDecl:
return "ObjCProtocolDecl";
case CXCursor_ObjCPropertyDecl:
return "ObjCPropertyDecl";
case CXCursor_ObjCIvarDecl:
return "ObjCIvarDecl";
case CXCursor_ObjCInstanceMethodDecl:
return "ObjCInstanceMethodDecl";
case CXCursor_ObjCClassMethodDecl:
return "ObjCClassMethodDecl";
case CXCursor_ObjCImplementationDecl:
return "ObjCImplementationDecl";
case CXCursor_ObjCCategoryImplDecl:
return "ObjCCategoryImplDecl";
case CXCursor_TypedefDecl:
return "TypedefDecl";
case CXCursor_CXXMethod:
return "CXXMethod";
case CXCursor_Namespace:
return "Namespace";
case CXCursor_LinkageSpec:
return "LinkageSpec";
case CXCursor_Constructor:
return "Constructor";
case CXCursor_Destructor:
return "Destructor";
case CXCursor_ConversionFunction:
return "ConversionFunction";
case CXCursor_TemplateTypeParameter:
return "TemplateTypeParameter";
case CXCursor_NonTypeTemplateParameter:
return "NonTypeTemplateParameter";
case CXCursor_TemplateTemplateParameter:
return "TemplateTemplateParameter";
case CXCursor_FunctionTemplate:
return "FunctionTemplate";
case CXCursor_ClassTemplate:
return "ClassTemplate";
case CXCursor_ClassTemplatePartialSpecialization:
return "ClassTemplatePartialSpecialization";
case CXCursor_NamespaceAlias:
return "NamespaceAlias";
case CXCursor_UsingDirective:
return "UsingDirective";
case CXCursor_UsingDeclaration:
return "UsingDeclaration";
case CXCursor_TypeAliasDecl:
return "TypeAliasDecl";
case CXCursor_ObjCSynthesizeDecl:
return "ObjCSynthesizeDecl";
case CXCursor_ObjCDynamicDecl:
return "ObjCDynamicDecl";
case CXCursor_CXXAccessSpecifier:
return "CXXAccessSpecifier";
// case CXCursor_FirstDecl: return "FirstDecl";
// case CXCursor_LastDecl: return "LastDecl";
// case CXCursor_FirstRef: return "FirstRef";
case CXCursor_ObjCSuperClassRef:
return "ObjCSuperClassRef";
case CXCursor_ObjCProtocolRef:
return "ObjCProtocolRef";
case CXCursor_ObjCClassRef:
return "ObjCClassRef";
case CXCursor_TypeRef:
return "TypeRef";
case CXCursor_CXXBaseSpecifier:
return "CXXBaseSpecifier";
case CXCursor_TemplateRef:
return "TemplateRef";
case CXCursor_NamespaceRef:
return "NamespaceRef";
case CXCursor_MemberRef:
return "MemberRef";
case CXCursor_LabelRef:
return "LabelRef";
case CXCursor_OverloadedDeclRef:
return "OverloadedDeclRef";
case CXCursor_VariableRef:
return "VariableRef";
// case CXCursor_LastRef: return "LastRef";
// case CXCursor_FirstInvalid: return "FirstInvalid";
case CXCursor_InvalidFile:
return "InvalidFile";
case CXCursor_NoDeclFound:
return "NoDeclFound";
case CXCursor_NotImplemented:
return "NotImplemented";
case CXCursor_InvalidCode:
return "InvalidCode";
// case CXCursor_LastInvalid: return "LastInvalid";
// case CXCursor_FirstExpr: return "FirstExpr";
case CXCursor_UnexposedExpr:
return "UnexposedExpr";
case CXCursor_DeclRefExpr:
return "DeclRefExpr";
case CXCursor_MemberRefExpr:
return "MemberRefExpr";
case CXCursor_CallExpr:
return "CallExpr";
case CXCursor_ObjCMessageExpr:
return "ObjCMessageExpr";
case CXCursor_BlockExpr:
return "BlockExpr";
case CXCursor_IntegerLiteral:
return "IntegerLiteral";
case CXCursor_FloatingLiteral:
return "FloatingLiteral";
case CXCursor_ImaginaryLiteral:
return "ImaginaryLiteral";
case CXCursor_StringLiteral:
return "StringLiteral";
case CXCursor_CharacterLiteral:
return "CharacterLiteral";
case CXCursor_ParenExpr:
return "ParenExpr";
case CXCursor_UnaryOperator:
return "UnaryOperator";
case CXCursor_ArraySubscriptExpr:
return "ArraySubscriptExpr";
case CXCursor_BinaryOperator:
return "BinaryOperator";
case CXCursor_CompoundAssignOperator:
return "CompoundAssignOperator";
case CXCursor_ConditionalOperator:
return "ConditionalOperator";
case CXCursor_CStyleCastExpr:
return "CStyleCastExpr";
case CXCursor_CompoundLiteralExpr:
return "CompoundLiteralExpr";
case CXCursor_InitListExpr:
return "InitListExpr";
case CXCursor_AddrLabelExpr:
return "AddrLabelExpr";
case CXCursor_StmtExpr:
return "StmtExpr";
case CXCursor_GenericSelectionExpr:
return "GenericSelectionExpr";
case CXCursor_GNUNullExpr:
return "GNUNullExpr";
case CXCursor_CXXStaticCastExpr:
return "CXXStaticCastExpr";
case CXCursor_CXXDynamicCastExpr:
return "CXXDynamicCastExpr";
case CXCursor_CXXReinterpretCastExpr:
return "CXXReinterpretCastExpr";
case CXCursor_CXXConstCastExpr:
return "CXXConstCastExpr";
case CXCursor_CXXFunctionalCastExpr:
return "CXXFunctionalCastExpr";
case CXCursor_CXXTypeidExpr:
return "CXXTypeidExpr";
case CXCursor_CXXBoolLiteralExpr:
return "CXXBoolLiteralExpr";
case CXCursor_CXXNullPtrLiteralExpr:
return "CXXNullPtrLiteralExpr";
case CXCursor_CXXThisExpr:
return "CXXThisExpr";
case CXCursor_CXXThrowExpr:
return "CXXThrowExpr";
case CXCursor_CXXNewExpr:
return "CXXNewExpr";
case CXCursor_CXXDeleteExpr:
return "CXXDeleteExpr";
case CXCursor_UnaryExpr:
return "UnaryExpr";
case CXCursor_ObjCStringLiteral:
return "ObjCStringLiteral";
case CXCursor_ObjCEncodeExpr:
return "ObjCEncodeExpr";
case CXCursor_ObjCSelectorExpr:
return "ObjCSelectorExpr";
case CXCursor_ObjCProtocolExpr:
return "ObjCProtocolExpr";
case CXCursor_ObjCBridgedCastExpr:
return "ObjCBridgedCastExpr";
case CXCursor_PackExpansionExpr:
return "PackExpansionExpr";
case CXCursor_SizeOfPackExpr:
return "SizeOfPackExpr";
case CXCursor_LambdaExpr:
return "LambdaExpr";
case CXCursor_ObjCBoolLiteralExpr:
return "ObjCBoolLiteralExpr";
case CXCursor_ObjCSelfExpr:
return "ObjCSelfExpr";
// case CXCursor_LastExpr: return "LastExpr";
// case CXCursor_FirstStmt: return "FirstStmt";
case CXCursor_UnexposedStmt:
return "UnexposedStmt";
case CXCursor_LabelStmt:
return "LabelStmt";
case CXCursor_CompoundStmt:
return "CompoundStmt";
case CXCursor_CaseStmt:
return "CaseStmt";
case CXCursor_DefaultStmt:
return "DefaultStmt";
case CXCursor_IfStmt:
return "IfStmt";
case CXCursor_SwitchStmt:
return "SwitchStmt";
case CXCursor_WhileStmt:
return "WhileStmt";
case CXCursor_DoStmt:
return "DoStmt";
case CXCursor_ForStmt:
return "ForStmt";
case CXCursor_GotoStmt:
return "GotoStmt";
case CXCursor_IndirectGotoStmt:
return "IndirectGotoStmt";
case CXCursor_ContinueStmt:
return "ContinueStmt";
case CXCursor_BreakStmt:
return "BreakStmt";
case CXCursor_ReturnStmt:
return "ReturnStmt";
case CXCursor_GCCAsmStmt:
return "GCCAsmStmt";
// case CXCursor_AsmStmt: return "AsmStmt";
case CXCursor_ObjCAtTryStmt:
return "ObjCAtTryStmt";
case CXCursor_ObjCAtCatchStmt:
return "ObjCAtCatchStmt";
case CXCursor_ObjCAtFinallyStmt:
return "ObjCAtFinallyStmt";
case CXCursor_ObjCAtThrowStmt:
return "ObjCAtThrowStmt";
case CXCursor_ObjCAtSynchronizedStmt:
return "ObjCAtSynchronizedStmt";
case CXCursor_ObjCAutoreleasePoolStmt:
return "ObjCAutoreleasePoolStmt";
case CXCursor_ObjCForCollectionStmt:
return "ObjCForCollectionStmt";
case CXCursor_CXXCatchStmt:
return "CXXCatchStmt";
case CXCursor_CXXTryStmt:
return "CXXTryStmt";
case CXCursor_CXXForRangeStmt:
return "CXXForRangeStmt";
case CXCursor_SEHTryStmt:
return "SEHTryStmt";
case CXCursor_SEHExceptStmt:
return "SEHExceptStmt";
case CXCursor_SEHFinallyStmt:
return "SEHFinallyStmt";
case CXCursor_MSAsmStmt:
return "MSAsmStmt";
case CXCursor_NullStmt:
return "NullStmt";
case CXCursor_DeclStmt:
return "DeclStmt";
case CXCursor_LastStmt:
return "LastStmt";
case CXCursor_TranslationUnit:
return "TranslationUnit";
// case CXCursor_FirstAttr: return "FirstAttr";
case CXCursor_UnexposedAttr:
return "UnexposedAttr";
case CXCursor_IBActionAttr:
return "IBActionAttr";
case CXCursor_IBOutletAttr:
return "IBOutletAttr";
case CXCursor_IBOutletCollectionAttr:
return "IBOutletCollectionAttr";
case CXCursor_CXXFinalAttr:
return "CXXFinalAttr";
case CXCursor_CXXOverrideAttr:
return "CXXOverrideAttr";
case CXCursor_AnnotateAttr:
return "AnnotateAttr";
case CXCursor_AsmLabelAttr:
return "AsmLabelAttr";
case CXCursor_LastAttr:
return "LastAttr";
case CXCursor_PreprocessingDirective:
return "PreprocessingDirective";
case CXCursor_MacroDefinition:
return "MacroDefinition";
case CXCursor_MacroExpansion:
return "MacroExpansion";
// case CXCursor_MacroInstantiation: return "MacroInstantiation";
case CXCursor_InclusionDirective:
return "InclusionDirective";
// case CXCursor_FirstPreprocessing: return "FirstPreprocessing";
// case CXCursor_LastPreprocessing: return "LastPreprocessing";
case CXCursor_ModuleImportDecl:
return "ModuleImportDecl";
// case CXCursor_FirstExtraDecl: return "FirstExtraDecl";
case CXCursor_LastExtraDecl:
return "LastExtraDecl";
default:
break;
}
return "<unknown kind>";
}

View File

@ -14,3 +14,7 @@ optional<lsDiagnostic> BuildAndDisposeDiagnostic(CXDiagnostic diagnostic,
// Returns the absolute path to |file|.
std::string FileName(CXFile file);
std::string ToString(CXString cx_string);
std::string ToString(CXCursorKind cursor_kind);

View File

@ -24,9 +24,9 @@
#include "working_files.h"
#include <doctest/doctest.h>
#include <loguru.hpp>
#include <rapidjson/istreamwrapper.h>
#include <rapidjson/ostreamwrapper.h>
#include <loguru.hpp>
#include <climits>
#include <fstream>

View File

@ -85,7 +85,7 @@ std::vector<std::unique_ptr<IndexFile>> FileConsumer::TakeLocalState() {
}
void FileConsumer::EmitError(CXFile file) const {
std::string file_name = clang::ToString(clang_getFileName(file));
std::string file_name = ToString(clang_getFileName(file));
// TODO: Investigate this more, why can we get an empty file name?
if (!file_name.empty()) {
std::string error_message = "Could not get unique file id for " +

View File

@ -4,7 +4,6 @@
#include "libclangmm/Cursor.h"
#include "libclangmm/Index.h"
#include "libclangmm/TranslationUnit.h"
#include "libclangmm/Utility.h"
#include "platform.h"
#include "serializer.h"
#include "timer.h"
@ -446,8 +445,8 @@ clang::VisiterResult DumpVisitor(clang::Cursor cursor,
int* level) {
for (int i = 0; i < *level; ++i)
std::cerr << " ";
std::cerr << clang::ToString(cursor.get_kind()) << " "
<< cursor.get_spelling() << std::endl;
std::cerr << ToString(cursor.get_kind()) << " " << cursor.get_spelling()
<< std::endl;
*level += 1;
cursor.VisitChildren(&DumpVisitor, level);
@ -923,8 +922,8 @@ void indexDeclaration(CXClientData client_data, const CXIdxDeclInfo* decl) {
// if (!decl->isRedeclaration) {
var->def.short_name = decl->entityInfo->name;
std::string type_name = clang::ToString(
clang_getTypeSpelling(clang_getCursorType(decl->cursor)));
std::string type_name =
ToString(clang_getTypeSpelling(clang_getCursorType(decl->cursor)));
var->def.detailed_name =
type_name + " " +
ns->QualifiedName(decl->semanticContainer, var->def.short_name);

View File

@ -1,10 +1,10 @@
#pragma once
#include "clang_utils.h"
#include "file_consumer.h"
#include "language_server_api.h"
#include "libclangmm/Index.h"
#include "libclangmm/TranslationUnit.h"
#include "libclangmm/Utility.h"
#include "performance.h"
#include "position.h"
#include "serializer.h"

View File

@ -1,8 +1,8 @@
#include <algorithm>
#include <cassert>
#include "../clang_utils.h"
#include "Cursor.h"
#include "Utility.h"
namespace clang {
@ -141,15 +141,15 @@ SourceRange Cursor::get_source_range() const {
*/
std::string Cursor::get_spelling() const {
return clang::ToString(clang_getCursorSpelling(cx_cursor));
return ::ToString(clang_getCursorSpelling(cx_cursor));
}
std::string Cursor::get_display_name() const {
return clang::ToString(clang_getCursorDisplayName(cx_cursor));
return ::ToString(clang_getCursorDisplayName(cx_cursor));
}
std::string Cursor::get_usr() const {
return clang::ToString(clang_getCursorUSR(cx_cursor));
return ::ToString(clang_getCursorUSR(cx_cursor));
}
bool Cursor::is_definition() const {
@ -203,7 +203,7 @@ bool Cursor::is_valid_kind() const {
std::string Cursor::get_type_description() const {
auto type = clang_getCursorType(cx_cursor);
return clang::ToString(clang_getTypeSpelling(type));
return ::ToString(clang_getTypeSpelling(type));
#if false
std::string spelling;
@ -338,14 +338,13 @@ std::string Cursor::evaluate() const {
std::string Cursor::get_comments() const {
Cursor referenced = get_referenced();
if (referenced)
return clang::ToString(
clang_Cursor_getRawCommentText(referenced.cx_cursor));
return ::ToString(clang_Cursor_getRawCommentText(referenced.cx_cursor));
return "";
}
std::string Cursor::ToString() const {
return clang::ToString(get_kind()) + " " + get_spelling();
return ::ToString(get_kind()) + " " + get_spelling();
}
} // namespace clang

View File

@ -2,7 +2,6 @@
#include "../platform.h"
#include "../utils.h"
#include "Utility.h"
#include <loguru.hpp>

View File

@ -1,333 +0,0 @@
#include "Utility.h"
std::string clang::ToString(CXString cx_string) {
std::string string;
if (cx_string.data != nullptr) {
string = clang_getCString(cx_string);
clang_disposeString(cx_string);
}
return string;
}
std::string clang::ToString(CXCursorKind kind) {
switch (kind) {
case CXCursor_UnexposedDecl:
return "UnexposedDecl";
case CXCursor_StructDecl:
return "StructDecl";
case CXCursor_UnionDecl:
return "UnionDecl";
case CXCursor_ClassDecl:
return "ClassDecl";
case CXCursor_EnumDecl:
return "EnumDecl";
case CXCursor_FieldDecl:
return "FieldDecl";
case CXCursor_EnumConstantDecl:
return "EnumConstantDecl";
case CXCursor_FunctionDecl:
return "FunctionDecl";
case CXCursor_VarDecl:
return "VarDecl";
case CXCursor_ParmDecl:
return "ParmDecl";
case CXCursor_ObjCInterfaceDecl:
return "ObjCInterfaceDecl";
case CXCursor_ObjCCategoryDecl:
return "ObjCCategoryDecl";
case CXCursor_ObjCProtocolDecl:
return "ObjCProtocolDecl";
case CXCursor_ObjCPropertyDecl:
return "ObjCPropertyDecl";
case CXCursor_ObjCIvarDecl:
return "ObjCIvarDecl";
case CXCursor_ObjCInstanceMethodDecl:
return "ObjCInstanceMethodDecl";
case CXCursor_ObjCClassMethodDecl:
return "ObjCClassMethodDecl";
case CXCursor_ObjCImplementationDecl:
return "ObjCImplementationDecl";
case CXCursor_ObjCCategoryImplDecl:
return "ObjCCategoryImplDecl";
case CXCursor_TypedefDecl:
return "TypedefDecl";
case CXCursor_CXXMethod:
return "CXXMethod";
case CXCursor_Namespace:
return "Namespace";
case CXCursor_LinkageSpec:
return "LinkageSpec";
case CXCursor_Constructor:
return "Constructor";
case CXCursor_Destructor:
return "Destructor";
case CXCursor_ConversionFunction:
return "ConversionFunction";
case CXCursor_TemplateTypeParameter:
return "TemplateTypeParameter";
case CXCursor_NonTypeTemplateParameter:
return "NonTypeTemplateParameter";
case CXCursor_TemplateTemplateParameter:
return "TemplateTemplateParameter";
case CXCursor_FunctionTemplate:
return "FunctionTemplate";
case CXCursor_ClassTemplate:
return "ClassTemplate";
case CXCursor_ClassTemplatePartialSpecialization:
return "ClassTemplatePartialSpecialization";
case CXCursor_NamespaceAlias:
return "NamespaceAlias";
case CXCursor_UsingDirective:
return "UsingDirective";
case CXCursor_UsingDeclaration:
return "UsingDeclaration";
case CXCursor_TypeAliasDecl:
return "TypeAliasDecl";
case CXCursor_ObjCSynthesizeDecl:
return "ObjCSynthesizeDecl";
case CXCursor_ObjCDynamicDecl:
return "ObjCDynamicDecl";
case CXCursor_CXXAccessSpecifier:
return "CXXAccessSpecifier";
// case CXCursor_FirstDecl: return "FirstDecl";
// case CXCursor_LastDecl: return "LastDecl";
// case CXCursor_FirstRef: return "FirstRef";
case CXCursor_ObjCSuperClassRef:
return "ObjCSuperClassRef";
case CXCursor_ObjCProtocolRef:
return "ObjCProtocolRef";
case CXCursor_ObjCClassRef:
return "ObjCClassRef";
case CXCursor_TypeRef:
return "TypeRef";
case CXCursor_CXXBaseSpecifier:
return "CXXBaseSpecifier";
case CXCursor_TemplateRef:
return "TemplateRef";
case CXCursor_NamespaceRef:
return "NamespaceRef";
case CXCursor_MemberRef:
return "MemberRef";
case CXCursor_LabelRef:
return "LabelRef";
case CXCursor_OverloadedDeclRef:
return "OverloadedDeclRef";
case CXCursor_VariableRef:
return "VariableRef";
// case CXCursor_LastRef: return "LastRef";
// case CXCursor_FirstInvalid: return "FirstInvalid";
case CXCursor_InvalidFile:
return "InvalidFile";
case CXCursor_NoDeclFound:
return "NoDeclFound";
case CXCursor_NotImplemented:
return "NotImplemented";
case CXCursor_InvalidCode:
return "InvalidCode";
// case CXCursor_LastInvalid: return "LastInvalid";
// case CXCursor_FirstExpr: return "FirstExpr";
case CXCursor_UnexposedExpr:
return "UnexposedExpr";
case CXCursor_DeclRefExpr:
return "DeclRefExpr";
case CXCursor_MemberRefExpr:
return "MemberRefExpr";
case CXCursor_CallExpr:
return "CallExpr";
case CXCursor_ObjCMessageExpr:
return "ObjCMessageExpr";
case CXCursor_BlockExpr:
return "BlockExpr";
case CXCursor_IntegerLiteral:
return "IntegerLiteral";
case CXCursor_FloatingLiteral:
return "FloatingLiteral";
case CXCursor_ImaginaryLiteral:
return "ImaginaryLiteral";
case CXCursor_StringLiteral:
return "StringLiteral";
case CXCursor_CharacterLiteral:
return "CharacterLiteral";
case CXCursor_ParenExpr:
return "ParenExpr";
case CXCursor_UnaryOperator:
return "UnaryOperator";
case CXCursor_ArraySubscriptExpr:
return "ArraySubscriptExpr";
case CXCursor_BinaryOperator:
return "BinaryOperator";
case CXCursor_CompoundAssignOperator:
return "CompoundAssignOperator";
case CXCursor_ConditionalOperator:
return "ConditionalOperator";
case CXCursor_CStyleCastExpr:
return "CStyleCastExpr";
case CXCursor_CompoundLiteralExpr:
return "CompoundLiteralExpr";
case CXCursor_InitListExpr:
return "InitListExpr";
case CXCursor_AddrLabelExpr:
return "AddrLabelExpr";
case CXCursor_StmtExpr:
return "StmtExpr";
case CXCursor_GenericSelectionExpr:
return "GenericSelectionExpr";
case CXCursor_GNUNullExpr:
return "GNUNullExpr";
case CXCursor_CXXStaticCastExpr:
return "CXXStaticCastExpr";
case CXCursor_CXXDynamicCastExpr:
return "CXXDynamicCastExpr";
case CXCursor_CXXReinterpretCastExpr:
return "CXXReinterpretCastExpr";
case CXCursor_CXXConstCastExpr:
return "CXXConstCastExpr";
case CXCursor_CXXFunctionalCastExpr:
return "CXXFunctionalCastExpr";
case CXCursor_CXXTypeidExpr:
return "CXXTypeidExpr";
case CXCursor_CXXBoolLiteralExpr:
return "CXXBoolLiteralExpr";
case CXCursor_CXXNullPtrLiteralExpr:
return "CXXNullPtrLiteralExpr";
case CXCursor_CXXThisExpr:
return "CXXThisExpr";
case CXCursor_CXXThrowExpr:
return "CXXThrowExpr";
case CXCursor_CXXNewExpr:
return "CXXNewExpr";
case CXCursor_CXXDeleteExpr:
return "CXXDeleteExpr";
case CXCursor_UnaryExpr:
return "UnaryExpr";
case CXCursor_ObjCStringLiteral:
return "ObjCStringLiteral";
case CXCursor_ObjCEncodeExpr:
return "ObjCEncodeExpr";
case CXCursor_ObjCSelectorExpr:
return "ObjCSelectorExpr";
case CXCursor_ObjCProtocolExpr:
return "ObjCProtocolExpr";
case CXCursor_ObjCBridgedCastExpr:
return "ObjCBridgedCastExpr";
case CXCursor_PackExpansionExpr:
return "PackExpansionExpr";
case CXCursor_SizeOfPackExpr:
return "SizeOfPackExpr";
case CXCursor_LambdaExpr:
return "LambdaExpr";
case CXCursor_ObjCBoolLiteralExpr:
return "ObjCBoolLiteralExpr";
case CXCursor_ObjCSelfExpr:
return "ObjCSelfExpr";
// case CXCursor_LastExpr: return "LastExpr";
// case CXCursor_FirstStmt: return "FirstStmt";
case CXCursor_UnexposedStmt:
return "UnexposedStmt";
case CXCursor_LabelStmt:
return "LabelStmt";
case CXCursor_CompoundStmt:
return "CompoundStmt";
case CXCursor_CaseStmt:
return "CaseStmt";
case CXCursor_DefaultStmt:
return "DefaultStmt";
case CXCursor_IfStmt:
return "IfStmt";
case CXCursor_SwitchStmt:
return "SwitchStmt";
case CXCursor_WhileStmt:
return "WhileStmt";
case CXCursor_DoStmt:
return "DoStmt";
case CXCursor_ForStmt:
return "ForStmt";
case CXCursor_GotoStmt:
return "GotoStmt";
case CXCursor_IndirectGotoStmt:
return "IndirectGotoStmt";
case CXCursor_ContinueStmt:
return "ContinueStmt";
case CXCursor_BreakStmt:
return "BreakStmt";
case CXCursor_ReturnStmt:
return "ReturnStmt";
case CXCursor_GCCAsmStmt:
return "GCCAsmStmt";
// case CXCursor_AsmStmt: return "AsmStmt";
case CXCursor_ObjCAtTryStmt:
return "ObjCAtTryStmt";
case CXCursor_ObjCAtCatchStmt:
return "ObjCAtCatchStmt";
case CXCursor_ObjCAtFinallyStmt:
return "ObjCAtFinallyStmt";
case CXCursor_ObjCAtThrowStmt:
return "ObjCAtThrowStmt";
case CXCursor_ObjCAtSynchronizedStmt:
return "ObjCAtSynchronizedStmt";
case CXCursor_ObjCAutoreleasePoolStmt:
return "ObjCAutoreleasePoolStmt";
case CXCursor_ObjCForCollectionStmt:
return "ObjCForCollectionStmt";
case CXCursor_CXXCatchStmt:
return "CXXCatchStmt";
case CXCursor_CXXTryStmt:
return "CXXTryStmt";
case CXCursor_CXXForRangeStmt:
return "CXXForRangeStmt";
case CXCursor_SEHTryStmt:
return "SEHTryStmt";
case CXCursor_SEHExceptStmt:
return "SEHExceptStmt";
case CXCursor_SEHFinallyStmt:
return "SEHFinallyStmt";
case CXCursor_MSAsmStmt:
return "MSAsmStmt";
case CXCursor_NullStmt:
return "NullStmt";
case CXCursor_DeclStmt:
return "DeclStmt";
case CXCursor_LastStmt:
return "LastStmt";
case CXCursor_TranslationUnit:
return "TranslationUnit";
// case CXCursor_FirstAttr: return "FirstAttr";
case CXCursor_UnexposedAttr:
return "UnexposedAttr";
case CXCursor_IBActionAttr:
return "IBActionAttr";
case CXCursor_IBOutletAttr:
return "IBOutletAttr";
case CXCursor_IBOutletCollectionAttr:
return "IBOutletCollectionAttr";
case CXCursor_CXXFinalAttr:
return "CXXFinalAttr";
case CXCursor_CXXOverrideAttr:
return "CXXOverrideAttr";
case CXCursor_AnnotateAttr:
return "AnnotateAttr";
case CXCursor_AsmLabelAttr:
return "AsmLabelAttr";
case CXCursor_LastAttr:
return "LastAttr";
case CXCursor_PreprocessingDirective:
return "PreprocessingDirective";
case CXCursor_MacroDefinition:
return "MacroDefinition";
case CXCursor_MacroExpansion:
return "MacroExpansion";
// case CXCursor_MacroInstantiation: return "MacroInstantiation";
case CXCursor_InclusionDirective:
return "InclusionDirective";
// case CXCursor_FirstPreprocessing: return "FirstPreprocessing";
// case CXCursor_LastPreprocessing: return "LastPreprocessing";
case CXCursor_ModuleImportDecl:
return "ModuleImportDecl";
// case CXCursor_FirstExtraDecl: return "FirstExtraDecl";
case CXCursor_LastExtraDecl:
return "LastExtraDecl";
default:
break;
}
return "<unknown kind>";
}

View File

@ -1,11 +0,0 @@
#pragma once
#include <clang-c/Index.h>
#include <string>
namespace clang {
std::string ToString(CXString cx_string);
std::string ToString(CXCursorKind cursor_kind);
} // namespace clang

View File

@ -1,6 +1,6 @@
#include "project.h"
#include "libclangmm/Utility.h"
#include "clang_utils.h"
#include "match.h"
#include "platform.h"
#include "serializer.h"
@ -259,16 +259,16 @@ std::vector<Project::Entry> LoadCompilationEntriesFromDirectory(
clang_CompileCommands_getCommand(cx_commands, i);
std::string directory =
clang::ToString(clang_CompileCommand_getDirectory(cx_command));
ToString(clang_CompileCommand_getDirectory(cx_command));
std::string relative_filename =
clang::ToString(clang_CompileCommand_getFilename(cx_command));
ToString(clang_CompileCommand_getFilename(cx_command));
unsigned num_args = clang_CompileCommand_getNumArgs(cx_command);
CompileCommandsEntry entry;
entry.args.reserve(num_args);
for (unsigned j = 0; j < num_args; ++j)
entry.args.push_back(
clang::ToString(clang_CompileCommand_getArg(cx_command, j)));
ToString(clang_CompileCommand_getArg(cx_command, j)));
clang_time.Pause(); // TODO: don't call clang::ToString in this block.
our_time.Resume();

View File

@ -429,9 +429,9 @@ IndexUpdate::IndexUpdate(const IdMap& previous_id_map,
bool did_add = \
ComputeDifferenceForUpdate(previous, current, &removed, &added); \
if (did_add) { \
/*std::cerr << "Adding mergeable update on " << \
/*std::cerr << "Adding mergeable update on " << \ \ \ \ \ \ \
* current_def->def.short_name << " (" << current_def->def.usr << ") for \
* field " << #index_name << std::endl;*/ \
* \ \ \ \ \ \ field " << #index_name << std::endl;*/ \
query_name.push_back(MergeableUpdate<type_id, type>( \
current_id_map.ToQuery(current_def->id), added, removed)); \
} \
@ -606,7 +606,7 @@ IndexUpdate::IndexUpdate(const IdMap& previous_id_map,
}
void IndexUpdate::Merge(const IndexUpdate& update) {
// This function runs on an indexer thread.
// This function runs on an indexer thread.
#define INDEX_UPDATE_APPEND(name) AddRange(&name, update.name);
#define INDEX_UPDATE_MERGE(name) AddMergeableRange(&name, update.name);