Skip to content

Commit cc6e3f4

Browse files
committed
Merge from 'master' to 'sycl-web' (#128)
CONFLICT (content): Merge conflict in clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp CONFLICT (content): Merge conflict in clang/test/Driver/clang-offload-bundler.c
2 parents 70e4c84 + 6e82d0d commit cc6e3f4

File tree

359 files changed

+14551
-5536
lines changed

Some content is hidden

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

359 files changed

+14551
-5536
lines changed

clang-tools-extra/CODE_OWNERS.TXT

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,7 @@ D: clang-tidy
2323
N: Julie Hockett
2424
E: juliehockett@google.com
2525
D: clang-doc
26+
27+
N: Sam McCall
28+
E: sammccall@google.com
29+
D: clangd

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ genStylesheetsHTML(StringRef InfoPath, const ClangDocContext &CDCtx) {
278278
llvm::sys::path::filename(FilePath));
279279
// Paths in HTML must be in posix-style
280280
llvm::sys::path::native(StylesheetPath, llvm::sys::path::Style::posix);
281-
LinkNode->Attributes.emplace_back("href", StylesheetPath.str());
281+
LinkNode->Attributes.emplace_back("href", std::string(StylesheetPath.str()));
282282
Out.emplace_back(std::move(LinkNode));
283283
}
284284
return Out;
@@ -293,7 +293,7 @@ genJsScriptsHTML(StringRef InfoPath, const ClangDocContext &CDCtx) {
293293
llvm::sys::path::append(ScriptPath, llvm::sys::path::filename(FilePath));
294294
// Paths in HTML must be in posix-style
295295
llvm::sys::path::native(ScriptPath, llvm::sys::path::Style::posix);
296-
ScriptNode->Attributes.emplace_back("src", ScriptPath.str());
296+
ScriptNode->Attributes.emplace_back("src", std::string(ScriptPath.str()));
297297
Out.emplace_back(std::move(ScriptNode));
298298
}
299299
return Out;
@@ -422,7 +422,7 @@ genReferencesBlock(const std::vector<Reference> &References,
422422

423423
std::vector<std::unique_ptr<TagNode>> Out;
424424
Out.emplace_back(std::make_unique<TagNode>(HTMLTag::TAG_H2, Title));
425-
Out.back()->Attributes.emplace_back("id", Title);
425+
Out.back()->Attributes.emplace_back("id", std::string(Title));
426426
Out.emplace_back(std::make_unique<TagNode>(HTMLTag::TAG_UL));
427427
auto &ULBody = Out.back();
428428
for (const auto &R : References) {
@@ -454,7 +454,7 @@ writeFileDefinition(const Location &L,
454454
Node->Children.emplace_back(std::make_unique<TextNode>(" of file "));
455455
auto LocFileNode = std::make_unique<TagNode>(
456456
HTMLTag::TAG_A, llvm::sys::path::filename(FileURL));
457-
LocFileNode->Attributes.emplace_back("href", FileURL.str());
457+
LocFileNode->Attributes.emplace_back("href", std::string(FileURL.str()));
458458
Node->Children.emplace_back(std::move(LocFileNode));
459459
return Node;
460460
}
@@ -502,7 +502,7 @@ static std::unique_ptr<TagNode> genInfoFileMainNode(
502502

503503
auto LeftSidebarNode = std::make_unique<TagNode>(HTMLTag::TAG_DIV);
504504
LeftSidebarNode->Attributes.emplace_back("id", "sidebar-left");
505-
LeftSidebarNode->Attributes.emplace_back("path", InfoPath);
505+
LeftSidebarNode->Attributes.emplace_back("path", std::string(InfoPath));
506506
LeftSidebarNode->Attributes.emplace_back(
507507
"class", "col-xs-6 col-sm-3 col-md-2 sidebar sidebar-offcanvas-left");
508508

clang-tools-extra/clang-reorder-fields/ReorderFieldsAction.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ using llvm::SmallSetVector;
3636
static const RecordDecl *findDefinition(StringRef RecordName,
3737
ASTContext &Context) {
3838
auto Results =
39-
match(recordDecl(hasName(std::string(RecordName)), isDefinition())
40-
.bind("recordDecl"),
39+
match(recordDecl(hasName(RecordName), isDefinition()).bind("recordDecl"),
4140
Context);
4241
if (Results.empty()) {
4342
llvm::errs() << "Definition of " << RecordName << " not found\n";

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ static CheckersList getAnalyzerCheckersAndPackages(ClangTidyContext &Context,
359359

360360
if (CheckName.startswith("core") ||
361361
Context.isCheckEnabled(ClangTidyCheckName)) {
362-
List.emplace_back(CheckName, true);
362+
List.emplace_back(std::string(CheckName), true);
363363
}
364364
}
365365
return List;

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,8 @@ class ClangTidyContext {
174174
return DiagLevelAndFormatString(
175175
static_cast<DiagnosticIDs::Level>(
176176
DiagEngine->getDiagnosticLevel(DiagnosticID, Loc)),
177-
DiagEngine->getDiagnosticIDs()->getDescription(DiagnosticID));
177+
std::string(
178+
DiagEngine->getDiagnosticIDs()->getDescription(DiagnosticID)));
178179
}
179180

180181
private:

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,7 @@ rewriteInverseTimeCall(const MatchFinder::MatchResult &Result,
9191
DurationScale Scale, const Expr &Node) {
9292
llvm::StringRef InverseFunction = getTimeInverseForScale(Scale);
9393
if (const auto *MaybeCallArg = selectFirst<const Expr>(
94-
"e", match(callExpr(callee(functionDecl(
95-
hasName(std::string(InverseFunction)))),
94+
"e", match(callExpr(callee(functionDecl(hasName(InverseFunction))),
9695
hasArgument(0, expr().bind("e"))),
9796
Node, *Result.Context))) {
9897
return tooling::fixit::getText(*MaybeCallArg, *Result.Context).str();

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,11 @@ void TimeSubtractionCheck::registerMatchers(MatchFinder *Finder) {
108108
// a 'Duration'. If we know the result is a 'Duration', we can then infer
109109
// that the second operand must be a 'Time'.
110110
auto CallMatcher =
111-
callExpr(callee(functionDecl(
112-
hasName(std::string(getDurationFactoryForScale(*Scale))))),
113-
hasArgument(0, binaryOperator(hasOperatorName("-"),
114-
hasLHS(TimeInverseMatcher))
115-
.bind("binop")))
111+
callExpr(
112+
callee(functionDecl(hasName(getDurationFactoryForScale(*Scale)))),
113+
hasArgument(0, binaryOperator(hasOperatorName("-"),
114+
hasLHS(TimeInverseMatcher))
115+
.bind("binop")))
116116
.bind("outer_call");
117117
Finder->addMatcher(CallMatcher, this);
118118

@@ -160,8 +160,8 @@ void TimeSubtractionCheck::check(const MatchFinder::MatchResult &Result) {
160160
// latter case (addressed first), we also need to worry about parenthesis.
161161
const auto *MaybeCallArg = selectFirst<const CallExpr>(
162162
"arg", match(expr(hasAncestor(
163-
callExpr(callee(functionDecl(hasName(std::string(
164-
getDurationFactoryForScale(*Scale))))))
163+
callExpr(callee(functionDecl(hasName(
164+
getDurationFactoryForScale(*Scale)))))
165165
.bind("arg"))),
166166
*BinOp, *Result.Context));
167167
if (MaybeCallArg && MaybeCallArg->getArg(0)->IgnoreImpCasts() == BinOp &&

clang-tools-extra/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ void SpecialMemberFunctionsCheck::check(
103103
if (!MatchedDecl)
104104
return;
105105

106-
ClassDefId ID(MatchedDecl->getLocation(), MatchedDecl->getName());
106+
ClassDefId ID(MatchedDecl->getLocation(), std::string(MatchedDecl->getName()));
107107

108108
auto StoreMember = [this, &ID](SpecialMemberFunctionKind Kind) {
109109
llvm::SmallVectorImpl<SpecialMemberFunctionKind> &Members =

clang-tools-extra/clang-tidy/google/UpgradeGoogletestCaseCheck.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -242,10 +242,10 @@ static bool
242242
derivedTypeHasReplacementMethod(const MatchFinder::MatchResult &Result,
243243
llvm::StringRef ReplacementMethod) {
244244
const auto *Class = Result.Nodes.getNodeAs<CXXRecordDecl>("class");
245-
return !match(cxxRecordDecl(unless(isExpansionInFileMatching(
246-
"gtest/gtest(-typed-test)?\\.h$")),
247-
hasMethod(cxxMethodDecl(
248-
hasName(std::string(ReplacementMethod))))),
245+
return !match(cxxRecordDecl(
246+
unless(isExpansionInFileMatching(
247+
"gtest/gtest(-typed-test)?\\.h$")),
248+
hasMethod(cxxMethodDecl(hasName(ReplacementMethod)))),
249249
*Class, *Result.Context)
250250
.empty();
251251
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ classifyToken(const FunctionDecl &F, Preprocessor &PP, Token Tok) {
173173
bool ContainsSomethingElse = false;
174174

175175
Token End;
176+
End.startToken();
176177
End.setKind(tok::eof);
177178
SmallVector<Token, 2> Stream{Tok, End};
178179

clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ void RenamerClangTidyCheck::checkMacro(SourceManager &SourceMgr,
340340
return;
341341
FailureInfo &Info = *MaybeFailure;
342342
StringRef Name = MacroNameTok.getIdentifierInfo()->getName();
343-
NamingCheckId ID(MI->getDefinitionLoc(), Name);
343+
NamingCheckId ID(MI->getDefinitionLoc(), std::string(Name));
344344
NamingCheckFailure &Failure = NamingCheckFailures[ID];
345345
SourceRange Range(MacroNameTok.getLocation(), MacroNameTok.getEndLoc());
346346

@@ -351,7 +351,7 @@ void RenamerClangTidyCheck::checkMacro(SourceManager &SourceMgr,
351351
void RenamerClangTidyCheck::expandMacro(const Token &MacroNameTok,
352352
const MacroInfo *MI) {
353353
StringRef Name = MacroNameTok.getIdentifierInfo()->getName();
354-
NamingCheckId ID(MI->getDefinitionLoc(), Name);
354+
NamingCheckId ID(MI->getDefinitionLoc(), std::string(Name));
355355

356356
auto Failure = NamingCheckFailures.find(ID);
357357
if (Failure == NamingCheckFailures.end())

clang-tools-extra/clang-tidy/utils/UsingInserter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ Optional<FixItHint> UsingInserter::createUsingDeclaration(
5858
return None;
5959
}
6060
// Find conflicting declarations and references.
61-
auto ConflictingDecl = namedDecl(hasName(std::string(UnqualifiedName)));
61+
auto ConflictingDecl = namedDecl(hasName(UnqualifiedName));
6262
bool HasConflictingDeclaration =
6363
!match(findAll(ConflictingDecl), *Function, Context).empty();
6464
bool HasConflictingDeclRef =

clang-tools-extra/clangd/ClangdServer.cpp

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -316,16 +316,21 @@ void ClangdServer::prepareRename(PathRef File, Position Pos,
316316
return CB(InpAST.takeError());
317317
auto &AST = InpAST->AST;
318318
const auto &SM = AST.getSourceManager();
319-
SourceLocation Loc =
320-
SM.getMacroArgExpandedLocation(getBeginningOfIdentifier(
321-
Pos, AST.getSourceManager(), AST.getLangOpts()));
322-
auto Range = getTokenRange(SM, AST.getLangOpts(), Loc);
323-
if (!Range)
324-
return CB(llvm::None); // "rename" is not valid at the position.
319+
auto Loc = sourceLocationInMainFile(SM, Pos);
320+
if (!Loc)
321+
return CB(Loc.takeError());
322+
const auto *TouchingIdentifier =
323+
spelledIdentifierTouching(*Loc, AST.getTokens());
324+
if (!TouchingIdentifier)
325+
return CB(llvm::None); // no rename on non-identifiers.
326+
327+
auto Range = halfOpenToRange(
328+
SM, CharSourceRange::getCharRange(TouchingIdentifier->location(),
329+
TouchingIdentifier->endLocation()));
325330

326331
if (CrossFileRename)
327332
// FIXME: we now assume cross-file rename always succeeds, revisit this.
328-
return CB(*Range);
333+
return CB(Range);
329334

330335
// Performing the local rename isn't substantially more expensive than
331336
// doing an AST-based check, so we just rename and throw away the results.
@@ -338,7 +343,7 @@ void ClangdServer::prepareRename(PathRef File, Position Pos,
338343
// the message to users (VSCode does).
339344
return CB(Changes.takeError());
340345
}
341-
return CB(*Range);
346+
return CB(Range);
342347
};
343348
WorkScheduler.runWithAST("PrepareRename", File, std::move(Action));
344349
}

clang-tools-extra/clangd/ClangdServer.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -165,12 +165,6 @@ class ClangdServer {
165165
const FileSystemProvider &FSProvider, const Options &Opts,
166166
Callbacks *Callbacks = nullptr);
167167

168-
// FIXME: remove this compatibility alias.
169-
ClangdServer(const GlobalCompilationDatabase &CDB,
170-
const FileSystemProvider &FSProvider, Callbacks &Callbacks,
171-
const Options &Opts)
172-
: ClangdServer(CDB, FSProvider, Opts, &Callbacks) {}
173-
174168
/// Add a \p File to the list of tracked C++ files or update the contents if
175169
/// \p File is already tracked. Also schedules parsing of the AST for it on a
176170
/// separate thread. When the parsing is complete, DiagConsumer passed in
@@ -359,9 +353,6 @@ class ClangdServer {
359353
TUScheduler WorkScheduler;
360354
};
361355

362-
// FIXME: Remove this compatibility alias.
363-
using DiagnosticsConsumer = ClangdServer::Callbacks;
364-
365356
} // namespace clangd
366357
} // namespace clang
367358

clang-tools-extra/clangd/FindTarget.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ struct TargetFinder {
231231
}
232232

233233
void add(const Decl *Dcl, RelSet Flags) {
234-
const NamedDecl *D = llvm::dyn_cast<NamedDecl>(Dcl);
234+
const NamedDecl *D = llvm::dyn_cast_or_null<NamedDecl>(Dcl);
235235
if (!D)
236236
return;
237237
debug(*D, Flags);

clang-tools-extra/clangd/XRefs.cpp

Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "index/Relation.h"
2222
#include "index/SymbolLocation.h"
2323
#include "clang/AST/ASTContext.h"
24+
#include "clang/AST/Attr.h"
2425
#include "clang/AST/Decl.h"
2526
#include "clang/AST/DeclCXX.h"
2627
#include "clang/AST/DeclTemplate.h"
@@ -249,31 +250,17 @@ std::vector<LocatedSymbol> locateSymbolAt(ParsedAST &AST, Position Pos,
249250
return Result;
250251
}
251252

252-
// Emit all symbol locations (declaration or definition) from AST.
253-
DeclRelationSet Relations =
254-
DeclRelation::TemplatePattern | DeclRelation::Alias;
255-
for (const NamedDecl *D : getDeclAtPosition(AST, SourceLoc, Relations)) {
253+
auto AddResultDecl = [&](const NamedDecl *D) {
256254
const NamedDecl *Def = getDefinition(D);
257255
const NamedDecl *Preferred = Def ? Def : D;
258256

259-
// If we're at the point of declaration of a template specialization,
260-
// it's more useful to navigate to the template declaration.
261-
if (SM.getMacroArgExpandedLocation(Preferred->getLocation()) ==
262-
IdentStartLoc) {
263-
if (auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(Preferred)) {
264-
D = CTSD->getSpecializedTemplate();
265-
Def = getDefinition(D);
266-
Preferred = Def ? Def : D;
267-
}
268-
}
269-
270257
auto Loc = makeLocation(AST.getASTContext(), nameLocation(*Preferred, SM),
271258
*MainFilePath);
272259
if (!Loc)
273-
continue;
260+
return;
274261

275262
Result.emplace_back();
276-
Result.back().Name = printName(AST.getASTContext(), *D);
263+
Result.back().Name = printName(AST.getASTContext(), *Preferred);
277264
Result.back().PreferredDeclaration = *Loc;
278265
// Preferred is always a definition if possible, so this check works.
279266
if (Def == Preferred)
@@ -282,6 +269,37 @@ std::vector<LocatedSymbol> locateSymbolAt(ParsedAST &AST, Position Pos,
282269
// Record SymbolID for index lookup later.
283270
if (auto ID = getSymbolID(Preferred))
284271
ResultIndex[*ID] = Result.size() - 1;
272+
};
273+
274+
// Emit all symbol locations (declaration or definition) from AST.
275+
DeclRelationSet Relations =
276+
DeclRelation::TemplatePattern | DeclRelation::Alias;
277+
for (const NamedDecl *D : getDeclAtPosition(AST, SourceLoc, Relations)) {
278+
// Special case: void foo() ^override: jump to the overridden method.
279+
if (const auto *CMD = llvm::dyn_cast<CXXMethodDecl>(D)) {
280+
const auto *Attr = D->getAttr<OverrideAttr>();
281+
const syntax::Token *Tok =
282+
spelledIdentifierTouching(SourceLoc, AST.getTokens());
283+
if (Attr && Tok &&
284+
SM.getSpellingLoc(Attr->getLocation()) == Tok->location()) {
285+
// We may be overridding multiple methods - offer them all.
286+
for (const NamedDecl *ND : CMD->overridden_methods())
287+
AddResultDecl(ND);
288+
continue;
289+
}
290+
}
291+
292+
// Special case: the point of declaration of a template specialization,
293+
// it's more useful to navigate to the template declaration.
294+
if (SM.getMacroArgExpandedLocation(D->getLocation()) == IdentStartLoc) {
295+
if (auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(D)) {
296+
AddResultDecl(CTSD->getSpecializedTemplate());
297+
continue;
298+
}
299+
}
300+
301+
// Otherwise the target declaration is the right one.
302+
AddResultDecl(D);
285303
}
286304

287305
// Now query the index for all Symbol IDs we found in the AST.

clang-tools-extra/clangd/clients/clangd-vscode/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"publisher": "llvm-vs-code-extensions",
77
"homepage": "https://clang.llvm.org/extra/clangd.html",
88
"engines": {
9-
"vscode": "^1.36.0"
9+
"vscode": "^1.41.0"
1010
},
1111
"categories": [
1212
"Programming Languages",
@@ -40,9 +40,9 @@
4040
},
4141
"dependencies": {
4242
"jsonc-parser": "^2.1.0",
43-
"vscode-languageclient": "^6.0.0-next.1",
44-
"vscode-languageserver": "^6.0.0-next.1",
45-
"vscode-languageserver-types": "^3.15.0-next.5"
43+
"vscode-languageclient": "^6.1.0",
44+
"vscode-languageserver": "^6.1.0",
45+
"vscode-languageserver-types": "^3.15.1"
4646
},
4747
"devDependencies": {
4848
"@types/mocha": "^2.2.32",

0 commit comments

Comments
 (0)