mirror of
https://github.com/MaskRay/ccls.git
synced 2025-02-16 21:58:08 +00:00
Move all libclangmm/* files into src/* directory
This commit is contained in:
parent
348b4a2e4e
commit
601af73ca9
@ -9,40 +9,8 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
|
||||||
/*
|
|
||||||
#include <execinfo.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
#if false
|
|
||||||
constexpr int kBacktraceBufferSize = 300;
|
|
||||||
|
|
||||||
void EmitBacktrace() {
|
|
||||||
void* buffer[kBacktraceBufferSize];
|
|
||||||
int nptrs = backtrace(buffer, kBacktraceBufferSize);
|
|
||||||
|
|
||||||
fprintf(stderr, "backtrace() returned %d addresses\n", nptrs);
|
|
||||||
|
|
||||||
/* The call backtrace_symbols_fd(buffer, nptrs, STDOUT_FILENO)
|
|
||||||
would produce similar output to the following: */
|
|
||||||
|
|
||||||
char** strings = backtrace_symbols(buffer, nptrs);
|
|
||||||
if (!strings) {
|
|
||||||
perror("Failed to emit backtrace");
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int j = 0; j < nptrs; j++)
|
|
||||||
fprintf(stderr, "%s\n", strings[j]);
|
|
||||||
|
|
||||||
free(strings);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
unsigned Flags() {
|
unsigned Flags() {
|
||||||
// TODO: use clang_defaultEditingTranslationUnitOptions()?
|
// TODO: use clang_defaultEditingTranslationUnitOptions()?
|
||||||
return CXTranslationUnit_Incomplete | CXTranslationUnit_KeepGoing |
|
return CXTranslationUnit_Incomplete | CXTranslationUnit_KeepGoing |
|
||||||
@ -283,8 +251,8 @@ void BuildDetailString(CXCompletionString completion_string,
|
|||||||
|
|
||||||
void TryEnsureDocumentParsed(ClangCompleteManager* manager,
|
void TryEnsureDocumentParsed(ClangCompleteManager* manager,
|
||||||
std::shared_ptr<CompletionSession> session,
|
std::shared_ptr<CompletionSession> session,
|
||||||
std::unique_ptr<clang::TranslationUnit>* tu,
|
std::unique_ptr<ClangTranslationUnit>* tu,
|
||||||
clang::Index* index) {
|
ClangIndex* index) {
|
||||||
// Nothing to do. We already have a translation unit.
|
// Nothing to do. We already have a translation unit.
|
||||||
if (*tu)
|
if (*tu)
|
||||||
return;
|
return;
|
||||||
@ -304,14 +272,14 @@ void TryEnsureDocumentParsed(ClangCompleteManager* manager,
|
|||||||
|
|
||||||
LOG_S(INFO) << "Creating completion session with arguments "
|
LOG_S(INFO) << "Creating completion session with arguments "
|
||||||
<< StringJoin(args);
|
<< StringJoin(args);
|
||||||
*tu = clang::TranslationUnit::Create(index, session->file.filename, args,
|
*tu = ClangTranslationUnit::Create(index, session->file.filename, args,
|
||||||
unsaved, Flags());
|
unsaved, Flags());
|
||||||
|
|
||||||
// Build diagnostics.
|
// Build diagnostics.
|
||||||
if (manager->config_->diagnosticsOnParse && *tu) {
|
if (manager->config_->diagnosticsOnParse && *tu) {
|
||||||
// If we're emitting diagnostics, do an immediate reparse, otherwise we will
|
// If we're emitting diagnostics, do an immediate reparse, otherwise we will
|
||||||
// emit stale/bad diagnostics.
|
// emit stale/bad diagnostics.
|
||||||
*tu = clang::TranslationUnit::Reparse(std::move(*tu), unsaved);
|
*tu = ClangTranslationUnit::Reparse(std::move(*tu), unsaved);
|
||||||
if (!*tu) {
|
if (!*tu) {
|
||||||
LOG_S(ERROR) << "Reparsing translation unit for diagnostics failed for "
|
LOG_S(ERROR) << "Reparsing translation unit for diagnostics failed for "
|
||||||
<< session->file.filename;
|
<< session->file.filename;
|
||||||
@ -352,7 +320,7 @@ void CompletionParseMain(ClangCompleteManager* completion_manager) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<clang::TranslationUnit> parsing;
|
std::unique_ptr<ClangTranslationUnit> parsing;
|
||||||
TryEnsureDocumentParsed(completion_manager, session, &parsing,
|
TryEnsureDocumentParsed(completion_manager, session, &parsing,
|
||||||
&session->index);
|
&session->index);
|
||||||
|
|
||||||
@ -468,7 +436,7 @@ void CompletionQueryMain(ClangCompleteManager* completion_manager) {
|
|||||||
|
|
||||||
timer.Reset();
|
timer.Reset();
|
||||||
session->tu =
|
session->tu =
|
||||||
clang::TranslationUnit::Reparse(std::move(session->tu), unsaved);
|
ClangTranslationUnit::Reparse(std::move(session->tu), unsaved);
|
||||||
timer.ResetAndPrint("[complete] clang_reparseTranslationUnit");
|
timer.ResetAndPrint("[complete] clang_reparseTranslationUnit");
|
||||||
if (!session->tu) {
|
if (!session->tu) {
|
||||||
LOG_S(ERROR) << "Reparsing translation unit for diagnostics failed for "
|
LOG_S(ERROR) << "Reparsing translation unit for diagnostics failed for "
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include "atomic_object.h"
|
#include "atomic_object.h"
|
||||||
|
#include "clang_index.h"
|
||||||
|
#include "clang_translation_unit.h"
|
||||||
#include "language_server_api.h"
|
#include "language_server_api.h"
|
||||||
#include "libclangmm/Index.h"
|
|
||||||
#include "libclangmm/TranslationUnit.h"
|
|
||||||
#include "project.h"
|
#include "project.h"
|
||||||
#include "threaded_queue.h"
|
#include "threaded_queue.h"
|
||||||
#include "working_files.h"
|
#include "working_files.h"
|
||||||
@ -17,7 +17,7 @@ struct CompletionSession
|
|||||||
: public std::enable_shared_from_this<CompletionSession> {
|
: public std::enable_shared_from_this<CompletionSession> {
|
||||||
Project::Entry file;
|
Project::Entry file;
|
||||||
WorkingFiles* working_files;
|
WorkingFiles* working_files;
|
||||||
clang::Index index;
|
ClangIndex index;
|
||||||
|
|
||||||
// When |tu| was last parsed.
|
// When |tu| was last parsed.
|
||||||
optional<std::chrono::time_point<std::chrono::high_resolution_clock>>
|
optional<std::chrono::time_point<std::chrono::high_resolution_clock>>
|
||||||
@ -27,7 +27,7 @@ struct CompletionSession
|
|||||||
std::mutex tu_lock;
|
std::mutex tu_lock;
|
||||||
|
|
||||||
// The active translation unit.
|
// The active translation unit.
|
||||||
std::unique_ptr<clang::TranslationUnit> tu;
|
std::unique_ptr<ClangTranslationUnit> tu;
|
||||||
|
|
||||||
CompletionSession(const Project::Entry& file, WorkingFiles* working_files);
|
CompletionSession(const Project::Entry& file, WorkingFiles* working_files);
|
||||||
~CompletionSession();
|
~CompletionSession();
|
||||||
@ -52,7 +52,7 @@ struct ClangCompleteManager {
|
|||||||
using OnDiagnostic =
|
using OnDiagnostic =
|
||||||
std::function<void(std::string path,
|
std::function<void(std::string path,
|
||||||
NonElidedVector<lsDiagnostic> diagnostics)>;
|
NonElidedVector<lsDiagnostic> diagnostics)>;
|
||||||
using OnIndex = std::function<void(clang::TranslationUnit* tu,
|
using OnIndex = std::function<void(ClangTranslationUnit* tu,
|
||||||
const std::vector<CXUnsavedFile>& unsaved,
|
const std::vector<CXUnsavedFile>& unsaved,
|
||||||
const std::string& path,
|
const std::string& path,
|
||||||
const std::vector<std::string>& args)>;
|
const std::vector<std::string>& args)>;
|
||||||
|
13
src/clang_index.cc
Normal file
13
src/clang_index.cc
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#include "clang_index.h"
|
||||||
|
|
||||||
|
ClangIndex::ClangIndex() : ClangIndex(1, 0) {}
|
||||||
|
|
||||||
|
ClangIndex::ClangIndex(int exclude_declarations_from_pch,
|
||||||
|
int display_diagnostics) {
|
||||||
|
cx_index =
|
||||||
|
clang_createIndex(exclude_declarations_from_pch, display_diagnostics);
|
||||||
|
}
|
||||||
|
|
||||||
|
ClangIndex::~ClangIndex() {
|
||||||
|
clang_disposeIndex(cx_index);
|
||||||
|
}
|
12
src/clang_index.h
Normal file
12
src/clang_index.h
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <clang-c/Index.h>
|
||||||
|
|
||||||
|
// Simple RAII wrapper about CXIndex.
|
||||||
|
class ClangIndex {
|
||||||
|
public:
|
||||||
|
ClangIndex();
|
||||||
|
ClangIndex(int exclude_declarations_from_pch, int display_diagnostics);
|
||||||
|
~ClangIndex();
|
||||||
|
CXIndex cx_index;
|
||||||
|
};
|
@ -1,7 +1,7 @@
|
|||||||
#include "TranslationUnit.h"
|
#include "clang_translation_unit.h"
|
||||||
|
|
||||||
#include "../platform.h"
|
#include "platform.h"
|
||||||
#include "../utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
#include <loguru.hpp>
|
#include <loguru.hpp>
|
||||||
|
|
||||||
@ -10,11 +10,9 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
namespace clang {
|
|
||||||
|
|
||||||
// static
|
// static
|
||||||
std::unique_ptr<TranslationUnit> TranslationUnit::Create(
|
std::unique_ptr<ClangTranslationUnit> ClangTranslationUnit::Create(
|
||||||
Index* index,
|
ClangIndex* 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,
|
||||||
@ -34,7 +32,7 @@ std::unique_ptr<TranslationUnit> TranslationUnit::Create(
|
|||||||
|
|
||||||
switch (error_code) {
|
switch (error_code) {
|
||||||
case CXError_Success:
|
case CXError_Success:
|
||||||
return MakeUnique<TranslationUnit>(cx_tu);
|
return MakeUnique<ClangTranslationUnit>(cx_tu);
|
||||||
case CXError_Failure:
|
case CXError_Failure:
|
||||||
LOG_S(ERROR) << "libclang generic failure for " << filepath
|
LOG_S(ERROR) << "libclang generic failure for " << filepath
|
||||||
<< " with args " << StringJoin(args);
|
<< " with args " << StringJoin(args);
|
||||||
@ -57,8 +55,8 @@ std::unique_ptr<TranslationUnit> TranslationUnit::Create(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
std::unique_ptr<TranslationUnit> TranslationUnit::Reparse(
|
std::unique_ptr<ClangTranslationUnit> ClangTranslationUnit::Reparse(
|
||||||
std::unique_ptr<TranslationUnit> tu,
|
std::unique_ptr<ClangTranslationUnit> tu,
|
||||||
std::vector<CXUnsavedFile>& unsaved) {
|
std::vector<CXUnsavedFile>& unsaved) {
|
||||||
int error_code = clang_reparseTranslationUnit(
|
int error_code = clang_reparseTranslationUnit(
|
||||||
tu->cx_tu, (unsigned)unsaved.size(), unsaved.data(),
|
tu->cx_tu, (unsigned)unsaved.size(), unsaved.data(),
|
||||||
@ -83,10 +81,8 @@ std::unique_ptr<TranslationUnit> TranslationUnit::Reparse(
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
TranslationUnit::TranslationUnit(CXTranslationUnit tu) : cx_tu(tu) {}
|
ClangTranslationUnit::ClangTranslationUnit(CXTranslationUnit tu) : cx_tu(tu) {}
|
||||||
|
|
||||||
TranslationUnit::~TranslationUnit() {
|
ClangTranslationUnit::~ClangTranslationUnit() {
|
||||||
clang_disposeTranslationUnit(cx_tu);
|
clang_disposeTranslationUnit(cx_tu);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace clang
|
|
32
src/clang_translation_unit.h
Normal file
32
src/clang_translation_unit.h
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "clang_cursor.h"
|
||||||
|
#include "clang_index.h"
|
||||||
|
|
||||||
|
#include <clang-c/Index.h>
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
// RAII wrapper around CXTranslationUnit which also makes it much more
|
||||||
|
// challenging to use a CXTranslationUnit instance that is not correctly
|
||||||
|
// initialized.
|
||||||
|
class ClangTranslationUnit {
|
||||||
|
public:
|
||||||
|
static std::unique_ptr<ClangTranslationUnit> Create(
|
||||||
|
ClangIndex* index,
|
||||||
|
const std::string& filepath,
|
||||||
|
const std::vector<std::string>& arguments,
|
||||||
|
std::vector<CXUnsavedFile> unsaved_files,
|
||||||
|
unsigned flags);
|
||||||
|
|
||||||
|
static std::unique_ptr<ClangTranslationUnit> Reparse(
|
||||||
|
std::unique_ptr<ClangTranslationUnit> tu,
|
||||||
|
std::vector<CXUnsavedFile>& unsaved);
|
||||||
|
|
||||||
|
explicit ClangTranslationUnit(CXTranslationUnit tu);
|
||||||
|
~ClangTranslationUnit();
|
||||||
|
|
||||||
|
CXTranslationUnit cx_tu;
|
||||||
|
};
|
@ -835,7 +835,7 @@ enum class FileParseQuery { NeedsParse, DoesNotNeedParse, NoSuchFile };
|
|||||||
std::vector<Index_DoIdMap> DoParseFile(
|
std::vector<Index_DoIdMap> DoParseFile(
|
||||||
Config* config,
|
Config* config,
|
||||||
WorkingFiles* working_files,
|
WorkingFiles* working_files,
|
||||||
clang::Index* index,
|
ClangIndex* index,
|
||||||
FileConsumer::SharedState* file_consumer_shared,
|
FileConsumer::SharedState* file_consumer_shared,
|
||||||
TimestampManager* timestamp_manager,
|
TimestampManager* timestamp_manager,
|
||||||
ImportManager* import_manager,
|
ImportManager* import_manager,
|
||||||
@ -1018,14 +1018,14 @@ std::vector<Index_DoIdMap> DoParseFile(
|
|||||||
void IndexWithTuFromCodeCompletion(
|
void IndexWithTuFromCodeCompletion(
|
||||||
QueueManager* queue,
|
QueueManager* queue,
|
||||||
FileConsumer::SharedState* file_consumer_shared,
|
FileConsumer::SharedState* file_consumer_shared,
|
||||||
clang::TranslationUnit* tu,
|
ClangTranslationUnit* tu,
|
||||||
const std::vector<CXUnsavedFile>& file_contents,
|
const std::vector<CXUnsavedFile>& file_contents,
|
||||||
const std::string& path,
|
const std::string& path,
|
||||||
const std::vector<std::string>& args) {
|
const std::vector<std::string>& args) {
|
||||||
file_consumer_shared->Reset(path);
|
file_consumer_shared->Reset(path);
|
||||||
|
|
||||||
PerformanceImportFile perf;
|
PerformanceImportFile perf;
|
||||||
clang::Index index(0, 0);
|
ClangIndex index;
|
||||||
std::vector<std::unique_ptr<IndexFile>> indexes = ParseWithTu(
|
std::vector<std::unique_ptr<IndexFile>> indexes = ParseWithTu(
|
||||||
file_consumer_shared, &perf, tu, &index, path, args, file_contents);
|
file_consumer_shared, &perf, tu, &index, path, args, file_contents);
|
||||||
|
|
||||||
@ -1050,7 +1050,7 @@ void IndexWithTuFromCodeCompletion(
|
|||||||
std::vector<Index_DoIdMap> ParseFile(
|
std::vector<Index_DoIdMap> ParseFile(
|
||||||
Config* config,
|
Config* config,
|
||||||
WorkingFiles* working_files,
|
WorkingFiles* working_files,
|
||||||
clang::Index* index,
|
ClangIndex* index,
|
||||||
FileConsumer::SharedState* file_consumer_shared,
|
FileConsumer::SharedState* file_consumer_shared,
|
||||||
TimestampManager* timestamp_manager,
|
TimestampManager* timestamp_manager,
|
||||||
ImportManager* import_manager,
|
ImportManager* import_manager,
|
||||||
@ -1079,7 +1079,7 @@ bool IndexMain_DoParse(Config* config,
|
|||||||
FileConsumer::SharedState* file_consumer_shared,
|
FileConsumer::SharedState* file_consumer_shared,
|
||||||
TimestampManager* timestamp_manager,
|
TimestampManager* timestamp_manager,
|
||||||
ImportManager* import_manager,
|
ImportManager* import_manager,
|
||||||
clang::Index* index) {
|
ClangIndex* index) {
|
||||||
optional<Index_Request> request = queue->index_request.TryDequeue();
|
optional<Index_Request> request = queue->index_request.TryDequeue();
|
||||||
if (!request)
|
if (!request)
|
||||||
return false;
|
return false;
|
||||||
@ -1216,7 +1216,7 @@ WorkThread::Result IndexMain(Config* config,
|
|||||||
EmitProgress(queue);
|
EmitProgress(queue);
|
||||||
|
|
||||||
// TODO: dispose of index after it is not used for a while.
|
// TODO: dispose of index after it is not used for a while.
|
||||||
clang::Index index(1, 0);
|
ClangIndex index;
|
||||||
|
|
||||||
// TODO: process all off IndexMain_DoIndex before calling
|
// TODO: process all off IndexMain_DoIndex before calling
|
||||||
// IndexMain_DoCreateIndexUpdate for
|
// IndexMain_DoCreateIndexUpdate for
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
|
|
||||||
#include "clang_cursor.h"
|
#include "clang_cursor.h"
|
||||||
#include "clang_utils.h"
|
#include "clang_utils.h"
|
||||||
#include "libclangmm/Index.h"
|
|
||||||
#include "libclangmm/TranslationUnit.h"
|
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
#include "serializer.h"
|
#include "serializer.h"
|
||||||
#include "timer.h"
|
#include "timer.h"
|
||||||
@ -208,13 +206,13 @@ struct IndexParam {
|
|||||||
// translation unit.
|
// translation unit.
|
||||||
IndexFile* primary_file = nullptr;
|
IndexFile* primary_file = nullptr;
|
||||||
|
|
||||||
clang::TranslationUnit* tu = nullptr;
|
ClangTranslationUnit* tu = nullptr;
|
||||||
|
|
||||||
FileConsumer* file_consumer = nullptr;
|
FileConsumer* file_consumer = nullptr;
|
||||||
NamespaceHelper ns;
|
NamespaceHelper ns;
|
||||||
ConstructorCache ctors;
|
ConstructorCache ctors;
|
||||||
|
|
||||||
IndexParam(clang::TranslationUnit* tu, FileConsumer* file_consumer)
|
IndexParam(ClangTranslationUnit* tu, FileConsumer* file_consumer)
|
||||||
: tu(tu), file_consumer(file_consumer) {}
|
: tu(tu), file_consumer(file_consumer) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1592,7 +1590,7 @@ std::vector<std::unique_ptr<IndexFile>> Parse(
|
|||||||
const std::vector<std::string>& args,
|
const std::vector<std::string>& args,
|
||||||
const std::vector<FileContents>& file_contents,
|
const std::vector<FileContents>& file_contents,
|
||||||
PerformanceImportFile* perf,
|
PerformanceImportFile* perf,
|
||||||
clang::Index* index,
|
ClangIndex* index,
|
||||||
bool dump_ast) {
|
bool dump_ast) {
|
||||||
if (!config->enableIndexing)
|
if (!config->enableIndexing)
|
||||||
return {};
|
return {};
|
||||||
@ -1610,7 +1608,7 @@ std::vector<std::unique_ptr<IndexFile>> Parse(
|
|||||||
unsaved_files.push_back(unsaved);
|
unsaved_files.push_back(unsaved);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<clang::TranslationUnit> tu = clang::TranslationUnit::Create(
|
std::unique_ptr<ClangTranslationUnit> tu = ClangTranslationUnit::Create(
|
||||||
index, file, args, unsaved_files,
|
index, file, args, unsaved_files,
|
||||||
CXTranslationUnit_KeepGoing |
|
CXTranslationUnit_KeepGoing |
|
||||||
CXTranslationUnit_DetailedPreprocessingRecord);
|
CXTranslationUnit_DetailedPreprocessingRecord);
|
||||||
@ -1629,8 +1627,8 @@ std::vector<std::unique_ptr<IndexFile>> Parse(
|
|||||||
std::vector<std::unique_ptr<IndexFile>> ParseWithTu(
|
std::vector<std::unique_ptr<IndexFile>> ParseWithTu(
|
||||||
FileConsumer::SharedState* file_consumer_shared,
|
FileConsumer::SharedState* file_consumer_shared,
|
||||||
PerformanceImportFile* perf,
|
PerformanceImportFile* perf,
|
||||||
clang::TranslationUnit* tu,
|
ClangTranslationUnit* tu,
|
||||||
clang::Index* index,
|
ClangIndex* index,
|
||||||
const std::string& file,
|
const std::string& file,
|
||||||
const std::vector<std::string>& args,
|
const std::vector<std::string>& args,
|
||||||
const std::vector<CXUnsavedFile>& file_contents) {
|
const std::vector<CXUnsavedFile>& file_contents) {
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "clang_index.h"
|
||||||
|
#include "clang_translation_unit.h"
|
||||||
#include "clang_utils.h"
|
#include "clang_utils.h"
|
||||||
#include "file_consumer.h"
|
#include "file_consumer.h"
|
||||||
#include "language_server_api.h"
|
#include "language_server_api.h"
|
||||||
#include "libclangmm/Index.h"
|
|
||||||
#include "libclangmm/TranslationUnit.h"
|
|
||||||
#include "performance.h"
|
#include "performance.h"
|
||||||
#include "position.h"
|
#include "position.h"
|
||||||
#include "serializer.h"
|
#include "serializer.h"
|
||||||
@ -525,13 +525,13 @@ std::vector<std::unique_ptr<IndexFile>> Parse(
|
|||||||
const std::vector<std::string>& args,
|
const std::vector<std::string>& args,
|
||||||
const std::vector<FileContents>& file_contents,
|
const std::vector<FileContents>& file_contents,
|
||||||
PerformanceImportFile* perf,
|
PerformanceImportFile* perf,
|
||||||
clang::Index* index,
|
ClangIndex* index,
|
||||||
bool dump_ast = false);
|
bool dump_ast = false);
|
||||||
std::vector<std::unique_ptr<IndexFile>> ParseWithTu(
|
std::vector<std::unique_ptr<IndexFile>> ParseWithTu(
|
||||||
FileConsumer::SharedState* file_consumer_shared,
|
FileConsumer::SharedState* file_consumer_shared,
|
||||||
PerformanceImportFile* perf,
|
PerformanceImportFile* perf,
|
||||||
clang::TranslationUnit* tu,
|
ClangTranslationUnit* tu,
|
||||||
clang::Index* index,
|
ClangIndex* index,
|
||||||
const std::string& file,
|
const std::string& file,
|
||||||
const std::vector<std::string>& args,
|
const std::vector<std::string>& args,
|
||||||
const std::vector<CXUnsavedFile>& file_contents);
|
const std::vector<CXUnsavedFile>& file_contents);
|
||||||
|
@ -1,9 +0,0 @@
|
|||||||
#include "Index.h"
|
|
||||||
|
|
||||||
clang::Index::Index(int excludeDeclarationsFromPCH, int displayDiagnostics) {
|
|
||||||
cx_index = clang_createIndex(excludeDeclarationsFromPCH, displayDiagnostics);
|
|
||||||
}
|
|
||||||
|
|
||||||
clang::Index::~Index() {
|
|
||||||
clang_disposeIndex(cx_index);
|
|
||||||
}
|
|
@ -1,13 +0,0 @@
|
|||||||
#ifndef INDEX_H_
|
|
||||||
#define INDEX_H_
|
|
||||||
#include <clang-c/Index.h>
|
|
||||||
|
|
||||||
namespace clang {
|
|
||||||
class Index {
|
|
||||||
public:
|
|
||||||
Index(int excludeDeclarationsFromPCH, int displayDiagnostics);
|
|
||||||
~Index();
|
|
||||||
CXIndex cx_index;
|
|
||||||
};
|
|
||||||
} // namespace clang
|
|
||||||
#endif // INDEX_H_
|
|
@ -1,33 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include "../clang_cursor.h"
|
|
||||||
#include "Index.h"
|
|
||||||
|
|
||||||
#include <clang-c/Index.h>
|
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
namespace clang {
|
|
||||||
|
|
||||||
class TranslationUnit {
|
|
||||||
public:
|
|
||||||
static std::unique_ptr<TranslationUnit> Create(
|
|
||||||
Index* index,
|
|
||||||
const std::string& filepath,
|
|
||||||
const std::vector<std::string>& arguments,
|
|
||||||
std::vector<CXUnsavedFile> unsaved_files,
|
|
||||||
unsigned flags);
|
|
||||||
|
|
||||||
static std::unique_ptr<TranslationUnit> Reparse(
|
|
||||||
std::unique_ptr<TranslationUnit> tu,
|
|
||||||
std::vector<CXUnsavedFile>& unsaved);
|
|
||||||
|
|
||||||
explicit TranslationUnit(CXTranslationUnit tu);
|
|
||||||
~TranslationUnit();
|
|
||||||
|
|
||||||
CXTranslationUnit cx_tu;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace clang
|
|
@ -269,7 +269,7 @@ std::vector<Project::Entry> LoadCompilationEntriesFromDirectory(
|
|||||||
for (unsigned j = 0; j < num_args; ++j)
|
for (unsigned j = 0; j < num_args; ++j)
|
||||||
entry.args.push_back(
|
entry.args.push_back(
|
||||||
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.
|
clang_time.Pause(); // TODO: don't call ToString in this block.
|
||||||
|
|
||||||
our_time.Resume();
|
our_time.Resume();
|
||||||
std::string absolute_filename;
|
std::string absolute_filename;
|
||||||
|
@ -113,7 +113,7 @@ void RunTests() {
|
|||||||
|
|
||||||
// TODO: Assert that we need to be on clang >= 3.9.1
|
// TODO: Assert that we need to be on clang >= 3.9.1
|
||||||
bool update_all = false;
|
bool update_all = false;
|
||||||
clang::Index index(1, 0);
|
ClangIndex index;
|
||||||
|
|
||||||
for (std::string path : GetFilesInFolder("tests", true /*recursive*/,
|
for (std::string path : GetFilesInFolder("tests", true /*recursive*/,
|
||||||
true /*add_folder_to_path*/)) {
|
true /*add_folder_to_path*/)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user