Skip to content

Commit e397c18

Browse files
authored
Merge branch 'main' into cfg_analyzer_noreturn
2 parents e98e489 + 94a6cd4 commit e397c18

File tree

711 files changed

+33948
-20949
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

711 files changed

+33948
-20949
lines changed

.github/workflows/libc-fullbuild-tests.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,37 +21,37 @@ jobs:
2121
- os: ubuntu-24.04
2222
build_type: Debug
2323
ccache-variant: sccache
24-
c_compiler: clang-20
25-
cpp_compiler: clang++-20
24+
c_compiler: clang-22
25+
cpp_compiler: clang++-22
2626
target: x86_64-unknown-linux-llvm
2727
include_scudo: ON
2828
- os: ubuntu-24.04
2929
build_type: Release
3030
ccache-variant: sccache
31-
c_compiler: clang-20
32-
cpp_compiler: clang++-20
31+
c_compiler: clang-22
32+
cpp_compiler: clang++-22
3333
target: x86_64-unknown-linux-llvm
3434
include_scudo: ON
3535
- os: ubuntu-24.04
3636
build_type: MinSizeRel
3737
ccache-variant: sccache
38-
c_compiler: clang-20
39-
cpp_compiler: clang++-20
38+
c_compiler: clang-22
39+
cpp_compiler: clang++-22
4040
target: x86_64-unknown-linux-llvm
4141
include_scudo: ON
4242
# TODO: remove ccache logic when https://github.com/hendrikmuhs/ccache-action/issues/279 is resolved.
4343
- os: ubuntu-24.04-arm
4444
build_type: Debug
4545
ccache-variant: ccache
46-
c_compiler: clang-20
47-
cpp_compiler: clang++-20
46+
c_compiler: clang-22
47+
cpp_compiler: clang++-22
4848
target: aarch64-unknown-linux-llvm
4949
include_scudo: ON
5050
- os: ubuntu-24.04
5151
build_type: Debug
5252
ccache-variant: ccache
53-
c_compiler: clang-20
54-
cpp_compiler: clang++-20
53+
c_compiler: clang-22
54+
cpp_compiler: clang++-22
5555
target: x86_64-unknown-uefi-llvm
5656
include_scudo: OFF
5757
# TODO: add back gcc build when it is fixed
@@ -81,7 +81,7 @@ jobs:
8181
run: |
8282
wget https://apt.llvm.org/llvm.sh
8383
chmod +x llvm.sh
84-
sudo ./llvm.sh 20
84+
sudo ./llvm.sh 22
8585
sudo apt-get update
8686
sudo apt-get install -y libmpfr-dev libgmp-dev libmpc-dev ninja-build linux-libc-dev
8787
sudo ln -sf /usr/include/$(uname -p)-linux-gnu/asm /usr/include/asm

bolt/test/link_fdata.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import argparse
1111
import os
12+
import platform
1213
import shutil
1314
import subprocess
1415
import sys
@@ -19,7 +20,11 @@
1920
parser.add_argument("objfile", help="Object file to extract symbol values from")
2021
parser.add_argument("output")
2122
parser.add_argument("prefix", nargs="?", default="FDATA", help="Custom FDATA prefix")
22-
parser.add_argument("--nmtool", default="nm", help="Path to nm tool")
23+
parser.add_argument(
24+
"--nmtool",
25+
default="llvm-nm" if platform.system() == "Windows" else "nm",
26+
help="Path to nm tool",
27+
)
2328
parser.add_argument("--no-lbr", action="store_true")
2429
parser.add_argument("--no-redefine", action="store_true")
2530

@@ -86,7 +91,10 @@
8691
exit("ERROR: unexpected input:\n%s" % line)
8792

8893
# Read nm output: <symbol value> <symbol type> <symbol name>
89-
is_llvm_nm = os.path.basename(os.path.realpath(shutil.which(args.nmtool))) == "llvm-nm"
94+
# Ignore .exe on Windows host.
95+
is_llvm_nm = os.path.basename(os.path.realpath(shutil.which(args.nmtool))).startswith(
96+
"llvm-nm"
97+
)
9098
nm_output = subprocess.run(
9199
[
92100
args.nmtool,

clang-tools-extra/clangd/XRefs.cpp

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -859,17 +859,47 @@ std::vector<DocumentLink> getDocumentLinks(ParsedAST &AST) {
859859
for (auto &Inc : AST.getIncludeStructure().MainFileIncludes) {
860860
if (Inc.Resolved.empty())
861861
continue;
862+
863+
// Get the location of the # symbole of the "#include ..." statement
862864
auto HashLoc = SM.getComposedLoc(SM.getMainFileID(), Inc.HashOffset);
865+
866+
// get the # Token itself, std::next to get the "include" token and the
867+
// first token after (aka "File Token")
863868
const auto *HashTok = AST.getTokens().spelledTokenContaining(HashLoc);
864869
assert(HashTok && "got inclusion at wrong offset");
865870
const auto *IncludeTok = std::next(HashTok);
866871
const auto *FileTok = std::next(IncludeTok);
867-
// FileTok->range is not sufficient here, as raw lexing wouldn't yield
868-
// correct tokens for angled filenames. Hence we explicitly use
869-
// Inc.Written's length.
870-
auto FileRange =
871-
syntax::FileRange(SM, FileTok->location(), Inc.Written.length())
872-
.toCharRange(SM);
872+
873+
// The File Token can either be of kind :
874+
// "less" if using the "#include <h-char-sequence> new-line" syntax
875+
// "string_literal" if using the "#include "q-char-sequence" new-line"
876+
// syntax something else (most likely "identifier") if using the "#include
877+
// pp-tokens new-line" syntax (#include with macro argument)
878+
879+
CharSourceRange FileRange;
880+
881+
if (FileTok->kind() == tok::TokenKind::less) {
882+
// FileTok->range would only include the '<' char. Hence we explicitly use
883+
// Inc.Written's length.
884+
FileRange =
885+
syntax::FileRange(SM, FileTok->location(), Inc.Written.length())
886+
.toCharRange(SM);
887+
} else if (FileTok->kind() == tok::TokenKind::string_literal) {
888+
// FileTok->range includes the quotes for string literals so just return
889+
// it.
890+
FileRange = FileTok->range(SM).toCharRange(SM);
891+
} else {
892+
// FileTok is the first Token of a macro spelling
893+
894+
// Report the range of the first token (as it should be the macro
895+
// identifier)
896+
// We could use the AST to find the last spelled token of the macro and
897+
// report a range spanning the full macro expression, but it would require
898+
// using token-buffers that are deemed too unstable and crash-prone
899+
// due to optimizations in cland
900+
901+
FileRange = FileTok->range(SM).toCharRange(SM);
902+
}
873903

874904
Result.push_back(
875905
DocumentLink({halfOpenToRange(SM, FileRange),

clang-tools-extra/clangd/unittests/XRefsTests.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2784,14 +2784,24 @@ TEST(GetNonLocalDeclRefs, All) {
27842784

27852785
TEST(DocumentLinks, All) {
27862786
Annotations MainCpp(R"cpp(
2787+
#define HEADER_AA "faa.h"
2788+
#define HEADER_BB "fbb.h"
2789+
#define GET_HEADER(X) HEADER_ ## X
2790+
27872791
#/*comments*/include /*comments*/ $foo[["foo.h"]] //more comments
27882792
int end_of_preamble = 0;
27892793
#include $bar[[<bar.h>]]
2794+
#include $AA[[GET_HEADER]](AA) // Some comment !
2795+
# /* What about */ \
2796+
include /* multiple line */ \
2797+
$BB[[GET_HEADER]]( /* statements ? */ \
2798+
BB /* :) */ )
27902799
)cpp");
27912800

27922801
TestTU TU;
27932802
TU.Code = std::string(MainCpp.code());
2794-
TU.AdditionalFiles = {{"foo.h", ""}, {"bar.h", ""}};
2803+
TU.AdditionalFiles = {
2804+
{"faa.h", ""}, {"fbb.h", ""}, {"foo.h", ""}, {"bar.h", ""}};
27952805
TU.ExtraArgs = {"-isystem."};
27962806
auto AST = TU.build();
27972807

@@ -2801,7 +2811,11 @@ TEST(DocumentLinks, All) {
28012811
DocumentLink({MainCpp.range("foo"),
28022812
URIForFile::canonicalize(testPath("foo.h"), "")}),
28032813
DocumentLink({MainCpp.range("bar"),
2804-
URIForFile::canonicalize(testPath("bar.h"), "")})));
2814+
URIForFile::canonicalize(testPath("bar.h"), "")}),
2815+
DocumentLink({MainCpp.range("AA"),
2816+
URIForFile::canonicalize(testPath("faa.h"), "")}),
2817+
DocumentLink({MainCpp.range("BB"),
2818+
URIForFile::canonicalize(testPath("fbb.h"), "")})));
28052819
}
28062820

28072821
} // namespace

clang-tools-extra/docs/clang-tidy/checks/bugprone/compare-pointer-to-member-virtual-function.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ virtual functions, thereby improving the overall stability and maintainability
5656
of your code. In scenarios involving pointers to member virtual functions, it's
5757
only advisable to employ ``nullptr`` for comparisons.
5858

59+
5960
Limitations
6061
-----------
6162

clang-tools-extra/docs/clang-tidy/checks/bugprone/copy-constructor-init.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ outcomes. The check ensures that the copy constructor of a derived class
3535
properly calls the copy constructor of the base class, helping to prevent bugs
3636
and improve code quality.
3737

38-
Limitations:
38+
39+
Limitations
40+
-----------
3941

4042
* It won't generate warnings for empty classes, as there are no class members
4143
(including base class sub-objects) to worry about.

clang-tools-extra/docs/clang-tidy/checks/bugprone/crtp-constructor-accessibility.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,9 @@ Example:
8585

8686
CRTP<int> AlsoCompileTimeError;
8787

88-
Limitations:
88+
89+
Limitations
90+
-----------
8991

9092
* The check is not supported below C++11
9193

clang-tools-extra/docs/clang-tidy/checks/bugprone/nondeterministic-pointer-iteration-order.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ This check only detects range-based for loops over unordered sets and maps. It
3535
also detects calls sorting-like algorithms on containers holding pointers.
3636
Other similar usages will not be found and are false negatives.
3737

38-
Limitations:
38+
39+
Limitations
40+
-----------
3941

4042
* This check currently does not check if a nondeterministic iteration order is
4143
likely to be a mistake, and instead marks all such iterations as bugprone.

clang-tools-extra/docs/clang-tidy/checks/bugprone/redundant-branch-condition.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,9 @@ Every possible change is considered, thus if the condition variable is not
7878
a local variable of the function, it is a volatile or it has an alias (pointer
7979
or reference) then no warning is issued.
8080

81-
Known limitations
82-
^^^^^^^^^^^^^^^^^
81+
82+
Limitations
83+
-----------
8384

8485
The ``else`` branch is not checked currently for negated condition variable:
8586

clang-tools-extra/docs/clang-tidy/checks/bugprone/sizeof-expression.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,9 @@ This check corresponds to the CERT C Coding Standard rule
266266
`ARR39-C. Do not add or subtract a scaled integer to a pointer
267267
<http://wiki.sei.cmu.edu/confluence/display/c/ARR39-C.+Do+not+add+or+subtract+a+scaled+integer+to+a+pointer>`_.
268268

269+
269270
Limitations
270-
"""""""""""
271+
-----------
271272

272273
Cases where the pointee type has a size of `1` byte (such as, and most
273274
importantly, ``char``) are excluded.

0 commit comments

Comments
 (0)