Skip to content

Commit 8cc7346

Browse files
committed
merge main into amd-staging
2 parents 4f4afb6 + 6a42fb8 commit 8cc7346

File tree

164 files changed

+217408
-589
lines changed

Some content is hidden

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

164 files changed

+217408
-589
lines changed

.ci/metrics/metrics.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,13 @@ def github_get_metrics(
282282
queued_count = collections.Counter()
283283
running_count = collections.Counter()
284284

285+
# Initialize all the counters to 0 so we report 0 when no job is queued
286+
# or running.
287+
for wf_name, wf_metric_name in GITHUB_WORKFLOW_TO_TRACK.items():
288+
for job_name, job_metric_name in GITHUB_JOB_TO_TRACK[wf_metric_name].items():
289+
queued_count[wf_metric_name + "_" + job_metric_name] = 0
290+
running_count[wf_metric_name + "_" + job_metric_name] = 0
291+
285292
# The list of workflows this iteration will process.
286293
# MaxSize = GITHUB_WORKFLOWS_MAX_PROCESS_COUNT
287294
workflow_seen_as_completed = set()

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "clang/AST/ASTContext.h"
2323
#include "clang/AST/ASTDiagnostic.h"
2424
#include "clang/AST/Attr.h"
25+
#include "clang/AST/Expr.h"
2526
#include "clang/Basic/CharInfo.h"
2627
#include "clang/Basic/Diagnostic.h"
2728
#include "clang/Basic/DiagnosticOptions.h"
@@ -166,8 +167,8 @@ ClangTidyContext::ClangTidyContext(
166167
AllowEnablingAnalyzerAlphaCheckers(AllowEnablingAnalyzerAlphaCheckers),
167168
EnableModuleHeadersParsing(EnableModuleHeadersParsing) {
168169
// Before the first translation unit we can get errors related to command-line
169-
// parsing, use empty string for the file name in this case.
170-
setCurrentFile("");
170+
// parsing, use dummy string for the file name in this case.
171+
setCurrentFile("dummy");
171172
}
172173

173174
ClangTidyContext::~ClangTidyContext() = default;
@@ -528,6 +529,8 @@ void ClangTidyDiagnosticConsumer::forwardDiagnostic(const Diagnostic &Info) {
528529
case clang::DiagnosticsEngine::ak_addrspace:
529530
Builder << static_cast<LangAS>(Info.getRawArg(Index));
530531
break;
532+
case clang::DiagnosticsEngine::ak_expr:
533+
Builder << reinterpret_cast<const Expr *>(Info.getRawArg(Index));
531534
}
532535
}
533536
}

clang/docs/ReleaseNotes.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,9 @@ Improvements to Clang's diagnostics
280280
- Clang now better preserves the sugared types of pointers to member.
281281
- Clang now better preserves the presence of the template keyword with dependent
282282
prefixes.
283+
- Clang now respects the current language mode when printing expressions in
284+
diagnostics. This fixes a bunch of `bool` being printed as `_Bool`, and also
285+
a bunch of HLSL types being printed as their C++ equivalents.
283286
- When printing types for diagnostics, clang now doesn't suppress the scopes of
284287
template arguments contained within nested names.
285288
- The ``-Wshift-bool`` warning has been added to warn about shifting a boolean. (#GH28334)

clang/include/clang/AST/Expr.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7379,6 +7379,14 @@ class RecoveryExpr final : public Expr,
73797379
friend class ASTStmtWriter;
73807380
};
73817381

7382+
/// Insertion operator for diagnostics. This allows sending
7383+
/// Expr into a diagnostic with <<.
7384+
inline const StreamingDiagnostic &operator<<(const StreamingDiagnostic &DB,
7385+
const Expr *E) {
7386+
DB.AddTaggedVal(reinterpret_cast<uint64_t>(E), DiagnosticsEngine::ak_expr);
7387+
return DB;
7388+
}
7389+
73827390
} // end namespace clang
73837391

73847392
#endif // LLVM_CLANG_AST_EXPR_H

clang/include/clang/AST/TemplateBase.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ class TemplateArgument {
262262
/// This form of template argument only occurs in template argument
263263
/// lists used for dependent types and for expression; it will not
264264
/// occur in a non-dependent, canonical template argument list.
265-
TemplateArgument(Expr *E, bool IsDefaulted = false) {
265+
explicit TemplateArgument(Expr *E, bool IsDefaulted = false) {
266266
TypeOrValue.Kind = Expression;
267267
TypeOrValue.IsDefaulted = IsDefaulted;
268268
TypeOrValue.V = reinterpret_cast<uintptr_t>(E);

clang/include/clang/Basic/Diagnostic.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,10 @@ class DiagnosticsEngine : public RefCountedBase<DiagnosticsEngine> {
284284
ak_qualtype_pair,
285285

286286
/// Attr *
287-
ak_attr
287+
ak_attr,
288+
289+
/// Expr *
290+
ak_expr,
288291
};
289292

290293
/// Represents on argument value, which is a union discriminated

clang/lib/AST/ASTDiagnostic.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,14 @@ void clang::FormatASTNodeDiagnosticArgument(
508508
NeedQuotes = false;
509509
break;
510510
}
511+
case DiagnosticsEngine::ak_expr: {
512+
const Expr *E = reinterpret_cast<Expr *>(Val);
513+
assert(E && "Received null Expr!");
514+
E->printPretty(OS, /*Helper=*/nullptr, Context.getPrintingPolicy());
515+
// FIXME: Include quotes when printing expressions.
516+
NeedQuotes = false;
517+
break;
518+
}
511519
}
512520

513521
if (NeedQuotes) {

clang/lib/AST/ByteCode/Compiler.cpp

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6148,7 +6148,8 @@ bool Compiler<Emitter>::VisitUnaryOperator(const UnaryOperator *E) {
61486148

61496149
if (!this->visit(SubExpr))
61506150
return false;
6151-
if (classifyPrim(SubExpr) == PT_Ptr && !E->getType()->isArrayType())
6151+
6152+
if (classifyPrim(SubExpr) == PT_Ptr)
61526153
return this->emitNarrowPtr(E);
61536154
return true;
61546155

@@ -6800,6 +6801,10 @@ bool Compiler<Emitter>::emitDestruction(const Descriptor *Desc,
68006801
assert(!Desc->isPrimitive());
68016802
assert(!Desc->isPrimitiveArray());
68026803

6804+
// Can happen if the decl is invalid.
6805+
if (Desc->isDummy())
6806+
return true;
6807+
68036808
// Arrays.
68046809
if (Desc->isArray()) {
68056810
const Descriptor *ElemDesc = Desc->ElemDesc;
@@ -6818,15 +6823,17 @@ bool Compiler<Emitter>::emitDestruction(const Descriptor *Desc,
68186823
return true;
68196824
}
68206825

6821-
for (ssize_t I = Desc->getNumElems() - 1; I >= 0; --I) {
6822-
if (!this->emitConstUint64(I, Loc))
6823-
return false;
6824-
if (!this->emitArrayElemPtrUint64(Loc))
6825-
return false;
6826-
if (!this->emitDestruction(ElemDesc, Loc))
6827-
return false;
6828-
if (!this->emitPopPtr(Loc))
6829-
return false;
6826+
if (size_t N = Desc->getNumElems()) {
6827+
for (ssize_t I = N - 1; I >= 0; --I) {
6828+
if (!this->emitConstUint64(I, Loc))
6829+
return false;
6830+
if (!this->emitArrayElemPtrUint64(Loc))
6831+
return false;
6832+
if (!this->emitDestruction(ElemDesc, Loc))
6833+
return false;
6834+
if (!this->emitPopPtr(Loc))
6835+
return false;
6836+
}
68306837
}
68316838
return true;
68326839
}

clang/lib/AST/ByteCode/Interp.h

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2059,8 +2059,11 @@ bool OffsetHelper(InterpState &S, CodePtr OpPC, const T &Offset,
20592059
// useful thing we can do. Any other index has been diagnosed before and
20602060
// we don't get here.
20612061
if (Result == 0 && Ptr.isOnePastEnd()) {
2062-
S.Stk.push<Pointer>(Ptr.asBlockPointer().Pointee,
2063-
Ptr.asBlockPointer().Base);
2062+
if (Ptr.getFieldDesc()->isArray())
2063+
S.Stk.push<Pointer>(Ptr.atIndex(0));
2064+
else
2065+
S.Stk.push<Pointer>(Ptr.asBlockPointer().Pointee,
2066+
Ptr.asBlockPointer().Base);
20642067
return true;
20652068
}
20662069

@@ -2677,8 +2680,16 @@ inline bool ArrayElemPtr(InterpState &S, CodePtr OpPC) {
26772680
return false;
26782681
}
26792682

2680-
if (!OffsetHelper<T, ArithOp::Add>(S, OpPC, Offset, Ptr))
2681-
return false;
2683+
if (Offset.isZero()) {
2684+
if (Ptr.getFieldDesc()->isArray() && Ptr.getIndex() == 0) {
2685+
S.Stk.push<Pointer>(Ptr.atIndex(0));
2686+
} else {
2687+
S.Stk.push<Pointer>(Ptr);
2688+
}
2689+
} else {
2690+
if (!OffsetHelper<T, ArithOp::Add>(S, OpPC, Offset, Ptr))
2691+
return false;
2692+
}
26822693

26832694
return NarrowPtr(S, OpPC);
26842695
}
@@ -2693,8 +2704,16 @@ inline bool ArrayElemPtrPop(InterpState &S, CodePtr OpPC) {
26932704
return false;
26942705
}
26952706

2696-
if (!OffsetHelper<T, ArithOp::Add>(S, OpPC, Offset, Ptr))
2697-
return false;
2707+
if (Offset.isZero()) {
2708+
if (Ptr.getFieldDesc()->isArray() && Ptr.getIndex() == 0) {
2709+
S.Stk.push<Pointer>(Ptr.atIndex(0));
2710+
} else {
2711+
S.Stk.push<Pointer>(Ptr);
2712+
}
2713+
} else {
2714+
if (!OffsetHelper<T, ArithOp::Add>(S, OpPC, Offset, Ptr))
2715+
return false;
2716+
}
26982717

26992718
return NarrowPtr(S, OpPC);
27002719
}

clang/lib/AST/ByteCode/Pointer.h

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -200,37 +200,28 @@ class Pointer {
200200
if (isZero() || isUnknownSizeArray())
201201
return *this;
202202

203+
unsigned Base = asBlockPointer().Base;
203204
// Pointer to an array of base types - enter block.
204-
if (asBlockPointer().Base == RootPtrMark)
205+
if (Base == RootPtrMark)
205206
return Pointer(asBlockPointer().Pointee, sizeof(InlineDescriptor),
206207
Offset == 0 ? Offset : PastEndMark);
207208

208209
// Pointer is one past end - magic offset marks that.
209210
if (isOnePastEnd())
210-
return Pointer(asBlockPointer().Pointee, asBlockPointer().Base,
211-
PastEndMark);
212-
213-
// Primitive arrays are a bit special since they do not have inline
214-
// descriptors. If Offset != Base, then the pointer already points to
215-
// an element and there is nothing to do. Otherwise, the pointer is
216-
// adjusted to the first element of the array.
217-
if (inPrimitiveArray()) {
218-
if (Offset != asBlockPointer().Base)
211+
return Pointer(asBlockPointer().Pointee, Base, PastEndMark);
212+
213+
if (Offset != Base) {
214+
// If we're pointing to a primitive array element, there's nothing to do.
215+
if (inPrimitiveArray())
219216
return *this;
220-
return Pointer(asBlockPointer().Pointee, asBlockPointer().Base,
221-
Offset + sizeof(InitMapPtr));
217+
// Pointer is to a composite array element - enter it.
218+
if (Offset != Base)
219+
return Pointer(asBlockPointer().Pointee, Offset, Offset);
222220
}
223221

224-
// Pointer is to a field or array element - enter it.
225-
if (Offset != asBlockPointer().Base)
226-
return Pointer(asBlockPointer().Pointee, Offset, Offset);
227-
228-
// Enter the first element of an array.
229-
if (!getFieldDesc()->isArray())
230-
return *this;
231-
232-
const unsigned NewBase = asBlockPointer().Base + sizeof(InlineDescriptor);
233-
return Pointer(asBlockPointer().Pointee, NewBase, NewBase);
222+
// Otherwise, we're pointing to a non-array element or
223+
// are already narrowed to a composite array element. Nothing to do.
224+
return *this;
234225
}
235226

236227
/// Expands a pointer to the containing array, undoing narrowing.

0 commit comments

Comments
 (0)