Skip to content

Commit

Permalink
Merged master:628f008b201 into amd-gfx:536937b3dc3
Browse files Browse the repository at this point in the history
Local branch amd-gfx 536937b [AMDGPU] Fixed incorrect PAL metadata register naming
Remote branch master 628f008 [docs] Fix buildbot failures
  • Loading branch information
Sw authored and Sw committed May 21, 2020
2 parents 536937b + 628f008 commit 9d914d7
Show file tree
Hide file tree
Showing 116 changed files with 1,853 additions and 972 deletions.
21 changes: 11 additions & 10 deletions clang-tools-extra/clang-tidy/abseil/DurationDivisionCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,17 @@ void DurationDivisionCheck::registerMatchers(MatchFinder *finder) {
const auto DurationExpr =
expr(hasType(cxxRecordDecl(hasName("::absl::Duration"))));
finder->addMatcher(
implicitCastExpr(
hasSourceExpression(ignoringParenCasts(
cxxOperatorCallExpr(hasOverloadedOperatorName("/"),
hasArgument(0, DurationExpr),
hasArgument(1, DurationExpr))
.bind("OpCall"))),
hasImplicitDestinationType(qualType(unless(isInteger()))),
unless(hasParent(cxxStaticCastExpr())),
unless(hasParent(cStyleCastExpr())),
unless(isInTemplateInstantiation())),
traverse(ast_type_traits::TK_AsIs,
implicitCastExpr(
hasSourceExpression(ignoringParenCasts(
cxxOperatorCallExpr(hasOverloadedOperatorName("/"),
hasArgument(0, DurationExpr),
hasArgument(1, DurationExpr))
.bind("OpCall"))),
hasImplicitDestinationType(qualType(unless(isInteger()))),
unless(hasParent(cxxStaticCastExpr())),
unless(hasParent(cStyleCastExpr())),
unless(isInTemplateInstantiation()))),
this);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,20 +78,23 @@ void FasterStrsplitDelimiterCheck::registerMatchers(MatchFinder *Finder) {

// Find uses of absl::StrSplit(..., "x") and absl::StrSplit(...,
// absl::ByAnyChar("x")) to transform them into absl::StrSplit(..., 'x').
Finder->addMatcher(callExpr(callee(functionDecl(hasName("::absl::StrSplit"))),
hasArgument(1, anyOf(ByAnyCharArg, SingleChar)),
unless(isInTemplateInstantiation()))
.bind("StrSplit"),
this);
Finder->addMatcher(
traverse(ast_type_traits::TK_AsIs,
callExpr(callee(functionDecl(hasName("::absl::StrSplit"))),
hasArgument(1, anyOf(ByAnyCharArg, SingleChar)),
unless(isInTemplateInstantiation()))
.bind("StrSplit")),
this);

// Find uses of absl::MaxSplits("x", N) and
// absl::MaxSplits(absl::ByAnyChar("x"), N) to transform them into
// absl::MaxSplits('x', N).
Finder->addMatcher(
callExpr(
callee(functionDecl(hasName("::absl::MaxSplits"))),
hasArgument(0, anyOf(ByAnyCharArg, ignoringParenCasts(SingleChar))),
unless(isInTemplateInstantiation())),
traverse(ast_type_traits::TK_AsIs,
callExpr(callee(functionDecl(hasName("::absl::MaxSplits"))),
hasArgument(0, anyOf(ByAnyCharArg,
ignoringParenCasts(SingleChar))),
unless(isInTemplateInstantiation()))),
this);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,12 @@ const clang::CallExpr* ProcessArgument(const Expr* Arg,
static const auto* const Strcat = new auto(hasName("::absl::StrCat"));
const auto IsStrcat = cxxBindTemporaryExpr(
has(callExpr(callee(functionDecl(*Strcat))).bind("StrCat")));
if (const auto* SubStrcatCall = selectFirst<const CallExpr>(
if (const auto *SubStrcatCall = selectFirst<const CallExpr>(
"StrCat",
match(stmt(anyOf(
cxxConstructExpr(IsAlphanum, hasArgument(0, IsStrcat)),
IsStrcat)),
match(stmt(traverse(ast_type_traits::TK_AsIs,
anyOf(cxxConstructExpr(IsAlphanum,
hasArgument(0, IsStrcat)),
IsStrcat))),
*Arg->IgnoreParenImpCasts(), *Result.Context))) {
RemoveCallLeaveArgs(SubStrcatCall, CheckResult);
return SubStrcatCall;
Expand Down
19 changes: 11 additions & 8 deletions clang-tools-extra/clang-tidy/abseil/StrCatAppendCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,17 @@ void StrCatAppendCheck::registerMatchers(MatchFinder *Finder) {
// StrCat on the RHS. The first argument of the StrCat call should be the same
// as the LHS. Ignore calls from template instantiations.
Finder->addMatcher(
cxxOperatorCallExpr(
unless(isInTemplateInstantiation()), hasOverloadedOperatorName("="),
hasArgument(0, declRefExpr(to(decl().bind("LHS")))),
hasArgument(1, IgnoringTemporaries(
callExpr(callee(StrCat), hasArgument(0, AlphaNum),
unless(HasAnotherReferenceToLhs))
.bind("Call"))))
.bind("Op"),
traverse(ast_type_traits::TK_AsIs,
cxxOperatorCallExpr(
unless(isInTemplateInstantiation()),
hasOverloadedOperatorName("="),
hasArgument(0, declRefExpr(to(decl().bind("LHS")))),
hasArgument(
1, IgnoringTemporaries(
callExpr(callee(StrCat), hasArgument(0, AlphaNum),
unless(HasAnotherReferenceToLhs))
.bind("Call"))))
.bind("Op")),
this);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,17 @@ void UpgradeDurationConversionsCheck::registerMatchers(MatchFinder *Finder) {
// `absl::Hours(x)`
// where `x` is not of a built-in type.
Finder->addMatcher(
implicitCastExpr(
anyOf(hasCastKind(CK_UserDefinedConversion),
has(implicitCastExpr(hasCastKind(CK_UserDefinedConversion)))),
hasParent(callExpr(
callee(functionDecl(DurationFactoryFunction(),
unless(hasParent(functionTemplateDecl())))),
hasArgument(0, expr().bind("arg")))))
.bind("OuterExpr"),
traverse(
ast_type_traits::TK_AsIs,
implicitCastExpr(anyOf(hasCastKind(CK_UserDefinedConversion),
has(implicitCastExpr(
hasCastKind(CK_UserDefinedConversion)))),
hasParent(callExpr(
callee(functionDecl(
DurationFactoryFunction(),
unless(hasParent(functionTemplateDecl())))),
hasArgument(0, expr().bind("arg")))))
.bind("OuterExpr")),
this);
}

Expand All @@ -116,6 +119,8 @@ void UpgradeDurationConversionsCheck::check(
"implicit conversion to 'int64_t' is deprecated in this context; use an "
"explicit cast instead";

TraversalKindScope RAII(*Result.Context, ast_type_traits::TK_AsIs);

const auto *ArgExpr = Result.Nodes.getNodeAs<Expr>("arg");
SourceLocation Loc = ArgExpr->getBeginLoc();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ void AssertSideEffectCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {

void AssertSideEffectCheck::registerMatchers(MatchFinder *Finder) {
auto DescendantWithSideEffect =
hasDescendant(expr(hasSideEffect(CheckFunctionCalls)));
traverse(ast_type_traits::TK_AsIs,
hasDescendant(expr(hasSideEffect(CheckFunctionCalls))));
auto ConditionWithSideEffect = hasCondition(DescendantWithSideEffect);
Finder->addMatcher(
stmt(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,16 @@ void BoolPointerImplicitConversionCheck::registerMatchers(MatchFinder *Finder) {
// Look for ifs that have an implicit bool* to bool conversion in the
// condition. Filter negations.
Finder->addMatcher(
ifStmt(hasCondition(findAll(implicitCastExpr(
unless(hasParent(unaryOperator(hasOperatorName("!")))),
hasSourceExpression(
expr(hasType(pointerType(pointee(booleanType()))),
ignoringParenImpCasts(declRefExpr().bind("expr")))),
hasCastKind(CK_PointerToBoolean)))),
unless(isInTemplateInstantiation()))
.bind("if"),
traverse(
ast_type_traits::TK_AsIs,
ifStmt(hasCondition(findAll(implicitCastExpr(
unless(hasParent(unaryOperator(hasOperatorName("!")))),
hasSourceExpression(expr(
hasType(pointerType(pointee(booleanType()))),
ignoringParenImpCasts(declRefExpr().bind("expr")))),
hasCastKind(CK_PointerToBoolean)))),
unless(isInTemplateInstantiation()))
.bind("if")),
this);
}

Expand Down
74 changes: 41 additions & 33 deletions clang-tools-extra/clang-tidy/bugprone/DanglingHandleCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,55 +117,63 @@ void DanglingHandleCheck::registerMatchersForVariables(MatchFinder *Finder) {

// Find 'Handle foo = ReturnsAValue();'
Finder->addMatcher(
varDecl(
hasType(hasUnqualifiedDesugaredType(
recordType(hasDeclaration(cxxRecordDecl(IsAHandle))))),
unless(parmVarDecl()),
hasInitializer(exprWithCleanups(has(ignoringParenImpCasts(handleFrom(
traverse(ast_type_traits::TK_AsIs,
varDecl(hasType(hasUnqualifiedDesugaredType(recordType(
hasDeclaration(cxxRecordDecl(IsAHandle))))),
unless(parmVarDecl()),
hasInitializer(exprWithCleanups(
has(ignoringParenImpCasts(handleFrom(
IsAHandle, ConvertedHandle))))
.bind("bad_stmt"))),
.bind("bad_stmt")))),
this);
// Find 'foo = ReturnsAValue(); // foo is Handle'
Finder->addMatcher(
cxxOperatorCallExpr(callee(cxxMethodDecl(ofClass(IsAHandle))),
hasOverloadedOperatorName("="),
hasArgument(1, ConvertedHandle))
.bind("bad_stmt"),
traverse(ast_type_traits::TK_AsIs,
cxxOperatorCallExpr(callee(cxxMethodDecl(ofClass(IsAHandle))),
hasOverloadedOperatorName("="),
hasArgument(1, ConvertedHandle))
.bind("bad_stmt")),
this);

// Container insertions that will dangle.
Finder->addMatcher(makeContainerMatcher(IsAHandle).bind("bad_stmt"), this);
Finder->addMatcher(traverse(ast_type_traits::TK_AsIs,
makeContainerMatcher(IsAHandle).bind("bad_stmt")),
this);
}

void DanglingHandleCheck::registerMatchersForReturn(MatchFinder *Finder) {
// Return a local.
Finder->addMatcher(
returnStmt(
// The AST contains two constructor calls:
// 1. Value to Handle conversion.
// 2. Handle copy construction.
// We have to match both.
has(ignoringImplicit(handleFrom(
IsAHandle,
handleFrom(IsAHandle,
declRefExpr(to(varDecl(
// Is function scope ...
hasAutomaticStorageDuration(),
// ... and it is a local array or Value.
anyOf(hasType(arrayType()),
hasType(hasUnqualifiedDesugaredType(
recordType(hasDeclaration(recordDecl(
unless(IsAHandle)))))))))))))),
// Temporary fix for false positives inside lambdas.
unless(hasAncestor(lambdaExpr())))
.bind("bad_stmt"),
traverse(
ast_type_traits::TK_AsIs,
returnStmt(
// The AST contains two constructor calls:
// 1. Value to Handle conversion.
// 2. Handle copy construction.
// We have to match both.
has(ignoringImplicit(handleFrom(
IsAHandle,
handleFrom(IsAHandle,
declRefExpr(to(varDecl(
// Is function scope ...
hasAutomaticStorageDuration(),
// ... and it is a local array or Value.
anyOf(hasType(arrayType()),
hasType(hasUnqualifiedDesugaredType(
recordType(hasDeclaration(recordDecl(
unless(IsAHandle)))))))))))))),
// Temporary fix for false positives inside lambdas.
unless(hasAncestor(lambdaExpr())))
.bind("bad_stmt")),
this);

// Return a temporary.
Finder->addMatcher(
returnStmt(has(exprWithCleanups(has(ignoringParenImpCasts(handleFrom(
IsAHandle, handleFromTemporaryValue(IsAHandle)))))))
.bind("bad_stmt"),
traverse(
ast_type_traits::TK_AsIs,
returnStmt(has(exprWithCleanups(has(ignoringParenImpCasts(handleFrom(
IsAHandle, handleFromTemporaryValue(IsAHandle)))))))
.bind("bad_stmt")),
this);
}

Expand Down
16 changes: 9 additions & 7 deletions clang-tools-extra/clang-tidy/bugprone/InaccurateEraseCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,15 @@ void InaccurateEraseCheck::registerMatchers(MatchFinder *Finder) {
const auto DeclInStd = type(hasUnqualifiedDesugaredType(
tagType(hasDeclaration(decl(isInStdNamespace())))));
Finder->addMatcher(
cxxMemberCallExpr(
on(anyOf(hasType(DeclInStd), hasType(pointsTo(DeclInStd)))),
callee(cxxMethodDecl(hasName("erase"))), argumentCountIs(1),
hasArgument(0, has(ignoringImplicit(
anyOf(EndCall, has(ignoringImplicit(EndCall)))))),
unless(isInTemplateInstantiation()))
.bind("erase"),
traverse(
ast_type_traits::TK_AsIs,
cxxMemberCallExpr(
on(anyOf(hasType(DeclInStd), hasType(pointsTo(DeclInStd)))),
callee(cxxMethodDecl(hasName("erase"))), argumentCountIs(1),
hasArgument(0, has(ignoringImplicit(anyOf(
EndCall, has(ignoringImplicit(EndCall)))))),
unless(isInTemplateInstantiation()))
.bind("erase")),
this);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,11 @@ void IncorrectRoundingsCheck::registerMatchers(MatchFinder *MatchFinder) {
// Find expressions of cast to int of the sum of a floating point expression
// and 0.5.
MatchFinder->addMatcher(
implicitCastExpr(
hasImplicitDestinationType(isInteger()),
ignoringParenCasts(binaryOperator(hasOperatorName("+"), OneSideHalf)))
.bind("CastExpr"),
traverse(ast_type_traits::TK_AsIs,
implicitCastExpr(hasImplicitDestinationType(isInteger()),
ignoringParenCasts(binaryOperator(
hasOperatorName("+"), OneSideHalf)))
.bind("CastExpr")),
this);
}

Expand Down
18 changes: 10 additions & 8 deletions clang-tools-extra/clang-tidy/bugprone/IntegerDivisionCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,16 @@ void IntegerDivisionCheck::registerMatchers(MatchFinder *Finder) {
callExpr(IntType), explicitCastExpr(IntType), UnaryOperators);

Finder->addMatcher(
binaryOperator(
hasOperatorName("/"), hasLHS(expr(IntType)), hasRHS(expr(IntType)),
hasAncestor(
castExpr(hasCastKind(CK_IntegralToFloating)).bind("FloatCast")),
unless(hasAncestor(
expr(Exceptions,
hasAncestor(castExpr(equalsBoundNode("FloatCast")))))))
.bind("IntDiv"),
traverse(ast_type_traits::TK_AsIs,
binaryOperator(
hasOperatorName("/"), hasLHS(expr(IntType)),
hasRHS(expr(IntType)),
hasAncestor(castExpr(hasCastKind(CK_IntegralToFloating))
.bind("FloatCast")),
unless(hasAncestor(expr(
Exceptions,
hasAncestor(castExpr(equalsBoundNode("FloatCast")))))))
.bind("IntDiv")),
this);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,22 @@ void MisplacedOperatorInStrlenInAllocCheck::registerMatchers(
hasInitializer(ignoringParenImpCasts(
declRefExpr(hasDeclaration(Alloc1Func)))));

Finder->addMatcher(callExpr(callee(decl(anyOf(Alloc0Func, Alloc0FuncPtr))),
hasArgument(0, BadArg))
.bind("Alloc"),
this);
Finder->addMatcher(callExpr(callee(decl(anyOf(Alloc1Func, Alloc1FuncPtr))),
hasArgument(1, BadArg))
.bind("Alloc"),
this);
Finder->addMatcher(
cxxNewExpr(isArray(), hasArraySize(BadArg)).bind("Alloc"), this);
traverse(ast_type_traits::TK_AsIs,
callExpr(callee(decl(anyOf(Alloc0Func, Alloc0FuncPtr))),
hasArgument(0, BadArg))
.bind("Alloc")),
this);
Finder->addMatcher(
traverse(ast_type_traits::TK_AsIs,
callExpr(callee(decl(anyOf(Alloc1Func, Alloc1FuncPtr))),
hasArgument(1, BadArg))
.bind("Alloc")),
this);
Finder->addMatcher(
traverse(ast_type_traits::TK_AsIs,
cxxNewExpr(isArray(), hasArraySize(BadArg)).bind("Alloc")),
this);
}

void MisplacedOperatorInStrlenInAllocCheck::check(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ void MisplacedWideningCastCheck::registerMatchers(MatchFinder *Finder) {
const auto ImplicitCast =
implicitCastExpr(hasImplicitDestinationType(isInteger()),
has(ignoringParenImpCasts(Calc)));
const auto Cast = expr(anyOf(ExplicitCast, ImplicitCast)).bind("Cast");
const auto Cast =
traverse(ast_type_traits::TK_AsIs,
expr(anyOf(ExplicitCast, ImplicitCast)).bind("Cast"));

Finder->addMatcher(varDecl(hasInitializer(Cast)), this);
Finder->addMatcher(returnStmt(hasReturnValue(Cast)), this);
Expand Down
Loading

0 comments on commit 9d914d7

Please sign in to comment.