Skip to content

Commit a87977a

Browse files
authored
Merge branch 'main' into attributes
2 parents 9622499 + 0fb8fac commit a87977a

File tree

941 files changed

+75697
-61955
lines changed

Some content is hidden

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

941 files changed

+75697
-61955
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,13 +202,13 @@ jobs:
202202
matrix:
203203
include:
204204
- config: generic-cxx03
205-
os: macos-latest
205+
os: macos-15
206206
- config: generic-cxx23
207-
os: macos-latest
207+
os: macos-15
208208
- config: generic-modules
209-
os: macos-latest
209+
os: macos-15
210210
- config: apple-configuration
211-
os: macos-latest
211+
os: macos-15
212212
- config: apple-system
213213
os: macos-13
214214
- config: apple-system-hardened
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# This file defines an action that builds the various Docker images used to run
2+
# libc++ CI whenever modifications to those Docker files are pushed to `main`.
3+
#
4+
# The images are pushed to the LLVM package registry at https://github.com/orgs/llvm/packages
5+
# and tagged appropriately. The selection of which Docker image version is used by the libc++
6+
# CI nodes at any given point is controlled from the workflow files themselves.
7+
8+
name: Build Docker images for libc++ CI
9+
10+
permissions:
11+
contents: read
12+
packages: write
13+
14+
on:
15+
push:
16+
branches:
17+
- main
18+
paths:
19+
- 'libcxx/utils/ci/**'
20+
- '.github/workflows/libcxx-build-containers.yml'
21+
pull_request:
22+
branches:
23+
- main
24+
paths:
25+
- 'libcxx/utils/ci/**'
26+
- '.github/workflows/libcxx-build-containers.yml'
27+
28+
jobs:
29+
build-and-push:
30+
runs-on: ubuntu-latest
31+
if: github.repository_owner == 'llvm'
32+
33+
steps:
34+
- uses: actions/checkout@v4
35+
36+
- name: Build the Linux builder image
37+
working-directory: libcxx/utils/ci
38+
run: docker compose build actions-builder
39+
40+
# - name: Build the Android builder image
41+
# working-directory: libcxx/utils/ci
42+
# run: docker compose build android-buildkite-builder
43+
44+
- name: Log in to GitHub Container Registry
45+
uses: docker/login-action@v3
46+
with:
47+
registry: ghcr.io
48+
username: ${{ github.actor }}
49+
password: ${{ secrets.GITHUB_TOKEN }}
50+
51+
- name: Push the Linux builder image
52+
if: github.event_name == 'push'
53+
working-directory: libcxx/utils/ci
54+
run: |
55+
docker compose push actions-builder
56+
env:
57+
TAG: ${{ github.sha }}
58+
59+
# - name: Push the Android builder image
60+
# if: github.event_name == 'push'
61+
# working-directory: libcxx/utils/ci
62+
# run: |
63+
# docker compose push android-buildkite-builder
64+
# env:
65+
# TAG: ${{ github.sha }}

clang-tools-extra/clang-tidy/bugprone/VirtualNearMissCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ static bool checkOverridingFunctionReturnType(const ASTContext *Context,
112112

113113
// The class type D should have the same cv-qualification as or less
114114
// cv-qualification than the class type B.
115-
if (DTy.isMoreQualifiedThan(BTy))
115+
if (DTy.isMoreQualifiedThan(BTy, *Context))
116116
return false;
117117

118118
return true;

clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.cpp

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -299,10 +299,11 @@ static bool applyDiceHeuristic(StringRef Arg, StringRef Param,
299299

300300
/// Checks if ArgType binds to ParamType regarding reference-ness and
301301
/// cv-qualifiers.
302-
static bool areRefAndQualCompatible(QualType ArgType, QualType ParamType) {
302+
static bool areRefAndQualCompatible(QualType ArgType, QualType ParamType,
303+
const ASTContext &Ctx) {
303304
return !ParamType->isReferenceType() ||
304305
ParamType.getNonReferenceType().isAtLeastAsQualifiedAs(
305-
ArgType.getNonReferenceType());
306+
ArgType.getNonReferenceType(), Ctx);
306307
}
307308

308309
static bool isPointerOrArray(QualType TypeToCheck) {
@@ -311,12 +312,12 @@ static bool isPointerOrArray(QualType TypeToCheck) {
311312

312313
/// Checks whether ArgType is an array type identical to ParamType's array type.
313314
/// Enforces array elements' qualifier compatibility as well.
314-
static bool isCompatibleWithArrayReference(QualType ArgType,
315-
QualType ParamType) {
315+
static bool isCompatibleWithArrayReference(QualType ArgType, QualType ParamType,
316+
const ASTContext &Ctx) {
316317
if (!ArgType->isArrayType())
317318
return false;
318319
// Here, qualifiers belong to the elements of the arrays.
319-
if (!ParamType.isAtLeastAsQualifiedAs(ArgType))
320+
if (!ParamType.isAtLeastAsQualifiedAs(ArgType, Ctx))
320321
return false;
321322

322323
return ParamType.getUnqualifiedType() == ArgType.getUnqualifiedType();
@@ -342,12 +343,13 @@ static QualType convertToPointeeOrArrayElementQualType(QualType TypeToConvert) {
342343
/// every * in ParamType to the right of that cv-qualifier, except the last
343344
/// one, must also be const-qualified.
344345
static bool arePointersStillQualCompatible(QualType ArgType, QualType ParamType,
345-
bool &IsParamContinuouslyConst) {
346+
bool &IsParamContinuouslyConst,
347+
const ASTContext &Ctx) {
346348
// The types are compatible, if the parameter is at least as qualified as the
347349
// argument, and if it is more qualified, it has to be const on upper pointer
348350
// levels.
349351
bool AreTypesQualCompatible =
350-
ParamType.isAtLeastAsQualifiedAs(ArgType) &&
352+
ParamType.isAtLeastAsQualifiedAs(ArgType, Ctx) &&
351353
(!ParamType.hasQualifiers() || IsParamContinuouslyConst);
352354
// Check whether the parameter's constness continues at the current pointer
353355
// level.
@@ -359,9 +361,10 @@ static bool arePointersStillQualCompatible(QualType ArgType, QualType ParamType,
359361
/// Checks whether multilevel pointers are compatible in terms of levels,
360362
/// qualifiers and pointee type.
361363
static bool arePointerTypesCompatible(QualType ArgType, QualType ParamType,
362-
bool IsParamContinuouslyConst) {
364+
bool IsParamContinuouslyConst,
365+
const ASTContext &Ctx) {
363366
if (!arePointersStillQualCompatible(ArgType, ParamType,
364-
IsParamContinuouslyConst))
367+
IsParamContinuouslyConst, Ctx))
365368
return false;
366369

367370
do {
@@ -372,7 +375,7 @@ static bool arePointerTypesCompatible(QualType ArgType, QualType ParamType,
372375
// Check whether cv-qualifiers permit compatibility on
373376
// current level.
374377
if (!arePointersStillQualCompatible(ArgType, ParamType,
375-
IsParamContinuouslyConst))
378+
IsParamContinuouslyConst, Ctx))
376379
return false;
377380

378381
if (ParamType.getUnqualifiedType() == ArgType.getUnqualifiedType())
@@ -396,7 +399,7 @@ static bool areTypesCompatible(QualType ArgType, QualType ParamType,
396399
return true;
397400

398401
// Check for constness and reference compatibility.
399-
if (!areRefAndQualCompatible(ArgType, ParamType))
402+
if (!areRefAndQualCompatible(ArgType, ParamType, Ctx))
400403
return false;
401404

402405
bool IsParamReference = ParamType->isReferenceType();
@@ -434,7 +437,7 @@ static bool areTypesCompatible(QualType ArgType, QualType ParamType,
434437
// When ParamType is an array reference, ArgType has to be of the same-sized
435438
// array-type with cv-compatible element type.
436439
if (IsParamReference && ParamType->isArrayType())
437-
return isCompatibleWithArrayReference(ArgType, ParamType);
440+
return isCompatibleWithArrayReference(ArgType, ParamType, Ctx);
438441

439442
bool IsParamContinuouslyConst =
440443
!IsParamReference || ParamType.getNonReferenceType().isConstQualified();
@@ -444,7 +447,7 @@ static bool areTypesCompatible(QualType ArgType, QualType ParamType,
444447
ParamType = convertToPointeeOrArrayElementQualType(ParamType);
445448

446449
// Check qualifier compatibility on the next level.
447-
if (!ParamType.isAtLeastAsQualifiedAs(ArgType))
450+
if (!ParamType.isAtLeastAsQualifiedAs(ArgType, Ctx))
448451
return false;
449452

450453
if (ParamType.getUnqualifiedType() == ArgType.getUnqualifiedType())
@@ -472,8 +475,8 @@ static bool areTypesCompatible(QualType ArgType, QualType ParamType,
472475
if (!(ParamType->isAnyPointerType() && ArgType->isAnyPointerType()))
473476
return false;
474477

475-
return arePointerTypesCompatible(ArgType, ParamType,
476-
IsParamContinuouslyConst);
478+
return arePointerTypesCompatible(ArgType, ParamType, IsParamContinuouslyConst,
479+
Ctx);
477480
}
478481

479482
static bool isOverloadedUnaryOrBinarySymbolOperator(const FunctionDecl *FD) {

clang-tools-extra/clangd/ClangdLSPServer.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1419,15 +1419,12 @@ void ClangdLSPServer::applyConfiguration(
14191419
const ConfigurationSettings &Settings) {
14201420
// Per-file update to the compilation database.
14211421
llvm::StringSet<> ModifiedFiles;
1422-
for (auto &Entry : Settings.compilationDatabaseChanges) {
1423-
PathRef File = Entry.first;
1424-
auto Old = CDB->getCompileCommand(File);
1425-
auto New =
1426-
tooling::CompileCommand(std::move(Entry.second.workingDirectory), File,
1427-
std::move(Entry.second.compilationCommand),
1422+
for (auto &[File, Command] : Settings.compilationDatabaseChanges) {
1423+
auto Cmd =
1424+
tooling::CompileCommand(std::move(Command.workingDirectory), File,
1425+
std::move(Command.compilationCommand),
14281426
/*Output=*/"");
1429-
if (Old != New) {
1430-
CDB->setCompileCommand(File, std::move(New));
1427+
if (CDB->setCompileCommand(File, std::move(Cmd))) {
14311428
ModifiedFiles.insert(File);
14321429
}
14331430
}

clang-tools-extra/clangd/GlobalCompilationDatabase.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -807,20 +807,27 @@ tooling::CompileCommand OverlayCDB::getFallbackCommand(PathRef File) const {
807807
return Cmd;
808808
}
809809

810-
void OverlayCDB::setCompileCommand(PathRef File,
810+
bool OverlayCDB::setCompileCommand(PathRef File,
811811
std::optional<tooling::CompileCommand> Cmd) {
812812
// We store a canonical version internally to prevent mismatches between set
813813
// and get compile commands. Also it assures clients listening to broadcasts
814814
// doesn't receive different names for the same file.
815815
std::string CanonPath = removeDots(File);
816816
{
817817
std::unique_lock<std::mutex> Lock(Mutex);
818-
if (Cmd)
819-
Commands[CanonPath] = std::move(*Cmd);
820-
else
818+
if (Cmd) {
819+
if (auto [It, Inserted] =
820+
Commands.try_emplace(CanonPath, std::move(*Cmd));
821+
!Inserted) {
822+
if (It->second == *Cmd)
823+
return false;
824+
It->second = *Cmd;
825+
}
826+
} else
821827
Commands.erase(CanonPath);
822828
}
823829
OnCommandChanged.broadcast({CanonPath});
830+
return true;
824831
}
825832

826833
DelegatingCDB::DelegatingCDB(const GlobalCompilationDatabase *Base)

clang-tools-extra/clangd/GlobalCompilationDatabase.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,9 @@ class OverlayCDB : public DelegatingCDB {
203203
tooling::CompileCommand getFallbackCommand(PathRef File) const override;
204204

205205
/// Sets or clears the compilation command for a particular file.
206-
void
206+
/// Returns true if the command was changed (including insertion and removal),
207+
/// false if it was unchanged.
208+
bool
207209
setCompileCommand(PathRef File,
208210
std::optional<tooling::CompileCommand> CompilationCommand);
209211

clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
#include "clang/AST/ASTContext.h"
5757
#include "clang/AST/Decl.h"
5858
#include "clang/AST/DeclBase.h"
59+
#include "clang/AST/ExprCXX.h"
5960
#include "clang/AST/NestedNameSpecifier.h"
6061
#include "clang/AST/RecursiveASTVisitor.h"
6162
#include "clang/AST/Stmt.h"
@@ -70,7 +71,6 @@
7071
#include "llvm/ADT/StringRef.h"
7172
#include "llvm/Support/Casting.h"
7273
#include "llvm/Support/Error.h"
73-
#include "llvm/Support/raw_os_ostream.h"
7474
#include <optional>
7575

7676
namespace clang {
@@ -95,18 +95,21 @@ enum FunctionDeclKind {
9595
OutOfLineDefinition
9696
};
9797

98-
// A RootStmt is a statement that's fully selected including all it's children
99-
// and it's parent is unselected.
98+
// A RootStmt is a statement that's fully selected including all its children
99+
// and its parent is unselected.
100100
// Check if a node is a root statement.
101101
bool isRootStmt(const Node *N) {
102102
if (!N->ASTNode.get<Stmt>())
103103
return false;
104104
// Root statement cannot be partially selected.
105105
if (N->Selected == SelectionTree::Partial)
106106
return false;
107-
// Only DeclStmt can be an unselected RootStmt since VarDecls claim the entire
108-
// selection range in selectionTree.
109-
if (N->Selected == SelectionTree::Unselected && !N->ASTNode.get<DeclStmt>())
107+
// A DeclStmt can be an unselected RootStmt since VarDecls claim the entire
108+
// selection range in selectionTree. Additionally, a CXXOperatorCallExpr of a
109+
// binary operation can be unselected because its children claim the entire
110+
// selection range in the selection tree (e.g. <<).
111+
if (N->Selected == SelectionTree::Unselected && !N->ASTNode.get<DeclStmt>() &&
112+
!N->ASTNode.get<CXXOperatorCallExpr>())
110113
return false;
111114
return true;
112115
}
@@ -913,8 +916,8 @@ Expected<Tweak::Effect> ExtractFunction::apply(const Selection &Inputs) {
913916

914917
tooling::Replacements OtherEdit(
915918
createForwardDeclaration(*ExtractedFunc, SM));
916-
if (auto PathAndEdit = Tweak::Effect::fileEdit(SM, SM.getFileID(*FwdLoc),
917-
OtherEdit))
919+
if (auto PathAndEdit =
920+
Tweak::Effect::fileEdit(SM, SM.getFileID(*FwdLoc), OtherEdit))
918921
MultiFileEffect->ApplyEdits.try_emplace(PathAndEdit->first,
919922
PathAndEdit->second);
920923
else

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

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,13 @@ TEST_F(OverlayCDBTest, GetCompileCommand) {
9292
EXPECT_EQ(CDB.getCompileCommand(testPath("missing.cc")), std::nullopt);
9393

9494
auto Override = cmd(testPath("foo.cc"), "-DA=3");
95-
CDB.setCompileCommand(testPath("foo.cc"), Override);
95+
EXPECT_TRUE(CDB.setCompileCommand(testPath("foo.cc"), Override));
96+
EXPECT_FALSE(CDB.setCompileCommand(testPath("foo.cc"), Override));
9697
EXPECT_THAT(CDB.getCompileCommand(testPath("foo.cc"))->CommandLine,
9798
Contains("-DA=3"));
9899
EXPECT_EQ(CDB.getCompileCommand(testPath("missing.cc")), std::nullopt);
99-
CDB.setCompileCommand(testPath("missing.cc"), Override);
100+
EXPECT_TRUE(CDB.setCompileCommand(testPath("missing.cc"), Override));
101+
EXPECT_FALSE(CDB.setCompileCommand(testPath("missing.cc"), Override));
100102
EXPECT_THAT(CDB.getCompileCommand(testPath("missing.cc"))->CommandLine,
101103
Contains("-DA=3"));
102104
}
@@ -111,7 +113,7 @@ TEST_F(OverlayCDBTest, NoBase) {
111113
OverlayCDB CDB(nullptr, {"-DA=6"});
112114
EXPECT_EQ(CDB.getCompileCommand(testPath("bar.cc")), std::nullopt);
113115
auto Override = cmd(testPath("bar.cc"), "-DA=5");
114-
CDB.setCompileCommand(testPath("bar.cc"), Override);
116+
EXPECT_TRUE(CDB.setCompileCommand(testPath("bar.cc"), Override));
115117
EXPECT_THAT(CDB.getCompileCommand(testPath("bar.cc"))->CommandLine,
116118
Contains("-DA=5"));
117119

@@ -128,10 +130,10 @@ TEST_F(OverlayCDBTest, Watch) {
128130
Changes.push_back(ChangedFiles);
129131
});
130132

131-
Inner.setCompileCommand("A.cpp", tooling::CompileCommand());
132-
Outer.setCompileCommand("B.cpp", tooling::CompileCommand());
133-
Inner.setCompileCommand("A.cpp", std::nullopt);
134-
Outer.setCompileCommand("C.cpp", std::nullopt);
133+
EXPECT_TRUE(Inner.setCompileCommand("A.cpp", tooling::CompileCommand()));
134+
EXPECT_TRUE(Outer.setCompileCommand("B.cpp", tooling::CompileCommand()));
135+
EXPECT_TRUE(Inner.setCompileCommand("A.cpp", std::nullopt));
136+
EXPECT_TRUE(Outer.setCompileCommand("C.cpp", std::nullopt));
135137
EXPECT_THAT(Changes, ElementsAre(ElementsAre("A.cpp"), ElementsAre("B.cpp"),
136138
ElementsAre("A.cpp"), ElementsAre("C.cpp")));
137139
}
@@ -151,7 +153,7 @@ TEST_F(OverlayCDBTest, Adjustments) {
151153
tooling::CompileCommand BarCommand;
152154
BarCommand.Filename = testPath("bar.cc");
153155
BarCommand.CommandLine = {"clang++", "-DB=1", testPath("bar.cc")};
154-
CDB.setCompileCommand(testPath("bar.cc"), BarCommand);
156+
EXPECT_TRUE(CDB.setCompileCommand(testPath("bar.cc"), BarCommand));
155157
Cmd = *CDB.getCompileCommand(testPath("bar.cc"));
156158
EXPECT_THAT(
157159
Cmd.CommandLine,
@@ -412,7 +414,7 @@ TEST(GlobalCompilationDatabaseTest, NonCanonicalFilenames) {
412414

413415
llvm::SmallString<128> Root(testRoot());
414416
llvm::sys::path::append(Root, "build", "..", "a.cc");
415-
DB.setCompileCommand(Root.str(), tooling::CompileCommand());
417+
EXPECT_TRUE(DB.setCompileCommand(Root.str(), tooling::CompileCommand()));
416418
EXPECT_THAT(DiscoveredFiles, UnorderedElementsAre(testPath("a.cc")));
417419
DiscoveredFiles.clear();
418420

@@ -432,7 +434,7 @@ TEST_F(OverlayCDBTest, GetProjectInfo) {
432434
EXPECT_EQ(DB.getProjectInfo(Header)->SourceRoot, testRoot());
433435

434436
// Shouldn't change after an override.
435-
DB.setCompileCommand(File, tooling::CompileCommand());
437+
EXPECT_TRUE(DB.setCompileCommand(File, tooling::CompileCommand()));
436438
EXPECT_EQ(DB.getProjectInfo(File)->SourceRoot, testRoot());
437439
EXPECT_EQ(DB.getProjectInfo(Header)->SourceRoot, testRoot());
438440
}

0 commit comments

Comments
 (0)