Skip to content

Commit 7735d06

Browse files
authored
Merge branch 'main' into hliao/main/fix-cir-dependency
2 parents a26b77e + 3e6f618 commit 7735d06

File tree

183 files changed

+6614
-3430
lines changed

Some content is hidden

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

183 files changed

+6614
-3430
lines changed

.github/workflows/docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ jobs:
6565
fetch-depth: 1
6666
- name: Get subprojects that have doc changes
6767
id: docs-changed-subprojects
68-
uses: tj-actions/changed-files@dcc7a0cba800f454d79fff4b993e8c3555bcc0a8 # v45.0.7
68+
uses: step-security/changed-files@3dbe17c78367e7d60f00d78ae6781a35be47b4a1 # v45.0.1
6969
with:
7070
files_yaml: |
7171
llvm:

.github/workflows/pr-code-format.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232

3333
- name: Get changed files
3434
id: changed-files
35-
uses: tj-actions/changed-files@fea790cb660e33aef4bdf07304e28fedd77dfa13 # v39.2.4
35+
uses: step-security/changed-files@3dbe17c78367e7d60f00d78ae6781a35be47b4a1 # v45.0.1
3636
with:
3737
separator: ","
3838
skip_initial_fetch: true

clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,11 @@ static bool sameValue(const Expr *E1, const Expr *E2) {
176176
cast<StringLiteral>(E2)->getString();
177177
case Stmt::DeclRefExprClass:
178178
return cast<DeclRefExpr>(E1)->getDecl() == cast<DeclRefExpr>(E2)->getDecl();
179+
case Stmt::CStyleCastExprClass:
180+
case Stmt::CXXStaticCastExprClass:
181+
case Stmt::CXXFunctionalCastExprClass:
182+
return sameValue(cast<ExplicitCastExpr>(E1)->getSubExpr(),
183+
cast<ExplicitCastExpr>(E2)->getSubExpr());
179184
default:
180185
return false;
181186
}
@@ -206,10 +211,13 @@ void UseDefaultMemberInitCheck::registerMatchers(MatchFinder *Finder) {
206211
cxxBoolLiteral(), cxxNullPtrLiteralExpr(), implicitValueInitExpr(),
207212
declRefExpr(to(anyOf(enumConstantDecl(), ConstExpRef))));
208213

214+
auto ExplicitCastExpr = castExpr(hasSourceExpression(InitBase));
215+
auto InitMatcher = anyOf(InitBase, ExplicitCastExpr);
216+
209217
auto Init =
210-
anyOf(initListExpr(anyOf(allOf(initCountIs(1), hasInit(0, InitBase)),
218+
anyOf(initListExpr(anyOf(allOf(initCountIs(1), hasInit(0, InitMatcher)),
211219
initCountIs(0), hasType(arrayType()))),
212-
InitBase);
220+
InitBase, ExplicitCastExpr);
213221

214222
Finder->addMatcher(
215223
cxxConstructorDecl(forEachConstructorInitializer(

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,8 @@ Changes in existing checks
159159

160160
- Improved :doc:`modernize-use-default-member-init
161161
<clang-tidy/checks/modernize/use-default-member-init>` check by matching
162-
``constexpr`` and ``static`` values on member initialization.
162+
``constexpr`` and ``static``` values on member initialization and by detecting
163+
explicit casting of built-in types within member list initialization.
163164

164165
- Improved :doc:`modernize-use-ranges
165166
<clang-tidy/checks/modernize/use-ranges>` check by updating suppress

clang-tools-extra/test/clang-tidy/checkers/modernize/use-default-member-init.cpp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,4 +536,40 @@ namespace PR122480 {
536536
// CHECK-FIXES: int b{STATIC_VAL};
537537
};
538538

539+
class CStyleCastInit {
540+
CStyleCastInit() : a{(int)1.23}, b{(float)42}, c{(double)'C'} {}
541+
// CHECK-MESSAGES: :[[@LINE-1]]:50: warning: member initializer for 'c' is redundant [modernize-use-default-member-init]
542+
// CHECK-FIXES: CStyleCastInit() {}
543+
544+
int a;
545+
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use default member initializer for 'a' [modernize-use-default-member-init]
546+
// CHECK-FIXES: int a{(int)1.23};
547+
float b;
548+
// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: use default member initializer for 'b' [modernize-use-default-member-init]
549+
// CHECK-FIXES: float b{(float)42};
550+
double c{(double)'C'};
551+
};
552+
553+
class StaticCastInit {
554+
StaticCastInit() : m(static_cast<int>(9.99)), n(static_cast<char>(65)) {}
555+
// CHECK-MESSAGES: :[[@LINE-1]]:49: warning: member initializer for 'n' is redundant [modernize-use-default-member-init]
556+
// CHECK-FIXES: StaticCastInit() {}
557+
int m;
558+
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use default member initializer for 'm' [modernize-use-default-member-init]
559+
// CHECK-FIXES: int m{static_cast<int>(9.99)};
560+
char n{static_cast<char>(65)};
561+
};
562+
563+
class FunctionalCastInit {
564+
FunctionalCastInit() : a(int(5.67)), b(float(2)), c(double('C')) {}
565+
// CHECK-MESSAGES: :[[@LINE-1]]:40: warning: member initializer for 'b' is redundant [modernize-use-default-member-init]
566+
int a;
567+
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use default member initializer for 'a' [modernize-use-default-member-init]
568+
// CHECK-FIXES: int a{int(5.67)};
569+
float b{float(2)};
570+
double c;
571+
// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use default member initializer for 'c' [modernize-use-default-member-init]
572+
// CHECK-FIXES: double c{double('C')};
573+
};
574+
539575
} //namespace PR122480

clang/docs/ReleaseNotes.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,9 @@ Bug Fixes in This Version
278278
considered an error in C23 mode and are allowed as an extension in earlier language modes.
279279

280280
- Remove the ``static`` specifier for the value of ``_FUNCTION_`` for static functions, in MSVC compatibility mode.
281+
- Fixed a modules crash where exception specifications were not propagated properly (#GH121245, relanded in #GH129982)
282+
- Fixed a problematic case with recursive deserialization within ``FinishedDeserializing()`` where
283+
``PassInterestingDeclsToConsumer()`` was called before the declarations were safe to be passed. (#GH129982)
281284

282285
Bug Fixes to Compiler Builtins
283286
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

clang/include/clang/Sema/Sema.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10755,11 +10755,6 @@ class Sema final : public SemaBase {
1075510755
SourceLocation EndLoc);
1075610756
void ActOnForEachDeclStmt(DeclGroupPtrTy Decl);
1075710757

10758-
/// DiagnoseDiscardedExprMarkedNodiscard - Given an expression that is
10759-
/// semantically a discarded-value expression, diagnose if any [[nodiscard]]
10760-
/// value has been discarded.
10761-
void DiagnoseDiscardedExprMarkedNodiscard(const Expr *E);
10762-
1076310758
/// DiagnoseUnusedExprResult - If the statement passed in is an expression
1076410759
/// whose result is unused, warn.
1076510760
void DiagnoseUnusedExprResult(const Stmt *S, unsigned DiagID);

clang/include/clang/Serialization/ASTReader.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1176,11 +1176,11 @@ class ASTReader
11761176
/// Number of Decl/types that are currently deserializing.
11771177
unsigned NumCurrentElementsDeserializing = 0;
11781178

1179-
/// Set true while we are in the process of passing deserialized
1180-
/// "interesting" decls to consumer inside FinishedDeserializing().
1181-
/// This is used as a guard to avoid recursively repeating the process of
1179+
/// Set false while we are in a state where we cannot safely pass deserialized
1180+
/// "interesting" decls to the consumer inside FinishedDeserializing().
1181+
/// This is used as a guard to avoid recursively entering the process of
11821182
/// passing decls to consumer.
1183-
bool PassingDeclsToConsumer = false;
1183+
bool CanPassDeclsToConsumer = true;
11841184

11851185
/// The set of identifiers that were read while the AST reader was
11861186
/// (recursively) loading declarations.

clang/lib/Sema/SemaExprMember.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1136,7 +1136,6 @@ Sema::BuildMemberReferenceExpr(Expr *BaseExpr, QualType BaseExprType,
11361136
if (Converted.isInvalid())
11371137
return true;
11381138
BaseExpr = Converted.get();
1139-
DiagnoseDiscardedExprMarkedNodiscard(BaseExpr);
11401139
return false;
11411140
};
11421141
auto ConvertBaseExprToGLValue = [&] {

clang/lib/Sema/SemaStmt.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -413,10 +413,6 @@ void DiagnoseUnused(Sema &S, const Expr *E, std::optional<unsigned> DiagID) {
413413
}
414414
} // namespace
415415

416-
void Sema::DiagnoseDiscardedExprMarkedNodiscard(const Expr *E) {
417-
DiagnoseUnused(*this, E, std::nullopt);
418-
}
419-
420416
void Sema::DiagnoseUnusedExprResult(const Stmt *S, unsigned DiagID) {
421417
if (const LabelStmt *Label = dyn_cast_if_present<LabelStmt>(S))
422418
S = Label->getSubStmt();

0 commit comments

Comments
 (0)