Skip to content

Commit 91fab1b

Browse files
authored
Merge pull request #556 from Xilinx/bump_to_08195f31
[AutoBump] Merge with 08195f3 (Jan 23) (18)
2 parents a28ff29 + 9a3a74a commit 91fab1b

File tree

1,511 files changed

+76232
-52162
lines changed

Some content is hidden

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

1,511 files changed

+76232
-52162
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

.github/workflows/release-binaries.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949
prepare:
5050
name: Prepare to build binaries
5151
runs-on: ${{ inputs.runs-on }}
52-
if: github.repository == 'llvm/llvm-project'
52+
if: github.repository_owner == 'llvm'
5353
outputs:
5454
release-version: ${{ steps.vars.outputs.release-version }}
5555
ref: ${{ steps.vars.outputs.ref }}
@@ -177,7 +177,7 @@ jobs:
177177
build-release-package:
178178
name: "Build Release Package"
179179
needs: prepare
180-
if: github.repository == 'llvm/llvm-project'
180+
if: github.repository_owner == 'llvm'
181181
runs-on: ${{ needs.prepare.outputs.build-runs-on }}
182182
steps:
183183

@@ -327,7 +327,7 @@ jobs:
327327
- prepare
328328
- build-release-package
329329
if: >-
330-
github.repository == 'llvm/llvm-project'
330+
github.repository_owner == 'llvm'
331331
runs-on: ${{ needs.prepare.outputs.test-runs-on }}
332332
steps:
333333
- name: Checkout Actions

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: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "clang/AST/ASTContext.h"
1111
#include "clang/AST/Decl.h"
1212
#include "clang/ASTMatchers/ASTMatchFinder.h"
13+
#include "clang/ASTMatchers/ASTMatchers.h"
1314
#include "clang/Lex/Lexer.h"
1415

1516
using namespace clang::ast_matchers;
@@ -50,6 +51,10 @@ UnusedUsingDeclsCheck::UnusedUsingDeclsCheck(StringRef Name,
5051
HeaderFileExtensions(Context->getHeaderFileExtensions()) {}
5152

5253
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;
5358
Finder->addMatcher(usingDecl(isExpansionInMainFile()).bind("using"), this);
5459
auto DeclMatcher = hasDeclaration(namedDecl().bind("used"));
5560
Finder->addMatcher(loc(templateSpecializationType(DeclMatcher)), this);
@@ -82,12 +87,6 @@ void UnusedUsingDeclsCheck::registerMatchers(MatchFinder *Finder) {
8287
void UnusedUsingDeclsCheck::check(const MatchFinder::MatchResult &Result) {
8388
if (Result.Context->getDiagnostics().hasUncompilableErrorOccurred())
8489
return;
85-
// We don't emit warnings on unused-using-decls from headers, so bail out if
86-
// the main file is a header.
87-
if (auto MainFile = Result.SourceManager->getFileEntryRefForID(
88-
Result.SourceManager->getMainFileID());
89-
utils::isFileExtension(MainFile->getName(), HeaderFileExtensions))
90-
return;
9190

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

clang-tools-extra/modularize/CoverageChecker.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -278,15 +278,15 @@ CoverageChecker::collectUmbrellaHeaderHeaders(StringRef UmbrellaHeaderName) {
278278
sys::fs::current_path(PathBuf);
279279

280280
// Create the compilation database.
281-
std::unique_ptr<CompilationDatabase> Compilations;
282-
Compilations.reset(new FixedCompilationDatabase(Twine(PathBuf), CommandLine));
281+
FixedCompilationDatabase Compilations(Twine(PathBuf), CommandLine);
283282

284283
std::vector<std::string> HeaderPath;
285284
HeaderPath.push_back(std::string(UmbrellaHeaderName));
286285

287286
// Create the tool and run the compilation.
288-
ClangTool Tool(*Compilations, HeaderPath);
289-
int HadErrors = Tool.run(new CoverageCheckerFrontendActionFactory(*this));
287+
ClangTool Tool(Compilations, HeaderPath);
288+
CoverageCheckerFrontendActionFactory ActionFactory(*this);
289+
int HadErrors = Tool.run(&ActionFactory);
290290

291291
// If we had errors, exit early.
292292
return !HadErrors;

clang/docs/BoundsSafety.rst

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -996,4 +996,11 @@ and the soundness of the type system. This may incur significant code size
996996
overhead in unoptimized builds and leaving some of the adoption mistakes to be
997997
caught only at run time. This is not a fundamental limitation, however, because
998998
incrementally adding necessary static analysis will allow us to catch issues
999-
early on and remove unnecessary bounds checks in unoptimized builds.
999+
early on and remove unnecessary bounds checks in unoptimized builds.
1000+
1001+
Try it out
1002+
==========
1003+
1004+
Your feedback on the programming model is valuable. You may want to follow the
1005+
instruction in :doc:`BoundsSafetyAdoptionGuide` to play with ``-fbounds-safety``
1006+
and please send your feedback to `Yeoul Na <mailto:[email protected]>`_.
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
======================================
2+
Adoption Guide for ``-fbounds-safety``
3+
======================================
4+
5+
.. contents::
6+
:local:
7+
8+
Where to get ``-fbounds-safety``
9+
================================
10+
11+
The open sourcing to llvm.org's ``llvm-project`` is still on going and the
12+
feature is not available yet. In the mean time, the preview implementation is
13+
available
14+
`here <https://github.com/swiftlang/llvm-project/tree/stable/20240723>`_ in a
15+
fork of ``llvm-project``. Please follow
16+
`Building LLVM with CMake <https://llvm.org/docs/CMake.html>`_ to build the
17+
compiler.
18+
19+
Feature flag
20+
============
21+
22+
Pass ``-fbounds-safety`` as a Clang compilation flag for the C file that you
23+
want to adopt. We recommend adopting the model file by file, because adoption
24+
requires some effort to add bounds annotations and fix compiler diagnostics.
25+
26+
Include ``ptrcheck.h``
27+
======================
28+
29+
``ptrcheck.h`` is a Clang toolchain header to provide definition of the bounds
30+
annotations such as ``__counted_by``, ``__counted_by_or_null``, ``__sized_by``,
31+
etc. In the LLVM source tree, the header is located in
32+
``llvm-project/clang/lib/Headers/ptrcheck.h``.
33+
34+
35+
Add bounds annotations on pointers as necessary
36+
===============================================
37+
38+
Annotate pointers on struct fields and function parameters if they are pointing
39+
to an array of object, with appropriate bounds annotations. Please see
40+
:doc:`BoundsSafety` to learn what kind of bounds annotations are available and
41+
their semantics. Note that local pointer variables typically don't need bounds
42+
annotations because they are implicitely a wide pointer (``__bidi_indexable``)
43+
that automatically carries the bounds information.
44+
45+
Address compiler diagnostics
46+
============================
47+
48+
Once you pass ``-fbounds-safety`` to compiler a C file, you will see some new
49+
compiler warnings and errors, which guide adoption of ``-fbounds-safety``.
50+
Consider the following example:
51+
52+
.. code-block:: c
53+
54+
#include <ptrcheck.h>
55+
56+
void init_buf(int *p, int n) {
57+
for (int i = 0; i < n; ++i)
58+
p[i] = 0; // error: array subscript on single pointer 'p' must use a constant index of 0 to be in bounds
59+
}
60+
61+
The parameter ``int *p`` doesn't have a bounds annotation, so the compiler will
62+
complain about the code indexing into it (``p[i]``) as it assumes that ``p`` is
63+
pointing to a single ``int`` object or null. To address the diagnostics, you
64+
should add a bounds annotation on ``int *p`` so that the compiler can reason
65+
about the safety of the array subscript. In the following example, ``p`` is now
66+
``int *__counted_by(n)``, so the compiler will allow the array subscript with
67+
additional run-time checks as necessary.
68+
69+
.. code-block:: c
70+
71+
#include <ptrcheck.h>
72+
73+
void init_buf(int *__counted_by(n) p, int n) {
74+
for (int i = 0; i < n; ++i)
75+
p[i] = 0; // ok; `p` is now has a type with bounds annotation.
76+
}
77+
78+
Run test suites to fix new run-time traps
79+
=========================================
80+
81+
Adopting ``-fbounds-safety`` may cause your program to trap if it violates
82+
bounds safety or it has incorrect adoption. Thus, it is necessary to perform
83+
run-time testing of your program to gain confidence that it won't trap at
84+
run time.
85+
86+
Repeat the process for each remaining file
87+
==========================================
88+
89+
Once you've done with adopting a single C file, please repeat the same process
90+
for each remaining C file that you want to adopt.

0 commit comments

Comments
 (0)