[clang-tidy][NFC] Remove redundant braces with clang-format 'RemoveBracesLLVM' (2/N) (#172751)
This commit is contained in:
parent
f196b1d66f
commit
b0ef56de79
@ -49,23 +49,20 @@ static std::string createReplacementText(const LambdaExpr *Lambda) {
|
||||
llvm::raw_string_ostream Stream(Replacement);
|
||||
|
||||
auto AppendName = [&](llvm::StringRef Name) {
|
||||
if (!Replacement.empty()) {
|
||||
if (!Replacement.empty())
|
||||
Stream << ", ";
|
||||
}
|
||||
if (Lambda->getCaptureDefault() == LCD_ByRef && Name != "this") {
|
||||
if (Lambda->getCaptureDefault() == LCD_ByRef && Name != "this")
|
||||
Stream << "&" << Name;
|
||||
} else {
|
||||
else
|
||||
Stream << Name;
|
||||
}
|
||||
};
|
||||
|
||||
for (const LambdaCapture &Capture : Lambda->implicit_captures()) {
|
||||
assert(Capture.isImplicit());
|
||||
if (Capture.capturesVariable() && Capture.isImplicit()) {
|
||||
if (Capture.capturesVariable() && Capture.isImplicit())
|
||||
AppendName(Capture.getCapturedVar()->getName());
|
||||
} else if (Capture.capturesThis()) {
|
||||
else if (Capture.capturesThis())
|
||||
AppendName("this");
|
||||
}
|
||||
}
|
||||
if (!Replacement.empty() && !Lambda->explicit_captures().empty()) {
|
||||
// Add back separator if we are adding explicit capture variables.
|
||||
|
||||
@ -103,10 +103,9 @@ static std::string
|
||||
toCommaSeparatedString(const R &OrderedDecls,
|
||||
const SmallPtrSetImpl<const T *> &DeclsToInit) {
|
||||
SmallVector<StringRef, 16> Names;
|
||||
for (const T *Decl : OrderedDecls) {
|
||||
for (const T *Decl : OrderedDecls)
|
||||
if (DeclsToInit.contains(Decl))
|
||||
Names.emplace_back(getName(Decl));
|
||||
}
|
||||
return llvm::join(Names.begin(), Names.end(), ", ");
|
||||
}
|
||||
|
||||
@ -254,9 +253,8 @@ getInitializationsInOrder(const CXXRecordDecl &ClassDecl,
|
||||
Decls.clear();
|
||||
for (const auto &Base : ClassDecl.bases()) {
|
||||
// Decl may be null if the base class is a template parameter.
|
||||
if (const NamedDecl *Decl = getCanonicalRecordDecl(Base.getType())) {
|
||||
if (const NamedDecl *Decl = getCanonicalRecordDecl(Base.getType()))
|
||||
Decls.emplace_back(Decl);
|
||||
}
|
||||
}
|
||||
forEachField(ClassDecl, ClassDecl.fields(),
|
||||
[&](const FieldDecl *F) { Decls.push_back(F); });
|
||||
@ -377,9 +375,8 @@ static bool isIncompleteOrZeroLengthArrayType(const ASTContext &Context,
|
||||
}
|
||||
|
||||
static bool isEmpty(const ASTContext &Context, const QualType &Type) {
|
||||
if (const CXXRecordDecl *ClassDecl = Type->getAsCXXRecordDecl()) {
|
||||
if (const CXXRecordDecl *ClassDecl = Type->getAsCXXRecordDecl())
|
||||
return ClassDecl->isEmpty();
|
||||
}
|
||||
return isIncompleteOrZeroLengthArrayType(Context, Type);
|
||||
}
|
||||
|
||||
@ -570,10 +567,9 @@ void ProTypeMemberInitCheck::checkMissingBaseClassInitializer(
|
||||
if (Ctor->isImplicit())
|
||||
return;
|
||||
|
||||
for (const CXXCtorInitializer *Init : Ctor->inits()) {
|
||||
for (const CXXCtorInitializer *Init : Ctor->inits())
|
||||
if (Init->isBaseInitializer() && Init->isWritten())
|
||||
BasesToInit.erase(Init->getBaseClass()->getAsCXXRecordDecl());
|
||||
}
|
||||
}
|
||||
|
||||
if (BasesToInit.empty())
|
||||
|
||||
@ -120,9 +120,8 @@ public:
|
||||
|
||||
void MacroExpands(const Token &MacroNameTok, const MacroDefinition &MD,
|
||||
SourceRange Range, const MacroArgs *Args) override {
|
||||
if (MacroNameTok.getIdentifierInfo()->getName() == "va_arg") {
|
||||
if (MacroNameTok.getIdentifierInfo()->getName() == "va_arg")
|
||||
Check->diag(MacroNameTok.getLocation(), VaArgWarningMessage);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
@ -182,9 +181,8 @@ void ProTypeVarargCheck::check(const MatchFinder::MatchResult &Result) {
|
||||
diag(Matched->getExprLoc(), "do not call c-style vararg functions");
|
||||
}
|
||||
|
||||
if (const auto *Matched = Result.Nodes.getNodeAs<Expr>("va_use")) {
|
||||
if (const auto *Matched = Result.Nodes.getNodeAs<Expr>("va_use"))
|
||||
diag(Matched->getExprLoc(), VaArgWarningMessage);
|
||||
}
|
||||
|
||||
if (const auto *Matched = Result.Nodes.getNodeAs<VarDecl>("va_list")) {
|
||||
auto SR = Matched->getSourceRange();
|
||||
|
||||
@ -29,9 +29,8 @@ AST_MATCHER_P(LambdaExpr, valueCapturesVar, DeclarationMatcher, VarMatcher) {
|
||||
}
|
||||
AST_MATCHER_P2(Stmt, argumentOf, bool, AllowPartialMove, StatementMatcher,
|
||||
Ref) {
|
||||
if (AllowPartialMove) {
|
||||
if (AllowPartialMove)
|
||||
return stmt(anyOf(Ref, hasDescendant(Ref))).matches(Node, Finder, Builder);
|
||||
}
|
||||
return Ref.matches(Node, Finder, Builder);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
@ -109,12 +109,10 @@ join(ArrayRef<SpecialMemberFunctionsCheck::SpecialMemberFunctionKind> SMFS,
|
||||
|
||||
Stream << toString(SMFS[0]);
|
||||
const size_t LastIndex = SMFS.size() - 1;
|
||||
for (size_t I = 1; I < LastIndex; ++I) {
|
||||
for (size_t I = 1; I < LastIndex; ++I)
|
||||
Stream << ", " << toString(SMFS[I]);
|
||||
}
|
||||
if (LastIndex != 0) {
|
||||
if (LastIndex != 0)
|
||||
Stream << AndOr << toString(SMFS[LastIndex]);
|
||||
}
|
||||
return Stream.str();
|
||||
}
|
||||
|
||||
@ -160,9 +158,8 @@ void SpecialMemberFunctionsCheck::check(
|
||||
}
|
||||
|
||||
void SpecialMemberFunctionsCheck::onEndOfTranslationUnit() {
|
||||
for (const auto &C : ClassWithSpecialMembers) {
|
||||
for (const auto &C : ClassWithSpecialMembers)
|
||||
checkForMissingMembers(C.first, C.second);
|
||||
}
|
||||
}
|
||||
|
||||
void SpecialMemberFunctionsCheck::checkForMissingMembers(
|
||||
@ -238,10 +235,9 @@ void SpecialMemberFunctionsCheck::checkForMissingMembers(
|
||||
|
||||
if (!MissingMembers.empty()) {
|
||||
llvm::SmallVector<SpecialMemberFunctionKind, 5> DefinedMemberKinds;
|
||||
for (const auto &Data : DefinedMembers) {
|
||||
for (const auto &Data : DefinedMembers)
|
||||
if (!Data.IsImplicit)
|
||||
DefinedMemberKinds.push_back(Data.FunctionKind);
|
||||
}
|
||||
diag(ID.first, "class '%0' defines %1 but does not define %2")
|
||||
<< ID.second << cppcoreguidelines::join(DefinedMemberKinds, " and ")
|
||||
<< cppcoreguidelines::join(MissingMembers, " or ");
|
||||
|
||||
@ -37,10 +37,9 @@ static bool isMessageExpressionInsideMacro(const ObjCMessageExpr *Expr) {
|
||||
// if one is found and has not been marked unavailable.
|
||||
static bool isInitMethodAvailable(const ObjCInterfaceDecl *ClassDecl) {
|
||||
while (ClassDecl != nullptr) {
|
||||
for (const auto *MethodDecl : ClassDecl->instance_methods()) {
|
||||
for (const auto *MethodDecl : ClassDecl->instance_methods())
|
||||
if (MethodDecl->getSelector().getAsString() == "init")
|
||||
return !MethodDecl->isUnavailable();
|
||||
}
|
||||
ClassDecl = ClassDecl->getSuperClass();
|
||||
}
|
||||
|
||||
|
||||
@ -23,7 +23,7 @@ static const llvm::StringRef RenameCaseToSuiteMessage =
|
||||
|
||||
static std::optional<llvm::StringRef>
|
||||
getNewMacroName(llvm::StringRef MacroName) {
|
||||
std::pair<llvm::StringRef, llvm::StringRef> ReplacementMap[] = {
|
||||
static const llvm::StringMap<llvm::StringRef> ReplacementMap = {
|
||||
{"TYPED_TEST_CASE", "TYPED_TEST_SUITE"},
|
||||
{"TYPED_TEST_CASE_P", "TYPED_TEST_SUITE_P"},
|
||||
{"REGISTER_TYPED_TEST_CASE_P", "REGISTER_TYPED_TEST_SUITE_P"},
|
||||
@ -31,11 +31,9 @@ getNewMacroName(llvm::StringRef MacroName) {
|
||||
{"INSTANTIATE_TEST_CASE_P", "INSTANTIATE_TEST_SUITE_P"},
|
||||
};
|
||||
|
||||
for (auto &Mapping : ReplacementMap) {
|
||||
if (MacroName == Mapping.first)
|
||||
return Mapping.second;
|
||||
}
|
||||
|
||||
if (const auto MappingIt = ReplacementMap.find(MacroName);
|
||||
MappingIt != ReplacementMap.end())
|
||||
return MappingIt->second;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
@ -204,7 +202,7 @@ void UpgradeGoogletestCaseCheck::registerMatchers(MatchFinder *Finder) {
|
||||
}
|
||||
|
||||
static llvm::StringRef getNewMethodName(llvm::StringRef CurrentName) {
|
||||
std::pair<llvm::StringRef, llvm::StringRef> ReplacementMap[] = {
|
||||
static const llvm::StringMap<llvm::StringRef> ReplacementMap = {
|
||||
{"SetUpTestCase", "SetUpTestSuite"},
|
||||
{"TearDownTestCase", "TearDownTestSuite"},
|
||||
{"test_case_name", "test_suite_name"},
|
||||
@ -217,10 +215,9 @@ static llvm::StringRef getNewMethodName(llvm::StringRef CurrentName) {
|
||||
{"test_case_to_run_count", "test_suite_to_run_count"},
|
||||
{"GetTestCase", "GetTestSuite"}};
|
||||
|
||||
for (auto &Mapping : ReplacementMap) {
|
||||
if (CurrentName == Mapping.first)
|
||||
return Mapping.second;
|
||||
}
|
||||
if (const auto MappingIt = ReplacementMap.find(CurrentName);
|
||||
MappingIt != ReplacementMap.end())
|
||||
return MappingIt->second;
|
||||
|
||||
llvm_unreachable("Unexpected function name");
|
||||
}
|
||||
|
||||
@ -57,9 +57,8 @@ static EditGenerator rewrite(RangeSelector Call, RangeSelector Builder) {
|
||||
};
|
||||
std::optional<Token> LessToken =
|
||||
clang::Lexer::findNextToken(Begin, SM, LangOpts);
|
||||
while (LessToken && LessToken->getKind() != clang::tok::less) {
|
||||
while (LessToken && LessToken->getKind() != clang::tok::less)
|
||||
LessToken = NextToken(LessToken);
|
||||
}
|
||||
if (!LessToken) {
|
||||
return llvm::make_error<llvm::StringError>(llvm::errc::invalid_argument,
|
||||
"missing '<' token");
|
||||
|
||||
@ -50,9 +50,8 @@ utils::UseRangesCheck::ReplacerMap UseRangesCheck::getReplacerMap() const {
|
||||
const auto AddStdToLLVM =
|
||||
[&Results](llvm::IntrusiveRefCntPtr<Replacer> Replacer,
|
||||
std::initializer_list<StringRef> Names) {
|
||||
for (const auto &Name : Names) {
|
||||
for (const auto &Name : Names)
|
||||
Results.try_emplace(("::std::" + Name).str(), Replacer);
|
||||
}
|
||||
};
|
||||
|
||||
// Single range algorithms
|
||||
|
||||
@ -162,16 +162,14 @@ void ConfusableIdentifierCheck::check(
|
||||
cast<Decl>(ND->getDeclContext()->getNonTransparentContext()));
|
||||
|
||||
// Associate template parameters with this declaration of this template.
|
||||
if (const auto *TD = dyn_cast<TemplateDecl>(ND)) {
|
||||
if (const auto *TD = dyn_cast<TemplateDecl>(ND))
|
||||
for (const NamedDecl *Param : *TD->getTemplateParameters())
|
||||
addDeclToCheck(Param, TD->getTemplatedDecl());
|
||||
}
|
||||
|
||||
// Associate function parameters with this declaration of this function.
|
||||
if (const auto *FD = dyn_cast<FunctionDecl>(ND)) {
|
||||
if (const auto *FD = dyn_cast<FunctionDecl>(ND))
|
||||
for (const NamedDecl *Param : FD->parameters())
|
||||
addDeclToCheck(Param, ND);
|
||||
}
|
||||
}
|
||||
|
||||
void ConfusableIdentifierCheck::addDeclToCheck(const NamedDecl *ND,
|
||||
@ -193,23 +191,19 @@ void ConfusableIdentifierCheck::addDeclToCheck(const NamedDecl *ND,
|
||||
void ConfusableIdentifierCheck::onEndOfTranslationUnit() {
|
||||
llvm::StringMap<llvm::SmallVector<const IdentifierInfo *, 1>> SkeletonToNames;
|
||||
// Compute the skeleton for each identifier.
|
||||
for (auto &[Ident, Decls] : NameToDecls) {
|
||||
for (auto &[Ident, Decls] : NameToDecls)
|
||||
SkeletonToNames[skeleton(Ident->getName())].push_back(Ident);
|
||||
}
|
||||
|
||||
// Visit each skeleton with more than one identifier.
|
||||
for (auto &[Skel, Idents] : SkeletonToNames) {
|
||||
if (Idents.size() < 2) {
|
||||
if (Idents.size() < 2)
|
||||
continue;
|
||||
}
|
||||
|
||||
// Find the declaration contexts that transitively contain each identifier.
|
||||
DeclsWithinContextMap DeclsWithinContext;
|
||||
for (const IdentifierInfo *II : Idents) {
|
||||
for (auto [ND, Parent] : NameToDecls[II]) {
|
||||
for (const IdentifierInfo *II : Idents)
|
||||
for (auto [ND, Parent] : NameToDecls[II])
|
||||
addToEnclosingContexts(DeclsWithinContext, Parent, ND);
|
||||
}
|
||||
}
|
||||
|
||||
// Check to see if any declaration is declared in a context that
|
||||
// transitively contains another declaration with a different identifier but
|
||||
|
||||
@ -35,10 +35,9 @@ public:
|
||||
const std::vector<StringRef> &IgnoredFilesList)
|
||||
: Check(Check), SM(SM) {
|
||||
IgnoredFilesRegexes.reserve(IgnoredFilesList.size());
|
||||
for (const StringRef &It : IgnoredFilesList) {
|
||||
for (const StringRef &It : IgnoredFilesList)
|
||||
if (!It.empty())
|
||||
IgnoredFilesRegexes.emplace_back(It);
|
||||
}
|
||||
}
|
||||
|
||||
void FileChanged(SourceLocation Loc, FileChangeReason Reason,
|
||||
|
||||
@ -1398,10 +1398,9 @@ void RedundantExpressionCheck::check(const MatchFinder::MatchResult &Result) {
|
||||
: "operator has equivalent nested operands";
|
||||
|
||||
const auto Diag = diag(Op->getExprLoc(), Message);
|
||||
for (const auto &KeyValue : Result.Nodes.getMap()) {
|
||||
for (const auto &KeyValue : Result.Nodes.getMap())
|
||||
if (StringRef(KeyValue.first).starts_with("duplicate"))
|
||||
Diag << KeyValue.second.getSourceRange();
|
||||
}
|
||||
}
|
||||
|
||||
if (const auto *NegateOperator =
|
||||
|
||||
@ -159,12 +159,11 @@ SourceLocation StaticAssertCheck::getLastParenLoc(const ASTContext *ASTCtx,
|
||||
return {};
|
||||
|
||||
unsigned int ParenCount = 1;
|
||||
while (ParenCount && !Lexer.LexFromRawLexer(Token)) {
|
||||
while (ParenCount && !Lexer.LexFromRawLexer(Token))
|
||||
if (Token.is(tok::l_paren))
|
||||
++ParenCount;
|
||||
else if (Token.is(tok::r_paren))
|
||||
--ParenCount;
|
||||
}
|
||||
|
||||
return Token.getLocation();
|
||||
}
|
||||
|
||||
@ -77,9 +77,8 @@ void ThrowByValueCatchByReferenceCheck::diagnoseThrowLocations(
|
||||
return;
|
||||
// If it's a variable from a catch statement, we return as well.
|
||||
auto *DeclRef = dyn_cast<DeclRefExpr>(Inner);
|
||||
if (DeclRef && isCatchVariable(DeclRef)) {
|
||||
if (DeclRef && isCatchVariable(DeclRef))
|
||||
return;
|
||||
}
|
||||
diag(SubExpr->getBeginLoc(), "throw expression throws a pointer; it should "
|
||||
"throw a non-pointer value instead");
|
||||
}
|
||||
|
||||
@ -148,9 +148,8 @@ void UnusedParametersCheck::warnOnUnusedParameter(
|
||||
return;
|
||||
auto MyDiag = diag(Param->getLocation(), "parameter %0 is unused") << Param;
|
||||
|
||||
if (!Indexer) {
|
||||
if (!Indexer)
|
||||
Indexer = std::make_unique<IndexerVisitor>(*Result.Context);
|
||||
}
|
||||
|
||||
// Cannot remove parameter for non-local functions.
|
||||
if (Function->isExternallyVisible() ||
|
||||
|
||||
@ -161,9 +161,8 @@ void UnusedUsingDeclsCheck::check(const MatchFinder::MatchResult &Result) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Used->getKind() == TemplateArgument::Declaration) {
|
||||
if (Used->getKind() == TemplateArgument::Declaration)
|
||||
RemoveNamedDecl(Used->getAsDecl());
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@ -173,10 +172,9 @@ void UnusedUsingDeclsCheck::check(const MatchFinder::MatchResult &Result) {
|
||||
}
|
||||
// Check the uninstantiated template function usage.
|
||||
if (const auto *ULE = Result.Nodes.getNodeAs<UnresolvedLookupExpr>("used")) {
|
||||
for (const NamedDecl *ND : ULE->decls()) {
|
||||
for (const NamedDecl *ND : ULE->decls())
|
||||
if (const auto *USD = dyn_cast<UsingShadowDecl>(ND))
|
||||
removeFromFoundDecls(USD->getTargetDecl()->getCanonicalDecl());
|
||||
}
|
||||
return;
|
||||
}
|
||||
// Check user-defined literals
|
||||
|
||||
@ -112,11 +112,10 @@ void BufferDerefCheck::checkBuffers(ArrayRef<const Type *> BufferTypes,
|
||||
for (auto It = Indirections.rbegin(); It != Indirections.rend(); ++It) {
|
||||
if (!IndirectionDesc.empty())
|
||||
IndirectionDesc += "->";
|
||||
if (*It == IndirectionType::Pointer) {
|
||||
if (*It == IndirectionType::Pointer)
|
||||
IndirectionDesc += "pointer";
|
||||
} else {
|
||||
else
|
||||
IndirectionDesc += "array";
|
||||
}
|
||||
}
|
||||
|
||||
const auto Loc = BufferExprs[I]->getSourceRange().getBegin();
|
||||
|
||||
@ -51,9 +51,8 @@ void NSDateFormatterCheck::check(const MatchFinder::MatchResult &Result) {
|
||||
const StringLiteral *SL = cast<ObjCStringLiteral>(StrExpr)->getString();
|
||||
const StringRef SR = SL->getString();
|
||||
|
||||
if (!isValidDatePattern(SR)) {
|
||||
if (!isValidDatePattern(SR))
|
||||
diag(StrExpr->getExprLoc(), "invalid date format specifier");
|
||||
}
|
||||
|
||||
if (SR.contains('y') && SR.contains('w') && !SR.contains('Y')) {
|
||||
diag(StrExpr->getExprLoc(),
|
||||
|
||||
@ -88,9 +88,8 @@ static bool prefixedPropertyNameValid(llvm::StringRef PropertyName) {
|
||||
const size_t Start = PropertyName.find_first_of('_');
|
||||
assert(Start != llvm::StringRef::npos && Start + 1 < PropertyName.size());
|
||||
auto Prefix = PropertyName.substr(0, Start);
|
||||
if (Prefix.lower() != Prefix) {
|
||||
if (Prefix.lower() != Prefix)
|
||||
return false;
|
||||
}
|
||||
auto RegexExp = llvm::Regex(llvm::StringRef(validPropertyNameRegex(false)));
|
||||
return RegexExp.match(PropertyName.substr(Start + 1));
|
||||
}
|
||||
|
||||
@ -39,25 +39,21 @@ const std::uint64_t Max32 = std::numeric_limits<std::int32_t>::max();
|
||||
static std::pair<const char *, std::uint32_t>
|
||||
getNewType(std::size_t Size, std::uint64_t Min, std::uint64_t Max) noexcept {
|
||||
if (Min) {
|
||||
if (Min <= Min8 && Max <= Max8) {
|
||||
if (Min <= Min8 && Max <= Max8)
|
||||
return {"std::int8_t", sizeof(std::int8_t)};
|
||||
}
|
||||
|
||||
if (Min <= Min16 && Max <= Max16 && Size > sizeof(std::int16_t)) {
|
||||
if (Min <= Min16 && Max <= Max16 && Size > sizeof(std::int16_t))
|
||||
return {"std::int16_t", sizeof(std::int16_t)};
|
||||
}
|
||||
|
||||
if (Min <= Min32 && Max <= Max32 && Size > sizeof(std::int32_t)) {
|
||||
if (Min <= Min32 && Max <= Max32 && Size > sizeof(std::int32_t))
|
||||
return {"std::int32_t", sizeof(std::int32_t)};
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
if (Max) {
|
||||
if (Max <= std::numeric_limits<std::uint8_t>::max()) {
|
||||
if (Max <= std::numeric_limits<std::uint8_t>::max())
|
||||
return {"std::uint8_t", sizeof(std::uint8_t)};
|
||||
}
|
||||
|
||||
if (Max <= std::numeric_limits<std::uint16_t>::max() &&
|
||||
Size > sizeof(std::uint16_t)) {
|
||||
@ -115,11 +111,10 @@ void EnumSizeCheck::check(const MatchFinder::MatchResult &Result) {
|
||||
|
||||
for (const auto &It : MatchedDecl->enumerators()) {
|
||||
const llvm::APSInt &InitVal = It->getInitVal();
|
||||
if ((InitVal.isUnsigned() || InitVal.isNonNegative())) {
|
||||
if ((InitVal.isUnsigned() || InitVal.isNonNegative()))
|
||||
MaxV = std::max<std::uint64_t>(MaxV, InitVal.getZExtValue());
|
||||
} else {
|
||||
else
|
||||
MinV = std::max<std::uint64_t>(MinV, InitVal.abs().getZExtValue());
|
||||
}
|
||||
}
|
||||
|
||||
auto NewType = getNewType(Size, MinV, MaxV);
|
||||
|
||||
@ -135,10 +135,9 @@ void MoveConstArgCheck::check(const MatchFinder::MatchResult &Result) {
|
||||
if (R->isLambda())
|
||||
return;
|
||||
// Don't warn when the type is not copyable.
|
||||
for (const auto *Ctor : R->ctors()) {
|
||||
for (const auto *Ctor : R->ctors())
|
||||
if (Ctor->isCopyConstructor() && Ctor->isDeleted())
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!IsConstArg && IsTriviallyCopyable && !CheckTriviallyCopyableMove)
|
||||
|
||||
@ -19,9 +19,8 @@ namespace clang::tidy::performance {
|
||||
|
||||
namespace {
|
||||
AST_MATCHER_P(Type, isBuiltinType, BuiltinType::Kind, Kind) {
|
||||
if (const auto *BT = dyn_cast<BuiltinType>(&Node)) {
|
||||
if (const auto *BT = dyn_cast<BuiltinType>(&Node))
|
||||
return BT->getKind() == Kind;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
} // anonymous namespace
|
||||
|
||||
@ -43,9 +43,8 @@ static std::optional<SourceLocation> firstLocAfterNewLine(SourceLocation Loc,
|
||||
SourceManager &SM) {
|
||||
bool Invalid = false;
|
||||
const char *TextAfter = SM.getCharacterData(Loc, &Invalid);
|
||||
if (Invalid) {
|
||||
if (Invalid)
|
||||
return std::nullopt;
|
||||
}
|
||||
const size_t Offset = std::strcspn(TextAfter, "\n");
|
||||
return Loc.getLocWithOffset(TextAfter[Offset] == '\0' ? Offset : Offset + 1);
|
||||
}
|
||||
@ -160,9 +159,8 @@ static bool isInitializingVariableImmutable(
|
||||
|
||||
// The reference or pointer is not declared and hence not initialized anywhere
|
||||
// in the function. We assume its pointee is not modified then.
|
||||
if (!InitializingVar.isLocalVarDecl() || !InitializingVar.hasInit()) {
|
||||
if (!InitializingVar.isLocalVarDecl() || !InitializingVar.hasInit())
|
||||
return true;
|
||||
}
|
||||
|
||||
auto Matches =
|
||||
match(initializerReturnsReferenceToConst(ExcludedContainerTypes),
|
||||
@ -217,12 +215,10 @@ static bool differentReplacedTemplateParams(const QualType &VarType,
|
||||
|
||||
static QualType constructorArgumentType(const VarDecl *OldVar,
|
||||
const BoundNodes &Nodes) {
|
||||
if (OldVar) {
|
||||
if (OldVar)
|
||||
return OldVar->getType();
|
||||
}
|
||||
if (const auto *FuncDecl = Nodes.getNodeAs<FunctionDecl>(FunctionDeclId)) {
|
||||
if (const auto *FuncDecl = Nodes.getNodeAs<FunctionDecl>(FunctionDeclId))
|
||||
return FuncDecl->getReturnType();
|
||||
}
|
||||
const auto *MethodDecl = Nodes.getNodeAs<CXXMethodDecl>(MethodDeclId);
|
||||
return MethodDecl->getReturnType();
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user