Skip to content

Commit b05e2dd

Browse files
committed
Merge from 'main' to 'sycl-web' (88 commits)
CONFLICT (content): Merge conflict in clang/include/clang/Driver/Options.td
2 parents 652a40e + fa18827 commit b05e2dd

File tree

207 files changed

+9167
-2142
lines changed

Some content is hidden

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

207 files changed

+9167
-2142
lines changed

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

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -62,23 +62,28 @@ void RvalueReferenceParamNotMovedCheck::registerMatchers(MatchFinder *Finder) {
6262
anyOf(isConstQualified(), substTemplateTypeParmType()))))),
6363
optionally(hasType(qualType(references(templateTypeParmType(
6464
hasDeclaration(templateTypeParmDecl().bind("template-type"))))))),
65-
anyOf(hasAncestor(cxxConstructorDecl(
66-
ToParam, isDefinition(), unless(isMoveConstructor()),
67-
optionally(hasDescendant(MoveCallMatcher)))),
68-
hasAncestor(functionDecl(
69-
unless(cxxConstructorDecl()), ToParam,
70-
unless(cxxMethodDecl(isMoveAssignmentOperator())),
71-
hasBody(optionally(hasDescendant(MoveCallMatcher))))))),
65+
hasDeclContext(
66+
functionDecl(
67+
isDefinition(), unless(isDeleted()), unless(isDefaulted()),
68+
unless(cxxConstructorDecl(isMoveConstructor())),
69+
unless(cxxMethodDecl(isMoveAssignmentOperator())), ToParam,
70+
anyOf(cxxConstructorDecl(
71+
optionally(hasDescendant(MoveCallMatcher))),
72+
functionDecl(unless(cxxConstructorDecl()),
73+
optionally(hasBody(
74+
hasDescendant(MoveCallMatcher))))))
75+
.bind("func"))),
7276
this);
7377
}
7478

7579
void RvalueReferenceParamNotMovedCheck::check(
7680
const MatchFinder::MatchResult &Result) {
7781
const auto *Param = Result.Nodes.getNodeAs<ParmVarDecl>("param");
82+
const auto *Function = Result.Nodes.getNodeAs<FunctionDecl>("func");
7883
const auto *TemplateType =
7984
Result.Nodes.getNodeAs<TemplateTypeParmDecl>("template-type");
8085

81-
if (!Param)
86+
if (!Param || !Function)
8287
return;
8388

8489
if (IgnoreUnnamedParams && Param->getName().empty())
@@ -87,10 +92,6 @@ void RvalueReferenceParamNotMovedCheck::check(
8792
if (!Param->isUsed() && Param->hasAttr<UnusedAttr>())
8893
return;
8994

90-
const auto *Function = dyn_cast<FunctionDecl>(Param->getDeclContext());
91-
if (!Function)
92-
return;
93-
9495
if (IgnoreNonDeducedTemplateTypes && TemplateType)
9596
return;
9697

clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include "UnusedUsingDeclsCheck.h"
1010
#include "clang/AST/ASTContext.h"
11+
#include "clang/AST/Decl.h"
1112
#include "clang/ASTMatchers/ASTMatchFinder.h"
1213
#include "clang/Lex/Lexer.h"
1314

@@ -71,6 +72,10 @@ void UnusedUsingDeclsCheck::registerMatchers(MatchFinder *Finder) {
7172
templateArgument().bind("used")))),
7273
this);
7374
Finder->addMatcher(userDefinedLiteral().bind("used"), this);
75+
Finder->addMatcher(
76+
loc(elaboratedType(unless(hasQualifier(nestedNameSpecifier())),
77+
hasUnqualifiedDesugaredType(type().bind("usedType")))),
78+
this);
7479
// Cases where we can identify the UsingShadowDecl directly, rather than
7580
// just its target.
7681
// FIXME: cover more cases in this way, as the AST supports it.
@@ -145,6 +150,12 @@ void UnusedUsingDeclsCheck::check(const MatchFinder::MatchResult &Result) {
145150
return;
146151
}
147152

153+
if (const auto *T = Result.Nodes.getNodeAs<Type>("usedType")) {
154+
if (const auto *ND = T->getAsTagDecl())
155+
RemoveNamedDecl(ND);
156+
return;
157+
}
158+
148159
if (const auto *UsedShadow =
149160
Result.Nodes.getNodeAs<UsingShadowDecl>("usedShadow")) {
150161
removeFromFoundDecls(UsedShadow->getTargetDecl());

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,8 @@ Changes in existing checks
260260

261261
- Improved :doc:`cppcoreguidelines-rvalue-reference-param-not-moved
262262
<clang-tidy/checks/cppcoreguidelines/rvalue-reference-param-not-moved>` check
263-
to ignore unused parameters when they are marked as unused.
263+
to ignore unused parameters when they are marked as unused and parameters of
264+
deleted functions and constructors.
264265

265266
- Improved :doc:`llvm-namespace-comment
266267
<clang-tidy/checks/llvm/namespace-comment>` check to provide fixes for
@@ -290,6 +291,10 @@ Changes in existing checks
290291
<clang-tidy/checks/misc/redundant-expression>` check to ignore
291292
false-positives in unevaluated context (e.g., ``decltype``).
292293

294+
- Improved :doc:`misc-unused-using-decls
295+
<clang-tidy/checks/misc/unused-using-decls>` check to avoid false positive when
296+
using in elaborated type.
297+
293298
- Improved :doc:`modernize-avoid-bind
294299
<clang-tidy/checks/modernize/avoid-bind>` check to
295300
not emit a ``return`` for fixes when the function returns ``void``.

clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/rvalue-reference-param-not-moved.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,8 +334,7 @@ void instantiate_a_class_template() {
334334
withObjRef.never_moves(o);
335335
}
336336

337-
namespace gh68209
338-
{
337+
namespace gh68209 {
339338
void f1([[maybe_unused]] int&& x) {}
340339

341340
void f2(__attribute__((unused)) int&& x) {}
@@ -358,3 +357,13 @@ namespace gh68209
358357
void f8(__attribute__((unused)) int&& x) { x += 1; }
359358
// CHECK-MESSAGES: :[[@LINE-1]]:41: warning: rvalue reference parameter 'x' is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
360359
} // namespace gh68209
360+
361+
namespace gh69412 {
362+
struct S
363+
{
364+
S(const int&);
365+
S(int&&) = delete;
366+
367+
void foo(int&&) = delete;
368+
};
369+
} // namespace gh69412

clang-tools-extra/test/clang-tidy/checkers/misc/unused-using-decls.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,3 +213,12 @@ template <typename T, template <typename> class U> class Bar {};
213213
// We used to report Q unsued, because we only checked the first template
214214
// argument.
215215
Bar<int, Q> *bar;
216+
217+
namespace gh69714 {
218+
struct StructGH69714_1 {};
219+
struct StructGH69714_2 {};
220+
} // namespace gh69714
221+
using gh69714::StructGH69714_1;
222+
using gh69714::StructGH69714_2;
223+
struct StructGH69714_1 a;
224+
struct StructGH69714_2 *b;

clang/bindings/python/clang/cindex.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1403,6 +1403,8 @@ def __repr__(self):
14031403
CursorKind.STATIC_ASSERT = CursorKind(602)
14041404
# A friend declaration
14051405
CursorKind.FRIEND_DECL = CursorKind(603)
1406+
# A concept declaration
1407+
CursorKind.CONCEPT_DECL = CursorKind(604)
14061408

14071409
# A code completion overload candidate.
14081410
CursorKind.OVERLOAD_CANDIDATE = CursorKind(700)

clang/docs/ReleaseNotes.rst

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ C23 Feature Support
185185
- Clang now supports ``N3007 Type inference for object definitions``.
186186

187187
- Clang now supports ``<stdckdint.h>`` which defines several macros for performing
188-
checked integer arithmetic.
188+
checked integer arithmetic. It is also exposed in pre-C23 modes.
189189

190190
Non-comprehensive list of changes in this release
191191
-------------------------------------------------
@@ -348,6 +348,9 @@ Improvements to Clang's diagnostics
348348
| ~~~~~~~~~^~~~~~~~
349349
- Clang now always diagnoses when using non-standard layout types in ``offsetof`` .
350350
(`#64619: <https://github.com/llvm/llvm-project/issues/64619>`_)
351+
- Clang now diagnoses redefined defaulted constructor when redefined
352+
defaulted constructor with different exception specs.
353+
(`#69094: <https://github.com/llvm/llvm-project/issues/69094>`_)
351354
- Clang now diagnoses use of variable-length arrays in C++ by default (and
352355
under ``-Wall`` in GNU++ mode). This is an extension supported by Clang and
353356
GCC, but is very easy to accidentally use without realizing it's a
@@ -398,6 +401,10 @@ Improvements to Clang's diagnostics
398401
24 | return decltype(fun_ptr)( f_ptr /*comment*/);
399402
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
400403
404+
- ``-Wzero-as-null-pointer-constant`` diagnostic is no longer emitted when using ``__null``
405+
(or, more commonly, ``NULL`` when the platform defines it as ``__null``) to be more consistent
406+
with GCC.
407+
401408
Bug Fixes in This Version
402409
-------------------------
403410
- Fixed an issue where a class template specialization whose declaration is
@@ -629,6 +636,10 @@ Bug Fixes to C++ Support
629636
(`#46200 <https://github.com/llvm/llvm-project/issues/46200>`_)
630637
(`#57812 <https://github.com/llvm/llvm-project/issues/57812>`_)
631638

639+
- Fix bug where we were overriding zero-initialization of class members when
640+
default initializing a base class in a constant expression context. Fixes:
641+
(`#69890 <https://github.com/llvm/llvm-project/issues/69890>`_)
642+
632643
Bug Fixes to AST Handling
633644
^^^^^^^^^^^^^^^^^^^^^^^^^
634645
- Fixed an import failure of recursive friend class template.

clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,17 @@ class DataflowAnalysisContext {
129129
/// token.
130130
Atom joinFlowConditions(Atom FirstToken, Atom SecondToken);
131131

132-
/// Returns true if and only if the constraints of the flow condition
133-
/// identified by `Token` imply that `Val` is true.
134-
bool flowConditionImplies(Atom Token, const Formula &);
132+
/// Returns true if the constraints of the flow condition identified by
133+
/// `Token` imply that `F` is true.
134+
/// Returns false if the flow condition does not imply `F` or if the solver
135+
/// times out.
136+
bool flowConditionImplies(Atom Token, const Formula &F);
137+
138+
/// Returns true if the constraints of the flow condition identified by
139+
/// `Token` still allow `F` to be true.
140+
/// Returns false if the flow condition implies that `F` is false or if the
141+
/// solver times out.
142+
bool flowConditionAllows(Atom Token, const Formula &F);
135143

136144
/// Returns true if `Val1` is equivalent to `Val2`.
137145
/// Note: This function doesn't take into account constraints on `Val1` and
@@ -184,6 +192,12 @@ class DataflowAnalysisContext {
184192
addTransitiveFlowConditionConstraints(Atom Token,
185193
llvm::SetVector<const Formula *> &Out);
186194

195+
/// Returns true if the solver is able to prove that there is a satisfying
196+
/// assignment for `Constraints`.
197+
bool isSatisfiable(llvm::SetVector<const Formula *> Constraints) {
198+
return querySolver(std::move(Constraints)).getStatus() ==
199+
Solver::Result::Status::Satisfiable;
200+
}
187201

188202
/// Returns true if the solver is able to prove that there is no satisfying
189203
/// assignment for `Constraints`

clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -542,12 +542,29 @@ class Environment {
542542
Atom getFlowConditionToken() const { return FlowConditionToken; }
543543

544544
/// Record a fact that must be true if this point in the program is reached.
545-
void addToFlowCondition(const Formula &);
545+
void assume(const Formula &);
546+
547+
/// Deprecated synonym for `assume()`.
548+
void addToFlowCondition(const Formula &F) { assume(F); }
546549

547550
/// Returns true if the formula is always true when this point is reached.
548-
/// Returns false if the formula may be false, or if the flow condition isn't
549-
/// sufficiently precise to prove that it is true.
550-
bool flowConditionImplies(const Formula &) const;
551+
/// Returns false if the formula may be false (or the flow condition isn't
552+
/// sufficiently precise to prove that it is true) or if the solver times out.
553+
///
554+
/// Note that there is an asymmetry between this function and `allows()` in
555+
/// that they both return false if the solver times out. The assumption is
556+
/// that if `proves()` or `allows()` returns true, this will result in a
557+
/// diagnostic, and we want to bias towards false negatives in the case where
558+
/// the solver times out.
559+
bool proves(const Formula &) const;
560+
561+
/// Returns true if the formula may be true when this point is reached.
562+
/// Returns false if the formula is always false when this point is reached
563+
/// (or the flow condition is overly constraining) or if the solver times out.
564+
bool allows(const Formula &) const;
565+
566+
/// Deprecated synonym for `proves()`.
567+
bool flowConditionImplies(const Formula &F) const { return proves(F); }
551568

552569
/// Returns the `DeclContext` of the block being analysed, if any. Otherwise,
553570
/// returns null.

clang/include/clang/Basic/DiagnosticParseKinds.td

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1349,7 +1349,9 @@ def warn_omp_extra_tokens_at_eol : Warning<
13491349
"extra tokens at the end of '#pragma omp %0' are ignored">,
13501350
InGroup<ExtraTokens>;
13511351
def err_omp_multiple_step_or_linear_modifier : Error<
1352-
"multiple %select{'step size'|'linear modifier'}0 found in linear clause">;
1352+
"multiple %select{'step size'|'linear modifier'}0 found in linear clause">;
1353+
def err_omp_deprecate_old_syntax: Error<
1354+
"old syntax '%0' on '%1' clause was deprecated, use new syntax '%2'">;
13531355
def warn_pragma_expected_colon_r_paren : Warning<
13541356
"missing ':' or ')' after %0 - ignoring">, InGroup<IgnoredPragmas>;
13551357
def err_omp_unknown_directive : Error<

0 commit comments

Comments
 (0)