Skip to content

Commit c80e470

Browse files
committed
Merge commit '42a4f5103b7087b1460463d11f7ba68d1832abfc' into feature/merge-upstream-20220102
2 parents 364b0cb + 42a4f51 commit c80e470

File tree

2,416 files changed

+126279
-91475
lines changed

Some content is hidden

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

2,416 files changed

+126279
-91475
lines changed

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
#include "llvm/ADT/StringExtras.h"
1515
#include "llvm/Support/Error.h"
1616

17-
using clang::comments::FullComment;
18-
1917
namespace clang {
2018
namespace doc {
2119

@@ -68,7 +66,7 @@ bool MapASTVisitor::VisitCXXMethodDecl(const CXXMethodDecl *D) {
6866

6967
bool MapASTVisitor::VisitFunctionDecl(const FunctionDecl *D) {
7068
// Don't visit CXXMethodDecls twice
71-
if (dyn_cast<CXXMethodDecl>(D))
69+
if (isa<CXXMethodDecl>(D))
7270
return true;
7371
return mapDecl(D);
7472
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ populateParentNamespaces(llvm::SmallVector<Reference, 4> &Namespaces,
382382
// corresponds to a Record and if it doesn't have any namespace (because this
383383
// means it's in the global namespace). Also if its outermost namespace is a
384384
// record because that record matches the previous condition mentioned.
385-
if ((Namespaces.empty() && dyn_cast<RecordDecl>(D)) ||
385+
if ((Namespaces.empty() && isa<RecordDecl>(D)) ||
386386
(!Namespaces.empty() && Namespaces.back().RefType == InfoType::IT_record))
387387
Namespaces.emplace_back(SymbolID(), "GlobalNamespace",
388388
InfoType::IT_namespace);
@@ -419,10 +419,10 @@ static void populateFunctionInfo(FunctionInfo &I, const FunctionDecl *D,
419419
populateSymbolInfo(I, D, FC, LineNumber, Filename, IsFileInRootDir,
420420
IsInAnonymousNamespace);
421421
if (const auto *T = getDeclForType(D->getReturnType())) {
422-
if (dyn_cast<EnumDecl>(T))
422+
if (isa<EnumDecl>(T))
423423
I.ReturnType = TypeInfo(getUSRForDecl(T), T->getNameAsString(),
424424
InfoType::IT_enum, getInfoRelativePath(T));
425-
else if (dyn_cast<RecordDecl>(T))
425+
else if (isa<RecordDecl>(T))
426426
I.ReturnType = TypeInfo(getUSRForDecl(T), T->getNameAsString(),
427427
InfoType::IT_record, getInfoRelativePath(T));
428428
} else {

clang-tools-extra/clang-include-fixer/YamlSymbolIndex.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#include <string>
1616
#include <vector>
1717

18-
using clang::find_all_symbols::SymbolInfo;
1918
using clang::find_all_symbols::SymbolAndSignals;
2019

2120
namespace clang {

clang-tools-extra/clang-include-fixer/find-all-symbols/SymbolInfo.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
#include "llvm/Support/raw_ostream.h"
1414

1515
using llvm::yaml::MappingTraits;
16-
using llvm::yaml::IO;
17-
using llvm::yaml::Input;
1816
using ContextType = clang::find_all_symbols::SymbolInfo::ContextType;
1917
using clang::find_all_symbols::SymbolInfo;
2018
using clang::find_all_symbols::SymbolAndSignals;

clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,8 @@ DiagnosticBuilder ClangTidyContext::diag(const ClangTidyError &Error) {
193193
SM.getFileManager().getFile(Error.Message.FilePath);
194194
FileID ID = SM.getOrCreateFileID(*File, SrcMgr::C_User);
195195
SourceLocation FileStartLoc = SM.getLocForStartOfFile(ID);
196-
SourceLocation Loc = FileStartLoc.getLocWithOffset(Error.Message.FileOffset);
196+
SourceLocation Loc = FileStartLoc.getLocWithOffset(
197+
static_cast<SourceLocation::IntTy>(Error.Message.FileOffset));
197198
return diag(Error.DiagnosticName, Loc, Error.Message.Message,
198199
static_cast<DiagnosticIDs::Level>(Error.DiagLevel));
199200
}

clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -241,14 +241,12 @@ getFixIt(const tooling::Diagnostic &Diagnostic, bool AnyFix);
241241

242242
/// A diagnostic consumer that turns each \c Diagnostic into a
243243
/// \c SourceManager-independent \c ClangTidyError.
244-
///
245-
/// \param EnableNolintBlocks Enables diagnostic-disabling inside blocks of
246-
/// code, delimited by NOLINTBEGIN and NOLINTEND.
247-
//
248244
// FIXME: If we move away from unit-tests, this can be moved to a private
249245
// implementation file.
250246
class ClangTidyDiagnosticConsumer : public DiagnosticConsumer {
251247
public:
248+
/// \param EnableNolintBlocks Enables diagnostic-disabling inside blocks of
249+
/// code, delimited by NOLINTBEGIN and NOLINTEND.
252250
ClangTidyDiagnosticConsumer(ClangTidyContext &Ctx,
253251
DiagnosticsEngine *ExternalDiagEngine = nullptr,
254252
bool RemoveIncompatibleErrors = true,

clang-tools-extra/clang-tidy/abseil/DurationFactoryScaleCheck.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,6 @@ void DurationFactoryScaleCheck::check(const MatchFinder::MatchResult &Result) {
221221
tooling::fixit::getText(*Remainder, *Result.Context) + ")")
222222
.str());
223223
}
224-
return;
225224
}
226225

227226
} // namespace abseil

clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ void StringFindStartswithCheck::registerMatchers(MatchFinder *Finder) {
4040

4141
auto StringFind = cxxMemberCallExpr(
4242
// .find()-call on a string...
43-
callee(cxxMethodDecl(hasName("find"))),
43+
callee(cxxMethodDecl(hasName("find")).bind("findfun")),
4444
on(hasType(StringType)),
4545
// ... with some search expression ...
4646
hasArgument(0, expr().bind("needle")),
@@ -55,6 +55,25 @@ void StringFindStartswithCheck::registerMatchers(MatchFinder *Finder) {
5555
ignoringParenImpCasts(StringFind.bind("findexpr"))))
5656
.bind("expr"),
5757
this);
58+
59+
auto StringRFind = cxxMemberCallExpr(
60+
// .rfind()-call on a string...
61+
callee(cxxMethodDecl(hasName("rfind")).bind("findfun")),
62+
on(hasType(StringType)),
63+
// ... with some search expression ...
64+
hasArgument(0, expr().bind("needle")),
65+
// ... and "0" as second argument.
66+
hasArgument(1, ZeroLiteral));
67+
68+
Finder->addMatcher(
69+
// Match [=!]= with either a zero or npos on one side and a string.rfind
70+
// on the other.
71+
binaryOperator(
72+
hasAnyOperatorName("==", "!="),
73+
hasOperands(ignoringParenImpCasts(ZeroLiteral),
74+
ignoringParenImpCasts(StringRFind.bind("findexpr"))))
75+
.bind("expr"),
76+
this);
5877
}
5978

6079
void StringFindStartswithCheck::check(const MatchFinder::MatchResult &Result) {
@@ -69,6 +88,11 @@ void StringFindStartswithCheck::check(const MatchFinder::MatchResult &Result) {
6988
const Expr *Haystack = Result.Nodes.getNodeAs<CXXMemberCallExpr>("findexpr")
7089
->getImplicitObjectArgument();
7190
assert(Haystack != nullptr);
91+
const CXXMethodDecl *FindFun =
92+
Result.Nodes.getNodeAs<CXXMethodDecl>("findfun");
93+
assert(FindFun != nullptr);
94+
95+
bool Rev = FindFun->getName().contains("rfind");
7296

7397
if (ComparisonExpr->getBeginLoc().isMacroID())
7498
return;
@@ -86,10 +110,11 @@ void StringFindStartswithCheck::check(const MatchFinder::MatchResult &Result) {
86110
bool Neg = ComparisonExpr->getOpcode() == BO_NE;
87111

88112
// Create the warning message and a FixIt hint replacing the original expr.
89-
auto Diagnostic = diag(ComparisonExpr->getBeginLoc(),
90-
"use %select{absl::StartsWith|!absl::StartsWith}0 "
91-
"instead of find() %select{==|!=}0 0")
92-
<< Neg;
113+
auto Diagnostic =
114+
diag(ComparisonExpr->getBeginLoc(),
115+
"use %select{absl::StartsWith|!absl::StartsWith}0 "
116+
"instead of %select{find()|rfind()}1 %select{==|!=}0 0")
117+
<< Neg << Rev;
93118

94119
Diagnostic << FixItHint::CreateReplacement(
95120
ComparisonExpr->getSourceRange(),

clang-tools-extra/clang-tidy/android/CloexecCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ void CloexecCheck::insertStringFlag(
8787

8888
// Check if the <Mode> may be in the mode string.
8989
const auto *ModeStr = dyn_cast<StringLiteral>(ModeArg->IgnoreParenCasts());
90-
if (!ModeStr || (ModeStr->getString().find(Mode) != StringRef::npos))
90+
if (!ModeStr || ModeStr->getString().contains(Mode))
9191
return;
9292

9393
std::string ReplacementText = buildFixMsgForStringFlag(

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ static StringRef exprToStr(const Expr *E,
144144

145145
return Lexer::getSourceText(
146146
CharSourceRange::getTokenRange(E->getSourceRange()),
147-
*Result.SourceManager, Result.Context->getLangOpts(), 0);
147+
*Result.SourceManager, Result.Context->getLangOpts(), nullptr);
148148
}
149149

150150
// Returns the proper token based end location of \p E.
@@ -477,7 +477,7 @@ static void insertNullTerminatorExpr(StringRef Name,
477477
FunctionExpr->getBeginLoc());
478478
StringRef SpaceBeforeStmtStr = Lexer::getSourceText(
479479
CharSourceRange::getCharRange(SpaceRange), *Result.SourceManager,
480-
Result.Context->getLangOpts(), 0);
480+
Result.Context->getLangOpts(), nullptr);
481481

482482
SmallString<128> NewAddNullTermExprStr;
483483
NewAddNullTermExprStr =

0 commit comments

Comments
 (0)