Skip to content

Commit ca8b94e

Browse files
authored
LLVM and SPIRV-LLVM-Translator pulldown (WW41)
LLVM: llvm/llvm-project@e372c1d SPIRV-LLVM-Translator: KhronosGroup/SPIRV-LLVM-Translator@f33b946
2 parents 049ae99 + 1321600 commit ca8b94e

File tree

1,555 files changed

+58172
-25514
lines changed

Some content is hidden

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

1,555 files changed

+58172
-25514
lines changed

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

Lines changed: 41 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -18,32 +18,17 @@ namespace clang {
1818
namespace tidy {
1919
namespace android {
2020

21-
namespace {
22-
AST_MATCHER(BinaryOperator, isRHSATempFailureRetryArg) {
23-
if (!Node.getBeginLoc().isMacroID())
24-
return false;
25-
26-
const SourceManager &SM = Finder->getASTContext().getSourceManager();
27-
if (!SM.isMacroArgExpansion(Node.getRHS()->IgnoreParenCasts()->getBeginLoc()))
28-
return false;
29-
30-
const LangOptions &Opts = Finder->getASTContext().getLangOpts();
31-
SourceLocation LocStart = Node.getBeginLoc();
32-
while (LocStart.isMacroID()) {
33-
SourceLocation Invocation = SM.getImmediateMacroCallerLoc(LocStart);
34-
Token Tok;
35-
if (!Lexer::getRawToken(SM.getSpellingLoc(Invocation), Tok, SM, Opts,
36-
/*IgnoreWhiteSpace=*/true)) {
37-
if (Tok.getKind() == tok::raw_identifier &&
38-
Tok.getRawIdentifier() == "TEMP_FAILURE_RETRY")
39-
return true;
40-
}
21+
ComparisonInTempFailureRetryCheck::ComparisonInTempFailureRetryCheck(
22+
StringRef Name, ClangTidyContext *Context)
23+
: ClangTidyCheck(Name, Context),
24+
RawRetryList(Options.get("RetryMacros", "TEMP_FAILURE_RETRY")) {
25+
StringRef(RawRetryList).split(RetryMacros, ",", -1, false);
26+
}
4127

42-
LocStart = Invocation;
43-
}
44-
return false;
28+
void ComparisonInTempFailureRetryCheck::storeOptions(
29+
ClangTidyOptions::OptionMap &Opts) {
30+
Options.store(Opts, "RetryMacros", RawRetryList);
4531
}
46-
} // namespace
4732

4833
void ComparisonInTempFailureRetryCheck::registerMatchers(MatchFinder *Finder) {
4934
// Both glibc's and Bionic's TEMP_FAILURE_RETRY macros structurally look like:
@@ -63,15 +48,43 @@ void ComparisonInTempFailureRetryCheck::registerMatchers(MatchFinder *Finder) {
6348
Finder->addMatcher(
6449
binaryOperator(hasOperatorName("="),
6550
hasRHS(ignoringParenCasts(
66-
binaryOperator(isComparisonOperator()).bind("binop"))),
67-
isRHSATempFailureRetryArg()),
51+
binaryOperator(isComparisonOperator()).bind("inner"))))
52+
.bind("outer"),
6853
this);
6954
}
7055

7156
void ComparisonInTempFailureRetryCheck::check(
7257
const MatchFinder::MatchResult &Result) {
73-
const auto &BinOp = *Result.Nodes.getNodeAs<BinaryOperator>("binop");
74-
diag(BinOp.getOperatorLoc(), "top-level comparison in TEMP_FAILURE_RETRY");
58+
StringRef RetryMacroName;
59+
const auto &Node = *Result.Nodes.getNodeAs<BinaryOperator>("outer");
60+
if (!Node.getBeginLoc().isMacroID())
61+
return;
62+
63+
const SourceManager &SM = *Result.SourceManager;
64+
if (!SM.isMacroArgExpansion(Node.getRHS()->IgnoreParenCasts()->getBeginLoc()))
65+
return;
66+
67+
const LangOptions &Opts = Result.Context->getLangOpts();
68+
SourceLocation LocStart = Node.getBeginLoc();
69+
while (LocStart.isMacroID()) {
70+
SourceLocation Invocation = SM.getImmediateMacroCallerLoc(LocStart);
71+
Token Tok;
72+
if (!Lexer::getRawToken(SM.getSpellingLoc(Invocation), Tok, SM, Opts,
73+
/*IgnoreWhiteSpace=*/true)) {
74+
if (Tok.getKind() == tok::raw_identifier &&
75+
llvm::is_contained(RetryMacros, Tok.getRawIdentifier())) {
76+
RetryMacroName = Tok.getRawIdentifier();
77+
break;
78+
}
79+
}
80+
81+
LocStart = Invocation;
82+
}
83+
if (RetryMacroName.empty())
84+
return;
85+
86+
const auto &Inner = *Result.Nodes.getNodeAs<BinaryOperator>("inner");
87+
diag(Inner.getOperatorLoc(), "top-level comparison in %0") << RetryMacroName;
7588

7689
// FIXME: FixIts would be nice, but potentially nontrivial when nested macros
7790
// happen, e.g. `TEMP_FAILURE_RETRY(IS_ZERO(foo()))`

clang-tools-extra/clang-tidy/android/ComparisonInTempFailureRetryCheck.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_COMPARISONINTEMPFAILURERETRYCHECK_H
1111

1212
#include "../ClangTidyCheck.h"
13+
#include "llvm/ADT/SmallVector.h"
14+
#include "llvm/ADT/StringRef.h"
15+
#include <string>
1316

1417
namespace clang {
1518
namespace tidy {
@@ -22,10 +25,14 @@ namespace android {
2225
/// TEMP_FAILURE_RETRY is a macro provided by both glibc and Bionic.
2326
class ComparisonInTempFailureRetryCheck : public ClangTidyCheck {
2427
public:
25-
ComparisonInTempFailureRetryCheck(StringRef Name, ClangTidyContext *Context)
26-
: ClangTidyCheck(Name, Context) {}
28+
ComparisonInTempFailureRetryCheck(StringRef Name, ClangTidyContext *Context);
29+
void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
2730
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
2831
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
32+
33+
private:
34+
const std::string RawRetryList;
35+
SmallVector<StringRef, 5> RetryMacros;
2936
};
3037

3138
} // namespace android

clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@ struct UnqualNameVisitor : public RecursiveASTVisitor<UnqualNameVisitor> {
6666
->getName()))
6767
return false;
6868
break;
69+
case TypeLoc::Typedef:
70+
if (VisitUnqualName(
71+
TL.getAs<TypedefTypeLoc>().getTypePtr()->getDecl()->getName()))
72+
return false;
73+
break;
6974
default:
7075
break;
7176
}

clang-tools-extra/clang-tidy/readability/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ add_clang_library(clangTidyReadabilityModule
1212
DeleteNullPointerCheck.cpp
1313
DeletedDefaultCheck.cpp
1414
ElseAfterReturnCheck.cpp
15+
FunctionCognitiveComplexityCheck.cpp
1516
FunctionSizeCheck.cpp
1617
IdentifierNamingCheck.cpp
1718
ImplicitBoolConversionCheck.cpp

0 commit comments

Comments
 (0)