[clang-tools-extra] ec5f4be - [clang-tidy][NFC] Fix modernize-return-braced-init-list findings
Piotr Zegar via cfe-commits
cfe-commits at lists.llvm.org
Sun Aug 27 01:53:51 PDT 2023
Author: Piotr Zegar
Date: 2023-08-27T08:52:10Z
New Revision: ec5f4be4521c3b28d6bb14f34f39a87c36fe8c00
URL: https://github.com/llvm/llvm-project/commit/ec5f4be4521c3b28d6bb14f34f39a87c36fe8c00
DIFF: https://github.com/llvm/llvm-project/commit/ec5f4be4521c3b28d6bb14f34f39a87c36fe8c00.diff
LOG: [clang-tidy][NFC] Fix modernize-return-braced-init-list findings
Fix issues found by clang-tidy in clang-tidy source directory.
Added:
Modified:
clang-tools-extra/clang-tidy/ClangTidy.cpp
clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
clang-tools-extra/clang-tidy/ClangTidyModule.cpp
clang-tools-extra/clang-tidy/GlobList.cpp
clang-tools-extra/clang-tidy/abseil/DurationRewriter.cpp
clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.cpp
clang-tools-extra/clang-tidy/concurrency/MtUnsafeCheck.cpp
clang-tools-extra/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.h
clang-tools-extra/clang-tidy/google/ExplicitConstructorCheck.cpp
clang-tools-extra/clang-tidy/google/FunctionNamingCheck.cpp
clang-tools-extra/clang-tidy/google/GlobalVariableDeclarationCheck.cpp
clang-tools-extra/clang-tidy/misc/StaticAssertCheck.cpp
clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
clang-tools-extra/clang-tidy/modernize/UseConstraintsCheck.cpp
clang-tools-extra/clang-tidy/modernize/UseOverrideCheck.cpp
clang-tools-extra/clang-tidy/objc/PropertyDeclarationCheck.cpp
clang-tools-extra/clang-tidy/readability/AvoidConstParamsInDecls.cpp
clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp
clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp
clang-tools-extra/clang-tidy/readability/IsolateDeclarationCheck.cpp
clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.h
clang-tools-extra/clang-tidy/utils/FixItHintUtils.cpp
clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp
clang-tools-extra/clang-tidy/utils/LexerUtils.cpp
clang-tools-extra/clang-tidy/utils/LexerUtils.h
clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
Removed:
################################################################################
diff --git a/clang-tools-extra/clang-tidy/ClangTidy.cpp b/clang-tools-extra/clang-tidy/ClangTidy.cpp
index ca48388e85a99e..99f137879d7f93 100644
--- a/clang-tools-extra/clang-tidy/ClangTidy.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidy.cpp
@@ -242,11 +242,11 @@ class ErrorReporter {
private:
SourceLocation getLocation(StringRef FilePath, unsigned Offset) {
if (FilePath.empty())
- return SourceLocation();
+ return {};
auto File = SourceMgr.getFileManager().getFile(FilePath);
if (!File)
- return SourceLocation();
+ return {};
FileID ID = SourceMgr.getOrCreateFileID(*File, SrcMgr::C_User);
return SourceMgr.getLocForStartOfFile(ID).getLocWithOffset(Offset);
diff --git a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
index 962f7dc32de3e6..30b4bfbe387795 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
+++ b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
@@ -212,11 +212,11 @@ class ClangTidyContext {
using DiagLevelAndFormatString = std::pair<DiagnosticIDs::Level, std::string>;
DiagLevelAndFormatString getDiagLevelAndFormatString(unsigned DiagnosticID,
SourceLocation Loc) {
- return DiagLevelAndFormatString(
+ return {
static_cast<DiagnosticIDs::Level>(
DiagEngine->getDiagnosticLevel(DiagnosticID, Loc)),
std::string(
- DiagEngine->getDiagnosticIDs()->getDescription(DiagnosticID)));
+ DiagEngine->getDiagnosticIDs()->getDescription(DiagnosticID))};
}
void setOptionsCollector(llvm::StringSet<> *Collector) {
diff --git a/clang-tools-extra/clang-tidy/ClangTidyModule.cpp b/clang-tools-extra/clang-tidy/ClangTidyModule.cpp
index 8650e46b8833e6..7432229fda8007 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyModule.cpp
@@ -46,8 +46,6 @@ ClangTidyCheckFactories::createChecksForLanguage(
return Checks;
}
-ClangTidyOptions ClangTidyModule::getModuleOptions() {
- return ClangTidyOptions();
-}
+ClangTidyOptions ClangTidyModule::getModuleOptions() { return {}; }
} // namespace clang::tidy
diff --git a/clang-tools-extra/clang-tidy/GlobList.cpp b/clang-tools-extra/clang-tidy/GlobList.cpp
index acd08dd3ee08c4..1d5b3a882fa648 100644
--- a/clang-tools-extra/clang-tidy/GlobList.cpp
+++ b/clang-tools-extra/clang-tidy/GlobList.cpp
@@ -39,7 +39,7 @@ static llvm::Regex consumeGlob(StringRef &GlobList) {
RegexText.push_back(C);
}
RegexText.push_back('$');
- return llvm::Regex(RegexText);
+ return {RegexText};
}
GlobList::GlobList(StringRef Globs, bool KeepNegativeGlobs /* =true */) {
diff --git a/clang-tools-extra/clang-tidy/abseil/DurationRewriter.cpp b/clang-tools-extra/clang-tidy/abseil/DurationRewriter.cpp
index 2790a205d26804..bd317d0d264178 100644
--- a/clang-tools-extra/clang-tidy/abseil/DurationRewriter.cpp
+++ b/clang-tools-extra/clang-tidy/abseil/DurationRewriter.cpp
@@ -278,7 +278,7 @@ std::string rewriteExprFromNumberToDuration(
return *MaybeRewrite;
if (isLiteralZero(Result, RootNode))
- return std::string("absl::ZeroDuration()");
+ return {"absl::ZeroDuration()"};
return (llvm::Twine(getDurationFactoryForScale(Scale)) + "(" +
simplifyDurationFactoryArg(Result, RootNode) + ")")
@@ -296,7 +296,7 @@ std::string rewriteExprFromNumberToTime(
return *MaybeRewrite;
if (isLiteralZero(Result, RootNode))
- return std::string("absl::UnixEpoch()");
+ return {"absl::UnixEpoch()"};
return (llvm::Twine(getTimeFactoryForScale(Scale)) + "(" +
tooling::fixit::getText(RootNode, *Result.Context) + ")")
diff --git a/clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.cpp
index a0b2afdb131032..efa7dd66c816ea 100644
--- a/clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.cpp
@@ -235,7 +235,7 @@ struct OptionEnumMapping<
{bugprone::SignalHandlerCheck::AsyncSafeFunctionSetKind::POSIX,
"POSIX"},
};
- return ArrayRef(Mapping);
+ return {Mapping};
}
};
diff --git a/clang-tools-extra/clang-tidy/concurrency/MtUnsafeCheck.cpp b/clang-tools-extra/clang-tidy/concurrency/MtUnsafeCheck.cpp
index 93a19d2ab9aecf..acffaa30d418e0 100644
--- a/clang-tools-extra/clang-tidy/concurrency/MtUnsafeCheck.cpp
+++ b/clang-tools-extra/clang-tidy/concurrency/MtUnsafeCheck.cpp
@@ -269,7 +269,7 @@ template <> struct OptionEnumMapping<concurrency::MtUnsafeCheck::FunctionSet> {
Mapping[] = {{concurrency::MtUnsafeCheck::FunctionSet::Posix, "posix"},
{concurrency::MtUnsafeCheck::FunctionSet::Glibc, "glibc"},
{concurrency::MtUnsafeCheck::FunctionSet::Any, "any"}};
- return ArrayRef(Mapping);
+ return {Mapping};
}
};
diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.h b/clang-tools-extra/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.h
index c14219b85e9083..981a73a20611af 100644
--- a/clang-tools-extra/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.h
+++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.h
@@ -83,13 +83,13 @@ struct DenseMapInfo<
clang::tidy::cppcoreguidelines::SpecialMemberFunctionsCheck::ClassDefId;
static inline ClassDefId getEmptyKey() {
- return ClassDefId(DenseMapInfo<clang::SourceLocation>::getEmptyKey(),
- "EMPTY");
+ return {DenseMapInfo<clang::SourceLocation>::getEmptyKey(),
+ "EMPTY"};
}
static inline ClassDefId getTombstoneKey() {
- return ClassDefId(DenseMapInfo<clang::SourceLocation>::getTombstoneKey(),
- "TOMBSTONE");
+ return {DenseMapInfo<clang::SourceLocation>::getTombstoneKey(),
+ "TOMBSTONE"};
}
static unsigned getHashValue(ClassDefId Val) {
diff --git a/clang-tools-extra/clang-tidy/google/ExplicitConstructorCheck.cpp b/clang-tools-extra/clang-tidy/google/ExplicitConstructorCheck.cpp
index f6b7ebca525510..34d49af9f81e23 100644
--- a/clang-tools-extra/clang-tidy/google/ExplicitConstructorCheck.cpp
+++ b/clang-tools-extra/clang-tidy/google/ExplicitConstructorCheck.cpp
@@ -38,7 +38,7 @@ static SourceRange findToken(const SourceManager &Sources,
SourceLocation StartLoc, SourceLocation EndLoc,
bool (*Pred)(const Token &)) {
if (StartLoc.isMacroID() || EndLoc.isMacroID())
- return SourceRange();
+ return {};
FileID File = Sources.getFileID(Sources.getSpellingLoc(StartLoc));
StringRef Buf = Sources.getBufferData(File);
const char *StartChar = Sources.getCharacterData(StartLoc);
@@ -50,11 +50,11 @@ static SourceRange findToken(const SourceManager &Sources,
if (Pred(Tok)) {
Token NextTok;
Lex.LexFromRawLexer(NextTok);
- return SourceRange(Tok.getLocation(), NextTok.getLocation());
+ return {Tok.getLocation(), NextTok.getLocation()};
}
} while (Tok.isNot(tok::eof) && Tok.getLocation() < EndLoc);
- return SourceRange();
+ return {};
}
static bool declIsStdInitializerList(const NamedDecl *D) {
diff --git a/clang-tools-extra/clang-tidy/google/FunctionNamingCheck.cpp b/clang-tools-extra/clang-tidy/google/FunctionNamingCheck.cpp
index e42b4e9a1aeaf1..5cf256ea5c8478 100644
--- a/clang-tools-extra/clang-tidy/google/FunctionNamingCheck.cpp
+++ b/clang-tools-extra/clang-tidy/google/FunctionNamingCheck.cpp
@@ -49,7 +49,7 @@ FixItHint generateFixItHint(const FunctionDecl *Decl) {
// otherwise the check cannot determine the appropriate function name prefix
// to use.
if (Decl->getStorageClass() != SC_Static)
- return FixItHint();
+ return {};
StringRef Name = Decl->getName();
std::string NewName = Decl->getName().str();
@@ -80,7 +80,7 @@ FixItHint generateFixItHint(const FunctionDecl *Decl) {
CharSourceRange::getTokenRange(SourceRange(Decl->getLocation())),
llvm::StringRef(NewName));
- return FixItHint();
+ return {};
}
} // namespace
diff --git a/clang-tools-extra/clang-tidy/google/GlobalVariableDeclarationCheck.cpp b/clang-tools-extra/clang-tidy/google/GlobalVariableDeclarationCheck.cpp
index a2a728f3b309ec..04971907bc5be5 100644
--- a/clang-tools-extra/clang-tidy/google/GlobalVariableDeclarationCheck.cpp
+++ b/clang-tools-extra/clang-tidy/google/GlobalVariableDeclarationCheck.cpp
@@ -26,7 +26,7 @@ FixItHint generateFixItHint(const VarDecl *Decl, bool IsConst) {
if (IsConst && (Decl->getStorageClass() != SC_Static)) {
// No fix available if it is not a static constant, since it is
diff icult
// to determine the proper fix in this case.
- return FixItHint();
+ return {};
}
char FC = Decl->getName()[0];
@@ -35,14 +35,14 @@ FixItHint generateFixItHint(const VarDecl *Decl, bool IsConst) {
// is a single-character variable, since it is
diff icult to determine the
// proper fix in this case. Users should create a proper variable name by
// their own.
- return FixItHint();
+ return {};
}
char SC = Decl->getName()[1];
if ((FC == 'k' || FC == 'g') && !llvm::isAlpha(SC)) {
// No fix available if the prefix is correct but the second character is
// not alphabetical, since it is
diff icult to determine the proper fix in
// this case.
- return FixItHint();
+ return {};
}
auto NewName = (IsConst ? "k" : "g") +
diff --git a/clang-tools-extra/clang-tidy/misc/StaticAssertCheck.cpp b/clang-tools-extra/clang-tidy/misc/StaticAssertCheck.cpp
index a2fba6760a916e..77763a9f429f2b 100644
--- a/clang-tools-extra/clang-tidy/misc/StaticAssertCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/StaticAssertCheck.cpp
@@ -141,7 +141,7 @@ SourceLocation StaticAssertCheck::getLastParenLoc(const ASTContext *ASTCtx,
std::optional<llvm::MemoryBufferRef> Buffer =
SM.getBufferOrNone(SM.getFileID(AssertLoc));
if (!Buffer)
- return SourceLocation();
+ return {};
const char *BufferPos = SM.getCharacterData(AssertLoc);
@@ -152,7 +152,7 @@ SourceLocation StaticAssertCheck::getLastParenLoc(const ASTContext *ASTCtx,
// assert first left parenthesis
if (Lexer.LexFromRawLexer(Token) || Lexer.LexFromRawLexer(Token) ||
!Token.is(tok::l_paren))
- return SourceLocation();
+ return {};
unsigned int ParenCount = 1;
while (ParenCount && !Lexer.LexFromRawLexer(Token)) {
diff --git a/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp b/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
index c43d46b145a178..37aa26ded42407 100644
--- a/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
@@ -38,7 +38,7 @@ template <> struct OptionEnumMapping<modernize::Confidence::Level> {
Mapping[] = {{modernize::Confidence::CL_Reasonable, "reasonable"},
{modernize::Confidence::CL_Safe, "safe"},
{modernize::Confidence::CL_Risky, "risky"}};
- return ArrayRef(Mapping);
+ return {Mapping};
}
};
@@ -51,7 +51,7 @@ template <> struct OptionEnumMapping<modernize::VariableNamer::NamingStyle> {
{modernize::VariableNamer::NS_CamelBack, "camelBack"},
{modernize::VariableNamer::NS_LowerCase, "lower_case"},
{modernize::VariableNamer::NS_UpperCase, "UPPER_CASE"}};
- return ArrayRef(Mapping);
+ return {Mapping};
}
};
@@ -465,7 +465,7 @@ static StringRef getStringFromRange(SourceManager &SourceMgr,
SourceRange Range) {
if (SourceMgr.getFileID(Range.getBegin()) !=
SourceMgr.getFileID(Range.getEnd())) {
- return StringRef(); // Empty string.
+ return {}; // Empty string.
}
return Lexer::getSourceText(CharSourceRange(Range, true), SourceMgr,
diff --git a/clang-tools-extra/clang-tidy/modernize/UseConstraintsCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseConstraintsCheck.cpp
index 74074180b5a9ff..75ebfbd381ad8f 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseConstraintsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseConstraintsCheck.cpp
@@ -199,14 +199,13 @@ getConditionRange(ASTContext &Context,
const SourceManager &SM = Context.getSourceManager();
if (EnableIf.getNumArgs() > 1) {
TemplateArgumentLoc NextArg = EnableIf.getArgLoc(1);
- return SourceRange(
- EnableIf.getLAngleLoc().getLocWithOffset(1),
- utils::lexer::findPreviousTokenKind(NextArg.getSourceRange().getBegin(),
- SM, LangOpts, tok::comma));
+ return {EnableIf.getLAngleLoc().getLocWithOffset(1),
+ utils::lexer::findPreviousTokenKind(
+ NextArg.getSourceRange().getBegin(), SM, LangOpts, tok::comma)};
}
- return SourceRange(EnableIf.getLAngleLoc().getLocWithOffset(1),
- getRAngleFileLoc(SM, EnableIf));
+ return {EnableIf.getLAngleLoc().getLocWithOffset(1),
+ getRAngleFileLoc(SM, EnableIf)};
}
static SourceRange getTypeRange(ASTContext &Context,
@@ -214,11 +213,10 @@ static SourceRange getTypeRange(ASTContext &Context,
TemplateArgumentLoc Arg = EnableIf.getArgLoc(1);
const LangOptions &LangOpts = Context.getLangOpts();
const SourceManager &SM = Context.getSourceManager();
- return SourceRange(
- utils::lexer::findPreviousTokenKind(Arg.getSourceRange().getBegin(), SM,
- LangOpts, tok::comma)
- .getLocWithOffset(1),
- getRAngleFileLoc(SM, EnableIf));
+ return {utils::lexer::findPreviousTokenKind(Arg.getSourceRange().getBegin(),
+ SM, LangOpts, tok::comma)
+ .getLocWithOffset(1),
+ getRAngleFileLoc(SM, EnableIf)};
}
// Returns the original source text of the second argument of a call to
diff --git a/clang-tools-extra/clang-tidy/modernize/UseOverrideCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseOverrideCheck.cpp
index 824d037e4552c5..e348968b325a5a 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseOverrideCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseOverrideCheck.cpp
@@ -85,8 +85,7 @@ parseTokens(CharSourceRange Range, const MatchFinder::MatchResult &Result) {
}
static StringRef getText(const Token &Tok, const SourceManager &Sources) {
- return StringRef(Sources.getCharacterData(Tok.getLocation()),
- Tok.getLength());
+ return {Sources.getCharacterData(Tok.getLocation()), Tok.getLength()};
}
void UseOverrideCheck::check(const MatchFinder::MatchResult &Result) {
diff --git a/clang-tools-extra/clang-tidy/objc/PropertyDeclarationCheck.cpp b/clang-tools-extra/clang-tidy/objc/PropertyDeclarationCheck.cpp
index d72c17ac55f620..07904350dc26c6 100644
--- a/clang-tools-extra/clang-tidy/objc/PropertyDeclarationCheck.cpp
+++ b/clang-tools-extra/clang-tidy/objc/PropertyDeclarationCheck.cpp
@@ -52,7 +52,7 @@ FixItHint generateFixItHint(const ObjCPropertyDecl *Decl, NamingStyle Style) {
llvm::StringRef(NewName));
}
}
- return FixItHint();
+ return {};
}
std::string validPropertyNameRegex(bool UsedInMatcher) {
diff --git a/clang-tools-extra/clang-tidy/readability/AvoidConstParamsInDecls.cpp b/clang-tools-extra/clang-tidy/readability/AvoidConstParamsInDecls.cpp
index 6906717dd46926..6476f1d7fdf2b8 100644
--- a/clang-tools-extra/clang-tidy/readability/AvoidConstParamsInDecls.cpp
+++ b/clang-tools-extra/clang-tidy/readability/AvoidConstParamsInDecls.cpp
@@ -18,8 +18,7 @@ namespace clang::tidy::readability {
namespace {
SourceRange getTypeRange(const ParmVarDecl &Param) {
- return SourceRange(Param.getBeginLoc(),
- Param.getLocation().getLocWithOffset(-1));
+ return {Param.getBeginLoc(), Param.getLocation().getLocWithOffset(-1)};
}
} // namespace
diff --git a/clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp b/clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp
index 6889aa9718477c..d8dbaa7c9d73c4 100644
--- a/clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp
@@ -159,27 +159,27 @@ BracesAroundStatementsCheck::findRParenLoc(const IfOrWhileStmt *S,
const ASTContext *Context) {
// Skip macros.
if (S->getBeginLoc().isMacroID())
- return SourceLocation();
+ return {};
SourceLocation CondEndLoc = S->getCond()->getEndLoc();
if (const DeclStmt *CondVar = S->getConditionVariableDeclStmt())
CondEndLoc = CondVar->getEndLoc();
if (!CondEndLoc.isValid()) {
- return SourceLocation();
+ return {};
}
SourceLocation PastCondEndLoc =
Lexer::getLocForEndOfToken(CondEndLoc, 0, SM, Context->getLangOpts());
if (PastCondEndLoc.isInvalid())
- return SourceLocation();
+ return {};
SourceLocation RParenLoc =
forwardSkipWhitespaceAndComments(PastCondEndLoc, SM, Context);
if (RParenLoc.isInvalid())
- return SourceLocation();
+ return {};
tok::TokenKind TokKind = getTokenKind(RParenLoc, SM, Context);
if (TokKind != tok::r_paren)
- return SourceLocation();
+ return {};
return RParenLoc;
}
diff --git a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
index 7d4c7d4448e846..102980d8dd10bf 100644
--- a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
@@ -47,7 +47,7 @@ OptionEnumMapping<
"Camel_Snake_Case"},
{readability::IdentifierNamingCheck::CT_CamelSnakeBack,
"camel_Snake_Back"}};
- return llvm::ArrayRef(Mapping);
+ return {Mapping};
}
template <>
@@ -62,7 +62,7 @@ struct OptionEnumMapping<
{HungarianPrefixType::HPT_On, "On"},
{HungarianPrefixType::HPT_LowerCase, "LowerCase"},
{HungarianPrefixType::HPT_CamelCase, "CamelCase"}};
- return llvm::ArrayRef(Mapping);
+ return {Mapping};
}
};
diff --git a/clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp b/clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp
index 99b792b90a3ca9..69e6d73c4fcd7b 100644
--- a/clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp
@@ -170,7 +170,7 @@ StringRef getEquivalentBoolLiteralForExpr(const Expr *Expression,
return "true";
}
- return StringRef();
+ return {};
}
void fixGenericExprCastFromBool(DiagnosticBuilder &Diag,
diff --git a/clang-tools-extra/clang-tidy/readability/IsolateDeclarationCheck.cpp b/clang-tools-extra/clang-tidy/readability/IsolateDeclarationCheck.cpp
index 97abf8d9ecca6c..9140b1f51631bb 100644
--- a/clang-tools-extra/clang-tidy/readability/IsolateDeclarationCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/IsolateDeclarationCheck.cpp
@@ -43,7 +43,7 @@ static SourceLocation findStartOfIndirection(SourceLocation Start,
while (Indirections-- != 0) {
Start = findPreviousAnyTokenKind(Start, SM, LangOpts, tok::star, tok::amp);
if (Start.isInvalid() || Start.isMacroID())
- return SourceLocation();
+ return {};
}
return Start;
}
diff --git a/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp b/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
index 504a174377c69d..dd7f8141a694e2 100644
--- a/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
+++ b/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
@@ -31,9 +31,7 @@
using namespace clang::tooling;
using namespace llvm;
-static cl::desc desc(StringRef description) {
- return cl::desc(description.ltrim());
-}
+static cl::desc desc(StringRef description) { return {description.ltrim()}; }
static cl::OptionCategory ClangTidyCategory("clang-tidy options");
diff --git a/clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.h b/clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.h
index af4db6bc7bd464..78da016a0fb45f 100644
--- a/clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.h
+++ b/clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.h
@@ -38,12 +38,8 @@ class ExceptionAnalyzer {
class ExceptionInfo {
public:
using Throwables = llvm::SmallSet<const Type *, 2>;
- static ExceptionInfo createUnknown() {
- return ExceptionInfo(State::Unknown);
- }
- static ExceptionInfo createNonThrowing() {
- return ExceptionInfo(State::Throwing);
- }
+ static ExceptionInfo createUnknown() { return {State::Unknown}; }
+ static ExceptionInfo createNonThrowing() { return {State::Throwing}; }
/// By default the exception situation is unknown and must be
/// clarified step-wise.
diff --git a/clang-tools-extra/clang-tidy/utils/FixItHintUtils.cpp b/clang-tools-extra/clang-tidy/utils/FixItHintUtils.cpp
index a0758fc58ee7bb..226dd60b5bf5f5 100644
--- a/clang-tools-extra/clang-tidy/utils/FixItHintUtils.cpp
+++ b/clang-tools-extra/clang-tidy/utils/FixItHintUtils.cpp
@@ -253,7 +253,7 @@ std::string formatDereference(const Expr &ExprNode, const ASTContext &Context) {
StringRef Text = tooling::fixit::getText(ExprNode, Context);
if (Text.empty())
- return std::string();
+ return {};
// Remove remaining '->' from overloaded operator call
Text.consume_back("->");
diff --git a/clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp b/clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp
index 95dbdbb0813927..fe4d2b6d03aa48 100644
--- a/clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp
+++ b/clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp
@@ -230,6 +230,6 @@ OptionEnumMapping<utils::IncludeSorter::IncludeStyle>::getEnumMapping() {
Mapping[] = {{utils::IncludeSorter::IS_LLVM, "llvm"},
{utils::IncludeSorter::IS_Google, "google"},
{utils::IncludeSorter::IS_Google_ObjC, "google-objc"}};
- return ArrayRef(Mapping);
+ return {Mapping};
}
} // namespace clang::tidy
diff --git a/clang-tools-extra/clang-tidy/utils/LexerUtils.cpp b/clang-tools-extra/clang-tidy/utils/LexerUtils.cpp
index 32c9168dc2a2d2..df2b0bef576ca3 100644
--- a/clang-tools-extra/clang-tidy/utils/LexerUtils.cpp
+++ b/clang-tools-extra/clang-tidy/utils/LexerUtils.cpp
@@ -47,11 +47,11 @@ SourceLocation findPreviousTokenStart(SourceLocation Start,
const SourceManager &SM,
const LangOptions &LangOpts) {
if (Start.isInvalid() || Start.isMacroID())
- return SourceLocation();
+ return {};
SourceLocation BeforeStart = Start.getLocWithOffset(-1);
if (BeforeStart.isInvalid() || BeforeStart.isMacroID())
- return SourceLocation();
+ return {};
return Lexer::GetBeginningOfToken(BeforeStart, SM, LangOpts);
}
@@ -61,16 +61,16 @@ SourceLocation findPreviousTokenKind(SourceLocation Start,
const LangOptions &LangOpts,
tok::TokenKind TK) {
if (Start.isInvalid() || Start.isMacroID())
- return SourceLocation();
+ return {};
while (true) {
SourceLocation L = findPreviousTokenStart(Start, SM, LangOpts);
if (L.isInvalid() || L.isMacroID())
- return SourceLocation();
+ return {};
Token T;
if (Lexer::getRawToken(L, T, SM, LangOpts, /*IgnoreWhiteSpace=*/true))
- return SourceLocation();
+ return {};
if (T.is(TK))
return T.getLocation();
@@ -230,7 +230,7 @@ static SourceLocation getSemicolonAfterStmtEndLoc(const SourceLocation &EndLoc,
if (NextTok && NextTok->is(tok::TokenKind::semi))
return NextTok->getLocation();
- return SourceLocation();
+ return {};
}
SourceLocation getUnifiedEndLoc(const Stmt &S, const SourceManager &SM,
diff --git a/clang-tools-extra/clang-tidy/utils/LexerUtils.h b/clang-tools-extra/clang-tidy/utils/LexerUtils.h
index f4ddb2c6382b57..ea9bd512b68b8f 100644
--- a/clang-tools-extra/clang-tidy/utils/LexerUtils.h
+++ b/clang-tools-extra/clang-tidy/utils/LexerUtils.h
@@ -46,16 +46,16 @@ SourceLocation findPreviousAnyTokenKind(SourceLocation Start,
const LangOptions &LangOpts,
TokenKind TK, TokenKinds... TKs) {
if (Start.isInvalid() || Start.isMacroID())
- return SourceLocation();
+ return {};
while (true) {
SourceLocation L = findPreviousTokenStart(Start, SM, LangOpts);
if (L.isInvalid() || L.isMacroID())
- return SourceLocation();
+ return {};
Token T;
// Returning 'true' is used to signal failure to retrieve the token.
if (Lexer::getRawToken(L, T, SM, LangOpts, /*IgnoreWhiteSpace=*/true))
- return SourceLocation();
+ return {};
if (T.isOneOf(TK, TKs...))
return T.getLocation();
@@ -74,7 +74,7 @@ SourceLocation findNextAnyTokenKind(SourceLocation Start,
Lexer::findNextToken(Start, SM, LangOpts);
if (!CurrentToken)
- return SourceLocation();
+ return {};
Token PotentialMatch = *CurrentToken;
if (PotentialMatch.isOneOf(TK, TKs...))
@@ -84,7 +84,7 @@ SourceLocation findNextAnyTokenKind(SourceLocation Start,
// the loop, otherwise we will get infinite loop (findNextToken will return
// eof on eof).
if (PotentialMatch.is(tok::eof))
- return SourceLocation();
+ return {};
Start = PotentialMatch.getLastLoc();
}
}
diff --git a/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp b/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
index ee400d88a3a742..d24b7a65b1c433 100644
--- a/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
+++ b/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
@@ -31,13 +31,13 @@ struct DenseMapInfo<clang::tidy::RenamerClangTidyCheck::NamingCheckId> {
using NamingCheckId = clang::tidy::RenamerClangTidyCheck::NamingCheckId;
static inline NamingCheckId getEmptyKey() {
- return NamingCheckId(DenseMapInfo<clang::SourceLocation>::getEmptyKey(),
- "EMPTY");
+ return {DenseMapInfo<clang::SourceLocation>::getEmptyKey(),
+ "EMPTY"};
}
static inline NamingCheckId getTombstoneKey() {
- return NamingCheckId(DenseMapInfo<clang::SourceLocation>::getTombstoneKey(),
- "TOMBSTONE");
+ return {DenseMapInfo<clang::SourceLocation>::getTombstoneKey(),
+ "TOMBSTONE"};
}
static unsigned getHashValue(NamingCheckId Val) {
More information about the cfe-commits
mailing list