Skip to content

Commit 7d9f913

Browse files
committed
Update comment on getCustomDiagID; NFC
These APIs should almost never be used in Clang, so documenting that more clearly. The problem is that the diagnostics are never associated with a diagnostic group, so users have no way to control warning behavior associated with the diagnostic. That makes for a poor user experience. Instead, use a real diagnostic whenever possible or the API taking a CustomDiagDesc as a last resort.
1 parent 020856e commit 7d9f913

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

clang/include/clang/Basic/Diagnostic.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -895,7 +895,10 @@ class DiagnosticsEngine : public RefCountedBase<DiagnosticsEngine> {
895895
/// \param FormatString A fixed diagnostic format string that will be hashed
896896
/// and mapped to a unique DiagID.
897897
template <unsigned N>
898-
// TODO: Deprecate this once all uses are removed from Clang.
898+
// FIXME: this API should almost never be used; custom diagnostics do not
899+
// have an associated diagnostic group and thus cannot be controlled by users
900+
// like other diagnostics. The number of times this API is used in Clang
901+
// should only ever be reduced, not increased.
899902
// [[deprecated("Use a CustomDiagDesc instead of a Level")]]
900903
unsigned getCustomDiagID(Level L, const char (&FormatString)[N]) {
901904
return Diags->getCustomDiagID((DiagnosticIDs::Level)L,

clang/include/clang/Basic/DiagnosticIDs.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,10 @@ class DiagnosticIDs : public RefCountedBase<DiagnosticIDs> {
283283
// writing, nearly all callers of this function were invalid.
284284
unsigned getCustomDiagID(CustomDiagDesc Diag);
285285

286-
// TODO: Deprecate this once all uses are removed from LLVM
286+
// FIXME: this API should almost never be used; custom diagnostics do not
287+
// have an associated diagnostic group and thus cannot be controlled by users
288+
// like other diagnostics. The number of times this API is used in Clang
289+
// should only ever be reduced, not increased.
287290
// [[deprecated("Use a CustomDiagDesc instead of a Level")]]
288291
unsigned getCustomDiagID(Level Level, StringRef Message) {
289292
return getCustomDiagID([&]() -> CustomDiagDesc {

0 commit comments

Comments
 (0)