mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-22 07:35:08 +00:00
Remove parts of libclangmm
This commit is contained in:
parent
d867d962d8
commit
b165cfa59d
@ -1,17 +0,0 @@
|
||||
#include "CompilationDatabase.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
clang::CompilationDatabase::CompilationDatabase(const std::string& project_path) {
|
||||
CXCompilationDatabase_Error error;
|
||||
cx_db = clang_CompilationDatabase_fromDirectory(project_path.c_str(), &error);
|
||||
if (error == CXCompilationDatabase_CanNotLoadDatabase) {
|
||||
std::cerr << "[FATAL]: Unable to load compile_commands.json located at \""
|
||||
<< project_path << "\"";
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
clang::CompilationDatabase::~CompilationDatabase() {
|
||||
clang_CompilationDatabase_dispose(cx_db);
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <clang-c/CXCompilationDatabase.h>
|
||||
|
||||
namespace clang {
|
||||
|
||||
struct CompilationCommand {
|
||||
std::string path;
|
||||
std::string args;
|
||||
};
|
||||
|
||||
class CompilationDatabase {
|
||||
public:
|
||||
explicit CompilationDatabase(const std::string &project_path);
|
||||
~CompilationDatabase();
|
||||
|
||||
CXCompilationDatabase cx_db;
|
||||
};
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
#include "CompileCommand.h"
|
||||
#include "CompileCommands.h"
|
||||
#include "Utility.h"
|
||||
|
||||
namespace clang {
|
||||
|
||||
CompileCommand::CompileCommand(const CXCompileCommand& command)
|
||||
: cx_command(command) {};
|
||||
|
||||
std::string CompileCommand::get_command() const {
|
||||
std::string result;
|
||||
unsigned int num_args = clang_CompileCommand_getNumArgs(cx_command);
|
||||
for (unsigned int i = 0; i < num_args; i++)
|
||||
result += ToString(clang_CompileCommand_getArg(cx_command, i));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
std::vector<std::string> CompileCommand::get_command_as_args() const {
|
||||
unsigned num_args = clang_CompileCommand_getNumArgs(cx_command);
|
||||
std::vector<std::string> result(num_args);
|
||||
for (unsigned i = 0; i < num_args; i++)
|
||||
result[i] = ToString(clang_CompileCommand_getArg(cx_command, i));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace clang
|
@ -1,16 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <clang-c/CXCompilationDatabase.h>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
namespace clang {
|
||||
class CompileCommand {
|
||||
public:
|
||||
CompileCommand(const CXCompileCommand& cx_command);
|
||||
std::string get_command() const;
|
||||
std::vector<std::string> get_command_as_args() const;
|
||||
|
||||
CXCompileCommand cx_command;
|
||||
};
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
#include "CompileCommands.h"
|
||||
|
||||
clang::CompileCommands::CompileCommands(const CompilationDatabase& db) {
|
||||
cx_commands =
|
||||
clang_CompilationDatabase_getAllCompileCommands(db.cx_db);
|
||||
//if (clang_CompileCommands_getSize(cx_commands) == 0)
|
||||
// cx_commands = clang_CompilationDatabase_getAllCompileCommands(db.cx_db);
|
||||
}
|
||||
|
||||
clang::CompileCommands::~CompileCommands() {
|
||||
clang_CompileCommands_dispose(cx_commands);
|
||||
}
|
||||
|
||||
std::vector<clang::CompileCommand> clang::CompileCommands::get_commands() {
|
||||
unsigned N = clang_CompileCommands_getSize(cx_commands);
|
||||
std::vector<CompileCommand> res;
|
||||
for (unsigned i = 0; i < N; i++) {
|
||||
CXCompileCommand command = clang_CompileCommands_getCommand(cx_commands, i);
|
||||
res.push_back(command);
|
||||
}
|
||||
return res;
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <clang-c/CXCompilationDatabase.h>
|
||||
|
||||
#include "CompilationDatabase.h"
|
||||
#include "CompileCommand.h"
|
||||
|
||||
namespace clang {
|
||||
class CompileCommands {
|
||||
public:
|
||||
CompileCommands(const CompilationDatabase& db);
|
||||
std::vector<CompileCommand> get_commands();
|
||||
~CompileCommands();
|
||||
|
||||
CXCompileCommands cx_commands;
|
||||
};
|
||||
}
|
@ -46,9 +46,11 @@ std::string Type::get_spelling() const {
|
||||
return ToString(clang_getTypeSpelling(cx_type));
|
||||
}
|
||||
|
||||
/*
|
||||
SourceLocation Cursor::get_source_location() const {
|
||||
return SourceLocation(clang_getCursorLocation(cx_cursor));
|
||||
}
|
||||
*/
|
||||
|
||||
Type Type::get_return_type() const {
|
||||
return Type(clang_getResultType(cx_type));
|
||||
|
@ -6,7 +6,6 @@
|
||||
#include <type_traits>
|
||||
|
||||
#include <clang-c/Index.h>
|
||||
#include "SourceLocation.h"
|
||||
#include "SourceRange.h"
|
||||
|
||||
|
||||
@ -51,7 +50,7 @@ public:
|
||||
|
||||
CXCursorKind get_kind() const;
|
||||
Type get_type() const;
|
||||
SourceLocation get_source_location() const;
|
||||
//SourceLocation get_source_location() const;
|
||||
//SourceRange get_source_range() const;
|
||||
std::string get_spelling() const;
|
||||
std::string get_display_name() const;
|
||||
|
@ -1,47 +0,0 @@
|
||||
#include <cassert>
|
||||
|
||||
#include "SourceLocation.h"
|
||||
#include "Utility.h"
|
||||
|
||||
namespace clang {
|
||||
|
||||
SourceLocation::SourceLocation(CXTranslationUnit &tu, const std::string &filepath, unsigned offset) {
|
||||
CXFile file = clang_getFile(tu, filepath.c_str());
|
||||
assert(false);
|
||||
//cx_location = clang_getLocationForOffset(tu, file, offset);
|
||||
}
|
||||
|
||||
SourceLocation::SourceLocation(CXTranslationUnit &tu, const std::string &filepath, unsigned line, unsigned column) {
|
||||
CXFile file = clang_getFile(tu, filepath.c_str());
|
||||
assert(false);
|
||||
//cx_location = clang_getLocation(tu, file, line, column);
|
||||
}
|
||||
|
||||
SourceLocation::SourceLocation() {}
|
||||
|
||||
SourceLocation::SourceLocation(const CXSourceLocation& cx_location) {
|
||||
//clang_getExpansionLocation
|
||||
|
||||
CXFile file;
|
||||
clang_getSpellingLocation(cx_location, &file, &line, &column, &offset);
|
||||
if (file != nullptr)
|
||||
path = clang::ToString(clang_getFileName(file));
|
||||
}
|
||||
|
||||
SourceLocation::SourceLocation(const CXIdxLoc& cx_location)
|
||||
: SourceLocation(clang_indexLoc_getCXSourceLocation(cx_location)) {
|
||||
}
|
||||
|
||||
bool operator==(const SourceLocation& a, const SourceLocation& b) {
|
||||
return a.path == b.path && a.line == b.line && a.column == b.column;
|
||||
}
|
||||
|
||||
bool operator!=(const SourceLocation& a, const SourceLocation& b) {
|
||||
return !(a == b);
|
||||
}
|
||||
|
||||
std::string SourceLocation::ToString() const {
|
||||
return path + ":" + std::to_string(line) + ":" + std::to_string(column);
|
||||
}
|
||||
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
#ifndef SOURCELOCATION_H_
|
||||
#define SOURCELOCATION_H_
|
||||
|
||||
#include <clang-c/Index.h>
|
||||
#include <string>
|
||||
|
||||
namespace clang {
|
||||
|
||||
class Offset {
|
||||
public:
|
||||
Offset() {}
|
||||
Offset(unsigned line, unsigned index) : line(line), index(index) {}
|
||||
bool operator==(const clang::Offset &o) { return (line == o.line && index == o.index); }
|
||||
bool operator!=(const clang::Offset &o) { return !(*this == o); }
|
||||
unsigned line;
|
||||
unsigned index; //byte index in line (not char number)
|
||||
};
|
||||
|
||||
class SourceLocation {
|
||||
friend class TranslationUnit;
|
||||
SourceLocation(CXTranslationUnit &tu, const std::string &filepath, unsigned offset);
|
||||
SourceLocation(CXTranslationUnit &tu, const std::string &filepath, unsigned line, unsigned column);
|
||||
public:
|
||||
SourceLocation();
|
||||
SourceLocation(const CXSourceLocation& cx_location);
|
||||
SourceLocation(const CXIdxLoc& cx_location);
|
||||
|
||||
std::string path;
|
||||
unsigned line = 0;
|
||||
unsigned column = 0;
|
||||
unsigned offset = 0;
|
||||
|
||||
std::string ToString() const;
|
||||
};
|
||||
|
||||
bool operator==(const SourceLocation& a, const SourceLocation& b);
|
||||
bool operator!=(const SourceLocation& a, const SourceLocation& b);
|
||||
|
||||
} // namespace clang
|
||||
|
||||
#endif // SOURCELOCATION_H_
|
@ -1,7 +1,6 @@
|
||||
#ifndef SOURCERANGE_H_
|
||||
#define SOURCERANGE_H_
|
||||
#include <clang-c/Index.h>
|
||||
#include "SourceLocation.h"
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
#include "TranslationUnit.h"
|
||||
#include "SourceLocation.h"
|
||||
#include "Tokens.h"
|
||||
#include "Utility.h"
|
||||
#include <fstream>
|
||||
|
@ -1,13 +1,9 @@
|
||||
#ifndef CLANGMM_H_
|
||||
#define CLANGMM_H_
|
||||
#include "TranslationUnit.h"
|
||||
#include "SourceLocation.h"
|
||||
#include "SourceRange.h"
|
||||
#include "Token.h"
|
||||
#include "Tokens.h"
|
||||
#include "CompilationDatabase.h"
|
||||
#include "CompileCommands.h"
|
||||
#include "CompileCommand.h"
|
||||
#include "CodeCompleteResults.h"
|
||||
#include "CompletionString.h"
|
||||
#include "Index.h"
|
||||
|
Loading…
Reference in New Issue
Block a user