Skip to content

Commit eb9ecef

Browse files
authored
Merge branch 'main' into main
2 parents 0c7d8ae + fd80048 commit eb9ecef

File tree

856 files changed

+14117
-24581
lines changed

Some content is hidden

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

856 files changed

+14117
-24581
lines changed

.github/workflows/libcxx-build-and-test.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
stage1:
3838
if: github.repository_owner == 'llvm'
3939
runs-on: libcxx-self-hosted-linux
40-
container: ghcr.io/llvm/libcxx-linux-builder:b6bb9dc5abd7c6452c13a53fa8949cb259db459b
40+
container: ghcr.io/llvm/libcxx-linux-builder:2b57ebb50b6d418e70382e655feaa619b558e254
4141
continue-on-error: false
4242
strategy:
4343
fail-fast: false
@@ -75,7 +75,7 @@ jobs:
7575
stage2:
7676
if: github.repository_owner == 'llvm'
7777
runs-on: libcxx-self-hosted-linux
78-
container: ghcr.io/llvm/libcxx-linux-builder:b6bb9dc5abd7c6452c13a53fa8949cb259db459b
78+
container: ghcr.io/llvm/libcxx-linux-builder:2b57ebb50b6d418e70382e655feaa619b558e254
7979
needs: [ stage1 ]
8080
continue-on-error: false
8181
strategy:
@@ -163,7 +163,7 @@ jobs:
163163
- config: 'generic-msan'
164164
machine: libcxx-self-hosted-linux
165165
runs-on: ${{ matrix.machine }}
166-
container: ghcr.io/llvm/libcxx-linux-builder:b6bb9dc5abd7c6452c13a53fa8949cb259db459b
166+
container: ghcr.io/llvm/libcxx-linux-builder:2b57ebb50b6d418e70382e655feaa619b558e254
167167
steps:
168168
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
169169
- name: ${{ matrix.config }}

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

+11-10
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,12 @@ SlabTuple indexSymbols(ASTContext &AST, Preprocessor &PP,
4848
const MainFileMacros *MacroRefsToIndex,
4949
const include_cleaner::PragmaIncludes &PI,
5050
bool IsIndexMainAST, llvm::StringRef Version,
51-
bool CollectMainFileRefs) {
51+
bool CollectMainFileRefs, SymbolOrigin Origin) {
5252
SymbolCollector::Options CollectorOpts;
5353
CollectorOpts.CollectIncludePath = true;
5454
CollectorOpts.PragmaIncludes = Π
5555
CollectorOpts.CountReferences = false;
56-
CollectorOpts.Origin =
57-
IsIndexMainAST ? SymbolOrigin::Open : SymbolOrigin::Preamble;
56+
CollectorOpts.Origin = Origin;
5857
CollectorOpts.CollectMainFileRefs = CollectMainFileRefs;
5958
// We want stdlib implementation details in the index only if we've opened the
6059
// file in question. This does means xrefs won't work, though.
@@ -221,22 +220,24 @@ FileShardedIndex::getShard(llvm::StringRef Uri) const {
221220
}
222221

223222
SlabTuple indexMainDecls(ParsedAST &AST) {
224-
return indexSymbols(
225-
AST.getASTContext(), AST.getPreprocessor(), AST.getLocalTopLevelDecls(),
226-
&AST.getMacros(), AST.getPragmaIncludes(),
227-
/*IsIndexMainAST=*/true, AST.version(), /*CollectMainFileRefs=*/true);
223+
return indexSymbols(AST.getASTContext(), AST.getPreprocessor(),
224+
AST.getLocalTopLevelDecls(), &AST.getMacros(),
225+
AST.getPragmaIncludes(),
226+
/*IsIndexMainAST=*/true, AST.version(),
227+
/*CollectMainFileRefs=*/true, SymbolOrigin::Open);
228228
}
229229

230230
SlabTuple indexHeaderSymbols(llvm::StringRef Version, ASTContext &AST,
231231
Preprocessor &PP,
232-
const include_cleaner::PragmaIncludes &PI) {
232+
const include_cleaner::PragmaIncludes &PI,
233+
SymbolOrigin Origin) {
233234
std::vector<Decl *> DeclsToIndex(
234235
AST.getTranslationUnitDecl()->decls().begin(),
235236
AST.getTranslationUnitDecl()->decls().end());
236237
return indexSymbols(AST, PP, DeclsToIndex,
237238
/*MainFileMacros=*/nullptr, PI,
238239
/*IsIndexMainAST=*/false, Version,
239-
/*CollectMainFileRefs=*/false);
240+
/*CollectMainFileRefs=*/false, Origin);
240241
}
241242

242243
FileSymbols::FileSymbols(IndexContents IdxContents, bool SupportContainedRefs)
@@ -462,7 +463,7 @@ void FileIndex::updatePreamble(PathRef Path, llvm::StringRef Version,
462463
const include_cleaner::PragmaIncludes &PI) {
463464
IndexFileIn IF;
464465
std::tie(IF.Symbols, std::ignore, IF.Relations) =
465-
indexHeaderSymbols(Version, AST, PP, PI);
466+
indexHeaderSymbols(Version, AST, PP, PI, SymbolOrigin::Preamble);
466467
updatePreamble(std::move(IF));
467468
}
468469

clang-tools-extra/clangd/index/FileIndex.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,8 @@ SlabTuple indexMainDecls(ParsedAST &AST);
164164
/// included headers.
165165
SlabTuple indexHeaderSymbols(llvm::StringRef Version, ASTContext &AST,
166166
Preprocessor &PP,
167-
const include_cleaner::PragmaIncludes &PI);
167+
const include_cleaner::PragmaIncludes &PI,
168+
SymbolOrigin Origin);
168169

169170
/// Takes slabs coming from a TU (multiple files) and shards them per
170171
/// declaration location.

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

+18-19
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,15 @@
1515
#include "Compiler.h"
1616
#include "Config.h"
1717
#include "SymbolCollector.h"
18+
#include "clang-include-cleaner/Record.h"
19+
#include "index/FileIndex.h"
1820
#include "index/IndexAction.h"
1921
#include "support/Logger.h"
2022
#include "support/ThreadsafeFS.h"
2123
#include "support/Trace.h"
2224
#include "clang/Basic/LangOptions.h"
2325
#include "clang/Frontend/CompilerInvocation.h"
26+
#include "clang/Frontend/FrontendActions.h"
2427
#include "clang/Lex/PreprocessorOptions.h"
2528
#include "clang/Tooling/Inclusions/StandardLibrary.h"
2629
#include "llvm/ADT/IntrusiveRefCntPtr.h"
@@ -223,33 +226,29 @@ SymbolSlab indexStandardLibrary(llvm::StringRef HeaderSources,
223226
return Symbols;
224227
}
225228

226-
SymbolCollector::Options IndexOpts;
227-
IndexOpts.Origin = SymbolOrigin::StdLib;
228-
IndexOpts.CollectMainFileSymbols = false;
229-
IndexOpts.CollectMainFileRefs = false;
230-
IndexOpts.CollectMacro = true;
231-
IndexOpts.StoreAllDocumentation = true;
232-
// Sadly we can't use IndexOpts.FileFilter to restrict indexing scope.
233-
// Files from outside the StdLibLocation may define true std symbols anyway.
234-
// We end up "blessing" such headers, and can only do that by indexing
235-
// everything first.
236-
237-
// Refs, relations, include graph in the stdlib mostly aren't useful.
238-
auto Action = createStaticIndexingAction(
239-
IndexOpts, [&](SymbolSlab S) { Symbols = std::move(S); }, nullptr,
240-
nullptr, nullptr);
241-
242-
if (!Action->BeginSourceFile(*Clang, Input)) {
229+
SyntaxOnlyAction Action;
230+
231+
if (!Action.BeginSourceFile(*Clang, Input)) {
243232
elog("Standard Library Index: BeginSourceFile() failed");
244233
return Symbols;
245234
}
246235

247-
if (llvm::Error Err = Action->Execute()) {
236+
if (llvm::Error Err = Action.Execute()) {
248237
elog("Standard Library Index: Execute failed: {0}", std::move(Err));
249238
return Symbols;
250239
}
251240

252-
Action->EndSourceFile();
241+
// We don't care about include graph for stdlib headers, so provide a no-op
242+
// PI.
243+
include_cleaner::PragmaIncludes PI;
244+
auto Slabs =
245+
indexHeaderSymbols("", Clang->getASTContext(), Clang->getPreprocessor(),
246+
PI, SymbolOrigin::StdLib);
247+
Symbols = std::move(std::get<0>(Slabs));
248+
249+
// Run EndSourceFile() after indexing completes, so ensure the AST and
250+
// preprocessor state is alive during indexing.
251+
Action.EndSourceFile();
253252

254253
unsigned SymbolsBeforeFilter = Symbols.size();
255254
Symbols = filter(std::move(Symbols), Loc);

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

+48
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@
1313
#include "Config.h"
1414
#include "SyncAPI.h"
1515
#include "TestFS.h"
16+
#include "index/Index.h"
1617
#include "index/StdLib.h"
1718
#include "clang/Basic/LangOptions.h"
1819
#include "clang/Basic/SourceManager.h"
20+
#include "llvm/Testing/Support/Error.h"
1921
#include "gmock/gmock.h"
2022
#include "gtest/gtest.h"
2123
#include <memory>
@@ -158,6 +160,52 @@ TEST(StdLibTests, EndToEnd) {
158160
UnorderedElementsAre(StdlibSymbol("list"), StdlibSymbol("vector")));
159161
}
160162

163+
TEST(StdLibTests, StdLibDocComments) {
164+
Config Cfg;
165+
Cfg.Index.StandardLibrary = true;
166+
WithContextValue Enabled(Config::Key, std::move(Cfg));
167+
168+
MockFS FS;
169+
FS.Files["stdlib/vector"] = R"cpp(
170+
namespace std {
171+
struct vector {
172+
/**doc comment*/
173+
struct inner {};
174+
};
175+
}
176+
)cpp";
177+
MockCompilationDatabase CDB;
178+
CDB.ExtraClangFlags.push_back("-isystem" + testPath("stdlib"));
179+
ClangdServer::Options Opts = ClangdServer::optsForTest();
180+
Opts.BuildDynamicSymbolIndex = true; // also used for stdlib index
181+
ClangdServer Server(CDB, FS, Opts);
182+
183+
// Open an empty file. <vector> will not be part of the preamble index,
184+
// but it will be part of the stdlib index.
185+
Server.addDocument(testPath("foo.cc"), "");
186+
187+
// Wait for the stdlib index to be built.
188+
ASSERT_TRUE(Server.blockUntilIdleForTest());
189+
190+
// Check that the index contains the doc comment.
191+
SymbolSlab Result;
192+
EXPECT_THAT_ERROR(runCustomAction(Server, testPath("foo.cc"),
193+
[&](InputsAndAST Inputs) {
194+
FuzzyFindRequest Req;
195+
Req.Query = "inner";
196+
Req.Scopes = {"std::vector::"};
197+
SymbolSlab::Builder Builder;
198+
Inputs.Inputs.Index->fuzzyFind(
199+
Req, [&](const Symbol &Sym) {
200+
Builder.insert(Sym);
201+
});
202+
Result = std::move(Builder).build();
203+
}),
204+
llvm::Succeeded());
205+
ASSERT_EQ(Result.size(), 1u);
206+
EXPECT_EQ(Result.begin()->Documentation, "doc comment");
207+
}
208+
161209
} // namespace
162210
} // namespace clangd
163211
} // namespace clang

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "Diagnostics.h"
1313
#include "TestFS.h"
1414
#include "index/FileIndex.h"
15+
#include "index/SymbolOrigin.h"
1516
#include "clang/AST/RecursiveASTVisitor.h"
1617
#include "clang/Basic/Diagnostic.h"
1718
#include "clang/Frontend/CompilerInvocation.h"
@@ -164,7 +165,7 @@ SymbolSlab TestTU::headerSymbols() const {
164165
auto AST = build();
165166
return std::get<0>(indexHeaderSymbols(
166167
/*Version=*/"null", AST.getASTContext(), AST.getPreprocessor(),
167-
AST.getPragmaIncludes()));
168+
AST.getPragmaIncludes(), SymbolOrigin::Preamble));
168169
}
169170

170171
RefSlab TestTU::headerRefs() const {

clang/bindings/python/clang/cindex.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1887,7 +1887,7 @@ def binary_operator(self):
18871887
"""
18881888

18891889
if not hasattr(self, "_binopcode"):
1890-
self._binopcode = conf.lib.clang_Cursor_getBinaryOpcode(self)
1890+
self._binopcode = conf.lib.clang_getCursorBinaryOperatorKind(self)
18911891

18921892
return BinaryOperator.from_id(self._binopcode)
18931893

@@ -4097,7 +4097,7 @@ def set_property(self, property, value):
40974097
("clang_Cursor_getTemplateArgumentType", [Cursor, c_uint], Type),
40984098
("clang_Cursor_getTemplateArgumentValue", [Cursor, c_uint], c_longlong),
40994099
("clang_Cursor_getTemplateArgumentUnsignedValue", [Cursor, c_uint], c_ulonglong),
4100-
("clang_Cursor_getBinaryOpcode", [Cursor], c_int),
4100+
("clang_getCursorBinaryOperatorKind", [Cursor], c_int),
41014101
("clang_Cursor_getBriefCommentText", [Cursor], _CXString),
41024102
("clang_Cursor_getRawCommentText", [Cursor], _CXString),
41034103
("clang_Cursor_getOffsetOfField", [Cursor], c_longlong),

clang/docs/CommandGuide/clang.rst

+17
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,23 @@ Language Selection and Mode Options
146146
147147
ISO C 2017 with GNU extensions
148148

149+
| ``c23``
150+
| ``iso9899:2024``
151+
152+
ISO C 2023
153+
154+
| ``gnu23``
155+
156+
ISO C 2023 with GNU extensions
157+
158+
| ``c2y``
159+
160+
ISO C 202y
161+
162+
| ``gnu2y``
163+
164+
ISO C 202y with GNU extensions
165+
149166
The default C language standard is ``gnu17``, except on PS4, where it is
150167
``gnu99``.
151168

clang/docs/ReleaseNotes.rst

+20-3
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ C Language Changes
205205
``-Wunterminated-string-initialization``. However, this diagnostic is not
206206
silenced by the ``nonstring`` attribute as these initializations are always
207207
incompatible with C++.
208-
- Added ``-Wjump-bypasses-init``, which is off by default and grouped under
208+
- Added ``-Wjump-misses-init``, which is off by default and grouped under
209209
``-Wc++-compat``. It diagnoses when a jump (``goto`` to its label, ``switch``
210210
to its ``case``) will bypass the initialization of a local variable, which is
211211
invalid in C++.
@@ -241,6 +241,7 @@ C2y Feature Support
241241

242242
C23 Feature Support
243243
^^^^^^^^^^^^^^^^^^^
244+
- Clang now accepts ``-std=iso9899:2024`` as an alias for C23.
244245
- Added ``__builtin_c23_va_start()`` for compatibility with GCC and to enable
245246
better diagnostic behavior for the ``va_start()`` macro in C23 and later.
246247
This also updates the definition of ``va_start()`` in ``<stdarg.h>`` to use
@@ -254,7 +255,10 @@ C23 Feature Support
254255
- Implemented `WG14 N3037 <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3037.pdf>`_
255256
which allows tag types to be redefined within the same translation unit so
256257
long as both definitions are structurally equivalent (same tag types, same
257-
tag names, same tag members, etc).
258+
tag names, same tag members, etc). As a result of this paper, ``-Wvisibility``
259+
is no longer diagnosed in C23 if the parameter is a complete tag type (it
260+
does still fire when the parameter is an incomplete tag type as that cannot
261+
be completed).
258262
- Fixed a failed assertion with an invalid parameter to the ``#embed``
259263
directive. Fixes #GH126940.
260264

@@ -283,6 +287,8 @@ Non-comprehensive list of changes in this release
283287
stack space when running on Apple AArch64 based platforms. This means that
284288
stack traces of Clang from debuggers, crashes, and profilers may look
285289
different than before.
290+
- Fixed a crash when a VLA with an invalid size expression was used within a
291+
``sizeof`` or ``typeof`` expression. (#GH138444)
286292

287293
New Compiler Flags
288294
------------------
@@ -550,7 +556,9 @@ Bug Fixes in This Version
550556
- Fixed visibility calculation for template functions. (#GH103477)
551557
- Fixed a bug where an attribute before a ``pragma clang attribute`` or
552558
``pragma clang __debug`` would cause an assertion. Instead, this now diagnoses
553-
the invalid attribute location appropriately. (#GH137861)
559+
the invalid attribute location appropriately. (#GH137861)
560+
- Fixed a crash when a malformed ``_Pragma`` directive appears as part of an
561+
``#include`` directive. (#GH138094)
554562

555563
Bug Fixes to Compiler Builtins
556564
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -586,6 +594,9 @@ Bug Fixes to Attribute Support
586594
``__attribute__((unused))`` are still ignored after the definition, though
587595
this behavior may be relaxed in the future). (#GH135481)
588596

597+
- Clang will warn if a complete type specializes a deprecated partial specialization.
598+
(#GH44496)
599+
589600
Bug Fixes to C++ Support
590601
^^^^^^^^^^^^^^^^^^^^^^^^
591602

@@ -637,11 +648,13 @@ Bug Fixes to C++ Support
637648
- Clang no longer crashes when establishing subsumption between some constraint expressions. (#GH122581)
638649
- Clang now issues an error when placement new is used to modify a const-qualified variable
639650
in a ``constexpr`` function. (#GH131432)
651+
- Fixed an incorrect TreeTransform for calls to ``consteval`` functions if a conversion template is present. (#GH137885)
640652
- Clang now emits a warning when class template argument deduction for alias templates is used in C++17. (#GH133806)
641653
- Fix a crash when checking the template template parameters of a dependent lambda appearing in an alias declaration.
642654
(#GH136432), (#GH137014), (#GH138018)
643655
- Fixed an assertion when trying to constant-fold various builtins when the argument
644656
referred to a reference to an incomplete type. (#GH129397)
657+
- Fixed a crash when a cast involved a parenthesized aggregate initialization in dependent context. (#GH72880)
645658

646659
Bug Fixes to AST Handling
647660
^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -798,6 +811,10 @@ libclang
798811
- Fixed a buffer overflow in ``CXString`` implementation. The fix may result in
799812
increased memory allocation.
800813

814+
- Deprecate ``clang_Cursor_GetBinaryOpcode`` and ``clang_Cursor_getBinaryOpcodeStr``
815+
implementations, which are duplicates of ``clang_getCursorBinaryOperatorKind``
816+
and ``clang_getBinaryOperatorKindSpelling`` respectively.
817+
801818
Code Completion
802819
---------------
803820

0 commit comments

Comments
 (0)