Skip to content

Commit e202a21

Browse files
authored
Merge branch 'main' into fastmathflag-complex-angle
2 parents b5d3e0b + 6e934b7 commit e202a21

File tree

559 files changed

+20537
-9472
lines changed

Some content is hidden

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

559 files changed

+20537
-9472
lines changed

bolt/lib/Rewrite/RewriteInstance.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2306,9 +2306,13 @@ void RewriteInstance::processRelocations() {
23062306
return;
23072307

23082308
for (const SectionRef &Section : InputFile->sections()) {
2309-
if (cantFail(Section.getRelocatedSection()) != InputFile->section_end() &&
2310-
!BinarySection(*BC, Section).isAllocatable())
2311-
readRelocations(Section);
2309+
section_iterator SecIter = cantFail(Section.getRelocatedSection());
2310+
if (SecIter == InputFile->section_end())
2311+
continue;
2312+
if (BinarySection(*BC, Section).isAllocatable())
2313+
continue;
2314+
2315+
readRelocations(Section);
23122316
}
23132317

23142318
if (NumFailedRelocations)
@@ -4300,18 +4304,17 @@ RewriteInstance::getOutputSections(ELFObjectFile<ELFT> *File,
43004304
for (auto &SectionKV : OutputSections) {
43014305
ELFShdrTy &Section = SectionKV.second;
43024306

4303-
// Ignore TLS sections as they don't take any space in the file.
4307+
// Ignore NOBITS sections as they don't take any space in the file.
43044308
if (Section.sh_type == ELF::SHT_NOBITS)
43054309
continue;
43064310

43074311
// Note that address continuity is not guaranteed as sections could be
43084312
// placed in different loadable segments.
43094313
if (PrevSection &&
43104314
PrevSection->sh_offset + PrevSection->sh_size > Section.sh_offset) {
4311-
if (opts::Verbosity > 1) {
4315+
if (opts::Verbosity > 1)
43124316
BC->outs() << "BOLT-INFO: adjusting size for section "
43134317
<< PrevBinSec->getOutputName() << '\n';
4314-
}
43154318
PrevSection->sh_size = Section.sh_offset - PrevSection->sh_offset;
43164319
}
43174320

clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -169,14 +169,14 @@ class RenamerClangTidyCheckPPCallbacks : public PPCallbacks {
169169
return;
170170
if (SM.isWrittenInCommandLineFile(MacroNameTok.getLocation()))
171171
return;
172-
Check->checkMacro(SM, MacroNameTok, Info);
172+
Check->checkMacro(MacroNameTok, Info, SM);
173173
}
174174

175175
/// MacroExpands calls expandMacro for macros in the main file
176176
void MacroExpands(const Token &MacroNameTok, const MacroDefinition &MD,
177177
SourceRange /*Range*/,
178178
const MacroArgs * /*Args*/) override {
179-
Check->expandMacro(MacroNameTok, MD.getMacroInfo());
179+
Check->expandMacro(MacroNameTok, MD.getMacroInfo(), SM);
180180
}
181181

182182
private:
@@ -187,7 +187,7 @@ class RenamerClangTidyCheckPPCallbacks : public PPCallbacks {
187187
class RenamerClangTidyVisitor
188188
: public RecursiveASTVisitor<RenamerClangTidyVisitor> {
189189
public:
190-
RenamerClangTidyVisitor(RenamerClangTidyCheck *Check, const SourceManager *SM,
190+
RenamerClangTidyVisitor(RenamerClangTidyCheck *Check, const SourceManager &SM,
191191
bool AggressiveDependentMemberLookup)
192192
: Check(Check), SM(SM),
193193
AggressiveDependentMemberLookup(AggressiveDependentMemberLookup) {}
@@ -258,7 +258,7 @@ class RenamerClangTidyVisitor
258258
// Fix overridden methods
259259
if (const auto *Method = dyn_cast<CXXMethodDecl>(Decl)) {
260260
if (const CXXMethodDecl *Overridden = getOverrideMethod(Method)) {
261-
Check->addUsage(Overridden, Method->getLocation());
261+
Check->addUsage(Overridden, Method->getLocation(), SM);
262262
return true; // Don't try to add the actual decl as a Failure.
263263
}
264264
}
@@ -268,7 +268,7 @@ class RenamerClangTidyVisitor
268268
if (isa<ClassTemplateSpecializationDecl>(Decl))
269269
return true;
270270

271-
Check->checkNamedDecl(Decl, *SM);
271+
Check->checkNamedDecl(Decl, SM);
272272
return true;
273273
}
274274

@@ -385,7 +385,7 @@ class RenamerClangTidyVisitor
385385

386386
private:
387387
RenamerClangTidyCheck *Check;
388-
const SourceManager *SM;
388+
const SourceManager &SM;
389389
const bool AggressiveDependentMemberLookup;
390390
};
391391

@@ -415,7 +415,7 @@ void RenamerClangTidyCheck::registerPPCallbacks(
415415

416416
void RenamerClangTidyCheck::addUsage(
417417
const RenamerClangTidyCheck::NamingCheckId &Decl, SourceRange Range,
418-
const SourceManager *SourceMgr) {
418+
const SourceManager &SourceMgr) {
419419
// Do nothing if the provided range is invalid.
420420
if (Range.isInvalid())
421421
return;
@@ -425,8 +425,7 @@ void RenamerClangTidyCheck::addUsage(
425425
// spelling location to different source locations, and we only want to fix
426426
// the token once, before it is expanded by the macro.
427427
SourceLocation FixLocation = Range.getBegin();
428-
if (SourceMgr)
429-
FixLocation = SourceMgr->getSpellingLoc(FixLocation);
428+
FixLocation = SourceMgr.getSpellingLoc(FixLocation);
430429
if (FixLocation.isInvalid())
431430
return;
432431

@@ -440,15 +439,15 @@ void RenamerClangTidyCheck::addUsage(
440439
if (!Failure.shouldFix())
441440
return;
442441

443-
if (SourceMgr && SourceMgr->isWrittenInScratchSpace(FixLocation))
442+
if (SourceMgr.isWrittenInScratchSpace(FixLocation))
444443
Failure.FixStatus = RenamerClangTidyCheck::ShouldFixStatus::InsideMacro;
445444

446-
if (!utils::rangeCanBeFixed(Range, SourceMgr))
445+
if (!utils::rangeCanBeFixed(Range, &SourceMgr))
447446
Failure.FixStatus = RenamerClangTidyCheck::ShouldFixStatus::InsideMacro;
448447
}
449448

450449
void RenamerClangTidyCheck::addUsage(const NamedDecl *Decl, SourceRange Range,
451-
const SourceManager *SourceMgr) {
450+
const SourceManager &SourceMgr) {
452451
// Don't keep track for non-identifier names.
453452
auto *II = Decl->getIdentifier();
454453
if (!II)
@@ -489,18 +488,24 @@ void RenamerClangTidyCheck::checkNamedDecl(const NamedDecl *Decl,
489488
}
490489

491490
Failure.Info = std::move(Info);
492-
addUsage(Decl, Range, &SourceMgr);
491+
addUsage(Decl, Range, SourceMgr);
493492
}
494493

495494
void RenamerClangTidyCheck::check(const MatchFinder::MatchResult &Result) {
496-
RenamerClangTidyVisitor Visitor(this, Result.SourceManager,
495+
if (!Result.SourceManager) {
496+
// In principle SourceManager is not null but going only by the definition
497+
// of MatchResult it must be handled. Cannot rename anything without a
498+
// SourceManager.
499+
return;
500+
}
501+
RenamerClangTidyVisitor Visitor(this, *Result.SourceManager,
497502
AggressiveDependentMemberLookup);
498503
Visitor.TraverseAST(*Result.Context);
499504
}
500505

501-
void RenamerClangTidyCheck::checkMacro(const SourceManager &SourceMgr,
502-
const Token &MacroNameTok,
503-
const MacroInfo *MI) {
506+
void RenamerClangTidyCheck::checkMacro(const Token &MacroNameTok,
507+
const MacroInfo *MI,
508+
const SourceManager &SourceMgr) {
504509
std::optional<FailureInfo> MaybeFailure =
505510
getMacroFailureInfo(MacroNameTok, SourceMgr);
506511
if (!MaybeFailure)
@@ -515,11 +520,12 @@ void RenamerClangTidyCheck::checkMacro(const SourceManager &SourceMgr,
515520
Failure.FixStatus = ShouldFixStatus::FixInvalidIdentifier;
516521

517522
Failure.Info = std::move(Info);
518-
addUsage(ID, Range);
523+
addUsage(ID, Range, SourceMgr);
519524
}
520525

521526
void RenamerClangTidyCheck::expandMacro(const Token &MacroNameTok,
522-
const MacroInfo *MI) {
527+
const MacroInfo *MI,
528+
const SourceManager &SourceMgr) {
523529
StringRef Name = MacroNameTok.getIdentifierInfo()->getName();
524530
NamingCheckId ID(MI->getDefinitionLoc(), Name);
525531

@@ -528,7 +534,7 @@ void RenamerClangTidyCheck::expandMacro(const Token &MacroNameTok,
528534
return;
529535

530536
SourceRange Range(MacroNameTok.getLocation(), MacroNameTok.getEndLoc());
531-
addUsage(ID, Range);
537+
addUsage(ID, Range, SourceMgr);
532538
}
533539

534540
static std::string

clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,18 +108,19 @@ class RenamerClangTidyCheck : public ClangTidyCheck {
108108
llvm::DenseMap<NamingCheckId, NamingCheckFailure>;
109109

110110
/// Check Macros for style violations.
111-
void checkMacro(const SourceManager &SourceMgr, const Token &MacroNameTok,
112-
const MacroInfo *MI);
111+
void checkMacro(const Token &MacroNameTok, const MacroInfo *MI,
112+
const SourceManager &SourceMgr);
113113

114114
/// Add a usage of a macro if it already has a violation.
115-
void expandMacro(const Token &MacroNameTok, const MacroInfo *MI);
115+
void expandMacro(const Token &MacroNameTok, const MacroInfo *MI,
116+
const SourceManager &SourceMgr);
116117

117118
void addUsage(const RenamerClangTidyCheck::NamingCheckId &Decl,
118-
SourceRange Range, const SourceManager *SourceMgr = nullptr);
119+
SourceRange Range, const SourceManager &SourceMgr);
119120

120121
/// Convenience method when the usage to be added is a NamedDecl.
121122
void addUsage(const NamedDecl *Decl, SourceRange Range,
122-
const SourceManager *SourceMgr = nullptr);
123+
const SourceManager &SourceMgr);
123124

124125
void checkNamedDecl(const NamedDecl *Decl, const SourceManager &SourceMgr);
125126

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ Improvements to clang-tidy
100100
- Improved :program:`run-clang-tidy.py` script. Added argument `-source-filter`
101101
to filter source files from the compilation database, via a RegEx. In a
102102
similar fashion to what `-header-filter` does for header files.
103+
- Improved :program:`check_clang_tidy.py` script. Added argument `-export-fixes`
104+
to aid in clang-tidy and test development.
103105

104106
New checks
105107
^^^^^^^^^^

clang-tools-extra/test/clang-tidy/check_clang_tidy.py

Lines changed: 55 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,43 @@
88
#
99
# ===------------------------------------------------------------------------===#
1010

11-
r"""
11+
"""
1212
ClangTidy Test Helper
1313
=====================
1414
15-
This script runs clang-tidy in fix mode and verify fixes, messages or both.
15+
This script is used to simplify writing, running, and debugging tests compatible
16+
with llvm-lit. By default it runs clang-tidy in fix mode and uses FileCheck to
17+
verify messages and/or fixes.
18+
19+
For debugging, with --export-fixes, the tool simply exports fixes to a provided
20+
file and does not run FileCheck.
1621
17-
Usage:
18-
check_clang_tidy.py [-resource-dir=<resource-dir>] \
19-
[-assume-filename=<file-with-source-extension>] \
20-
[-check-suffix=<comma-separated-file-check-suffixes>] \
21-
[-check-suffixes=<comma-separated-file-check-suffixes>] \
22-
[-std=c++(98|11|14|17|20)[-or-later]] \
23-
<source-file> <check-name> <temp-file> \
24-
-- [optional clang-tidy arguments]
22+
Extra arguments, those after the first -- if any, are passed to either
23+
clang-tidy or clang:
24+
* Arguments between the first -- and second -- are clang-tidy arguments.
25+
* May be only whitespace if there are no clang-tidy arguments.
26+
* clang-tidy's --config would go here.
27+
* Arguments after the second -- are clang arguments
28+
29+
Examples
30+
--------
2531
26-
Example:
2732
// RUN: %check_clang_tidy %s llvm-include-order %t -- -- -isystem %S/Inputs
2833
29-
Notes:
34+
or
35+
36+
// RUN: %check_clang_tidy %s llvm-include-order --export-fixes=fixes.yaml %t -std=c++20
37+
38+
Notes
39+
-----
3040
-std=c++(98|11|14|17|20)-or-later:
3141
This flag will cause multiple runs within the same check_clang_tidy
3242
execution. Make sure you don't have shared state across these runs.
3343
"""
3444

3545
import argparse
3646
import os
47+
import pathlib
3748
import re
3849
import subprocess
3950
import sys
@@ -88,6 +99,7 @@ def __init__(self, args, extra_args):
8899
self.has_check_fixes = False
89100
self.has_check_messages = False
90101
self.has_check_notes = False
102+
self.export_fixes = args.export_fixes
91103
self.fixes = MessagePrefix("CHECK-FIXES")
92104
self.messages = MessagePrefix("CHECK-MESSAGES")
93105
self.notes = MessagePrefix("CHECK-NOTES")
@@ -181,7 +193,13 @@ def run_clang_tidy(self):
181193
[
182194
"clang-tidy",
183195
self.temp_file_name,
184-
"-fix",
196+
]
197+
+ [
198+
"-fix"
199+
if self.export_fixes is None
200+
else "--export-fixes=" + self.export_fixes
201+
]
202+
+ [
185203
"--checks=-*," + self.check_name,
186204
]
187205
+ self.clang_tidy_extra_args
@@ -255,12 +273,14 @@ def check_notes(self, clang_tidy_output):
255273

256274
def run(self):
257275
self.read_input()
258-
self.get_prefixes()
276+
if self.export_fixes is None:
277+
self.get_prefixes()
259278
self.prepare_test_inputs()
260279
clang_tidy_output = self.run_clang_tidy()
261-
self.check_fixes()
262-
self.check_messages(clang_tidy_output)
263-
self.check_notes(clang_tidy_output)
280+
if self.export_fixes is None:
281+
self.check_fixes()
282+
self.check_messages(clang_tidy_output)
283+
self.check_notes(clang_tidy_output)
264284

265285

266286
def expand_std(std):
@@ -284,7 +304,11 @@ def csv(string):
284304

285305

286306
def parse_arguments():
287-
parser = argparse.ArgumentParser()
307+
parser = argparse.ArgumentParser(
308+
prog=pathlib.Path(__file__).stem,
309+
description=__doc__,
310+
formatter_class=argparse.RawDescriptionHelpFormatter,
311+
)
288312
parser.add_argument("-expect-clang-tidy-error", action="store_true")
289313
parser.add_argument("-resource-dir")
290314
parser.add_argument("-assume-filename")
@@ -298,7 +322,19 @@ def parse_arguments():
298322
type=csv,
299323
help="comma-separated list of FileCheck suffixes",
300324
)
301-
parser.add_argument("-std", type=csv, default=["c++11-or-later"])
325+
parser.add_argument(
326+
"-export-fixes",
327+
default=None,
328+
type=str,
329+
metavar="file",
330+
help="A file to export fixes into instead of fixing.",
331+
)
332+
parser.add_argument(
333+
"-std",
334+
type=csv,
335+
default=["c++11-or-later"],
336+
help="Passed to clang. Special -or-later values are expanded.",
337+
)
302338
return parser.parse_known_args()
303339

304340

clang/cmake/caches/Release.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
# General Options
66
set(LLVM_RELEASE_ENABLE_LTO THIN CACHE STRING "")
7-
set(LLVM_RELEASE_ENABLE_PGO ON CACHE BOOL "")
7+
set(LLVM_RELEASE_ENABLE_PGO OFF CACHE BOOL "")
88

99
set(CMAKE_BUILD_TYPE RELEASE CACHE STRING "")
1010

clang/docs/ClangFormat.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ to format C/C++/Java/JavaScript/JSON/Objective-C/Protobuf/C# code.
5454
Objective-C: .m .mm
5555
Proto: .proto .protodevel
5656
TableGen: .td
57-
TextProto: .textpb .pb.txt .textproto .asciipb
57+
TextProto: .txtpb .textpb .pb.txt .textproto .asciipb
5858
Verilog: .sv .svh .v .vh
5959
--cursor=<uint> - The position of the cursor when invoking
6060
clang-format from an editor integration

clang/docs/LanguageExtensions.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1493,6 +1493,7 @@ Conditional ``explicit`` __cpp_conditional_explicit C+
14931493
``if consteval`` __cpp_if_consteval C++23 C++20
14941494
``static operator()`` __cpp_static_call_operator C++23 C++03
14951495
Attributes on Lambda-Expressions C++23 C++11
1496+
``= delete ("should have a reason");`` __cpp_deleted_function C++26 C++03
14961497
-------------------------------------------- -------------------------------- ------------- -------------
14971498
Designated initializers (N494) C99 C89
14981499
Array & element qualification (N2607) C23 C89
@@ -1610,6 +1611,7 @@ The following type trait primitives are supported by Clang. Those traits marked
16101611
* ``__is_pod`` (C++, GNU, Microsoft, Embarcadero):
16111612
Note, the corresponding standard trait was deprecated in C++20.
16121613
* ``__is_pointer`` (C++, Embarcadero)
1614+
* ``__is_pointer_interconvertible_base_of`` (C++, GNU, Microsoft)
16131615
* ``__is_polymorphic`` (C++, GNU, Microsoft, Embarcadero)
16141616
* ``__is_reference`` (C++, Embarcadero)
16151617
* ``__is_referenceable`` (C++, GNU, Microsoft, Embarcadero):

0 commit comments

Comments
 (0)