Skip to content

Commit 1bf0e55

Browse files
committed
Merge remote-tracking branch 'upstream/main' into unify_privatization_paths
2 parents e29c7d4 + 50da768 commit 1bf0e55

File tree

323 files changed

+20491
-16726
lines changed

Some content is hidden

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

323 files changed

+20491
-16726
lines changed

bolt/include/bolt/Rewrite/DWARFRewriter.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -177,13 +177,6 @@ class DWARFRewriter {
177177
DIEValue &HighPCAttrInfo,
178178
std::optional<uint64_t> RangesBase = std::nullopt);
179179

180-
/// Adds a \p Str to .debug_str section.
181-
/// Uses \p AttrInfoVal to either update entry in a DIE for legacy DWARF using
182-
/// \p DebugInfoPatcher, or for DWARF5 update an index in .debug_str_offsets
183-
/// for this contribution of \p Unit.
184-
void addStringHelper(DIEBuilder &DIEBldr, DIE &Die, const DWARFUnit &Unit,
185-
DIEValue &DIEAttrInfo, StringRef Str);
186-
187180
public:
188181
DWARFRewriter(BinaryContext &BC) : BC(BC) {}
189182

bolt/lib/Rewrite/DWARFRewriter.cpp

Lines changed: 45 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -582,19 +582,51 @@ static void emitDWOBuilder(const std::string &DWOName,
582582
Rewriter.writeDWOFiles(CU, OverriddenSections, DWOName, LocWriter);
583583
}
584584

585-
void DWARFRewriter::addStringHelper(DIEBuilder &DIEBldr, DIE &Die,
586-
const DWARFUnit &Unit,
587-
DIEValue &DIEAttrInfo, StringRef Str) {
588-
uint32_t NewOffset = StrWriter->addString(Str);
585+
/// Adds a \p Str to .debug_str section.
586+
/// Uses \p AttrInfoVal to either update entry in a DIE for legacy DWARF using
587+
/// \p DebugInfoPatcher, or for DWARF5 update an index in .debug_str_offsets
588+
/// for this contribution of \p Unit.
589+
static void addStringHelper(DebugStrOffsetsWriter &StrOffstsWriter,
590+
DebugStrWriter &StrWriter, DIEBuilder &DIEBldr,
591+
DIE &Die, const DWARFUnit &Unit,
592+
DIEValue &DIEAttrInfo, StringRef Str) {
593+
uint32_t NewOffset = StrWriter.addString(Str);
589594
if (Unit.getVersion() >= 5) {
590-
StrOffstsWriter->updateAddressMap(DIEAttrInfo.getDIEInteger().getValue(),
591-
NewOffset);
595+
StrOffstsWriter.updateAddressMap(DIEAttrInfo.getDIEInteger().getValue(),
596+
NewOffset);
592597
return;
593598
}
594599
DIEBldr.replaceValue(&Die, DIEAttrInfo.getAttribute(), DIEAttrInfo.getForm(),
595600
DIEInteger(NewOffset));
596601
}
597602

603+
static std::string
604+
updateDWONameCompDir(DebugStrOffsetsWriter &StrOffstsWriter,
605+
DebugStrWriter &StrWriter,
606+
std::unordered_map<std::string, uint32_t> &NameToIndexMap,
607+
DWARFUnit &Unit, DIEBuilder &DIEBldr, DIE &UnitDIE) {
608+
DIEValue DWONameAttrInfo = UnitDIE.findAttribute(dwarf::DW_AT_dwo_name);
609+
if (!DWONameAttrInfo)
610+
DWONameAttrInfo = UnitDIE.findAttribute(dwarf::DW_AT_GNU_dwo_name);
611+
assert(DWONameAttrInfo && "DW_AT_dwo_name is not in Skeleton CU.");
612+
std::string ObjectName;
613+
614+
ObjectName = getDWOName(Unit, NameToIndexMap);
615+
addStringHelper(StrOffstsWriter, StrWriter, DIEBldr, UnitDIE, Unit,
616+
DWONameAttrInfo, ObjectName.c_str());
617+
618+
DIEValue CompDirAttrInfo = UnitDIE.findAttribute(dwarf::DW_AT_comp_dir);
619+
assert(CompDirAttrInfo && "DW_AT_comp_dir is not in Skeleton CU.");
620+
621+
if (!opts::DwarfOutputPath.empty()) {
622+
if (!sys::fs::exists(opts::DwarfOutputPath))
623+
sys::fs::create_directory(opts::DwarfOutputPath);
624+
addStringHelper(StrOffstsWriter, StrWriter, DIEBldr, UnitDIE, Unit,
625+
CompDirAttrInfo, opts::DwarfOutputPath.c_str());
626+
}
627+
return ObjectName;
628+
}
629+
598630
using DWARFUnitVec = std::vector<DWARFUnit *>;
599631
using CUPartitionVector = std::vector<DWARFUnitVec>;
600632
/// Partitions CUs in to buckets. Bucket size is controlled by
@@ -692,33 +724,6 @@ void DWARFRewriter::updateDebugInfo() {
692724
// specified.
693725
std::unordered_map<std::string, uint32_t> NameToIndexMap;
694726

695-
auto updateDWONameCompDir = [&](DWARFUnit &Unit, DIEBuilder &DIEBldr,
696-
DIE &UnitDIE) -> std::string {
697-
DIEValue DWONameAttrInfo = UnitDIE.findAttribute(dwarf::DW_AT_dwo_name);
698-
if (!DWONameAttrInfo)
699-
DWONameAttrInfo = UnitDIE.findAttribute(dwarf::DW_AT_GNU_dwo_name);
700-
assert(DWONameAttrInfo && "DW_AT_dwo_name is not in Skeleton CU.");
701-
std::string ObjectName;
702-
703-
{
704-
std::lock_guard<std::mutex> Lock(AccessMutex);
705-
ObjectName = getDWOName(Unit, NameToIndexMap);
706-
}
707-
addStringHelper(DIEBldr, UnitDIE, Unit, DWONameAttrInfo,
708-
ObjectName.c_str());
709-
710-
DIEValue CompDirAttrInfo = UnitDIE.findAttribute(dwarf::DW_AT_comp_dir);
711-
assert(CompDirAttrInfo && "DW_AT_comp_dir is not in Skeleton CU.");
712-
713-
if (!opts::DwarfOutputPath.empty()) {
714-
if (!sys::fs::exists(opts::DwarfOutputPath))
715-
sys::fs::create_directory(opts::DwarfOutputPath);
716-
addStringHelper(DIEBldr, UnitDIE, Unit, CompDirAttrInfo,
717-
opts::DwarfOutputPath.c_str());
718-
}
719-
return ObjectName;
720-
};
721-
722727
DWARF5AcceleratorTable DebugNamesTable(opts::CreateDebugNames, BC,
723728
*StrWriter);
724729
DWPState State;
@@ -741,8 +746,13 @@ void DWARFRewriter::updateDebugInfo() {
741746
DIEBuilder DWODIEBuilder(BC, &(*SplitCU)->getContext(), DebugNamesTable,
742747
Unit);
743748
DWODIEBuilder.buildDWOUnit(**SplitCU);
744-
std::string DWOName = updateDWONameCompDir(
745-
*Unit, *DIEBlder, *DIEBlder->getUnitDIEbyUnit(*Unit));
749+
std::string DWOName = "";
750+
{
751+
std::lock_guard<std::mutex> Lock(AccessMutex);
752+
DWOName = updateDWONameCompDir(*StrOffstsWriter, *StrWriter,
753+
NameToIndexMap, *Unit, *DIEBlder,
754+
*DIEBlder->getUnitDIEbyUnit(*Unit));
755+
}
746756

747757
DebugLoclistWriter DebugLocDWoWriter(*Unit, Unit->getVersion(), true);
748758
DebugRangesSectionWriter *TempRangesSectionWriter = RangesSectionWriter;

clang-tools-extra/clang-include-fixer/find-all-symbols/STLPostfixHeaderMap.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ const HeaderMapCollector::RegexHeaderMap *getSTLPostfixHeaderMap() {
1515
static const HeaderMapCollector::RegexHeaderMap STLPostfixHeaderMap = {
1616
{"include/__stdarg___gnuc_va_list.h$", "<cstdarg>"},
1717
{"include/__stdarg___va_copy.h$", "<cstdarg>"},
18+
{"include/__stdarg_header_macro.h$", "<cstdarg>"},
1819
{"include/__stdarg_va_arg.h$", "<cstdarg>"},
1920
{"include/__stdarg_va_copy.h$", "<cstdarg>"},
2021
{"include/__stdarg_va_list.h$", "<cstdarg>"},
22+
{"include/__stddef_header_macro.h$", "<cstddef>"},
2123
{"include/__stddef_max_align_t.h$", "<cstddef>"},
2224
{"include/__stddef_null.h$", "<cstddef>"},
2325
{"include/__stddef_nullptr_t.h$", "<cstddef>"},

clang-tools-extra/clang-tidy/bugprone/ReturnConstRefFromParameterCheck.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,13 @@ void ReturnConstRefFromParameterCheck::registerMatchers(MatchFinder *Finder) {
2929
void ReturnConstRefFromParameterCheck::check(
3030
const MatchFinder::MatchResult &Result) {
3131
const auto *R = Result.Nodes.getNodeAs<ReturnStmt>("ret");
32-
diag(R->getRetValue()->getBeginLoc(),
33-
"returning a constant reference parameter may cause a use-after-free "
32+
const SourceRange Range = R->getRetValue()->getSourceRange();
33+
if (Range.isInvalid())
34+
return;
35+
diag(Range.getBegin(),
36+
"returning a constant reference parameter may cause use-after-free "
3437
"when the parameter is constructed from a temporary")
35-
<< R->getRetValue()->getSourceRange();
38+
<< Range;
3639
}
3740

3841
} // namespace clang::tidy::bugprone

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@ namespace {
1818
const std::pair<llvm::StringRef, llvm::StringRef> IncludeMappings[] = {
1919
{"include/__stdarg___gnuc_va_list.h", "<cstdarg>"},
2020
{"include/__stdarg___va_copy.h", "<cstdarg>"},
21+
{"include/__stdarg_header_macro.h", "<cstdarg>"},
2122
{"include/__stdarg_va_arg.h", "<cstdarg>"},
2223
{"include/__stdarg_va_copy.h", "<cstdarg>"},
2324
{"include/__stdarg_va_list.h", "<cstdarg>"},
25+
{"include/__stddef_header_macro.h", "<cstddef>"},
2426
{"include/__stddef_max_align_t.h", "<cstddef>"},
2527
{"include/__stddef_null.h", "<cstddef>"},
2628
{"include/__stddef_nullptr_t.h", "<cstddef>"},

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -965,6 +965,19 @@ class Foo final {})cpp";
965965
// Bindings are in theory public members of an anonymous struct.
966966
HI.AccessSpecifier = "public";
967967
}},
968+
{// Don't crash on invalid decl with invalid init expr.
969+
R"cpp(
970+
Unknown [[^abc]] = invalid;
971+
// error-ok
972+
)cpp",
973+
[](HoverInfo &HI) {
974+
HI.Name = "abc";
975+
HI.Kind = index::SymbolKind::Variable;
976+
HI.NamespaceScope = "";
977+
HI.Definition = "int abc = <recovery - expr>()";
978+
HI.Type = "int";
979+
HI.AccessSpecifier = "public";
980+
}},
968981
{// Extra info for function call.
969982
R"cpp(
970983
void fun(int arg_a, int &arg_b) {};

clang/docs/ClangFormatStyleOptions.rst

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -861,7 +861,8 @@ the configuration (without a prefix: ``Auto``).
861861

862862
**AlignConsecutiveShortCaseStatements** (``ShortCaseStatementsAlignmentStyle``) :versionbadge:`clang-format 17` :ref:`<AlignConsecutiveShortCaseStatements>`
863863
Style of aligning consecutive short case labels.
864-
Only applies if ``AllowShortCaseLabelsOnASingleLine`` is ``true``.
864+
Only applies if ``AllowShortCaseExpressionOnASingleLine`` or
865+
``AllowShortCaseLabelsOnASingleLine`` is ``true``.
865866

866867

867868
.. code-block:: yaml
@@ -935,6 +936,24 @@ the configuration (without a prefix: ``Auto``).
935936
default: return "";
936937
}
937938
939+
* ``bool AlignCaseArrows`` Whether to align the case arrows when aligning short case expressions.
940+
941+
.. code-block:: java
942+
943+
true:
944+
i = switch (day) {
945+
case THURSDAY, SATURDAY -> 8;
946+
case WEDNESDAY -> 9;
947+
default -> 0;
948+
};
949+
950+
false:
951+
i = switch (day) {
952+
case THURSDAY, SATURDAY -> 8;
953+
case WEDNESDAY -> 9;
954+
default -> 0;
955+
};
956+
938957
* ``bool AlignCaseColons`` Whether aligned case labels are aligned on the colon, or on the tokens
939958
after the colon.
940959

@@ -1692,6 +1711,21 @@ the configuration (without a prefix: ``Auto``).
16921711

16931712

16941713

1714+
.. _AllowShortCaseExpressionOnASingleLine:
1715+
1716+
**AllowShortCaseExpressionOnASingleLine** (``Boolean``) :versionbadge:`clang-format 19` :ref:`<AllowShortCaseExpressionOnASingleLine>`
1717+
Whether to merge a short switch labeled rule into a single line.
1718+
1719+
.. code-block:: java
1720+
1721+
true: false:
1722+
switch (a) { vs. switch (a) {
1723+
case 1 -> 1; case 1 ->
1724+
default -> 0; 1;
1725+
}; default ->
1726+
0;
1727+
};
1728+
16951729
.. _AllowShortCaseLabelsOnASingleLine:
16961730

16971731
**AllowShortCaseLabelsOnASingleLine** (``Boolean``) :versionbadge:`clang-format 3.6` :ref:`<AllowShortCaseLabelsOnASingleLine>`

clang/docs/ReleaseNotes.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -834,6 +834,9 @@ clang-format
834834
``BreakTemplateDeclarations``.
835835
- ``AlwaysBreakAfterReturnType`` is deprecated and renamed to
836836
``BreakAfterReturnType``.
837+
- Handles Java ``switch`` expressions.
838+
- Adds ``AllowShortCaseExpressionOnASingleLine`` option.
839+
- Adds ``AlignCaseArrows`` suboption to ``AlignConsecutiveShortCaseStatements``.
837840

838841
libclang
839842
--------

clang/include/clang/AST/OpenACCClause.h

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,44 @@ class OpenACCFirstPrivateClause final
313313
ArrayRef<Expr *> VarList, SourceLocation EndLoc);
314314
};
315315

316+
class OpenACCDevicePtrClause final
317+
: public OpenACCClauseWithVarList,
318+
public llvm::TrailingObjects<OpenACCDevicePtrClause, Expr *> {
319+
320+
OpenACCDevicePtrClause(SourceLocation BeginLoc, SourceLocation LParenLoc,
321+
ArrayRef<Expr *> VarList, SourceLocation EndLoc)
322+
: OpenACCClauseWithVarList(OpenACCClauseKind::DevicePtr, BeginLoc,
323+
LParenLoc, EndLoc) {
324+
std::uninitialized_copy(VarList.begin(), VarList.end(),
325+
getTrailingObjects<Expr *>());
326+
setExprs(MutableArrayRef(getTrailingObjects<Expr *>(), VarList.size()));
327+
}
328+
329+
public:
330+
static OpenACCDevicePtrClause *
331+
Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc,
332+
ArrayRef<Expr *> VarList, SourceLocation EndLoc);
333+
};
334+
335+
class OpenACCAttachClause final
336+
: public OpenACCClauseWithVarList,
337+
public llvm::TrailingObjects<OpenACCAttachClause, Expr *> {
338+
339+
OpenACCAttachClause(SourceLocation BeginLoc, SourceLocation LParenLoc,
340+
ArrayRef<Expr *> VarList, SourceLocation EndLoc)
341+
: OpenACCClauseWithVarList(OpenACCClauseKind::Attach, BeginLoc, LParenLoc,
342+
EndLoc) {
343+
std::uninitialized_copy(VarList.begin(), VarList.end(),
344+
getTrailingObjects<Expr *>());
345+
setExprs(MutableArrayRef(getTrailingObjects<Expr *>(), VarList.size()));
346+
}
347+
348+
public:
349+
static OpenACCAttachClause *
350+
Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc,
351+
ArrayRef<Expr *> VarList, SourceLocation EndLoc);
352+
};
353+
316354
class OpenACCNoCreateClause final
317355
: public OpenACCClauseWithVarList,
318356
public llvm::TrailingObjects<OpenACCNoCreateClause, Expr *> {

clang/include/clang/Basic/AttrDocs.td

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5663,11 +5663,12 @@ The ``preserve_none`` calling convention tries to preserve as few general
56635663
registers as possible. So all general registers are caller saved registers. It
56645664
also uses more general registers to pass arguments. This attribute doesn't
56655665
impact floating-point registers (XMMs/YMMs). Floating-point registers still
5666-
follow the c calling convention.
5666+
follow the c calling convention. ``preserve_none``'s ABI is still unstable, and
5667+
may be changed in the future.
56675668

56685669
- Only RSP and RBP are preserved by callee.
56695670

5670-
- Register RDI, RSI, RDX, RCX, R8, R9, R11, R12, R13, R14, R15 and RAX now can
5671+
- Register R12, R13, R14, R15, RDI, RSI, RDX, RCX, R8, R9, R11, and RAX now can
56715672
be used to pass function arguments.
56725673
}];
56735674
}

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12337,4 +12337,7 @@ def warn_acc_deprecated_alias_name
1233712337
: Warning<"OpenACC clause name '%0' is a deprecated clause name and is "
1233812338
"now an alias for '%1'">,
1233912339
InGroup<DiagGroup<"openacc-deprecated-clause-alias">>;
12340+
def err_acc_var_not_pointer_type
12341+
: Error<"expected pointer in '%0' clause, type is %1">;
12342+
def note_acc_expected_pointer_var : Note<"expected variable of pointer type">;
1234012343
} // end of sema component.

clang/include/clang/Basic/OpenACCClauses.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#define CLAUSE_ALIAS(ALIAS_NAME, CLAUSE_NAME)
2222
#endif
2323

24+
VISIT_CLAUSE(Attach)
2425
VISIT_CLAUSE(Copy)
2526
CLAUSE_ALIAS(PCopy, Copy)
2627
CLAUSE_ALIAS(PresentOrCopy, Copy)
@@ -34,6 +35,7 @@ VISIT_CLAUSE(Create)
3435
CLAUSE_ALIAS(PCreate, Create)
3536
CLAUSE_ALIAS(PresentOrCreate, Create)
3637
VISIT_CLAUSE(Default)
38+
VISIT_CLAUSE(DevicePtr)
3739
VISIT_CLAUSE(FirstPrivate)
3840
VISIT_CLAUSE(If)
3941
VISIT_CLAUSE(NoCreate)

clang/include/clang/Driver/Options.td

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3663,14 +3663,14 @@ defm rwpi : BoolFOption<"rwpi",
36633663
"Generate read-write position independent code (ARM only)">,
36643664
NegFlag<SetFalse, [], [ClangOption, FlangOption, CC1Option]>>;
36653665
def fplugin_EQ : Joined<["-"], "fplugin=">, Group<f_Group>,
3666-
Flags<[NoXarchOption]>, MetaVarName<"<dsopath>">,
3666+
Flags<[NoXarchOption, NoArgumentUnused]>, MetaVarName<"<dsopath>">,
36673667
HelpText<"Load the named plugin (dynamic shared object)">;
36683668
def fplugin_arg : Joined<["-"], "fplugin-arg-">,
3669-
MetaVarName<"<name>-<arg>">,
3669+
MetaVarName<"<name>-<arg>">, Flags<[NoArgumentUnused]>,
36703670
HelpText<"Pass <arg> to plugin <name>">;
36713671
def fpass_plugin_EQ : Joined<["-"], "fpass-plugin=">,
36723672
Group<f_Group>, Visibility<[ClangOption, CC1Option, FlangOption, FC1Option]>,
3673-
MetaVarName<"<dsopath>">,
3673+
MetaVarName<"<dsopath>">, Flags<[NoArgumentUnused]>,
36743674
HelpText<"Load pass plugin from a dynamic shared object file (only with new pass manager).">,
36753675
MarshallingInfoStringVector<CodeGenOpts<"PassPlugins">>;
36763676
defm tocdata : BoolOption<"m","tocdata",

0 commit comments

Comments
 (0)