Skip to content

Commit 18343c7

Browse files
committed
merge main into amd-staging
2 parents cd815d9 + 62e4436 commit 18343c7

File tree

786 files changed

+24105
-8833
lines changed

Some content is hidden

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

786 files changed

+24105
-8833
lines changed

.github/new-prs-labeler.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,7 @@ clang:static analyzer:
499499
- clang/tools/scan-build/**
500500
- clang/utils/analyzer/**
501501
- clang/docs/analyzer/**
502+
- clang/test/Analysis/**
502503

503504
pgo:
504505
- llvm/lib/Transforms/Instrumentation/CGProfile.cpp

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

Lines changed: 16 additions & 12 deletions
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:d8a0709b1090350a7fe3604d8ab78c7d62f10698
40+
container: ghcr.io/llvm/libcxx-linux-builder:b319dfef21f6c7b0bc6a356d6b9f41a3b3b98ae9
4141
continue-on-error: false
4242
strategy:
4343
fail-fast: false
@@ -48,8 +48,8 @@ jobs:
4848
'generic-cxx26',
4949
'generic-modules'
5050
]
51-
cc: [ 'clang-20' ]
52-
cxx: [ 'clang++-20' ]
51+
cc: [ 'clang-21' ]
52+
cxx: [ 'clang++-21' ]
5353
include:
5454
- config: 'generic-gcc'
5555
cc: 'gcc-14'
@@ -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:d8a0709b1090350a7fe3604d8ab78c7d62f10698
78+
container: ghcr.io/llvm/libcxx-linux-builder:b319dfef21f6c7b0bc6a356d6b9f41a3b3b98ae9
7979
needs: [ stage1 ]
8080
continue-on-error: false
8181
strategy:
@@ -88,18 +88,22 @@ jobs:
8888
'generic-cxx20',
8989
'generic-cxx23'
9090
]
91-
cc: [ 'clang-20' ]
92-
cxx: [ 'clang++-20' ]
91+
cc: [ 'clang-21' ]
92+
cxx: [ 'clang++-21' ]
9393
include:
9494
- config: 'generic-gcc-cxx11'
9595
cc: 'gcc-14'
9696
cxx: 'g++-14'
97-
- config: 'generic-cxx23'
98-
cc: 'clang-18'
99-
cxx: 'clang++-18'
97+
- config: 'generic-cxx26'
98+
cc: 'clang-20'
99+
cxx: 'clang++-20'
100100
- config: 'generic-cxx26'
101101
cc: 'clang-19'
102102
cxx: 'clang++-19'
103+
# Release transition
104+
- config: 'generic-cxx23'
105+
cc: 'clang-18'
106+
cxx: 'clang++-18'
103107
steps:
104108
- uses: actions/checkout@v4
105109
- name: ${{ matrix.config }}
@@ -163,14 +167,14 @@ jobs:
163167
- config: 'generic-msan'
164168
machine: libcxx-self-hosted-linux
165169
runs-on: ${{ matrix.machine }}
166-
container: ghcr.io/llvm/libcxx-linux-builder:d8a0709b1090350a7fe3604d8ab78c7d62f10698
170+
container: ghcr.io/llvm/libcxx-linux-builder:b319dfef21f6c7b0bc6a356d6b9f41a3b3b98ae9
167171
steps:
168172
- uses: actions/checkout@v4
169173
- name: ${{ matrix.config }}
170174
run: libcxx/utils/ci/run-buildbot ${{ matrix.config }}
171175
env:
172-
CC: clang-20
173-
CXX: clang++-20
176+
CC: clang-21
177+
CXX: clang++-21
174178
- uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 # v4.3.0
175179
if: always()
176180
with:

.github/workflows/release-binaries.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,11 @@ jobs:
138138
arches=arm64
139139
else
140140
arches=x86_64
141+
# Disable Flang builds on macOS x86_64. The FortranLower library takes
142+
# 2-3 hours to build on macOS, much slower than on Linux.
143+
# The long build time causes the release build to time out on x86_64,
144+
# so we need to disable flang there.
145+
target_cmake_flags="$target_cmake_flags -DLLVM_RELEASE_ENABLE_PROJECTS='clang;lld;lldb;clang-tools-extra;bolt;polly;mlir'"
141146
fi
142147
target_cmake_flags="$target_cmake_flags -DBOOTSTRAP_BOOTSTRAP_DARWIN_osx_ARCHS=$arches -DBOOTSTRAP_BOOTSTRAP_DARWIN_osx_BUILTIN_ARCHS=$arches"
143148
fi

bolt/lib/RuntimeLibs/InstrumentationRuntimeLibrary.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ void InstrumentationRuntimeLibrary::link(
219219
}
220220
outs() << "BOLT-INFO: output linked against instrumentation runtime "
221221
"library, lib entry point is 0x"
222-
<< Twine::utohexstr(RuntimeFiniAddress) << "\n";
222+
<< Twine::utohexstr(RuntimeStartAddress) << "\n";
223223
outs() << "BOLT-INFO: clear procedure is 0x"
224224
<< Twine::utohexstr(
225225
Linker.lookupSymbol("__bolt_instr_clear_counters").value_or(0))

clang-tools-extra/clang-tidy/misc/ConstCorrectnessCheck.cpp

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
#include "ConstCorrectnessCheck.h"
1010
#include "../utils/FixItHintUtils.h"
11+
#include "../utils/Matchers.h"
12+
#include "../utils/OptionsUtils.h"
1113
#include "clang/AST/ASTContext.h"
1214
#include "clang/ASTMatchers/ASTMatchFinder.h"
1315
#include "clang/ASTMatchers/ASTMatchers.h"
@@ -41,7 +43,9 @@ ConstCorrectnessCheck::ConstCorrectnessCheck(StringRef Name,
4143
TransformValues(Options.get("TransformValues", true)),
4244
TransformReferences(Options.get("TransformReferences", true)),
4345
TransformPointersAsValues(
44-
Options.get("TransformPointersAsValues", false)) {
46+
Options.get("TransformPointersAsValues", false)),
47+
AllowedTypes(
48+
utils::options::parseStringList(Options.get("AllowedTypes", ""))) {
4549
if (AnalyzeValues == false && AnalyzeReferences == false)
4650
this->configurationDiag(
4751
"The check 'misc-const-correctness' will not "
@@ -57,6 +61,8 @@ void ConstCorrectnessCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
5761
Options.store(Opts, "TransformValues", TransformValues);
5862
Options.store(Opts, "TransformReferences", TransformReferences);
5963
Options.store(Opts, "TransformPointersAsValues", TransformPointersAsValues);
64+
Options.store(Opts, "AllowedTypes",
65+
utils::options::serializeStringList(AllowedTypes));
6066
}
6167

6268
void ConstCorrectnessCheck::registerMatchers(MatchFinder *Finder) {
@@ -73,6 +79,12 @@ void ConstCorrectnessCheck::registerMatchers(MatchFinder *Finder) {
7379
hasType(referenceType(pointee(hasCanonicalType(templateTypeParmType())))),
7480
hasType(referenceType(pointee(substTemplateTypeParmType()))));
7581

82+
const auto AllowedType = hasType(qualType(anyOf(
83+
hasDeclaration(namedDecl(matchers::matchesAnyListedName(AllowedTypes))),
84+
references(namedDecl(matchers::matchesAnyListedName(AllowedTypes))),
85+
pointerType(pointee(hasDeclaration(
86+
namedDecl(matchers::matchesAnyListedName(AllowedTypes))))))));
87+
7688
const auto AutoTemplateType = varDecl(
7789
anyOf(hasType(autoType()), hasType(referenceType(pointee(autoType()))),
7890
hasType(pointerType(pointee(autoType())))));
@@ -87,7 +99,8 @@ void ConstCorrectnessCheck::registerMatchers(MatchFinder *Finder) {
8799
unless(anyOf(ConstType, ConstReference, TemplateType,
88100
hasInitializer(isInstantiationDependent()), AutoTemplateType,
89101
RValueReference, FunctionPointerRef,
90-
hasType(cxxRecordDecl(isLambda())), isImplicit())));
102+
hasType(cxxRecordDecl(isLambda())), isImplicit(),
103+
AllowedType)));
91104

92105
// Match the function scope for which the analysis of all local variables
93106
// shall be run.

clang-tools-extra/clang-tidy/misc/ConstCorrectnessCheck.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class ConstCorrectnessCheck : public ClangTidyCheck {
4545
const bool TransformValues;
4646
const bool TransformReferences;
4747
const bool TransformPointersAsValues;
48+
const std::vector<StringRef> AllowedTypes;
4849
};
4950

5051
} // namespace clang::tidy::misc

clang-tools-extra/clangd/CollectMacros.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,13 @@
1818
namespace clang {
1919
namespace clangd {
2020

21-
Range MacroOccurrence::toRange(const SourceManager &SM) const {
21+
CharSourceRange MacroOccurrence::toSourceRange(const SourceManager &SM) const {
2222
auto MainFile = SM.getMainFileID();
23-
return halfOpenToRange(
24-
SM, syntax::FileRange(MainFile, StartOffset, EndOffset).toCharRange(SM));
23+
return syntax::FileRange(MainFile, StartOffset, EndOffset).toCharRange(SM);
24+
}
25+
26+
Range MacroOccurrence::toRange(const SourceManager &SM) const {
27+
return halfOpenToRange(SM, toSourceRange(SM));
2528
}
2629

2730
void CollectMainFileMacros::add(const Token &MacroNameTok, const MacroInfo *MI,

clang-tools-extra/clangd/CollectMacros.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ struct MacroOccurrence {
3131
// True if the occurence is used in a conditional directive, e.g. #ifdef MACRO
3232
bool InConditionalDirective;
3333

34+
CharSourceRange toSourceRange(const SourceManager &SM) const;
3435
Range toRange(const SourceManager &SM) const;
3536
};
3637

clang-tools-extra/clangd/XRefs.cpp

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,15 @@ void enhanceLocatedSymbolsFromIndex(llvm::MutableArrayRef<LocatedSymbol> Result,
372372
});
373373
}
374374

375+
bool objcMethodIsTouched(const SourceManager &SM, const ObjCMethodDecl *OMD,
376+
SourceLocation Loc) {
377+
unsigned NumSels = OMD->getNumSelectorLocs();
378+
for (unsigned I = 0; I < NumSels; ++I)
379+
if (SM.getSpellingLoc(OMD->getSelectorLoc(I)) == Loc)
380+
return true;
381+
return false;
382+
}
383+
375384
// Decls are more complicated.
376385
// The AST contains at least a declaration, maybe a definition.
377386
// These are up-to-date, and so generally preferred over index results.
@@ -430,6 +439,26 @@ locateASTReferent(SourceLocation CurLoc, const syntax::Token *TouchedIdentifier,
430439
continue;
431440
}
432441
}
442+
// Special case: - (void)^method {} should jump to overrides, but the decl
443+
// shouldn't, only the definition. Note that an Objective-C method can
444+
// override a parent class or protocol.
445+
//
446+
// FIXME: Support jumping from a protocol decl to overrides on go-to
447+
// definition.
448+
if (const auto *OMD = llvm::dyn_cast<ObjCMethodDecl>(D)) {
449+
if (OMD->isThisDeclarationADefinition() && TouchedIdentifier &&
450+
objcMethodIsTouched(SM, OMD, TouchedIdentifier->location())) {
451+
llvm::SmallVector<const ObjCMethodDecl *, 4> Overrides;
452+
OMD->getOverriddenMethods(Overrides);
453+
if (!Overrides.empty()) {
454+
for (const auto *Override : Overrides)
455+
AddResultDecl(Override);
456+
LocateASTReferentMetric.record(1, "objc-overriden-method");
457+
}
458+
AddResultDecl(OMD);
459+
continue;
460+
}
461+
}
433462

434463
// Special case: the cursor is on an alias, prefer other results.
435464
// This targets "using ns::^Foo", where the target is more interesting.
@@ -1283,6 +1312,12 @@ std::vector<LocatedSymbol> findImplementations(ParsedAST &AST, Position Pos,
12831312
} else if (const auto *RD = dyn_cast<CXXRecordDecl>(ND)) {
12841313
IDs.insert(getSymbolID(RD));
12851314
QueryKind = RelationKind::BaseOf;
1315+
} else if (const auto *OMD = dyn_cast<ObjCMethodDecl>(ND)) {
1316+
IDs.insert(getSymbolID(OMD));
1317+
QueryKind = RelationKind::OverriddenBy;
1318+
} else if (const auto *ID = dyn_cast<ObjCInterfaceDecl>(ND)) {
1319+
IDs.insert(getSymbolID(ID));
1320+
QueryKind = RelationKind::BaseOf;
12861321
}
12871322
}
12881323
return findImplementors(std::move(IDs), QueryKind, Index, AST.tuPath());
@@ -1302,6 +1337,21 @@ void getOverriddenMethods(const CXXMethodDecl *CMD,
13021337
}
13031338
}
13041339

1340+
// Recursively finds all the overridden methods of `OMD` in complete type
1341+
// hierarchy.
1342+
void getOverriddenMethods(const ObjCMethodDecl *OMD,
1343+
llvm::DenseSet<SymbolID> &OverriddenMethods) {
1344+
if (!OMD)
1345+
return;
1346+
llvm::SmallVector<const ObjCMethodDecl *, 4> Overrides;
1347+
OMD->getOverriddenMethods(Overrides);
1348+
for (const ObjCMethodDecl *Base : Overrides) {
1349+
if (auto ID = getSymbolID(Base))
1350+
OverriddenMethods.insert(ID);
1351+
getOverriddenMethods(Base, OverriddenMethods);
1352+
}
1353+
}
1354+
13051355
std::optional<std::string>
13061356
stringifyContainerForMainFileRef(const Decl *Container) {
13071357
// FIXME We might also want to display the signature here
@@ -1438,6 +1488,12 @@ ReferencesResult findReferences(ParsedAST &AST, Position Pos, uint32_t Limit,
14381488
getOverriddenMethods(CMD, OverriddenMethods);
14391489
}
14401490
}
1491+
// Special case: Objective-C methods can override a parent class or
1492+
// protocol, we should be sure to report references to those.
1493+
if (const auto *OMD = llvm::dyn_cast<ObjCMethodDecl>(ND)) {
1494+
OverriddenBy.Subjects.insert(getSymbolID(OMD));
1495+
getOverriddenMethods(OMD, OverriddenMethods);
1496+
}
14411497
}
14421498
}
14431499

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,8 @@ void SymbolCollector::handleMacros(const MainFileMacros &MacroRefsToIndex) {
713713
// Add macro references.
714714
for (const auto &IDToRefs : MacroRefsToIndex.MacroRefs) {
715715
for (const auto &MacroRef : IDToRefs.second) {
716-
const auto &Range = MacroRef.toRange(SM);
716+
const auto &SR = MacroRef.toSourceRange(SM);
717+
auto Range = halfOpenToRange(SM, SR);
717718
bool IsDefinition = MacroRef.IsDefinition;
718719
Ref R;
719720
R.Location.Start.setLine(Range.start.line);
@@ -726,9 +727,7 @@ void SymbolCollector::handleMacros(const MainFileMacros &MacroRefsToIndex) {
726727
if (IsDefinition) {
727728
Symbol S;
728729
S.ID = IDToRefs.first;
729-
auto StartLoc = cantFail(sourceLocationInMainFile(SM, Range.start));
730-
auto EndLoc = cantFail(sourceLocationInMainFile(SM, Range.end));
731-
S.Name = toSourceCode(SM, SourceRange(StartLoc, EndLoc));
730+
S.Name = toSourceCode(SM, SR.getAsRange());
732731
S.SymInfo.Kind = index::SymbolKind::Macro;
733732
S.SymInfo.SubKind = index::SymbolSubKind::None;
734733
S.SymInfo.Properties = index::SymbolPropertySet();

0 commit comments

Comments
 (0)