[clang] [clang-tools-extra] [clang][diagnostics] Stable IDs for Clang diagnostics (PR #168153)
Dave Bartolomeo via cfe-commits
cfe-commits at lists.llvm.org
Tue Mar 3 12:15:26 PST 2026
================
@@ -434,6 +478,30 @@ StringRef DiagnosticIDs::getDescription(unsigned DiagID) const {
return CustomDiagInfo->getDescription(DiagID).GetDescription();
}
+/// getStableID - Given a diagnostic ID, return the stable ID of the diagnostic.
+std::string DiagnosticIDs::getStableID(unsigned DiagID) const {
+ if (const StaticDiagInfoRec *Info = GetDiagInfo(DiagID))
+ return Info->getStableID().str();
+ assert(CustomDiagInfo && "Invalid CustomDiagInfo");
----------------
dbartol wrote:
For a custom diagnostic, `CustomDiagInfo` will always be non-null, so the assert should not trigger. See `DiagnosticIDs::getDescription()` immediately above (not changed in this PR) for an existing example handling the exact same case.
https://github.com/llvm/llvm-project/pull/168153
More information about the cfe-commits
mailing list