diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -110,12 +110,12 @@ `51414 `_, `51416 `_, and `51641 `_. -- The builtin function __builtin_dump_struct would crash clang when the target +- The builtin function __builtin_dump_struct would crash clang when the target struct contains a bitfield. It now correctly handles bitfields. This fixes Issue `Issue 54462 `_. - Statement expressions are now disabled in default arguments in general. This fixes Issue `Issue 53488 `_. -- According to `CWG 1394 `_ and +- According to `CWG 1394 `_ and `C++20 [dcl.fct.def.general]p2 `_, Clang should not diagnose incomplete types in function definitions if the function body is "= delete;". This fixes Issue `Issue 52802 `_. @@ -149,8 +149,8 @@ because there is no way to fully qualify the enumerator name, so this "extension" was unintentional and useless. This fixes `Issue 42372 `_. -- Clang will now find and emit a call to an allocation function in a - promise_type body for coroutines if there is any allocation function +- Clang will now find and emit a call to an allocation function in a + promise_type body for coroutines if there is any allocation function declaration in the scope of promise_type. Additionally, to implement CWG2585, a coroutine will no longer generate a call to a global allocation function with the signature (std::size_t, p0, ..., pn). @@ -296,6 +296,8 @@ operations, such as division or float-to-integer conversion, on ``_BitInt`` types with more than 128 bits currently crash clang. This option will be removed in the future once clang supports all such operations. +- Added the ``-print-diagnostic-options`` option, which prints a list of + warnings the compiler supports. Deprecated Compiler Flags ------------------------- @@ -545,7 +547,7 @@ - Added a new checker ``alpha.unix.cstring.UninitializedRead`` this will check for uninitialized reads from common memory copy/manipulation functions such as ``memcpy``, ``mempcpy``, ``memmove``, ``memcmp``, ` - `strcmp``, ``strncmp``, ``strcpy``, ``strlen``, ``strsep`` and many more. Although + `strcmp``, ``strncmp``, ``strcpy``, ``strlen``, ``strsep`` and many more. Although this checker currently is in list of alpha checkers due to a false positive. .. _release-notes-ubsan: diff --git a/clang/include/clang/Basic/DiagnosticCategories.h b/clang/include/clang/Basic/DiagnosticCategories.h --- a/clang/include/clang/Basic/DiagnosticCategories.h +++ b/clang/include/clang/Basic/DiagnosticCategories.h @@ -21,7 +21,8 @@ }; enum class Group { -#define DIAG_ENTRY(GroupName, FlagNameOffset, Members, SubGroups) GroupName, +#define DIAG_ENTRY(GroupName, FlagNameOffset, Members, SubGroups, Docs) \ + GroupName, #include "clang/Basic/DiagnosticGroups.inc" #undef CATEGORY #undef DIAG_ENTRY diff --git a/clang/include/clang/Basic/DiagnosticIDs.h b/clang/include/clang/Basic/DiagnosticIDs.h --- a/clang/include/clang/Basic/DiagnosticIDs.h +++ b/clang/include/clang/Basic/DiagnosticIDs.h @@ -231,6 +231,9 @@ /// "deprecated-declarations". static StringRef getWarningOptionForGroup(diag::Group); + /// Given a diagnostic group ID, return its documentation. + static StringRef getWarningOptionDocumentation(diag::Group GroupID); + /// Given a group ID, returns the flag that toggles the group. /// For example, for "deprecated-declarations", returns /// Group::DeprecatedDeclarations. diff --git a/clang/lib/Basic/DiagnosticIDs.cpp b/clang/lib/Basic/DiagnosticIDs.cpp --- a/clang/lib/Basic/DiagnosticIDs.cpp +++ b/clang/lib/Basic/DiagnosticIDs.cpp @@ -607,6 +607,7 @@ uint16_t NameOffset; uint16_t Members; uint16_t SubGroups; + StringRef Documentation; // String is stored with a pascal-style length byte. StringRef getName() const { @@ -618,12 +619,17 @@ // Second the table of options, sorted by name for fast binary lookup. static const WarningOption OptionTable[] = { -#define DIAG_ENTRY(GroupName, FlagNameOffset, Members, SubGroups) \ - {FlagNameOffset, Members, SubGroups}, +#define DIAG_ENTRY(GroupName, FlagNameOffset, Members, SubGroups, Docs) \ + {FlagNameOffset, Members, SubGroups, Docs}, #include "clang/Basic/DiagnosticGroups.inc" #undef DIAG_ENTRY }; +/// Given a diagnostic group ID, return its documentation. +StringRef DiagnosticIDs::getWarningOptionDocumentation(diag::Group Group) { + return OptionTable[static_cast(Group)].Documentation; +} + StringRef DiagnosticIDs::getWarningOptionForGroup(diag::Group Group) { return OptionTable[static_cast(Group)].getName(); } diff --git a/clang/tools/diagtool/DiagnosticNames.cpp b/clang/tools/diagtool/DiagnosticNames.cpp --- a/clang/tools/diagtool/DiagnosticNames.cpp +++ b/clang/tools/diagtool/DiagnosticNames.cpp @@ -66,7 +66,7 @@ // Second the table of options, sorted by name for fast binary lookup. static const GroupRecord OptionTable[] = { -#define DIAG_ENTRY(GroupName, FlagNameOffset, Members, SubGroups) \ +#define DIAG_ENTRY(GroupName, FlagNameOffset, Members, SubGroups, Docs) \ {FlagNameOffset, Members, SubGroups}, #include "clang/Basic/DiagnosticGroups.inc" #undef DIAG_ENTRY diff --git a/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp b/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp --- a/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp +++ b/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp @@ -1534,14 +1534,22 @@ const bool hasSubGroups = !SubGroups.empty() || (IsPedantic && !GroupsInPedantic.empty()); if (hasSubGroups) { - OS << "/* DiagSubGroup" << I.second.IDNo << " */ " << SubGroupIndex; + OS << "/* DiagSubGroup" << I.second.IDNo << " */ " << SubGroupIndex + << ", "; if (IsPedantic) SubGroupIndex += GroupsInPedantic.size(); SubGroupIndex += SubGroups.size() + 1; } else { - OS << "0"; + OS << "0, "; } + std::string Documentation = I.second.Defs.back() + ->getValue("Documentation") + ->getValue() + ->getAsUnquotedString(); + + OS << "R\"(" << StringRef(Documentation).trim() << ")\""; + OS << ")\n"; } OS << "#endif // DIAG_ENTRY\n\n";