Skip to content

Commit 0fb6b73

Browse files
committed
merge main into amd-staging
2 parents 45e055f + c025b96 commit 0fb6b73

File tree

682 files changed

+10682
-4371
lines changed

Some content is hidden

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

682 files changed

+10682
-4371
lines changed

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

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,19 @@ on:
1111

1212
jobs:
1313
build:
14-
runs-on: ubuntu-24.04
14+
runs-on: ${{ matrix.os }}
1515
strategy:
1616
fail-fast: false
1717
matrix:
1818
include:
19-
- c_compiler: clang
19+
- os: ubuntu-24.04
20+
ccache-variant: sccache
21+
c_compiler: clang
22+
cpp_compiler: clang++
23+
# TODO: remove ccache logic when https://github.com/hendrikmuhs/ccache-action/issues/279 is resolved.
24+
- os: ubuntu-24.04-arm
25+
ccache-variant: ccache
26+
c_compiler: clang
2027
cpp_compiler: clang++
2128
# TODO: add back gcc build when it is fixed
2229
# - c_compiler: gcc
@@ -35,7 +42,7 @@ jobs:
3542
with:
3643
max-size: 1G
3744
key: libc_fullbuild_${{ matrix.c_compiler }}
38-
variant: sccache
45+
variant: ${{ matrix.ccache-variant }}
3946

4047
# Notice:
4148
# - MPFR is required by some of the mathlib tests.
@@ -62,8 +69,8 @@ jobs:
6269
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
6370
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
6471
-DCMAKE_BUILD_TYPE=MinSizeRel
65-
-DCMAKE_C_COMPILER_LAUNCHER=sccache
66-
-DCMAKE_CXX_COMPILER_LAUNCHER=sccache
72+
-DCMAKE_C_COMPILER_LAUNCHER=${{ matrix.ccache-variant }}
73+
-DCMAKE_CXX_COMPILER_LAUNCHER=${{ matrix.ccache-variant }}
6774
-DCMAKE_INSTALL_PREFIX=${{ steps.strings.outputs.build-install-dir }}
6875
-DLLVM_ENABLE_RUNTIMES="libc;compiler-rt"
6976
-DLLVM_LIBC_FULL_BUILD=ON

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

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,28 @@ jobs:
1919
include:
2020
# TODO: add linux gcc when it is fixed
2121
- os: ubuntu-24.04
22+
ccache-variant: sccache
23+
compiler:
24+
c_compiler: clang
25+
cpp_compiler: clang++
26+
# TODO: remove ccache logic when https://github.com/hendrikmuhs/ccache-action/issues/279 is resolved.
27+
- os: ubuntu-24.04-arm
28+
ccache-variant: ccache
2229
compiler:
2330
c_compiler: clang
2431
cpp_compiler: clang++
2532
- os: windows-2022
33+
ccache-variant: sccache
34+
compiler:
35+
c_compiler: clang-cl
36+
cpp_compiler: clang-cl
37+
- os: windows-2025
38+
ccache-variant: sccache
2639
compiler:
2740
c_compiler: clang-cl
2841
cpp_compiler: clang-cl
2942
- os: macos-14
43+
ccache-variant: sccache
3044
compiler:
3145
c_compiler: clang
3246
cpp_compiler: clang++
@@ -46,7 +60,7 @@ jobs:
4660
with:
4761
max-size: 1G
4862
key: libc_overlay_build_${{ matrix.os }}_${{ matrix.compiler.c_compiler }}
49-
variant: sccache
63+
variant: ${{ matrix.ccache-variant }}
5064

5165
# MPFR is required by some of the mathlib tests.
5266
- name: Prepare dependencies (Ubuntu)
@@ -82,8 +96,8 @@ jobs:
8296
-DCMAKE_CXX_COMPILER=${{ matrix.compiler.cpp_compiler }}
8397
-DCMAKE_C_COMPILER=${{ matrix.compiler.c_compiler }}
8498
-DCMAKE_BUILD_TYPE=MinSizeRel
85-
-DCMAKE_C_COMPILER_LAUNCHER=sccache
86-
-DCMAKE_CXX_COMPILER_LAUNCHER=sccache
99+
-DCMAKE_C_COMPILER_LAUNCHER=${{ matrix.ccache-variant }}
100+
-DCMAKE_CXX_COMPILER_LAUNCHER=${{ matrix.ccache-variant }}
87101
-DCMAKE_POLICY_DEFAULT_CMP0141=NEW
88102
-DCMAKE_MSVC_DEBUG_INFORMATION_FORMAT=Embedded
89103
-DLLVM_ENABLE_RUNTIMES=libc

clang-tools-extra/clang-tidy/ClangTidyProfiling.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,23 +36,25 @@ ClangTidyProfiling::StorageParams::StorageParams(llvm::StringRef ProfilePrefix,
3636
.str();
3737
}
3838

39-
void ClangTidyProfiling::printUserFriendlyTable(llvm::raw_ostream &OS) {
40-
TG->print(OS);
39+
void ClangTidyProfiling::printUserFriendlyTable(llvm::raw_ostream &OS,
40+
llvm::TimerGroup &TG) {
41+
TG.print(OS);
4142
OS.flush();
4243
}
4344

44-
void ClangTidyProfiling::printAsJSON(llvm::raw_ostream &OS) {
45+
void ClangTidyProfiling::printAsJSON(llvm::raw_ostream &OS,
46+
llvm::TimerGroup &TG) {
4547
OS << "{\n";
4648
OS << R"("file": ")" << Storage->SourceFilename << "\",\n";
4749
OS << R"("timestamp": ")" << Storage->Timestamp << "\",\n";
4850
OS << "\"profile\": {\n";
49-
TG->printJSONValues(OS, "");
51+
TG.printJSONValues(OS, "");
5052
OS << "\n}\n";
5153
OS << "}\n";
5254
OS.flush();
5355
}
5456

55-
void ClangTidyProfiling::storeProfileData() {
57+
void ClangTidyProfiling::storeProfileData(llvm::TimerGroup &TG) {
5658
assert(Storage && "We should have a filename.");
5759

5860
llvm::SmallString<256> OutputDirectory(Storage->StoreFilename);
@@ -71,19 +73,18 @@ void ClangTidyProfiling::storeProfileData() {
7173
return;
7274
}
7375

74-
printAsJSON(OS);
76+
printAsJSON(OS, TG);
7577
}
7678

7779
ClangTidyProfiling::ClangTidyProfiling(std::optional<StorageParams> Storage)
7880
: Storage(std::move(Storage)) {}
7981

8082
ClangTidyProfiling::~ClangTidyProfiling() {
81-
TG.emplace("clang-tidy", "clang-tidy checks profiling", Records);
82-
83+
llvm::TimerGroup TG{"clang-tidy", "clang-tidy checks profiling", Records};
8384
if (!Storage)
84-
printUserFriendlyTable(llvm::errs());
85+
printUserFriendlyTable(llvm::errs(), TG);
8586
else
86-
storeProfileData();
87+
storeProfileData(TG);
8788
}
8889

8990
} // namespace clang::tidy

clang-tools-extra/clang-tidy/ClangTidyProfiling.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,11 @@ class ClangTidyProfiling {
3434
};
3535

3636
private:
37-
std::optional<llvm::TimerGroup> TG;
38-
3937
std::optional<StorageParams> Storage;
4038

41-
void printUserFriendlyTable(llvm::raw_ostream &OS);
42-
void printAsJSON(llvm::raw_ostream &OS);
43-
44-
void storeProfileData();
39+
void printUserFriendlyTable(llvm::raw_ostream &OS, llvm::TimerGroup &TG);
40+
void printAsJSON(llvm::raw_ostream &OS, llvm::TimerGroup &TG);
41+
void storeProfileData(llvm::TimerGroup &TG);
4542

4643
public:
4744
llvm::StringMap<llvm::TimeRecord> Records;

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ UnusedUsingDeclsCheck::UnusedUsingDeclsCheck(StringRef Name,
5151
HeaderFileExtensions(Context->getHeaderFileExtensions()) {}
5252

5353
void UnusedUsingDeclsCheck::registerMatchers(MatchFinder *Finder) {
54+
// We don't emit warnings on unused-using-decls from headers, so bail out if
55+
// the main file is a header.
56+
if (utils::isFileExtension(getCurrentMainFile(), HeaderFileExtensions))
57+
return;
5458
Finder->addMatcher(usingDecl(isExpansionInMainFile()).bind("using"), this);
5559
auto DeclMatcher = hasDeclaration(namedDecl().bind("used"));
5660
Finder->addMatcher(loc(templateSpecializationType(DeclMatcher)), this);
@@ -83,12 +87,6 @@ void UnusedUsingDeclsCheck::registerMatchers(MatchFinder *Finder) {
8387
void UnusedUsingDeclsCheck::check(const MatchFinder::MatchResult &Result) {
8488
if (Result.Context->getDiagnostics().hasUncompilableErrorOccurred())
8589
return;
86-
// We don't emit warnings on unused-using-decls from headers, so bail out if
87-
// the main file is a header.
88-
if (auto MainFile = Result.SourceManager->getFileEntryRefForID(
89-
Result.SourceManager->getMainFileID());
90-
utils::isFileExtension(MainFile->getName(), HeaderFileExtensions))
91-
return;
9290

9391
if (const auto *Using = Result.Nodes.getNodeAs<UsingDecl>("using")) {
9492
// Ignores using-declarations defined in macros.

clang/include/clang/Basic/DiagnosticDriverKinds.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,10 @@ def warn_drv_deprecated_arg_ofast : Warning<
458458
"argument '-Ofast' is deprecated; use '-O3 -ffast-math' for the same behavior,"
459459
" or '-O3' to enable only conforming optimizations">,
460460
InGroup<DeprecatedOFast>;
461+
def warn_drv_deprecated_arg_ofast_for_flang : Warning<
462+
"argument '-Ofast' is deprecated; use '-O3 -ffast-math -fstack-arrays' for the same behavior,"
463+
" or '-O3 -fstack-arrays' to enable only conforming optimizations">,
464+
InGroup<DeprecatedOFast>;
461465
def warn_drv_deprecated_custom : Warning<
462466
"argument '%0' is deprecated, %1">, InGroup<Deprecated>;
463467
def warn_drv_assuming_mfloat_abi_is : Warning<

clang/include/clang/Driver/Options.td

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -933,10 +933,12 @@ def O : Joined<["-"], "O">, Group<O_Group>,
933933
def O_flag : Flag<["-"], "O">, Visibility<[ClangOption, CC1Option, FC1Option]>,
934934
Alias<O>, AliasArgs<["1"]>;
935935
def Ofast : Joined<["-"], "Ofast">, Group<O_Group>,
936-
Visibility<[ClangOption, CC1Option, FlangOption]>,
937-
HelpTextForVariants<[ClangOption, CC1Option],
938-
"Deprecated; use '-O3 -ffast-math' for the same behavior,"
939-
" or '-O3' to enable only conforming optimizations">;
936+
Visibility<[ClangOption, CC1Option, FlangOption, FC1Option]>,
937+
HelpTextForVariants<[FlangOption, FC1Option],
938+
"Deprecated; use '-O3 -ffast-math -fstack-arrays' for the same behavior,"
939+
" or '-O3 -fstack-arrays' to enable only conforming optimizations">,
940+
HelpText<"Deprecated; use '-O3 -ffast-math' for the same behavior,"
941+
" or '-O3' to enable only conforming optimizations">;
940942
def P : Flag<["-"], "P">,
941943
Visibility<[ClangOption, CC1Option, FlangOption, FC1Option]>,
942944
Group<Preprocessor_Group>,

clang/include/clang/Sema/SemaInternal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ inline std::pair<unsigned, unsigned> getDepthAndIndex(const NamedDecl *ND) {
7272
/// Retrieve the depth and index of an unexpanded parameter pack.
7373
inline std::pair<unsigned, unsigned>
7474
getDepthAndIndex(UnexpandedParameterPack UPP) {
75-
if (const auto *TTP = UPP.first.dyn_cast<const TemplateTypeParmType *>())
75+
if (const auto *TTP = dyn_cast<const TemplateTypeParmType *>(UPP.first))
7676
return std::make_pair(TTP->getDepth(), TTP->getIndex());
7777

7878
return getDepthAndIndex(cast<NamedDecl *>(UPP.first));

clang/lib/AST/ByteCode/Descriptor.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -428,17 +428,17 @@ QualType Descriptor::getElemQualType() const {
428428
}
429429

430430
SourceLocation Descriptor::getLocation() const {
431-
if (auto *D = Source.dyn_cast<const Decl *>())
431+
if (auto *D = dyn_cast<const Decl *>(Source))
432432
return D->getLocation();
433-
if (auto *E = Source.dyn_cast<const Expr *>())
433+
if (auto *E = dyn_cast<const Expr *>(Source))
434434
return E->getExprLoc();
435435
llvm_unreachable("Invalid descriptor type");
436436
}
437437

438438
SourceInfo Descriptor::getLoc() const {
439-
if (const auto *D = Source.dyn_cast<const Decl *>())
439+
if (const auto *D = dyn_cast<const Decl *>(Source))
440440
return SourceInfo(D);
441-
if (const auto *E = Source.dyn_cast<const Expr *>())
441+
if (const auto *E = dyn_cast<const Expr *>(Source))
442442
return SourceInfo(E);
443443
llvm_unreachable("Invalid descriptor type");
444444
}

clang/lib/AST/ByteCode/Interp.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -873,13 +873,17 @@ bool CheckNewDeleteForms(InterpState &S, CodePtr OpPC,
873873

874874
bool CheckDeleteSource(InterpState &S, CodePtr OpPC, const Expr *Source,
875875
const Pointer &Ptr) {
876-
// The two sources we currently allow are new expressions and
877-
// __builtin_operator_new calls.
876+
// Regular new type(...) call.
878877
if (isa_and_nonnull<CXXNewExpr>(Source))
879878
return true;
880-
if (const CallExpr *CE = dyn_cast_if_present<CallExpr>(Source);
879+
// operator new.
880+
if (const auto *CE = dyn_cast_if_present<CallExpr>(Source);
881881
CE && CE->getBuiltinCallee() == Builtin::BI__builtin_operator_new)
882882
return true;
883+
// std::allocator.allocate() call
884+
if (const auto *MCE = dyn_cast_if_present<CXXMemberCallExpr>(Source);
885+
MCE && MCE->getMethodDecl()->getIdentifier()->isStr("allocate"))
886+
return true;
883887

884888
// Whatever this is, we didn't heap allocate it.
885889
const SourceInfo &Loc = S.Current->getSource(OpPC);
@@ -1489,7 +1493,8 @@ bool CheckNewTypeMismatch(InterpState &S, CodePtr OpPC, const Expr *E,
14891493
const auto *NewExpr = cast<CXXNewExpr>(E);
14901494
QualType StorageType = Ptr.getType();
14911495

1492-
if (isa_and_nonnull<CXXNewExpr>(Ptr.getFieldDesc()->asExpr()) &&
1496+
if ((isa_and_nonnull<CXXNewExpr>(Ptr.getFieldDesc()->asExpr()) ||
1497+
isa_and_nonnull<CXXMemberCallExpr>(Ptr.getFieldDesc()->asExpr())) &&
14931498
StorageType->isPointerType()) {
14941499
// FIXME: Are there other cases where this is a problem?
14951500
StorageType = StorageType->getPointeeType();

0 commit comments

Comments
 (0)