mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-26 17:41:58 +00:00
Fix null pointer dereference of param.primary_file
This commit is contained in:
parent
181b405c54
commit
007bc5362c
@ -1932,25 +1932,29 @@ std::vector<std::unique_ptr<IndexFile>> ParseWithTu(
|
|||||||
perf->index_build = timer.ElapsedMicrosecondsAndReset();
|
perf->index_build = timer.ElapsedMicrosecondsAndReset();
|
||||||
|
|
||||||
std::unordered_map<std::string, int> inc_to_line;
|
std::unordered_map<std::string, int> inc_to_line;
|
||||||
for (auto &inc : param.primary_file->includes)
|
// TODO
|
||||||
inc_to_line[inc.resolved_path] = inc.line;
|
if (param.primary_file)
|
||||||
|
for (auto &inc : param.primary_file->includes)
|
||||||
|
inc_to_line[inc.resolved_path] = inc.line;
|
||||||
|
|
||||||
auto result = param.file_consumer->TakeLocalState();
|
auto result = param.file_consumer->TakeLocalState();
|
||||||
for (std::unique_ptr<IndexFile>& entry : result) {
|
for (std::unique_ptr<IndexFile>& entry : result) {
|
||||||
entry->import_file = file;
|
entry->import_file = file;
|
||||||
entry->args = args;
|
entry->args = args;
|
||||||
|
|
||||||
// If there are errors, show at least one at the include position.
|
if (param.primary_file) {
|
||||||
auto it = inc_to_line.find(entry->path);
|
// If there are errors, show at least one at the include position.
|
||||||
if (it != inc_to_line.end()) {
|
auto it = inc_to_line.find(entry->path);
|
||||||
int line = it->second;
|
if (it != inc_to_line.end()) {
|
||||||
for (auto ls_diagnostic : entry->diagnostics_) {
|
int line = it->second;
|
||||||
if (ls_diagnostic.severity != lsDiagnosticSeverity::Error)
|
for (auto ls_diagnostic : entry->diagnostics_) {
|
||||||
continue;
|
if (ls_diagnostic.severity != lsDiagnosticSeverity::Error)
|
||||||
ls_diagnostic.range =
|
continue;
|
||||||
lsRange(lsPosition(line, 10), lsPosition(line, 10));
|
ls_diagnostic.range =
|
||||||
param.primary_file->diagnostics_.push_back(ls_diagnostic);
|
lsRange(lsPosition(line, 10), lsPosition(line, 10));
|
||||||
break;
|
param.primary_file->diagnostics_.push_back(ls_diagnostic);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user