diff options
author | Ted Kremenek <kremenek@apple.com> | 2012-04-12 00:03:31 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2012-04-12 00:03:31 +0000 |
commit | 26a6d498ee5f2c3e592328128a9fb74db87531cc (patch) | |
tree | 2ecff96942e482a28bf26b771c22c258bab5b2ea /clang/tools/libclang/CIndexDiagnostic.cpp | |
parent | 5811fd6cc45d0af6fc7eb714fa60bf8f1ef5e75f (diff) | |
download | bcm5719-llvm-26a6d498ee5f2c3e592328128a9fb74db87531cc.tar.gz bcm5719-llvm-26a6d498ee5f2c3e592328128a9fb74db87531cc.zip |
Implement clang_getDiagnosticCategoryText() to provide a way for a client of libclang to accurately
get the diagnostic category name from a serialized diagnostic when the version of libclang used
to read the diagnostic file is newer than the clang that emitted the diagnostic file.
llvm-svn: 154567
Diffstat (limited to 'clang/tools/libclang/CIndexDiagnostic.cpp')
-rw-r--r-- | clang/tools/libclang/CIndexDiagnostic.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/clang/tools/libclang/CIndexDiagnostic.cpp b/clang/tools/libclang/CIndexDiagnostic.cpp index d8a2b05b206..8fbe3d8c3d3 100644 --- a/clang/tools/libclang/CIndexDiagnostic.cpp +++ b/clang/tools/libclang/CIndexDiagnostic.cpp @@ -72,6 +72,8 @@ public: } unsigned getCategory() const { return 0; } + CXString getCategoryText() const { return createCXString(""); } + unsigned getNumRanges() const { return 0; } CXSourceRange getRange(unsigned Range) const { return clang_getNullRange(); } unsigned getNumFixIts() const { return 0; } @@ -324,7 +326,7 @@ CXString clang_formatDiagnostic(CXDiagnostic Diagnostic, unsigned Options) { } if (Options & CXDiagnostic_DisplayCategoryName) { - CXString CategoryName = clang_getDiagnosticCategoryName(CategoryID); + CXString CategoryName = clang_getDiagnosticCategoryText(Diagnostic); if (NeedBracket) Out << " ["; if (NeedComma) @@ -385,9 +387,16 @@ unsigned clang_getDiagnosticCategory(CXDiagnostic Diag) { } CXString clang_getDiagnosticCategoryName(unsigned Category) { + // Kept for backwards compatibility. return createCXString(DiagnosticIDs::getCategoryNameFromID(Category)); } +CXString clang_getDiagnosticCategoryText(CXDiagnostic Diag) { + if (CXDiagnosticImpl *D = static_cast<CXDiagnosticImpl *>(Diag)) + return D->getCategoryText(); + return createCXString(""); +} + unsigned clang_getDiagnosticNumRanges(CXDiagnostic Diag) { if (CXDiagnosticImpl *D = static_cast<CXDiagnosticImpl *>(Diag)) return D->getNumRanges(); |