Skip to content

Commit 7b7e044

Browse files
committed
LLVM and SPIRV-LLVM-Translator pulldown (WW01)
LLVM: llvm/llvm-project@bb84dd81590b SPIRV-LLVM-Translator: KhronosGroup/SPIRV-LLVM-Translator@987a1ab
2 parents 8dae986 + e07fa00 commit 7b7e044

File tree

1,487 files changed

+127591
-111654
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,487 files changed

+127591
-111654
lines changed

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

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88

99
#include "SymbolIndexManager.h"
1010
#include "find-all-symbols/SymbolInfo.h"
11-
#include "llvm/ADT/DenseMap.h"
11+
#include "llvm/ADT/STLExtras.h"
1212
#include "llvm/ADT/SmallVector.h"
13+
#include "llvm/ADT/StringMap.h"
1314
#include "llvm/Support/Debug.h"
1415
#include "llvm/Support/Path.h"
1516

@@ -47,7 +48,7 @@ static double similarityScore(llvm::StringRef FileName,
4748

4849
static void rank(std::vector<SymbolAndSignals> &Symbols,
4950
llvm::StringRef FileName) {
50-
llvm::DenseMap<llvm::StringRef, double> Score;
51+
llvm::StringMap<double> Score;
5152
for (const auto &Symbol : Symbols) {
5253
// Calculate a score from the similarity of the header the symbol is in
5354
// with the current file and the popularity of the symbol.
@@ -58,14 +59,14 @@ static void rank(std::vector<SymbolAndSignals> &Symbols,
5859
}
5960
// Sort by the gathered scores. Use file name as a tie breaker so we can
6061
// deduplicate.
61-
std::sort(Symbols.begin(), Symbols.end(),
62-
[&](const SymbolAndSignals &A, const SymbolAndSignals &B) {
63-
auto AS = Score[A.Symbol.getFilePath()];
64-
auto BS = Score[B.Symbol.getFilePath()];
65-
if (AS != BS)
66-
return AS > BS;
67-
return A.Symbol.getFilePath() < B.Symbol.getFilePath();
68-
});
62+
llvm::sort(Symbols.begin(), Symbols.end(),
63+
[&](const SymbolAndSignals &A, const SymbolAndSignals &B) {
64+
auto AS = Score[A.Symbol.getFilePath()];
65+
auto BS = Score[B.Symbol.getFilePath()];
66+
if (AS != BS)
67+
return AS > BS;
68+
return A.Symbol.getFilePath() < B.Symbol.getFilePath();
69+
});
6970
}
7071

7172
std::vector<find_all_symbols::SymbolInfo>

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/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/google/UpgradeGoogletestCaseCheck.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,12 @@ void UpgradeGoogletestCaseCheck::registerMatchers(MatchFinder *Finder) {
196196
usingDecl(hasAnyUsingShadowDecl(hasTargetDecl(TestCaseTypeAlias)))
197197
.bind("using"),
198198
this);
199+
Finder->addMatcher(
200+
typeLoc(loc(usingType(hasUnderlyingType(
201+
typedefType(hasDeclaration(TestCaseTypeAlias))))),
202+
unless(hasAncestor(decl(isImplicit()))), LocationFilter)
203+
.bind("typeloc"),
204+
this);
199205
}
200206

201207
static llvm::StringRef getNewMethodName(llvm::StringRef CurrentName) {

clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ AST_MATCHER_P(DeducedTemplateSpecializationType, refsToTemplatedDecl,
4545
return DeclMatcher.matches(*TD, Finder, Builder);
4646
return false;
4747
}
48+
4849
} // namespace
4950

5051
// A function that helps to tell whether a TargetDecl in a UsingDecl will be
@@ -60,13 +61,10 @@ static bool shouldCheckDecl(const Decl *TargetDecl) {
6061
void UnusedUsingDeclsCheck::registerMatchers(MatchFinder *Finder) {
6162
Finder->addMatcher(usingDecl(isExpansionInMainFile()).bind("using"), this);
6263
auto DeclMatcher = hasDeclaration(namedDecl().bind("used"));
63-
Finder->addMatcher(loc(enumType(DeclMatcher)), this);
64-
Finder->addMatcher(loc(recordType(DeclMatcher)), this);
6564
Finder->addMatcher(loc(templateSpecializationType(DeclMatcher)), this);
6665
Finder->addMatcher(loc(deducedTemplateSpecializationType(
6766
refsToTemplatedDecl(namedDecl().bind("used")))),
6867
this);
69-
Finder->addMatcher(declRefExpr().bind("used"), this);
7068
Finder->addMatcher(callExpr(callee(unresolvedLookupExpr().bind("used"))),
7169
this);
7270
Finder->addMatcher(
@@ -76,6 +74,12 @@ void UnusedUsingDeclsCheck::registerMatchers(MatchFinder *Finder) {
7674
Finder->addMatcher(loc(templateSpecializationType(forEachTemplateArgument(
7775
templateArgument().bind("used")))),
7876
this);
77+
// Cases where we can identify the UsingShadowDecl directly, rather than
78+
// just its target.
79+
// FIXME: cover more cases in this way, as the AST supports it.
80+
auto ThroughShadowMatcher = throughUsingDecl(namedDecl().bind("usedShadow"));
81+
Finder->addMatcher(declRefExpr(ThroughShadowMatcher), this);
82+
Finder->addMatcher(loc(usingType(ThroughShadowMatcher)), this);
7983
}
8084

8185
void UnusedUsingDeclsCheck::check(const MatchFinder::MatchResult &Result) {
@@ -137,6 +141,12 @@ void UnusedUsingDeclsCheck::check(const MatchFinder::MatchResult &Result) {
137141
return;
138142
}
139143

144+
if (const auto *UsedShadow =
145+
Result.Nodes.getNodeAs<UsingShadowDecl>("usedShadow")) {
146+
removeFromFoundDecls(UsedShadow->getTargetDecl());
147+
return;
148+
}
149+
140150
if (const auto *Used = Result.Nodes.getNodeAs<TemplateArgument>("used")) {
141151
if (Used->getKind() == TemplateArgument::Template) {
142152
if (const auto *TD = Used->getAsTemplate().getAsTemplateDecl())

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,13 @@ struct UnqualNameVisitor : public RecursiveASTVisitor<UnqualNameVisitor> {
7070
TL.getAs<TypedefTypeLoc>().getTypePtr()->getDecl()->getName()))
7171
return false;
7272
break;
73+
case TypeLoc::Using:
74+
if (visitUnqualName(TL.getAs<UsingTypeLoc>()
75+
.getTypePtr()
76+
->getFoundDecl()
77+
->getName()))
78+
return false;
79+
break;
7380
default:
7481
break;
7582
}

clang-tools-extra/clangd/ClangdLSPServer.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,13 +1208,6 @@ void ClangdLSPServer::onCallHierarchyIncomingCalls(
12081208
Server->incomingCalls(Params.item, std::move(Reply));
12091209
}
12101210

1211-
void ClangdLSPServer::onCallHierarchyOutgoingCalls(
1212-
const CallHierarchyOutgoingCallsParams &Params,
1213-
Callback<std::vector<CallHierarchyOutgoingCall>> Reply) {
1214-
// FIXME: To be implemented.
1215-
Reply(std::vector<CallHierarchyOutgoingCall>{});
1216-
}
1217-
12181211
void ClangdLSPServer::onInlayHints(const InlayHintsParams &Params,
12191212
Callback<std::vector<InlayHint>> Reply) {
12201213
Server->inlayHints(Params.textDocument.uri.file(), std::move(Reply));
@@ -1478,7 +1471,6 @@ void ClangdLSPServer::bindMethods(LSPBinder &Bind,
14781471
Bind.method("typeHierarchy/resolve", this, &ClangdLSPServer::onResolveTypeHierarchy);
14791472
Bind.method("textDocument/prepareCallHierarchy", this, &ClangdLSPServer::onPrepareCallHierarchy);
14801473
Bind.method("callHierarchy/incomingCalls", this, &ClangdLSPServer::onCallHierarchyIncomingCalls);
1481-
Bind.method("callHierarchy/outgoingCalls", this, &ClangdLSPServer::onCallHierarchyOutgoingCalls);
14821474
Bind.method("textDocument/selectionRange", this, &ClangdLSPServer::onSelectionRange);
14831475
Bind.method("textDocument/documentLink", this, &ClangdLSPServer::onDocumentLink);
14841476
Bind.method("textDocument/semanticTokens/full", this, &ClangdLSPServer::onSemanticTokens);

clang-tools-extra/clangd/FindTarget.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,10 @@ struct TargetFinder {
364364
Outer.add(ET->desugar(), Flags);
365365
}
366366

367+
void VisitUsingType(const UsingType *ET) {
368+
Outer.add(ET->getFoundDecl(), Flags);
369+
}
370+
367371
void VisitInjectedClassNameType(const InjectedClassNameType *ICNT) {
368372
Outer.add(ICNT->getDecl(), Flags);
369373
}
@@ -855,6 +859,13 @@ refInTypeLoc(TypeLoc L, const HeuristicResolver *Resolver) {
855859
}
856860
}
857861

862+
void VisitUsingTypeLoc(UsingTypeLoc L) {
863+
Refs.push_back(ReferenceLoc{NestedNameSpecifierLoc(),
864+
L.getLocalSourceRange().getBegin(),
865+
/*IsDecl=*/false,
866+
{L.getFoundDecl()}});
867+
}
868+
858869
void VisitTagTypeLoc(TagTypeLoc L) {
859870
Refs.push_back(ReferenceLoc{NestedNameSpecifierLoc(),
860871
L.getNameLoc(),

clang-tools-extra/clangd/IncludeCleaner.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@ class ReferencedLocationCrawler
7474
return true;
7575
}
7676

77+
bool VisitUsingType(UsingType *UT) {
78+
add(UT->getFoundDecl());
79+
return true;
80+
}
81+
7782
bool VisitTypedefType(TypedefType *TT) {
7883
add(TT->getDecl());
7984
return true;

0 commit comments

Comments
 (0)