Skip to content

Commit 5b2d196

Browse files
Merge branch 'llvm:main' into gh-101657
2 parents dfb2648 + 92ad039 commit 5b2d196

File tree

1,860 files changed

+102740
-49223
lines changed

Some content is hidden

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

1,860 files changed

+102740
-49223
lines changed

bolt/lib/Passes/Instrumentation.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,8 @@ static bool hasAArch64ExclusiveMemop(
109109
BinaryBasicBlock *BB = BBQueue.front().first;
110110
bool IsLoad = BBQueue.front().second;
111111
BBQueue.pop();
112-
if (Visited.find(BB) != Visited.end())
112+
if (!Visited.insert(BB).second)
113113
continue;
114-
Visited.insert(BB);
115114

116115
for (const MCInst &Inst : *BB) {
117116
// Two loads one after another - skip whole function
@@ -126,8 +125,7 @@ static bool hasAArch64ExclusiveMemop(
126125
if (BC.MIB->isAArch64ExclusiveLoad(Inst))
127126
IsLoad = true;
128127

129-
if (IsLoad && BBToSkip.find(BB) == BBToSkip.end()) {
130-
BBToSkip.insert(BB);
128+
if (IsLoad && BBToSkip.insert(BB).second) {
131129
if (opts::Verbosity >= 2) {
132130
outs() << "BOLT-INSTRUMENTER: skip BB " << BB->getName()
133131
<< " due to exclusive instruction in function "

bolt/tools/driver/llvm-bolt.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,9 +202,9 @@ int main(int argc, char **argv) {
202202

203203
ToolName = argv[0];
204204

205-
if (llvm::sys::path::filename(ToolName) == "perf2bolt")
205+
if (llvm::sys::path::filename(ToolName).starts_with("perf2bolt"))
206206
perf2boltMode(argc, argv);
207-
else if (llvm::sys::path::filename(ToolName) == "llvm-boltdiff")
207+
else if (llvm::sys::path::filename(ToolName).starts_with("llvm-boltdiff"))
208208
boltDiffMode(argc, argv);
209209
else
210210
boltMode(argc, argv);

clang-tools-extra/clang-doc/tool/ClangDocMain.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,8 +300,7 @@ Example usage for a project using a compile commands database:
300300
llvm::StringMap<std::vector<StringRef>> USRToBitcode;
301301
Executor->get()->getToolResults()->forEachResult(
302302
[&](StringRef Key, StringRef Value) {
303-
auto R = USRToBitcode.try_emplace(Key, std::vector<StringRef>());
304-
R.first->second.emplace_back(Value);
303+
USRToBitcode[Key].emplace_back(Value);
305304
});
306305

307306
// Collects all Infos according to their unique USR value. This map is added

clang-tools-extra/clang-tidy/ClangTidy.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,6 @@ ClangTidyASTConsumerFactory::createASTConsumer(
458458
if (!AnalyzerOptions.CheckersAndPackages.empty()) {
459459
setStaticAnalyzerCheckerOpts(Context.getOptions(), AnalyzerOptions);
460460
AnalyzerOptions.AnalysisDiagOpt = PD_NONE;
461-
AnalyzerOptions.eagerlyAssumeBinOpBifurcation = true;
462461
std::unique_ptr<ento::AnalysisASTConsumer> AnalysisConsumer =
463462
ento::CreateAnalysisConsumer(Compiler);
464463
AnalysisConsumer->AddDiagnosticConsumer(

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ void CrtpConstructorAccessibilityCheck::check(
165165

166166
WithFriendHintIfNeeded(
167167
diag(Ctor->getLocation(),
168-
"%0 contructor allows the CRTP to be %select{inherited "
168+
"%0 constructor allows the CRTP to be %select{inherited "
169169
"from|constructed}1 as a regular template class; consider making "
170170
"it private%select{| and declaring the derived class as friend}2")
171171
<< Access << IsPublic << NeedsFriend

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,9 @@ SizeofExpressionCheck::SizeofExpressionCheck(StringRef Name,
7070
Options.get("WarnOnSizeOfCompareToConstant", true)),
7171
WarnOnSizeOfPointerToAggregate(
7272
Options.get("WarnOnSizeOfPointerToAggregate", true)),
73-
WarnOnSizeOfPointer(Options.get("WarnOnSizeOfPointer", false)) {}
73+
WarnOnSizeOfPointer(Options.get("WarnOnSizeOfPointer", false)),
74+
WarnOnOffsetDividedBySizeOf(
75+
Options.get("WarnOnOffsetDividedBySizeOf", true)) {}
7476

7577
void SizeofExpressionCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
7678
Options.store(Opts, "WarnOnSizeOfConstant", WarnOnSizeOfConstant);
@@ -82,6 +84,8 @@ void SizeofExpressionCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
8284
Options.store(Opts, "WarnOnSizeOfPointerToAggregate",
8385
WarnOnSizeOfPointerToAggregate);
8486
Options.store(Opts, "WarnOnSizeOfPointer", WarnOnSizeOfPointer);
87+
Options.store(Opts, "WarnOnOffsetDividedBySizeOf",
88+
WarnOnOffsetDividedBySizeOf);
8589
}
8690

8791
void SizeofExpressionCheck::registerMatchers(MatchFinder *Finder) {
@@ -307,7 +311,8 @@ void SizeofExpressionCheck::registerMatchers(MatchFinder *Finder) {
307311
offsetOfExpr()))
308312
.bind("sizeof-in-ptr-arithmetic-scale-expr");
309313
const auto PtrArithmeticIntegerScaleExpr = binaryOperator(
310-
hasAnyOperatorName("*", "/"),
314+
WarnOnOffsetDividedBySizeOf ? binaryOperator(hasAnyOperatorName("*", "/"))
315+
: binaryOperator(hasOperatorName("*")),
311316
// sizeof(...) * sizeof(...) and sizeof(...) / sizeof(...) is handled
312317
// by this check on another path.
313318
hasOperands(expr(hasType(isInteger()), unless(SizeofLikeScaleExpr)),

clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class SizeofExpressionCheck : public ClangTidyCheck {
3131
const bool WarnOnSizeOfCompareToConstant;
3232
const bool WarnOnSizeOfPointerToAggregate;
3333
const bool WarnOnSizeOfPointer;
34+
const bool WarnOnOffsetDividedBySizeOf;
3435
};
3536

3637
} // namespace clang::tidy::bugprone

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,6 +1135,9 @@ StyleKind IdentifierNamingCheck::findStyleKind(
11351135
if (isa<TypeAliasDecl>(D) && NamingStyles[SK_TypeAlias])
11361136
return SK_TypeAlias;
11371137

1138+
if (isa<NamespaceAliasDecl>(D) && NamingStyles[SK_Namespace])
1139+
return SK_Namespace;
1140+
11381141
if (const auto *Decl = dyn_cast<NamespaceDecl>(D)) {
11391142
if (Decl->isAnonymousNamespace())
11401143
return SK_Invalid;

clang-tools-extra/clangd/AST.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,13 @@ getQualification(ASTContext &Context, const DeclContext *DestContext,
144144
// since we stored inner-most parent first.
145145
std::string Result;
146146
llvm::raw_string_ostream OS(Result);
147-
for (const auto *Parent : llvm::reverse(Parents))
147+
for (const auto *Parent : llvm::reverse(Parents)) {
148+
if (Parent != *Parents.rbegin() && Parent->isDependent() &&
149+
Parent->getAsRecordDecl() &&
150+
Parent->getAsRecordDecl()->getDescribedClassTemplate())
151+
OS << "template ";
148152
Parent->print(OS, Context.getPrintingPolicy());
153+
}
149154
return OS.str();
150155
}
151156

clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp

Lines changed: 44 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,28 @@ getFunctionSourceAfterReplacements(const FunctionDecl *FD,
128128
SM.getBufferData(SM.getMainFileID()), Replacements);
129129
if (!QualifiedFunc)
130130
return QualifiedFunc.takeError();
131-
return QualifiedFunc->substr(FuncBegin, FuncEnd - FuncBegin + 1);
131+
132+
std::string TemplatePrefix;
133+
if (auto *MD = llvm::dyn_cast<CXXMethodDecl>(FD)) {
134+
for (const CXXRecordDecl *Parent = MD->getParent(); Parent;
135+
Parent =
136+
llvm::dyn_cast_or_null<const CXXRecordDecl>(Parent->getParent())) {
137+
if (const TemplateParameterList *Params =
138+
Parent->getDescribedTemplateParams()) {
139+
std::string S;
140+
llvm::raw_string_ostream Stream(S);
141+
Params->print(Stream, FD->getASTContext());
142+
if (!S.empty())
143+
*S.rbegin() = '\n'; // Replace space with newline
144+
TemplatePrefix.insert(0, S);
145+
}
146+
}
147+
}
148+
149+
auto Source = QualifiedFunc->substr(FuncBegin, FuncEnd - FuncBegin + 1);
150+
if (!TemplatePrefix.empty())
151+
Source.insert(0, TemplatePrefix);
152+
return Source;
132153
}
133154

134155
// Returns replacements to delete tokens with kind `Kind` in the range
@@ -212,9 +233,13 @@ getFunctionSourceCode(const FunctionDecl *FD, const DeclContext *TargetContext,
212233
}
213234
}
214235
const NamedDecl *ND = Ref.Targets.front();
215-
const std::string Qualifier =
236+
std::string Qualifier =
216237
getQualification(AST, TargetContext,
217238
SM.getLocForStartOfFile(SM.getMainFileID()), ND);
239+
if (ND->getDeclContext()->isDependentContext() &&
240+
llvm::isa<TypeDecl>(ND)) {
241+
Qualifier.insert(0, "typename ");
242+
}
218243
if (auto Err = DeclarationCleanups.add(
219244
tooling::Replacement(SM, Ref.NameLoc, 0, Qualifier)))
220245
Errors = llvm::joinErrors(std::move(Errors), std::move(Err));
@@ -407,10 +432,23 @@ class DefineOutline : public Tweak {
407432
return !SameFile;
408433
}
409434

410-
// Bail out in templated classes, as it is hard to spell the class name,
411-
// i.e if the template parameter is unnamed.
412-
if (MD->getParent()->isTemplated())
413-
return false;
435+
for (const CXXRecordDecl *Parent = MD->getParent(); Parent;
436+
Parent =
437+
llvm::dyn_cast_or_null<const CXXRecordDecl>(Parent->getParent())) {
438+
if (const TemplateParameterList *Params =
439+
Parent->getDescribedTemplateParams()) {
440+
441+
// Class template member functions must be defined in the
442+
// same file.
443+
SameFile = true;
444+
445+
// Bail out if the template parameter is unnamed.
446+
for (NamedDecl *P : *Params) {
447+
if (!P->getIdentifier())
448+
return false;
449+
}
450+
}
451+
}
414452

415453
// The refactoring is meaningless for unnamed classes and namespaces,
416454
// unless we're outlining in the same file

0 commit comments

Comments
 (0)