Some formatting changes

This commit is contained in:
Jacob Dufault 2017-04-22 00:42:57 -07:00
parent 489f54e538
commit 14aa4b77e4
9 changed files with 456 additions and 300 deletions

View File

@ -5,7 +5,6 @@
#include <memory> #include <memory>
#include <mutex> #include <mutex>
// A object which can be stored and taken from atomically. // A object which can be stored and taken from atomically.
template <class T> template <class T>
struct AtomicObject { struct AtomicObject {
@ -21,7 +20,7 @@ struct AtomicObject {
// release lock as long as the wait and reaquire it afterwards. // release lock as long as the wait and reaquire it afterwards.
cv_.wait(lock); cv_.wait(lock);
} }
return std::move(value_); return std::move(value_);
} }

View File

@ -8,7 +8,8 @@
namespace { namespace {
std::string GetCachedBaseFileName(const std::string& cache_directory, std::string source_file) { std::string GetCachedBaseFileName(const std::string& cache_directory,
std::string source_file) {
assert(!cache_directory.empty()); assert(!cache_directory.empty());
std::replace(source_file.begin(), source_file.end(), '\\', '_'); std::replace(source_file.begin(), source_file.end(), '\\', '_');
std::replace(source_file.begin(), source_file.end(), '/', '_'); std::replace(source_file.begin(), source_file.end(), '/', '_');
@ -19,11 +20,13 @@ std::string GetCachedBaseFileName(const std::string& cache_directory, std::strin
} // namespace } // namespace
std::unique_ptr<IndexedFile> LoadCachedIndex(IndexerConfig* config, const std::string& filename) { std::unique_ptr<IndexedFile> LoadCachedIndex(IndexerConfig* config,
const std::string& filename) {
if (!config->enableCacheRead) if (!config->enableCacheRead)
return nullptr; return nullptr;
optional<std::string> file_content = ReadContent(GetCachedBaseFileName(config->cacheDirectory, filename) + ".json"); optional<std::string> file_content = ReadContent(
GetCachedBaseFileName(config->cacheDirectory, filename) + ".json");
if (!file_content) if (!file_content)
return nullptr; return nullptr;
@ -34,18 +37,23 @@ std::unique_ptr<IndexedFile> LoadCachedIndex(IndexerConfig* config, const std::s
return nullptr; return nullptr;
} }
optional<std::string> LoadCachedFileContents(IndexerConfig* config, const std::string& filename) { optional<std::string> LoadCachedFileContents(IndexerConfig* config,
const std::string& filename) {
if (!config->enableCacheRead) if (!config->enableCacheRead)
return nullopt; return nullopt;
return ReadContent(GetCachedBaseFileName(config->cacheDirectory, filename) + ".txt"); return ReadContent(GetCachedBaseFileName(config->cacheDirectory, filename) +
".txt");
} }
void WriteToCache(IndexerConfig* config, const std::string& filename, IndexedFile& file) { void WriteToCache(IndexerConfig* config,
const std::string& filename,
IndexedFile& file) {
if (!config->enableCacheWrite) if (!config->enableCacheWrite)
return; return;
std::string cache_basename = GetCachedBaseFileName(config->cacheDirectory, filename); std::string cache_basename =
GetCachedBaseFileName(config->cacheDirectory, filename);
CopyFileTo(cache_basename + ".txt", filename); CopyFileTo(cache_basename + ".txt", filename);

View File

@ -10,8 +10,12 @@ using std::experimental::nullopt;
struct IndexerConfig; struct IndexerConfig;
struct IndexedFile; struct IndexedFile;
std::unique_ptr<IndexedFile> LoadCachedIndex(IndexerConfig* config, const std::string& filename); std::unique_ptr<IndexedFile> LoadCachedIndex(IndexerConfig* config,
const std::string& filename);
optional<std::string> LoadCachedFileContents(IndexerConfig* config, const std::string& filename); optional<std::string> LoadCachedFileContents(IndexerConfig* config,
const std::string& filename);
void WriteToCache(IndexerConfig* config, const std::string& filename, IndexedFile& file); void WriteToCache(IndexerConfig* config,
const std::string& filename,
IndexedFile& file);

View File

@ -10,15 +10,14 @@ Type::Type() : cx_type() {}
Type::Type(const CXType& other) : cx_type(other) {} Type::Type(const CXType& other) : cx_type(other) {}
bool Type::operator==(const Type& rhs) const { bool Type::operator==(const Type& rhs) const {
return clang_equalTypes(cx_type, rhs.cx_type); return clang_equalTypes(cx_type, rhs.cx_type);
} }
bool Type::is_fundamental() const { bool Type::is_fundamental() const {
//switch (cx_type.kind) { // switch (cx_type.kind) {
//case CXType_Auto: // case CXType_Auto:
//return true; // return true;
//} //}
// NOTE: This will return false for pointed types. Should we call // NOTE: This will return false for pointed types. Should we call
@ -36,11 +35,11 @@ std::string Type::get_usr() const {
} }
Type Type::strip_qualifiers() const { Type Type::strip_qualifiers() const {
//CXRefQualifierKind qualifiers = clang_Type_getCXXRefQualifier(cx_type) // CXRefQualifierKind qualifiers = clang_Type_getCXXRefQualifier(cx_type)
switch (cx_type.kind) { switch (cx_type.kind) {
case CXType_LValueReference: case CXType_LValueReference:
case CXType_Pointer: case CXType_Pointer:
return clang_getPointeeType(cx_type); return clang_getPointeeType(cx_type);
} }
return cx_type; return cx_type;
@ -72,11 +71,11 @@ std::vector<Type> Type::get_arguments() const {
return types; return types;
} }
std::vector<Type> Type::get_template_arguments() const { std::vector<Type> Type::get_template_arguments() const {
/* /*
CINDEX_LINKAGE int clang_Type_getNumTemplateArguments(CXType T); CINDEX_LINKAGE int clang_Type_getNumTemplateArguments(CXType T);
CINDEX_LINKAGE CXType clang_Type_getTemplateArgumentAsType(CXType T, unsigned i); CINDEX_LINKAGE CXType clang_Type_getTemplateArgumentAsType(CXType T, unsigned
i);
*/ */
int size = clang_Type_getNumTemplateArguments(cx_type); int size = clang_Type_getNumTemplateArguments(cx_type);
@ -90,9 +89,8 @@ std::vector<Type> Type::get_template_arguments() const {
return types; return types;
} }
static_assert(sizeof(Cursor) == sizeof(CXCursor), static_assert(sizeof(Cursor) == sizeof(CXCursor),
"Cursor must be the same size as CXCursor"); "Cursor must be the same size as CXCursor");
Cursor::Cursor() : cx_cursor(clang_getNullCursor()) {} Cursor::Cursor() : cx_cursor(clang_getNullCursor()) {}
@ -182,15 +180,13 @@ bool Cursor::is_valid_kind() const {
CXCursorKind kind = get_kind(); CXCursorKind kind = get_kind();
return kind > CXCursor_UnexposedDecl && return kind > CXCursor_UnexposedDecl &&
(kind < CXCursor_FirstInvalid || kind > CXCursor_LastInvalid); (kind < CXCursor_FirstInvalid || kind > CXCursor_LastInvalid);
} }
std::string Cursor::get_type_description() const { std::string Cursor::get_type_description() const {
auto type = clang_getCursorType(cx_cursor); auto type = clang_getCursorType(cx_cursor);
return clang::ToString(clang_getTypeSpelling(type)); return clang::ToString(clang_getTypeSpelling(type));
std::string spelling; std::string spelling;
auto referenced = clang_getCursorReferenced(cx_cursor); auto referenced = clang_getCursorReferenced(cx_cursor);
@ -198,28 +194,35 @@ std::string Cursor::get_type_description() const {
auto type = clang_getCursorType(referenced); auto type = clang_getCursorType(referenced);
spelling = clang::ToString(clang_getTypeSpelling(type)); spelling = clang::ToString(clang_getTypeSpelling(type));
#if CINDEX_VERSION_MAJOR==0 && CINDEX_VERSION_MINOR<32 #if CINDEX_VERSION_MAJOR == 0 && CINDEX_VERSION_MINOR < 32
const std::string auto_str = "auto"; const std::string auto_str = "auto";
if (spelling.size() >= 4 && std::equal(auto_str.begin(), auto_str.end(), spelling.begin())) { if (spelling.size() >= 4 &&
auto canonical_type = clang_getCanonicalType(clang_getCursorType(cx_cursor)); std::equal(auto_str.begin(), auto_str.end(), spelling.begin())) {
auto canonical_type =
clang_getCanonicalType(clang_getCursorType(cx_cursor));
auto canonical_spelling = ToString(clang_getTypeSpelling(canonical_type)); auto canonical_spelling = ToString(clang_getTypeSpelling(canonical_type));
if (spelling.size() > 5 && spelling[4] == ' ' && spelling[5] == '&' && spelling != canonical_spelling) if (spelling.size() > 5 && spelling[4] == ' ' && spelling[5] == '&' &&
spelling != canonical_spelling)
return canonical_spelling + " &"; return canonical_spelling + " &";
else else
return canonical_spelling; return canonical_spelling;
} }
const std::string const_auto_str = "const auto"; const std::string const_auto_str = "const auto";
if (spelling.size() >= 10 && std::equal(const_auto_str.begin(), const_auto_str.end(), spelling.begin())) { if (spelling.size() >= 10 &&
auto canonical_type = clang_getCanonicalType(clang_getCursorType(cx_cursor)); std::equal(const_auto_str.begin(), const_auto_str.end(),
spelling.begin())) {
auto canonical_type =
clang_getCanonicalType(clang_getCursorType(cx_cursor));
auto canonical_spelling = ToString(clang_getTypeSpelling(canonical_type)); auto canonical_spelling = ToString(clang_getTypeSpelling(canonical_type));
if (spelling.size() > 11 && spelling[10] == ' ' && spelling[11] == '&' && spelling != canonical_spelling) if (spelling.size() > 11 && spelling[10] == ' ' && spelling[11] == '&' &&
spelling != canonical_spelling)
return canonical_spelling + " &"; return canonical_spelling + " &";
else else
return canonical_spelling; return canonical_spelling;
} }
#endif #endif
} }
if (spelling.empty()) if (spelling.empty())
return get_spelling(); return get_spelling();
@ -315,7 +318,8 @@ std::string Cursor::evaluate() const {
std::string Cursor::get_comments() const { std::string Cursor::get_comments() const {
Cursor referenced = get_referenced(); Cursor referenced = get_referenced();
if (referenced) if (referenced)
return clang::ToString(clang_Cursor_getRawCommentText(referenced.cx_cursor)); return clang::ToString(
clang_Cursor_getRawCommentText(referenced.cx_cursor));
return ""; return "";
} }
@ -324,4 +328,4 @@ std::string Cursor::ToString() const {
return clang::ToString(get_kind()) + " " + get_spelling(); return clang::ToString(get_kind()) + " " + get_spelling();
} }
} // namespace clang } // namespace clang

View File

@ -7,11 +7,10 @@
#include <clang-c/Index.h> #include <clang-c/Index.h>
namespace clang { namespace clang {
class Type { class Type {
public: public:
Type(); Type();
Type(const CXType& other); Type(const CXType& other);
@ -35,14 +34,10 @@ public:
CXType cx_type; CXType cx_type;
}; };
enum class VisiterResult { enum class VisiterResult { Break, Continue, Recurse };
Break,
Continue,
Recurse
};
class Cursor { class Cursor {
public: public:
Cursor(); Cursor();
Cursor(const CXCursor& other); Cursor(const CXCursor& other);
@ -52,8 +47,6 @@ public:
CXCursorKind get_kind() const; CXCursorKind get_kind() const;
Type get_type() const; Type get_type() const;
//SourceLocation get_source_location() const;
//SourceRange get_source_range() const;
std::string get_spelling() const; std::string get_spelling() const;
std::string get_display_name() const; std::string get_display_name() const;
std::string get_usr() const; std::string get_usr() const;
@ -75,23 +68,24 @@ public:
std::vector<Cursor> get_arguments() const; std::vector<Cursor> get_arguments() const;
bool is_valid_kind() const; bool is_valid_kind() const;
//std::string evaluate() const;
std::string get_type_description() const; std::string get_type_description() const;
std::string get_comments() const; std::string get_comments() const;
std::string ToString() const; std::string ToString() const;
template<typename TClientData> template <typename TClientData>
using Visitor = VisiterResult(*)(Cursor cursor, Cursor parent, TClientData* client_data); using Visitor = VisiterResult (*)(Cursor cursor,
Cursor parent,
TClientData* client_data);
enum class VisitResult { enum class VisitResult { Completed, EndedEarly };
Completed, EndedEarly
};
template<typename TClientData> template <typename TClientData>
VisitResult VisitChildren(Visitor<TClientData> visitor, TClientData* client_data) const { VisitResult VisitChildren(Visitor<TClientData> visitor,
if (clang_visitChildren(cx_cursor, reinterpret_cast<CXCursorVisitor>(visitor), client_data) == 0) TClientData* client_data) const {
if (clang_visitChildren(cx_cursor,
reinterpret_cast<CXCursorVisitor>(visitor),
client_data) == 0)
return VisitResult::Completed; return VisitResult::Completed;
return VisitResult::EndedEarly; return VisitResult::EndedEarly;
} }

View File

@ -3,11 +3,11 @@
#include <clang-c/Index.h> #include <clang-c/Index.h>
namespace clang { namespace clang {
class Index { class Index {
public: public:
Index(int excludeDeclarationsFromPCH, int displayDiagnostics); Index(int excludeDeclarationsFromPCH, int displayDiagnostics);
~Index(); ~Index();
CXIndex cx_index; CXIndex cx_index;
}; };
} // namespace clang } // namespace clang
#endif // INDEX_H_ #endif // INDEX_H_

View File

@ -10,14 +10,12 @@
namespace clang { namespace clang {
TranslationUnit::TranslationUnit( TranslationUnit::TranslationUnit(IndexerConfig* config,
IndexerConfig* config, Index& index,
Index &index, const std::string& filepath,
const std::string& filepath, const std::vector<std::string>& arguments,
const std::vector<std::string>& arguments, std::vector<CXUnsavedFile> unsaved_files,
std::vector<CXUnsavedFile> unsaved_files, unsigned flags) {
unsigned flags) {
std::vector<const char*> args; std::vector<const char*> args;
for (const std::string& a : arguments) for (const std::string& a : arguments)
args.push_back(a.c_str()); args.push_back(a.c_str());
@ -35,32 +33,30 @@ TranslationUnit::TranslationUnit(
std::cerr << std::endl; std::cerr << std::endl;
CXErrorCode error_code = clang_parseTranslationUnit2( CXErrorCode error_code = clang_parseTranslationUnit2(
index.cx_index, index.cx_index, filepath.c_str(), args.data(), args.size(),
filepath.c_str(), unsaved_files.data(), unsaved_files.size(), flags, &cx_tu);
args.data(), args.size(),
unsaved_files.data(), unsaved_files.size(),
flags, &cx_tu);
switch (error_code) { switch (error_code) {
case CXError_Success: case CXError_Success:
did_fail = false; did_fail = false;
break; break;
case CXError_Failure: case CXError_Failure:
std::cerr << "libclang generic failure for " << filepath << std::endl; std::cerr << "libclang generic failure for " << filepath << std::endl;
did_fail = true; did_fail = true;
break; break;
case CXError_Crashed: case CXError_Crashed:
std::cerr << "libclang crashed for " << filepath << std::endl; std::cerr << "libclang crashed for " << filepath << std::endl;
did_fail = true; did_fail = true;
break; break;
case CXError_InvalidArguments: case CXError_InvalidArguments:
std::cerr << "libclang had invalid arguments for " << filepath << std::endl; std::cerr << "libclang had invalid arguments for " << filepath
did_fail = true; << std::endl;
break; did_fail = true;
case CXError_ASTReadError: break;
std::cerr << "libclang had ast read error for " << filepath << std::endl; case CXError_ASTReadError:
did_fail = true; std::cerr << "libclang had ast read error for " << filepath << std::endl;
break; did_fail = true;
break;
} }
} }
@ -68,33 +64,35 @@ TranslationUnit::~TranslationUnit() {
clang_disposeTranslationUnit(cx_tu); clang_disposeTranslationUnit(cx_tu);
} }
void TranslationUnit::ReparseTranslationUnit(std::vector<CXUnsavedFile>& unsaved) { void TranslationUnit::ReparseTranslationUnit(
int error_code = clang_reparseTranslationUnit(cx_tu, unsaved.size(), unsaved.data(), clang_defaultReparseOptions(cx_tu)); std::vector<CXUnsavedFile>& unsaved) {
int error_code =
clang_reparseTranslationUnit(cx_tu, unsaved.size(), unsaved.data(),
clang_defaultReparseOptions(cx_tu));
switch (error_code) { switch (error_code) {
case CXError_Success: case CXError_Success:
did_fail = false; did_fail = false;
break; break;
case CXError_Failure: case CXError_Failure:
std::cerr << "libclang reparse generic failure" << std::endl; std::cerr << "libclang reparse generic failure" << std::endl;
did_fail = true; did_fail = true;
break; break;
case CXError_Crashed: case CXError_Crashed:
std::cerr << "libclang reparse crashed " << std::endl; std::cerr << "libclang reparse crashed " << std::endl;
did_fail = true; did_fail = true;
break; break;
case CXError_InvalidArguments: case CXError_InvalidArguments:
std::cerr << "libclang reparse had invalid arguments" << std::endl; std::cerr << "libclang reparse had invalid arguments" << std::endl;
did_fail = true; did_fail = true;
break; break;
case CXError_ASTReadError: case CXError_ASTReadError:
std::cerr << "libclang reparse had ast read error" << std::endl; std::cerr << "libclang reparse had ast read error" << std::endl;
did_fail = true; did_fail = true;
break; break;
} }
} }
Cursor TranslationUnit::document_cursor() const { Cursor TranslationUnit::document_cursor() const {
return Cursor(clang_getTranslationUnitCursor(cx_tu)); return Cursor(clang_getTranslationUnitCursor(cx_tu));
} }
} }

View File

@ -10,24 +10,23 @@
#include "../language_server_api.h" #include "../language_server_api.h"
namespace clang { namespace clang {
class TranslationUnit { class TranslationUnit {
public: public:
TranslationUnit(IndexerConfig* config, TranslationUnit(IndexerConfig* config,
Index &index, Index& index,
const std::string &filepath, const std::string& filepath,
const std::vector<std::string>& arguments, const std::vector<std::string>& arguments,
std::vector<CXUnsavedFile> unsaved_files, std::vector<CXUnsavedFile> unsaved_files,
unsigned flags); unsigned flags);
~TranslationUnit(); ~TranslationUnit();
bool did_fail = false; bool did_fail = false;
void ReparseTranslationUnit(std::vector<CXUnsavedFile>& unsaved); void ReparseTranslationUnit(std::vector<CXUnsavedFile>& unsaved);
Cursor document_cursor() const; Cursor document_cursor() const;
CXTranslationUnit cx_tu; CXTranslationUnit cx_tu;
}; };
} // namespace clang } // namespace clang
#endif // TRANSLATIONUNIT_H_ #endif // TRANSLATIONUNIT_H_

View File

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