Skip to content

Commit f8044f3

Browse files
committed
rebase
Created using spr 1.3.6-beta.1
2 parents 9fe1912 + 947ddf5 commit f8044f3

File tree

738 files changed

+17463
-8467
lines changed

Some content is hidden

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

738 files changed

+17463
-8467
lines changed

bolt/include/bolt/Profile/YAMLProfileReader.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ class YAMLProfileReader : public ProfileReaderBase {
105105
yaml::bolt::BinaryProfile YamlBP;
106106

107107
/// Map a function ID from a YAML profile to a BinaryFunction object.
108-
std::vector<BinaryFunction *> YamlProfileToFunction;
108+
DenseMap<uint32_t, BinaryFunction *> YamlProfileToFunction;
109109

110110
using FunctionSet = std::unordered_set<const BinaryFunction *>;
111111
/// To keep track of functions that have a matched profile before the profile
@@ -162,8 +162,6 @@ class YAMLProfileReader : public ProfileReaderBase {
162162
/// Update matched YAML -> BinaryFunction pair.
163163
void matchProfileToFunction(yaml::bolt::BinaryFunctionProfile &YamlBF,
164164
BinaryFunction &BF) {
165-
if (YamlBF.Id >= YamlProfileToFunction.size())
166-
YamlProfileToFunction.resize(YamlBF.Id + 1);
167165
YamlProfileToFunction[YamlBF.Id] = &BF;
168166
YamlBF.Used = true;
169167

bolt/lib/Profile/YAMLProfileReader.cpp

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -238,9 +238,7 @@ bool YAMLProfileReader::parseFunctionProfile(
238238
BB.setExecutionCount(YamlBB.ExecCount);
239239

240240
for (const yaml::bolt::CallSiteInfo &YamlCSI : YamlBB.CallSites) {
241-
BinaryFunction *Callee = YamlCSI.DestId < YamlProfileToFunction.size()
242-
? YamlProfileToFunction[YamlCSI.DestId]
243-
: nullptr;
241+
BinaryFunction *Callee = YamlProfileToFunction.lookup(YamlCSI.DestId);
244242
bool IsFunction = Callee ? true : false;
245243
MCSymbol *CalleeSymbol = nullptr;
246244
if (IsFunction)
@@ -703,7 +701,7 @@ Error YAMLProfileReader::readProfile(BinaryContext &BC) {
703701
break;
704702
}
705703
}
706-
YamlProfileToFunction.resize(YamlBP.Functions.size() + 1);
704+
YamlProfileToFunction.reserve(YamlBP.Functions.size());
707705

708706
// Computes hash for binary functions.
709707
if (opts::MatchProfileWithFunctionHash) {
@@ -756,12 +754,7 @@ Error YAMLProfileReader::readProfile(BinaryContext &BC) {
756754
NormalizeByCalls = usesEvent("branches");
757755
uint64_t NumUnused = 0;
758756
for (yaml::bolt::BinaryFunctionProfile &YamlBF : YamlBP.Functions) {
759-
if (YamlBF.Id >= YamlProfileToFunction.size()) {
760-
// Such profile was ignored.
761-
++NumUnused;
762-
continue;
763-
}
764-
if (BinaryFunction *BF = YamlProfileToFunction[YamlBF.Id])
757+
if (BinaryFunction *BF = YamlProfileToFunction.lookup(YamlBF.Id))
765758
parseFunctionProfile(*BF, YamlBF);
766759
else
767760
++NumUnused;

bolt/lib/Rewrite/PseudoProbeRewriter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,8 @@ void PseudoProbeRewriter::parsePseudoProbe(bool ProfiledOnly) {
127127

128128
StringRef Contents = PseudoProbeDescSection->getContents();
129129
if (!ProbeDecoder.buildGUID2FuncDescMap(
130-
reinterpret_cast<const uint8_t *>(Contents.data()),
131-
Contents.size())) {
130+
reinterpret_cast<const uint8_t *>(Contents.data()), Contents.size(),
131+
/*IsMMapped*/ true)) {
132132
errs() << "BOLT-WARNING: fail in building GUID2FuncDescMap\n";
133133
return;
134134
}

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ using namespace clang::ast_matchers;
1515
namespace clang::tidy::bugprone {
1616

1717
void ThrowKeywordMissingCheck::registerMatchers(MatchFinder *Finder) {
18-
auto CtorInitializerList =
19-
cxxConstructorDecl(hasAnyConstructorInitializer(anything()));
20-
2118
Finder->addMatcher(
2219
cxxConstructExpr(
2320
hasType(cxxRecordDecl(
@@ -27,7 +24,7 @@ void ThrowKeywordMissingCheck::registerMatchers(MatchFinder *Finder) {
2724
stmt(anyOf(cxxThrowExpr(), callExpr(), returnStmt()))),
2825
hasAncestor(decl(anyOf(varDecl(), fieldDecl()))),
2926
hasAncestor(expr(cxxNewExpr(hasAnyPlacementArg(anything())))),
30-
allOf(hasAncestor(CtorInitializerList),
27+
allOf(hasAncestor(cxxConstructorDecl()),
3128
unless(hasAncestor(cxxCatchStmt()))))))
3229
.bind("temporary-exception-not-thrown"),
3330
this);

clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88

99
#include "InitVariablesCheck.h"
1010

11+
#include "../utils/LexerUtils.h"
1112
#include "clang/AST/ASTContext.h"
13+
#include "clang/AST/Type.h"
1214
#include "clang/ASTMatchers/ASTMatchFinder.h"
13-
#include "clang/Lex/PPCallbacks.h"
1415
#include "clang/Lex/Preprocessor.h"
1516
#include <optional>
1617

@@ -107,8 +108,9 @@ void InitVariablesCheck::check(const MatchFinder::MatchResult &Result) {
107108
<< MatchedDecl;
108109
if (*InitializationString != nullptr)
109110
Diagnostic << FixItHint::CreateInsertion(
110-
MatchedDecl->getLocation().getLocWithOffset(
111-
MatchedDecl->getName().size()),
111+
utils::lexer::findNextTerminator(MatchedDecl->getLocation(),
112+
*Result.SourceManager,
113+
Result.Context->getLangOpts()),
112114
*InitializationString);
113115
if (AddMathInclude) {
114116
Diagnostic << IncludeInserter.createIncludeInsertion(

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,10 @@ Changes in existing checks
177177
usages of ``sizeof()``, ``alignof()``, and ``offsetof()`` when adding or
178178
subtracting from a pointer directly or when used to scale a numeric value.
179179

180+
- Improved :doc:`bugprone-throw-keyword-missing
181+
<clang-tidy/checks/bugprone/throw-keyword-missing>` by fixing a false positive
182+
when using non-static member initializers and a constructor.
183+
180184
- Improved :doc:`bugprone-unchecked-optional-access
181185
<clang-tidy/checks/bugprone/unchecked-optional-access>` to support
182186
`bsl::optional` and `bdlb::NullableValue` from
@@ -190,6 +194,10 @@ Changes in existing checks
190194
fix false positive that floating point variable is only used in increment
191195
expression.
192196

197+
- Improved :doc:`cppcoreguidelines-init-variables
198+
<clang-tidy/checks/cppcoreguidelines/init-variables>` check by fixing the
199+
insertion location for function pointers.
200+
193201
- Improved :doc:`cppcoreguidelines-prefer-member-initializer
194202
<clang-tidy/checks/cppcoreguidelines/prefer-member-initializer>` check to
195203
avoid false positive when member initialization depends on a structured
@@ -208,9 +216,9 @@ Changes in existing checks
208216
false positive for C++23 deducing this.
209217

210218
- Improved :doc:`modernize-avoid-c-arrays
211-
<clang-tidy/checks/modernize/avoid-c-arrays>` check to suggest using ``std::span``
212-
as a replacement for parameters of incomplete C array type in C++20 and
213-
``std::array`` or ``std::vector`` before C++20.
219+
<clang-tidy/checks/modernize/avoid-c-arrays>` check to suggest using
220+
``std::span`` as a replacement for parameters of incomplete C array type in
221+
C++20 and ``std::array`` or ``std::vector`` before C++20.
214222

215223
- Improved :doc:`modernize-loop-convert
216224
<clang-tidy/checks/modernize/loop-convert>` check to fix false positive when

clang-tools-extra/test/clang-tidy/checkers/bugprone/throw-keyword-missing.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,15 @@ CtorInitializerListTest::CtorInitializerListTest(float) try : exc(RegularExcepti
139139
RegularException();
140140
}
141141

142+
namespace GH115055 {
143+
class CtorInitializerListTest2 {
144+
public:
145+
CtorInitializerListTest2() {}
146+
private:
147+
RegularException exc{};
148+
};
149+
} // namespace GH115055
150+
142151
RegularException funcReturningExceptionTest(int i) {
143152
return RegularException();
144153
}

clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/init-variables.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,3 +134,17 @@ void test_clang_diagnostic_error() {
134134
// CHECK-MESSAGES: :[[@LINE-1]]:3: error: unknown type name 'UnknownType' [clang-diagnostic-error]
135135
// CHECK-FIXES-NOT: {{^}} UnknownType b = 0;{{$}}
136136
}
137+
138+
namespace gh112089 {
139+
void foo(void*);
140+
using FPtr = void(*)(void*);
141+
void test() {
142+
void(*a1)(void*);
143+
// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: variable 'a1' is not initialized [cppcoreguidelines-init-variables]
144+
// CHECK-FIXES: void(*a1)(void*) = nullptr;
145+
FPtr a2;
146+
// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: variable 'a2' is not initialized [cppcoreguidelines-init-variables]
147+
// CHECK-FIXES: FPtr a2 = nullptr;
148+
}
149+
} // namespace gh112089
150+

clang/docs/AMDGPUSupport.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ Predefined Macros
5050
* - ``__AMDGCN_UNSAFE_FP_ATOMICS__``
5151
- Defined if unsafe floating-point atomics are allowed.
5252
* - ``__AMDGCN_WAVEFRONT_SIZE__``
53-
- Defines the wavefront size. Allowed values are 32 and 64.
53+
- Defines the wavefront size. Allowed values are 32 and 64 (deprecated).
5454
* - ``__AMDGCN_WAVEFRONT_SIZE``
55-
- Alias to ``__AMDGCN_WAVEFRONT_SIZE__``. To be deprecated.
55+
- Alias to ``__AMDGCN_WAVEFRONT_SIZE__`` (deprecated).
5656
* - ``__HAS_FMAF__``
5757
- Defined if FMAF instruction is available (deprecated).
5858
* - ``__HAS_LDEXPF__``

clang/docs/HIPSupport.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ Predefined Macros
178178

179179
Note that some architecture specific AMDGPU macros will have default values when
180180
used from the HIP host compilation. Other :doc:`AMDGPU macros <AMDGPUSupport>`
181-
like ``__AMDGCN_WAVEFRONT_SIZE__`` will default to 64 for example.
181+
like ``__AMDGCN_WAVEFRONT_SIZE__`` (deprecated) will default to 64 for example.
182182

183183
Compilation Modes
184184
=================

clang/docs/ReleaseNotes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,9 @@ Attribute Changes in Clang
449449
- Fix a bug where clang doesn't automatically apply the ``[[gsl::Owner]]`` or
450450
``[[gsl::Pointer]]`` to STL explicit template specialization decls. (#GH109442)
451451

452+
- Clang now supports ``[[clang::lifetime_capture_by(X)]]``. Similar to lifetimebound, this can be
453+
used to specify when a reference to a function parameter is captured by another capturing entity ``X``.
454+
452455
Improvements to Clang's diagnostics
453456
-----------------------------------
454457

@@ -740,6 +743,7 @@ X86 Support
740743
- Support ISA of ``AMX-FP8``.
741744
- Support ISA of ``AMX-TRANSPOSE``.
742745
- Support ISA of ``AMX-AVX512``.
746+
- Support ISA of ``AMX-TF32``.
743747

744748
Arm and AArch64 Support
745749
^^^^^^^^^^^^^^^^^^^^^^^

clang/docs/SafeBuffers.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ A relatively fresh version of C++ is recommended. In particular, the very useful
5858
standard view class ``std::span`` requires C++20.
5959

6060
Other implementations of the C++ standard library may provide different
61-
flags to enable such hardening hardening.
61+
flags to enable such hardening.
6262

6363
If you're using custom containers and views, they will need to be hardened
6464
this way as well, but you don't necessarily need to do this ahead of time.

clang/include/clang/AST/StmtOpenACC.h

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ class OpenACCAssociatedStmtConstruct : public OpenACCConstructStmt {
114114
}
115115
};
116116

117-
class OpenACCLoopConstruct;
118117
/// This class represents a compute construct, representing a 'Kind' of
119118
/// `parallel', 'serial', or 'kernel'. These constructs are associated with a
120119
/// 'structured block', defined as:
@@ -183,8 +182,7 @@ class OpenACCComputeConstruct final
183182
static OpenACCComputeConstruct *
184183
Create(const ASTContext &C, OpenACCDirectiveKind K, SourceLocation BeginLoc,
185184
SourceLocation DirectiveLoc, SourceLocation EndLoc,
186-
ArrayRef<const OpenACCClause *> Clauses, Stmt *StructuredBlock,
187-
ArrayRef<OpenACCLoopConstruct *> AssociatedLoopConstructs);
185+
ArrayRef<const OpenACCClause *> Clauses, Stmt *StructuredBlock);
188186

189187
Stmt *getStructuredBlock() { return getAssociatedStmt(); }
190188
const Stmt *getStructuredBlock() const {
@@ -198,12 +196,10 @@ class OpenACCLoopConstruct final
198196
: public OpenACCAssociatedStmtConstruct,
199197
public llvm::TrailingObjects<OpenACCLoopConstruct,
200198
const OpenACCClause *> {
201-
// The compute construct this loop is associated with, or nullptr if this is
202-
// an orphaned loop construct, or if it hasn't been set yet. Because we
203-
// construct the directives at the end of their statement, the 'parent'
204-
// construct is not yet available at the time of construction, so this needs
205-
// to be set 'later'.
206-
const OpenACCComputeConstruct *ParentComputeConstruct = nullptr;
199+
// The compute/combined construct kind this loop is associated with, or
200+
// invalid if this is an orphaned loop construct.
201+
OpenACCDirectiveKind ParentComputeConstructKind =
202+
OpenACCDirectiveKind::Invalid;
207203

208204
friend class ASTStmtWriter;
209205
friend class ASTStmtReader;
@@ -212,15 +208,9 @@ class OpenACCLoopConstruct final
212208

213209
OpenACCLoopConstruct(unsigned NumClauses);
214210

215-
OpenACCLoopConstruct(SourceLocation Start, SourceLocation DirLoc,
216-
SourceLocation End,
211+
OpenACCLoopConstruct(OpenACCDirectiveKind ParentKind, SourceLocation Start,
212+
SourceLocation DirLoc, SourceLocation End,
217213
ArrayRef<const OpenACCClause *> Clauses, Stmt *Loop);
218-
void setLoop(Stmt *Loop);
219-
220-
void setParentComputeConstruct(OpenACCComputeConstruct *CC) {
221-
assert(!ParentComputeConstruct && "Parent already set?");
222-
ParentComputeConstruct = CC;
223-
}
224214

225215
public:
226216
static bool classof(const Stmt *T) {
@@ -231,9 +221,9 @@ class OpenACCLoopConstruct final
231221
unsigned NumClauses);
232222

233223
static OpenACCLoopConstruct *
234-
Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation DirLoc,
235-
SourceLocation EndLoc, ArrayRef<const OpenACCClause *> Clauses,
236-
Stmt *Loop);
224+
Create(const ASTContext &C, OpenACCDirectiveKind ParentKind,
225+
SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation EndLoc,
226+
ArrayRef<const OpenACCClause *> Clauses, Stmt *Loop);
237227

238228
Stmt *getLoop() { return getAssociatedStmt(); }
239229
const Stmt *getLoop() const {
@@ -246,10 +236,11 @@ class OpenACCLoopConstruct final
246236
/// loop construct is the nearest compute construct that lexically contains
247237
/// the loop construct.
248238
bool isOrphanedLoopConstruct() const {
249-
return ParentComputeConstruct == nullptr;
239+
return ParentComputeConstructKind == OpenACCDirectiveKind::Invalid;
250240
}
251-
const OpenACCComputeConstruct *getParentComputeConstruct() const {
252-
return ParentComputeConstruct;
241+
242+
OpenACCDirectiveKind getParentComputeConstructKind() const {
243+
return ParentComputeConstructKind;
253244
}
254245
};
255246
} // namespace clang

clang/include/clang/Basic/Attr.td

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1889,6 +1889,39 @@ def LifetimeBound : DeclOrTypeAttr {
18891889
let SimpleHandler = 1;
18901890
}
18911891

1892+
def LifetimeCaptureBy : DeclOrTypeAttr {
1893+
let Spellings = [Clang<"lifetime_capture_by", 0>];
1894+
let Subjects = SubjectList<[ParmVar, ImplicitObjectParameter], ErrorDiag>;
1895+
let Args = [VariadicParamOrParamIdxArgument<"Params">];
1896+
let Documentation = [LifetimeCaptureByDocs];
1897+
let AdditionalMembers = [{
1898+
private:
1899+
SmallVector<IdentifierInfo*, 1> ArgIdents;
1900+
SmallVector<SourceLocation, 1> ArgLocs;
1901+
1902+
public:
1903+
static constexpr int THIS = 0;
1904+
static constexpr int INVALID = -1;
1905+
static constexpr int UNKNOWN = -2;
1906+
static constexpr int GLOBAL = -3;
1907+
1908+
void setArgs(SmallVector<IdentifierInfo*>&& Idents,
1909+
SmallVector<SourceLocation>&& Locs) {
1910+
assert(Idents.size() == Locs.size());
1911+
assert(Idents.size() == params_Size);
1912+
ArgIdents = std::move(Idents);
1913+
ArgLocs = std::move(Locs);
1914+
}
1915+
1916+
ArrayRef<IdentifierInfo*> getArgIdents() const { return ArgIdents; }
1917+
ArrayRef<SourceLocation> getArgLocs() const { return ArgLocs; }
1918+
void setParamIdx(size_t Idx, int Val) {
1919+
assert(Idx < params_Size);
1920+
params_[Idx] = Val;
1921+
}
1922+
}];
1923+
}
1924+
18921925
def TrivialABI : InheritableAttr {
18931926
// This attribute does not have a C [[]] spelling because it requires the
18941927
// CPlusPlus language option.

0 commit comments

Comments
 (0)