[all-commits] [llvm/llvm-project] 734787: [diagtool] Make the BuiltinDiagnosticsByID table s...
Karl-Johan Karlsson via All-commits
all-commits at lists.llvm.org
Fri Jan 17 01:23:50 PST 2025
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 73478708839fad8b02b3cfc84959d64a15ba93ca
https://github.com/llvm/llvm-project/commit/73478708839fad8b02b3cfc84959d64a15ba93ca
Author: Karl-Johan Karlsson <karl-johan.karlsson at ericsson.com>
Date: 2025-01-17 (Fri, 17 Jan 2025)
Changed paths:
A clang/include/clang/Basic/AllDiagnosticKinds.inc
M clang/lib/Basic/DiagnosticIDs.cpp
M clang/tools/diagtool/DiagnosticNames.cpp
Log Message:
-----------
[diagtool] Make the BuiltinDiagnosticsByID table sorted (#120321)
When building with -DLLVM_ENABLE_EXPENSIVE_CHECKS=ON with a recent
libstdc++ (e.g. from gcc 13.3.0) the testcase
clang/test/Misc/warning-flags-tree.c fail with the message:
```
+ diagtool tree --internal
.../include/c++/13.3.0/bits/stl_algo.h:2013:
In function:
_ForwardIterator std::lower_bound(_ForwardIterator, _ForwardIterator,
const _Tp &, _Compare) [_ForwardIterator = const
diagtool::DiagnosticRecord *, _Tp = diagtool::DiagnosticRecord, _Compare
= bool (*)(const diagtool::DiagnosticRecord &, const
diagtool::DiagnosticRecord &)]
Error: elements in iterator range [first, last) are not partitioned by the predicate __comp and value __val.
Objects involved in the operation:
iterator "first" @ 0x7ffea8ef2fd8 {
}
iterator "last" @ 0x7ffea8ef2fd0 {
}
```
The reason for this error is that std::lower_bound is called on
BuiltinDiagnosticsByID without it being entirely sorted. Calling
std::lower_bound If the range is not sorted, the behavior of this
function is undefined. This is detected when building with expensive
checks.
To make BuiltinDiagnosticsByID sorted we need to slightly change the
order the inc-files are included. The include of
DiagnosticCrossTUKinds.inc in DiagnosticNames.cpp is included too early
and should be moved down directly after DiagnosticCommentKinds.inc.
As a part of pull request the includes that build up
BuiltinDiagnosticsByID table are extracted into a common wrapper header
file AllDiagnosticKinds.inc that is used by both clang and diagtool.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list