[cfe-commits] r146287 - in /cfe/trunk: include/clang-c/Index.h tools/libclang/CIndexDiagnostic.cpp tools/libclang/libclang.exports
Ted Kremenek
kremenek at apple.com
Fri Dec 9 14:28:32 PST 2011
Author: kremenek
Date: Fri Dec 9 16:28:32 2011
New Revision: 146287
URL: http://llvm.org/viewvc/llvm-project?rev=146287&view=rev
Log:
Add clang_getDiagnosticSetFromTU() to libclang. Fixes <rdar://problem/10553081>.
Modified:
cfe/trunk/include/clang-c/Index.h
cfe/trunk/tools/libclang/CIndexDiagnostic.cpp
cfe/trunk/tools/libclang/libclang.exports
Modified: cfe/trunk/include/clang-c/Index.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=146287&r1=146286&r2=146287&view=diff
==============================================================================
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Fri Dec 9 16:28:32 2011
@@ -620,6 +620,15 @@
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.
*/
CINDEX_LINKAGE void clang_disposeDiagnostic(CXDiagnostic Diagnostic);
Modified: cfe/trunk/tools/libclang/CIndexDiagnostic.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndexDiagnostic.cpp?rev=146287&r1=146286&r2=146287&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CIndexDiagnostic.cpp (original)
+++ cfe/trunk/tools/libclang/CIndexDiagnostic.cpp Fri Dec 9 16:28:32 2011
@@ -98,15 +98,22 @@
}
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
Modified: cfe/trunk/tools/libclang/libclang.exports
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/libclang.exports?rev=146287&r1=146286&r2=146287&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/libclang.exports (original)
+++ cfe/trunk/tools/libclang/libclang.exports Fri Dec 9 16:28:32 2011
@@ -97,6 +97,7 @@
clang_getDiagnosticNumRanges
clang_getDiagnosticOption
clang_getDiagnosticRange
+clang_getDiagnosticSetFromTU
clang_getDiagnosticSeverity
clang_getDiagnosticSpelling
clang_getElementType
More information about the cfe-commits
mailing list