Skip to content

Commit d052f38

Browse files
authored
Merge branch 'main' into fix/fixit-unknown-attributes
2 parents 2a1010f + 2cb32e2 commit d052f38

File tree

312 files changed

+7827
-2511
lines changed

Some content is hidden

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

312 files changed

+7827
-2511
lines changed

clang-tools-extra/clang-doc/BitcodeReader.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,8 @@ static llvm::Error decodeRecord(const Record &R, AccessSpecifier &Field,
5454
case AS_none:
5555
Field = (AccessSpecifier)R[0];
5656
return llvm::Error::success();
57-
default:
58-
return llvm::createStringError(llvm::inconvertibleErrorCode(),
59-
"invalid value for AccessSpecifier");
6057
}
58+
llvm_unreachable("invalid value for AccessSpecifier");
6159
}
6260

6361
static llvm::Error decodeRecord(const Record &R, TagTypeKind &Field,

clang-tools-extra/clang-doc/BitcodeWriter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,7 @@ bool ClangDocBitcodeWriter::dispatchInfoForWrite(Info *I) {
664664
case InfoType::IT_typedef:
665665
emitBlock(*static_cast<clang::doc::TypedefInfo *>(I));
666666
break;
667-
default:
667+
case InfoType::IT_default:
668668
llvm::errs() << "Unexpected info, unable to write.\n";
669669
return true;
670670
}

clang-tools-extra/clang-doc/Representation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ mergeInfos(std::vector<std::unique_ptr<Info>> &Values) {
143143
return reduce<FunctionInfo>(Values);
144144
case InfoType::IT_typedef:
145145
return reduce<TypedefInfo>(Values);
146-
default:
146+
case InfoType::IT_default:
147147
return llvm::createStringError(llvm::inconvertibleErrorCode(),
148148
"unexpected info type");
149149
}

clang-tools-extra/clang-doc/Serialize.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,8 @@ std::string serialize(std::unique_ptr<Info> &I) {
388388
return serialize(*static_cast<EnumInfo *>(I.get()));
389389
case InfoType::IT_function:
390390
return serialize(*static_cast<FunctionInfo *>(I.get()));
391-
default:
391+
case InfoType::IT_typedef:
392+
case InfoType::IT_default:
392393
return "";
393394
}
394395
}
@@ -525,9 +526,13 @@ static std::unique_ptr<Info> makeAndInsertIntoParent(ChildType Child) {
525526
InsertChild(ParentRec->Children, std::forward<ChildType>(Child));
526527
return ParentRec;
527528
}
528-
default:
529-
llvm_unreachable("Invalid reference type for parent namespace");
529+
case InfoType::IT_default:
530+
case InfoType::IT_enum:
531+
case InfoType::IT_function:
532+
case InfoType::IT_typedef:
533+
break;
530534
}
535+
llvm_unreachable("Invalid reference type for parent namespace");
531536
}
532537

533538
// There are two uses for this function.

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

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -702,17 +702,16 @@ void NotNullTerminatedResultCheck::registerMatchers(MatchFinder *Finder) {
702702
return hasArgument(
703703
CC.LengthPos,
704704
allOf(
705-
anyOf(
706-
ignoringImpCasts(integerLiteral().bind(WrongLengthExprName)),
707-
allOf(unless(hasDefinition(SizeOfCharExpr)),
708-
allOf(CC.WithIncrease
709-
? ignoringImpCasts(hasDefinition(HasIncOp))
710-
: ignoringImpCasts(allOf(
711-
unless(hasDefinition(HasIncOp)),
712-
anyOf(hasDefinition(binaryOperator().bind(
713-
UnknownLengthName)),
714-
hasDefinition(anything())))),
715-
AnyOfWrongLengthInit))),
705+
anyOf(ignoringImpCasts(integerLiteral().bind(WrongLengthExprName)),
706+
allOf(unless(hasDefinition(SizeOfCharExpr)),
707+
allOf(CC.WithIncrease
708+
? ignoringImpCasts(hasDefinition(HasIncOp))
709+
: ignoringImpCasts(
710+
allOf(unless(hasDefinition(HasIncOp)),
711+
hasDefinition(optionally(
712+
binaryOperator().bind(
713+
UnknownLengthName))))),
714+
AnyOfWrongLengthInit))),
716715
expr().bind(LengthExprName)));
717716
};
718717

clang-tools-extra/clang-tidy/hicpp/ExceptionBaseclassCheck.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,12 @@ void ExceptionBaseclassCheck::registerMatchers(MatchFinder *Finder) {
2424
isSameOrDerivedFrom(hasName("::std::exception")))))))))),
2525
// This condition is always true, but will bind to the
2626
// template value if the thrown type is templated.
27-
anyOf(has(expr(
28-
hasType(substTemplateTypeParmType().bind("templ_type")))),
29-
anything()),
27+
optionally(has(
28+
expr(hasType(substTemplateTypeParmType().bind("templ_type"))))),
3029
// Bind to the declaration of the type of the value that
31-
// is thrown. 'anything()' is necessary to always succeed
32-
// in the 'eachOf' because builtin types are not
33-
// 'namedDecl'.
34-
eachOf(has(expr(hasType(namedDecl().bind("decl")))), anything()))
30+
// is thrown. 'optionally' is necessary because builtin types
31+
// are not 'namedDecl'.
32+
optionally(has(expr(hasType(namedDecl().bind("decl"))))))
3533
.bind("bad_throw"),
3634
this);
3735
}

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

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ void StaticAssertCheck::registerMatchers(MatchFinder *Finder) {
3838
binaryOperator(
3939
hasAnyOperatorName("&&", "=="),
4040
hasEitherOperand(ignoringImpCasts(stringLiteral().bind("assertMSG"))),
41-
anyOf(binaryOperator(hasEitherOperand(IsAlwaysFalseWithCast)),
42-
anything()))
41+
optionally(binaryOperator(hasEitherOperand(IsAlwaysFalseWithCast))))
4342
.bind("assertExprRoot"),
4443
IsAlwaysFalse);
4544
auto NonConstexprFunctionCall =
@@ -52,12 +51,10 @@ void StaticAssertCheck::registerMatchers(MatchFinder *Finder) {
5251
auto NonConstexprCode =
5352
expr(anyOf(NonConstexprFunctionCall, NonConstexprVariableReference));
5453
auto AssertCondition =
55-
expr(
56-
anyOf(expr(ignoringParenCasts(anyOf(
57-
AssertExprRoot, unaryOperator(hasUnaryOperand(
58-
ignoringParenCasts(AssertExprRoot)))))),
59-
anything()),
60-
unless(NonConstexprCode), unless(hasDescendant(NonConstexprCode)))
54+
expr(optionally(expr(ignoringParenCasts(anyOf(
55+
AssertExprRoot, unaryOperator(hasUnaryOperand(
56+
ignoringParenCasts(AssertExprRoot))))))),
57+
unless(NonConstexprCode), unless(hasDescendant(NonConstexprCode)))
6158
.bind("condition");
6259
auto Condition =
6360
anyOf(ignoringParenImpCasts(callExpr(

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

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,12 @@ void UseBoolLiteralsCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
2626

2727
void UseBoolLiteralsCheck::registerMatchers(MatchFinder *Finder) {
2828
Finder->addMatcher(
29-
traverse(
30-
TK_AsIs,
31-
implicitCastExpr(
32-
has(ignoringParenImpCasts(integerLiteral().bind("literal"))),
33-
hasImplicitDestinationType(qualType(booleanType())),
34-
unless(isInTemplateInstantiation()),
35-
anyOf(hasParent(explicitCastExpr().bind("cast")), anything()))),
29+
traverse(TK_AsIs,
30+
implicitCastExpr(
31+
has(ignoringParenImpCasts(integerLiteral().bind("literal"))),
32+
hasImplicitDestinationType(qualType(booleanType())),
33+
unless(isInTemplateInstantiation()),
34+
optionally(hasParent(explicitCastExpr().bind("cast"))))),
3635
this);
3736

3837
Finder->addMatcher(

clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,8 +348,8 @@ void ImplicitBoolConversionCheck::registerMatchers(MatchFinder *Finder) {
348348
implicitCastExpr().bind("implicitCastFromBool"),
349349
unless(hasParent(BitfieldConstruct)),
350350
// Check also for nested casts, for example: bool -> int -> float.
351-
anyOf(hasParent(implicitCastExpr().bind("furtherImplicitCast")),
352-
anything()),
351+
optionally(
352+
hasParent(implicitCastExpr().bind("furtherImplicitCast"))),
353353
unless(isInTemplateInstantiation()),
354354
unless(IsInCompilerGeneratedFunction))),
355355
this);

clang-tools-extra/clangd/unittests/XRefsTests.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2311,6 +2311,14 @@ TEST(FindReferences, WithinAST) {
23112311
$(S::deleteObject)[[de^lete]] S;
23122312
}
23132313
};
2314+
)cpp",
2315+
// Array designators
2316+
R"cpp(
2317+
const int $def[[F^oo]] = 0;
2318+
int Bar[] = {
2319+
[$(Bar)[[F^oo]]...$(Bar)[[Fo^o]] + 1] = 0,
2320+
[$(Bar)[[^Foo]] + 2] = 1
2321+
};
23142322
)cpp"};
23152323
for (const char *Test : Tests)
23162324
checkFindRefs(Test);

0 commit comments

Comments
 (0)