Skip to content

Commit eb93a2e

Browse files
committed
merge main into amd-staging
2 parents 6e1edf9 + 370ea51 commit eb93a2e

Some content is hidden

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

46 files changed

+683
-860
lines changed

clang/docs/ClangFormatStyleOptions.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1795,6 +1795,13 @@ the configuration (without a prefix: ``Auto``).
17951795

17961796

17971797

1798+
.. _AllowBreakBeforeQtProperty:
1799+
1800+
**AllowBreakBeforeQtProperty** (``Boolean``) :versionbadge:`clang-format 22` :ref:`<AllowBreakBeforeQtProperty>`
1801+
Allow breaking before ``Q_Property`` keywords ``READ``, ``WRITE``, etc. as
1802+
if they were preceded by a comma (``,``). This allows them to be formatted
1803+
according to ``BinPackParameters``.
1804+
17981805
.. _AllowShortBlocksOnASingleLine:
17991806

18001807
**AllowShortBlocksOnASingleLine** (``ShortBlockStyle``) :versionbadge:`clang-format 3.5` :ref:`<AllowShortBlocksOnASingleLine>`

clang/docs/ReleaseNotes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -784,6 +784,7 @@ clang-format
784784
- Add ``NumericLiteralCase`` option for enforcing character case in numeric
785785
literals.
786786
- Add ``Leave`` suboption to ``IndentPPDirectives``.
787+
- Add ``AllowBreakBeforeQtProperty`` option.
787788

788789
libclang
789790
--------

clang/include/clang/Format/Format.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -732,6 +732,12 @@ struct FormatStyle {
732732
/// \version 18
733733
BreakBeforeNoexceptSpecifierStyle AllowBreakBeforeNoexceptSpecifier;
734734

735+
/// Allow breaking before ``Q_Property`` keywords ``READ``, ``WRITE``, etc. as
736+
/// if they were preceded by a comma (``,``). This allows them to be formatted
737+
/// according to ``BinPackParameters``.
738+
/// \version 22
739+
bool AllowBreakBeforeQtProperty;
740+
735741
/// Different styles for merging short blocks containing at most one
736742
/// statement.
737743
enum ShortBlockStyle : int8_t {
@@ -5458,6 +5464,7 @@ struct FormatStyle {
54585464
R.AllowAllParametersOfDeclarationOnNextLine &&
54595465
AllowBreakBeforeNoexceptSpecifier ==
54605466
R.AllowBreakBeforeNoexceptSpecifier &&
5467+
AllowBreakBeforeQtProperty == R.AllowBreakBeforeQtProperty &&
54615468
AllowShortBlocksOnASingleLine == R.AllowShortBlocksOnASingleLine &&
54625469
AllowShortCaseExpressionOnASingleLine ==
54635470
R.AllowShortCaseExpressionOnASingleLine &&

clang/lib/Basic/Targets.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,9 @@ std::unique_ptr<TargetInfo> AllocateTarget(const llvm::Triple &Triple,
172172
case llvm::Triple::OpenBSD:
173173
return std::make_unique<OpenBSDTargetInfo<AArch64leTargetInfo>>(Triple,
174174
Opts);
175+
case llvm::Triple::Hurd:
176+
return std::make_unique<HurdTargetInfo<AArch64leTargetInfo>>(Triple,
177+
Opts);
175178
case llvm::Triple::Win32:
176179
switch (Triple.getEnvironment()) {
177180
case llvm::Triple::GNU:
@@ -464,6 +467,8 @@ std::unique_ptr<TargetInfo> AllocateTarget(const llvm::Triple &Triple,
464467
case llvm::Triple::Managarm:
465468
return std::make_unique<ManagarmTargetInfo<RISCV64TargetInfo>>(Triple,
466469
Opts);
470+
case llvm::Triple::Hurd:
471+
return std::make_unique<HurdTargetInfo<RISCV64TargetInfo>>(Triple, Opts);
467472
default:
468473
return std::make_unique<RISCV64TargetInfo>(Triple, Opts);
469474
}

clang/lib/Driver/ToolChains/Gnu.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2575,6 +2575,14 @@ void Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes(
25752575

25762576
if (TargetTriple.isOSHurd()) {
25772577
switch (TargetTriple.getArch()) {
2578+
case llvm::Triple::aarch64:
2579+
LibDirs.append(begin(AArch64LibDirs), end(AArch64LibDirs));
2580+
TripleAliases.push_back("aarch64-gnu");
2581+
break;
2582+
case llvm::Triple::riscv64:
2583+
LibDirs.append(begin(RISCV64LibDirs), end(RISCV64LibDirs));
2584+
TripleAliases.push_back("riscv64-gnu");
2585+
break;
25782586
case llvm::Triple::x86_64:
25792587
LibDirs.append(begin(X86_64LibDirs), end(X86_64LibDirs));
25802588
TripleAliases.push_back("x86_64-gnu");

clang/lib/Driver/ToolChains/Hurd.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ std::string Hurd::getMultiarchTriple(const Driver &D,
3434
default:
3535
break;
3636

37+
case llvm::Triple::aarch64:
38+
return "aarch64-gnu";
39+
40+
case llvm::Triple::riscv64:
41+
return "riscv64-gnu";
42+
3743
case llvm::Triple::x86:
3844
// We use the existence of '/lib/<triple>' as a directory to detect some
3945
// common hurd triples that don't quite match the Clang triple for both
@@ -142,6 +148,10 @@ Tool *Hurd::buildAssembler() const {
142148

143149
std::string Hurd::getDynamicLinker(const ArgList &Args) const {
144150
switch (getArch()) {
151+
case llvm::Triple::aarch64:
152+
return "/lib/ld-aarch64.so.1";
153+
case llvm::Triple::riscv64:
154+
return "/lib/ld-riscv64-lp64.so.1";
145155
case llvm::Triple::x86:
146156
return "/lib/ld.so";
147157
case llvm::Triple::x86_64:

clang/lib/Driver/ToolChains/Hurd.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ class LLVM_LIBRARY_VISIBILITY Hurd : public Generic_ELF {
3030
addLibStdCxxIncludePaths(const llvm::opt::ArgList &DriverArgs,
3131
llvm::opt::ArgStringList &CC1Args) const override;
3232

33+
bool IsAArch64OutlineAtomicsDefault(
34+
const llvm::opt::ArgList &Args) const override {
35+
return true;
36+
}
37+
3338
std::string getDynamicLinker(const llvm::opt::ArgList &Args) const override;
3439

3540
void addExtraOpts(llvm::opt::ArgStringList &CmdArgs) const override;

clang/lib/Format/Format.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,6 +1028,8 @@ template <> struct MappingTraits<FormatStyle> {
10281028
Style.AllowAllParametersOfDeclarationOnNextLine);
10291029
IO.mapOptional("AllowBreakBeforeNoexceptSpecifier",
10301030
Style.AllowBreakBeforeNoexceptSpecifier);
1031+
IO.mapOptional("AllowBreakBeforeQtProperty",
1032+
Style.AllowBreakBeforeQtProperty);
10311033
IO.mapOptional("AllowShortBlocksOnASingleLine",
10321034
Style.AllowShortBlocksOnASingleLine);
10331035
IO.mapOptional("AllowShortCaseExpressionOnASingleLine",
@@ -1567,6 +1569,7 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind Language) {
15671569
LLVMStyle.AllowAllArgumentsOnNextLine = true;
15681570
LLVMStyle.AllowAllParametersOfDeclarationOnNextLine = true;
15691571
LLVMStyle.AllowBreakBeforeNoexceptSpecifier = FormatStyle::BBNSS_Never;
1572+
LLVMStyle.AllowBreakBeforeQtProperty = false;
15701573
LLVMStyle.AllowShortBlocksOnASingleLine = FormatStyle::SBS_Never;
15711574
LLVMStyle.AllowShortCaseExpressionOnASingleLine = true;
15721575
LLVMStyle.AllowShortCaseLabelsOnASingleLine = false;

clang/lib/Format/FormatToken.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,20 @@ const char *getTokenTypeName(TokenType Type) {
3333
return nullptr;
3434
}
3535

36+
static constexpr std::array<StringRef, 14> QtPropertyKeywords = {
37+
"BINDABLE", "CONSTANT", "DESIGNABLE", "FINAL", "MEMBER",
38+
"NOTIFY", "READ", "REQUIRED", "RESET", "REVISION",
39+
"SCRIPTABLE", "STORED", "USER", "WRITE",
40+
};
41+
42+
bool FormatToken::isQtProperty() const {
43+
assert(llvm::is_sorted(QtPropertyKeywords));
44+
return std::binary_search(QtPropertyKeywords.begin(),
45+
QtPropertyKeywords.end(), TokenText);
46+
}
47+
3648
// Sorted common C++ non-keyword types.
37-
static SmallVector<StringRef> CppNonKeywordTypes = {
49+
static constexpr std::array<StringRef, 14> CppNonKeywordTypes = {
3850
"clock_t", "int16_t", "int32_t", "int64_t", "int8_t",
3951
"intptr_t", "ptrdiff_t", "size_t", "time_t", "uint16_t",
4052
"uint32_t", "uint64_t", "uint8_t", "uintptr_t",
@@ -330,6 +342,8 @@ bool startsNextParameter(const FormatToken &Current, const FormatStyle &Style) {
330342
}
331343
if (Style.Language == FormatStyle::LK_Proto && Current.is(TT_SelectorName))
332344
return true;
345+
if (Current.is(TT_QtProperty))
346+
return true;
333347
return Previous.is(tok::comma) && !Current.isTrailingComment() &&
334348
((Previous.isNot(TT_CtorInitializerComma) ||
335349
Style.BreakConstructorInitializers !=

clang/lib/Format/FormatToken.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ namespace format {
136136
TYPE(PointerOrReference) \
137137
TYPE(ProtoExtensionLSquare) \
138138
TYPE(PureVirtualSpecifier) \
139+
TYPE(QtProperty) \
139140
TYPE(RangeBasedForLoopColon) \
140141
TYPE(RecordLBrace) \
141142
TYPE(RecordRBrace) \
@@ -703,6 +704,7 @@ struct FormatToken {
703704
isAttribute();
704705
}
705706

707+
[[nodiscard]] bool isQtProperty() const;
706708
[[nodiscard]] bool isTypeName(const LangOptions &LangOpts) const;
707709
[[nodiscard]] bool isTypeOrIdentifier(const LangOptions &LangOpts) const;
708710

0 commit comments

Comments
 (0)