forked from OSchip/llvm-project
Add clang_getDiagnosticSetFromTU() to libclang. Fixes <rdar://problem/10553081>.
llvm-svn: 146287
This commit is contained in:
parent
2d6d886d73
commit
b4a8b056f8
clang
|
@ -619,6 +619,15 @@ CINDEX_LINKAGE unsigned clang_getNumDiagnostics(CXTranslationUnit Unit);
|
|||
CINDEX_LINKAGE CXDiagnostic clang_getDiagnostic(CXTranslationUnit Unit,
|
||||
unsigned Index);
|
||||
|
||||
/**
|
||||
* \brief Retrieve the complete set of diagnostics associated with a
|
||||
* translation unit.
|
||||
*
|
||||
* \param Unit the translation unit to query.
|
||||
*/
|
||||
CINDEX_LINKAGE CXDiagnosticSet
|
||||
clang_getDiagnosticSetFromTU(CXTranslationUnit Unit);
|
||||
|
||||
/**
|
||||
* \brief Destroy a diagnostic.
|
||||
*/
|
||||
|
|
|
@ -98,15 +98,22 @@ unsigned clang_getNumDiagnostics(CXTranslationUnit Unit) {
|
|||
}
|
||||
|
||||
CXDiagnostic clang_getDiagnostic(CXTranslationUnit Unit, unsigned Index) {
|
||||
if (!Unit->TUData)
|
||||
CXDiagnosticSet D = clang_getDiagnosticSetFromTU(Unit);
|
||||
if (!D)
|
||||
return 0;
|
||||
|
||||
CXDiagnosticSetImpl *Diags = lazyCreateDiags(Unit);
|
||||
CXDiagnosticSetImpl *Diags = static_cast<CXDiagnosticSetImpl*>(D);
|
||||
if (Index >= Diags->getNumDiagnostics())
|
||||
return 0;
|
||||
|
||||
return Diags->getDiagnostic(Index);
|
||||
}
|
||||
|
||||
CXDiagnosticSet clang_getDiagnosticSetFromTU(CXTranslationUnit Unit) {
|
||||
if (!Unit->TUData)
|
||||
return 0;
|
||||
return static_cast<CXDiagnostic>(lazyCreateDiags(Unit));
|
||||
}
|
||||
|
||||
void clang_disposeDiagnostic(CXDiagnostic Diagnostic) {
|
||||
// No-op. Kept as a legacy API. CXDiagnostics are now managed
|
||||
|
|
|
@ -97,6 +97,7 @@ clang_getDiagnosticNumFixIts
|
|||
clang_getDiagnosticNumRanges
|
||||
clang_getDiagnosticOption
|
||||
clang_getDiagnosticRange
|
||||
clang_getDiagnosticSetFromTU
|
||||
clang_getDiagnosticSeverity
|
||||
clang_getDiagnosticSpelling
|
||||
clang_getElementType
|
||||
|
|
Loading…
Reference in New Issue