Skip to content

Commit ea7e39a

Browse files
authored
Merge branch 'main' into jroelofs/gvn-remarks
2 parents 5c7a47a + d6e25c4 commit ea7e39a

File tree

804 files changed

+36050
-10639
lines changed

Some content is hidden

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

804 files changed

+36050
-10639
lines changed

bolt/lib/Profile/DataAggregator.cpp

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ FilterMemProfile("filter-mem-profile",
6161
cl::init(true),
6262
cl::cat(AggregatorCategory));
6363

64+
static cl::opt<bool> ParseMemProfile(
65+
"parse-mem-profile",
66+
cl::desc("enable memory profile parsing if it's present in the input data, "
67+
"on by default unless `--itrace` is set."),
68+
cl::init(true), cl::cat(AggregatorCategory));
69+
6470
static cl::opt<unsigned long long>
6571
FilterPID("pid",
6672
cl::desc("only use samples from process with specified PID"),
@@ -181,6 +187,10 @@ void DataAggregator::start() {
181187
"script -F pid,event,ip",
182188
/*Wait = */false);
183189
} else if (!opts::ITraceAggregation.empty()) {
190+
// Disable parsing memory profile from trace data, unless requested by user.
191+
if (!opts::ParseMemProfile.getNumOccurrences())
192+
opts::ParseMemProfile = false;
193+
184194
std::string ItracePerfScriptArgs = llvm::formatv(
185195
"script -F pid,brstack --itrace={0}", opts::ITraceAggregation);
186196
launchPerfProcess("branch events with itrace", MainEventsPPI,
@@ -191,12 +201,9 @@ void DataAggregator::start() {
191201
/*Wait = */ false);
192202
}
193203

194-
// Note: we launch script for mem events regardless of the option, as the
195-
// command fails fairly fast if mem events were not collected.
196-
launchPerfProcess("mem events",
197-
MemEventsPPI,
198-
"script -F pid,event,addr,ip",
199-
/*Wait = */false);
204+
if (opts::ParseMemProfile)
205+
launchPerfProcess("mem events", MemEventsPPI, "script -F pid,event,addr,ip",
206+
/*Wait = */ false);
200207

201208
launchPerfProcess("process events", MMapEventsPPI,
202209
"script --show-mmap-events --no-itrace",
@@ -217,7 +224,8 @@ void DataAggregator::abort() {
217224
sys::Wait(TaskEventsPPI.PI, 1, &Error);
218225
sys::Wait(MMapEventsPPI.PI, 1, &Error);
219226
sys::Wait(MainEventsPPI.PI, 1, &Error);
220-
sys::Wait(MemEventsPPI.PI, 1, &Error);
227+
if (opts::ParseMemProfile)
228+
sys::Wait(MemEventsPPI.PI, 1, &Error);
221229

222230
deleteTempFiles();
223231

@@ -506,7 +514,8 @@ Error DataAggregator::preprocessProfile(BinaryContext &BC) {
506514
errs() << "PERF2BOLT: failed to parse samples\n";
507515

508516
// Special handling for memory events
509-
if (!prepareToParse("mem events", MemEventsPPI, MemEventsErrorCallback))
517+
if (opts::ParseMemProfile &&
518+
!prepareToParse("mem events", MemEventsPPI, MemEventsErrorCallback))
510519
if (const std::error_code EC = parseMemEvents())
511520
errs() << "PERF2BOLT: failed to parse memory events: " << EC.message()
512521
<< '\n';

clang-tools-extra/clang-doc/BitcodeReader.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,8 @@ static llvm::Error decodeRecord(const Record &R, AccessSpecifier &Field,
5454
case AS_none:
5555
Field = (AccessSpecifier)R[0];
5656
return llvm::Error::success();
57-
default:
58-
return llvm::createStringError(llvm::inconvertibleErrorCode(),
59-
"invalid value for AccessSpecifier");
6057
}
58+
llvm_unreachable("invalid value for AccessSpecifier");
6159
}
6260

6361
static llvm::Error decodeRecord(const Record &R, TagTypeKind &Field,

clang-tools-extra/clang-doc/BitcodeWriter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,7 @@ bool ClangDocBitcodeWriter::dispatchInfoForWrite(Info *I) {
664664
case InfoType::IT_typedef:
665665
emitBlock(*static_cast<clang::doc::TypedefInfo *>(I));
666666
break;
667-
default:
667+
case InfoType::IT_default:
668668
llvm::errs() << "Unexpected info, unable to write.\n";
669669
return true;
670670
}

clang-tools-extra/clang-doc/Representation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ mergeInfos(std::vector<std::unique_ptr<Info>> &Values) {
143143
return reduce<FunctionInfo>(Values);
144144
case InfoType::IT_typedef:
145145
return reduce<TypedefInfo>(Values);
146-
default:
146+
case InfoType::IT_default:
147147
return llvm::createStringError(llvm::inconvertibleErrorCode(),
148148
"unexpected info type");
149149
}

clang-tools-extra/clang-doc/Serialize.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,8 @@ std::string serialize(std::unique_ptr<Info> &I) {
388388
return serialize(*static_cast<EnumInfo *>(I.get()));
389389
case InfoType::IT_function:
390390
return serialize(*static_cast<FunctionInfo *>(I.get()));
391-
default:
391+
case InfoType::IT_typedef:
392+
case InfoType::IT_default:
392393
return "";
393394
}
394395
}
@@ -525,9 +526,13 @@ static std::unique_ptr<Info> makeAndInsertIntoParent(ChildType Child) {
525526
InsertChild(ParentRec->Children, std::forward<ChildType>(Child));
526527
return ParentRec;
527528
}
528-
default:
529-
llvm_unreachable("Invalid reference type for parent namespace");
529+
case InfoType::IT_default:
530+
case InfoType::IT_enum:
531+
case InfoType::IT_function:
532+
case InfoType::IT_typedef:
533+
break;
530534
}
535+
llvm_unreachable("Invalid reference type for parent namespace");
531536
}
532537

533538
// There are two uses for this function.

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

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -702,17 +702,16 @@ void NotNullTerminatedResultCheck::registerMatchers(MatchFinder *Finder) {
702702
return hasArgument(
703703
CC.LengthPos,
704704
allOf(
705-
anyOf(
706-
ignoringImpCasts(integerLiteral().bind(WrongLengthExprName)),
707-
allOf(unless(hasDefinition(SizeOfCharExpr)),
708-
allOf(CC.WithIncrease
709-
? ignoringImpCasts(hasDefinition(HasIncOp))
710-
: ignoringImpCasts(allOf(
711-
unless(hasDefinition(HasIncOp)),
712-
anyOf(hasDefinition(binaryOperator().bind(
713-
UnknownLengthName)),
714-
hasDefinition(anything())))),
715-
AnyOfWrongLengthInit))),
705+
anyOf(ignoringImpCasts(integerLiteral().bind(WrongLengthExprName)),
706+
allOf(unless(hasDefinition(SizeOfCharExpr)),
707+
allOf(CC.WithIncrease
708+
? ignoringImpCasts(hasDefinition(HasIncOp))
709+
: ignoringImpCasts(
710+
allOf(unless(hasDefinition(HasIncOp)),
711+
hasDefinition(optionally(
712+
binaryOperator().bind(
713+
UnknownLengthName))))),
714+
AnyOfWrongLengthInit))),
716715
expr().bind(LengthExprName)));
717716
};
718717

clang-tools-extra/clang-tidy/hicpp/ExceptionBaseclassCheck.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,12 @@ void ExceptionBaseclassCheck::registerMatchers(MatchFinder *Finder) {
2424
isSameOrDerivedFrom(hasName("::std::exception")))))))))),
2525
// This condition is always true, but will bind to the
2626
// template value if the thrown type is templated.
27-
anyOf(has(expr(
28-
hasType(substTemplateTypeParmType().bind("templ_type")))),
29-
anything()),
27+
optionally(has(
28+
expr(hasType(substTemplateTypeParmType().bind("templ_type"))))),
3029
// Bind to the declaration of the type of the value that
31-
// is thrown. 'anything()' is necessary to always succeed
32-
// in the 'eachOf' because builtin types are not
33-
// 'namedDecl'.
34-
eachOf(has(expr(hasType(namedDecl().bind("decl")))), anything()))
30+
// is thrown. 'optionally' is necessary because builtin types
31+
// are not 'namedDecl'.
32+
optionally(has(expr(hasType(namedDecl().bind("decl"))))))
3533
.bind("bad_throw"),
3634
this);
3735
}

clang-tools-extra/clang-tidy/misc/StaticAssertCheck.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ void StaticAssertCheck::registerMatchers(MatchFinder *Finder) {
3838
binaryOperator(
3939
hasAnyOperatorName("&&", "=="),
4040
hasEitherOperand(ignoringImpCasts(stringLiteral().bind("assertMSG"))),
41-
anyOf(binaryOperator(hasEitherOperand(IsAlwaysFalseWithCast)),
42-
anything()))
41+
optionally(binaryOperator(hasEitherOperand(IsAlwaysFalseWithCast))))
4342
.bind("assertExprRoot"),
4443
IsAlwaysFalse);
4544
auto NonConstexprFunctionCall =
@@ -52,12 +51,10 @@ void StaticAssertCheck::registerMatchers(MatchFinder *Finder) {
5251
auto NonConstexprCode =
5352
expr(anyOf(NonConstexprFunctionCall, NonConstexprVariableReference));
5453
auto AssertCondition =
55-
expr(
56-
anyOf(expr(ignoringParenCasts(anyOf(
57-
AssertExprRoot, unaryOperator(hasUnaryOperand(
58-
ignoringParenCasts(AssertExprRoot)))))),
59-
anything()),
60-
unless(NonConstexprCode), unless(hasDescendant(NonConstexprCode)))
54+
expr(optionally(expr(ignoringParenCasts(anyOf(
55+
AssertExprRoot, unaryOperator(hasUnaryOperand(
56+
ignoringParenCasts(AssertExprRoot))))))),
57+
unless(NonConstexprCode), unless(hasDescendant(NonConstexprCode)))
6158
.bind("condition");
6259
auto Condition =
6360
anyOf(ignoringParenImpCasts(callExpr(

clang-tools-extra/clang-tidy/modernize/UseBoolLiteralsCheck.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,12 @@ void UseBoolLiteralsCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
2626

2727
void UseBoolLiteralsCheck::registerMatchers(MatchFinder *Finder) {
2828
Finder->addMatcher(
29-
traverse(
30-
TK_AsIs,
31-
implicitCastExpr(
32-
has(ignoringParenImpCasts(integerLiteral().bind("literal"))),
33-
hasImplicitDestinationType(qualType(booleanType())),
34-
unless(isInTemplateInstantiation()),
35-
anyOf(hasParent(explicitCastExpr().bind("cast")), anything()))),
29+
traverse(TK_AsIs,
30+
implicitCastExpr(
31+
has(ignoringParenImpCasts(integerLiteral().bind("literal"))),
32+
hasImplicitDestinationType(qualType(booleanType())),
33+
unless(isInTemplateInstantiation()),
34+
optionally(hasParent(explicitCastExpr().bind("cast"))))),
3635
this);
3736

3837
Finder->addMatcher(

clang-tools-extra/clang-tidy/modernize/UseIntegerSignComparisonCheck.cpp

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,28 +39,21 @@ intCastExpression(bool IsSigned,
3939
// std::cmp_{} functions trigger a compile-time error if either LHS or RHS
4040
// is a non-integer type, char, enum or bool
4141
// (unsigned char/ signed char are Ok and can be used).
42-
const auto HasIntegerType = hasType(hasCanonicalType(qualType(
42+
auto IntTypeExpr = expr(hasType(hasCanonicalType(qualType(
4343
isInteger(), IsSigned ? isSignedInteger() : isUnsignedInteger(),
44-
unless(isActualChar()), unless(booleanType()), unless(enumType()))));
45-
46-
const auto IntTypeExpr = expr(HasIntegerType);
44+
unless(isActualChar()), unless(booleanType()), unless(enumType())))));
4745

4846
const auto ImplicitCastExpr =
4947
CastBindName.empty() ? implicitCastExpr(hasSourceExpression(IntTypeExpr))
5048
: implicitCastExpr(hasSourceExpression(IntTypeExpr))
5149
.bind(CastBindName);
5250

53-
const auto ExplicitCastExpr =
54-
anyOf(explicitCastExpr(has(ImplicitCastExpr)),
55-
ignoringImpCasts(explicitCastExpr(has(ImplicitCastExpr))));
56-
57-
// Match function calls or variable references not directly wrapped by an
58-
// implicit cast
59-
const auto CallIntExpr = CastBindName.empty()
60-
? callExpr(HasIntegerType)
61-
: callExpr(HasIntegerType).bind(CastBindName);
51+
const auto CStyleCastExpr = cStyleCastExpr(has(ImplicitCastExpr));
52+
const auto StaticCastExpr = cxxStaticCastExpr(has(ImplicitCastExpr));
53+
const auto FunctionalCastExpr = cxxFunctionalCastExpr(has(ImplicitCastExpr));
6254

63-
return expr(anyOf(ImplicitCastExpr, ExplicitCastExpr, CallIntExpr));
55+
return expr(anyOf(ImplicitCastExpr, CStyleCastExpr, StaticCastExpr,
56+
FunctionalCastExpr));
6457
}
6558

6659
static StringRef parseOpCode(BinaryOperator::Opcode Code) {

0 commit comments

Comments
 (0)