Changeset View
Changeset View
Standalone View
Standalone View
plugins/clang/duchain/parsesession.cpp
Show First 20 Lines • Show All 374 Lines • ▼ Show 20 Line(s) | 348 | { | |||
---|---|---|---|---|---|
375 | } | 375 | } | ||
376 | 376 | | |||
377 | return m_definesFile.fileName().toUtf8(); | 377 | return m_definesFile.fileName().toUtf8(); | ||
378 | } | 378 | } | ||
379 | 379 | | |||
380 | void ParseSessionData::setUnit(CXTranslationUnit unit) | 380 | void ParseSessionData::setUnit(CXTranslationUnit unit) | ||
381 | { | 381 | { | ||
382 | m_unit = unit; | 382 | m_unit = unit; | ||
383 | m_diagnosticsCache.clear(); | ||||
383 | if (m_unit) { | 384 | if (m_unit) { | ||
384 | const ClangString unitFile(clang_getTranslationUnitSpelling(unit)); | 385 | const ClangString unitFile(clang_getTranslationUnitSpelling(unit)); | ||
385 | m_file = clang_getFile(m_unit, unitFile.c_str()); | 386 | m_file = clang_getFile(m_unit, unitFile.c_str()); | ||
386 | } else { | 387 | } else { | ||
387 | m_file = nullptr; | 388 | m_file = nullptr; | ||
388 | } | 389 | } | ||
389 | } | 390 | } | ||
390 | 391 | | |||
▲ Show 20 Lines • Show All 53 Lines • ▼ Show 20 Line(s) | 444 | if (!d) { | |||
444 | return {}; | 445 | return {}; | ||
445 | } | 446 | } | ||
446 | 447 | | |||
447 | QList<ProblemPointer> problems; | 448 | QList<ProblemPointer> problems; | ||
448 | 449 | | |||
449 | // extra clang diagnostics | 450 | // extra clang diagnostics | ||
450 | const uint numDiagnostics = clang_getNumDiagnostics(d->m_unit); | 451 | const uint numDiagnostics = clang_getNumDiagnostics(d->m_unit); | ||
451 | problems.reserve(numDiagnostics); | 452 | problems.reserve(numDiagnostics); | ||
453 | d->m_diagnosticsCache.resize(numDiagnostics); | ||||
454 | | ||||
452 | for (uint i = 0; i < numDiagnostics; ++i) { | 455 | for (uint i = 0; i < numDiagnostics; ++i) { | ||
453 | auto diagnostic = clang_getDiagnostic(d->m_unit, i); | 456 | auto diagnostic = clang_getDiagnostic(d->m_unit, i); | ||
454 | 457 | | |||
455 | CXSourceLocation location = clang_getDiagnosticLocation(diagnostic); | 458 | CXSourceLocation location = clang_getDiagnosticLocation(diagnostic); | ||
456 | CXFile diagnosticFile; | 459 | CXFile diagnosticFile; | ||
457 | clang_getFileLocation(location, &diagnosticFile, nullptr, nullptr, nullptr); | 460 | clang_getFileLocation(location, &diagnosticFile, nullptr, nullptr, nullptr); | ||
458 | // missing-include problems are so severe in clang that we always propagate | 461 | // missing-include problems are so severe in clang that we always propagate | ||
459 | // them to this document, to ensure that the user will see the error. | 462 | // them to this document, to ensure that the user will see the error. | ||
460 | if (diagnosticFile != file && ClangDiagnosticEvaluator::diagnosticType(diagnostic) != ClangDiagnosticEvaluator::IncludeFileNotFoundProblem) { | 463 | if (diagnosticFile != file && ClangDiagnosticEvaluator::diagnosticType(diagnostic) != ClangDiagnosticEvaluator::IncludeFileNotFoundProblem) { | ||
461 | continue; | 464 | continue; | ||
462 | } | 465 | } | ||
463 | 466 | | |||
464 | ProblemPointer problem(ClangDiagnosticEvaluator::createProblem(diagnostic, d->m_unit)); | 467 | auto& problem = d->m_diagnosticsCache[i]; | ||
468 | if (!problem) { | ||||
469 | problem = ClangDiagnosticEvaluator::createProblem(diagnostic, d->m_unit); | ||||
470 | } | ||||
471 | | ||||
465 | problems << problem; | 472 | problems << problem; | ||
466 | 473 | | |||
467 | clang_disposeDiagnostic(diagnostic); | 474 | clang_disposeDiagnostic(diagnostic); | ||
468 | } | 475 | } | ||
469 | 476 | | |||
470 | // other problem sources | 477 | // other problem sources | ||
471 | 478 | | |||
472 | TodoExtractor extractor(unit(), file); | 479 | TodoExtractor extractor(unit(), file); | ||
▲ Show 20 Lines • Show All 67 Lines • Show Last 20 Lines |