[clang-tidy][NFC] Fix modernize-return-braced-init-list findings

Fix issues found by clang-tidy in clang-tidy source directory.
This commit is contained in:
Piotr Zegar 2023-08-26 18:35:54 +00:00
parent 9c857f2151
commit ec5f4be452
28 changed files with 68 additions and 80 deletions

View File

@ -242,11 +242,11 @@ public:
private: private:
SourceLocation getLocation(StringRef FilePath, unsigned Offset) { SourceLocation getLocation(StringRef FilePath, unsigned Offset) {
if (FilePath.empty()) if (FilePath.empty())
return SourceLocation(); return {};
auto File = SourceMgr.getFileManager().getFile(FilePath); auto File = SourceMgr.getFileManager().getFile(FilePath);
if (!File) if (!File)
return SourceLocation(); return {};
FileID ID = SourceMgr.getOrCreateFileID(*File, SrcMgr::C_User); FileID ID = SourceMgr.getOrCreateFileID(*File, SrcMgr::C_User);
return SourceMgr.getLocForStartOfFile(ID).getLocWithOffset(Offset); return SourceMgr.getLocForStartOfFile(ID).getLocWithOffset(Offset);

View File

@ -212,11 +212,11 @@ public:
using DiagLevelAndFormatString = std::pair<DiagnosticIDs::Level, std::string>; using DiagLevelAndFormatString = std::pair<DiagnosticIDs::Level, std::string>;
DiagLevelAndFormatString getDiagLevelAndFormatString(unsigned DiagnosticID, DiagLevelAndFormatString getDiagLevelAndFormatString(unsigned DiagnosticID,
SourceLocation Loc) { SourceLocation Loc) {
return DiagLevelAndFormatString( return {
static_cast<DiagnosticIDs::Level>( static_cast<DiagnosticIDs::Level>(
DiagEngine->getDiagnosticLevel(DiagnosticID, Loc)), DiagEngine->getDiagnosticLevel(DiagnosticID, Loc)),
std::string( std::string(
DiagEngine->getDiagnosticIDs()->getDescription(DiagnosticID))); DiagEngine->getDiagnosticIDs()->getDescription(DiagnosticID))};
} }
void setOptionsCollector(llvm::StringSet<> *Collector) { void setOptionsCollector(llvm::StringSet<> *Collector) {

View File

@ -46,8 +46,6 @@ ClangTidyCheckFactories::createChecksForLanguage(
return Checks; return Checks;
} }
ClangTidyOptions ClangTidyModule::getModuleOptions() { ClangTidyOptions ClangTidyModule::getModuleOptions() { return {}; }
return ClangTidyOptions();
}
} // namespace clang::tidy } // namespace clang::tidy

View File

@ -39,7 +39,7 @@ static llvm::Regex consumeGlob(StringRef &GlobList) {
RegexText.push_back(C); RegexText.push_back(C);
} }
RegexText.push_back('$'); RegexText.push_back('$');
return llvm::Regex(RegexText); return {RegexText};
} }
GlobList::GlobList(StringRef Globs, bool KeepNegativeGlobs /* =true */) { GlobList::GlobList(StringRef Globs, bool KeepNegativeGlobs /* =true */) {

View File

@ -278,7 +278,7 @@ std::string rewriteExprFromNumberToDuration(
return *MaybeRewrite; return *MaybeRewrite;
if (isLiteralZero(Result, RootNode)) if (isLiteralZero(Result, RootNode))
return std::string("absl::ZeroDuration()"); return {"absl::ZeroDuration()"};
return (llvm::Twine(getDurationFactoryForScale(Scale)) + "(" + return (llvm::Twine(getDurationFactoryForScale(Scale)) + "(" +
simplifyDurationFactoryArg(Result, RootNode) + ")") simplifyDurationFactoryArg(Result, RootNode) + ")")
@ -296,7 +296,7 @@ std::string rewriteExprFromNumberToTime(
return *MaybeRewrite; return *MaybeRewrite;
if (isLiteralZero(Result, RootNode)) if (isLiteralZero(Result, RootNode))
return std::string("absl::UnixEpoch()"); return {"absl::UnixEpoch()"};
return (llvm::Twine(getTimeFactoryForScale(Scale)) + "(" + return (llvm::Twine(getTimeFactoryForScale(Scale)) + "(" +
tooling::fixit::getText(RootNode, *Result.Context) + ")") tooling::fixit::getText(RootNode, *Result.Context) + ")")

View File

@ -235,7 +235,7 @@ struct OptionEnumMapping<
{bugprone::SignalHandlerCheck::AsyncSafeFunctionSetKind::POSIX, {bugprone::SignalHandlerCheck::AsyncSafeFunctionSetKind::POSIX,
"POSIX"}, "POSIX"},
}; };
return ArrayRef(Mapping); return {Mapping};
} }
}; };

View File

@ -269,7 +269,7 @@ template <> struct OptionEnumMapping<concurrency::MtUnsafeCheck::FunctionSet> {
Mapping[] = {{concurrency::MtUnsafeCheck::FunctionSet::Posix, "posix"}, Mapping[] = {{concurrency::MtUnsafeCheck::FunctionSet::Posix, "posix"},
{concurrency::MtUnsafeCheck::FunctionSet::Glibc, "glibc"}, {concurrency::MtUnsafeCheck::FunctionSet::Glibc, "glibc"},
{concurrency::MtUnsafeCheck::FunctionSet::Any, "any"}}; {concurrency::MtUnsafeCheck::FunctionSet::Any, "any"}};
return ArrayRef(Mapping); return {Mapping};
} }
}; };

View File

@ -83,13 +83,13 @@ struct DenseMapInfo<
clang::tidy::cppcoreguidelines::SpecialMemberFunctionsCheck::ClassDefId; clang::tidy::cppcoreguidelines::SpecialMemberFunctionsCheck::ClassDefId;
static inline ClassDefId getEmptyKey() { static inline ClassDefId getEmptyKey() {
return ClassDefId(DenseMapInfo<clang::SourceLocation>::getEmptyKey(), return {DenseMapInfo<clang::SourceLocation>::getEmptyKey(),
"EMPTY"); "EMPTY"};
} }
static inline ClassDefId getTombstoneKey() { static inline ClassDefId getTombstoneKey() {
return ClassDefId(DenseMapInfo<clang::SourceLocation>::getTombstoneKey(), return {DenseMapInfo<clang::SourceLocation>::getTombstoneKey(),
"TOMBSTONE"); "TOMBSTONE"};
} }
static unsigned getHashValue(ClassDefId Val) { static unsigned getHashValue(ClassDefId Val) {

View File

@ -38,7 +38,7 @@ static SourceRange findToken(const SourceManager &Sources,
SourceLocation StartLoc, SourceLocation EndLoc, SourceLocation StartLoc, SourceLocation EndLoc,
bool (*Pred)(const Token &)) { bool (*Pred)(const Token &)) {
if (StartLoc.isMacroID() || EndLoc.isMacroID()) if (StartLoc.isMacroID() || EndLoc.isMacroID())
return SourceRange(); return {};
FileID File = Sources.getFileID(Sources.getSpellingLoc(StartLoc)); FileID File = Sources.getFileID(Sources.getSpellingLoc(StartLoc));
StringRef Buf = Sources.getBufferData(File); StringRef Buf = Sources.getBufferData(File);
const char *StartChar = Sources.getCharacterData(StartLoc); const char *StartChar = Sources.getCharacterData(StartLoc);
@ -50,11 +50,11 @@ static SourceRange findToken(const SourceManager &Sources,
if (Pred(Tok)) { if (Pred(Tok)) {
Token NextTok; Token NextTok;
Lex.LexFromRawLexer(NextTok); Lex.LexFromRawLexer(NextTok);
return SourceRange(Tok.getLocation(), NextTok.getLocation()); return {Tok.getLocation(), NextTok.getLocation()};
} }
} while (Tok.isNot(tok::eof) && Tok.getLocation() < EndLoc); } while (Tok.isNot(tok::eof) && Tok.getLocation() < EndLoc);
return SourceRange(); return {};
} }
static bool declIsStdInitializerList(const NamedDecl *D) { static bool declIsStdInitializerList(const NamedDecl *D) {

View File

@ -49,7 +49,7 @@ FixItHint generateFixItHint(const FunctionDecl *Decl) {
// otherwise the check cannot determine the appropriate function name prefix // otherwise the check cannot determine the appropriate function name prefix
// to use. // to use.
if (Decl->getStorageClass() != SC_Static) if (Decl->getStorageClass() != SC_Static)
return FixItHint(); return {};
StringRef Name = Decl->getName(); StringRef Name = Decl->getName();
std::string NewName = Decl->getName().str(); std::string NewName = Decl->getName().str();
@ -80,7 +80,7 @@ FixItHint generateFixItHint(const FunctionDecl *Decl) {
CharSourceRange::getTokenRange(SourceRange(Decl->getLocation())), CharSourceRange::getTokenRange(SourceRange(Decl->getLocation())),
llvm::StringRef(NewName)); llvm::StringRef(NewName));
return FixItHint(); return {};
} }
} // namespace } // namespace

View File

@ -26,7 +26,7 @@ FixItHint generateFixItHint(const VarDecl *Decl, bool IsConst) {
if (IsConst && (Decl->getStorageClass() != SC_Static)) { if (IsConst && (Decl->getStorageClass() != SC_Static)) {
// No fix available if it is not a static constant, since it is difficult // No fix available if it is not a static constant, since it is difficult
// to determine the proper fix in this case. // to determine the proper fix in this case.
return FixItHint(); return {};
} }
char FC = Decl->getName()[0]; char FC = Decl->getName()[0];
@ -35,14 +35,14 @@ FixItHint generateFixItHint(const VarDecl *Decl, bool IsConst) {
// is a single-character variable, since it is difficult to determine the // is a single-character variable, since it is difficult to determine the
// proper fix in this case. Users should create a proper variable name by // proper fix in this case. Users should create a proper variable name by
// their own. // their own.
return FixItHint(); return {};
} }
char SC = Decl->getName()[1]; char SC = Decl->getName()[1];
if ((FC == 'k' || FC == 'g') && !llvm::isAlpha(SC)) { if ((FC == 'k' || FC == 'g') && !llvm::isAlpha(SC)) {
// No fix available if the prefix is correct but the second character is // No fix available if the prefix is correct but the second character is
// not alphabetical, since it is difficult to determine the proper fix in // not alphabetical, since it is difficult to determine the proper fix in
// this case. // this case.
return FixItHint(); return {};
} }
auto NewName = (IsConst ? "k" : "g") + auto NewName = (IsConst ? "k" : "g") +

View File

@ -141,7 +141,7 @@ SourceLocation StaticAssertCheck::getLastParenLoc(const ASTContext *ASTCtx,
std::optional<llvm::MemoryBufferRef> Buffer = std::optional<llvm::MemoryBufferRef> Buffer =
SM.getBufferOrNone(SM.getFileID(AssertLoc)); SM.getBufferOrNone(SM.getFileID(AssertLoc));
if (!Buffer) if (!Buffer)
return SourceLocation(); return {};
const char *BufferPos = SM.getCharacterData(AssertLoc); const char *BufferPos = SM.getCharacterData(AssertLoc);
@ -152,7 +152,7 @@ SourceLocation StaticAssertCheck::getLastParenLoc(const ASTContext *ASTCtx,
// assert first left parenthesis // assert first left parenthesis
if (Lexer.LexFromRawLexer(Token) || Lexer.LexFromRawLexer(Token) || if (Lexer.LexFromRawLexer(Token) || Lexer.LexFromRawLexer(Token) ||
!Token.is(tok::l_paren)) !Token.is(tok::l_paren))
return SourceLocation(); return {};
unsigned int ParenCount = 1; unsigned int ParenCount = 1;
while (ParenCount && !Lexer.LexFromRawLexer(Token)) { while (ParenCount && !Lexer.LexFromRawLexer(Token)) {

View File

@ -38,7 +38,7 @@ template <> struct OptionEnumMapping<modernize::Confidence::Level> {
Mapping[] = {{modernize::Confidence::CL_Reasonable, "reasonable"}, Mapping[] = {{modernize::Confidence::CL_Reasonable, "reasonable"},
{modernize::Confidence::CL_Safe, "safe"}, {modernize::Confidence::CL_Safe, "safe"},
{modernize::Confidence::CL_Risky, "risky"}}; {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_CamelBack, "camelBack"},
{modernize::VariableNamer::NS_LowerCase, "lower_case"}, {modernize::VariableNamer::NS_LowerCase, "lower_case"},
{modernize::VariableNamer::NS_UpperCase, "UPPER_CASE"}}; {modernize::VariableNamer::NS_UpperCase, "UPPER_CASE"}};
return ArrayRef(Mapping); return {Mapping};
} }
}; };
@ -465,7 +465,7 @@ static StringRef getStringFromRange(SourceManager &SourceMgr,
SourceRange Range) { SourceRange Range) {
if (SourceMgr.getFileID(Range.getBegin()) != if (SourceMgr.getFileID(Range.getBegin()) !=
SourceMgr.getFileID(Range.getEnd())) { SourceMgr.getFileID(Range.getEnd())) {
return StringRef(); // Empty string. return {}; // Empty string.
} }
return Lexer::getSourceText(CharSourceRange(Range, true), SourceMgr, return Lexer::getSourceText(CharSourceRange(Range, true), SourceMgr,

View File

@ -199,14 +199,13 @@ getConditionRange(ASTContext &Context,
const SourceManager &SM = Context.getSourceManager(); const SourceManager &SM = Context.getSourceManager();
if (EnableIf.getNumArgs() > 1) { if (EnableIf.getNumArgs() > 1) {
TemplateArgumentLoc NextArg = EnableIf.getArgLoc(1); TemplateArgumentLoc NextArg = EnableIf.getArgLoc(1);
return SourceRange( return {EnableIf.getLAngleLoc().getLocWithOffset(1),
EnableIf.getLAngleLoc().getLocWithOffset(1), utils::lexer::findPreviousTokenKind(
utils::lexer::findPreviousTokenKind(NextArg.getSourceRange().getBegin(), NextArg.getSourceRange().getBegin(), SM, LangOpts, tok::comma)};
SM, LangOpts, tok::comma));
} }
return SourceRange(EnableIf.getLAngleLoc().getLocWithOffset(1), return {EnableIf.getLAngleLoc().getLocWithOffset(1),
getRAngleFileLoc(SM, EnableIf)); getRAngleFileLoc(SM, EnableIf)};
} }
static SourceRange getTypeRange(ASTContext &Context, static SourceRange getTypeRange(ASTContext &Context,
@ -214,11 +213,10 @@ static SourceRange getTypeRange(ASTContext &Context,
TemplateArgumentLoc Arg = EnableIf.getArgLoc(1); TemplateArgumentLoc Arg = EnableIf.getArgLoc(1);
const LangOptions &LangOpts = Context.getLangOpts(); const LangOptions &LangOpts = Context.getLangOpts();
const SourceManager &SM = Context.getSourceManager(); const SourceManager &SM = Context.getSourceManager();
return SourceRange( return {utils::lexer::findPreviousTokenKind(Arg.getSourceRange().getBegin(),
utils::lexer::findPreviousTokenKind(Arg.getSourceRange().getBegin(), SM, SM, LangOpts, tok::comma)
LangOpts, tok::comma) .getLocWithOffset(1),
.getLocWithOffset(1), getRAngleFileLoc(SM, EnableIf)};
getRAngleFileLoc(SM, EnableIf));
} }
// Returns the original source text of the second argument of a call to // Returns the original source text of the second argument of a call to

View File

@ -85,8 +85,7 @@ parseTokens(CharSourceRange Range, const MatchFinder::MatchResult &Result) {
} }
static StringRef getText(const Token &Tok, const SourceManager &Sources) { static StringRef getText(const Token &Tok, const SourceManager &Sources) {
return StringRef(Sources.getCharacterData(Tok.getLocation()), return {Sources.getCharacterData(Tok.getLocation()), Tok.getLength()};
Tok.getLength());
} }
void UseOverrideCheck::check(const MatchFinder::MatchResult &Result) { void UseOverrideCheck::check(const MatchFinder::MatchResult &Result) {

View File

@ -52,7 +52,7 @@ FixItHint generateFixItHint(const ObjCPropertyDecl *Decl, NamingStyle Style) {
llvm::StringRef(NewName)); llvm::StringRef(NewName));
} }
} }
return FixItHint(); return {};
} }
std::string validPropertyNameRegex(bool UsedInMatcher) { std::string validPropertyNameRegex(bool UsedInMatcher) {

View File

@ -18,8 +18,7 @@ namespace clang::tidy::readability {
namespace { namespace {
SourceRange getTypeRange(const ParmVarDecl &Param) { SourceRange getTypeRange(const ParmVarDecl &Param) {
return SourceRange(Param.getBeginLoc(), return {Param.getBeginLoc(), Param.getLocation().getLocWithOffset(-1)};
Param.getLocation().getLocWithOffset(-1));
} }
} // namespace } // namespace

View File

@ -159,27 +159,27 @@ BracesAroundStatementsCheck::findRParenLoc(const IfOrWhileStmt *S,
const ASTContext *Context) { const ASTContext *Context) {
// Skip macros. // Skip macros.
if (S->getBeginLoc().isMacroID()) if (S->getBeginLoc().isMacroID())
return SourceLocation(); return {};
SourceLocation CondEndLoc = S->getCond()->getEndLoc(); SourceLocation CondEndLoc = S->getCond()->getEndLoc();
if (const DeclStmt *CondVar = S->getConditionVariableDeclStmt()) if (const DeclStmt *CondVar = S->getConditionVariableDeclStmt())
CondEndLoc = CondVar->getEndLoc(); CondEndLoc = CondVar->getEndLoc();
if (!CondEndLoc.isValid()) { if (!CondEndLoc.isValid()) {
return SourceLocation(); return {};
} }
SourceLocation PastCondEndLoc = SourceLocation PastCondEndLoc =
Lexer::getLocForEndOfToken(CondEndLoc, 0, SM, Context->getLangOpts()); Lexer::getLocForEndOfToken(CondEndLoc, 0, SM, Context->getLangOpts());
if (PastCondEndLoc.isInvalid()) if (PastCondEndLoc.isInvalid())
return SourceLocation(); return {};
SourceLocation RParenLoc = SourceLocation RParenLoc =
forwardSkipWhitespaceAndComments(PastCondEndLoc, SM, Context); forwardSkipWhitespaceAndComments(PastCondEndLoc, SM, Context);
if (RParenLoc.isInvalid()) if (RParenLoc.isInvalid())
return SourceLocation(); return {};
tok::TokenKind TokKind = getTokenKind(RParenLoc, SM, Context); tok::TokenKind TokKind = getTokenKind(RParenLoc, SM, Context);
if (TokKind != tok::r_paren) if (TokKind != tok::r_paren)
return SourceLocation(); return {};
return RParenLoc; return RParenLoc;
} }

View File

@ -47,7 +47,7 @@ OptionEnumMapping<
"Camel_Snake_Case"}, "Camel_Snake_Case"},
{readability::IdentifierNamingCheck::CT_CamelSnakeBack, {readability::IdentifierNamingCheck::CT_CamelSnakeBack,
"camel_Snake_Back"}}; "camel_Snake_Back"}};
return llvm::ArrayRef(Mapping); return {Mapping};
} }
template <> template <>
@ -62,7 +62,7 @@ struct OptionEnumMapping<
{HungarianPrefixType::HPT_On, "On"}, {HungarianPrefixType::HPT_On, "On"},
{HungarianPrefixType::HPT_LowerCase, "LowerCase"}, {HungarianPrefixType::HPT_LowerCase, "LowerCase"},
{HungarianPrefixType::HPT_CamelCase, "CamelCase"}}; {HungarianPrefixType::HPT_CamelCase, "CamelCase"}};
return llvm::ArrayRef(Mapping); return {Mapping};
} }
}; };

View File

@ -170,7 +170,7 @@ StringRef getEquivalentBoolLiteralForExpr(const Expr *Expression,
return "true"; return "true";
} }
return StringRef(); return {};
} }
void fixGenericExprCastFromBool(DiagnosticBuilder &Diag, void fixGenericExprCastFromBool(DiagnosticBuilder &Diag,

View File

@ -43,7 +43,7 @@ static SourceLocation findStartOfIndirection(SourceLocation Start,
while (Indirections-- != 0) { while (Indirections-- != 0) {
Start = findPreviousAnyTokenKind(Start, SM, LangOpts, tok::star, tok::amp); Start = findPreviousAnyTokenKind(Start, SM, LangOpts, tok::star, tok::amp);
if (Start.isInvalid() || Start.isMacroID()) if (Start.isInvalid() || Start.isMacroID())
return SourceLocation(); return {};
} }
return Start; return Start;
} }

View File

@ -31,9 +31,7 @@
using namespace clang::tooling; using namespace clang::tooling;
using namespace llvm; using namespace llvm;
static cl::desc desc(StringRef description) { static cl::desc desc(StringRef description) { return {description.ltrim()}; }
return cl::desc(description.ltrim());
}
static cl::OptionCategory ClangTidyCategory("clang-tidy options"); static cl::OptionCategory ClangTidyCategory("clang-tidy options");

View File

@ -38,12 +38,8 @@ public:
class ExceptionInfo { class ExceptionInfo {
public: public:
using Throwables = llvm::SmallSet<const Type *, 2>; using Throwables = llvm::SmallSet<const Type *, 2>;
static ExceptionInfo createUnknown() { static ExceptionInfo createUnknown() { return {State::Unknown}; }
return ExceptionInfo(State::Unknown); static ExceptionInfo createNonThrowing() { return {State::Throwing}; }
}
static ExceptionInfo createNonThrowing() {
return ExceptionInfo(State::Throwing);
}
/// By default the exception situation is unknown and must be /// By default the exception situation is unknown and must be
/// clarified step-wise. /// clarified step-wise.

View File

@ -253,7 +253,7 @@ std::string formatDereference(const Expr &ExprNode, const ASTContext &Context) {
StringRef Text = tooling::fixit::getText(ExprNode, Context); StringRef Text = tooling::fixit::getText(ExprNode, Context);
if (Text.empty()) if (Text.empty())
return std::string(); return {};
// Remove remaining '->' from overloaded operator call // Remove remaining '->' from overloaded operator call
Text.consume_back("->"); Text.consume_back("->");

View File

@ -230,6 +230,6 @@ OptionEnumMapping<utils::IncludeSorter::IncludeStyle>::getEnumMapping() {
Mapping[] = {{utils::IncludeSorter::IS_LLVM, "llvm"}, Mapping[] = {{utils::IncludeSorter::IS_LLVM, "llvm"},
{utils::IncludeSorter::IS_Google, "google"}, {utils::IncludeSorter::IS_Google, "google"},
{utils::IncludeSorter::IS_Google_ObjC, "google-objc"}}; {utils::IncludeSorter::IS_Google_ObjC, "google-objc"}};
return ArrayRef(Mapping); return {Mapping};
} }
} // namespace clang::tidy } // namespace clang::tidy

View File

@ -47,11 +47,11 @@ SourceLocation findPreviousTokenStart(SourceLocation Start,
const SourceManager &SM, const SourceManager &SM,
const LangOptions &LangOpts) { const LangOptions &LangOpts) {
if (Start.isInvalid() || Start.isMacroID()) if (Start.isInvalid() || Start.isMacroID())
return SourceLocation(); return {};
SourceLocation BeforeStart = Start.getLocWithOffset(-1); SourceLocation BeforeStart = Start.getLocWithOffset(-1);
if (BeforeStart.isInvalid() || BeforeStart.isMacroID()) if (BeforeStart.isInvalid() || BeforeStart.isMacroID())
return SourceLocation(); return {};
return Lexer::GetBeginningOfToken(BeforeStart, SM, LangOpts); return Lexer::GetBeginningOfToken(BeforeStart, SM, LangOpts);
} }
@ -61,16 +61,16 @@ SourceLocation findPreviousTokenKind(SourceLocation Start,
const LangOptions &LangOpts, const LangOptions &LangOpts,
tok::TokenKind TK) { tok::TokenKind TK) {
if (Start.isInvalid() || Start.isMacroID()) if (Start.isInvalid() || Start.isMacroID())
return SourceLocation(); return {};
while (true) { while (true) {
SourceLocation L = findPreviousTokenStart(Start, SM, LangOpts); SourceLocation L = findPreviousTokenStart(Start, SM, LangOpts);
if (L.isInvalid() || L.isMacroID()) if (L.isInvalid() || L.isMacroID())
return SourceLocation(); return {};
Token T; Token T;
if (Lexer::getRawToken(L, T, SM, LangOpts, /*IgnoreWhiteSpace=*/true)) if (Lexer::getRawToken(L, T, SM, LangOpts, /*IgnoreWhiteSpace=*/true))
return SourceLocation(); return {};
if (T.is(TK)) if (T.is(TK))
return T.getLocation(); return T.getLocation();
@ -230,7 +230,7 @@ static SourceLocation getSemicolonAfterStmtEndLoc(const SourceLocation &EndLoc,
if (NextTok && NextTok->is(tok::TokenKind::semi)) if (NextTok && NextTok->is(tok::TokenKind::semi))
return NextTok->getLocation(); return NextTok->getLocation();
return SourceLocation(); return {};
} }
SourceLocation getUnifiedEndLoc(const Stmt &S, const SourceManager &SM, SourceLocation getUnifiedEndLoc(const Stmt &S, const SourceManager &SM,

View File

@ -46,16 +46,16 @@ SourceLocation findPreviousAnyTokenKind(SourceLocation Start,
const LangOptions &LangOpts, const LangOptions &LangOpts,
TokenKind TK, TokenKinds... TKs) { TokenKind TK, TokenKinds... TKs) {
if (Start.isInvalid() || Start.isMacroID()) if (Start.isInvalid() || Start.isMacroID())
return SourceLocation(); return {};
while (true) { while (true) {
SourceLocation L = findPreviousTokenStart(Start, SM, LangOpts); SourceLocation L = findPreviousTokenStart(Start, SM, LangOpts);
if (L.isInvalid() || L.isMacroID()) if (L.isInvalid() || L.isMacroID())
return SourceLocation(); return {};
Token T; Token T;
// Returning 'true' is used to signal failure to retrieve the token. // Returning 'true' is used to signal failure to retrieve the token.
if (Lexer::getRawToken(L, T, SM, LangOpts, /*IgnoreWhiteSpace=*/true)) if (Lexer::getRawToken(L, T, SM, LangOpts, /*IgnoreWhiteSpace=*/true))
return SourceLocation(); return {};
if (T.isOneOf(TK, TKs...)) if (T.isOneOf(TK, TKs...))
return T.getLocation(); return T.getLocation();
@ -74,7 +74,7 @@ SourceLocation findNextAnyTokenKind(SourceLocation Start,
Lexer::findNextToken(Start, SM, LangOpts); Lexer::findNextToken(Start, SM, LangOpts);
if (!CurrentToken) if (!CurrentToken)
return SourceLocation(); return {};
Token PotentialMatch = *CurrentToken; Token PotentialMatch = *CurrentToken;
if (PotentialMatch.isOneOf(TK, TKs...)) if (PotentialMatch.isOneOf(TK, TKs...))
@ -84,7 +84,7 @@ SourceLocation findNextAnyTokenKind(SourceLocation Start,
// the loop, otherwise we will get infinite loop (findNextToken will return // the loop, otherwise we will get infinite loop (findNextToken will return
// eof on eof). // eof on eof).
if (PotentialMatch.is(tok::eof)) if (PotentialMatch.is(tok::eof))
return SourceLocation(); return {};
Start = PotentialMatch.getLastLoc(); Start = PotentialMatch.getLastLoc();
} }
} }

View File

@ -31,13 +31,13 @@ struct DenseMapInfo<clang::tidy::RenamerClangTidyCheck::NamingCheckId> {
using NamingCheckId = clang::tidy::RenamerClangTidyCheck::NamingCheckId; using NamingCheckId = clang::tidy::RenamerClangTidyCheck::NamingCheckId;
static inline NamingCheckId getEmptyKey() { static inline NamingCheckId getEmptyKey() {
return NamingCheckId(DenseMapInfo<clang::SourceLocation>::getEmptyKey(), return {DenseMapInfo<clang::SourceLocation>::getEmptyKey(),
"EMPTY"); "EMPTY"};
} }
static inline NamingCheckId getTombstoneKey() { static inline NamingCheckId getTombstoneKey() {
return NamingCheckId(DenseMapInfo<clang::SourceLocation>::getTombstoneKey(), return {DenseMapInfo<clang::SourceLocation>::getTombstoneKey(),
"TOMBSTONE"); "TOMBSTONE"};
} }
static unsigned getHashValue(NamingCheckId Val) { static unsigned getHashValue(NamingCheckId Val) {