Skip to content

Commit 109283b

Browse files
committed
Merge "merge main into amd-staging" into amd-staging
2 parents e33f135 + 2f520d8 commit 109283b

File tree

107 files changed

+3462
-3582
lines changed

Some content is hidden

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

107 files changed

+3462
-3582
lines changed

.ci/generate-buildkite-pipeline-premerge

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,22 @@ function compute-projects-to-test() {
8585
done
8686
}
8787

88+
function compute-runtimes-to-test() {
89+
projects=${@}
90+
for project in ${projects}; do
91+
case ${project} in
92+
clang)
93+
for p in libcxx libcxxabi libunwind; do
94+
echo $p
95+
done
96+
;;
97+
*)
98+
# Nothing to do
99+
;;
100+
esac
101+
done
102+
}
103+
88104
function add-dependencies() {
89105
projects=${@}
90106
for project in ${projects}; do
@@ -178,6 +194,15 @@ function check-targets() {
178194
cross-project-tests)
179195
echo "check-cross-project"
180196
;;
197+
libcxx)
198+
echo "check-cxx"
199+
;;
200+
libcxxabi)
201+
echo "check-cxxabi"
202+
;;
203+
libunwind)
204+
echo "check-unwind"
205+
;;
181206
lldb)
182207
echo "check-all" # TODO: check-lldb may not include all the LLDB tests?
183208
;;
@@ -207,17 +232,6 @@ if echo "$modified_dirs" | grep -q -E "^(libcxx|libcxxabi|libunwind|runtimes|cma
207232
EOF
208233
fi
209234

210-
# If clang changed.
211-
if echo "$modified_dirs" | grep -q -E "^(clang)$"; then
212-
cat <<EOF
213-
- trigger: "clang-ci"
214-
build:
215-
message: "${buildMessage}"
216-
commit: "${BUILDKITE_COMMIT}"
217-
branch: "${BUILDKITE_BRANCH}"
218-
EOF
219-
fi
220-
221235
# Generic pipeline for projects that have not defined custom steps.
222236
#
223237
# Individual projects should instead define the pre-commit CI tests that suits their
@@ -231,6 +245,10 @@ linux_projects_to_test=$(exclude-linux $(compute-projects-to-test ${modified_pro
231245
linux_check_targets=$(check-targets ${linux_projects_to_test} | sort | uniq)
232246
linux_projects=$(add-dependencies ${linux_projects_to_test} | sort | uniq)
233247

248+
linux_runtimes_to_test=$(compute-runtimes-to-test ${linux_projects_to_test})
249+
linux_runtime_check_targets=$(check-targets ${linux_runtimes_to_test} | sort | uniq)
250+
linux_runtimes=$(echo ${linux_runtimes_to_test} | sort | uniq)
251+
234252
windows_projects_to_test=$(exclude-windows $(compute-projects-to-test ${modified_projects}))
235253
windows_check_targets=$(check-targets ${windows_projects_to_test} | sort | uniq)
236254
windows_projects=$(add-dependencies ${windows_projects_to_test} | sort | uniq)
@@ -255,7 +273,7 @@ if [[ "${linux_projects}" != "" ]]; then
255273
CC: 'clang'
256274
CXX: 'clang++'
257275
commands:
258-
- './.ci/monolithic-linux.sh "$(echo ${linux_projects} | tr ' ' ';')" "$(echo ${linux_check_targets})"'
276+
- './.ci/monolithic-linux.sh "$(echo ${linux_projects} | tr ' ' ';')" "$(echo ${linux_check_targets})" "$(echo ${linux_runtimes} | tr ' ' ';')" "$(echo ${linux_runtime_check_targets})"'
259277
EOF
260278
fi
261279

.ci/monolithic-linux.sh

Lines changed: 73 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ set -o pipefail
1818

1919
MONOREPO_ROOT="${MONOREPO_ROOT:="$(git rev-parse --show-toplevel)"}"
2020
BUILD_DIR="${BUILD_DIR:=${MONOREPO_ROOT}/build}"
21+
INSTALL_DIR="${BUILD_DIR}/install"
2122
rm -rf "${BUILD_DIR}"
2223

2324
ccache --zero-stats
@@ -49,8 +50,79 @@ cmake -S "${MONOREPO_ROOT}"/llvm -B "${BUILD_DIR}" \
4950
-D LLVM_ENABLE_LLD=ON \
5051
-D CMAKE_CXX_FLAGS=-gmlt \
5152
-D LLVM_CCACHE_BUILD=ON \
52-
-D MLIR_ENABLE_BINDINGS_PYTHON=ON
53+
-D MLIR_ENABLE_BINDINGS_PYTHON=ON \
54+
-D CMAKE_INSTALL_PREFIX="${INSTALL_DIR}"
5355

5456
echo "--- ninja"
5557
# Targets are not escaped as they are passed as separate arguments.
5658
ninja -C "${BUILD_DIR}" -k 0 ${targets}
59+
60+
runtimes="${3}"
61+
runtime_targets="${4}"
62+
63+
# Compiling runtimes with just-built Clang and running their tests
64+
# as an additional testing for Clang.
65+
if [[ "${runtimes}" != "" ]]; then
66+
if [[ "${runtime_targets}" == "" ]]; then
67+
echo "Runtimes to build are specified, but targets are not."
68+
exit 1
69+
fi
70+
71+
echo "--- ninja install-clang"
72+
73+
ninja -C ${BUILD_DIR} install-clang install-clang-resource-headers
74+
75+
RUNTIMES_BUILD_DIR="${MONOREPO_ROOT}/build-runtimes"
76+
INSTALL_DIR="${BUILD_DIR}/install"
77+
mkdir -p ${RUNTIMES_BUILD_DIR}
78+
79+
echo "--- cmake runtimes C++03"
80+
81+
cmake -S "${MONOREPO_ROOT}/runtimes" -B "${RUNTIMES_BUILD_DIR}" -GNinja \
82+
-D CMAKE_C_COMPILER="${INSTALL_DIR}/bin/clang" \
83+
-D CMAKE_CXX_COMPILER="${INSTALL_DIR}/bin/clang++" \
84+
-D LLVM_ENABLE_RUNTIMES="${runtimes}" \
85+
-D LIBCXX_CXX_ABI=libcxxabi \
86+
-D CMAKE_BUILD_TYPE=RelWithDebInfo \
87+
-D CMAKE_INSTALL_PREFIX="${INSTALL_DIR}" \
88+
-D LIBCXX_TEST_PARAMS="std=c++03" \
89+
-D LIBCXXABI_TEST_PARAMS="std=c++03"
90+
91+
echo "--- ninja runtimes C++03"
92+
93+
ninja -vC "${RUNTIMES_BUILD_DIR}" ${runtime_targets}
94+
95+
echo "--- cmake runtimes C++26"
96+
97+
rm -rf "${RUNTIMES_BUILD_DIR}"
98+
cmake -S "${MONOREPO_ROOT}/runtimes" -B "${RUNTIMES_BUILD_DIR}" -GNinja \
99+
-D CMAKE_C_COMPILER="${INSTALL_DIR}/bin/clang" \
100+
-D CMAKE_CXX_COMPILER="${INSTALL_DIR}/bin/clang++" \
101+
-D LLVM_ENABLE_RUNTIMES="${runtimes}" \
102+
-D LIBCXX_CXX_ABI=libcxxabi \
103+
-D CMAKE_BUILD_TYPE=RelWithDebInfo \
104+
-D CMAKE_INSTALL_PREFIX="${INSTALL_DIR}" \
105+
-D LIBCXX_TEST_PARAMS="std=c++26" \
106+
-D LIBCXXABI_TEST_PARAMS="std=c++26"
107+
108+
echo "--- ninja runtimes C++26"
109+
110+
ninja -vC "${RUNTIMES_BUILD_DIR}" ${runtime_targets}
111+
112+
echo "--- cmake runtimes clang modules"
113+
114+
rm -rf "${RUNTIMES_BUILD_DIR}"
115+
cmake -S "${MONOREPO_ROOT}/runtimes" -B "${RUNTIMES_BUILD_DIR}" -GNinja \
116+
-D CMAKE_C_COMPILER="${INSTALL_DIR}/bin/clang" \
117+
-D CMAKE_CXX_COMPILER="${INSTALL_DIR}/bin/clang++" \
118+
-D LLVM_ENABLE_RUNTIMES="${runtimes}" \
119+
-D LIBCXX_CXX_ABI=libcxxabi \
120+
-D CMAKE_BUILD_TYPE=RelWithDebInfo \
121+
-D CMAKE_INSTALL_PREFIX="${INSTALL_DIR}" \
122+
-D LIBCXX_TEST_PARAMS="enable_modules=clang" \
123+
-D LIBCXXABI_TEST_PARAMS="enable_modules=clang"
124+
125+
echo "--- ninja runtimes clang modules"
126+
127+
ninja -vC "${RUNTIMES_BUILD_DIR}" ${runtime_targets}
128+
fi

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ TEST(ClangdServerTest, SearchLibDir) {
392392
ErrorCheckingCallbacks DiagConsumer;
393393
MockCompilationDatabase CDB;
394394
CDB.ExtraClangFlags.insert(CDB.ExtraClangFlags.end(),
395-
{"-xc++", "-target", "x86_64-linux-unknown",
395+
{"-xc++", "--target=x86_64-unknown-linux-gnu",
396396
"-m64", "--gcc-toolchain=/randomusr",
397397
"-stdlib=libstdc++"});
398398
ClangdServer Server(CDB, FS, ClangdServer::optsForTest(), &DiagConsumer);

clang/docs/ClangFormatStyleOptions.rst

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1421,13 +1421,21 @@ the configuration (without a prefix: ``Auto``).
14211421

14221422
.. code-block:: c++
14231423

1424-
true:
14251424
#define A \
14261425
int aaaa; \
14271426
int b; \
14281427
int dddddddddd;
14291428

1430-
false:
1429+
* ``ENAS_LeftWithLastLine`` (in configuration: ``LeftWithLastLine``)
1430+
Align escaped newlines as far left as possible, using the last line of
1431+
the preprocessor directive as the reference if it's the longest.
1432+
1433+
.. code-block:: c++
1434+
1435+
#define A \
1436+
int aaaa; \
1437+
int b; \
1438+
int dddddddddd;
14311439

14321440
* ``ENAS_Right`` (in configuration: ``Right``)
14331441
Align escaped newlines in the right-most column.

clang/docs/ReleaseNotes.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -974,9 +974,10 @@ clang-format
974974
``BreakTemplateDeclarations``.
975975
- ``AlwaysBreakAfterReturnType`` is deprecated and renamed to
976976
``BreakAfterReturnType``.
977-
- Handles Java ``switch`` expressions.
977+
- Handles Java switch expressions.
978978
- Adds ``AllowShortCaseExpressionOnASingleLine`` option.
979979
- Adds ``AlignCaseArrows`` suboption to ``AlignConsecutiveShortCaseStatements``.
980+
- Adds ``LeftWithLastLine`` suboption to ``AlignEscapedNewlines``.
980981

981982
libclang
982983
--------

clang/include/clang/Format/Format.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -480,15 +480,21 @@ struct FormatStyle {
480480
ENAS_DontAlign,
481481
/// Align escaped newlines as far left as possible.
482482
/// \code
483-
/// true:
484483
/// #define A \
485484
/// int aaaa; \
486485
/// int b; \
487486
/// int dddddddddd;
488-
///
489-
/// false:
490487
/// \endcode
491488
ENAS_Left,
489+
/// Align escaped newlines as far left as possible, using the last line of
490+
/// the preprocessor directive as the reference if it's the longest.
491+
/// \code
492+
/// #define A \
493+
/// int aaaa; \
494+
/// int b; \
495+
/// int dddddddddd;
496+
/// \endcode
497+
ENAS_LeftWithLastLine,
492498
/// Align escaped newlines in the right-most column.
493499
/// \code
494500
/// #define A \

clang/lib/Format/Format.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@ struct ScalarEnumerationTraits<FormatStyle::EscapedNewlineAlignmentStyle> {
308308
FormatStyle::EscapedNewlineAlignmentStyle &Value) {
309309
IO.enumCase(Value, "DontAlign", FormatStyle::ENAS_DontAlign);
310310
IO.enumCase(Value, "Left", FormatStyle::ENAS_Left);
311+
IO.enumCase(Value, "LeftWithLastLine", FormatStyle::ENAS_LeftWithLastLine);
311312
IO.enumCase(Value, "Right", FormatStyle::ENAS_Right);
312313

313314
// For backward compatibility.

clang/lib/Format/WhitespaceManager.cpp

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,22 +1245,29 @@ void WhitespaceManager::alignTrailingComments(unsigned Start, unsigned End,
12451245
}
12461246

12471247
void WhitespaceManager::alignEscapedNewlines() {
1248-
if (Style.AlignEscapedNewlines == FormatStyle::ENAS_DontAlign)
1248+
const auto Align = Style.AlignEscapedNewlines;
1249+
if (Align == FormatStyle::ENAS_DontAlign)
12491250
return;
12501251

1251-
bool AlignLeft = Style.AlignEscapedNewlines == FormatStyle::ENAS_Left;
1252-
unsigned MaxEndOfLine = AlignLeft ? 0 : Style.ColumnLimit;
1252+
const bool WithLastLine = Align == FormatStyle::ENAS_LeftWithLastLine;
1253+
const bool AlignLeft = Align == FormatStyle::ENAS_Left || WithLastLine;
1254+
const auto MaxColumn = Style.ColumnLimit;
1255+
unsigned MaxEndOfLine = AlignLeft ? 0 : MaxColumn;
12531256
unsigned StartOfMacro = 0;
12541257
for (unsigned i = 1, e = Changes.size(); i < e; ++i) {
12551258
Change &C = Changes[i];
1256-
if (C.NewlinesBefore > 0) {
1257-
if (C.ContinuesPPDirective) {
1258-
MaxEndOfLine = std::max(C.PreviousEndOfTokenColumn + 2, MaxEndOfLine);
1259-
} else {
1260-
alignEscapedNewlines(StartOfMacro + 1, i, MaxEndOfLine);
1261-
MaxEndOfLine = AlignLeft ? 0 : Style.ColumnLimit;
1262-
StartOfMacro = i;
1263-
}
1259+
if (C.NewlinesBefore == 0 && (!WithLastLine || C.Tok->isNot(tok::eof)))
1260+
continue;
1261+
const bool InPPDirective = C.ContinuesPPDirective;
1262+
const auto BackslashColumn = C.PreviousEndOfTokenColumn + 2;
1263+
if (InPPDirective ||
1264+
(WithLastLine && (MaxColumn == 0 || BackslashColumn <= MaxColumn))) {
1265+
MaxEndOfLine = std::max(BackslashColumn, MaxEndOfLine);
1266+
}
1267+
if (!InPPDirective) {
1268+
alignEscapedNewlines(StartOfMacro + 1, i, MaxEndOfLine);
1269+
MaxEndOfLine = AlignLeft ? 0 : MaxColumn;
1270+
StartOfMacro = i;
12641271
}
12651272
}
12661273
alignEscapedNewlines(StartOfMacro + 1, Changes.size(), MaxEndOfLine);

clang/lib/Serialization/ASTWriter.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5037,6 +5037,14 @@ void ASTWriter::PrepareWritingSpecialDecls(Sema &SemaRef) {
50375037
continue;
50385038
}
50395039

5040+
// If we're writing C++ named modules, don't emit declarations which are
5041+
// not from modules by default. They may be built in declarations (be
5042+
// handled above) or implcit declarations (see the implementation of
5043+
// `Sema::Initialize()` for example).
5044+
if (isWritingStdCXXNamedModules() && !D->getOwningModule() &&
5045+
D->isImplicit())
5046+
continue;
5047+
50405048
GetDeclRef(D);
50415049
}
50425050

@@ -6197,8 +6205,9 @@ bool ASTWriter::wasDeclEmitted(const Decl *D) const {
61976205
return true;
61986206

61996207
bool Emitted = DeclIDs.contains(D);
6200-
assert((Emitted || GeneratingReducedBMI) &&
6201-
"The declaration can only be omitted in reduced BMI.");
6208+
assert((Emitted || (!D->getOwningModule() && isWritingStdCXXNamedModules()) ||
6209+
GeneratingReducedBMI) &&
6210+
"The declaration within modules can only be omitted in reduced BMI.");
62026211
return Emitted;
62036212
}
62046213

0 commit comments

Comments
 (0)