Skip to content

Commit 2a71d04

Browse files
committed
Merge remote-tracking branch 'origin/main' into pr/store-reverse
2 parents 8367247 + ff1b01b commit 2a71d04

File tree

467 files changed

+15249
-6998
lines changed

Some content is hidden

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

467 files changed

+15249
-6998
lines changed

.ci/metrics/metrics.py

Lines changed: 94 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,67 @@ class JobMetrics:
2626
workflow_id: int
2727

2828

29-
def get_metrics(github_repo: github.Repository, workflows_to_track: dict[str, int]):
29+
@dataclass
30+
class GaugeMetric:
31+
name: str
32+
value: int
33+
time_ns: int
34+
35+
36+
def get_sampled_workflow_metrics(github_repo: github.Repository):
37+
"""Gets global statistics about the Github workflow queue
38+
39+
Args:
40+
github_repo: A github repo object to use to query the relevant information.
41+
42+
Returns:
43+
Returns a list of GaugeMetric objects, containing the relevant metrics about
44+
the workflow
45+
"""
46+
47+
# Other states are available (pending, waiting, etc), but the meaning
48+
# is not documented (See #70540).
49+
# "queued" seems to be the info we want.
50+
queued_workflow_count = len(
51+
[
52+
x
53+
for x in github_repo.get_workflow_runs(status="queued")
54+
if x.name in WORKFLOWS_TO_TRACK
55+
]
56+
)
57+
running_workflow_count = len(
58+
[
59+
x
60+
for x in github_repo.get_workflow_runs(status="in_progress")
61+
if x.name in WORKFLOWS_TO_TRACK
62+
]
63+
)
64+
65+
workflow_metrics = []
66+
workflow_metrics.append(
67+
GaugeMetric(
68+
"workflow_queue_size",
69+
queued_workflow_count,
70+
time.time_ns(),
71+
)
72+
)
73+
workflow_metrics.append(
74+
GaugeMetric(
75+
"running_workflow_count",
76+
running_workflow_count,
77+
time.time_ns(),
78+
)
79+
)
80+
# Always send a hearbeat metric so we can monitor is this container is still able to log to Grafana.
81+
workflow_metrics.append(
82+
GaugeMetric("metrics_container_heartbeat", 1, time.time_ns())
83+
)
84+
return workflow_metrics
85+
86+
87+
def get_per_workflow_metrics(
88+
github_repo: github.Repository, workflows_to_track: dict[str, int]
89+
):
3090
"""Gets the metrics for specified Github workflows.
3191
3292
This function takes in a list of workflows to track, and optionally the
@@ -43,14 +103,14 @@ def get_metrics(github_repo: github.Repository, workflows_to_track: dict[str, in
43103
Returns a list of JobMetrics objects, containing the relevant metrics about
44104
the workflow.
45105
"""
46-
workflow_runs = iter(github_repo.get_workflow_runs())
47-
48106
workflow_metrics = []
49107

50108
workflows_to_include = set(workflows_to_track.keys())
51109

52-
while len(workflows_to_include) > 0:
53-
workflow_run = next(workflow_runs)
110+
for workflow_run in iter(github_repo.get_workflow_runs()):
111+
if len(workflows_to_include) == 0:
112+
break
113+
54114
if workflow_run.status != "completed":
55115
continue
56116

@@ -139,12 +199,27 @@ def upload_metrics(workflow_metrics, metrics_userid, api_key):
139199
metrics_userid: The userid to use for the upload.
140200
api_key: The API key to use for the upload.
141201
"""
202+
203+
if len(workflow_metrics) == 0:
204+
print("No metrics found to upload.", file=sys.stderr)
205+
return
206+
142207
metrics_batch = []
143208
for workflow_metric in workflow_metrics:
144-
workflow_formatted_name = workflow_metric.job_name.lower().replace(" ", "_")
145-
metrics_batch.append(
146-
f"{workflow_formatted_name} queue_time={workflow_metric.queue_time},run_time={workflow_metric.run_time},status={workflow_metric.status} {workflow_metric.created_at_ns}"
147-
)
209+
if isinstance(workflow_metric, GaugeMetric):
210+
name = workflow_metric.name.lower().replace(" ", "_")
211+
metrics_batch.append(
212+
f"{name} value={workflow_metric.value} {workflow_metric.time_ns}"
213+
)
214+
elif isinstance(workflow_metric, JobMetrics):
215+
name = workflow_metric.job_name.lower().replace(" ", "_")
216+
metrics_batch.append(
217+
f"{name} queue_time={workflow_metric.queue_time},run_time={workflow_metric.run_time},status={workflow_metric.status} {workflow_metric.created_at_ns}"
218+
)
219+
else:
220+
raise ValueError(
221+
f"Unsupported object type {type(workflow_metric)}: {str(workflow_metric)}"
222+
)
148223

149224
request_data = "\n".join(metrics_batch)
150225
response = requests.post(
@@ -176,16 +251,21 @@ def main():
176251
# Enter the main loop. Every five minutes we wake up and dump metrics for
177252
# the relevant jobs.
178253
while True:
179-
current_metrics = get_metrics(github_repo, workflows_to_track)
180-
if len(current_metrics) == 0:
181-
print("No metrics found to upload.", file=sys.stderr)
182-
continue
254+
current_metrics = get_per_workflow_metrics(github_repo, workflows_to_track)
255+
current_metrics += get_sampled_workflow_metrics(github_repo)
256+
# Always send a hearbeat metric so we can monitor is this container is still able to log to Grafana.
257+
current_metrics.append(
258+
GaugeMetric("metrics_container_heartbeat", 1, time.time_ns())
259+
)
183260

184261
upload_metrics(current_metrics, grafana_metrics_userid, grafana_api_key)
185262
print(f"Uploaded {len(current_metrics)} metrics", file=sys.stderr)
186263

187264
for workflow_metric in reversed(current_metrics):
188-
workflows_to_track[workflow_metric.job_name] = workflow_metric.workflow_id
265+
if isinstance(workflow_metric, JobMetrics):
266+
workflows_to_track[
267+
workflow_metric.job_name
268+
] = workflow_metric.workflow_id
189269

190270
time.sleep(SCRAPE_INTERVAL_SECONDS)
191271

clang-tools-extra/clang-reorder-fields/ReorderFieldsAction.cpp

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -118,47 +118,19 @@ findMembersUsedInInitExpr(const CXXCtorInitializer *Initializer,
118118
return Results;
119119
}
120120

121-
/// Returns the next token after `Loc` (including comment tokens).
122-
static std::optional<Token> getTokenAfter(SourceLocation Loc,
123-
const SourceManager &SM,
124-
const LangOptions &LangOpts) {
125-
if (Loc.isMacroID()) {
126-
return std::nullopt;
127-
}
128-
Loc = Lexer::getLocForEndOfToken(Loc, 0, SM, LangOpts);
129-
130-
// Break down the source location.
131-
std::pair<FileID, unsigned> LocInfo = SM.getDecomposedLoc(Loc);
132-
133-
// Try to load the file buffer.
134-
bool InvalidTemp = false;
135-
StringRef File = SM.getBufferData(LocInfo.first, &InvalidTemp);
136-
if (InvalidTemp)
137-
return std::nullopt;
138-
139-
const char *TokenBegin = File.data() + LocInfo.second;
140-
141-
Lexer lexer(SM.getLocForStartOfFile(LocInfo.first), LangOpts, File.begin(),
142-
TokenBegin, File.end());
143-
lexer.SetCommentRetentionState(true);
144-
// Find the token.
145-
Token Tok;
146-
lexer.LexFromRawLexer(Tok);
147-
return Tok;
148-
}
149-
150121
/// Returns the end of the trailing comments after `Loc`.
151122
static SourceLocation getEndOfTrailingComment(SourceLocation Loc,
152123
const SourceManager &SM,
153124
const LangOptions &LangOpts) {
154125
// We consider any following comment token that is indented more than the
155126
// first comment to be part of the trailing comment.
156127
const unsigned Column = SM.getPresumedColumnNumber(Loc);
157-
std::optional<Token> Tok = getTokenAfter(Loc, SM, LangOpts);
128+
std::optional<Token> Tok =
129+
Lexer::findNextToken(Loc, SM, LangOpts, /*IncludeComments=*/true);
158130
while (Tok && Tok->is(tok::comment) &&
159131
SM.getPresumedColumnNumber(Tok->getLocation()) > Column) {
160132
Loc = Tok->getEndLoc();
161-
Tok = getTokenAfter(Loc, SM, LangOpts);
133+
Tok = Lexer::findNextToken(Loc, SM, LangOpts, /*IncludeComments=*/true);
162134
}
163135
return Loc;
164136
}

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

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -86,29 +86,6 @@ SourceLocation findNextTerminator(SourceLocation Start, const SourceManager &SM,
8686
return findNextAnyTokenKind(Start, SM, LangOpts, tok::comma, tok::semi);
8787
}
8888

89-
std::optional<Token>
90-
findNextTokenIncludingComments(SourceLocation Start, const SourceManager &SM,
91-
const LangOptions &LangOpts) {
92-
// `Lexer::findNextToken` will ignore comment
93-
if (Start.isMacroID())
94-
return std::nullopt;
95-
Start = Lexer::getLocForEndOfToken(Start, 0, SM, LangOpts);
96-
// Break down the source location.
97-
std::pair<FileID, unsigned> LocInfo = SM.getDecomposedLoc(Start);
98-
bool InvalidTemp = false;
99-
StringRef File = SM.getBufferData(LocInfo.first, &InvalidTemp);
100-
if (InvalidTemp)
101-
return std::nullopt;
102-
// Lex from the start of the given location.
103-
Lexer L(SM.getLocForStartOfFile(LocInfo.first), LangOpts, File.begin(),
104-
File.data() + LocInfo.second, File.end());
105-
L.SetCommentRetentionState(true);
106-
// Find the token.
107-
Token Tok;
108-
L.LexFromRawLexer(Tok);
109-
return Tok;
110-
}
111-
11289
std::optional<Token>
11390
findNextTokenSkippingComments(SourceLocation Start, const SourceManager &SM,
11491
const LangOptions &LangOpts) {

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,11 @@ SourceLocation findNextAnyTokenKind(SourceLocation Start,
8989
}
9090
}
9191

92-
std::optional<Token>
92+
inline std::optional<Token>
9393
findNextTokenIncludingComments(SourceLocation Start, const SourceManager &SM,
94-
const LangOptions &LangOpts);
94+
const LangOptions &LangOpts) {
95+
return Lexer::findNextToken(Start, SM, LangOpts, true);
96+
}
9597

9698
// Finds next token that's not a comment.
9799
std::optional<Token> findNextTokenSkippingComments(SourceLocation Start,

clang/docs/Multilib.rst

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,73 @@ subclass and a suitable base multilib variant is present then the
122122
It is the responsibility of layered multilib authors to ensure that headers and
123123
libraries in each layer are complete enough to mask any incompatibilities.
124124

125+
Multilib custom flags
126+
=====================
127+
128+
Introduction
129+
------------
130+
131+
The multilib mechanism supports library variants that correspond to target,
132+
code generation or language command-line flags. Examples include ``--target``,
133+
``-mcpu``, ``-mfpu``, ``-mbranch-protection``, ``-fno-rtti``. However, some library
134+
variants are particular to features that do not correspond to any command-line
135+
option. Multithreading and semihosting, for instance, have no associated
136+
compiler option.
137+
138+
In order to support the selection of variants for which no compiler option
139+
exists, the multilib specification includes the concept of *custom flags*.
140+
These flags have no impact on code generation and are only used in the multilib
141+
processing.
142+
143+
Multilib custom flags follow this format in the driver invocation:
144+
145+
::
146+
147+
-fmultilib-flag=<value>
148+
149+
They are fed into the multilib system alongside the remaining flags.
150+
151+
Custom flag declarations
152+
------------------------
153+
154+
Custom flags can be declared in the YAML file under the *Flags* section.
155+
156+
.. code-block:: yaml
157+
158+
Flags:
159+
- Name: multithreaded
160+
Values:
161+
- Name: no-multithreaded
162+
MacroDefines: [__SINGLE_THREAD__]
163+
- Name: multithreaded
164+
Default: no-multithreaded
165+
166+
* Name: the name to categorize a flag.
167+
* Values: a list of flag Values (defined below).
168+
* Default: it specifies the name of the value this flag should take if not
169+
specified in the command-line invocation. It must be one value from the Values
170+
field.
171+
172+
Each flag *Value* is defined as:
173+
174+
* Name: name of the value. This is the string to be used in
175+
``-fmultilib-flag=<string>``.
176+
* MacroDefines: a list of strings to be used as macro definitions. Each string
177+
is fed into the driver as ``-D<string>``.
178+
179+
The namespace of flag values is common across all flags. This means that flag
180+
value names must be unique.
181+
182+
Usage of custom flags in the *Variants* specifications
183+
------------------------------------------------------
184+
185+
Library variants should list their requirement on one or more custom flags like
186+
they do for any other flag. Each requirement must be listed as
187+
``-fmultilib-flag=<value>``.
188+
189+
A variant that does not specify a requirement on one particular flag can be
190+
matched against any value of that flag.
191+
125192
Stability
126193
=========
127194

@@ -222,6 +289,23 @@ For a more comprehensive example see
222289
# Flags is a list of one or more strings.
223290
Flags: [--target=thumbv7m-none-eabi]
224291
292+
# Custom flag declarations. Each item is a different declaration.
293+
Flags:
294+
# Name of the flag
295+
- Name: multithreaded
296+
# List of custom flag values
297+
Values:
298+
# Name of the custom flag value. To be used in -fmultilib-flag=<string>.
299+
- Name: no-multithreaded
300+
# Macro definitions. Useful for defining extra macros for building the
301+
# associated library variant(s).
302+
MacroDefines: [__SINGLE_THREAD__]
303+
- Name: multithreaded
304+
# Default flag value. If no value for this flag declaration is used in the
305+
# command-line, the multilib system will use this one. Must be equal to one
306+
# of the flag value names from this flag declaration.
307+
Default: no-multithreaded
308+
225309
Design principles
226310
=================
227311

clang/docs/ReleaseNotes.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,8 +316,6 @@ C++23 Feature Support
316316
C++20 Feature Support
317317
^^^^^^^^^^^^^^^^^^^^^
318318

319-
- Implemented module level lookup for C++20 modules. (#GH90154)
320-
321319

322320
Resolutions to C++ Defect Reports
323321
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -952,6 +950,8 @@ Bug Fixes to C++ Support
952950
- Clang now identifies unexpanded parameter packs within the type constraint on a non-type template parameter. (#GH88866)
953951
- Fixed an issue while resolving type of expression indexing into a pack of values of non-dependent type (#GH121242)
954952
- Fixed a crash when __PRETTY_FUNCTION__ or __FUNCSIG__ (clang-cl) appears in the trailing return type of the lambda (#GH121274)
953+
- Fixed a crash caused by the incorrect construction of template arguments for CTAD alias guides when type
954+
constraints are applied. (#GH122134)
955955

956956
Bug Fixes to AST Handling
957957
^^^^^^^^^^^^^^^^^^^^^^^^^

clang/include/clang/AST/DeclBase.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -836,10 +836,6 @@ class alignas(8) Decl {
836836
return isFromASTFile() ? getImportedOwningModule() : getLocalOwningModule();
837837
}
838838

839-
/// Get the top level owning named module that owns this declaration if any.
840-
/// \returns nullptr if the declaration is not owned by a named module.
841-
Module *getTopLevelOwningNamedModule() const;
842-
843839
/// Get the module that owns this declaration for linkage purposes.
844840
/// There only ever is such a standard C++ module.
845841
Module *getOwningModuleForLinkage() const;
@@ -2726,12 +2722,6 @@ class DeclContext {
27262722
bool Deserialize = false) const;
27272723

27282724
private:
2729-
/// Lookup all external visible declarations and the external declarations
2730-
/// within the same module specified by \c NamedModule. We can't
2731-
/// get it from \c this since the same declaration may be declared in
2732-
/// multiple modules. e.g., namespace.
2733-
lookup_result lookupImpl(DeclarationName Name, Module *NamedModule) const;
2734-
27352725
/// Whether this declaration context has had externally visible
27362726
/// storage added since the last lookup. In this case, \c LookupPtr's
27372727
/// invariant may not hold and needs to be fixed before we perform

clang/include/clang/AST/ExternalASTMerger.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,7 @@ class ExternalASTMerger : public ExternalASTSource {
141141

142142
/// Implementation of the ExternalASTSource API.
143143
bool FindExternalVisibleDeclsByName(const DeclContext *DC,
144-
DeclarationName Name,
145-
Module *NamedModule) override;
144+
DeclarationName Name) override;
146145

147146
/// Implementation of the ExternalASTSource API.
148147
void

0 commit comments

Comments
 (0)