Skip to content

Commit c0bf19d

Browse files
committed
Merge remote-tracking branch 'origin/main' into vplan-to-uniform-transforms
2 parents cd4b3bf + ad6bb70 commit c0bf19d

File tree

145 files changed

+3203
-1336
lines changed

Some content is hidden

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

145 files changed

+3203
-1336
lines changed

clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,7 @@ bool MagicNumbersCheck::isIgnoredValue(const IntegerLiteral *Literal) const {
202202
if (IgnorePowersOf2IntegerValues && IntValue.isPowerOf2())
203203
return true;
204204

205-
return std::binary_search(IgnoredIntegerValues.begin(),
206-
IgnoredIntegerValues.end(), Value);
205+
return llvm::binary_search(IgnoredIntegerValues, Value);
207206
}
208207

209208
bool MagicNumbersCheck::isIgnoredValue(const FloatingLiteral *Literal) const {
@@ -213,14 +212,12 @@ bool MagicNumbersCheck::isIgnoredValue(const FloatingLiteral *Literal) const {
213212

214213
if (&FloatValue.getSemantics() == &llvm::APFloat::IEEEsingle()) {
215214
const float Value = FloatValue.convertToFloat();
216-
return std::binary_search(IgnoredFloatingPointValues.begin(),
217-
IgnoredFloatingPointValues.end(), Value);
215+
return llvm::binary_search(IgnoredFloatingPointValues, Value);
218216
}
219217

220218
if (&FloatValue.getSemantics() == &llvm::APFloat::IEEEdouble()) {
221219
const double Value = FloatValue.convertToDouble();
222-
return std::binary_search(IgnoredDoublePointValues.begin(),
223-
IgnoredDoublePointValues.end(), Value);
220+
return llvm::binary_search(IgnoredDoublePointValues, Value);
224221
}
225222

226223
return false;

clang/docs/ReleaseNotes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,8 @@ New Compiler Flags
313313

314314
- New option ``-ftime-report-json`` added which outputs the same timing data as ``-ftime-report`` but formatted as JSON.
315315

316+
- New option ``-Wnrvo`` added and disabled by default to warn about missed NRVO opportunites.
317+
316318
Deprecated Compiler Flags
317319
-------------------------
318320

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12445,6 +12445,10 @@ def warn_zero_as_null_pointer_constant : Warning<
1244512445
"zero as null pointer constant">,
1244612446
InGroup<DiagGroup<"zero-as-null-pointer-constant">>, DefaultIgnore;
1244712447

12448+
def warn_not_eliding_copy_on_return : Warning<
12449+
"not eliding copy on return">,
12450+
InGroup<DiagGroup<"nrvo">>, DefaultIgnore;
12451+
1244812452
def err_nullability_cs_multilevel : Error<
1244912453
"nullability keyword %0 cannot be applied to multi-level pointer type %1">;
1245012454
def note_nullability_type_specifier : Note<

clang/include/clang/Basic/JsonSupport.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ inline void printSourceLocationAsJson(raw_ostream &Out, SourceLocation Loc,
106106
return llvm::is_contained(ForbiddenChars, Char);
107107
});
108108
// Handle windows-specific path delimiters.
109-
std::replace(filename.begin(), filename.end(), '\\', '/');
109+
llvm::replace(filename, '\\', '/');
110110
}
111111
Out << "\"line\": " << PLoc.getLine()
112112
<< ", \"column\": " << PLoc.getColumn()

clang/include/clang/CIR/Dialect/IR/CIROps.td

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -971,6 +971,52 @@ def SwitchOp : CIR_Op<"switch",
971971
}];
972972
}
973973

974+
//===----------------------------------------------------------------------===//
975+
// SwitchFlatOp
976+
//===----------------------------------------------------------------------===//
977+
978+
def SwitchFlatOp : CIR_Op<"switch.flat", [AttrSizedOperandSegments,
979+
Terminator]> {
980+
981+
let description = [{
982+
The `cir.switch.flat` operation is a region-less and simplified
983+
version of the `cir.switch`.
984+
Its representation is closer to LLVM IR dialect
985+
than the C/C++ language feature.
986+
}];
987+
988+
let arguments = (ins
989+
CIR_IntType:$condition,
990+
Variadic<AnyType>:$defaultOperands,
991+
VariadicOfVariadic<AnyType, "case_operand_segments">:$caseOperands,
992+
ArrayAttr:$caseValues,
993+
DenseI32ArrayAttr:$case_operand_segments
994+
);
995+
996+
let successors = (successor
997+
AnySuccessor:$defaultDestination,
998+
VariadicSuccessor<AnySuccessor>:$caseDestinations
999+
);
1000+
1001+
let assemblyFormat = [{
1002+
$condition `:` type($condition) `,`
1003+
$defaultDestination (`(` $defaultOperands^ `:` type($defaultOperands) `)`)?
1004+
custom<SwitchFlatOpCases>(ref(type($condition)), $caseValues,
1005+
$caseDestinations, $caseOperands,
1006+
type($caseOperands))
1007+
attr-dict
1008+
}];
1009+
1010+
let builders = [
1011+
OpBuilder<(ins "mlir::Value":$condition,
1012+
"mlir::Block *":$defaultDestination,
1013+
"mlir::ValueRange":$defaultOperands,
1014+
CArg<"llvm::ArrayRef<llvm::APInt>", "{}">:$caseValues,
1015+
CArg<"mlir::BlockRange", "{}">:$caseDestinations,
1016+
CArg<"llvm::ArrayRef<mlir::ValueRange>", "{}">:$caseOperands)>
1017+
];
1018+
}
1019+
9741020
//===----------------------------------------------------------------------===//
9751021
// BrOp
9761022
//===----------------------------------------------------------------------===//

clang/include/clang/Sema/Overload.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,8 @@ class Sema;
435435

436436
// A function pointer type can be resolved to a member function type,
437437
// which is still an identity conversion.
438-
if (auto *N = T->getAs<MemberPointerType>())
438+
if (auto *N = T->getAs<MemberPointerType>();
439+
N && N->isMemberFunctionPointer())
439440
T = C.getDecayedType(N->getPointeeType());
440441
return T;
441442
};

clang/lib/Basic/Diagnostic.cpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -533,24 +533,28 @@ void WarningsSpecialCaseList::processSections(DiagnosticsEngine &Diags) {
533533
// Drop the default section introduced by special case list, we only support
534534
// exact diagnostic group names.
535535
// FIXME: We should make this configurable in the parser instead.
536-
Sections.erase("*");
536+
// FIXME: C++20 can use std::erase_if(Sections, [](Section &sec) { return
537+
// sec.SectionStr == "*"; });
538+
Sections.erase(
539+
std::remove_if(Sections.begin(), Sections.end(),
540+
[](Section &sec) { return sec.SectionStr == "*"; }),
541+
Sections.end());
537542
// Make sure we iterate sections by their line numbers.
538-
std::vector<std::pair<unsigned, const llvm::StringMapEntry<Section> *>>
539-
LineAndSectionEntry;
543+
std::vector<std::pair<unsigned, const Section *>> LineAndSectionEntry;
540544
LineAndSectionEntry.reserve(Sections.size());
541545
for (const auto &Entry : Sections) {
542-
StringRef DiagName = Entry.getKey();
546+
StringRef DiagName = Entry.SectionStr;
543547
// Each section has a matcher with that section's name, attached to that
544548
// line.
545-
const auto &DiagSectionMatcher = Entry.getValue().SectionMatcher;
549+
const auto &DiagSectionMatcher = Entry.SectionMatcher;
546550
unsigned DiagLine = DiagSectionMatcher->Globs.at(DiagName).second;
547551
LineAndSectionEntry.emplace_back(DiagLine, &Entry);
548552
}
549553
llvm::sort(LineAndSectionEntry);
550554
static constexpr auto WarningFlavor = clang::diag::Flavor::WarningOrError;
551555
for (const auto &[_, SectionEntry] : LineAndSectionEntry) {
552556
SmallVector<diag::kind> GroupDiags;
553-
StringRef DiagGroup = SectionEntry->getKey();
557+
StringRef DiagGroup = SectionEntry->SectionStr;
554558
if (Diags.getDiagnosticIDs()->getDiagnosticsInGroup(
555559
WarningFlavor, DiagGroup, GroupDiags)) {
556560
StringRef Suggestion =
@@ -563,7 +567,7 @@ void WarningsSpecialCaseList::processSections(DiagnosticsEngine &Diags) {
563567
for (diag::kind Diag : GroupDiags)
564568
// We're intentionally overwriting any previous mappings here to make sure
565569
// latest one takes precedence.
566-
DiagToSection[Diag] = &SectionEntry->getValue();
570+
DiagToSection[Diag] = SectionEntry;
567571
}
568572
}
569573

clang/lib/Basic/ProfileList.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class ProfileSpecialCaseList : public llvm::SpecialCaseList {
3737

3838
bool hasPrefix(StringRef Prefix) const {
3939
for (const auto &It : Sections)
40-
if (It.second.Entries.count(Prefix) > 0)
40+
if (It.Entries.count(Prefix) > 0)
4141
return true;
4242
return false;
4343
}

clang/lib/Basic/SanitizerSpecialCaseList.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ SanitizerSpecialCaseList::createOrDie(const std::vector<std::string> &Paths,
3737
}
3838

3939
void SanitizerSpecialCaseList::createSanitizerSections() {
40-
for (auto &It : Sections) {
41-
auto &S = It.second;
40+
for (auto &S : Sections) {
4241
SanitizerMask Mask;
4342

4443
#define SANITIZER(NAME, ID) \

clang/lib/Basic/Targets/AMDGPU.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ void AMDGPUTargetInfo::getTargetDefines(const LangOptions &Opts,
310310
// e.g. gfx10-1-generic -> gfx10_1_generic
311311
if (GPUKind >= llvm::AMDGPU::GK_AMDGCN_GENERIC_FIRST &&
312312
GPUKind <= llvm::AMDGPU::GK_AMDGCN_GENERIC_LAST) {
313-
std::replace(CanonName.begin(), CanonName.end(), '-', '_');
313+
llvm::replace(CanonName, '-', '_');
314314
}
315315

316316
Builder.defineMacro(Twine("__") + Twine(CanonName) + Twine("__"));
@@ -329,7 +329,7 @@ void AMDGPUTargetInfo::getTargetDefines(const LangOptions &Opts,
329329
auto Loc = OffloadArchFeatures.find(F);
330330
if (Loc != OffloadArchFeatures.end()) {
331331
std::string NewF = F.str();
332-
std::replace(NewF.begin(), NewF.end(), '-', '_');
332+
llvm::replace(NewF, '-', '_');
333333
Builder.defineMacro(Twine("__amdgcn_feature_") + Twine(NewF) +
334334
Twine("__"),
335335
Loc->second ? "1" : "0");

0 commit comments

Comments
 (0)