Skip to content

Commit 8f0f665

Browse files
committed
Merge remote-tracking branch 'origin/main' into aballman-tentative-defn-cpp-compat
2 parents 0fb0b0c + 4b3acfb commit 8f0f665

File tree

712 files changed

+14614
-4566
lines changed

Some content is hidden

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

712 files changed

+14614
-4566
lines changed

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

Lines changed: 42 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,23 @@ jobs:
1919
include:
2020
- os: ubuntu-24.04
2121
ccache-variant: sccache
22-
c_compiler: clang-20
23-
cpp_compiler: clang++-20
22+
c_compiler: clang-21
23+
cpp_compiler: clang++-21
24+
target: x86_64-unknown-linux-llvm
25+
include_scudo: ON
2426
# TODO: remove ccache logic when https://github.com/hendrikmuhs/ccache-action/issues/279 is resolved.
2527
- os: ubuntu-24.04-arm
2628
ccache-variant: ccache
27-
c_compiler: clang-20
28-
cpp_compiler: clang++-20
29+
c_compiler: clang-21
30+
cpp_compiler: clang++-21
31+
target: aarch64-unknown-linux-llvm
32+
include_scudo: ON
33+
- os: ubuntu-24.04
34+
ccache-variant: ccache
35+
c_compiler: clang-21
36+
cpp_compiler: clang++-21
37+
target: x86_64-unknown-uefi-llvm
38+
include_scudo: OFF
2939
# TODO: add back gcc build when it is fixed
3040
# - c_compiler: gcc
3141
# cpp_compiler: g++
@@ -53,7 +63,7 @@ jobs:
5363
run: |
5464
wget https://apt.llvm.org/llvm.sh
5565
chmod +x llvm.sh
56-
sudo ./llvm.sh 20
66+
sudo ./llvm.sh 21
5767
sudo apt-get update
5868
sudo apt-get install -y libmpfr-dev libgmp-dev libmpc-dev ninja-build linux-libc-dev
5969
sudo ln -sf /usr/include/$(uname -p)-linux-gnu/asm /usr/include/asm
@@ -68,22 +78,31 @@ jobs:
6878
# Configure libc fullbuild with scudo.
6979
# Use MinSizeRel to reduce the size of the build.
7080
- name: Configure CMake
71-
run: >
72-
cmake -B ${{ steps.strings.outputs.build-output-dir }}
73-
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
74-
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
75-
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
76-
-DCMAKE_C_COMPILER_LAUNCHER=${{ matrix.ccache-variant }}
77-
-DCMAKE_CXX_COMPILER_LAUNCHER=${{ matrix.ccache-variant }}
78-
-DCMAKE_INSTALL_PREFIX=${{ steps.strings.outputs.build-install-dir }}
79-
-DLLVM_ENABLE_RUNTIMES="libc;compiler-rt"
80-
-DLLVM_LIBC_FULL_BUILD=ON
81-
-DLLVM_LIBC_INCLUDE_SCUDO=ON
82-
-DCOMPILER_RT_BUILD_SCUDO_STANDALONE_WITH_LLVM_LIBC=ON
83-
-DCOMPILER_RT_BUILD_GWP_ASAN=OFF
84-
-DCOMPILER_RT_SCUDO_STANDALONE_BUILD_SHARED=OFF
85-
-G Ninja
86-
-S ${{ github.workspace }}/runtimes
81+
run: |
82+
export RUNTIMES="libc"
83+
84+
if [[ ${{ matrix.include_scudo}} == "ON" ]]; then
85+
export RUNTIMES="$RUNTIMES;compiler-rt"
86+
export CMAKE_FLAGS="
87+
-DLLVM_LIBC_INCLUDE_SCUDO=ON
88+
-DCOMPILER_RT_BUILD_SCUDO_STANDALONE_WITH_LLVM_LIBC=ON
89+
-DCOMPILER_RT_BUILD_GWP_ASAN=OFF
90+
-DCOMPILER_RT_SCUDO_STANDALONE_BUILD_SHARED=OFF"
91+
fi
92+
93+
cmake -B ${{ steps.strings.outputs.build-output-dir }} \
94+
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} \
95+
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }} \
96+
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
97+
-DCMAKE_C_COMPILER_LAUNCHER=${{ matrix.ccache-variant }} \
98+
-DCMAKE_CXX_COMPILER_LAUNCHER=${{ matrix.ccache-variant }} \
99+
-DCMAKE_INSTALL_PREFIX=${{ steps.strings.outputs.build-install-dir }} \
100+
-DLLVM_RUNTIMES_TARGET=${{ matrix.target }} \
101+
-DLLVM_ENABLE_RUNTIMES="$RUNTIMES" \
102+
-DLLVM_LIBC_FULL_BUILD=ON \
103+
-G Ninja \
104+
-S ${{ github.workspace }}/runtimes \
105+
$CMAKE_FLAGS
87106
88107
- name: Build
89108
run: >
@@ -93,6 +112,8 @@ jobs:
93112
--target install
94113
95114
- name: Test
115+
# Skip UEFI tests until we have testing set up.
116+
if: ${{ ! endsWith(matrix.target, '-uefi-llvm') }}
96117
run: >
97118
cmake
98119
--build ${{ steps.strings.outputs.build-output-dir }}

clang-tools-extra/clangd/index/YAMLSerialization.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,7 @@ template <> struct MappingTraits<Ref> {
319319
MappingNormalization<NormalizedRefKind, RefKind> NKind(IO, R.Kind);
320320
IO.mapRequired("Kind", NKind->Kind);
321321
IO.mapRequired("Location", R.Location);
322+
IO.mapOptional("Container", R.Container);
322323
}
323324
};
324325

clang-tools-extra/clangd/index/remote/Index.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ message Symbol {
8181
message Ref {
8282
optional SymbolLocation location = 1;
8383
optional uint32 kind = 2;
84+
optional string container = 3;
8485
}
8586

8687
message SymbolInfo {

clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,9 @@ llvm::Expected<clangd::Ref> Marshaller::fromProtobuf(const Ref &Message) {
203203
return Location.takeError();
204204
Result.Location = *Location;
205205
Result.Kind = static_cast<RefKind>(Message.kind());
206+
auto ContainerID = SymbolID::fromStr(Message.container());
207+
if (ContainerID)
208+
Result.Container = *ContainerID;
206209
return Result;
207210
}
208211

@@ -340,6 +343,7 @@ llvm::Expected<Ref> Marshaller::toProtobuf(const clangd::Ref &From) {
340343
if (!Location)
341344
return Location.takeError();
342345
*Result.mutable_location() = *Location;
346+
Result.set_container(From.Container.str());
343347
return Result;
344348
}
345349

clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ TEST(RemoteMarshallingTest, RefSerialization) {
223223
Location.FileURI = testPathURI(
224224
"llvm-project/llvm/clang-tools-extra/clangd/Protocol.h", Strings);
225225
Ref.Location = Location;
226+
Ref.Container = llvm::cantFail(SymbolID::fromStr("0000000000000001"));
226227

227228
Marshaller ProtobufMarshaller(testPath("llvm-project/"),
228229
testPath("llvm-project/"));

clang/bindings/python/clang/cindex.py

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,10 @@
7171
from typing import (
7272
Any,
7373
Callable,
74+
cast as Tcast,
7475
Generic,
7576
Optional,
77+
Sequence,
7678
Type as TType,
7779
TypeVar,
7880
TYPE_CHECKING,
@@ -314,6 +316,8 @@ def is_in_system_header(self):
314316
return conf.lib.clang_Location_isInSystemHeader(self) # type: ignore [no-any-return]
315317

316318
def __eq__(self, other):
319+
if not isinstance(other, SourceLocation):
320+
return False
317321
return conf.lib.clang_equalLocations(self, other) # type: ignore [no-any-return]
318322

319323
def __ne__(self, other):
@@ -372,6 +376,8 @@ def end(self):
372376
return conf.lib.clang_getRangeEnd(self) # type: ignore [no-any-return]
373377

374378
def __eq__(self, other):
379+
if not isinstance(other, SourceRange):
380+
return False
375381
return conf.lib.clang_equalRanges(self, other) # type: ignore [no-any-return]
376382

377383
def __ne__(self, other):
@@ -1556,6 +1562,8 @@ def from_location(tu, location):
15561562
return cursor
15571563

15581564
def __eq__(self, other):
1565+
if not isinstance(other, Cursor):
1566+
return False
15591567
return conf.lib.clang_equalCursors(self, other) # type: ignore [no-any-return]
15601568

15611569
def __ne__(self, other):
@@ -1746,7 +1754,7 @@ def get_definition(self):
17461754

17471755
def get_usr(self):
17481756
"""Return the Unified Symbol Resolution (USR) for the entity referenced
1749-
by the given cursor (or None).
1757+
by the given cursor.
17501758
17511759
A Unified Symbol Resolution (USR) is a string that identifies a
17521760
particular entity (function, class, variable, etc.) within a
@@ -2776,7 +2784,7 @@ def pretty_printed(self, policy):
27762784
return _CXString.from_result(conf.lib.clang_getTypePrettyPrinted(self, policy))
27772785

27782786
def __eq__(self, other):
2779-
if type(other) != type(self):
2787+
if not isinstance(other, Type):
27802788
return False
27812789

27822790
return conf.lib.clang_equalTypes(self, other) # type: ignore [no-any-return]
@@ -2886,10 +2894,9 @@ def kind(self):
28862894
def string(self):
28872895
res = conf.lib.clang_getCompletionChunkCompletionString(self.cs, self.key)
28882896

2889-
if res:
2890-
return CompletionString(res)
2891-
else:
2892-
None
2897+
if not res:
2898+
return None
2899+
return CompletionString(res)
28932900

28942901
def isKindOptional(self):
28952902
return self.__kindNumber == 0
@@ -2955,6 +2962,13 @@ def __getitem__(self, key):
29552962
raise IndexError
29562963
return CompletionChunk(self.obj, key)
29572964

2965+
if TYPE_CHECKING:
2966+
# Defining __getitem__ and __len__ is enough to make an iterable
2967+
# but the typechecker doesn't understand that.
2968+
def __iter__(self):
2969+
for i in range(len(self)):
2970+
yield self[i]
2971+
29582972
@property
29592973
def priority(self):
29602974
return conf.lib.clang_getCompletionPriority(self.obj) # type: ignore [no-any-return]
@@ -2970,7 +2984,7 @@ def briefComment(self):
29702984
return _CXString.from_result(
29712985
conf.lib.clang_getCompletionBriefComment(self.obj)
29722986
)
2973-
return _CXString()
2987+
return ""
29742988

29752989
def __repr__(self):
29762990
return (
@@ -3155,8 +3169,8 @@ def from_source(
31553169
a list via args. These can be used to specify include paths, warnings,
31563170
etc. e.g. ["-Wall", "-I/path/to/include"].
31573171
3158-
In-memory file content can be provided via unsaved_files. This is an
3159-
iterable of 2-tuples. The first element is the filename (str or
3172+
In-memory file content can be provided via unsaved_files. This is a
3173+
list of 2-tuples. The first element is the filename (str or
31603174
PathLike). The second element defines the content. Content can be
31613175
provided as str source code or as file objects (anything with a read()
31623176
method). If a file object is being used, content will be read until EOF
@@ -3328,13 +3342,15 @@ def get_extent(self, filename, locations):
33283342
start_location, end_location = locations
33293343

33303344
if hasattr(start_location, "__len__"):
3345+
start_location = Tcast(Sequence[int], start_location)
33313346
start_location = SourceLocation.from_position(
33323347
self, f, start_location[0], start_location[1]
33333348
)
33343349
elif isinstance(start_location, int):
33353350
start_location = SourceLocation.from_offset(self, f, start_location)
33363351

33373352
if hasattr(end_location, "__len__"):
3353+
end_location = Tcast(Sequence[int], end_location)
33383354
end_location = SourceLocation.from_position(
33393355
self, f, end_location[0], end_location[1]
33403356
)
@@ -3464,6 +3480,8 @@ def get_tokens(self, locations=None, extent=None):
34643480
2-tuple of SourceLocation or as a SourceRange. If both are defined,
34653481
behavior is undefined.
34663482
"""
3483+
if locations is None and extent is None:
3484+
raise TypeError("get_tokens() requires at least one argument")
34673485
if locations is not None:
34683486
extent = SourceRange(start=locations[0], end=locations[1])
34693487

@@ -3510,11 +3528,11 @@ def __ne__(self, other) -> bool:
35103528
@staticmethod
35113529
def from_result(res, arg):
35123530
assert isinstance(res, c_object_p)
3513-
res = File(res)
3531+
file = File(res)
35143532

35153533
# Copy a reference to the TranslationUnit to prevent premature GC.
3516-
res._tu = arg._tu
3517-
return res
3534+
file._tu = arg._tu
3535+
return file
35183536

35193537

35203538
class FileInclusion:
@@ -3593,7 +3611,7 @@ def filename(self):
35933611
def arguments(self):
35943612
"""
35953613
Get an iterable object providing each argument in the
3596-
command line for the compiler invocation as a _CXString.
3614+
command line for the compiler invocation as a string.
35973615
35983616
Invariant : the first argument is the compiler executable
35993617
"""

clang/docs/ClangFormatStyleOptions.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5195,6 +5195,29 @@ the configuration (without a prefix: ``Auto``).
51955195
Add a space in front of an Objective-C protocol list, i.e. use
51965196
``Foo <Protocol>`` instead of ``Foo<Protocol>``.
51975197

5198+
.. _OneLineFormatOffRegex:
5199+
5200+
**OneLineFormatOffRegex** (``String``) :versionbadge:`clang-format 21` :ref:`<OneLineFormatOffRegex>`
5201+
A regular expression that describes markers for turning formatting off for
5202+
one line. If it matches a comment that is the only token of a line,
5203+
clang-format skips the comment and the next line. Otherwise, clang-format
5204+
skips lines containing a matched token.
5205+
5206+
.. code-block:: c++
5207+
5208+
// OneLineFormatOffRegex: ^(// NOLINT|logger$)
5209+
// results in the output below:
5210+
int a;
5211+
int b ; // NOLINT
5212+
int c;
5213+
// NOLINTNEXTLINE
5214+
int d ;
5215+
int e;
5216+
s = "// NOLINT";
5217+
logger() ;
5218+
logger2();
5219+
my_logger();
5220+
51985221
.. _PPIndentWidth:
51995222

52005223
**PPIndentWidth** (``Integer``) :versionbadge:`clang-format 13` :ref:`<PPIndentWidth>`

clang/docs/ReleaseNotes.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,9 @@ C Language Changes
197197
``-Wunterminated-string-initialization``. However, this diagnostic is not
198198
silenced by the ``nonstring`` attribute as these initializations are always
199199
incompatible with C++.
200+
- Added the existing ``-Wduplicate-decl-specifier`` diagnostic, which is on by
201+
default, to ``-Wc++-compat`` because duplicated declaration specifiers are
202+
not valid in C++.
200203

201204
C2y Feature Support
202205
^^^^^^^^^^^^^^^^^^^
@@ -260,6 +263,10 @@ Non-comprehensive list of changes in this release
260263
- Added `__builtin_elementwise_minnum` and `__builtin_elementwise_maxnum`.
261264
- No longer crashing on invalid Objective-C categories and extensions when
262265
dumping the AST as JSON. (#GH137320)
266+
- Clang itself now uses split stacks instead of threads for allocating more
267+
stack space when running on Apple AArch64 based platforms. This means that
268+
stack traces of Clang from debuggers, crashes, and profilers may look
269+
different than before.
263270

264271
New Compiler Flags
265272
------------------
@@ -270,6 +277,8 @@ New Compiler Flags
270277
The feature has `existed <https://clang.llvm.org/docs/SourceBasedCodeCoverage.html#running-the-instrumented-program>`_)
271278
for a while and this is just a user facing option.
272279

280+
- New option ``-ftime-report-json`` added which outputs the same timing data as `-ftime-report` but formatted as JSON.
281+
273282
Deprecated Compiler Flags
274283
-------------------------
275284

@@ -520,6 +529,9 @@ Bug Fixes in This Version
520529
evaluation. The crashes were happening during diagnostics emission due to
521530
unimplemented statement printer. (#GH132641)
522531
- Fixed visibility calculation for template functions. (#GH103477)
532+
- Fixed a bug where an attribute before a ``pragma clang attribute`` or
533+
``pragma clang __debug`` would cause an assertion. Instead, this now diagnoses
534+
the invalid attribute location appropriately. (#GH137861)
523535

524536
Bug Fixes to Compiler Builtins
525537
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -746,6 +758,7 @@ clang-format
746758
top of the file.
747759
- Add ``EnumTrailingComma`` option for inserting/removing commas at the end of
748760
``enum`` enumerator lists.
761+
- Add ``OneLineFormatOffRegex`` option for turning formatting off for one line.
749762

750763
libclang
751764
--------

clang/include/clang/AST/Mangle.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ struct ThisAdjustment;
4040
struct ThunkInfo;
4141
class VarDecl;
4242

43+
/// Extract mangling function name from MangleContext such that swift can call
44+
/// it to prepare for ObjCDirect in swift.
45+
void mangleObjCMethodName(raw_ostream &OS, bool includePrefixByte,
46+
bool isInstanceMethod, StringRef ClassName,
47+
std::optional<StringRef> CategoryName,
48+
StringRef MethodName);
49+
4350
/// MangleContext - Context for tracking state which persists across multiple
4451
/// calls to the C++ name mangler.
4552
class MangleContext {

0 commit comments

Comments
 (0)