diff --git a/src/CompilationDatabase.h b/src/CompilationDatabase.h index 860f7bf..0527fdf 100644 --- a/src/CompilationDatabase.h +++ b/src/CompilationDatabase.h @@ -5,7 +5,6 @@ #include namespace clang { - class CompileCommands; class CompilationDatabase { public: explicit CompilationDatabase(const std::string &project_path); diff --git a/src/CompileCommand.cc b/src/CompileCommand.cc index 4ba97b7..3d98579 100644 --- a/src/CompileCommand.cc +++ b/src/CompileCommand.cc @@ -1,11 +1,6 @@ #include "CompileCommand.h" #include "CompileCommands.h" -clang::CompileCommand:: -CompileCommand(int nth, clang::CompileCommands &commands) { - cx_command = clang_CompileCommands_getCommand(commands.cx_commands, nth); -} - std::string clang::CompileCommand:: get_command() { std::string res; diff --git a/src/CompileCommand.h b/src/CompileCommand.h index 51f64a3..ba87d7d 100644 --- a/src/CompileCommand.h +++ b/src/CompileCommand.h @@ -1,12 +1,12 @@ #ifndef COMPILECOMMAND_H_ #define COMPILECOMMAND_H_ -#include "CompilationDatabase.h" +#include #include namespace clang { class CompileCommand { public: - CompileCommand(int nth, CompileCommands &commands); + CompileCommand(const CXCompileCommand& cx_command) : cx_command(cx_command) {}; std::string get_command(); std::vector get_command_as_args(); diff --git a/src/CompileCommands.cc b/src/CompileCommands.cc index 26ea944..2b5494b 100644 --- a/src/CompileCommands.cc +++ b/src/CompileCommands.cc @@ -18,7 +18,7 @@ get_commands() { unsigned N = clang_CompileCommands_getSize(cx_commands); std::vector res; for (unsigned i = 0; i < N; i++) { - res.emplace_back(clang::CompileCommand(i, *this)); + res.emplace_back(clang_CompileCommands_getCommand(cx_commands, i)); } return res; } diff --git a/src/Cursor.h b/src/Cursor.h index 05824d9..4b5fc10 100644 --- a/src/Cursor.h +++ b/src/Cursor.h @@ -175,7 +175,7 @@ namespace clang { class Cursor { public: - Cursor(CXCursor cx_cursor) : cx_cursor(cx_cursor) {} + Cursor(const CXCursor &cx_cursor) : cx_cursor(cx_cursor) {} Cursor(CXTranslationUnit &cx_tu, SourceLocation &source_location); const CursorKind get_kind(); SourceLocation get_source_location() const; diff --git a/src/SourceLocation.h b/src/SourceLocation.h index ad25c24..0837dc1 100644 --- a/src/SourceLocation.h +++ b/src/SourceLocation.h @@ -7,7 +7,7 @@ namespace clang { class SourceLocation { public: - SourceLocation(CXSourceLocation cx_location) : cx_location(cx_location) {} + SourceLocation(const CXSourceLocation& cx_location) : cx_location(cx_location) {} SourceLocation(CXTranslationUnit &cx_tu, const std::string &filename, diff --git a/src/SourceRange.h b/src/SourceRange.h index 6ca89a3..7a85504 100644 --- a/src/SourceRange.h +++ b/src/SourceRange.h @@ -13,7 +13,7 @@ namespace clang { class SourceRange { public: - SourceRange(CXSourceRange cx_range) : cx_range(cx_range) {} + SourceRange(const CXSourceRange& cx_range) : cx_range(cx_range) {} SourceRange(SourceLocation &start, SourceLocation &end); std::pair get_source_locations(); static RangeData get_range_data(SourceLocation &start, SourceLocation &end);